Commit 37ae41a9 authored by Merav Sicron's avatar Merav Sicron Committed by David S. Miller

bnx2x: Move the CNIC L2 CIDs to be right after the RSS CIDs

Currently the CNIC-related L2 CIDs (for sending control FCoE / iSCSI packets)
were at fixed position, according to the maximal number of RSS queues multiplied
by the number of traffic-classes. This change makes the CIDs dynamic, as they
are defined to be right after the highest RSS CID. This decreases the memory
allocated for the context.
Signed-off-by: default avatarMerav Sicron <meravs@broadcom.com>
Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 65565884
...@@ -248,13 +248,12 @@ enum { ...@@ -248,13 +248,12 @@ enum {
BNX2X_MAX_CNIC_ETH_CL_ID_IDX, BNX2X_MAX_CNIC_ETH_CL_ID_IDX,
}; };
#define BNX2X_CNIC_START_ETH_CID 48 #define BNX2X_CNIC_START_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) *\
enum { (bp)->max_cos)
/* iSCSI L2 */ /* iSCSI L2 */
BNX2X_ISCSI_ETH_CID = BNX2X_CNIC_START_ETH_CID, #define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp))
/* FCoE L2 */ /* FCoE L2 */
BNX2X_FCOE_ETH_CID, #define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1)
};
/** Additional rings budgeting */ /** Additional rings budgeting */
#ifdef BCM_CNIC #ifdef BCM_CNIC
...@@ -276,8 +275,6 @@ enum { ...@@ -276,8 +275,6 @@ enum {
#define FIRST_TX_ONLY_COS_INDEX 1 #define FIRST_TX_ONLY_COS_INDEX 1
#define FIRST_TX_COS_INDEX 0 #define FIRST_TX_COS_INDEX 0
#define MAX_TXQS_PER_COS FP_SB_MAX_E1x
/* rules for calculating the cids of tx-only connections */ /* rules for calculating the cids of tx-only connections */
#define CID_TO_FP(cid, bp) ((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp)) #define CID_TO_FP(cid, bp) ((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp))
#define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \ #define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \
...@@ -1448,10 +1445,12 @@ struct bnx2x { ...@@ -1448,10 +1445,12 @@ struct bnx2x {
/* /*
* Maximum CID count that might be required by the bnx2x: * Maximum CID count that might be required by the bnx2x:
* Max Tss * Max_Tx_Multi_Cos + CNIC L2 Clients (FCoE and iSCSI related) * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
*/ */
#define BNX2X_L2_CID_COUNT(bp) (MAX_TXQS_PER_COS * BNX2X_MULTI_TX_COS +\ #define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
NON_ETH_CONTEXT_USE + CNIC_PRESENT) + NON_ETH_CONTEXT_USE + CNIC_PRESENT)
#define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
+ NON_ETH_CONTEXT_USE + CNIC_PRESENT)
#define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\ #define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
ILT_PAGE_CIDS)) ILT_PAGE_CIDS))
......
...@@ -2235,6 +2235,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) ...@@ -2235,6 +2235,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
/* re-read iscsi info */ /* re-read iscsi info */
bnx2x_get_iscsi_info(bp); bnx2x_get_iscsi_info(bp);
bnx2x_setup_cnic_irq_info(bp); bnx2x_setup_cnic_irq_info(bp);
bnx2x_setup_cnic_info(bp);
if (bp->state == BNX2X_STATE_OPEN) if (bp->state == BNX2X_STATE_OPEN)
bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD);
#endif #endif
......
...@@ -244,6 +244,14 @@ int bnx2x_cnic_notify(struct bnx2x *bp, int cmd); ...@@ -244,6 +244,14 @@ int bnx2x_cnic_notify(struct bnx2x *bp, int cmd);
* @bp: driver handle * @bp: driver handle
*/ */
void bnx2x_setup_cnic_irq_info(struct bnx2x *bp); void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
/**
* bnx2x_setup_cnic_info - provides cnic with updated info
*
* @bp: driver handle
*/
void bnx2x_setup_cnic_info(struct bnx2x *bp);
#endif #endif
/** /**
...@@ -1107,12 +1115,7 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) ...@@ -1107,12 +1115,7 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp)
bnx2x_fcoe(bp, rx_queue) = BNX2X_NUM_ETH_QUEUES(bp); bnx2x_fcoe(bp, rx_queue) = BNX2X_NUM_ETH_QUEUES(bp);
bnx2x_fcoe(bp, cl_id) = bnx2x_cnic_eth_cl_id(bp, bnx2x_fcoe(bp, cl_id) = bnx2x_cnic_eth_cl_id(bp,
BNX2X_FCOE_ETH_CL_ID_IDX); BNX2X_FCOE_ETH_CL_ID_IDX);
/** Current BNX2X_FCOE_ETH_CID deffinition implies not more than bnx2x_fcoe(bp, cid) = BNX2X_FCOE_ETH_CID(bp);
* 16 ETH clients per function when CNIC is enabled!
*
* Fix it ASAP!!!
*/
bnx2x_fcoe(bp, cid) = BNX2X_FCOE_ETH_CID;
bnx2x_fcoe(bp, fw_sb_id) = DEF_SB_ID; bnx2x_fcoe(bp, fw_sb_id) = DEF_SB_ID;
bnx2x_fcoe(bp, igu_sb_id) = bp->igu_dsb_id; bnx2x_fcoe(bp, igu_sb_id) = bp->igu_dsb_id;
bnx2x_fcoe(bp, rx_cons_sb) = BNX2X_FCOE_L2_RX_INDEX; bnx2x_fcoe(bp, rx_cons_sb) = BNX2X_FCOE_L2_RX_INDEX;
......
...@@ -4628,7 +4628,7 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp, ...@@ -4628,7 +4628,7 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp,
case BNX2X_FILTER_MAC_PENDING: case BNX2X_FILTER_MAC_PENDING:
DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n"); DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n");
#ifdef BCM_CNIC #ifdef BCM_CNIC
if (cid == BNX2X_ISCSI_ETH_CID) if (cid == BNX2X_ISCSI_ETH_CID(bp))
vlan_mac_obj = &bp->iscsi_l2_mac_obj; vlan_mac_obj = &bp->iscsi_l2_mac_obj;
else else
#endif #endif
...@@ -4774,7 +4774,7 @@ static struct bnx2x_queue_sp_obj *bnx2x_cid_to_q_obj( ...@@ -4774,7 +4774,7 @@ static struct bnx2x_queue_sp_obj *bnx2x_cid_to_q_obj(
{ {
DP(BNX2X_MSG_SP, "retrieving fp from cid %d\n", cid); DP(BNX2X_MSG_SP, "retrieving fp from cid %d\n", cid);
#ifdef BCM_CNIC #ifdef BCM_CNIC
if (cid == BNX2X_FCOE_ETH_CID) if (cid == BNX2X_FCOE_ETH_CID(bp))
return &bnx2x_fcoe(bp, q_obj); return &bnx2x_fcoe(bp, q_obj);
else else
#endif #endif
...@@ -11724,7 +11724,7 @@ void bnx2x__init_func_obj(struct bnx2x *bp) ...@@ -11724,7 +11724,7 @@ void bnx2x__init_func_obj(struct bnx2x *bp)
/* must be called after sriov-enable */ /* must be called after sriov-enable */
static int bnx2x_set_qm_cid_count(struct bnx2x *bp) static int bnx2x_set_qm_cid_count(struct bnx2x *bp)
{ {
int cid_count = BNX2X_L2_CID_COUNT(bp); int cid_count = BNX2X_L2_MAX_CID(bp);
#ifdef BCM_CNIC #ifdef BCM_CNIC
cid_count += CNIC_CID_MAX; cid_count += CNIC_CID_MAX;
...@@ -11829,9 +11829,9 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, ...@@ -11829,9 +11829,9 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
/* /*
* Maximum number of netdev Tx queues: * Maximum number of netdev Tx queues:
* Maximum TSS queues * Maximum supported number of CoS + FCoE L2 * Maximum TSS queues * Maximum supported number of CoS + FCoE L2
*/ */
tx_count = MAX_TXQS_PER_COS * max_cos_est + FCOE_PRESENT; tx_count = rss_count * max_cos_est + FCOE_PRESENT;
/* dev zeroed in init_etherdev */ /* dev zeroed in init_etherdev */
dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count); dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count);
...@@ -11863,11 +11863,15 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, ...@@ -11863,11 +11863,15 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
* Map doorbels here as we need the real value of bp->max_cos which * Map doorbels here as we need the real value of bp->max_cos which
* is initialized in bnx2x_init_bp(). * is initialized in bnx2x_init_bp().
*/ */
doorbell_size = (rss_count * max_cos_est + NON_ETH_CONTEXT_USE + doorbell_size = BNX2X_L2_MAX_CID(bp) * (1 << BNX2X_DB_SHIFT);
CNIC_PRESENT) * (1 << BNX2X_DB_SHIFT); if (doorbell_size > pci_resource_len(pdev, 2)) {
dev_err(&bp->pdev->dev,
"Cannot map doorbells, bar size too small, aborting\n");
rc = -ENOMEM;
goto init_one_exit;
}
bp->doorbells = ioremap_nocache(pci_resource_start(pdev, 2), bp->doorbells = ioremap_nocache(pci_resource_start(pdev, 2),
min_t(u64, doorbell_size, doorbell_size);
pci_resource_len(pdev, 2)));
if (!bp->doorbells) { if (!bp->doorbells) {
dev_err(&bp->pdev->dev, dev_err(&bp->pdev->dev,
"Cannot map doorbell space, aborting\n"); "Cannot map doorbell space, aborting\n");
...@@ -12254,14 +12258,14 @@ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count) ...@@ -12254,14 +12258,14 @@ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count)
*/ */
if (type == ETH_CONNECTION_TYPE) { if (type == ETH_CONNECTION_TYPE) {
if (cmd == RAMROD_CMD_ID_ETH_CLIENT_SETUP) { if (cmd == RAMROD_CMD_ID_ETH_CLIENT_SETUP) {
cxt_index = BNX2X_ISCSI_ETH_CID / cxt_index = BNX2X_ISCSI_ETH_CID(bp) /
ILT_PAGE_CIDS; ILT_PAGE_CIDS;
cxt_offset = BNX2X_ISCSI_ETH_CID - cxt_offset = BNX2X_ISCSI_ETH_CID(bp) -
(cxt_index * ILT_PAGE_CIDS); (cxt_index * ILT_PAGE_CIDS);
bnx2x_set_ctx_validation(bp, bnx2x_set_ctx_validation(bp,
&bp->context[cxt_index]. &bp->context[cxt_index].
vcxt[cxt_offset].eth, vcxt[cxt_offset].eth,
BNX2X_ISCSI_ETH_CID); BNX2X_ISCSI_ETH_CID(bp));
} }
} }
...@@ -12615,6 +12619,21 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp) ...@@ -12615,6 +12619,21 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp)
cp->num_irq = 2; cp->num_irq = 2;
} }
void bnx2x_setup_cnic_info(struct bnx2x *bp)
{
struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
cp->ctx_tbl_offset = FUNC_ILT_BASE(BP_FUNC(bp)) +
bnx2x_cid_ilt_lines(bp);
cp->starting_cid = bnx2x_cid_ilt_lines(bp) * ILT_PAGE_CIDS;
cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp);
cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID(bp);
if (NO_ISCSI_OOO(bp))
cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO;
}
static int bnx2x_register_cnic(struct net_device *dev, struct cnic_ops *ops, static int bnx2x_register_cnic(struct net_device *dev, struct cnic_ops *ops,
void *data) void *data)
{ {
...@@ -12693,10 +12712,10 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev) ...@@ -12693,10 +12712,10 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev)
cp->drv_ctl = bnx2x_drv_ctl; cp->drv_ctl = bnx2x_drv_ctl;
cp->drv_register_cnic = bnx2x_register_cnic; cp->drv_register_cnic = bnx2x_register_cnic;
cp->drv_unregister_cnic = bnx2x_unregister_cnic; cp->drv_unregister_cnic = bnx2x_unregister_cnic;
cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID; cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp);
cp->iscsi_l2_client_id = cp->iscsi_l2_client_id =
bnx2x_cnic_eth_cl_id(bp, BNX2X_ISCSI_ETH_CL_ID_IDX); bnx2x_cnic_eth_cl_id(bp, BNX2X_ISCSI_ETH_CL_ID_IDX);
cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID; cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID(bp);
if (NO_ISCSI_OOO(bp)) if (NO_ISCSI_OOO(bp))
cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO; cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment