aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
diff options
context:
space:
mode:
authorMerav Sicron <meravs@broadcom.com>2012-11-06 19:45:48 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-07 18:57:19 -0500
commit55c11941e382cb26010138ab824216f47af37606 (patch)
tree92724ef130081b47426919758c5fac4061e9e708 /drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
parentbabc6727d537199f7fbf6dfe711ae418d399b3eb (diff)
bnx2x: Support loading cnic resources at run-time
This patch replaces the BCM_CNIC define with a flag which can change at run-time and which does not use the CONFIG_CNIC kconfig option. For the PF/hypervisor driver cnic is always supported, however allocation of cnic resources and configuration of the HW for offload mode is done only when the cnic module registers bnx2x. Signed-off-by: Merav Sicron <meravs@broadcom.com> Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x/bnx2x.h')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h132
1 files changed, 83 insertions, 49 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 72897c47b8c8..de121ccd675e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -34,18 +34,10 @@
34 34
35#include "bnx2x_hsi.h" 35#include "bnx2x_hsi.h"
36 36
37#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
38#define BCM_CNIC 1
39#include "../cnic_if.h" 37#include "../cnic_if.h"
40#endif
41 38
42#ifdef BCM_CNIC 39
43#define BNX2X_MIN_MSIX_VEC_CNT 3 40#define BNX2X_MIN_MSIX_VEC_CNT(bp) ((bp)->min_msix_vec_cnt)
44#define BNX2X_MSIX_VEC_FP_START 2
45#else
46#define BNX2X_MIN_MSIX_VEC_CNT 2
47#define BNX2X_MSIX_VEC_FP_START 1
48#endif
49 41
50#include <linux/mdio.h> 42#include <linux/mdio.h>
51 43
@@ -256,15 +248,10 @@ enum {
256 /* FCoE L2 */ 248 /* FCoE L2 */
257#define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1) 249#define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1)
258 250
259/** Additional rings budgeting */ 251#define CNIC_SUPPORT(bp) ((bp)->cnic_support)
260#ifdef BCM_CNIC 252#define CNIC_ENABLED(bp) ((bp)->cnic_enabled)
261#define CNIC_PRESENT 1 253#define CNIC_LOADED(bp) ((bp)->cnic_loaded)
262#define FCOE_PRESENT 1 254#define FCOE_INIT(bp) ((bp)->fcoe_init)
263#else
264#define CNIC_PRESENT 0
265#define FCOE_PRESENT 0
266#endif /* BCM_CNIC */
267#define NON_ETH_CONTEXT_USE (FCOE_PRESENT)
268 255
269#define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \ 256#define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
270 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR 257 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
@@ -297,9 +284,7 @@ enum {
297 OOO_TXQ_IDX_OFFSET, 284 OOO_TXQ_IDX_OFFSET,
298}; 285};
299#define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos) 286#define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
300#ifdef BCM_CNIC
301#define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET) 287#define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
302#endif
303 288
304/* fast path */ 289/* fast path */
305/* 290/*
@@ -585,15 +570,9 @@ struct bnx2x_fastpath {
585 ->var) 570 ->var)
586 571
587 572
588#define IS_ETH_FP(fp) (fp->index < \ 573#define IS_ETH_FP(fp) ((fp)->index < BNX2X_NUM_ETH_QUEUES((fp)->bp))
589 BNX2X_NUM_ETH_QUEUES(fp->bp)) 574#define IS_FCOE_FP(fp) ((fp)->index == FCOE_IDX((fp)->bp))
590#ifdef BCM_CNIC 575#define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX(bp))
591#define IS_FCOE_FP(fp) (fp->index == FCOE_IDX(fp->bp))
592#define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX(bp))
593#else
594#define IS_FCOE_FP(fp) false
595#define IS_FCOE_IDX(idx) false
596#endif
597 576
598 577
599/* MC hsi */ 578/* MC hsi */
@@ -886,6 +865,18 @@ struct bnx2x_common {
886 (CHIP_REV(bp) == CHIP_REV_Bx)) 865 (CHIP_REV(bp) == CHIP_REV_Bx))
887#define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \ 866#define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \
888 (CHIP_REV(bp) == CHIP_REV_Ax)) 867 (CHIP_REV(bp) == CHIP_REV_Ax))
868/* This define is used in two main places:
869 * 1. In the early stages of nic_load, to know if to configrue Parser / Searcher
870 * to nic-only mode or to offload mode. Offload mode is configured if either the
871 * chip is E1x (where MIC_MODE register is not applicable), or if cnic already
872 * registered for this port (which means that the user wants storage services).
873 * 2. During cnic-related load, to know if offload mode is already configured in
874 * the HW or needs to be configrued.
875 * Since the transition from nic-mode to offload-mode in HW causes traffic
876 * coruption, nic-mode is configured only in ports on which storage services
877 * where never requested.
878 */
879#define CONFIGURE_NIC_MODE(bp) (!CHIP_IS_E1x(bp) && !CNIC_ENABLED(bp))
889 880
890 int flash_size; 881 int flash_size;
891#define BNX2X_NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */ 882#define BNX2X_NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */
@@ -1003,18 +994,15 @@ union cdu_context {
1003#define CDU_ILT_PAGE_SZ (8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */ 994#define CDU_ILT_PAGE_SZ (8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */
1004#define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context)) 995#define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
1005 996
1006#ifdef BCM_CNIC
1007#define CNIC_ISCSI_CID_MAX 256 997#define CNIC_ISCSI_CID_MAX 256
1008#define CNIC_FCOE_CID_MAX 2048 998#define CNIC_FCOE_CID_MAX 2048
1009#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) 999#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
1010#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) 1000#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
1011#endif
1012 1001
1013#define QM_ILT_PAGE_SZ_HW 0 1002#define QM_ILT_PAGE_SZ_HW 0
1014#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 4K */ 1003#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
1015#define QM_CID_ROUND 1024 1004#define QM_CID_ROUND 1024
1016 1005
1017#ifdef BCM_CNIC
1018/* TM (timers) host DB constants */ 1006/* TM (timers) host DB constants */
1019#define TM_ILT_PAGE_SZ_HW 0 1007#define TM_ILT_PAGE_SZ_HW 0
1020#define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 4K */ 1008#define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
@@ -1032,8 +1020,6 @@ union cdu_context {
1032#define SRC_T2_SZ SRC_ILT_SZ 1020#define SRC_T2_SZ SRC_ILT_SZ
1033#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) 1021#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
1034 1022
1035#endif
1036
1037#define MAX_DMAE_C 8 1023#define MAX_DMAE_C 8
1038 1024
1039/* DMA memory not used in fastpath */ 1025/* DMA memory not used in fastpath */
@@ -1227,7 +1213,6 @@ struct bnx2x {
1227 struct bnx2x_sp_objs *sp_objs; 1213 struct bnx2x_sp_objs *sp_objs;
1228 struct bnx2x_fp_stats *fp_stats; 1214 struct bnx2x_fp_stats *fp_stats;
1229 struct bnx2x_fp_txdata *bnx2x_txq; 1215 struct bnx2x_fp_txdata *bnx2x_txq;
1230 int bnx2x_txq_size;
1231 void __iomem *regview; 1216 void __iomem *regview;
1232 void __iomem *doorbells; 1217 void __iomem *doorbells;
1233 u16 db_size; 1218 u16 db_size;
@@ -1350,6 +1335,15 @@ struct bnx2x {
1350#define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG) 1335#define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
1351#define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG) 1336#define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG)
1352 1337
1338 u8 cnic_support;
1339 bool cnic_enabled;
1340 bool cnic_loaded;
1341
1342 /* Flag that indicates that we can start looking for FCoE L2 queue
1343 * completions in the default status block.
1344 */
1345 bool fcoe_init;
1346
1353 int pm_cap; 1347 int pm_cap;
1354 int mrrs; 1348 int mrrs;
1355 1349
@@ -1420,6 +1414,8 @@ struct bnx2x {
1420#define BNX2X_MAX_COS 3 1414#define BNX2X_MAX_COS 3
1421#define BNX2X_MAX_TX_COS 2 1415#define BNX2X_MAX_TX_COS 2
1422 int num_queues; 1416 int num_queues;
1417 uint num_ethernet_queues;
1418 uint num_cnic_queues;
1423 int num_napi_queues; 1419 int num_napi_queues;
1424 int disable_tpa; 1420 int disable_tpa;
1425 1421
@@ -1433,6 +1429,7 @@ struct bnx2x {
1433 u8 igu_dsb_id; 1429 u8 igu_dsb_id;
1434 u8 igu_base_sb; 1430 u8 igu_base_sb;
1435 u8 igu_sb_cnt; 1431 u8 igu_sb_cnt;
1432 u8 min_msix_vec_cnt;
1436 1433
1437 dma_addr_t def_status_blk_mapping; 1434 dma_addr_t def_status_blk_mapping;
1438 1435
@@ -1478,16 +1475,16 @@ struct bnx2x {
1478 * Maximum supported number of RSS queues: number of IGU SBs minus one that goes 1475 * Maximum supported number of RSS queues: number of IGU SBs minus one that goes
1479 * to CNIC. 1476 * to CNIC.
1480 */ 1477 */
1481#define BNX2X_MAX_RSS_COUNT(bp) ((bp)->igu_sb_cnt - CNIC_PRESENT) 1478#define BNX2X_MAX_RSS_COUNT(bp) ((bp)->igu_sb_cnt - CNIC_SUPPORT(bp))
1482 1479
1483/* 1480/*
1484 * Maximum CID count that might be required by the bnx2x: 1481 * Maximum CID count that might be required by the bnx2x:
1485 * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI 1482 * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
1486 */ 1483 */
1487#define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \ 1484#define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
1488 + NON_ETH_CONTEXT_USE + CNIC_PRESENT) 1485 + 2 * CNIC_SUPPORT(bp))
1489#define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \ 1486#define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
1490 + NON_ETH_CONTEXT_USE + CNIC_PRESENT) 1487 + 2 * CNIC_SUPPORT(bp))
1491#define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\ 1488#define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
1492 ILT_PAGE_CIDS)) 1489 ILT_PAGE_CIDS))
1493 1490
@@ -1495,9 +1492,6 @@ struct bnx2x {
1495 1492
1496 int dropless_fc; 1493 int dropless_fc;
1497 1494
1498#ifdef BCM_CNIC
1499 u32 cnic_flags;
1500#define BNX2X_CNIC_FLAG_MAC_SET 1
1501 void *t2; 1495 void *t2;
1502 dma_addr_t t2_mapping; 1496 dma_addr_t t2_mapping;
1503 struct cnic_ops __rcu *cnic_ops; 1497 struct cnic_ops __rcu *cnic_ops;
@@ -1518,7 +1512,6 @@ struct bnx2x {
1518 1512
1519 /* Start index of the "special" (CNIC related) L2 cleints */ 1513 /* Start index of the "special" (CNIC related) L2 cleints */
1520 u8 cnic_base_cl_id; 1514 u8 cnic_base_cl_id;
1521#endif
1522 1515
1523 int dmae_ready; 1516 int dmae_ready;
1524 /* used to synchronize dmae accesses */ 1517 /* used to synchronize dmae accesses */
@@ -1647,9 +1640,9 @@ struct bnx2x {
1647/* Tx queues may be less or equal to Rx queues */ 1640/* Tx queues may be less or equal to Rx queues */
1648extern int num_queues; 1641extern int num_queues;
1649#define BNX2X_NUM_QUEUES(bp) (bp->num_queues) 1642#define BNX2X_NUM_QUEUES(bp) (bp->num_queues)
1650#define BNX2X_NUM_ETH_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - NON_ETH_CONTEXT_USE) 1643#define BNX2X_NUM_ETH_QUEUES(bp) ((bp)->num_ethernet_queues)
1651#define BNX2X_NUM_NON_CNIC_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - \ 1644#define BNX2X_NUM_NON_CNIC_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - \
1652 NON_ETH_CONTEXT_USE) 1645 (bp)->num_cnic_queues)
1653#define BNX2X_NUM_RX_QUEUES(bp) BNX2X_NUM_QUEUES(bp) 1646#define BNX2X_NUM_RX_QUEUES(bp) BNX2X_NUM_QUEUES(bp)
1654 1647
1655#define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1) 1648#define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1)
@@ -1689,6 +1682,13 @@ struct bnx2x_func_init_params {
1689 u16 spq_prod; /* valid iff FUNC_FLG_SPQ */ 1682 u16 spq_prod; /* valid iff FUNC_FLG_SPQ */
1690}; 1683};
1691 1684
1685#define for_each_cnic_queue(bp, var) \
1686 for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
1687 (var)++) \
1688 if (skip_queue(bp, var)) \
1689 continue; \
1690 else
1691
1692#define for_each_eth_queue(bp, var) \ 1692#define for_each_eth_queue(bp, var) \
1693 for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++) 1693 for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
1694 1694
@@ -1702,6 +1702,22 @@ struct bnx2x_func_init_params {
1702 else 1702 else
1703 1703
1704/* Skip forwarding FP */ 1704/* Skip forwarding FP */
1705#define for_each_valid_rx_queue(bp, var) \
1706 for ((var) = 0; \
1707 (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) : \
1708 BNX2X_NUM_ETH_QUEUES(bp)); \
1709 (var)++) \
1710 if (skip_rx_queue(bp, var)) \
1711 continue; \
1712 else
1713
1714#define for_each_rx_queue_cnic(bp, var) \
1715 for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
1716 (var)++) \
1717 if (skip_rx_queue(bp, var)) \
1718 continue; \
1719 else
1720
1705#define for_each_rx_queue(bp, var) \ 1721#define for_each_rx_queue(bp, var) \
1706 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ 1722 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1707 if (skip_rx_queue(bp, var)) \ 1723 if (skip_rx_queue(bp, var)) \
@@ -1709,6 +1725,22 @@ struct bnx2x_func_init_params {
1709 else 1725 else
1710 1726
1711/* Skip OOO FP */ 1727/* Skip OOO FP */
1728#define for_each_valid_tx_queue(bp, var) \
1729 for ((var) = 0; \
1730 (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) : \
1731 BNX2X_NUM_ETH_QUEUES(bp)); \
1732 (var)++) \
1733 if (skip_tx_queue(bp, var)) \
1734 continue; \
1735 else
1736
1737#define for_each_tx_queue_cnic(bp, var) \
1738 for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
1739 (var)++) \
1740 if (skip_tx_queue(bp, var)) \
1741 continue; \
1742 else
1743
1712#define for_each_tx_queue(bp, var) \ 1744#define for_each_tx_queue(bp, var) \
1713 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ 1745 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1714 if (skip_tx_queue(bp, var)) \ 1746 if (skip_tx_queue(bp, var)) \
@@ -2179,7 +2211,6 @@ void bnx2x_notify_link_changed(struct bnx2x *bp);
2179#define BNX2X_MF_SD_PROTOCOL(bp) \ 2211#define BNX2X_MF_SD_PROTOCOL(bp) \
2180 ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK) 2212 ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
2181 2213
2182#ifdef BCM_CNIC
2183#define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \ 2214#define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
2184 (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI) 2215 (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
2185 2216
@@ -2196,9 +2227,12 @@ void bnx2x_notify_link_changed(struct bnx2x *bp);
2196#define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \ 2227#define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \
2197 (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \ 2228 (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \
2198 BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))) 2229 BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
2199#else
2200#define IS_MF_FCOE_AFEX(bp) false
2201#endif
2202 2230
2231enum {
2232 SWITCH_UPDATE,
2233 AFEX_UPDATE,
2234};
2235
2236#define NUM_MACS 8
2203 2237
2204#endif /* bnx2x.h */ 2238#endif /* bnx2x.h */