Skip to content

Commit 52d5254

Browse files
ffainellidavem330
authored andcommitted
bnxt: Implement ndo_get_port_parent_id()
BNXT only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a great candidate to be converted to use the ndo_get_port_parent_id() NDO instead of implementing switchdev_port_attr_get(). The conversion is straight forward here since the PF and VF code use the same getter. Since bnxt makes uses of switchdev_port_same_parent_id() convert it to use netdev_port_same_parent_id(). Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d6abc59 commit 52d5254

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9981,36 +9981,24 @@ static int bnxt_get_phys_port_name(struct net_device *dev, char *buf,
99819981
return 0;
99829982
}
99839983

9984-
int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr)
9984+
int bnxt_get_port_parent_id(struct net_device *dev,
9985+
struct netdev_phys_item_id *ppid)
99859986
{
9987+
struct bnxt *bp = netdev_priv(dev);
9988+
99869989
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
99879990
return -EOPNOTSUPP;
99889991

99899992
/* The PF and it's VF-reps only support the switchdev framework */
99909993
if (!BNXT_PF(bp))
99919994
return -EOPNOTSUPP;
99929995

9993-
switch (attr->id) {
9994-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
9995-
attr->u.ppid.id_len = sizeof(bp->switch_id);
9996-
memcpy(attr->u.ppid.id, bp->switch_id, attr->u.ppid.id_len);
9997-
break;
9998-
default:
9999-
return -EOPNOTSUPP;
10000-
}
10001-
return 0;
10002-
}
9996+
ppid->id_len = sizeof(bp->switch_id);
9997+
memcpy(ppid->id, bp->switch_id, ppid->id_len);
100039998

10004-
static int bnxt_swdev_port_attr_get(struct net_device *dev,
10005-
struct switchdev_attr *attr)
10006-
{
10007-
return bnxt_port_attr_get(netdev_priv(dev), attr);
9999+
return 0;
1000810000
}
1000910001

10010-
static const struct switchdev_ops bnxt_switchdev_ops = {
10011-
.switchdev_port_attr_get = bnxt_swdev_port_attr_get
10012-
};
10013-
1001410002
static const struct net_device_ops bnxt_netdev_ops = {
1001510003
.ndo_open = bnxt_open,
1001610004
.ndo_start_xmit = bnxt_start_xmit,
@@ -10042,6 +10030,7 @@ static const struct net_device_ops bnxt_netdev_ops = {
1004210030
.ndo_bpf = bnxt_xdp,
1004310031
.ndo_bridge_getlink = bnxt_bridge_getlink,
1004410032
.ndo_bridge_setlink = bnxt_bridge_setlink,
10033+
.ndo_get_port_parent_id = bnxt_get_port_parent_id,
1004510034
.ndo_get_phys_port_name = bnxt_get_phys_port_name
1004610035
};
1004710036

@@ -10400,7 +10389,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1040010389
dev->netdev_ops = &bnxt_netdev_ops;
1040110390
dev->watchdog_timeo = BNXT_TX_TIMEOUT;
1040210391
dev->ethtool_ops = &bnxt_ethtool_ops;
10403-
SWITCHDEV_SET_OPS(dev, &bnxt_switchdev_ops);
1040410392
pci_set_drvdata(pdev, dev);
1040510393

1040610394
rc = bnxt_alloc_hwrm_resources(bp);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/rhashtable.h>
2323
#include <net/devlink.h>
2424
#include <net/dst_metadata.h>
25-
#include <net/switchdev.h>
2625
#include <net/xdp.h>
2726
#include <linux/net_dim.h>
2827

@@ -1795,7 +1794,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
17951794
int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
17961795
int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
17971796
int bnxt_restore_pf_fw_resources(struct bnxt *bp);
1798-
int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr);
1797+
int bnxt_get_port_parent_id(struct net_device *dev,
1798+
struct netdev_phys_item_id *ppid);
17991799
void bnxt_dim_work(struct work_struct *work);
18001800
int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
18011801

drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct net_device *dev)
4545
struct bnxt *bp;
4646

4747
/* check if dev belongs to the same switch */
48-
if (!switchdev_port_same_parent_id(pf_bp->dev, dev)) {
48+
if (!netdev_port_same_parent_id(pf_bp->dev, dev)) {
4949
netdev_info(pf_bp->dev, "dev(ifindex=%d) not on same switch",
5050
dev->ifindex);
5151
return BNXT_FID_INVALID;

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,17 @@ static void bnxt_vf_rep_get_drvinfo(struct net_device *dev,
237237
strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
238238
}
239239

240-
static int bnxt_vf_rep_port_attr_get(struct net_device *dev,
241-
struct switchdev_attr *attr)
240+
static int bnxt_vf_rep_get_port_parent_id(struct net_device *dev,
241+
struct netdev_phys_item_id *ppid)
242242
{
243243
struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
244244

245245
/* as only PORT_PARENT_ID is supported currently use common code
246246
* between PF and VF-rep for now.
247247
*/
248-
return bnxt_port_attr_get(vf_rep->bp, attr);
248+
return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid);
249249
}
250250

251-
static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = {
252-
.switchdev_port_attr_get = bnxt_vf_rep_port_attr_get
253-
};
254-
255251
static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = {
256252
.get_drvinfo = bnxt_vf_rep_get_drvinfo
257253
};
@@ -262,6 +258,7 @@ static const struct net_device_ops bnxt_vf_rep_netdev_ops = {
262258
.ndo_start_xmit = bnxt_vf_rep_xmit,
263259
.ndo_get_stats64 = bnxt_vf_rep_get_stats64,
264260
.ndo_setup_tc = bnxt_vf_rep_setup_tc,
261+
.ndo_get_port_parent_id = bnxt_vf_rep_get_port_parent_id,
265262
.ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name
266263
};
267264

@@ -392,7 +389,6 @@ static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct bnxt_vf_rep *vf_rep,
392389

393390
dev->netdev_ops = &bnxt_vf_rep_netdev_ops;
394391
dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops;
395-
SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops);
396392
/* Just inherit all the featues of the parent PF as the VF-R
397393
* uses the RX/TX rings of the parent PF
398394
*/

0 commit comments

Comments
 (0)