diff options
Diffstat (limited to 'drivers/net/netdevsim')
-rw-r--r-- | drivers/net/netdevsim/dev.c | 44 | ||||
-rw-r--r-- | drivers/net/netdevsim/netdev.c | 29 | ||||
-rw-r--r-- | drivers/net/netdevsim/netdevsim.h | 1 |
3 files changed, 53 insertions, 21 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index b509b941d5ca..c5c417a3c0ce 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -38,6 +38,8 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) nsim_dev->ports_ddir = debugfs_create_dir("ports", nsim_dev->ddir); if (IS_ERR_OR_NULL(nsim_dev->ports_ddir)) return PTR_ERR_OR_ZERO(nsim_dev->ports_ddir) ?: -EINVAL; + debugfs_create_bool("fw_update_status", 0600, nsim_dev->ddir, + &nsim_dev->fw_update_status); return 0; } @@ -220,8 +222,49 @@ static int nsim_dev_reload(struct devlink *devlink, return 0; } +#define NSIM_DEV_FLASH_SIZE 500000 +#define NSIM_DEV_FLASH_CHUNK_SIZE 1000 +#define NSIM_DEV_FLASH_CHUNK_TIME_MS 10 + +static int nsim_dev_flash_update(struct devlink *devlink, const char *file_name, + const char *component, + struct netlink_ext_ack *extack) +{ + struct nsim_dev *nsim_dev = devlink_priv(devlink); + int i; + + if (nsim_dev->fw_update_status) { + devlink_flash_update_begin_notify(devlink); + devlink_flash_update_status_notify(devlink, + "Preparing to flash", + component, 0, 0); + } + + for (i = 0; i < NSIM_DEV_FLASH_SIZE / NSIM_DEV_FLASH_CHUNK_SIZE; i++) { + if (nsim_dev->fw_update_status) + devlink_flash_update_status_notify(devlink, "Flashing", + component, + i * NSIM_DEV_FLASH_CHUNK_SIZE, + NSIM_DEV_FLASH_SIZE); + msleep(NSIM_DEV_FLASH_CHUNK_TIME_MS); + } + + if (nsim_dev->fw_update_status) { + devlink_flash_update_status_notify(devlink, "Flashing", + component, + NSIM_DEV_FLASH_SIZE, + NSIM_DEV_FLASH_SIZE); + devlink_flash_update_status_notify(devlink, "Flashing done", + component, 0, 0); + devlink_flash_update_end_notify(devlink); + } + + return 0; +} + static const struct devlink_ops nsim_dev_devlink_ops = { .reload = nsim_dev_reload, + .flash_update = nsim_dev_flash_update, }; static struct nsim_dev * @@ -240,6 +283,7 @@ nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev, unsigned int port_count) get_random_bytes(nsim_dev->switch_id.id, nsim_dev->switch_id.id_len); INIT_LIST_HEAD(&nsim_dev->port_list); mutex_init(&nsim_dev->port_list_lock); + nsim_dev->fw_update_status = true; nsim_dev->fib_data = nsim_fib_create(); if (IS_ERR(nsim_dev->fib_data)) { diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index e5c8aa08e1cd..0740940f41b1 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -78,26 +78,6 @@ nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv); } -static int -nsim_setup_tc_block(struct net_device *dev, struct tc_block_offload *f) -{ - struct netdevsim *ns = netdev_priv(dev); - - if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS) - return -EOPNOTSUPP; - - switch (f->command) { - case TC_BLOCK_BIND: - return tcf_block_cb_register(f->block, nsim_setup_tc_block_cb, - ns, ns, f->extack); - case TC_BLOCK_UNBIND: - tcf_block_cb_unregister(f->block, nsim_setup_tc_block_cb, ns); - return 0; - default: - return -EOPNOTSUPP; - } -} - static int nsim_set_vf_mac(struct net_device *dev, int vf, u8 *mac) { struct netdevsim *ns = netdev_priv(dev); @@ -223,12 +203,19 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state) return 0; } +static LIST_HEAD(nsim_block_cb_list); + static int nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) { + struct netdevsim *ns = netdev_priv(dev); + switch (type) { case TC_SETUP_BLOCK: - return nsim_setup_tc_block(dev, type_data); + return flow_block_cb_setup_simple(type_data, + &nsim_block_cb_list, + nsim_setup_tc_block_cb, + ns, ns, true); default: return -EOPNOTSUPP; } diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 3f398797c2bc..79c05af2a7c0 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -157,6 +157,7 @@ struct nsim_dev { struct netdev_phys_item_id switch_id; struct list_head port_list; struct mutex port_list_lock; /* protects port list */ + bool fw_update_status; }; int nsim_dev_init(void); |