Message ID | 20210206125551.8616-7-parav@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | netdevsim port add, delete support | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 32 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 9f2164ea89cd..e8b6bd22fb1f 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -910,6 +910,7 @@ static const struct devlink_ops nsim_dev_devlink_ops = { .port_function_hw_addr_get = nsim_dev_port_fn_hw_addr_get, .port_function_hw_addr_set = nsim_dev_port_fn_hw_addr_set, .port_fn_state_get = nsim_dev_port_fn_state_get, + .port_fn_state_set = nsim_dev_port_fn_state_set, }; #define NSIM_DEV_MAX_MACS_DEFAULT 32 diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index c0544d93e1e8..93bfa3e946b2 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -333,3 +333,7 @@ int nsim_dev_port_fn_state_get(struct devlink *devlink, enum devlink_port_fn_state *state, enum devlink_port_fn_opstate *opstate, struct netlink_ext_ack *extack); +int nsim_dev_port_fn_state_set(struct devlink *devlink, + struct devlink_port *port, + enum devlink_port_fn_state state, + struct netlink_ext_ack *extack); diff --git a/drivers/net/netdevsim/port_function.c b/drivers/net/netdevsim/port_function.c index 10c692b8aea2..8e8e7d6df8a1 100644 --- a/drivers/net/netdevsim/port_function.c +++ b/drivers/net/netdevsim/port_function.c @@ -504,3 +504,18 @@ int nsim_dev_port_fn_state_get(struct devlink *devlink, *opstate = DEVLINK_PORT_FN_OPSTATE_ATTACHED; return 0; } + +int nsim_dev_port_fn_state_set(struct devlink *devlink, + struct devlink_port *dl_port, + enum devlink_port_fn_state state, + struct netlink_ext_ack *extack) +{ + struct nsim_dev *nsim_dev = devlink_priv(devlink); + struct nsim_port_fn *port; + + port = nsim_dev_to_port_fn(nsim_dev, dl_port, extack); + if (IS_ERR(port)) + return PTR_ERR(port); + port->state = state; + return 0; +}
Simulate port function state of a PCI port. This enables users to get and set the state of the PCI port function. Example of a PCI SF port which supports a port function: Create a device with ID=10 and one physical port. $ echo "10 1" > /sys/bus/netdevsim/new_device Add PCI PF port: $ devlink port add netdevsim/netdevsim10 flavour pcipf pfnum 2 netdevsim/netdevsim10/1: type eth netdev eth1 flavour pcipf controller 0 pfnum 2 external false splittable false function: hw_addr 00:00:00:00:00:00 $ devlink port add netdevsim/netdevsim10 flavour pcisf pfnum 2 netdevsim/netdevsim10/2: type eth netdev eth2 flavour pcisf controller 0 pfnum 2 sfnum 0 splittable false function: hw_addr 00:00:00:00:00:00 Show devlink port: $ devlink port show netdevsim/netdevsim10/2 netdevsim/netdevsim10/2: type eth netdev eth2 flavour pcisf controller 0 pfnum 2 sfnum 0 splittable false function: hw_addr 00:00:00:00:00:00 state inactive opstate detached Set the MAC address and activate the function: $ devlink port function set netdevsim/netdevsim10/2 hw_addr 00:11:22:33:44:55 state active Show the port and function attributes in JSON format: $ devlink port show netdevsim/netdevsim10/2 -jp { "port": { "netdevsim/netdevsim10/2": { "type": "eth", "netdev": "eth2", "flavour": "pcisf", "controller": 0, "pfnum": 2, "sfnum": 0, "splittable": false, "function": { "hw_addr": "00:11:22:33:44:55", "state": "active", "opstate": "attached" } } } } Signed-off-by: Parav Pandit <parav@nvidia.com> --- drivers/net/netdevsim/dev.c | 1 + drivers/net/netdevsim/netdevsim.h | 4 ++++ drivers/net/netdevsim/port_function.c | 15 +++++++++++++++ 3 files changed, 20 insertions(+)