Skip to content
Permalink
Browse files
devlink: allow driver to pass flash component name for line card device
Leverage the existing devlink flash update mechanism and allow driver
to pass a custom "component name" string identifying the line card
device to flash.

Example:
$ devlink lc show pci/0000:01:00.0 lc 8
pci/0000:01:00.0:
  lc 8 state active type 16x100G
    supported_types:
       16x100G
    devices:
      device 0 flashable true component lc8_dev0
      device 1 flashable false
      device 2 flashable false
      device 3 flashable false
$ devlink dev flash pci/0000:01:00.0 file some_file.mfa2 component lc8_dev0

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
  • Loading branch information
Jiri Pirko committed Feb 16, 2022
1 parent c6be732 commit ddbc2cda5873d87ed1bf101a45620504bfc99a5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
@@ -1575,7 +1575,8 @@ devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
void devlink_linecard_destroy(struct devlink_linecard *linecard);
struct devlink_linecard_device *
devlink_linecard_device_create(struct devlink_linecard *linecard,
unsigned int device_index, void *priv);
unsigned int device_index,
const char *flash_component, void *priv);
void
devlink_linecard_device_destroy(struct devlink_linecard *linecard,
struct devlink_linecard_device *linecard_device);
@@ -2064,6 +2064,7 @@ struct devlink_info_req {
struct devlink_linecard_device {
struct list_head list;
unsigned int index;
const char *flash_component;
void *priv;
};

@@ -2080,6 +2081,10 @@ devlink_nl_linecard_device_fill(struct sk_buff *msg,
if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX,
linecard_device->index))
return -EMSGSIZE;
if (linecard_device->flash_component &&
nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,
linecard_device->flash_component))
return -EMSGSIZE;
nla_nest_end(msg, attr);

return 0;
@@ -10498,20 +10503,24 @@ EXPORT_SYMBOL_GPL(devlink_linecard_destroy);
*
* @linecard: devlink linecard
* @device_index: index of the linecard device
* @flash_component: name of flash update component,
* NULL if unable to flash
* @priv: user priv pointer
*
* Return: Line card device structure or an ERR_PTR() encoded error code.
*/
struct devlink_linecard_device *
devlink_linecard_device_create(struct devlink_linecard *linecard,
unsigned int device_index, void *priv)
unsigned int device_index,
const char *flash_component, void *priv)
{
struct devlink_linecard_device *linecard_device;

linecard_device = kzalloc(sizeof(*linecard_device), GFP_KERNEL);
if (!linecard_device)
return ERR_PTR(-ENOMEM);
linecard_device->index = device_index;
linecard_device->flash_component = flash_component;
linecard_device->priv = priv;
mutex_lock(&linecard->devlink->lock);
list_add_tail(&linecard_device->list, &linecard->device_list);

0 comments on commit ddbc2cd

Please sign in to comment.