net/ice/base: align macro names to specification
[dpdk.git] / drivers / net / ice / base / ice_flex_pipe.c
index 8d918ef..e511b50 100644 (file)
@@ -807,6 +807,28 @@ ice_aq_download_pkg(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
        return status;
 }
 
+/**
+ * ice_aq_upload_section
+ * @hw: pointer to the hardware structure
+ * @pkg_buf: the package buffer which will receive the section
+ * @buf_size: the size of the package buffer
+ * @cd: pointer to command details structure or NULL
+ *
+ * Upload Section (0x0C41)
+ */
+enum ice_status
+ice_aq_upload_section(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
+                     u16 buf_size, struct ice_sq_cd *cd)
+{
+       struct ice_aq_desc desc;
+
+       ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_upload_section);
+       desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
+
+       return ice_aq_send_cmd(hw, &desc, pkg_buf, buf_size, cd);
+}
+
 /**
  * ice_aq_update_pkg
  * @hw: pointer to the hardware structure
@@ -1006,6 +1028,13 @@ ice_dwnld_cfg_bufs(struct ice_hw *hw, struct ice_buf *bufs, u32 count)
                        break;
        }
 
+       if (!status) {
+               status = ice_set_vlan_mode(hw);
+               if (status)
+                       ice_debug(hw, ICE_DBG_PKG, "Failed to set VLAN mode: err %d\n",
+                                 status);
+       }
+
        ice_release_global_cfg_lock(hw);
 
        return status;
@@ -1075,34 +1104,40 @@ ice_download_pkg(struct ice_hw *hw, struct ice_seg *ice_seg)
 static enum ice_status
 ice_init_pkg_info(struct ice_hw *hw, struct ice_pkg_hdr *pkg_hdr)
 {
-       struct ice_global_metadata_seg *meta_seg;
        struct ice_generic_seg_hdr *seg_hdr;
 
        ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
        if (!pkg_hdr)
                return ICE_ERR_PARAM;
 
-       meta_seg = (struct ice_global_metadata_seg *)
-                  ice_find_seg_in_pkg(hw, SEGMENT_TYPE_METADATA, pkg_hdr);
-       if (meta_seg) {
-               hw->pkg_ver = meta_seg->pkg_ver;
-               ice_memcpy(hw->pkg_name, meta_seg->pkg_name,
-                          sizeof(hw->pkg_name), ICE_NONDMA_TO_NONDMA);
+       seg_hdr = (struct ice_generic_seg_hdr *)
+               ice_find_seg_in_pkg(hw, SEGMENT_TYPE_ICE, pkg_hdr);
+       if (seg_hdr) {
+               struct ice_meta_sect *meta;
+               struct ice_pkg_enum state;
+
+               ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
+
+               /* Get package information from the Metadata Section */
+               meta = (struct ice_meta_sect *)
+                       ice_pkg_enum_section((struct ice_seg *)seg_hdr, &state,
+                                            ICE_SID_METADATA);
+               if (!meta) {
+                       ice_debug(hw, ICE_DBG_INIT, "Did not find ice metadata section in package\n");
+                       return ICE_ERR_CFG;
+               }
+
+               hw->pkg_ver = meta->ver;
+               ice_memcpy(hw->pkg_name, meta->name, sizeof(meta->name),
+                          ICE_NONDMA_TO_NONDMA);
 
                ice_debug(hw, ICE_DBG_PKG, "Pkg: %d.%d.%d.%d, %s\n",
-                         meta_seg->pkg_ver.major, meta_seg->pkg_ver.minor,
-                         meta_seg->pkg_ver.update, meta_seg->pkg_ver.draft,
-                         meta_seg->pkg_name);
-       } else {
-               ice_debug(hw, ICE_DBG_INIT, "Did not find metadata segment in driver package\n");
-               return ICE_ERR_CFG;
-       }
+                         meta->ver.major, meta->ver.minor, meta->ver.update,
+                         meta->ver.draft, meta->name);
 
-       seg_hdr = ice_find_seg_in_pkg(hw, SEGMENT_TYPE_ICE, pkg_hdr);
-       if (seg_hdr) {
-               hw->ice_pkg_ver = seg_hdr->seg_format_ver;
-               ice_memcpy(hw->ice_pkg_name, seg_hdr->seg_id,
-                          sizeof(hw->ice_pkg_name), ICE_NONDMA_TO_NONDMA);
+               hw->ice_seg_fmt_ver = seg_hdr->seg_format_ver;
+               ice_memcpy(hw->ice_seg_id, seg_hdr->seg_id,
+                          sizeof(hw->ice_seg_id), ICE_NONDMA_TO_NONDMA);
 
                ice_debug(hw, ICE_DBG_PKG, "Ice Seg: %d.%d.%d.%d, %s\n",
                          seg_hdr->seg_format_ver.major,
@@ -1787,7 +1822,7 @@ void ice_init_prof_result_bm(struct ice_hw *hw)
  *
  * Frees a package buffer
  */
-static void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build *bld)
+void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build *bld)
 {
        ice_free(hw, bld);
 }
@@ -1827,7 +1862,7 @@ ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count)
        bld->reserved_section_table_entries += count;
 
        data_end = LE16_TO_CPU(buf->data_end) +
-                  (count * sizeof(buf->section_entry[0]));
+               FLEX_ARRAY_SIZE(buf, section_entry, count);
        buf->data_end = CPU_TO_LE16(data_end);
 
        return ICE_SUCCESS;
@@ -1886,6 +1921,43 @@ ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size)
        return NULL;
 }
 
+/**
+ * ice_pkg_buf_alloc_single_section
+ * @hw: pointer to the HW structure
+ * @type: the section type value
+ * @size: the size of the section to reserve (in bytes)
+ * @section: returns pointer to the section
+ *
+ * Allocates a package buffer with a single section.
+ * Note: all package contents must be in Little Endian form.
+ */
+struct ice_buf_build *
+ice_pkg_buf_alloc_single_section(struct ice_hw *hw, u32 type, u16 size,
+                                void **section)
+{
+       struct ice_buf_build *buf;
+
+       if (!section)
+               return NULL;
+
+       buf = ice_pkg_buf_alloc(hw);
+       if (!buf)
+               return NULL;
+
+       if (ice_pkg_buf_reserve_section(buf, 1))
+               goto ice_pkg_buf_alloc_single_section_err;
+
+       *section = ice_pkg_buf_alloc_section(buf, type, size);
+       if (!*section)
+               goto ice_pkg_buf_alloc_single_section_err;
+
+       return buf;
+
+ice_pkg_buf_alloc_single_section_err:
+       ice_pkg_buf_free(hw, buf);
+       return NULL;
+}
+
 /**
  * ice_pkg_buf_get_active_sections
  * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc())
@@ -1913,7 +1985,7 @@ static u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld)
  *
  * Return a pointer to the buffer's header
  */
-static struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld)
+struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld)
 {
        if (!bld)
                return NULL;
@@ -2150,7 +2222,7 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)
        u16 count = 0;
        u16 index;
        u16 size;
-       u16 i;
+       u16 i, j;
 
        ice_acquire_lock(&hw->tnl_lock);
 
@@ -2190,30 +2262,31 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)
                                          size);
        if (!sect_rx)
                goto ice_destroy_tunnel_err;
-       sect_rx->count = CPU_TO_LE16(1);
+       sect_rx->count = CPU_TO_LE16(count);
 
        sect_tx = (struct ice_boost_tcam_section *)
                ice_pkg_buf_alloc_section(bld, ICE_SID_TXPARSER_BOOST_TCAM,
                                          size);
        if (!sect_tx)
                goto ice_destroy_tunnel_err;
-       sect_tx->count = CPU_TO_LE16(1);
+       sect_tx->count = CPU_TO_LE16(count);
 
        /* 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++)
+       for (i = 0, j = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
                if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use &&
                    (all || hw->tnl.tbl[i].port == port)) {
-                       ice_memcpy(sect_rx->tcam + i,
+                       ice_memcpy(sect_rx->tcam + j,
                                   hw->tnl.tbl[i].boost_entry,
                                   sizeof(*sect_rx->tcam),
                                   ICE_NONDMA_TO_NONDMA);
-                       ice_memcpy(sect_tx->tcam + i,
+                       ice_memcpy(sect_tx->tcam + j,
                                   hw->tnl.tbl[i].boost_entry,
                                   sizeof(*sect_tx->tcam),
                                   ICE_NONDMA_TO_NONDMA);
                        hw->tnl.tbl[i].marked = true;
+                       j++;
                }
 
        status = ice_update_pkg(hw, ice_pkg_buf(bld), 1);