net/ice: revert fake TSO fixes
[dpdk.git] / drivers / net / ice / base / ice_nvm.c
index d5e6215..bfeade6 100644 (file)
@@ -17,7 +17,7 @@
  *
  * Read the NVM using the admin queue commands (0x0701)
  */
-static enum ice_status
+enum ice_status
 ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
                void *data, bool last_command, bool read_shadow_ram,
                struct ice_sq_cd *cd)
@@ -186,7 +186,7 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
  *
  * This function will request NVM ownership.
  */
-static enum ice_status
+enum ice_status
 ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access)
 {
        ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
@@ -203,7 +203,7 @@ ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access)
  *
  * This function will release NVM ownership.
  */
-static void ice_release_nvm(struct ice_hw *hw)
+void ice_release_nvm(struct ice_hw *hw)
 {
        ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
 
@@ -300,6 +300,67 @@ ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len,
        return ICE_ERR_DOES_NOT_EXIST;
 }
 
+/**
+ * ice_read_pba_string - Reads part number string from NVM
+ * @hw: pointer to hardware structure
+ * @pba_num: stores the part number string from the NVM
+ * @pba_num_size: part number string buffer length
+ *
+ * Reads the part number string from the NVM.
+ */
+enum ice_status
+ice_read_pba_string(struct ice_hw *hw, u8 *pba_num, u32 pba_num_size)
+{
+       u16 pba_tlv, pba_tlv_len;
+       enum ice_status status;
+       u16 pba_word, pba_size;
+       u16 i;
+
+       status = ice_get_pfa_module_tlv(hw, &pba_tlv, &pba_tlv_len,
+                                       ICE_SR_PBA_BLOCK_PTR);
+       if (status != ICE_SUCCESS) {
+               ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block TLV.\n");
+               return status;
+       }
+
+       /* pba_size is the next word */
+       status = ice_read_sr_word(hw, (pba_tlv + 2), &pba_size);
+       if (status != ICE_SUCCESS) {
+               ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Section size.\n");
+               return status;
+       }
+
+       if (pba_tlv_len < pba_size) {
+               ice_debug(hw, ICE_DBG_INIT, "Invalid PBA Block TLV size.\n");
+               return ICE_ERR_INVAL_SIZE;
+       }
+
+       /* Subtract one to get PBA word count (PBA Size word is included in
+        * total size)
+        */
+       pba_size--;
+       if (pba_num_size < (((u32)pba_size * 2) + 1)) {
+               ice_debug(hw, ICE_DBG_INIT,
+                         "Buffer too small for PBA data.\n");
+               return ICE_ERR_PARAM;
+       }
+
+       for (i = 0; i < pba_size; i++) {
+               status = ice_read_sr_word(hw, (pba_tlv + 2 + 1) + i, &pba_word);
+               if (status != ICE_SUCCESS) {
+                       ice_debug(hw, ICE_DBG_INIT,
+                                 "Failed to read PBA Block word %d.\n", i);
+                       return status;
+               }
+
+               pba_num[(i * 2)] = (pba_word >> 8) & 0xFF;
+               pba_num[(i * 2) + 1] = pba_word & 0xFF;
+       }
+       pba_num[(pba_size * 2)] = '\0';
+
+       return status;
+}
+
 /**
  * ice_get_orom_ver_info - Read Option ROM version information
  * @hw: pointer to the HW struct
@@ -488,6 +549,11 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
        case ICE_DEV_ID_E822L_SFP:
        case ICE_DEV_ID_E822L_10G_BASE_T:
        case ICE_DEV_ID_E822L_SGMII:
+       case ICE_DEV_ID_E823L_BACKPLANE:
+       case ICE_DEV_ID_E823L_SFP:
+       case ICE_DEV_ID_E823L_10G_BASE_T:
+       case ICE_DEV_ID_E823L_1GBE:
+       case ICE_DEV_ID_E823L_QSFP:
                return status;
        default:
                break;