Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmet: Add vendor_id and subsys_vendor_id subsystem attributes

Define the new vendor_id and subsys_vendor_id configfs attribute for
target subsystems. These attributes are respectively reported as the
vid field and as the ssvid field of the identify controller data of
a target controllers using the subsystem for which these attributes
are set.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
Tested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Damien Le Moal and committed by
Keith Busch
5d4f4ea8 30e77e0f

+49 -3
+2 -3
drivers/nvme/target/admin-cmd.c
··· 522 522 goto out; 523 523 } 524 524 525 - /* XXX: figure out how to assign real vendors IDs. */ 526 - id->vid = 0; 527 - id->ssvid = 0; 525 + id->vid = cpu_to_le16(subsys->vendor_id); 526 + id->ssvid = cpu_to_le16(subsys->subsys_vendor_id); 528 527 529 528 memcpy(id->sn, ctrl->subsys->serial, NVMET_SN_MAX_SIZE); 530 529 memcpy_and_pad(id->mn, sizeof(id->mn), subsys->model_number,
+45
drivers/nvme/target/configfs.c
··· 1412 1412 } 1413 1413 CONFIGFS_ATTR(nvmet_subsys_, attr_cntlid_max); 1414 1414 1415 + static ssize_t nvmet_subsys_attr_vendor_id_show(struct config_item *item, 1416 + char *page) 1417 + { 1418 + return snprintf(page, PAGE_SIZE, "0x%x\n", to_subsys(item)->vendor_id); 1419 + } 1420 + 1421 + static ssize_t nvmet_subsys_attr_vendor_id_store(struct config_item *item, 1422 + const char *page, size_t count) 1423 + { 1424 + u16 vid; 1425 + 1426 + if (kstrtou16(page, 0, &vid)) 1427 + return -EINVAL; 1428 + 1429 + down_write(&nvmet_config_sem); 1430 + to_subsys(item)->vendor_id = vid; 1431 + up_write(&nvmet_config_sem); 1432 + return count; 1433 + } 1434 + CONFIGFS_ATTR(nvmet_subsys_, attr_vendor_id); 1435 + 1436 + static ssize_t nvmet_subsys_attr_subsys_vendor_id_show(struct config_item *item, 1437 + char *page) 1438 + { 1439 + return snprintf(page, PAGE_SIZE, "0x%x\n", 1440 + to_subsys(item)->subsys_vendor_id); 1441 + } 1442 + 1443 + static ssize_t nvmet_subsys_attr_subsys_vendor_id_store(struct config_item *item, 1444 + const char *page, size_t count) 1445 + { 1446 + u16 ssvid; 1447 + 1448 + if (kstrtou16(page, 0, &ssvid)) 1449 + return -EINVAL; 1450 + 1451 + down_write(&nvmet_config_sem); 1452 + to_subsys(item)->subsys_vendor_id = ssvid; 1453 + up_write(&nvmet_config_sem); 1454 + return count; 1455 + } 1456 + CONFIGFS_ATTR(nvmet_subsys_, attr_subsys_vendor_id); 1457 + 1415 1458 static ssize_t nvmet_subsys_attr_model_show(struct config_item *item, 1416 1459 char *page) 1417 1460 { ··· 1683 1640 &nvmet_subsys_attr_attr_serial, 1684 1641 &nvmet_subsys_attr_attr_cntlid_min, 1685 1642 &nvmet_subsys_attr_attr_cntlid_max, 1643 + &nvmet_subsys_attr_attr_vendor_id, 1644 + &nvmet_subsys_attr_attr_subsys_vendor_id, 1686 1645 &nvmet_subsys_attr_attr_model, 1687 1646 &nvmet_subsys_attr_attr_qid_max, 1688 1647 &nvmet_subsys_attr_attr_ieee_oui,
+2
drivers/nvme/target/nvmet.h
··· 324 324 struct config_group namespaces_group; 325 325 struct config_group allowed_hosts_group; 326 326 327 + u16 vendor_id; 328 + u16 subsys_vendor_id; 327 329 char *model_number; 328 330 u32 ieee_oui; 329 331 char *firmware_rev;