diff options
author | Vladislav Zolotarov <vladz@broadcom.com> | 2011-01-31 09:39:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-31 23:44:46 -0500 |
commit | 2ba451421b23636c45fabfa522858c5c124b3673 (patch) | |
tree | fc576f3ac8a064b50747533522940f05e39f70c1 /drivers/net/bnx2x | |
parent | 0c838ff1ade71162775afffd9e5c6478a60bdca6 (diff) |
bnx2x, cnic: Consolidate iSCSI/FCoE shared mem logic in bnx2x
Move all shared mem code to bnx2x to avoid code duplication. bnx2x now
performs:
- Read the FCoE and iSCSI max connection information.
- Read the iSCSI and FCoE MACs from NPAR configuration in shmem.
- Block the CNIC for the current function if there is neither FCoE nor
iSCSI valid configuration by returning NULL from bnx2x_cnic_probe().
Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x')
-rw-r--r-- | drivers/net/bnx2x/bnx2x.h | 5 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_hsi.h | 25 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_main.c | 112 |
3 files changed, 120 insertions, 22 deletions
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index 04fb72b923b2..ff87ec33d00e 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h | |||
@@ -976,8 +976,12 @@ struct bnx2x { | |||
976 | #define MF_FUNC_DIS 0x1000 | 976 | #define MF_FUNC_DIS 0x1000 |
977 | #define FCOE_MACS_SET 0x2000 | 977 | #define FCOE_MACS_SET 0x2000 |
978 | #define NO_FCOE_FLAG 0x4000 | 978 | #define NO_FCOE_FLAG 0x4000 |
979 | #define NO_ISCSI_OOO_FLAG 0x8000 | ||
980 | #define NO_ISCSI_FLAG 0x10000 | ||
979 | 981 | ||
980 | #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG) | 982 | #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG) |
983 | #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG) | ||
984 | #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG) | ||
981 | 985 | ||
982 | int pf_num; /* absolute PF number */ | 986 | int pf_num; /* absolute PF number */ |
983 | int pfid; /* per-path PF number */ | 987 | int pfid; /* per-path PF number */ |
@@ -1125,7 +1129,6 @@ struct bnx2x { | |||
1125 | u16 cnic_kwq_pending; | 1129 | u16 cnic_kwq_pending; |
1126 | u16 cnic_spq_pending; | 1130 | u16 cnic_spq_pending; |
1127 | struct mutex cnic_mutex; | 1131 | struct mutex cnic_mutex; |
1128 | u8 iscsi_mac[ETH_ALEN]; | ||
1129 | u8 fip_mac[ETH_ALEN]; | 1132 | u8 fip_mac[ETH_ALEN]; |
1130 | #endif | 1133 | #endif |
1131 | 1134 | ||
diff --git a/drivers/net/bnx2x/bnx2x_hsi.h b/drivers/net/bnx2x/bnx2x_hsi.h index 51d69db23a71..be503cc0a50b 100644 --- a/drivers/net/bnx2x/bnx2x_hsi.h +++ b/drivers/net/bnx2x/bnx2x_hsi.h | |||
@@ -11,20 +11,27 @@ | |||
11 | 11 | ||
12 | #include "bnx2x_fw_defs.h" | 12 | #include "bnx2x_fw_defs.h" |
13 | 13 | ||
14 | #define FW_ENCODE_32BIT_PATTERN 0x1e1e1e1e | ||
15 | |||
14 | struct license_key { | 16 | struct license_key { |
15 | u32 reserved[6]; | 17 | u32 reserved[6]; |
16 | 18 | ||
17 | #if defined(__BIG_ENDIAN) | 19 | u32 max_iscsi_conn; |
18 | u16 max_iscsi_init_conn; | 20 | #define BNX2X_MAX_ISCSI_TRGT_CONN_MASK 0xFFFF |
19 | u16 max_iscsi_trgt_conn; | 21 | #define BNX2X_MAX_ISCSI_TRGT_CONN_SHIFT 0 |
20 | #elif defined(__LITTLE_ENDIAN) | 22 | #define BNX2X_MAX_ISCSI_INIT_CONN_MASK 0xFFFF0000 |
21 | u16 max_iscsi_trgt_conn; | 23 | #define BNX2X_MAX_ISCSI_INIT_CONN_SHIFT 16 |
22 | u16 max_iscsi_init_conn; | ||
23 | #endif | ||
24 | 24 | ||
25 | u32 reserved_a[6]; | 25 | u32 reserved_a; |
26 | }; | 26 | |
27 | u32 max_fcoe_conn; | ||
28 | #define BNX2X_MAX_FCOE_TRGT_CONN_MASK 0xFFFF | ||
29 | #define BNX2X_MAX_FCOE_TRGT_CONN_SHIFT 0 | ||
30 | #define BNX2X_MAX_FCOE_INIT_CONN_MASK 0xFFFF0000 | ||
31 | #define BNX2X_MAX_FCOE_INIT_CONN_SHIFT 16 | ||
27 | 32 | ||
33 | u32 reserved_b[4]; | ||
34 | }; | ||
28 | 35 | ||
29 | #define PORT_0 0 | 36 | #define PORT_0 0 |
30 | #define PORT_1 1 | 37 | #define PORT_1 1 |
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index 2215a39f74fb..ae8d20a2b4fc 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -6456,12 +6456,13 @@ static int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set) | |||
6456 | u32 iscsi_l2_cl_id = BNX2X_ISCSI_ETH_CL_ID + | 6456 | u32 iscsi_l2_cl_id = BNX2X_ISCSI_ETH_CL_ID + |
6457 | BP_E1HVN(bp) * NONE_ETH_CONTEXT_USE; | 6457 | BP_E1HVN(bp) * NONE_ETH_CONTEXT_USE; |
6458 | u32 cl_bit_vec = (1 << iscsi_l2_cl_id); | 6458 | u32 cl_bit_vec = (1 << iscsi_l2_cl_id); |
6459 | u8 *iscsi_mac = bp->cnic_eth_dev.iscsi_mac; | ||
6459 | 6460 | ||
6460 | /* Send a SET_MAC ramrod */ | 6461 | /* Send a SET_MAC ramrod */ |
6461 | bnx2x_set_mac_addr_gen(bp, set, bp->iscsi_mac, cl_bit_vec, | 6462 | bnx2x_set_mac_addr_gen(bp, set, iscsi_mac, cl_bit_vec, |
6462 | cam_offset, 0); | 6463 | cam_offset, 0); |
6463 | 6464 | ||
6464 | bnx2x_set_mac_in_nig(bp, set, bp->iscsi_mac, LLH_CAM_ISCSI_ETH_LINE); | 6465 | bnx2x_set_mac_in_nig(bp, set, iscsi_mac, LLH_CAM_ISCSI_ETH_LINE); |
6465 | 6466 | ||
6466 | return 0; | 6467 | return 0; |
6467 | } | 6468 | } |
@@ -8385,11 +8386,47 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) | |||
8385 | bp->common.shmem2_base); | 8386 | bp->common.shmem2_base); |
8386 | } | 8387 | } |
8387 | 8388 | ||
8389 | #ifdef BCM_CNIC | ||
8390 | static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) | ||
8391 | { | ||
8392 | u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, | ||
8393 | drv_lic_key[BP_PORT(bp)].max_iscsi_conn); | ||
8394 | u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, | ||
8395 | drv_lic_key[BP_PORT(bp)].max_fcoe_conn); | ||
8396 | |||
8397 | /* Get the number of maximum allowed iSCSI and FCoE connections */ | ||
8398 | bp->cnic_eth_dev.max_iscsi_conn = | ||
8399 | (max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >> | ||
8400 | BNX2X_MAX_ISCSI_INIT_CONN_SHIFT; | ||
8401 | |||
8402 | bp->cnic_eth_dev.max_fcoe_conn = | ||
8403 | (max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >> | ||
8404 | BNX2X_MAX_FCOE_INIT_CONN_SHIFT; | ||
8405 | |||
8406 | BNX2X_DEV_INFO("max_iscsi_conn 0x%x max_fcoe_conn 0x%x\n", | ||
8407 | bp->cnic_eth_dev.max_iscsi_conn, | ||
8408 | bp->cnic_eth_dev.max_fcoe_conn); | ||
8409 | |||
8410 | /* If mamimum allowed number of connections is zero - | ||
8411 | * disable the feature. | ||
8412 | */ | ||
8413 | if (!bp->cnic_eth_dev.max_iscsi_conn) | ||
8414 | bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; | ||
8415 | |||
8416 | if (!bp->cnic_eth_dev.max_fcoe_conn) | ||
8417 | bp->flags |= NO_FCOE_FLAG; | ||
8418 | } | ||
8419 | #endif | ||
8420 | |||
8388 | static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | 8421 | static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) |
8389 | { | 8422 | { |
8390 | u32 val, val2; | 8423 | u32 val, val2; |
8391 | int func = BP_ABS_FUNC(bp); | 8424 | int func = BP_ABS_FUNC(bp); |
8392 | int port = BP_PORT(bp); | 8425 | int port = BP_PORT(bp); |
8426 | #ifdef BCM_CNIC | ||
8427 | u8 *iscsi_mac = bp->cnic_eth_dev.iscsi_mac; | ||
8428 | u8 *fip_mac = bp->fip_mac; | ||
8429 | #endif | ||
8393 | 8430 | ||
8394 | if (BP_NOMCP(bp)) { | 8431 | if (BP_NOMCP(bp)) { |
8395 | BNX2X_ERROR("warning: random MAC workaround active\n"); | 8432 | BNX2X_ERROR("warning: random MAC workaround active\n"); |
@@ -8402,7 +8439,9 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | |||
8402 | bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2); | 8439 | bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2); |
8403 | 8440 | ||
8404 | #ifdef BCM_CNIC | 8441 | #ifdef BCM_CNIC |
8405 | /* iSCSI NPAR MAC */ | 8442 | /* iSCSI and FCoE NPAR MACs: if there is no either iSCSI or |
8443 | * FCoE MAC then the appropriate feature should be disabled. | ||
8444 | */ | ||
8406 | if (IS_MF_SI(bp)) { | 8445 | if (IS_MF_SI(bp)) { |
8407 | u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); | 8446 | u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); |
8408 | if (cfg & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) { | 8447 | if (cfg & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) { |
@@ -8410,8 +8449,39 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | |||
8410 | iscsi_mac_addr_upper); | 8449 | iscsi_mac_addr_upper); |
8411 | val = MF_CFG_RD(bp, func_ext_config[func]. | 8450 | val = MF_CFG_RD(bp, func_ext_config[func]. |
8412 | iscsi_mac_addr_lower); | 8451 | iscsi_mac_addr_lower); |
8413 | bnx2x_set_mac_buf(bp->iscsi_mac, val, val2); | 8452 | BNX2X_DEV_INFO("Read iSCSI MAC: " |
8414 | } | 8453 | "0x%x:0x%04x\n", val2, val); |
8454 | bnx2x_set_mac_buf(iscsi_mac, val, val2); | ||
8455 | |||
8456 | /* Disable iSCSI OOO if MAC configuration is | ||
8457 | * invalid. | ||
8458 | */ | ||
8459 | if (!is_valid_ether_addr(iscsi_mac)) { | ||
8460 | bp->flags |= NO_ISCSI_OOO_FLAG | | ||
8461 | NO_ISCSI_FLAG; | ||
8462 | memset(iscsi_mac, 0, ETH_ALEN); | ||
8463 | } | ||
8464 | } else | ||
8465 | bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; | ||
8466 | |||
8467 | if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) { | ||
8468 | val2 = MF_CFG_RD(bp, func_ext_config[func]. | ||
8469 | fcoe_mac_addr_upper); | ||
8470 | val = MF_CFG_RD(bp, func_ext_config[func]. | ||
8471 | fcoe_mac_addr_lower); | ||
8472 | BNX2X_DEV_INFO("Read FCoE MAC to " | ||
8473 | "0x%x:0x%04x\n", val2, val); | ||
8474 | bnx2x_set_mac_buf(fip_mac, val, val2); | ||
8475 | |||
8476 | /* Disable FCoE if MAC configuration is | ||
8477 | * invalid. | ||
8478 | */ | ||
8479 | if (!is_valid_ether_addr(fip_mac)) { | ||
8480 | bp->flags |= NO_FCOE_FLAG; | ||
8481 | memset(bp->fip_mac, 0, ETH_ALEN); | ||
8482 | } | ||
8483 | } else | ||
8484 | bp->flags |= NO_FCOE_FLAG; | ||
8415 | } | 8485 | } |
8416 | #endif | 8486 | #endif |
8417 | } else { | 8487 | } else { |
@@ -8425,7 +8495,7 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | |||
8425 | iscsi_mac_upper); | 8495 | iscsi_mac_upper); |
8426 | val = SHMEM_RD(bp, dev_info.port_hw_config[port]. | 8496 | val = SHMEM_RD(bp, dev_info.port_hw_config[port]. |
8427 | iscsi_mac_lower); | 8497 | iscsi_mac_lower); |
8428 | bnx2x_set_mac_buf(bp->iscsi_mac, val, val2); | 8498 | bnx2x_set_mac_buf(iscsi_mac, val, val2); |
8429 | #endif | 8499 | #endif |
8430 | } | 8500 | } |
8431 | 8501 | ||
@@ -8433,14 +8503,12 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | |||
8433 | memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN); | 8503 | memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN); |
8434 | 8504 | ||
8435 | #ifdef BCM_CNIC | 8505 | #ifdef BCM_CNIC |
8436 | /* Inform the upper layers about FCoE MAC */ | 8506 | /* Set the FCoE MAC in modes other then MF_SI */ |
8437 | if (!CHIP_IS_E1x(bp)) { | 8507 | if (!CHIP_IS_E1x(bp)) { |
8438 | if (IS_MF_SD(bp)) | 8508 | if (IS_MF_SD(bp)) |
8439 | memcpy(bp->fip_mac, bp->dev->dev_addr, | 8509 | memcpy(fip_mac, bp->dev->dev_addr, ETH_ALEN); |
8440 | sizeof(bp->fip_mac)); | 8510 | else if (!IS_MF(bp)) |
8441 | else | 8511 | memcpy(fip_mac, iscsi_mac, ETH_ALEN); |
8442 | memcpy(bp->fip_mac, bp->iscsi_mac, | ||
8443 | sizeof(bp->fip_mac)); | ||
8444 | } | 8512 | } |
8445 | #endif | 8513 | #endif |
8446 | } | 8514 | } |
@@ -8603,6 +8671,10 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) | |||
8603 | /* Get MAC addresses */ | 8671 | /* Get MAC addresses */ |
8604 | bnx2x_get_mac_hwinfo(bp); | 8672 | bnx2x_get_mac_hwinfo(bp); |
8605 | 8673 | ||
8674 | #ifdef BCM_CNIC | ||
8675 | bnx2x_get_cnic_info(bp); | ||
8676 | #endif | ||
8677 | |||
8606 | return rc; | 8678 | return rc; |
8607 | } | 8679 | } |
8608 | 8680 | ||
@@ -10077,6 +10149,13 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev) | |||
10077 | struct bnx2x *bp = netdev_priv(dev); | 10149 | struct bnx2x *bp = netdev_priv(dev); |
10078 | struct cnic_eth_dev *cp = &bp->cnic_eth_dev; | 10150 | struct cnic_eth_dev *cp = &bp->cnic_eth_dev; |
10079 | 10151 | ||
10152 | /* If both iSCSI and FCoE are disabled - return NULL in | ||
10153 | * order to indicate CNIC that it should not try to work | ||
10154 | * with this device. | ||
10155 | */ | ||
10156 | if (NO_ISCSI(bp) && NO_FCOE(bp)) | ||
10157 | return NULL; | ||
10158 | |||
10080 | cp->drv_owner = THIS_MODULE; | 10159 | cp->drv_owner = THIS_MODULE; |
10081 | cp->chip_id = CHIP_ID(bp); | 10160 | cp->chip_id = CHIP_ID(bp); |
10082 | cp->pdev = bp->pdev; | 10161 | cp->pdev = bp->pdev; |
@@ -10097,6 +10176,15 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev) | |||
10097 | BP_E1HVN(bp) * NONE_ETH_CONTEXT_USE; | 10176 | BP_E1HVN(bp) * NONE_ETH_CONTEXT_USE; |
10098 | cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID; | 10177 | cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID; |
10099 | 10178 | ||
10179 | if (NO_ISCSI_OOO(bp)) | ||
10180 | cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO; | ||
10181 | |||
10182 | if (NO_ISCSI(bp)) | ||
10183 | cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI; | ||
10184 | |||
10185 | if (NO_FCOE(bp)) | ||
10186 | cp->drv_state |= CNIC_DRV_STATE_NO_FCOE; | ||
10187 | |||
10100 | DP(BNX2X_MSG_SP, "page_size %d, tbl_offset %d, tbl_lines %d, " | 10188 | DP(BNX2X_MSG_SP, "page_size %d, tbl_offset %d, tbl_lines %d, " |
10101 | "starting cid %d\n", | 10189 | "starting cid %d\n", |
10102 | cp->ctx_blk_size, | 10190 | cp->ctx_blk_size, |