On Wed, Jan 13, 2021 at 01:12:13PM +0100, Jiri Pirko wrote: > diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h > index cf89c318f2ac..e5ed0522591f 100644 > --- a/include/uapi/linux/devlink.h > +++ b/include/uapi/linux/devlink.h > @@ -126,6 +126,11 @@ enum devlink_command { > > DEVLINK_CMD_HEALTH_REPORTER_TEST, > > + DEVLINK_CMD_LINECARD_GET, /* can dump */ > + DEVLINK_CMD_LINECARD_SET,
Never used (but should) > + DEVLINK_CMD_LINECARD_NEW, > + DEVLINK_CMD_LINECARD_DEL, > + > /* add new commands above here */ > __DEVLINK_CMD_MAX, > DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 > @@ -529,6 +534,8 @@ enum devlink_attr { > DEVLINK_ATTR_RELOAD_ACTION_INFO, /* nested */ > DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */ > > + DEVLINK_ATTR_LINECARD_INDEX, /* u32 */ > + > /* add new attributes above here, update the policy in devlink.c */ > > __DEVLINK_ATTR_MAX, [...] > > +/** > + * devlink_linecard_register - Register devlink linecard Does not match function name > + * > + * @devlink: devlink > + * @devlink_linecard: devlink linecard > + * @linecard_index: driver-specific numerical identifier of the linecard > + * > + * Create devlink linecard instance with provided linecard index. > + * Caller can use any indexing, even hw-related one. > + */ > +struct devlink_linecard *devlink_linecard_create(struct devlink *devlink, > + unsigned int linecard_index) > +{ > + struct devlink_linecard *linecard; > + > + mutex_lock(&devlink->lock); > + if (devlink_linecard_index_exists(devlink, linecard_index)) { > + mutex_unlock(&devlink->lock); > + return ERR_PTR(-EEXIST); > + } > + > + linecard = kzalloc(sizeof(*linecard), GFP_KERNEL); > + if (!linecard) > + return ERR_PTR(-ENOMEM); > + > + linecard->devlink = devlink; > + linecard->index = linecard_index; > + list_add_tail(&linecard->list, &devlink->linecard_list); > + mutex_unlock(&devlink->lock); > + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); > + return linecard; > +} > +EXPORT_SYMBOL_GPL(devlink_linecard_create); > + > +/** > + * devlink_linecard_destroy - Destroy devlink linecard > + * > + * @devlink_linecard: devlink linecard > + */ > +void devlink_linecard_destroy(struct devlink_linecard *linecard) > +{ > + struct devlink *devlink = linecard->devlink; > + > + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); > + mutex_lock(&devlink->lock); > + list_del(&linecard->list); > + mutex_unlock(&devlink->lock); > +} > +EXPORT_SYMBOL_GPL(devlink_linecard_create); > + > int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, > u32 size, u16 ingress_pools_count, > u16 egress_pools_count, u16 ingress_tc_count, > -- > 2.26.2 >