Blame SOURCES/0013-netdrv-bnxt-Implement-ndo_get_port_parent_id.patch

f95c89
From 25caba1a0368d1af60c0ee2e817d36a0d97e05e1 Mon Sep 17 00:00:00 2001
f95c89
From: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Date: Wed, 2 Oct 2019 18:22:27 -0400
f95c89
Subject: [PATCH 13/96] [netdrv] bnxt: Implement ndo_get_port_parent_id()
f95c89
f95c89
Message-id: <610919f3c6de0c97b6b178b7f643f6c81a2de24a.1570027456.git.jtoppins@redhat.com>
f95c89
Patchwork-id: 276436
f95c89
O-Subject: [RHEL-8.2 PATCH 05/78] bnxt: Implement ndo_get_port_parent_id()
f95c89
Bugzilla: 1724766
f95c89
RH-Acked-by: John Linville <linville@redhat.com>
f95c89
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
f95c89
f95c89
BNXT only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
f95c89
great candidate to be converted to use the ndo_get_port_parent_id() NDO
f95c89
instead of implementing switchdev_port_attr_get(). The conversion is
f95c89
straight forward here since the PF and VF code use the same getter.
f95c89
f95c89
Since bnxt makes uses of switchdev_port_same_parent_id() convert it to
f95c89
use netdev_port_same_parent_id().
f95c89
f95c89
Acked-by: Jiri Pirko <jiri@mellanox.com>
f95c89
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
f95c89
Signed-off-by: David S. Miller <davem@davemloft.net>
f95c89
(cherry picked from commit 52d5254a2d045bba2a744042319c64e1fe41b5c8)
f95c89
Bugzilla: 1724766
f95c89
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532
f95c89
Tested: build, boot, basic ping
f95c89
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
f95c89
---
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 28 ++++++++-------------------
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  4 ++--
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  2 +-
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 12 ++++--------
f95c89
 4 files changed, 15 insertions(+), 31 deletions(-)
f95c89
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:12.276544673 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:12.414543406 +0100
f95c89
@@ -10099,8 +10099,11 @@
f95c89
 	return 0;
f95c89
 }
f95c89
 
f95c89
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr)
f95c89
+int bnxt_get_port_parent_id(struct net_device *dev,
f95c89
+			    struct netdev_phys_item_id *ppid)
f95c89
 {
f95c89
+	struct bnxt *bp = netdev_priv(dev);
f95c89
+
f95c89
 	if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
f95c89
 		return -EOPNOTSUPP;
f95c89
 
f95c89
@@ -10108,27 +10111,12 @@
f95c89
 	if (!BNXT_PF(bp))
f95c89
 		return -EOPNOTSUPP;
f95c89
 
f95c89
-	switch (attr->id) {
f95c89
-	case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
f95c89
-		attr->u.ppid.id_len = sizeof(bp->switch_id);
f95c89
-		memcpy(attr->u.ppid.id, bp->switch_id, attr->u.ppid.id_len);
f95c89
-		break;
f95c89
-	default:
f95c89
-		return -EOPNOTSUPP;
f95c89
-	}
f95c89
-	return 0;
f95c89
-}
f95c89
+	ppid->id_len = sizeof(bp->switch_id);
f95c89
+	memcpy(ppid->id, bp->switch_id, ppid->id_len);
f95c89
 
f95c89
-static int bnxt_swdev_port_attr_get(struct net_device *dev,
f95c89
-				    struct switchdev_attr *attr)
f95c89
-{
f95c89
-	return bnxt_port_attr_get(netdev_priv(dev), attr);
f95c89
+	return 0;
f95c89
 }
f95c89
 
f95c89
-static const struct switchdev_ops bnxt_switchdev_ops = {
f95c89
-	.switchdev_port_attr_get	= bnxt_swdev_port_attr_get
f95c89
-};
f95c89
-
f95c89
 static const struct net_device_ops bnxt_netdev_ops = {
f95c89
 	.ndo_open		= bnxt_open,
f95c89
 	.ndo_start_xmit		= bnxt_start_xmit,
f95c89
@@ -10160,6 +10148,7 @@
f95c89
 	.ndo_bpf		= bnxt_xdp,
f95c89
 	.ndo_bridge_getlink	= bnxt_bridge_getlink,
f95c89
 	.ndo_bridge_setlink	= bnxt_bridge_setlink,
f95c89
+	.ndo_get_port_parent_id	= bnxt_get_port_parent_id,
f95c89
 	.ndo_get_phys_port_name = bnxt_get_phys_port_name
f95c89
 };
f95c89
 
f95c89
@@ -10518,7 +10507,6 @@
f95c89
 	dev->netdev_ops = &bnxt_netdev_ops;
f95c89
 	dev->watchdog_timeo = BNXT_TX_TIMEOUT;
f95c89
 	dev->ethtool_ops = &bnxt_ethtool_ops;
f95c89
-	SWITCHDEV_SET_OPS(dev, &bnxt_switchdev_ops);
f95c89
 	pci_set_drvdata(pdev, dev);
f95c89
 
f95c89
 	rc = bnxt_alloc_hwrm_resources(bp);
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.h
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.h	2020-02-06 16:23:11.133555165 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.h	2020-02-06 16:23:12.415543397 +0100
f95c89
@@ -23,7 +23,6 @@
f95c89
 #include <linux/crash_dump.h>
f95c89
 #include <net/devlink.h>
f95c89
 #include <net/dst_metadata.h>
f95c89
-#include <net/switchdev.h>
f95c89
 #include <net/xdp.h>
f95c89
 #include <linux/net_dim.h>
f95c89
 
f95c89
@@ -1799,7 +1798,8 @@
f95c89
 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
f95c89
 int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
f95c89
 int bnxt_restore_pf_fw_resources(struct bnxt *bp);
f95c89
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr);
f95c89
+int bnxt_get_port_parent_id(struct net_device *dev,
f95c89
+			    struct netdev_phys_item_id *ppid);
f95c89
 void bnxt_dim_work(struct work_struct *work);
f95c89
 int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
f95c89
 
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c	2020-02-06 16:22:57.079684168 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c	2020-02-06 16:23:12.415543397 +0100
f95c89
@@ -45,7 +45,7 @@
f95c89
 	struct bnxt *bp;
f95c89
 
f95c89
 	/* check if dev belongs to the same switch */
f95c89
-	if (!switchdev_port_same_parent_id(pf_bp->dev, dev)) {
f95c89
+	if (!netdev_port_same_parent_id(pf_bp->dev, dev)) {
f95c89
 		netdev_info(pf_bp->dev, "dev(ifindex=%d) not on same switch",
f95c89
 			    dev->ifindex);
f95c89
 		return BNXT_FID_INVALID;
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c	2020-02-06 16:22:57.079684168 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c	2020-02-06 16:23:12.415543397 +0100
f95c89
@@ -237,21 +237,17 @@
f95c89
 	strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
f95c89
 }
f95c89
 
f95c89
-static int bnxt_vf_rep_port_attr_get(struct net_device *dev,
f95c89
-				     struct switchdev_attr *attr)
f95c89
+static int bnxt_vf_rep_get_port_parent_id(struct net_device *dev,
f95c89
+					  struct netdev_phys_item_id *ppid)
f95c89
 {
f95c89
 	struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
f95c89
 
f95c89
 	/* as only PORT_PARENT_ID is supported currently use common code
f95c89
 	 * between PF and VF-rep for now.
f95c89
 	 */
f95c89
-	return bnxt_port_attr_get(vf_rep->bp, attr);
f95c89
+	return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid);
f95c89
 }
f95c89
 
f95c89
-static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = {
f95c89
-	.switchdev_port_attr_get	= bnxt_vf_rep_port_attr_get
f95c89
-};
f95c89
-
f95c89
 static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = {
f95c89
 	.get_drvinfo		= bnxt_vf_rep_get_drvinfo
f95c89
 };
f95c89
@@ -262,6 +258,7 @@
f95c89
 	.ndo_start_xmit		= bnxt_vf_rep_xmit,
f95c89
 	.ndo_get_stats64	= bnxt_vf_rep_get_stats64,
f95c89
 	.ndo_setup_tc		= bnxt_vf_rep_setup_tc,
f95c89
+	.ndo_get_port_parent_id	= bnxt_vf_rep_get_port_parent_id,
f95c89
 	.ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name
f95c89
 };
f95c89
 
f95c89
@@ -392,7 +389,6 @@
f95c89
 
f95c89
 	dev->netdev_ops = &bnxt_vf_rep_netdev_ops;
f95c89
 	dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops;
f95c89
-	SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops);
f95c89
 	/* Just inherit all the featues of the parent PF as the VF-R
f95c89
 	 * uses the RX/TX rings of the parent PF
f95c89
 	 */