Message ID | 20190722214023.9513-16-snelson@pensando.io |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | Add ionic driver | expand |
On Mon, 2019-07-22 at 14:40 -0700, Shannon Nelson wrote: > When the netdev gets a new name from userland, pass that name > down to the NIC for internal tracking. > Just out of curiosity, why your NIC internal device/firmware need to keep tracking of the netdev name ?
On 7/25/19 4:55 PM, Saeed Mahameed wrote: > On Mon, 2019-07-22 at 14:40 -0700, Shannon Nelson wrote: >> When the netdev gets a new name from userland, pass that name >> down to the NIC for internal tracking. >> > Just out of curiosity, why your NIC internal device/firmware need to > keep tracking of the netdev name ? > > It is helpful in a debugging method inside the NIC firmware. sln
On Mon, 22 Jul 2019 14:40:19 -0700 Shannon Nelson <snelson@pensando.io> wrote: > + > +static void ionic_lif_set_netdev_info(struct lif *lif) > +{ > + struct ionic_admin_ctx ctx = { > + .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work), > + .cmd.lif_setattr = { > + .opcode = CMD_OPCODE_LIF_SETATTR, > + .index = cpu_to_le16(lif->index), > + .attr = IONIC_LIF_ATTR_NAME, > + }, > + }; > + > + strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name, > + sizeof(ctx.cmd.lif_setattr.name)); > + > + dev_info(lif->ionic->dev, "NETDEV_CHANGENAME %s %s\n", > + lif->name, ctx.cmd.lif_setattr.name); > + There is already a kernel message for this. Repeating the same thing in the driver is redundant.
On 7/30/19 4:39 PM, Stephen Hemminger wrote: > On Mon, 22 Jul 2019 14:40:19 -0700 > Shannon Nelson <snelson@pensando.io> wrote: > >> + >> +static void ionic_lif_set_netdev_info(struct lif *lif) >> +{ >> + struct ionic_admin_ctx ctx = { >> + .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work), >> + .cmd.lif_setattr = { >> + .opcode = CMD_OPCODE_LIF_SETATTR, >> + .index = cpu_to_le16(lif->index), >> + .attr = IONIC_LIF_ATTR_NAME, >> + }, >> + }; >> + >> + strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name, >> + sizeof(ctx.cmd.lif_setattr.name)); >> + >> + dev_info(lif->ionic->dev, "NETDEV_CHANGENAME %s %s\n", >> + lif->name, ctx.cmd.lif_setattr.name); >> + > There is already a kernel message for this. Repeating the same thing in the > driver is redundant. True, except for the lif name information. But since that really is debugging information, and I was getting tired of seeing those redundant messages, I was planning to remove them soon anyway. Thanks for the extra nudge. sln
diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h index d7eee79b2a10..9b720187b549 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h @@ -42,6 +42,8 @@ struct ionic { DECLARE_BITMAP(lifbits, IONIC_LIFS_MAX); unsigned int nintrs; DECLARE_BITMAP(intrs, INTR_CTRL_REGS_MAX); + struct work_struct nb_work; + struct notifier_block nb; }; struct ionic_admin_ctx { diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 40d3b1cb362a..9e032d813269 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1954,10 +1954,69 @@ int ionic_lifs_init(struct ionic *ionic) return 0; } +static void ionic_lif_notify_work(struct work_struct *ws) +{ +} + +static void ionic_lif_set_netdev_info(struct lif *lif) +{ + struct ionic_admin_ctx ctx = { + .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work), + .cmd.lif_setattr = { + .opcode = CMD_OPCODE_LIF_SETATTR, + .index = cpu_to_le16(lif->index), + .attr = IONIC_LIF_ATTR_NAME, + }, + }; + + strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name, + sizeof(ctx.cmd.lif_setattr.name)); + + dev_info(lif->ionic->dev, "NETDEV_CHANGENAME %s %s\n", + lif->name, ctx.cmd.lif_setattr.name); + + ionic_adminq_post_wait(lif, &ctx); +} + +static struct lif *ionic_netdev_lif(struct net_device *netdev) +{ + if (!netdev || netdev->netdev_ops->ndo_start_xmit != ionic_start_xmit) + return NULL; + + return netdev_priv(netdev); +} + +static int ionic_lif_notify(struct notifier_block *nb, + unsigned long event, void *info) +{ + struct net_device *ndev = netdev_notifier_info_to_dev(info); + struct ionic *ionic = container_of(nb, struct ionic, nb); + struct lif *lif = ionic_netdev_lif(ndev); + + if (!lif || lif->ionic != ionic) + return NOTIFY_DONE; + + switch (event) { + case NETDEV_CHANGENAME: + ionic_lif_set_netdev_info(lif); + break; + } + + return NOTIFY_DONE; +} + int ionic_lifs_register(struct ionic *ionic) { int err; + INIT_WORK(&ionic->nb_work, ionic_lif_notify_work); + + ionic->nb.notifier_call = ionic_lif_notify; + + err = register_netdevice_notifier(&ionic->nb); + if (err) + ionic->nb.notifier_call = NULL; + /* only register LIF0 for now */ err = register_netdev(ionic->master_lif->netdev); if (err) { @@ -1973,6 +2032,12 @@ int ionic_lifs_register(struct ionic *ionic) void ionic_lifs_unregister(struct ionic *ionic) { + if (ionic->nb.notifier_call) { + unregister_netdevice_notifier(&ionic->nb); + cancel_work_sync(&ionic->nb_work); + ionic->nb.notifier_call = NULL; + } + /* There is only one lif ever registered in the * current model, so don't bother searching the * ionic->lif for candidates to unregister
When the netdev gets a new name from userland, pass that name down to the NIC for internal tracking. Signed-off-by: Shannon Nelson <snelson@pensando.io> --- drivers/net/ethernet/pensando/ionic/ionic.h | 2 + .../net/ethernet/pensando/ionic/ionic_lif.c | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+)