Merge tag '5.15-rc-ksmbd-part2' of git://git.samba.org/ksmbd
[linux-2.6-microblaze.git] / drivers / target / target_core_configfs.c
index 4b2e493..102ec64 100644 (file)
@@ -1479,6 +1479,54 @@ static ssize_t target_wwn_revision_store(struct config_item *item,
        return count;
 }
 
+static ssize_t
+target_wwn_company_id_show(struct config_item *item,
+                               char *page)
+{
+       return snprintf(page, PAGE_SIZE, "%#08x\n",
+                       to_t10_wwn(item)->company_id);
+}
+
+static ssize_t
+target_wwn_company_id_store(struct config_item *item,
+                                const char *page, size_t count)
+{
+       struct t10_wwn *t10_wwn = to_t10_wwn(item);
+       struct se_device *dev = t10_wwn->t10_dev;
+       u32 val;
+       int ret;
+
+       /*
+        * The IEEE COMPANY_ID field should contain a 24-bit canonical
+        * form OUI assigned by the IEEE.
+        */
+       ret = kstrtou32(page, 0, &val);
+       if (ret < 0)
+               return ret;
+
+       if (val >= 0x1000000)
+               return -EOVERFLOW;
+
+       /*
+        * Check to see if any active exports exist. If they do exist, fail
+        * here as changing this information on the fly (underneath the
+        * initiator side OS dependent multipath code) could cause negative
+        * effects.
+        */
+       if (dev->export_count) {
+               pr_err("Unable to set Company ID while %u exports exist\n",
+                      dev->export_count);
+               return -EINVAL;
+       }
+
+       t10_wwn->company_id = val;
+
+       pr_debug("Target_Core_ConfigFS: Set IEEE Company ID: %#08x\n",
+                t10_wwn->company_id);
+
+       return count;
+}
+
 /*
  * VPD page 0x80 Unit serial
  */
@@ -1625,6 +1673,7 @@ DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20);
 CONFIGFS_ATTR(target_wwn_, vendor_id);
 CONFIGFS_ATTR(target_wwn_, product_id);
 CONFIGFS_ATTR(target_wwn_, revision);
+CONFIGFS_ATTR(target_wwn_, company_id);
 CONFIGFS_ATTR(target_wwn_, vpd_unit_serial);
 CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier);
 CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit);
@@ -1635,6 +1684,7 @@ static struct configfs_attribute *target_core_dev_wwn_attrs[] = {
        &target_wwn_attr_vendor_id,
        &target_wwn_attr_product_id,
        &target_wwn_attr_revision,
+       &target_wwn_attr_company_id,
        &target_wwn_attr_vpd_unit_serial,
        &target_wwn_attr_vpd_protocol_identifier,
        &target_wwn_attr_vpd_assoc_logical_unit,