diff options
author | Sathya Perla <sathya.perla@broadcom.com> | 2018-01-17 03:21:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-17 14:48:27 -0500 |
commit | dd4ea1da12495e1b3c400a28df11528892199f68 (patch) | |
tree | 446ca2ddda30292c928de253112aee3e74f21f02 | |
parent | c3480a603773cfc5d8aa44dbbee6c96e0f9d4d9d (diff) |
bnxt_en: export a common switchdev PARENT_ID for all reps of an adapter
Currently the driver exports different switchdev PARENT_IDs for
representors belonging to different SR-IOV PF-pools of an adapter.
This is not correct as the adapter can switch across all vports
of an adapter. This patch fixes this by exporting a common switchdev
PARENT_ID for all reps of an adapter. The PCIE DSN is used as the id.
Signed-off-by: Sathya Perla <sathya.perla@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 30 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | 6 |
5 files changed, 40 insertions, 7 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 77df92aa489d..6b7e99675571 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
@@ -8149,12 +8149,8 @@ int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr) | |||
8149 | 8149 | ||
8150 | switch (attr->id) { | 8150 | switch (attr->id) { |
8151 | case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: | 8151 | case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: |
8152 | /* In SRIOV each PF-pool (PF + child VFs) serves as a | 8152 | attr->u.ppid.id_len = sizeof(bp->switch_id); |
8153 | * switching domain, the PF's perm mac-addr can be used | 8153 | memcpy(attr->u.ppid.id, bp->switch_id, attr->u.ppid.id_len); |
8154 | * as the unique parent-id | ||
8155 | */ | ||
8156 | attr->u.ppid.id_len = ETH_ALEN; | ||
8157 | ether_addr_copy(attr->u.ppid.id, bp->pf.mac_addr); | ||
8158 | break; | 8154 | break; |
8159 | default: | 8155 | default: |
8160 | return -EOPNOTSUPP; | 8156 | return -EOPNOTSUPP; |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 0b30dcc37adb..1989c470172c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h | |||
@@ -1371,6 +1371,7 @@ struct bnxt { | |||
1371 | enum devlink_eswitch_mode eswitch_mode; | 1371 | enum devlink_eswitch_mode eswitch_mode; |
1372 | struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */ | 1372 | struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */ |
1373 | u16 *cfa_code_map; /* cfa_code -> vf_idx map */ | 1373 | u16 *cfa_code_map; /* cfa_code -> vf_idx map */ |
1374 | u8 switch_id[8]; | ||
1374 | struct bnxt_tc_info *tc_info; | 1375 | struct bnxt_tc_info *tc_info; |
1375 | }; | 1376 | }; |
1376 | 1377 | ||
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index 1d9b08c20f95..2ece1645f55d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | |||
@@ -43,7 +43,7 @@ static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct net_device *dev) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | /* Is dev a VF-rep? */ | 45 | /* Is dev a VF-rep? */ |
46 | if (dev != pf_bp->dev) | 46 | if (bnxt_dev_is_vf_rep(dev)) |
47 | return bnxt_vf_rep_get_fid(dev); | 47 | return bnxt_vf_rep_get_fid(dev); |
48 | 48 | ||
49 | bp = netdev_priv(dev); | 49 | bp = netdev_priv(dev); |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index 69186d188c43..2ca11be64182 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | |||
@@ -241,6 +241,11 @@ static const struct net_device_ops bnxt_vf_rep_netdev_ops = { | |||
241 | .ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name | 241 | .ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name |
242 | }; | 242 | }; |
243 | 243 | ||
244 | bool bnxt_dev_is_vf_rep(struct net_device *dev) | ||
245 | { | ||
246 | return dev->netdev_ops == &bnxt_vf_rep_netdev_ops; | ||
247 | } | ||
248 | |||
244 | /* Called when the parent PF interface is closed: | 249 | /* Called when the parent PF interface is closed: |
245 | * As the mode transition from SWITCHDEV to LEGACY | 250 | * As the mode transition from SWITCHDEV to LEGACY |
246 | * happens under the rtnl_lock() this routine is safe | 251 | * happens under the rtnl_lock() this routine is safe |
@@ -376,6 +381,26 @@ static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, | |||
376 | ether_addr_copy(dev->dev_addr, dev->perm_addr); | 381 | ether_addr_copy(dev->dev_addr, dev->perm_addr); |
377 | } | 382 | } |
378 | 383 | ||
384 | static int bnxt_pcie_dsn_get(struct bnxt *bp, u8 dsn[]) | ||
385 | { | ||
386 | struct pci_dev *pdev = bp->pdev; | ||
387 | int pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DSN); | ||
388 | u32 dw; | ||
389 | |||
390 | if (!pos) { | ||
391 | netdev_info(bp->dev, "Unable do read adapter's DSN"); | ||
392 | return -EOPNOTSUPP; | ||
393 | } | ||
394 | |||
395 | /* DSN (two dw) is at an offset of 4 from the cap pos */ | ||
396 | pos += 4; | ||
397 | pci_read_config_dword(pdev, pos, &dw); | ||
398 | put_unaligned_le32(dw, &dsn[0]); | ||
399 | pci_read_config_dword(pdev, pos + 4, &dw); | ||
400 | put_unaligned_le32(dw, &dsn[4]); | ||
401 | return 0; | ||
402 | } | ||
403 | |||
379 | static int bnxt_vf_reps_create(struct bnxt *bp) | 404 | static int bnxt_vf_reps_create(struct bnxt *bp) |
380 | { | 405 | { |
381 | u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev); | 406 | u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev); |
@@ -440,6 +465,11 @@ static int bnxt_vf_reps_create(struct bnxt *bp) | |||
440 | } | 465 | } |
441 | } | 466 | } |
442 | 467 | ||
468 | /* Read the adapter's DSN to use as the eswitch switch_id */ | ||
469 | rc = bnxt_pcie_dsn_get(bp, bp->switch_id); | ||
470 | if (rc) | ||
471 | goto err; | ||
472 | |||
443 | /* publish cfa_code_map only after all VF-reps have been initialized */ | 473 | /* publish cfa_code_map only after all VF-reps have been initialized */ |
444 | bp->cfa_code_map = cfa_code_map; | 474 | bp->cfa_code_map = cfa_code_map; |
445 | bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; | 475 | bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h index fb06bbe70e42..38b9a75ad724 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | |||
@@ -28,6 +28,7 @@ static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev) | |||
28 | return bp->pf.vf[vf_rep->vf_idx].fw_fid; | 28 | return bp->pf.vf[vf_rep->vf_idx].fw_fid; |
29 | } | 29 | } |
30 | 30 | ||
31 | bool bnxt_dev_is_vf_rep(struct net_device *dev); | ||
31 | int bnxt_dl_eswitch_mode_get(struct devlink *devlink, u16 *mode); | 32 | int bnxt_dl_eswitch_mode_get(struct devlink *devlink, u16 *mode); |
32 | int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode); | 33 | int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode); |
33 | 34 | ||
@@ -54,5 +55,10 @@ static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev) | |||
54 | { | 55 | { |
55 | return 0; | 56 | return 0; |
56 | } | 57 | } |
58 | |||
59 | static inline bool bnxt_dev_is_vf_rep(struct net_device *dev) | ||
60 | { | ||
61 | return false; | ||
62 | } | ||
57 | #endif /* CONFIG_BNXT_SRIOV */ | 63 | #endif /* CONFIG_BNXT_SRIOV */ |
58 | #endif /* BNXT_VFR_H */ | 64 | #endif /* BNXT_VFR_H */ |