Skip to content

Commit 5d4f4ea

Browse files
damien-lemoalkeithbusch
authored andcommitted
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Rick Wertenbroek <[email protected]> Tested-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 30e77e0 commit 5d4f4ea

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
522522
goto out;
523523
}
524524

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);
528527

529528
memcpy(id->sn, ctrl->subsys->serial, NVMET_SN_MAX_SIZE);
530529
memcpy_and_pad(id->mn, sizeof(id->mn), subsys->model_number,

drivers/nvme/target/configfs.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,49 @@ static ssize_t nvmet_subsys_attr_cntlid_max_store(struct config_item *item,
14121412
}
14131413
CONFIGFS_ATTR(nvmet_subsys_, attr_cntlid_max);
14141414

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+
14151458
static ssize_t nvmet_subsys_attr_model_show(struct config_item *item,
14161459
char *page)
14171460
{
@@ -1640,6 +1683,8 @@ static struct configfs_attribute *nvmet_subsys_attrs[] = {
16401683
&nvmet_subsys_attr_attr_serial,
16411684
&nvmet_subsys_attr_attr_cntlid_min,
16421685
&nvmet_subsys_attr_attr_cntlid_max,
1686+
&nvmet_subsys_attr_attr_vendor_id,
1687+
&nvmet_subsys_attr_attr_subsys_vendor_id,
16431688
&nvmet_subsys_attr_attr_model,
16441689
&nvmet_subsys_attr_attr_qid_max,
16451690
&nvmet_subsys_attr_attr_ieee_oui,

drivers/nvme/target/nvmet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ struct nvmet_subsys {
324324
struct config_group namespaces_group;
325325
struct config_group allowed_hosts_group;
326326

327+
u16 vendor_id;
328+
u16 subsys_vendor_id;
327329
char *model_number;
328330
u32 ieee_oui;
329331
char *firmware_rev;

0 commit comments

Comments
 (0)