@@ -7208,6 +7208,72 @@ static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp, int ctx_max)
72087208 return 0 ;
72097209}
72107210
7211+ #define BNXT_CTX_INIT_VALID (flags ) \
7212+ (!!((flags) & \
7213+ FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_ENABLE_CTX_KIND_INIT))
7214+
7215+ static int bnxt_hwrm_func_backing_store_qcaps_v2 (struct bnxt * bp )
7216+ {
7217+ struct hwrm_func_backing_store_qcaps_v2_output * resp ;
7218+ struct hwrm_func_backing_store_qcaps_v2_input * req ;
7219+ u16 last_valid_type = BNXT_CTX_INV ;
7220+ struct bnxt_ctx_mem_info * ctx ;
7221+ u16 type ;
7222+ int rc ;
7223+
7224+ rc = hwrm_req_init (bp , req , HWRM_FUNC_BACKING_STORE_QCAPS_V2 );
7225+ if (rc )
7226+ return rc ;
7227+
7228+ ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
7229+ if (!ctx )
7230+ return - ENOMEM ;
7231+ bp -> ctx = ctx ;
7232+
7233+ resp = hwrm_req_hold (bp , req );
7234+
7235+ for (type = 0 ; type < BNXT_CTX_V2_MAX ; ) {
7236+ struct bnxt_ctx_mem_type * ctxm = & ctx -> ctx_arr [type ];
7237+ u8 init_val , init_off , i ;
7238+ __le32 * p ;
7239+ u32 flags ;
7240+
7241+ req -> type = cpu_to_le16 (type );
7242+ rc = hwrm_req_send (bp , req );
7243+ if (rc )
7244+ goto ctx_done ;
7245+ flags = le32_to_cpu (resp -> flags );
7246+ type = le16_to_cpu (resp -> next_valid_type );
7247+ if (!(flags & FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_TYPE_VALID ))
7248+ continue ;
7249+
7250+ ctxm -> type = le16_to_cpu (resp -> type );
7251+ last_valid_type = ctxm -> type ;
7252+ ctxm -> entry_size = le16_to_cpu (resp -> entry_size );
7253+ ctxm -> flags = flags ;
7254+ ctxm -> instance_bmap = le32_to_cpu (resp -> instance_bit_map );
7255+ ctxm -> entry_multiple = resp -> entry_multiple ;
7256+ ctxm -> max_entries = le32_to_cpu (resp -> max_num_entries );
7257+ ctxm -> min_entries = le32_to_cpu (resp -> min_num_entries );
7258+ init_val = resp -> ctx_init_value ;
7259+ init_off = resp -> ctx_init_offset ;
7260+ bnxt_init_ctx_initializer (ctxm , init_val , init_off ,
7261+ BNXT_CTX_INIT_VALID (flags ));
7262+ ctxm -> split_entry_cnt = min_t (u8 , resp -> subtype_valid_cnt ,
7263+ BNXT_MAX_SPLIT_ENTRY );
7264+ for (i = 0 , p = & resp -> split_entry_0 ; i < ctxm -> split_entry_cnt ;
7265+ i ++ , p ++ )
7266+ ctxm -> split [i ] = le32_to_cpu (* p );
7267+ }
7268+ if (last_valid_type < BNXT_CTX_V2_MAX )
7269+ ctx -> ctx_arr [last_valid_type ].last = true;
7270+ rc = bnxt_alloc_all_ctx_pg_info (bp , BNXT_CTX_V2_MAX );
7271+
7272+ ctx_done :
7273+ hwrm_req_drop (bp , req );
7274+ return rc ;
7275+ }
7276+
72117277static int bnxt_hwrm_func_backing_store_qcaps (struct bnxt * bp )
72127278{
72137279 struct hwrm_func_backing_store_qcaps_output * resp ;
@@ -7217,6 +7283,9 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
72177283 if (bp -> hwrm_spec_code < 0x10902 || BNXT_VF (bp ) || bp -> ctx )
72187284 return 0 ;
72197285
7286+ if (bp -> fw_cap & BNXT_FW_CAP_BACKING_STORE_V2 )
7287+ return bnxt_hwrm_func_backing_store_qcaps_v2 (bp );
7288+
72207289 rc = hwrm_req_init (bp , req , HWRM_FUNC_BACKING_STORE_QCAPS );
72217290 if (rc )
72227291 return rc ;
@@ -7229,13 +7298,15 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
72297298 u8 init_val , init_idx = 0 ;
72307299 u16 init_mask ;
72317300
7232- ctx = kzalloc ( sizeof ( * ctx ), GFP_KERNEL ) ;
7301+ ctx = bp -> ctx ;
72337302 if (!ctx ) {
7234- rc = - ENOMEM ;
7235- goto ctx_err ;
7303+ ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
7304+ if (!ctx ) {
7305+ rc = - ENOMEM ;
7306+ goto ctx_err ;
7307+ }
7308+ bp -> ctx = ctx ;
72367309 }
7237- bp -> ctx = ctx ;
7238-
72397310 init_val = resp -> ctx_kind_initializer ;
72407311 init_mask = le16_to_cpu (resp -> ctx_init_mask );
72417312
@@ -7607,7 +7678,7 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
76077678 if (!ctx )
76087679 return ;
76097680
7610- for (type = 0 ; type < BNXT_CTX_MAX ; type ++ ) {
7681+ for (type = 0 ; type < BNXT_CTX_V2_MAX ; type ++ ) {
76117682 struct bnxt_ctx_mem_type * ctxm = & ctx -> ctx_arr [type ];
76127683 struct bnxt_ctx_pg_info * ctx_pg = ctxm -> pg_info ;
76137684 int i , n = 1 ;
@@ -7914,6 +7985,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
79147985 bp -> fw_cap |= BNXT_FW_CAP_HOT_RESET_IF ;
79157986 if (BNXT_PF (bp ) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED ))
79167987 bp -> fw_cap |= BNXT_FW_CAP_LIVEPATCH ;
7988+ if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_BS_V2_SUPPORTED )
7989+ bp -> fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2 ;
79177990
79187991 flags_ext2 = le32_to_cpu (resp -> flags_ext2 );
79197992 if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED )
0 commit comments