nvmet: expose IEEE OUI to configfs
Allow user to set OUI for the controller vendor. Reviewed-by: Konstantin Shelekhin <k.shelekhin@yadro.com> Reviewed-by: Dmitriy Bogdanov <d.bogdanov@yadro.com> Signed-off-by: Aleksandr Miloserdov <a.miloserdov@yadro.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
9f27bd701d
commit
23855abdc4
@ -372,6 +372,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
|
||||
memcpy_and_pad(id->fr, sizeof(id->fr),
|
||||
UTS_RELEASE, strlen(UTS_RELEASE), ' ');
|
||||
|
||||
put_unaligned_le24(subsys->ieee_oui, id->ieee);
|
||||
|
||||
id->rab = 6;
|
||||
|
||||
if (nvmet_is_disc_subsys(ctrl->subsys))
|
||||
@ -379,11 +381,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
|
||||
else
|
||||
id->cntrltype = NVME_CTRL_IO;
|
||||
|
||||
/*
|
||||
* XXX: figure out how we can assign a IEEE OUI, but until then
|
||||
* the safest is to leave it as zeroes.
|
||||
*/
|
||||
|
||||
/* we support multiple ports, multiples hosts and ANA: */
|
||||
id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
|
||||
NVME_CTRL_CMIC_ANA;
|
||||
|
@ -1259,6 +1259,54 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
|
||||
}
|
||||
CONFIGFS_ATTR(nvmet_subsys_, attr_model);
|
||||
|
||||
static ssize_t nvmet_subsys_attr_ieee_oui_show(struct config_item *item,
|
||||
char *page)
|
||||
{
|
||||
struct nvmet_subsys *subsys = to_subsys(item);
|
||||
|
||||
return sysfs_emit(page, "0x%06x\n", subsys->ieee_oui);
|
||||
}
|
||||
|
||||
static ssize_t nvmet_subsys_attr_ieee_oui_store_locked(struct nvmet_subsys *subsys,
|
||||
const char *page, size_t count)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
int ret;
|
||||
|
||||
if (subsys->subsys_discovered) {
|
||||
pr_err("Can't set IEEE OUI. 0x%06x is already assigned\n",
|
||||
subsys->ieee_oui);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = kstrtou32(page, 0, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (val >= 0x1000000)
|
||||
return -EINVAL;
|
||||
|
||||
subsys->ieee_oui = val;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t nvmet_subsys_attr_ieee_oui_store(struct config_item *item,
|
||||
const char *page, size_t count)
|
||||
{
|
||||
struct nvmet_subsys *subsys = to_subsys(item);
|
||||
ssize_t ret;
|
||||
|
||||
down_write(&nvmet_config_sem);
|
||||
mutex_lock(&subsys->lock);
|
||||
ret = nvmet_subsys_attr_ieee_oui_store_locked(subsys, page, count);
|
||||
mutex_unlock(&subsys->lock);
|
||||
up_write(&nvmet_config_sem);
|
||||
|
||||
return ret;
|
||||
}
|
||||
CONFIGFS_ATTR(nvmet_subsys_, attr_ieee_oui);
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_INTEGRITY
|
||||
static ssize_t nvmet_subsys_attr_pi_enable_show(struct config_item *item,
|
||||
char *page)
|
||||
@ -1320,6 +1368,7 @@ static struct configfs_attribute *nvmet_subsys_attrs[] = {
|
||||
&nvmet_subsys_attr_attr_cntlid_max,
|
||||
&nvmet_subsys_attr_attr_model,
|
||||
&nvmet_subsys_attr_attr_qid_max,
|
||||
&nvmet_subsys_attr_attr_ieee_oui,
|
||||
#ifdef CONFIG_BLK_DEV_INTEGRITY
|
||||
&nvmet_subsys_attr_attr_pi_enable,
|
||||
#endif
|
||||
|
@ -1561,6 +1561,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
|
||||
goto free_subsys;
|
||||
}
|
||||
|
||||
subsys->ieee_oui = 0;
|
||||
|
||||
switch (type) {
|
||||
case NVME_NQN_NVME:
|
||||
subsys->max_qid = NVMET_NR_QUEUES;
|
||||
|
@ -263,6 +263,7 @@ struct nvmet_subsys {
|
||||
struct config_group allowed_hosts_group;
|
||||
|
||||
char *model_number;
|
||||
u32 ieee_oui;
|
||||
|
||||
#ifdef CONFIG_NVME_TARGET_PASSTHRU
|
||||
struct nvme_ctrl *passthru_ctrl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user