Skip to content

Commit 1392d19

Browse files
Michal Kalderondavem330
authored andcommitted
qed: Add abstraction for different hsi values per chip
The number of BTB blocks was modified to be different between the two chip flavors supported (BB/K2) as a result, this lead to a re-write of selecting the default hsi value based on the chip. This patch creates a lookup table for hsi values per chip rather than ask again and again for every value. Signed-off-by: Ariel Elior <ariel.elior@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 997af5d commit 1392d19

3 files changed

Lines changed: 90 additions & 32 deletions

File tree

‎drivers/net/ethernet/qlogic/qed/qed.h‎

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,23 @@ struct qed_nvm_image_info {
532532
bool valid;
533533
};
534534

535+
enum qed_hsi_def_type {
536+
QED_HSI_DEF_MAX_NUM_VFS,
537+
QED_HSI_DEF_MAX_NUM_L2_QUEUES,
538+
QED_HSI_DEF_MAX_NUM_PORTS,
539+
QED_HSI_DEF_MAX_SB_PER_PATH,
540+
QED_HSI_DEF_MAX_NUM_PFS,
541+
QED_HSI_DEF_MAX_NUM_VPORTS,
542+
QED_HSI_DEF_NUM_ETH_RSS_ENGINE,
543+
QED_HSI_DEF_MAX_QM_TX_QUEUES,
544+
QED_HSI_DEF_NUM_PXP_ILT_RECORDS,
545+
QED_HSI_DEF_NUM_RDMA_STATISTIC_COUNTERS,
546+
QED_HSI_DEF_MAX_QM_GLOBAL_RLS,
547+
QED_HSI_DEF_MAX_PBF_CMD_LINES,
548+
QED_HSI_DEF_MAX_BTB_BLOCKS,
549+
QED_NUM_HSI_DEFS
550+
};
551+
535552
#define DRV_MODULE_VERSION \
536553
__stringify(QED_MAJOR_VERSION) "." \
537554
__stringify(QED_MINOR_VERSION) "." \
@@ -869,16 +886,35 @@ struct qed_dev {
869886
bool iwarp_cmt;
870887
};
871888

872-
#define NUM_OF_VFS(dev) (QED_IS_BB(dev) ? MAX_NUM_VFS_BB \
873-
: MAX_NUM_VFS_K2)
874-
#define NUM_OF_L2_QUEUES(dev) (QED_IS_BB(dev) ? MAX_NUM_L2_QUEUES_BB \
875-
: MAX_NUM_L2_QUEUES_K2)
876-
#define NUM_OF_PORTS(dev) (QED_IS_BB(dev) ? MAX_NUM_PORTS_BB \
877-
: MAX_NUM_PORTS_K2)
878-
#define NUM_OF_SBS(dev) (QED_IS_BB(dev) ? MAX_SB_PER_PATH_BB \
879-
: MAX_SB_PER_PATH_K2)
880-
#define NUM_OF_ENG_PFS(dev) (QED_IS_BB(dev) ? MAX_NUM_PFS_BB \
881-
: MAX_NUM_PFS_K2)
889+
u32 qed_get_hsi_def_val(struct qed_dev *cdev, enum qed_hsi_def_type type);
890+
891+
#define NUM_OF_VFS(dev) \
892+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_NUM_VFS)
893+
#define NUM_OF_L2_QUEUES(dev) \
894+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_NUM_L2_QUEUES)
895+
#define NUM_OF_PORTS(dev) \
896+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_NUM_PORTS)
897+
#define NUM_OF_SBS(dev) \
898+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_SB_PER_PATH)
899+
#define NUM_OF_ENG_PFS(dev) \
900+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_NUM_PFS)
901+
#define NUM_OF_VPORTS(dev) \
902+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_NUM_VPORTS)
903+
#define NUM_OF_RSS_ENGINES(dev) \
904+
qed_get_hsi_def_val(dev, QED_HSI_DEF_NUM_ETH_RSS_ENGINE)
905+
#define NUM_OF_QM_TX_QUEUES(dev) \
906+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_QM_TX_QUEUES)
907+
#define NUM_OF_PXP_ILT_RECORDS(dev) \
908+
qed_get_hsi_def_val(dev, QED_HSI_DEF_NUM_PXP_ILT_RECORDS)
909+
#define NUM_OF_RDMA_STATISTIC_COUNTERS(dev) \
910+
qed_get_hsi_def_val(dev, QED_HSI_DEF_NUM_RDMA_STATISTIC_COUNTERS)
911+
#define NUM_OF_QM_GLOBAL_RLS(dev) \
912+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_QM_GLOBAL_RLS)
913+
#define NUM_OF_PBF_CMD_LINES(dev) \
914+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_PBF_CMD_LINES)
915+
#define NUM_OF_BTB_BLOCKS(dev) \
916+
qed_get_hsi_def_val(dev, QED_HSI_DEF_MAX_BTB_BLOCKS)
917+
882918

883919
/**
884920
* @brief qed_concrete_to_sw_fid - get the sw function id from

‎drivers/net/ethernet/qlogic/qed/qed_dev.c‎

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,7 @@ static void qed_init_qm_port_params(struct qed_hwfn *p_hwfn)
15791579
{
15801580
/* Initialize qm port parameters */
15811581
u8 i, active_phys_tcs, num_ports = p_hwfn->cdev->num_ports_in_engine;
1582+
struct qed_dev *cdev = p_hwfn->cdev;
15821583

15831584
/* indicate how ooo and high pri traffic is dealt with */
15841585
active_phys_tcs = num_ports == MAX_NUM_PORTS_K2 ?
@@ -1588,11 +1589,13 @@ static void qed_init_qm_port_params(struct qed_hwfn *p_hwfn)
15881589
for (i = 0; i < num_ports; i++) {
15891590
struct init_qm_port_params *p_qm_port =
15901591
&p_hwfn->qm_info.qm_port_params[i];
1592+
u16 pbf_max_cmd_lines;
15911593

15921594
p_qm_port->active = 1;
15931595
p_qm_port->active_phys_tcs = active_phys_tcs;
1594-
p_qm_port->num_pbf_cmd_lines = PBF_MAX_CMD_LINES / num_ports;
1595-
p_qm_port->num_btb_blocks = BTB_MAX_BLOCKS / num_ports;
1596+
pbf_max_cmd_lines = (u16)NUM_OF_PBF_CMD_LINES(cdev);
1597+
p_qm_port->num_pbf_cmd_lines = pbf_max_cmd_lines / num_ports;
1598+
p_qm_port->num_btb_blocks = NUM_OF_BTB_BLOCKS(cdev) / num_ports;
15961599
}
15971600
}
15981601

@@ -3607,14 +3610,39 @@ __qed_hw_set_soft_resc_size(struct qed_hwfn *p_hwfn,
36073610
return 0;
36083611
}
36093612

3613+
static u32 qed_hsi_def_val[][MAX_CHIP_IDS] = {
3614+
{MAX_NUM_VFS_BB, MAX_NUM_VFS_K2},
3615+
{MAX_NUM_L2_QUEUES_BB, MAX_NUM_L2_QUEUES_K2},
3616+
{MAX_NUM_PORTS_BB, MAX_NUM_PORTS_K2},
3617+
{MAX_SB_PER_PATH_BB, MAX_SB_PER_PATH_K2,},
3618+
{MAX_NUM_PFS_BB, MAX_NUM_PFS_K2},
3619+
{MAX_NUM_VPORTS_BB, MAX_NUM_VPORTS_K2},
3620+
{ETH_RSS_ENGINE_NUM_BB, ETH_RSS_ENGINE_NUM_K2},
3621+
{MAX_QM_TX_QUEUES_BB, MAX_QM_TX_QUEUES_K2},
3622+
{PXP_NUM_ILT_RECORDS_BB, PXP_NUM_ILT_RECORDS_K2},
3623+
{RDMA_NUM_STATISTIC_COUNTERS_BB, RDMA_NUM_STATISTIC_COUNTERS_K2},
3624+
{MAX_QM_GLOBAL_RLS, MAX_QM_GLOBAL_RLS},
3625+
{PBF_MAX_CMD_LINES, PBF_MAX_CMD_LINES},
3626+
{BTB_MAX_BLOCKS_BB, BTB_MAX_BLOCKS_K2},
3627+
};
3628+
3629+
u32 qed_get_hsi_def_val(struct qed_dev *cdev, enum qed_hsi_def_type type)
3630+
{
3631+
enum chip_ids chip_id = QED_IS_BB(cdev) ? CHIP_BB : CHIP_K2;
3632+
3633+
if (type >= QED_NUM_HSI_DEFS) {
3634+
DP_ERR(cdev, "Unexpected HSI definition type [%d]\n", type);
3635+
return 0;
3636+
}
3637+
3638+
return qed_hsi_def_val[type][chip_id];
3639+
}
36103640
static int
36113641
qed_hw_set_soft_resc_size(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
36123642
{
3613-
bool b_ah = QED_IS_AH(p_hwfn->cdev);
36143643
u32 resc_max_val, mcp_resp;
36153644
u8 res_id;
36163645
int rc;
3617-
36183646
for (res_id = 0; res_id < QED_MAX_RESC; res_id++) {
36193647
switch (res_id) {
36203648
case QED_LL2_RAM_QUEUE:
@@ -3630,8 +3658,8 @@ qed_hw_set_soft_resc_size(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
36303658
resc_max_val = NUM_OF_GLOBAL_QUEUES;
36313659
break;
36323660
case QED_RDMA_STATS_QUEUE:
3633-
resc_max_val = b_ah ? RDMA_NUM_STATISTIC_COUNTERS_K2
3634-
: RDMA_NUM_STATISTIC_COUNTERS_BB;
3661+
resc_max_val =
3662+
NUM_OF_RDMA_STATISTIC_COUNTERS(p_hwfn->cdev);
36353663
break;
36363664
case QED_BDQ:
36373665
resc_max_val = BDQ_NUM_RESOURCES;
@@ -3664,37 +3692,32 @@ int qed_hw_get_dflt_resc(struct qed_hwfn *p_hwfn,
36643692
u32 *p_resc_num, u32 *p_resc_start)
36653693
{
36663694
u8 num_funcs = p_hwfn->num_funcs_on_engine;
3667-
bool b_ah = QED_IS_AH(p_hwfn->cdev);
3695+
struct qed_dev *cdev = p_hwfn->cdev;
36683696

36693697
switch (res_id) {
36703698
case QED_L2_QUEUE:
3671-
*p_resc_num = (b_ah ? MAX_NUM_L2_QUEUES_K2 :
3672-
MAX_NUM_L2_QUEUES_BB) / num_funcs;
3699+
*p_resc_num = NUM_OF_L2_QUEUES(cdev) / num_funcs;
36733700
break;
36743701
case QED_VPORT:
3675-
*p_resc_num = (b_ah ? MAX_NUM_VPORTS_K2 :
3676-
MAX_NUM_VPORTS_BB) / num_funcs;
3702+
*p_resc_num = NUM_OF_VPORTS(cdev) / num_funcs;
36773703
break;
36783704
case QED_RSS_ENG:
3679-
*p_resc_num = (b_ah ? ETH_RSS_ENGINE_NUM_K2 :
3680-
ETH_RSS_ENGINE_NUM_BB) / num_funcs;
3705+
*p_resc_num = NUM_OF_RSS_ENGINES(cdev) / num_funcs;
36813706
break;
36823707
case QED_PQ:
3683-
*p_resc_num = (b_ah ? MAX_QM_TX_QUEUES_K2 :
3684-
MAX_QM_TX_QUEUES_BB) / num_funcs;
3708+
*p_resc_num = NUM_OF_QM_TX_QUEUES(cdev) / num_funcs;
36853709
*p_resc_num &= ~0x7; /* The granularity of the PQs is 8 */
36863710
break;
36873711
case QED_RL:
3688-
*p_resc_num = MAX_QM_GLOBAL_RLS / num_funcs;
3712+
*p_resc_num = NUM_OF_QM_GLOBAL_RLS(cdev) / num_funcs;
36893713
break;
36903714
case QED_MAC:
36913715
case QED_VLAN:
36923716
/* Each VFC resource can accommodate both a MAC and a VLAN */
36933717
*p_resc_num = ETH_NUM_MAC_FILTERS / num_funcs;
36943718
break;
36953719
case QED_ILT:
3696-
*p_resc_num = (b_ah ? PXP_NUM_ILT_RECORDS_K2 :
3697-
PXP_NUM_ILT_RECORDS_BB) / num_funcs;
3720+
*p_resc_num = NUM_OF_PXP_ILT_RECORDS(cdev) / num_funcs;
36983721
break;
36993722
case QED_LL2_RAM_QUEUE:
37003723
*p_resc_num = MAX_NUM_LL2_RX_RAM_QUEUES / num_funcs;
@@ -3708,8 +3731,7 @@ int qed_hw_get_dflt_resc(struct qed_hwfn *p_hwfn,
37083731
*p_resc_num = NUM_OF_GLOBAL_QUEUES / num_funcs;
37093732
break;
37103733
case QED_RDMA_STATS_QUEUE:
3711-
*p_resc_num = (b_ah ? RDMA_NUM_STATISTIC_COUNTERS_K2 :
3712-
RDMA_NUM_STATISTIC_COUNTERS_BB) / num_funcs;
3734+
*p_resc_num = NUM_OF_RDMA_STATISTIC_COUNTERS(cdev) / num_funcs;
37133735
break;
37143736
case QED_BDQ:
37153737
if (p_hwfn->hw_info.personality != QED_PCI_ISCSI &&

‎include/linux/qed/common_hsi.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@
663663
#define PBF_MAX_CMD_LINES 3328
664664

665665
/* Number of BTB blocks. Each block is 256B. */
666-
#define BTB_MAX_BLOCKS 1440
667-
666+
#define BTB_MAX_BLOCKS_BB 1440
667+
#define BTB_MAX_BLOCKS_K2 1840
668668
/*****************/
669669
/* PRS CONSTANTS */
670670
/*****************/

0 commit comments

Comments
 (0)