From: Shannon Nelson <snelson@pensando.io>
To: snelson@pensando.io, netdev@vger.kernel.org
Subject: [PATCH v3 net-next 15/19] ionic: Add netdev-event handling
Date: Mon, 8 Jul 2019 12:25:28 -0700 [thread overview]
Message-ID: <20190708192532.27420-16-snelson@pensando.io> (raw)
In-Reply-To: <20190708192532.27420-1-snelson@pensando.io>
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(+)
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
--
2.17.1
next prev parent reply other threads:[~2019-07-08 19:26 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-08 19:25 [PATCH v3 net-next 00/19] Add ionic driver Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 01/19] ionic: Add basic framework for IONIC Network device driver Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 02/19] ionic: Add hardware init and device commands Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 03/19] ionic: Add port management commands Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 04/19] ionic: Add basic lif support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 05/19] ionic: Add interrupts and doorbells Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 06/19] ionic: Add basic adminq support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 07/19] ionic: Add adminq action Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 08/19] ionic: Add notifyq support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 09/19] ionic: Add the basic NDO callbacks for netdev support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 10/19] ionic: Add management of rx filters Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 11/19] ionic: Add Rx filter and rx_mode ndo support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 12/19] ionic: Add async link status check and basic stats Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 13/19] ionic: Add initial ethtool support Shannon Nelson
2019-07-08 22:04 ` Andrew Lunn
2019-07-09 5:15 ` Michal Kubecek
2019-07-09 22:35 ` Shannon Nelson
2019-07-11 19:10 ` Shannon Nelson
2019-07-09 2:14 ` Andrew Lunn
2019-07-13 5:16 ` Shannon Nelson
2019-07-18 3:28 ` Andrew Lunn
2019-07-19 0:12 ` Shannon Nelson
2019-07-19 2:40 ` Andrew Lunn
2019-07-19 18:41 ` Shannon Nelson
2019-07-19 19:07 ` Andrew Lunn
2019-07-19 20:20 ` Shannon Nelson
2019-07-09 2:27 ` Andrew Lunn
2019-07-09 22:42 ` Shannon Nelson
2019-07-18 3:21 ` Andrew Lunn
2019-07-18 17:05 ` Shannon Nelson
2019-07-18 17:28 ` Andrew Lunn
2019-07-18 17:54 ` Shannon Nelson
2019-07-09 2:30 ` Andrew Lunn
2019-07-13 5:32 ` Shannon Nelson
2019-07-18 3:31 ` Andrew Lunn
2019-07-18 17:14 ` Shannon Nelson
2019-07-09 5:25 ` Michal Kubecek
2019-07-09 22:34 ` Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 14/19] ionic: Add Tx and Rx handling Shannon Nelson
2019-07-08 19:25 ` Shannon Nelson [this message]
2019-07-08 19:25 ` [PATCH v3 net-next 16/19] ionic: Add driver stats Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 17/19] ionic: Add RSS support Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 18/19] ionic: Add coalesce and other features Shannon Nelson
2019-07-08 19:25 ` [PATCH v3 net-next 19/19] ionic: Add basic devlink interface Shannon Nelson
2019-07-08 19:34 ` Jiri Pirko
2019-07-08 19:58 ` Shannon Nelson
2019-07-08 20:03 ` Jiri Pirko
2019-07-08 22:58 ` Shannon Nelson
2019-07-09 6:56 ` Jiri Pirko
2019-07-09 19:13 ` Shannon Nelson
2019-07-10 6:48 ` Jiri Pirko
2019-07-10 17:06 ` Shannon Nelson
2019-07-09 1:26 ` Jakub Kicinski
2019-07-09 19:06 ` Shannon Nelson
2019-07-09 2:58 ` [PATCH v3 net-next 00/19] Add ionic driver David Miller
2019-07-09 3:01 ` Shannon Nelson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190708192532.27420-16-snelson@pensando.io \
--to=snelson@pensando.io \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).