netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karsten Graul <kgraul@linux.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	hca@linux.ibm.com, raspl@linux.ibm.com
Subject: [PATCH net-next 05/15] net/smc: Add diagnostic information to smc ib-device
Date: Mon,  2 Nov 2020 20:33:59 +0100	[thread overview]
Message-ID: <20201102193409.70901-6-kgraul@linux.ibm.com> (raw)
In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com>

From: Guvenc Gulce <guvenc@linux.ibm.com>

During smc ib-device creation, add network device name to smc
ib-device structure. Register for netdevice name changes and
update ib-device accordingly. This is needed for diagnostic purposes.

Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/smc_ib.c   | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 net/smc/smc_ib.h   |  2 ++
 net/smc/smc_pnet.c |  3 +++
 3 files changed, 52 insertions(+)

diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 1c314dbdc7fa..c4a04e868bf0 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -557,6 +557,52 @@ static void smc_ib_cleanup_per_ibdev(struct smc_ib_device *smcibdev)
 
 static struct ib_client smc_ib_client;
 
+static void smc_copy_netdev_name(struct smc_ib_device *smcibdev, int port)
+{
+	struct ib_device *ibdev = smcibdev->ibdev;
+	struct net_device *ndev;
+
+	if (ibdev->ops.get_netdev) {
+		ndev = ibdev->ops.get_netdev(ibdev, port + 1);
+		if (ndev) {
+			snprintf((char *)&smcibdev->netdev[port],
+				 sizeof(smcibdev->netdev[port]),
+				 "%s", ndev->name);
+			dev_put(ndev);
+		}
+	}
+}
+
+void smc_ib_ndev_name_change(struct net_device *ndev)
+{
+	struct smc_ib_device *smcibdev;
+	struct ib_device *libdev;
+	struct net_device *lndev;
+	u8 port_cnt;
+	int i;
+
+	mutex_lock(&smc_ib_devices.mutex);
+	list_for_each_entry(smcibdev, &smc_ib_devices.list, list) {
+		port_cnt = smcibdev->ibdev->phys_port_cnt;
+		for (i = 0;
+		     i < min_t(size_t, port_cnt, SMC_MAX_PORTS);
+		     i++) {
+			libdev = smcibdev->ibdev;
+			if (libdev->ops.get_netdev) {
+				lndev = libdev->ops.get_netdev(libdev, i + 1);
+				if (lndev)
+					dev_put(lndev);
+				if (lndev == ndev) {
+					snprintf((char *)&smcibdev->netdev[i],
+						 sizeof(smcibdev->netdev[i]),
+						 "%s", ndev->name);
+				}
+			}
+		}
+	}
+	mutex_unlock(&smc_ib_devices.mutex);
+}
+
 /* callback function for ib_register_client() */
 static int smc_ib_add_dev(struct ib_device *ibdev)
 {
@@ -596,6 +642,7 @@ static int smc_ib_add_dev(struct ib_device *ibdev)
 		if (smc_pnetid_by_dev_port(ibdev->dev.parent, i,
 					   smcibdev->pnetid[i]))
 			smc_pnetid_by_table_ib(smcibdev, i + 1);
+		smc_copy_netdev_name(smcibdev, i);
 		pr_warn_ratelimited("smc:    ib device %s port %d has pnetid "
 				    "%.16s%s\n",
 				    smcibdev->ibdev->name, i + 1,
diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h
index 3e6bfeddd53b..b0868146b46b 100644
--- a/net/smc/smc_ib.h
+++ b/net/smc/smc_ib.h
@@ -54,11 +54,13 @@ struct smc_ib_device {				/* ib-device infos for smc */
 	wait_queue_head_t	lnks_deleted;	/* wait 4 removal of all links*/
 	struct mutex		mutex;		/* protect dev setup+cleanup */
 	atomic_t		lnk_cnt_by_port[SMC_MAX_PORTS];/*#lnk per port*/
+	u8			netdev[SMC_MAX_PORTS][IFNAMSIZ];/* ndev names */
 };
 
 struct smc_buf_desc;
 struct smc_link;
 
+void smc_ib_ndev_name_change(struct net_device *ndev);
 int smc_ib_register_client(void) __init;
 void smc_ib_unregister_client(void);
 bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index f3c18b991d35..b0f40d73afd6 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -828,6 +828,9 @@ static int smc_pnet_netdev_event(struct notifier_block *this,
 	case NETDEV_UNREGISTER:
 		smc_pnet_remove_by_ndev(event_dev);
 		return NOTIFY_OK;
+	case NETDEV_CHANGENAME:
+		smc_ib_ndev_name_change(event_dev);
+		return NOTIFY_OK;
 	case NETDEV_REGISTER:
 		smc_pnet_add_by_ndev(event_dev);
 		return NOTIFY_OK;
-- 
2.17.1


  parent reply	other threads:[~2020-11-02 19:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 19:33 [PATCH net-next 00/15] net/smc: extend diagnostic netlink interface Karsten Graul
2020-11-02 19:33 ` [PATCH net-next 01/15] net/smc: use helper smc_conn_abort() in listen processing Karsten Graul
2020-11-02 19:33 ` [PATCH net-next 02/15] net/smc: Use active link of the connection Karsten Graul
2020-11-02 19:33 ` [PATCH net-next 03/15] net/smc: Add connection counters for links Karsten Graul
2020-11-02 19:33 ` [PATCH net-next 04/15] net/smc: Add link counters for IB device ports Karsten Graul
2020-11-02 19:33 ` Karsten Graul [this message]
2020-11-02 19:34 ` [PATCH net-next 06/15] net/smc: Add diagnostic information to link structure Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 07/15] net/smc: Refactor the netlink reply processing routine Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 08/15] net/smc: Add ability to work with extended SMC netlink API Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 09/15] net/smc: Introduce SMCR get linkgroup command Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 10/15] net/smc: Introduce SMCR get link command Karsten Graul
2020-11-02 22:12   ` Jakub Kicinski
2020-11-03  2:20   ` kernel test robot
2020-11-02 19:34 ` [PATCH net-next 11/15] net/smc: Add SMC-D Linkgroup diagnostic support Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 12/15] net/smc: Add support for obtaining SMCD device list Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 13/15] net/smc: Add support for obtaining SMCR " Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 14/15] net/smc: Refactor smc ism v2 capability handling Karsten Graul
2020-11-02 19:34 ` [PATCH net-next 15/15] net/smc: Add support for obtaining system information Karsten Graul

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=20201102193409.70901-6-kgraul@linux.ibm.com \
    --to=kgraul@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=raspl@linux.ibm.com \
    /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).