net/ice/base: introduce some new macros
[dpdk.git] / drivers / net / ice / base / ice_flow.c
index 9f2a794..36d31fa 100644 (file)
@@ -195,21 +195,11 @@ static const u32 ice_ptypes_arp_of[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
-/* Packet types for packets with an Outermost/First UDP header */
-static const u32 ice_ptypes_udp_of[] = {
-       0x81000000, 0x00000000, 0x04000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x00000000, 0x00000000,
-};
-
-/* Packet types for packets with an Innermost/Last UDP header */
+/* UDP Packet types for non-tunneled packets or tunneled
+ * packets with inner UDP.
+ */
 static const u32 ice_ptypes_udp_il[] = {
-       0x80000000, 0x20204040, 0x00081010, 0x80810102,
+       0x81000000, 0x20204040, 0x04081010, 0x80810102,
        0x00204040, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -222,7 +212,7 @@ static const u32 ice_ptypes_udp_il[] = {
 /* Packet types for packets with an Innermost/Last TCP header */
 static const u32 ice_ptypes_tcp_il[] = {
        0x04000000, 0x80810102, 0x10204040, 0x42040408,
-       0x00810002, 0x00000000, 0x00000000, 0x00000000,
+       0x00810102, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -294,10 +284,10 @@ static const u32 ice_ptypes_mac_il[] = {
 /* Manage parameters and info. used during the creation of a flow profile */
 struct ice_flow_prof_params {
        enum ice_block blk;
-       struct ice_flow_prof *prof;
-
        u16 entry_length; /* # of bytes formatted entry will require */
        u8 es_cnt;
+       struct ice_flow_prof *prof;
+
        /* For ACL, the es[0] will have the data of ICE_RX_MDID_PKT_FLAGS_15_0
         * This will give us the direction flags.
         */
@@ -425,9 +415,6 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                const ice_bitmap_t *src;
                u32 hdrs;
 
-               if (i > 0 && (i + 1) < prof->segs_cnt)
-                       continue;
-
                hdrs = prof->segs[i].hdrs;
 
                if (hdrs & ICE_FLOW_SEG_HDR_ETH) {
@@ -473,8 +460,7 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                                       ICE_FLOW_PTYPE_MAX);
                        hdrs &= ~ICE_FLOW_SEG_HDR_ICMP;
                } else if (hdrs & ICE_FLOW_SEG_HDR_UDP) {
-                       src = !i ? (const ice_bitmap_t *)ice_ptypes_udp_of :
-                               (const ice_bitmap_t *)ice_ptypes_udp_il;
+                       src = (const ice_bitmap_t *)ice_ptypes_udp_il;
                        ice_and_bitmap(params->ptypes, params->ptypes, src,
                                       ICE_FLOW_PTYPE_MAX);
                        hdrs &= ~ICE_FLOW_SEG_HDR_UDP;
@@ -858,6 +844,7 @@ ice_flow_proc_segs(struct ice_hw *hw, struct ice_flow_prof_params *params)
 
 #define ICE_FLOW_FIND_PROF_CHK_FLDS    0x00000001
 #define ICE_FLOW_FIND_PROF_CHK_VSI     0x00000002
+#define ICE_FLOW_FIND_PROF_NOT_CHK_DIR 0x00000004
 
 /**
  * ice_flow_find_prof_conds - Find a profile matching headers and conditions
@@ -877,7 +864,8 @@ ice_flow_find_prof_conds(struct ice_hw *hw, enum ice_block blk,
        struct ice_flow_prof *p;
 
        LIST_FOR_EACH_ENTRY(p, &hw->fl_profs[blk], ice_flow_prof, l_entry) {
-               if (p->dir == dir && segs_cnt && segs_cnt == p->segs_cnt) {
+               if ((p->dir == dir || conds & ICE_FLOW_FIND_PROF_NOT_CHK_DIR) &&
+                   segs_cnt && segs_cnt == p->segs_cnt) {
                        u8 i;
 
                        /* Check for profile-VSI association if specified */
@@ -946,17 +934,15 @@ ice_flow_find_prof_id(struct ice_hw *hw, enum ice_block blk, u64 prof_id)
 }
 
 /**
- * ice_flow_rem_entry_sync - Remove a flow entry
+ * ice_dealloc_flow_entry - Deallocate flow entry memory
  * @hw: pointer to the HW struct
  * @entry: flow entry to be removed
  */
-static enum ice_status
-ice_flow_rem_entry_sync(struct ice_hw *hw, struct ice_flow_entry *entry)
+static void
+ice_dealloc_flow_entry(struct ice_hw *hw, struct ice_flow_entry *entry)
 {
        if (!entry)
-               return ICE_ERR_BAD_PTR;
-
-       LIST_DEL(&entry->l_entry);
+               return;
 
        if (entry->entry)
                ice_free(hw, entry->entry);
@@ -968,6 +954,22 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, struct ice_flow_entry *entry)
        }
 
        ice_free(hw, entry);
+}
+
+/**
+ * ice_flow_rem_entry_sync - Remove a flow entry
+ * @hw: pointer to the HW struct
+ * @entry: flow entry to be removed
+ */
+static enum ice_status
+ice_flow_rem_entry_sync(struct ice_hw *hw, struct ice_flow_entry *entry)
+{
+       if (!entry)
+               return ICE_ERR_BAD_PTR;
+
+       LIST_DEL(&entry->l_entry);
+
+       ice_dealloc_flow_entry(hw, entry);
 
        return ICE_SUCCESS;
 }
@@ -1659,6 +1661,9 @@ enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle)
        if (!ice_is_vsi_valid(hw, vsi_handle))
                return ICE_ERR_PARAM;
 
+       if (LIST_EMPTY(&hw->fl_profs[blk]))
+               return ICE_SUCCESS;
+
        ice_acquire_lock(&hw->fl_profs_locks[blk]);
        LIST_FOR_EACH_ENTRY_SAFE(p, t, &hw->fl_profs[blk], ice_flow_prof,
                                 l_entry) {