net/ice/base: fix alignment
[dpdk.git] / drivers / net / ice / base / ice_flex_pipe.c
index 6ae71e6..0357fbd 100644 (file)
@@ -131,8 +131,9 @@ static struct ice_buf_table *ice_find_buf_table(struct ice_seg *ice_seg)
 {
        struct ice_nvm_table *nvms;
 
-       nvms = (struct ice_nvm_table *)(ice_seg->device_table +
-               LE32_TO_CPU(ice_seg->device_table_count));
+       nvms = (struct ice_nvm_table *)
+               (ice_seg->device_table +
+                LE32_TO_CPU(ice_seg->device_table_count));
 
        return (_FORCE_ struct ice_buf_table *)
                (nvms->vers + LE32_TO_CPU(nvms->table_count));
@@ -808,7 +809,6 @@ ice_aq_download_pkg(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
        return status;
 }
 
-
 /**
  * ice_aq_update_pkg
  * @hw: pointer to the hardware structure
@@ -1180,7 +1180,6 @@ init_pkg_free_alloc:
        return status;
 }
 
-
 /**
  * ice_verify_pkg - verify package
  * @pkg: pointer to the package buffer
@@ -1286,7 +1285,6 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
 
 /**
  * ice_chk_pkg_version - check package version for compatibility with driver
- * @hw: pointer to the hardware structure
  * @pkg_ver: pointer to a version structure to check
  *
  * Check to make sure that the package about to be downloaded is compatible with
@@ -1294,18 +1292,11 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
  * version must match our ICE_PKG_SUPP_VER_MAJ and ICE_PKG_SUPP_VER_MNR
  * definitions.
  */
-static enum ice_status
-ice_chk_pkg_version(struct ice_hw *hw, struct ice_pkg_ver *pkg_ver)
+static enum ice_status ice_chk_pkg_version(struct ice_pkg_ver *pkg_ver)
 {
        if (pkg_ver->major != ICE_PKG_SUPP_VER_MAJ ||
-           pkg_ver->minor != ICE_PKG_SUPP_VER_MNR) {
-               ice_info(hw, "ERROR: Incompatible package: %d.%d.%d.%d - requires package version: %d.%d.*.*\n",
-                        pkg_ver->major, pkg_ver->minor, pkg_ver->update,
-                        pkg_ver->draft, ICE_PKG_SUPP_VER_MAJ,
-                        ICE_PKG_SUPP_VER_MNR);
-
+           pkg_ver->minor != ICE_PKG_SUPP_VER_MNR)
                return ICE_ERR_NOT_SUPPORTED;
-       }
 
        return ICE_SUCCESS;
 }
@@ -1360,7 +1351,7 @@ enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
        /* before downloading the package, check package version for
         * compatibility with driver
         */
-       status = ice_chk_pkg_version(hw, &hw->pkg_ver);
+       status = ice_chk_pkg_version(&hw->pkg_ver);
        if (status)
                return status;
 
@@ -1386,7 +1377,7 @@ enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
        if (!status) {
                status = ice_get_pkg_info(hw);
                if (!status)
-                       status = ice_chk_pkg_version(hw, &hw->active_pkg_ver);
+                       status = ice_chk_pkg_version(&hw->active_pkg_ver);
        }
 
        if (!status) {
@@ -1662,6 +1653,47 @@ err:
        return ICE_ERR_NO_MEMORY;
 }
 
+/**
+ * ice_init_profile_to_result_bm - Initialize the profile result index bitmap
+ * @hw: pointer to hardware structure
+ */
+void
+ice_init_prof_result_bm(struct ice_hw *hw)
+{
+       struct ice_pkg_enum state;
+       struct ice_seg *ice_seg;
+       struct ice_fv *fv;
+
+       if (!hw->seg)
+               return;
+
+       ice_seg = hw->seg;
+       do {
+               u32 off;
+               u16 i;
+
+               fv = (struct ice_fv *)
+                       ice_pkg_enum_entry(ice_seg, &state, ICE_SID_FLD_VEC_SW,
+                                          &off, ice_sw_fv_handler);
+               ice_seg = NULL;
+               if (!fv)
+                       break;
+
+               ice_zero_bitmap(hw->switch_info->prof_res_bm[off],
+                               ICE_MAX_FV_WORDS);
+
+               /* Determine empty field vector indices, these can be
+                * used for recipe results. Skip index 0, since it is
+                * always used for Switch ID.
+                */
+               for (i = 1; i < ICE_MAX_FV_WORDS; i++)
+                       if (fv->ew[i].prot_id == ICE_PROT_INVALID &&
+                           fv->ew[i].off == ICE_FV_OFFSET_INVAL)
+                               ice_set_bit(i,
+                                           hw->switch_info->prof_res_bm[off]);
+       } while (fv);
+}
+
 /**
  * ice_pkg_buf_free
  * @hw: pointer to the HW structure
@@ -1921,7 +1953,7 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port)
        if (!bld)
                return ICE_ERR_NO_MEMORY;
 
-       /* allocate 2 sections, one for RX parser, one for TX parser */
+       /* allocate 2 sections, one for Rx parser, one for Tx parser */
        if (ice_pkg_buf_reserve_section(bld, 2))
                goto ice_create_tunnel_err;
 
@@ -1951,7 +1983,7 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port)
                    offsetof(struct ice_boost_key_value, hv_dst_port_key),
                    sizeof(sect_rx->tcam[0].key.key.hv_dst_port_key));
 
-       /* exact copy of entry to TX section entry */
+       /* exact copy of entry to Tx section entry */
        ice_memcpy(sect_tx->tcam, sect_rx->tcam, sizeof(*sect_tx->tcam),
                   ICE_NONDMA_TO_NONDMA);
 
@@ -2002,7 +2034,7 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)
        if (!bld)
                return ICE_ERR_NO_MEMORY;
 
-       /* allocate 2 sections, one for RX parser, one for TX parser */
+       /* allocate 2 sections, one for Rx parser, one for Tx parser */
        if (ice_pkg_buf_reserve_section(bld, 2))
                goto ice_destroy_tunnel_err;
 
@@ -2020,8 +2052,8 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)
                goto ice_destroy_tunnel_err;
        sect_tx->count = CPU_TO_LE16(1);
 
-       /* copy original boost entry to update package buffer, one copy to RX
-        * section, another copy to the TX section
+       /* copy original boost entry to update package buffer, one copy to Rx
+        * section, another copy to the Tx section
         */
        for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
                if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use &&
@@ -2084,7 +2116,6 @@ ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u8 fv_idx,
 
 /* PTG Management */
 
-
 /**
  * ice_ptg_find_ptype - Search for packet type group using packet type (ptype)
  * @hw: pointer to the hardware structure
@@ -2121,7 +2152,6 @@ void ice_ptg_alloc_val(struct ice_hw *hw, enum ice_block blk, u8 ptg)
        hw->blk[blk].xlt1.ptg_tbl[ptg].in_use = true;
 }
 
-
 /**
  * ice_ptg_remove_ptype - Removes ptype from a particular packet type group
  * @hw: pointer to the hardware structure
@@ -2315,7 +2345,6 @@ ice_match_prop_lst(struct LIST_HEAD_TYPE *list1, struct LIST_HEAD_TYPE *list2)
 
 /* VSIG Management */
 
-
 /**
  * ice_vsig_find_vsi - find a VSIG that contains a specified VSI
  * @hw: pointer to the hardware structure
@@ -2919,7 +2948,7 @@ ice_write_prof_mask_reg(struct ice_hw *hw, enum ice_block blk, u16 mask_idx,
  * ice_write_prof_mask_enable_res - write profile mask enable register
  * @hw: pointer to the HW struct
  * @blk: hardware block
- * @prof_id: profile id
+ * @prof_id: profile ID
  * @enable_mask: enable mask
  */
 static void
@@ -3095,7 +3124,7 @@ exit_ice_free_prof_mask:
  * ice_free_prof_masks - free all profile masks for a profile
  * @hw: pointer to the HW struct
  * @blk: hardware block
- * @prof_id: profile id
+ * @prof_id: profile ID
  */
 static enum ice_status
 ice_free_prof_masks(struct ice_hw *hw, enum ice_block blk, u16 prof_id)
@@ -3157,7 +3186,7 @@ void ice_shutdown_all_prof_masks(struct ice_hw *hw)
  * ice_update_prof_masking - set registers according to masking
  * @hw: pointer to the HW struct
  * @blk: hardware block
- * @prof_id: profile id
+ * @prof_id: profile ID
  * @es: field vector
  * @masks: masks
  */
@@ -3377,7 +3406,7 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
        void *sect;
 
        /* if the HW segment pointer is null then the first iteration of
-        * ice_pkg_enum_section() will fail. In this case the Hw tables will
+        * ice_pkg_enum_section() will fail. In this case the HW tables will
         * not be filled and return success.
         */
        if (!hw->seg) {
@@ -3469,7 +3498,7 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
                        return;
 
                /* if the sum of section size and offset exceed destination size
-                * then we are out of bounds of the Hw table size for that PF.
+                * then we are out of bounds of the HW table size for that PF.
                 * Changing section length to fill the remaining table space
                 * of that PF.
                 */
@@ -3488,7 +3517,7 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
  *
  * Reads the current package contents and populates the driver
  * database with the data iteratively for all advanced feature
- * blocks. Assume that the Hw tables have been allocated.
+ * blocks. Assume that the HW tables have been allocated.
  */
 void ice_fill_blk_tbls(struct ice_hw *hw)
 {
@@ -4944,12 +4973,11 @@ ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
                struct ice_vsig_prof *p;
 
                /* copy to the input list */
-               p = (struct ice_vsig_prof *)ice_malloc(hw, sizeof(*p));
+               p = (struct ice_vsig_prof *)ice_memdup(hw, ent1, sizeof(*p),
+                                                      ICE_NONDMA_TO_NONDMA);
                if (!p)
                        goto err_ice_get_profs_vsig;
 
-               ice_memcpy(p, ent1, sizeof(*p), ICE_NONDMA_TO_NONDMA);
-
                LIST_ADD_TAIL(&p->list, lst);
        }