dpdk: DPDK 20.05 iavf flow director backporting to DPDK 20.02
[vpp.git] / build / external / patches / dpdk_20.02 / 0016-common-iavf-add-flow-director-support-in-virtual-cha.patch
1 From 5e4e6320a3c306b277d71a1811cf616fc2a6de93 Mon Sep 17 00:00:00 2001
2 From: Chenmin Sun <chenmin.sun@intel.com>
3 Date: Fri, 17 Apr 2020 05:53:35 +0800
4 Subject: [DPDK 16/17] common/iavf: add flow director support in virtual
5  channel
6
7 Adds new ops and structures to support VF to add/delete/validate/
8 query flow director.
9
10 ADD and VALIDATE FDIR share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
11 VF sends this request to PF by filling out the related field in
12 virtchnl_fdir_add. If the rule is created successfully, PF
13 will return flow id and program status to VF. If the rule is
14 validated successfully, the PF will only return program status
15 to VF.
16
17 DELETE FDIR uses ops: VIRTCHNL_OP_DEL_FDIR_FILTER.
18 VF sends this request to PF by filling out the related field in
19 virtchnl_fdir_del. If the rule is deleted successfully, PF
20 will return program status to VF.
21
22 Query FDIR uses ops: VIRTCHNL_OP_QUERY_FDIR_FILTER.
23 VF sends this request to PF by filling out the related field in
24 virtchnl_fdir_query. If the request is successfully done by PF,
25 PF will return program status and query info to VF.
26
27 Signed-off-by: Simei Su <simei.su@intel.com>
28 Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
29 Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
30 Signed-off-by: Chenmin Sun <chenmin.sun@intel.com>
31 ---
32  drivers/common/iavf/virtchnl.h | 162 +++++++++++++++++++++++++++++++++
33  1 file changed, 162 insertions(+)
34
35 diff --git a/drivers/common/iavf/virtchnl.h b/drivers/common/iavf/virtchnl.h
36 index 667762643..4dbf9c1c2 100644
37 --- a/drivers/common/iavf/virtchnl.h
38 +++ b/drivers/common/iavf/virtchnl.h
39 @@ -134,6 +134,9 @@ enum virtchnl_ops {
40         VIRTCHNL_OP_DCF_GET_VSI_MAP = 42,
41         VIRTCHNL_OP_DCF_GET_PKG_INFO = 43,
42         VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
43 +       VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
44 +       VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
45 +       VIRTCHNL_OP_QUERY_FDIR_FILTER = 49,
46  };
47  
48  /* These macros are used to generate compilation errors if a structure/union
49 @@ -249,6 +252,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
50  #define VIRTCHNL_VF_OFFLOAD_ADQ_V2             0X01000000
51  #define VIRTCHNL_VF_OFFLOAD_USO                        0X02000000
52  #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC       0X04000000
53 +#define VIRTCHNL_VF_OFFLOAD_FDIR_PF            0X10000000
54         /* 0X80000000 is reserved */
55  
56  /* Define below the capability flags that are not offloads */
57 @@ -629,6 +633,11 @@ enum virtchnl_action {
58         /* action types */
59         VIRTCHNL_ACTION_DROP = 0,
60         VIRTCHNL_ACTION_TC_REDIRECT,
61 +       VIRTCHNL_ACTION_PASSTHRU,
62 +       VIRTCHNL_ACTION_QUEUE,
63 +       VIRTCHNL_ACTION_Q_REGION,
64 +       VIRTCHNL_ACTION_MARK,
65 +       VIRTCHNL_ACTION_COUNT,
66  };
67  
68  enum virtchnl_flow_type {
69 @@ -925,6 +934,150 @@ struct virtchnl_proto_hdrs {
70  
71  VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
72  
73 +/* action configuration for FDIR */
74 +struct virtchnl_filter_action {
75 +       enum virtchnl_action type;
76 +       union {
77 +               /* used for queue and qgroup action */
78 +               struct {
79 +                       u16 index;
80 +                       u8 region;
81 +               } queue;
82 +               /* used for count action */
83 +               struct {
84 +                       /* share counter ID with other flow rules */
85 +                       u8 shared;
86 +                       u32 id; /* counter ID */
87 +               } count;
88 +               /* used for mark action */
89 +               u32 mark_id;
90 +               u8 reserve[32];
91 +       } act_conf;
92 +};
93 +
94 +VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
95 +
96 +#define VIRTCHNL_MAX_NUM_ACTIONS  8
97 +
98 +struct virtchnl_filter_action_set {
99 +       /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
100 +       int count;
101 +       struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
102 +};
103 +
104 +VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
105 +
106 +/* pattern and action for FDIR rule */
107 +struct virtchnl_fdir_rule {
108 +       struct virtchnl_proto_hdrs proto_hdrs;
109 +       struct virtchnl_filter_action_set action_set;
110 +};
111 +
112 +VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
113 +
114 +/* query information to retrieve fdir rule counters.
115 + * PF will fill out this structure to reset counter.
116 + */
117 +struct virtchnl_fdir_query_info {
118 +       u32 match_packets_valid:1;
119 +       u32 match_bytes_valid:1;
120 +       u32 reserved:30;  /* Reserved, must be zero. */
121 +       u32 pad;
122 +       u64 matched_packets; /* Number of packets for this rule. */
123 +       u64 matched_bytes;   /* Number of bytes through this rule. */
124 +};
125 +
126 +VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_fdir_query_info);
127 +
128 +/* Status returned to VF after VF requests FDIR commands
129 + * VIRTCHNL_FDIR_SUCCESS
130 + * VF FDIR related request is successfully done by PF
131 + * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
132 + *
133 + * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
134 + * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
135 + *
136 + * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
137 + * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
138 + *
139 + * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
140 + * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
141 + *
142 + * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
143 + * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
144 + *
145 + * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
146 + * OP_ADD_FDIR_FILTER request is failed due to parameters validation
147 + * or HW doesn't support.
148 + *
149 + * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
150 + * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
151 + * for programming.
152 + *
153 + * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
154 + * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
155 + * for example, VF query counter of a rule who has no counter action.
156 + */
157 +enum virtchnl_fdir_prgm_status {
158 +       VIRTCHNL_FDIR_SUCCESS = 0,
159 +       VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
160 +       VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
161 +       VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
162 +       VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
163 +       VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
164 +       VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
165 +       VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
166 +};
167 +
168 +/* VIRTCHNL_OP_ADD_FDIR_FILTER
169 + * VF sends this request to PF by filling out vsi_id,
170 + * validate_only and rule_cfg. PF will return flow_id
171 + * if the request is successfully done and return add_status to VF.
172 + */
173 +struct virtchnl_fdir_add {
174 +       u16 vsi_id;  /* INPUT */
175 +       /*
176 +        * 1 for validating a fdir rule, 0 for creating a fdir rule.
177 +        * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
178 +        */
179 +       u16 validate_only; /* INPUT */
180 +       u32 flow_id;       /* OUTPUT */
181 +       struct virtchnl_fdir_rule rule_cfg; /* INPUT */
182 +       enum virtchnl_fdir_prgm_status status; /* OUTPUT */
183 +};
184 +
185 +VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
186 +
187 +/* VIRTCHNL_OP_DEL_FDIR_FILTER
188 + * VF sends this request to PF by filling out vsi_id
189 + * and flow_id. PF will return del_status to VF.
190 + */
191 +struct virtchnl_fdir_del {
192 +       u16 vsi_id;  /* INPUT */
193 +       u16 pad;
194 +       u32 flow_id; /* INPUT */
195 +       enum virtchnl_fdir_prgm_status status; /* OUTPUT */
196 +};
197 +
198 +VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
199 +
200 +/* VIRTCHNL_OP_QUERY_FDIR_FILTER
201 + * VF sends this request to PF by filling out vsi_id,
202 + * flow_id and reset_counter. PF will return query_info
203 + * and query_status to VF.
204 + */
205 +struct virtchnl_fdir_query {
206 +       u16 vsi_id;   /* INPUT */
207 +       u16 pad1[3];
208 +       u32 flow_id;  /* INPUT */
209 +       u32 reset_counter:1; /* INPUT */
210 +       struct virtchnl_fdir_query_info query_info; /* OUTPUT */
211 +       enum virtchnl_fdir_prgm_status status;  /* OUTPUT */
212 +       u32 pad2;
213 +};
214 +
215 +VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_fdir_query);
216 +
217  /**
218   * virtchnl_vc_validate_vf_msg
219   * @ver: Virtchnl version info
220 @@ -1110,6 +1263,15 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
221                  * so the valid length keeps the default value 0.
222                  */
223                 break;
224 +       case VIRTCHNL_OP_ADD_FDIR_FILTER:
225 +               valid_len = sizeof(struct virtchnl_fdir_add);
226 +               break;
227 +       case VIRTCHNL_OP_DEL_FDIR_FILTER:
228 +               valid_len = sizeof(struct virtchnl_fdir_del);
229 +               break;
230 +       case VIRTCHNL_OP_QUERY_FDIR_FILTER:
231 +               valid_len = sizeof(struct virtchnl_fdir_query);
232 +               break;
233         /* These are always errors coming from the VF. */
234         case VIRTCHNL_OP_EVENT:
235         case VIRTCHNL_OP_UNKNOWN:
236 -- 
237 2.17.1
238