Skip to content

Commit 1a371ea

Browse files
emuslndavem330
authored andcommitted
ionic: Add netdev-event handling
When the netdev gets a new name from userland, pass that name down to the NIC for internal tracking. Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0f3154e commit 1a371ea

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

drivers/net/ethernet/pensando/ionic/ionic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct ionic {
4444
DECLARE_BITMAP(lifbits, IONIC_LIFS_MAX);
4545
unsigned int nintrs;
4646
DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
47+
struct work_struct nb_work;
48+
struct notifier_block nb;
4749
};
4850

4951
struct ionic_admin_ctx {

drivers/net/ethernet/pensando/ionic/ionic_lif.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,10 +1955,66 @@ int ionic_lifs_init(struct ionic *ionic)
19551955
return 0;
19561956
}
19571957

1958+
static void ionic_lif_notify_work(struct work_struct *ws)
1959+
{
1960+
}
1961+
1962+
static void ionic_lif_set_netdev_info(struct ionic_lif *lif)
1963+
{
1964+
struct ionic_admin_ctx ctx = {
1965+
.work = COMPLETION_INITIALIZER_ONSTACK(ctx.work),
1966+
.cmd.lif_setattr = {
1967+
.opcode = IONIC_CMD_LIF_SETATTR,
1968+
.index = cpu_to_le16(lif->index),
1969+
.attr = IONIC_LIF_ATTR_NAME,
1970+
},
1971+
};
1972+
1973+
strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name,
1974+
sizeof(ctx.cmd.lif_setattr.name));
1975+
1976+
ionic_adminq_post_wait(lif, &ctx);
1977+
}
1978+
1979+
static struct ionic_lif *ionic_netdev_lif(struct net_device *netdev)
1980+
{
1981+
if (!netdev || netdev->netdev_ops->ndo_start_xmit != ionic_start_xmit)
1982+
return NULL;
1983+
1984+
return netdev_priv(netdev);
1985+
}
1986+
1987+
static int ionic_lif_notify(struct notifier_block *nb,
1988+
unsigned long event, void *info)
1989+
{
1990+
struct net_device *ndev = netdev_notifier_info_to_dev(info);
1991+
struct ionic *ionic = container_of(nb, struct ionic, nb);
1992+
struct ionic_lif *lif = ionic_netdev_lif(ndev);
1993+
1994+
if (!lif || lif->ionic != ionic)
1995+
return NOTIFY_DONE;
1996+
1997+
switch (event) {
1998+
case NETDEV_CHANGENAME:
1999+
ionic_lif_set_netdev_info(lif);
2000+
break;
2001+
}
2002+
2003+
return NOTIFY_DONE;
2004+
}
2005+
19582006
int ionic_lifs_register(struct ionic *ionic)
19592007
{
19602008
int err;
19612009

2010+
INIT_WORK(&ionic->nb_work, ionic_lif_notify_work);
2011+
2012+
ionic->nb.notifier_call = ionic_lif_notify;
2013+
2014+
err = register_netdevice_notifier(&ionic->nb);
2015+
if (err)
2016+
ionic->nb.notifier_call = NULL;
2017+
19622018
/* only register LIF0 for now */
19632019
err = register_netdev(ionic->master_lif->netdev);
19642020
if (err) {
@@ -1974,6 +2030,12 @@ int ionic_lifs_register(struct ionic *ionic)
19742030

19752031
void ionic_lifs_unregister(struct ionic *ionic)
19762032
{
2033+
if (ionic->nb.notifier_call) {
2034+
unregister_netdevice_notifier(&ionic->nb);
2035+
cancel_work_sync(&ionic->nb_work);
2036+
ionic->nb.notifier_call = NULL;
2037+
}
2038+
19772039
/* There is only one lif ever registered in the
19782040
* current model, so don't bother searching the
19792041
* ionic->lif for candidates to unregister

0 commit comments

Comments
 (0)