diff options
author | Parav Pandit <parav@nvidia.com> | 2021-06-07 22:24:06 +0300 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2021-06-11 02:28:49 +0000 |
commit | fbd4b581cb4161c21fea5125e1c902c105e3aa30 (patch) | |
tree | 80e144621cd2d1ba0ecc708e85e1a604d5214a50 /devlink | |
parent | 0d5cf51e0d6c7bfdc51754381b85367b5f8e254a (diff) | |
download | iproute2-fbd4b581cb4161c21fea5125e1c902c105e3aa30.tar.gz |
devlink: Add optional controller user input
A user optionally provides the external controller number when user
wants to create devlink port for the external controller.
An example on eswitch system:
$ devlink dev eswitch set pci/0033:01:00.0 mode switchdev
$ devlink port show
pci/0033:01:00.0/196607: type eth netdev enP51p1s0f0np0 flavour physical port 0 splittable false
pci/0033:01:00.0/131072: type eth netdev eth0 flavour pcipf controller 1 pfnum 0 external true splittable false
function:
hw_addr 00:00:00:00:00:00
$ devlink port add pci/0033:01:00.0 flavour pcisf pfnum 0 sfnum 77 controller 1
pci/0033:01:00.0/163840: type eth netdev eth1 flavour pcisf controller 1 pfnum 0 sfnum 77 external true splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
Diffstat (limited to 'devlink')
-rw-r--r-- | devlink/devlink.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/devlink/devlink.c b/devlink/devlink.c index 0b5548fb..9218576f 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -286,6 +286,7 @@ static void ifname_map_free(struct ifname_map *ifname_map) #define DL_OPT_PORT_PFNUMBER BIT(43) #define DL_OPT_PORT_SFNUMBER BIT(44) #define DL_OPT_PORT_FUNCTION_STATE BIT(45) +#define DL_OPT_PORT_CONTROLLER BIT(46) struct dl_opts { uint64_t present; /* flags of present items */ @@ -336,6 +337,7 @@ struct dl_opts { uint32_t overwrite_mask; enum devlink_reload_action reload_action; enum devlink_reload_limit reload_limit; + uint32_t port_controller; uint32_t port_sfnumber; uint16_t port_flavour; uint16_t port_pfnumber; @@ -1886,6 +1888,12 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required, if (err) return err; o_found |= DL_OPT_PORT_SFNUMBER; + } else if (dl_argv_match(dl, "controller") && (o_all & DL_OPT_PORT_CONTROLLER)) { + dl_arg_inc(dl); + err = dl_argv_uint32_t(dl, &opts->port_controller); + if (err) + return err; + o_found |= DL_OPT_PORT_CONTROLLER; } else { pr_err("Unknown option \"%s\"\n", dl_argv(dl)); return -EINVAL; @@ -2079,6 +2087,9 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl) mnl_attr_put_u16(nlh, DEVLINK_ATTR_PORT_PCI_PF_NUMBER, opts->port_pfnumber); if (opts->present & DL_OPT_PORT_SFNUMBER) mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_PCI_SF_NUMBER, opts->port_sfnumber); + if (opts->present & DL_OPT_PORT_CONTROLLER) + mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_CONTROLLER_NUMBER, + opts->port_controller); } static int dl_argv_parse_put(struct nlmsghdr *nlh, struct dl *dl, @@ -3795,7 +3806,8 @@ static void cmd_port_help(void) pr_err(" devlink port param set DEV/PORT_INDEX name PARAMETER value VALUE cmode { permanent | driverinit | runtime }\n"); pr_err(" devlink port param show [DEV/PORT_INDEX name PARAMETER]\n"); pr_err(" devlink port health show [ DEV/PORT_INDEX reporter REPORTER_NAME ]\n"); - pr_err(" devlink port add DEV/PORT_INDEX flavour FLAVOUR pfnum PFNUM [ sfnum SFNUM ]\n"); + pr_err(" devlink port add DEV/PORT_INDEX flavour FLAVOUR pfnum PFNUM\n" + " [ sfnum SFNUM ][ controller CNUM ]\n"); pr_err(" devlink port del DEV/PORT_INDEX\n"); } @@ -4324,7 +4336,8 @@ static int __cmd_health_show(struct dl *dl, bool show_device, bool show_port); static void cmd_port_add_help(void) { - pr_err(" devlink port add { DEV | DEV/PORT_INDEX } flavour FLAVOUR pfnum PFNUM [ sfnum SFNUM ]\n"); + pr_err(" devlink port add DEV/PORT_INDEX flavour FLAVOUR pfnum PFNUM\n" + " [ sfnum SFNUM ][ controller CNUM ]\n"); } static int cmd_port_add(struct dl *dl) @@ -4342,7 +4355,7 @@ static int cmd_port_add(struct dl *dl) err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE | DL_OPT_HANDLEP | DL_OPT_PORT_FLAVOUR | DL_OPT_PORT_PFNUMBER, - DL_OPT_PORT_SFNUMBER); + DL_OPT_PORT_SFNUMBER | DL_OPT_PORT_CONTROLLER); if (err) return err; |