Skip to content

Commit 230d00e

Browse files
Yuval Mintzdavem330
authored andcommitted
bnx2x: new Multi-function mode - BD
This adds support to a new multi-function mode, enabling driver to initialize such devices and correctly interacting with management FW for fully utilizing their features. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 924c621 commit 230d00e

File tree

8 files changed

+251
-15
lines changed

8 files changed

+251
-15
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,7 @@ enum {
14241424
SUB_MF_MODE_UNKNOWN = 0,
14251425
SUB_MF_MODE_UFP,
14261426
SUB_MF_MODE_NPAR1_DOT_5,
1427+
SUB_MF_MODE_BD,
14271428
};
14281429

14291430
struct bnx2x {
@@ -1638,6 +1639,8 @@ struct bnx2x {
16381639
u8 mf_sub_mode;
16391640
#define IS_MF_UFP(bp) (IS_MF_SD(bp) && \
16401641
bp->mf_sub_mode == SUB_MF_MODE_UFP)
1642+
#define IS_MF_BD(bp) (IS_MF_SD(bp) && \
1643+
bp->mf_sub_mode == SUB_MF_MODE_BD)
16411644

16421645
u8 wol;
16431646

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,20 @@ static void bnx2x_bz_fp(struct bnx2x *bp, int index)
25172517
fp->mode = TPA_MODE_DISABLED;
25182518
}
25192519

2520+
void bnx2x_set_os_driver_state(struct bnx2x *bp, u32 state)
2521+
{
2522+
u32 cur;
2523+
2524+
if (!IS_MF_BD(bp) || !SHMEM2_HAS(bp, os_driver_state) || IS_VF(bp))
2525+
return;
2526+
2527+
cur = SHMEM2_RD(bp, os_driver_state[BP_FW_MB_IDX(bp)]);
2528+
DP(NETIF_MSG_IFUP, "Driver state %08x-->%08x\n",
2529+
cur, state);
2530+
2531+
SHMEM2_WR(bp, os_driver_state[BP_FW_MB_IDX(bp)], state);
2532+
}
2533+
25202534
int bnx2x_load_cnic(struct bnx2x *bp)
25212535
{
25222536
int i, rc, port = BP_PORT(bp);
@@ -2880,6 +2894,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
28802894
/* mark driver is loaded in shmem2 */
28812895
u32 val;
28822896
val = SHMEM2_RD(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)]);
2897+
val &= ~DRV_FLAGS_MTU_MASK;
2898+
val |= (bp->dev->mtu << DRV_FLAGS_MTU_SHIFT);
28832899
SHMEM2_WR(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)],
28842900
val | DRV_FLAGS_CAPABILITIES_LOADED_SUPPORTED |
28852901
DRV_FLAGS_CAPABILITIES_LOADED_L2);
@@ -2896,6 +2912,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
28962912
if (bp->port.pmf && (bp->state != BNX2X_STATE_DIAG))
28972913
bnx2x_dcbx_init(bp, false);
28982914

2915+
if (!IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp))
2916+
bnx2x_set_os_driver_state(bp, OS_DRIVER_STATE_ACTIVE);
2917+
28992918
DP(NETIF_MSG_IFUP, "Ending successfully NIC load\n");
29002919

29012920
return 0;
@@ -2963,6 +2982,9 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
29632982

29642983
DP(NETIF_MSG_IFUP, "Starting NIC unload\n");
29652984

2985+
if (!IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp))
2986+
bnx2x_set_os_driver_state(bp, OS_DRIVER_STATE_DISABLED);
2987+
29662988
/* mark driver is unloaded in shmem2 */
29672989
if (IS_PF(bp) && SHMEM2_HAS(bp, drv_capabilities_flag)) {
29682990
u32 val;
@@ -4191,6 +4213,41 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
41914213
return NETDEV_TX_OK;
41924214
}
41934215

4216+
void bnx2x_get_c2s_mapping(struct bnx2x *bp, u8 *c2s_map, u8 *c2s_default)
4217+
{
4218+
int mfw_vn = BP_FW_MB_IDX(bp);
4219+
u32 tmp;
4220+
4221+
/* If the shmem shouldn't affect configuration, reflect */
4222+
if (!IS_MF_BD(bp)) {
4223+
int i;
4224+
4225+
for (i = 0; i < BNX2X_MAX_PRIORITY; i++)
4226+
c2s_map[i] = i;
4227+
*c2s_default = 0;
4228+
4229+
return;
4230+
}
4231+
4232+
tmp = SHMEM2_RD(bp, c2s_pcp_map_lower[mfw_vn]);
4233+
tmp = (__force u32)be32_to_cpu((__force __be32)tmp);
4234+
c2s_map[0] = tmp & 0xff;
4235+
c2s_map[1] = (tmp >> 8) & 0xff;
4236+
c2s_map[2] = (tmp >> 16) & 0xff;
4237+
c2s_map[3] = (tmp >> 24) & 0xff;
4238+
4239+
tmp = SHMEM2_RD(bp, c2s_pcp_map_upper[mfw_vn]);
4240+
tmp = (__force u32)be32_to_cpu((__force __be32)tmp);
4241+
c2s_map[4] = tmp & 0xff;
4242+
c2s_map[5] = (tmp >> 8) & 0xff;
4243+
c2s_map[6] = (tmp >> 16) & 0xff;
4244+
c2s_map[7] = (tmp >> 24) & 0xff;
4245+
4246+
tmp = SHMEM2_RD(bp, c2s_pcp_map_default[mfw_vn]);
4247+
tmp = (__force u32)be32_to_cpu((__force __be32)tmp);
4248+
*c2s_default = (tmp >> (8 * mfw_vn)) & 0xff;
4249+
}
4250+
41944251
/**
41954252
* bnx2x_setup_tc - routine to configure net_device for multi tc
41964253
*
@@ -4201,8 +4258,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
42014258
*/
42024259
int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)
42034260
{
4204-
int cos, prio, count, offset;
42054261
struct bnx2x *bp = netdev_priv(dev);
4262+
u8 c2s_map[BNX2X_MAX_PRIORITY], c2s_def;
4263+
int cos, prio, count, offset;
42064264

42074265
/* setup tc must be called under rtnl lock */
42084266
ASSERT_RTNL();
@@ -4226,12 +4284,16 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)
42264284
return -EINVAL;
42274285
}
42284286

4287+
bnx2x_get_c2s_mapping(bp, c2s_map, &c2s_def);
4288+
42294289
/* configure priority to traffic class mapping */
42304290
for (prio = 0; prio < BNX2X_MAX_PRIORITY; prio++) {
4231-
netdev_set_prio_tc_map(dev, prio, bp->prio_to_cos[prio]);
4291+
int outer_prio = c2s_map[prio];
4292+
4293+
netdev_set_prio_tc_map(dev, prio, bp->prio_to_cos[outer_prio]);
42324294
DP(BNX2X_MSG_SP | NETIF_MSG_IFUP,
42334295
"mapping priority %d to tc %d\n",
4234-
prio, bp->prio_to_cos[prio]);
4296+
outer_prio, bp->prio_to_cos[outer_prio]);
42354297
}
42364298

42374299
/* Use this configuration to differentiate tc0 from other COSes
@@ -4285,6 +4347,9 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
42854347
if (netif_running(dev))
42864348
rc = bnx2x_set_eth_mac(bp, true);
42874349

4350+
if (IS_PF(bp) && SHMEM2_HAS(bp, curr_cfg))
4351+
SHMEM2_WR(bp, curr_cfg, CURR_CFG_MET_OS);
4352+
42884353
return rc;
42894354
}
42904355

@@ -4838,6 +4903,9 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
48384903
*/
48394904
dev->mtu = new_mtu;
48404905

4906+
if (IS_PF(bp) && SHMEM2_HAS(bp, curr_cfg))
4907+
SHMEM2_WR(bp, curr_cfg, CURR_CFG_MET_OS);
4908+
48414909
return bnx2x_reload_if_running(dev);
48424910
}
48434911

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,14 @@ int bnx2x_set_features(struct net_device *dev, netdev_features_t features);
622622
*/
623623
void bnx2x_tx_timeout(struct net_device *dev);
624624

625+
/** bnx2x_get_c2s_mapping - read inner-to-outer vlan configuration
626+
* c2s_map should have BNX2X_MAX_PRIORITY entries.
627+
* @bp: driver handle
628+
* @c2s_map: should have BNX2X_MAX_PRIORITY entries for mapping
629+
* @c2s_default: entry for non-tagged configuration
630+
*/
631+
void bnx2x_get_c2s_mapping(struct bnx2x *bp, u8 *c2s_map, u8 *c2s_default);
632+
625633
/*********************** Inlines **********************************/
626634
/*********************** Fast path ********************************/
627635
static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
@@ -933,6 +941,27 @@ static inline int bnx2x_func_start(struct bnx2x *bp)
933941
start_params->mf_mode = bp->mf_mode;
934942
start_params->sd_vlan_tag = bp->mf_ov;
935943

944+
/* Configure Ethertype for BD mode */
945+
if (IS_MF_BD(bp)) {
946+
DP(NETIF_MSG_IFUP, "Configuring ethertype 0x88a8 for BD\n");
947+
start_params->sd_vlan_eth_type = ETH_P_8021AD;
948+
REG_WR(bp, PRS_REG_VLAN_TYPE_0, ETH_P_8021AD);
949+
REG_WR(bp, PBF_REG_VLAN_TYPE_0, ETH_P_8021AD);
950+
REG_WR(bp, NIG_REG_LLH_E1HOV_TYPE_1, ETH_P_8021AD);
951+
952+
bnx2x_get_c2s_mapping(bp, start_params->c2s_pri,
953+
&start_params->c2s_pri_default);
954+
start_params->c2s_pri_valid = 1;
955+
956+
DP(NETIF_MSG_IFUP,
957+
"Inner-to-Outer priority: %02x %02x %02x %02x %02x %02x %02x %02x [Default %02x]\n",
958+
start_params->c2s_pri[0], start_params->c2s_pri[1],
959+
start_params->c2s_pri[2], start_params->c2s_pri[3],
960+
start_params->c2s_pri[4], start_params->c2s_pri[5],
961+
start_params->c2s_pri[6], start_params->c2s_pri[7],
962+
start_params->c2s_pri_default);
963+
}
964+
936965
if (CHIP_IS_E2(bp) || CHIP_IS_E3(bp))
937966
start_params->network_cos_mode = STATIC_COS;
938967
else /* CHIP_IS_E1X */
@@ -1339,4 +1368,11 @@ void bnx2x_squeeze_objects(struct bnx2x *bp);
13391368
void bnx2x_schedule_sp_rtnl(struct bnx2x*, enum sp_rtnl_flag,
13401369
u32 verbose);
13411370

1371+
/**
1372+
* bnx2x_set_os_driver_state - write driver state for management FW usage
1373+
*
1374+
* @bp: driver handle
1375+
* @state: OS_DRIVER_STATE_* value reflecting current driver state
1376+
*/
1377+
void bnx2x_set_os_driver_state(struct bnx2x *bp, u32 state);
13421378
#endif /* BNX2X_CMN_H */

drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,9 @@ static int bnx2x_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
11311131
} else
11321132
bp->wol = 0;
11331133

1134+
if (SHMEM2_HAS(bp, curr_cfg))
1135+
SHMEM2_WR(bp, curr_cfg, CURR_CFG_MET_OS);
1136+
11341137
return 0;
11351138
}
11361139

drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ struct shared_feat_cfg { /* NVRAM Offset */
868868
#define SHARED_FEAT_CFG_FORCE_SF_MODE_SPIO4 0x00000200
869869
#define SHARED_FEAT_CFG_FORCE_SF_MODE_SWITCH_INDEPT 0x00000300
870870
#define SHARED_FEAT_CFG_FORCE_SF_MODE_AFEX_MODE 0x00000400
871+
#define SHARED_FEAT_CFG_FORCE_SF_MODE_BD_MODE 0x00000500
871872
#define SHARED_FEAT_CFG_FORCE_SF_MODE_UFP_MODE 0x00000600
872873
#define SHARED_FEAT_CFG_FORCE_SF_MODE_EXTENDED_MODE 0x00000700
873874

@@ -2068,6 +2069,12 @@ struct ncsi_oem_fcoe_features {
20682069
#define FCOE_FEATURES4_FEATURE_SETTINGS_OFFSET 0
20692070
};
20702071

2072+
enum curr_cfg_method_e {
2073+
CURR_CFG_MET_NONE = 0, /* default config */
2074+
CURR_CFG_MET_OS = 1,
2075+
CURR_CFG_MET_VENDOR_SPEC = 2,/* e.g. Option ROM, NPAR, O/S Cfg Utils */
2076+
};
2077+
20712078
struct ncsi_oem_data {
20722079
u32 driver_version[4];
20732080
struct ncsi_oem_fcoe_features ncsi_oem_fcoe_features;
@@ -2191,6 +2198,8 @@ struct shmem2_region {
21912198
#define DRV_FLAGS_CAPABILITIES_LOADED_L2 0x00000002
21922199
#define DRV_FLAGS_CAPABILITIES_LOADED_FCOE 0x00000004
21932200
#define DRV_FLAGS_CAPABILITIES_LOADED_ISCSI 0x00000008
2201+
#define DRV_FLAGS_MTU_MASK 0xffff0000
2202+
#define DRV_FLAGS_MTU_SHIFT 16
21942203

21952204
u32 extended_dev_info_shared_cfg_size;
21962205

@@ -2273,6 +2282,71 @@ struct shmem2_region {
22732282

22742283
/* We use indication for each PF (0..3) */
22752284
#define MFW_DRV_IND_READ_DONE_OFFSET(_pf_) (1 << (_pf_))
2285+
union { /* For various OEMs */ /* Offset 0x1a0 */
2286+
u8 storage_boot_prog[E2_FUNC_MAX];
2287+
#define STORAGE_BOOT_PROG_MASK 0x000000FF
2288+
#define STORAGE_BOOT_PROG_NONE 0x00000000
2289+
#define STORAGE_BOOT_PROG_ISCSI_IP_ACQUIRED 0x00000002
2290+
#define STORAGE_BOOT_PROG_FCOE_FABRIC_LOGIN_SUCCESS 0x00000002
2291+
#define STORAGE_BOOT_PROG_TARGET_FOUND 0x00000004
2292+
#define STORAGE_BOOT_PROG_ISCSI_CHAP_SUCCESS 0x00000008
2293+
#define STORAGE_BOOT_PROG_FCOE_LUN_FOUND 0x00000008
2294+
#define STORAGE_BOOT_PROG_LOGGED_INTO_TGT 0x00000010
2295+
#define STORAGE_BOOT_PROG_IMG_DOWNLOADED 0x00000020
2296+
#define STORAGE_BOOT_PROG_OS_HANDOFF 0x00000040
2297+
#define STORAGE_BOOT_PROG_COMPLETED 0x00000080
2298+
2299+
u32 oem_i2c_data_addr;
2300+
};
2301+
2302+
/* 9 entires for the C2S PCP map for each inner VLAN PCP + 1 default */
2303+
/* For PCP values 0-3 use the map lower */
2304+
/* 0xFF000000 - PCP 0, 0x00FF0000 - PCP 1,
2305+
* 0x0000FF00 - PCP 2, 0x000000FF PCP 3
2306+
*/
2307+
u32 c2s_pcp_map_lower[E2_FUNC_MAX]; /* 0x1a4 */
2308+
2309+
/* For PCP values 4-7 use the map upper */
2310+
/* 0xFF000000 - PCP 4, 0x00FF0000 - PCP 5,
2311+
* 0x0000FF00 - PCP 6, 0x000000FF PCP 7
2312+
*/
2313+
u32 c2s_pcp_map_upper[E2_FUNC_MAX]; /* 0x1b4 */
2314+
2315+
/* For PCP default value get the MSB byte of the map default */
2316+
u32 c2s_pcp_map_default[E2_FUNC_MAX]; /* 0x1c4 */
2317+
2318+
/* FC_NPIV table offset in NVRAM */
2319+
u32 fc_npiv_nvram_tbl_addr[PORT_MAX]; /* 0x1d4 */
2320+
2321+
/* Shows last method that changed configuration of this device */
2322+
enum curr_cfg_method_e curr_cfg; /* 0x1dc */
2323+
2324+
/* Storm FW version, shold be kept in the format 0xMMmmbbdd:
2325+
* MM - Major, mm - Minor, bb - Build ,dd - Drop
2326+
*/
2327+
u32 netproc_fw_ver; /* 0x1e0 */
2328+
2329+
/* Option ROM SMASH CLP version */
2330+
u32 clp_ver; /* 0x1e4 */
2331+
2332+
u32 pcie_bus_num; /* 0x1e8 */
2333+
2334+
u32 sriov_switch_mode; /* 0x1ec */
2335+
#define SRIOV_SWITCH_MODE_NONE 0x0
2336+
#define SRIOV_SWITCH_MODE_VEB 0x1
2337+
#define SRIOV_SWITCH_MODE_VEPA 0x2
2338+
2339+
u8 rsrv2[E2_FUNC_MAX]; /* 0x1f0 */
2340+
2341+
u32 img_inv_table_addr; /* Address to INV_TABLE_P */ /* 0x1f4 */
2342+
2343+
u32 mtu_size[E2_FUNC_MAX]; /* 0x1f8 */
2344+
2345+
u32 os_driver_state[E2_FUNC_MAX]; /* 0x208 */
2346+
#define OS_DRIVER_STATE_NOT_LOADED 0 /* not installed */
2347+
#define OS_DRIVER_STATE_LOADING 1 /* transition state */
2348+
#define OS_DRIVER_STATE_DISABLED 2 /* installed but disabled */
2349+
#define OS_DRIVER_STATE_ACTIVE 3 /* installed and active */
22762350
};
22772351

22782352

0 commit comments

Comments
 (0)