@@ -2901,6 +2901,41 @@ static int irdma_sc_cq_modify(struct irdma_sc_cq *cq,
29012901 return 0 ;
29022902}
29032903
2904+ /**
2905+ * irdma_sc_get_decoded_ird_size_gen_3 - get decoded IRD size for GEN 3
2906+ * @ird_enc: IRD encoding
2907+ * IRD size defaults to a value of 4 in case of invalid input.
2908+ */
2909+ static u16 irdma_sc_get_decoded_ird_size_gen_3 (u8 ird_enc )
2910+ {
2911+ switch (ird_enc ) {
2912+ case IRDMA_IRD_HW_SIZE_4096_GEN3 :
2913+ return 4096 ;
2914+ case IRDMA_IRD_HW_SIZE_2048_GEN3 :
2915+ return 2048 ;
2916+ case IRDMA_IRD_HW_SIZE_1024_GEN3 :
2917+ return 1024 ;
2918+ case IRDMA_IRD_HW_SIZE_512_GEN3 :
2919+ return 512 ;
2920+ case IRDMA_IRD_HW_SIZE_256_GEN3 :
2921+ return 256 ;
2922+ case IRDMA_IRD_HW_SIZE_128_GEN3 :
2923+ return 128 ;
2924+ case IRDMA_IRD_HW_SIZE_64_GEN3 :
2925+ return 64 ;
2926+ case IRDMA_IRD_HW_SIZE_32_GEN3 :
2927+ return 32 ;
2928+ case IRDMA_IRD_HW_SIZE_16_GEN3 :
2929+ return 16 ;
2930+ case IRDMA_IRD_HW_SIZE_8_GEN3 :
2931+ return 8 ;
2932+ case IRDMA_IRD_HW_SIZE_4_GEN3 :
2933+ return 4 ;
2934+ default :
2935+ return 4 ;
2936+ }
2937+ }
2938+
29042939/**
29052940 * irdma_check_cqp_progress - check cqp processing progress
29062941 * @timeout: timeout info struct
@@ -3212,6 +3247,7 @@ static int irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf,
32123247 struct irdma_hmc_fpm_misc * hmc_fpm_misc )
32133248{
32143249 struct irdma_hmc_obj_info * obj_info ;
3250+ u8 ird_encoding ;
32153251 u64 temp ;
32163252 u32 size ;
32173253 u16 max_pe_sds ;
@@ -3287,6 +3323,14 @@ static int irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf,
32873323 hmc_fpm_misc -> max_ceqs = FIELD_GET (IRDMA_QUERY_FPM_MAX_CEQS , temp );
32883324 hmc_fpm_misc -> ht_multiplier = FIELD_GET (IRDMA_QUERY_FPM_HTMULTIPLIER , temp );
32893325 hmc_fpm_misc -> timer_bucket = FIELD_GET (IRDMA_QUERY_FPM_TIMERBUCKET , temp );
3326+ if (FIELD_GET (IRDMA_MANAGE_RSRC_VER2 ,
3327+ dev -> feature_info [IRDMA_FTN_FLAGS ])) {
3328+ ird_encoding = (u8 )FIELD_GET (IRDMA_QUERY_FPM_MAX_IRD , temp );
3329+ hmc_fpm_misc -> ird =
3330+ irdma_sc_get_decoded_ird_size_gen_3 (ird_encoding ) / 2 ;
3331+ dev -> hw_attrs .max_hw_ird = hmc_fpm_misc -> ird ;
3332+ dev -> hw_attrs .max_hw_ord = hmc_fpm_misc -> ird ;
3333+ }
32903334 if (dev -> hw_attrs .uk_attrs .hw_rev == IRDMA_GEN_1 )
32913335 return 0 ;
32923336 irdma_sc_decode_fpm_query (buf , 96 , obj_info , IRDMA_HMC_IW_FSIMC );
@@ -5444,10 +5488,71 @@ static void irdma_set_host_hmc_rsrc_gen_3(struct irdma_sc_dev *dev)
54445488 avail_sds -= DIV_ROUND_UP (mrwanted , MAX_MR_PER_SD );
54455489 }
54465490
5491+ if (FIELD_GET (IRDMA_MANAGE_RSRC_VER2 , dev -> feature_info [IRDMA_FTN_FLAGS ]) &&
5492+ pblewanted > avail_sds * MAX_PBLE_PER_SD )
5493+ ibdev_dbg (to_ibdev (dev ),
5494+ "HMC: Warn: Resource version 2: pble wanted = 0x%x available = 0x%x\n" ,
5495+ pblewanted , avail_sds * MAX_PBLE_PER_SD );
5496+
54475497 pblewanted = min (pblewanted , avail_sds * MAX_PBLE_PER_SD );
54485498 hmc_info -> hmc_obj [IRDMA_HMC_IW_PBLE ].cnt = pblewanted ;
54495499}
54505500
5501+ /**
5502+ * irdma_verify_commit_fpm_gen_3 - verify query fpm values
5503+ * @dev: sc device struct
5504+ * @max_pages: max local memory available
5505+ * @qpwanted: number of qp's wanted
5506+ */
5507+ static int irdma_verify_commit_fpm_gen_3 (struct irdma_sc_dev * dev ,
5508+ u32 max_pages ,
5509+ u32 qpwanted )
5510+ {
5511+ struct irdma_hmc_fpm_misc * hmc_fpm_misc ;
5512+ u32 rrf_cnt , xf_cnt , timer_cnt , pages_needed ;
5513+ struct irdma_hmc_info * hmc_info ;
5514+ u32 rrffl_cnt = 0 ;
5515+ u32 xffl_cnt = 0 ;
5516+ u32 q1fl_cnt ;
5517+
5518+ hmc_info = dev -> hmc_info ;
5519+ hmc_fpm_misc = & dev -> hmc_fpm_misc ;
5520+
5521+ rrf_cnt = roundup_pow_of_two (IRDMA_RRF_MULTIPLIER * qpwanted );
5522+
5523+ if (hmc_info -> hmc_obj [IRDMA_HMC_IW_RRFFL ].max_cnt )
5524+ rrffl_cnt =
5525+ hmc_info -> hmc_obj [IRDMA_HMC_IW_RRF ].cnt /
5526+ hmc_fpm_misc -> rrf_block_size ;
5527+
5528+ xf_cnt = roundup_pow_of_two (IRDMA_XF_MULTIPLIER * qpwanted );
5529+
5530+ if (xf_cnt )
5531+ xffl_cnt = xf_cnt / hmc_fpm_misc -> xf_block_size ;
5532+
5533+ timer_cnt = (round_up (qpwanted , 512 ) / 512 + 1 ) *
5534+ hmc_fpm_misc -> timer_bucket ;
5535+
5536+ q1fl_cnt = hmc_info -> hmc_obj [IRDMA_HMC_IW_Q1 ].cnt / hmc_fpm_misc -> q1_block_size ;
5537+
5538+ pages_needed = irdma_get_objs_pages (dev , hmc_info , IRDMA_LOC_MEM );
5539+ if (pages_needed > max_pages ) {
5540+ ibdev_dbg (to_ibdev (dev ),
5541+ "HMC: FAIL: SW counts rrf_cnt = %u rrffl_cnt = %u timer_cnt = %u" ,
5542+ rrf_cnt , rrffl_cnt , timer_cnt );
5543+ ibdev_dbg (to_ibdev (dev ),
5544+ "HMC: FAIL: SW counts xf_cnt = %u xffl_cnt = %u q1fl_cnt = %u" ,
5545+ xf_cnt , xffl_cnt , q1fl_cnt );
5546+
5547+ return - EINVAL ;
5548+ }
5549+
5550+ hmc_fpm_misc -> max_sds -= pages_needed ;
5551+ hmc_fpm_misc -> loc_mem_pages -= pages_needed ;
5552+
5553+ return 0 ;
5554+ }
5555+
54515556/**
54525557 * irdma_set_loc_hmc_rsrc_gen_3 - calculate hmc resources for gen 3
54535558 * @dev: sc device struct
@@ -5463,6 +5568,9 @@ static int irdma_set_loc_hmc_rsrc_gen_3(struct irdma_sc_dev *dev,
54635568 struct irdma_hmc_info * hmc_info ;
54645569 u32 ird , ord ;
54655570
5571+ if (FIELD_GET (IRDMA_MANAGE_RSRC_VER2 , dev -> feature_info [IRDMA_FTN_FLAGS ]))
5572+ return irdma_verify_commit_fpm_gen_3 (dev , max_pages , qpwanted );
5573+
54665574 hmc_info = dev -> hmc_info ;
54675575 hmc_fpm_misc = & dev -> hmc_fpm_misc ;
54685576 ird = dev -> hw_attrs .max_hw_ird ;
@@ -5563,16 +5671,22 @@ static int cfg_fpm_value_gen_3(struct irdma_sc_dev *dev,
55635671 hmc_info -> hmc_obj [IRDMA_HMC_IW_OOISCFFL ].max_cnt = 0 ;
55645672 hmc_info -> hmc_obj [IRDMA_HMC_IW_HTE ].max_cnt = 0 ;
55655673 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIMC ].max_cnt = 0 ;
5566- hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].max_cnt =
5567- min (hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].max_cnt ,
5568- (u32 )IRDMA_FSIAV_CNT_MAX );
5674+
5675+ if (!FIELD_GET (IRDMA_MANAGE_RSRC_VER2 , dev -> feature_info [IRDMA_FTN_FLAGS ]))
5676+ hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].max_cnt =
5677+ min (hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].max_cnt ,
5678+ (u32 )IRDMA_FSIAV_CNT_MAX );
5679+
55695680 for (i = IRDMA_HMC_IW_QP ; i < IRDMA_HMC_IW_MAX ; i ++ )
55705681 hmc_info -> hmc_obj [i ].cnt = hmc_info -> hmc_obj [i ].max_cnt ;
55715682
55725683 while (qpwanted >= IRDMA_MIN_QP_CNT ) {
55735684 if (!irdma_set_loc_hmc_rsrc_gen_3 (dev , loc_mem_pages , qpwanted ))
55745685 break ;
55755686
5687+ if (FIELD_GET (IRDMA_MANAGE_RSRC_VER2 , dev -> feature_info [IRDMA_FTN_FLAGS ]))
5688+ return - EINVAL ;
5689+
55765690 qpwanted /= 2 ;
55775691 if (mrte_loc == IRDMA_LOC_MEM ) {
55785692 mrwanted = qpwanted * IRDMA_MIN_MR_PER_QP ;
@@ -5659,6 +5773,7 @@ int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count)
56595773 hmc_info -> hmc_obj [IRDMA_HMC_IW_PBLE ].max_cnt ,
56605774 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIMC ].max_cnt ,
56615775 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].max_cnt );
5776+
56625777 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIMC ].cnt =
56635778 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIMC ].max_cnt ;
56645779 hmc_info -> hmc_obj [IRDMA_HMC_IW_FSIAV ].cnt =
0 commit comments