@@ -2240,12 +2240,13 @@ static int qed_nvm_flash_image_validate(struct qed_dev *cdev,
22402240/* Binary file format -
22412241 * /----------------------------------------------------------------------\
22422242 * 0B | 0x5 [command index] |
2243- * 4B | Entity ID | Reserved | Number of config attributes |
2244- * 8B | Config ID | Length | Value |
2243+ * 4B | Number of config attributes | Reserved |
2244+ * 4B | Config ID | Entity ID | Length |
2245+ * 4B | Value |
22452246 * | |
22462247 * \----------------------------------------------------------------------/
2247- * There can be several cfg_id-Length-Value sets as specified by 'Number of...'.
2248- * Entity ID - A non zero entity value for which the config need to be updated .
2248+ * There can be several cfg_id-entity_id- Length-Value sets as specified by
2249+ * 'Number of config attributes' .
22492250 *
22502251 * The API parses config attributes from the user provided buffer and flashes
22512252 * them to the respective NVM path using Management FW inerface.
@@ -2265,18 +2266,17 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
22652266
22662267 /* NVM CFG ID attribute header */
22672268 * data += 4 ;
2268- entity_id = * * data ;
2269- * data += 2 ;
22702269 count = * ((u16 * )* data );
2271- * data += 2 ;
2270+ * data += 4 ;
22722271
22732272 DP_VERBOSE (cdev , NETIF_MSG_DRV ,
2274- "Read config ids: entity id %02x num _attrs = %0d\n" ,
2275- entity_id , count );
2273+ "Read config ids: num_attrs = %0d\n" , count );
22762274 /* NVM CFG ID attributes */
22772275 for (i = 0 ; i < count ; i ++ ) {
22782276 cfg_id = * ((u16 * )* data );
22792277 * data += 2 ;
2278+ entity_id = * * data ;
2279+ (* data )++ ;
22802280 len = * * data ;
22812281 (* data )++ ;
22822282 memcpy (buf , * data , len );
@@ -2286,7 +2286,8 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
22862286 QED_NVM_CFG_SET_FLAGS ;
22872287
22882288 DP_VERBOSE (cdev , NETIF_MSG_DRV ,
2289- "cfg_id = %d len = %d\n" , cfg_id , len );
2289+ "cfg_id = %d entity = %d len = %d\n" , cfg_id ,
2290+ entity_id , len );
22902291 rc = qed_mcp_nvm_set_cfg (hwfn , ptt , cfg_id , entity_id , flags ,
22912292 buf , len );
22922293 if (rc ) {
@@ -2300,6 +2301,31 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
23002301 return rc ;
23012302}
23022303
2304+ #define QED_MAX_NVM_BUF_LEN 32
2305+ static int qed_nvm_flash_cfg_len (struct qed_dev * cdev , u32 cmd )
2306+ {
2307+ struct qed_hwfn * hwfn = QED_LEADING_HWFN (cdev );
2308+ u8 buf [QED_MAX_NVM_BUF_LEN ];
2309+ struct qed_ptt * ptt ;
2310+ u32 len ;
2311+ int rc ;
2312+
2313+ ptt = qed_ptt_acquire (hwfn );
2314+ if (!ptt )
2315+ return QED_MAX_NVM_BUF_LEN ;
2316+
2317+ rc = qed_mcp_nvm_get_cfg (hwfn , ptt , cmd , 0 , QED_NVM_CFG_GET_FLAGS , buf ,
2318+ & len );
2319+ if (rc || !len ) {
2320+ DP_ERR (cdev , "Error %d reading %d\n" , rc , cmd );
2321+ len = QED_MAX_NVM_BUF_LEN ;
2322+ }
2323+
2324+ qed_ptt_release (hwfn , ptt );
2325+
2326+ return len ;
2327+ }
2328+
23032329static int qed_nvm_flash_cfg_read (struct qed_dev * cdev , u8 * * data ,
23042330 u32 cmd , u32 entity_id )
23052331{
@@ -2657,6 +2683,7 @@ const struct qed_common_ops qed_common_ops_pass = {
26572683 .read_module_eeprom = & qed_read_module_eeprom ,
26582684 .get_affin_hwfn_idx = & qed_get_affin_hwfn_idx ,
26592685 .read_nvm_cfg = & qed_nvm_flash_cfg_read ,
2686+ .read_nvm_cfg_len = & qed_nvm_flash_cfg_len ,
26602687 .set_grc_config = & qed_set_grc_config ,
26612688};
26622689
0 commit comments