net/ice/base: enable RSS with ether layer for PPPoE
[dpdk.git] / drivers / net / ice / base / ice_flow.h
index 265e1ee..3afd201 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_FLOW_H_
 #define ICE_FLOW_VSI_INVAL             0xffff
 #define ICE_FLOW_FLD_OFF_INVAL         0xffff
 
-/* Use any of the type from flow field to generate a equivalent hash field */
-#define ICE_FLOW_HASH_FLD(t)   (1ULL << (t))
-
+/* Generate flow hash field from flow field type(s) */
+#define ICE_FLOW_HASH_ETH      \
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA))
 #define ICE_FLOW_HASH_IPV4     \
-       (ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_IPV4_SA) | \
-        ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_IPV4_DA))
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA))
 #define ICE_FLOW_HASH_IPV6     \
-       (ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_IPV6_SA) | \
-        ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_IPV6_DA))
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA))
 #define ICE_FLOW_HASH_TCP_PORT \
-       (ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \
-        ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_TCP_DST_PORT))
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT))
 #define ICE_FLOW_HASH_UDP_PORT \
-       (ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \
-        ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_UDP_DST_PORT))
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT))
 #define ICE_FLOW_HASH_SCTP_PORT        \
-       (ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \
-        ICE_FLOW_HASH_FLD(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT))
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \
+        BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT))
 
 #define ICE_HASH_INVALID       0
 #define ICE_HASH_TCP_IPV4      (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_TCP_PORT)
 #define ICE_HASH_SCTP_IPV4     (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_SCTP_PORT)
 #define ICE_HASH_SCTP_IPV6     (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_SCTP_PORT)
 
+#define ICE_FLOW_HASH_GTP_TEID \
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID))
+
+#define ICE_FLOW_HASH_GTP_IPV4_TEID \
+       (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_TEID)
+#define ICE_FLOW_HASH_GTP_IPV6_TEID \
+       (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_TEID)
+
+#define ICE_FLOW_HASH_GTP_U_TEID \
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID))
+
+#define ICE_FLOW_HASH_GTP_U_IPV4_TEID \
+       (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_TEID)
+#define ICE_FLOW_HASH_GTP_U_IPV6_TEID \
+       (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_TEID)
+
+#define ICE_FLOW_HASH_PPPOE_SESS_ID \
+       (BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID))
+
+#define ICE_FLOW_HASH_PPPOE_SESS_ID_ETH \
+       (ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_PPPOE_SESS_ID)
+#define ICE_FLOW_HASH_PPPOE_TCP_ID \
+       (ICE_FLOW_HASH_TCP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
+#define ICE_FLOW_HASH_PPPOE_UDP_ID \
+       (ICE_FLOW_HASH_UDP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
+
 /* Protocol header fields within a packet segment. A segment consists of one or
  * more protocol headers that make up a logical group of protocol headers. Each
  * logical group of protocol headers encapsulates or is encapsulated using/by
  * VxLAN, etc.
  */
 enum ice_flow_seg_hdr {
-       ICE_FLOW_SEG_HDR_NONE   = 0x00000000,
-       ICE_FLOW_SEG_HDR_ETH    = 0x00000001,
-       ICE_FLOW_SEG_HDR_VLAN   = 0x00000002,
-       ICE_FLOW_SEG_HDR_IPV4   = 0x00000004,
-       ICE_FLOW_SEG_HDR_IPV6   = 0x00000008,
-       ICE_FLOW_SEG_HDR_ARP    = 0x00000010,
-       ICE_FLOW_SEG_HDR_ICMP   = 0x00000020,
-       ICE_FLOW_SEG_HDR_TCP    = 0x00000040,
-       ICE_FLOW_SEG_HDR_UDP    = 0x00000080,
-       ICE_FLOW_SEG_HDR_SCTP   = 0x00000100,
-       ICE_FLOW_SEG_HDR_GRE    = 0x00000200,
+       ICE_FLOW_SEG_HDR_NONE           = 0x00000000,
+       ICE_FLOW_SEG_HDR_ETH            = 0x00000001,
+       ICE_FLOW_SEG_HDR_VLAN           = 0x00000002,
+       ICE_FLOW_SEG_HDR_IPV4           = 0x00000004,
+       ICE_FLOW_SEG_HDR_IPV6           = 0x00000008,
+       ICE_FLOW_SEG_HDR_ARP            = 0x00000010,
+       ICE_FLOW_SEG_HDR_ICMP           = 0x00000020,
+       ICE_FLOW_SEG_HDR_TCP            = 0x00000040,
+       ICE_FLOW_SEG_HDR_UDP            = 0x00000080,
+       ICE_FLOW_SEG_HDR_SCTP           = 0x00000100,
+       ICE_FLOW_SEG_HDR_GRE            = 0x00000200,
+       ICE_FLOW_SEG_HDR_GTPC           = 0x00000400,
+       ICE_FLOW_SEG_HDR_GTPC_TEID      = 0x00000800,
+       ICE_FLOW_SEG_HDR_GTPU_IP        = 0x00001000,
+       ICE_FLOW_SEG_HDR_GTPU_DWN       = 0x00002000,
+       ICE_FLOW_SEG_HDR_GTPU_UP        = 0x00004000,
+       ICE_FLOW_SEG_HDR_PPPOE          = 0x00008000,
 };
 
+/* These segements all have the same PTYPES, but are otherwise distinguished by
+ * the value of the gtp_eh_pdu and gtp_eh_pdu_link flags:
+ *
+ *                                gtp_eh_pdu     gtp_eh_pdu_link
+ * ICE_FLOW_SEG_HDR_GTPU_IP           0              0
+ * ICE_FLOW_SEG_HDR_GTPU_DWN          1              0
+ * ICE_FLOW_SEG_HDR_GTPU_UP           1              1
+ */
+#define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \
+                              ICE_FLOW_SEG_HDR_GTPU_DWN | \
+                              ICE_FLOW_SEG_HDR_GTPU_UP)
+
 enum ice_flow_field {
        /* L2 */
        ICE_FLOW_FIELD_IDX_ETH_DA,
@@ -95,6 +140,16 @@ enum ice_flow_field {
        ICE_FLOW_FIELD_IDX_ICMP_CODE,
        /* GRE */
        ICE_FLOW_FIELD_IDX_GRE_KEYID,
+       /* GTPC_TEID */
+       ICE_FLOW_FIELD_IDX_GTPC_TEID,
+       /* GTPU_IP */
+       ICE_FLOW_FIELD_IDX_GTPU_IP_TEID,
+       /* GTPU_UP */
+       ICE_FLOW_FIELD_IDX_GTPU_UP_TEID,
+       /* GTPU_DWN */
+       ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID,
+       /* PPPOE */
+       ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID,
         /* The total number of enums must not exceed 64 */
        ICE_FLOW_FIELD_IDX_MAX
 };
@@ -174,7 +229,7 @@ enum ice_flow_priority {
 
 struct ice_flow_seg_xtrct {
        u8 prot_id;     /* Protocol ID of extracted header field */
-       u8 off;         /* Starting offset of the field in header in bytes */
+       u16 off;        /* Starting offset of the field in header in bytes */
        u8 idx;         /* Index of FV entry used */
        u8 disp;        /* Displacement of field in bits fr. FV entry's start */
 };
@@ -225,17 +280,15 @@ struct ice_flow_entry {
        struct LIST_ENTRY_TYPE l_entry;
 
        u64 id;
-       u16 vsi_handle;
-       enum ice_flow_priority priority;
        struct ice_flow_prof *prof;
-
+       /* Action list */
+       struct ice_flow_action *acts;
        /* Flow entry's content */
-       u16 entry_sz;
        void *entry;
-
-       /* Action list */
+       enum ice_flow_priority priority;
+       u16 vsi_handle;
+       u16 entry_sz;
        u8 acts_cnt;
-       struct ice_flow_action *acts;
 };
 
 #define ICE_FLOW_ENTRY_HNDL(e) ((unsigned long)e)
@@ -246,12 +299,13 @@ struct ice_flow_prof {
 
        u64 id;
        enum ice_flow_dir dir;
+       u8 segs_cnt;
+       u8 acts_cnt;
 
        /* Keep track of flow entries associated with this flow profile */
        struct ice_lock entries_lock;
        struct LIST_HEAD_TYPE entries;
 
-       u8 segs_cnt;
        struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX];
 
        /* software VSI handles referenced by this flow profile */
@@ -264,12 +318,13 @@ struct ice_flow_prof {
        } cfg;
 
        /* Default actions */
-       u8 acts_cnt;
        struct ice_flow_action *acts;
 };
 
 struct ice_rss_cfg {
        struct LIST_ENTRY_TYPE l_entry;
+       /* bitmap of VSIs added to the RSS entry */
+       ice_declare_bitmap(vsis, ICE_MAX_VSI);
        u64 hashed_flds;
        u32 packet_hdr;
 };
@@ -278,14 +333,23 @@ enum ice_flow_action_type {
        ICE_FLOW_ACT_NOP,
        ICE_FLOW_ACT_ALLOW,
        ICE_FLOW_ACT_DROP,
-       ICE_FLOW_ACT_COUNT,
+       ICE_FLOW_ACT_CNTR_PKT,
        ICE_FLOW_ACT_FWD_VSI,
        ICE_FLOW_ACT_FWD_VSI_LIST,      /* Should be abstracted away */
        ICE_FLOW_ACT_FWD_QUEUE,         /* Can Queues be abstracted away? */
        ICE_FLOW_ACT_FWD_QUEUE_GROUP,   /* Can Queues be abstracted away? */
-       ICE_FLOW_ACTION_PUSH,
-       ICE_FLOW_ACTION_POP,
-       ICE_FLOW_ACTION_MODIFY,
+       ICE_FLOW_ACT_PUSH,
+       ICE_FLOW_ACT_POP,
+       ICE_FLOW_ACT_MODIFY,
+       ICE_FLOW_ACT_CNTR_BYTES,
+       ICE_FLOW_ACT_CNTR_PKT_BYTES,
+       ICE_FLOW_ACT_GENERIC_0,
+       ICE_FLOW_ACT_GENERIC_1,
+       ICE_FLOW_ACT_GENERIC_2,
+       ICE_FLOW_ACT_GENERIC_3,
+       ICE_FLOW_ACT_GENERIC_4,
+       ICE_FLOW_ACT_RPT_FLOW_ID,
+       ICE_FLOW_ACT_BUILD_PROF_IDX,
 };
 
 struct ice_flow_action {
@@ -308,7 +372,9 @@ ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
                  struct ice_flow_prof **prof);
 enum ice_status
 ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
-
+enum ice_status
+ice_flow_assoc_vsig_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi_handle,
+                       u16 vsig);
 enum ice_status
 ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
                     u8 *hw_prof);
@@ -329,7 +395,7 @@ ice_flow_set_fld_prefix(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
 void
 ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
                     u16 val_loc, u16 mask_loc);
-void ice_rem_all_rss_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
+void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle);
 enum ice_status ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
 enum ice_status
 ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds);