xref: /f-stack/dpdk/drivers/net/ice/base/ice_acl.c (revision 2d9fd380)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2020 Intel Corporation
3  */
4 
5 #include "ice_acl.h"
6 #include "ice_adminq_cmd.h"
7 
8 /**
9  * ice_aq_alloc_acl_tbl - allocate ACL table
10  * @hw: pointer to the HW struct
11  * @tbl: pointer to ice_acl_alloc_tbl struct
12  * @cd: pointer to command details structure or NULL
13  *
14  * Allocate ACL table (indirect 0x0C10)
15  */
16 enum ice_status
ice_aq_alloc_acl_tbl(struct ice_hw * hw,struct ice_acl_alloc_tbl * tbl,struct ice_sq_cd * cd)17 ice_aq_alloc_acl_tbl(struct ice_hw *hw, struct ice_acl_alloc_tbl *tbl,
18 		     struct ice_sq_cd *cd)
19 {
20 	struct ice_aqc_acl_alloc_table *cmd;
21 	struct ice_aq_desc desc;
22 
23 	if (!tbl->act_pairs_per_entry)
24 		return ICE_ERR_PARAM;
25 
26 	if (tbl->act_pairs_per_entry > ICE_AQC_MAX_ACTION_MEMORIES)
27 		return ICE_ERR_MAX_LIMIT;
28 
29 	/* If this is concurrent table, then buffer shall be valid and
30 	 * contain DependentAllocIDs, 'num_dependent_alloc_ids' should be valid
31 	 * and within limit
32 	 */
33 	if (tbl->concurr) {
34 		if (!tbl->num_dependent_alloc_ids)
35 			return ICE_ERR_PARAM;
36 		if (tbl->num_dependent_alloc_ids >
37 		    ICE_AQC_MAX_CONCURRENT_ACL_TBL)
38 			return ICE_ERR_INVAL_SIZE;
39 	}
40 
41 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_alloc_acl_tbl);
42 	desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
43 
44 	cmd = &desc.params.alloc_table;
45 	cmd->table_width = CPU_TO_LE16(tbl->width * BITS_PER_BYTE);
46 	cmd->table_depth = CPU_TO_LE16(tbl->depth);
47 	cmd->act_pairs_per_entry = tbl->act_pairs_per_entry;
48 	if (tbl->concurr)
49 		cmd->table_type = tbl->num_dependent_alloc_ids;
50 
51 	return ice_aq_send_cmd(hw, &desc, &tbl->buf, sizeof(tbl->buf), cd);
52 }
53 
54 /**
55  * ice_aq_dealloc_acl_tbl - deallocate ACL table
56  * @hw: pointer to the HW struct
57  * @alloc_id: allocation ID of the table being released
58  * @buf: address of indirect data buffer
59  * @cd: pointer to command details structure or NULL
60  *
61  * Deallocate ACL table (indirect 0x0C11)
62  *
63  * NOTE: This command has no buffer format for command itself but response
64  * format is 'struct ice_aqc_acl_generic', pass ptr to that struct
65  * as 'buf' and its size as 'buf_size'
66  */
67 enum ice_status
ice_aq_dealloc_acl_tbl(struct ice_hw * hw,u16 alloc_id,struct ice_aqc_acl_generic * buf,struct ice_sq_cd * cd)68 ice_aq_dealloc_acl_tbl(struct ice_hw *hw, u16 alloc_id,
69 		       struct ice_aqc_acl_generic *buf, struct ice_sq_cd *cd)
70 {
71 	struct ice_aqc_acl_tbl_actpair *cmd;
72 	struct ice_aq_desc desc;
73 
74 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_tbl);
75 	cmd = &desc.params.tbl_actpair;
76 	cmd->alloc_id = CPU_TO_LE16(alloc_id);
77 
78 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
79 }
80 
81 static enum ice_status
ice_aq_acl_entry(struct ice_hw * hw,u16 opcode,u8 tcam_idx,u16 entry_idx,struct ice_aqc_acl_data * buf,struct ice_sq_cd * cd)82 ice_aq_acl_entry(struct ice_hw *hw, u16 opcode, u8 tcam_idx, u16 entry_idx,
83 		 struct ice_aqc_acl_data *buf, struct ice_sq_cd *cd)
84 {
85 	struct ice_aqc_acl_entry *cmd;
86 	struct ice_aq_desc desc;
87 
88 	ice_fill_dflt_direct_cmd_desc(&desc, opcode);
89 
90 	if (opcode == ice_aqc_opc_program_acl_entry)
91 		desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
92 
93 	cmd = &desc.params.program_query_entry;
94 	cmd->tcam_index = tcam_idx;
95 	cmd->entry_index = CPU_TO_LE16(entry_idx);
96 
97 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
98 }
99 
100 /**
101  * ice_aq_program_acl_entry - program ACL entry
102  * @hw: pointer to the HW struct
103  * @tcam_idx: Updated TCAM block index
104  * @entry_idx: updated entry index
105  * @buf: address of indirect data buffer
106  * @cd: pointer to command details structure or NULL
107  *
108  * Program ACL entry (direct 0x0C20)
109  */
110 enum ice_status
ice_aq_program_acl_entry(struct ice_hw * hw,u8 tcam_idx,u16 entry_idx,struct ice_aqc_acl_data * buf,struct ice_sq_cd * cd)111 ice_aq_program_acl_entry(struct ice_hw *hw, u8 tcam_idx, u16 entry_idx,
112 			 struct ice_aqc_acl_data *buf, struct ice_sq_cd *cd)
113 {
114 	return ice_aq_acl_entry(hw, ice_aqc_opc_program_acl_entry, tcam_idx,
115 				entry_idx, buf, cd);
116 }
117 
118 /**
119  * ice_aq_query_acl_entry - query ACL entry
120  * @hw: pointer to the HW struct
121  * @tcam_idx: Updated TCAM block index
122  * @entry_idx: updated entry index
123  * @buf: address of indirect data buffer
124  * @cd: pointer to command details structure or NULL
125  *
126  * Query ACL entry (direct 0x0C24)
127  *
128  * NOTE: Caller of this API to parse 'buf' appropriately since it contains
129  * response (key and key invert)
130  */
131 enum ice_status
ice_aq_query_acl_entry(struct ice_hw * hw,u8 tcam_idx,u16 entry_idx,struct ice_aqc_acl_data * buf,struct ice_sq_cd * cd)132 ice_aq_query_acl_entry(struct ice_hw *hw, u8 tcam_idx, u16 entry_idx,
133 		       struct ice_aqc_acl_data *buf, struct ice_sq_cd *cd)
134 {
135 	return ice_aq_acl_entry(hw, ice_aqc_opc_query_acl_entry, tcam_idx,
136 				entry_idx, buf, cd);
137 }
138 
139 /* Helper function to alloc/dealloc ACL action pair */
140 static enum ice_status
ice_aq_actpair_a_d(struct ice_hw * hw,u16 opcode,u16 alloc_id,struct ice_aqc_acl_generic * buf,struct ice_sq_cd * cd)141 ice_aq_actpair_a_d(struct ice_hw *hw, u16 opcode, u16 alloc_id,
142 		   struct ice_aqc_acl_generic *buf, struct ice_sq_cd *cd)
143 {
144 	struct ice_aqc_acl_tbl_actpair *cmd;
145 	struct ice_aq_desc desc;
146 
147 	ice_fill_dflt_direct_cmd_desc(&desc, opcode);
148 	cmd = &desc.params.tbl_actpair;
149 	cmd->alloc_id = CPU_TO_LE16(alloc_id);
150 
151 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
152 }
153 
154 /**
155  * ice_aq_alloc_actpair - allocate actionpair for specified ACL table
156  * @hw: pointer to the HW struct
157  * @alloc_id: allocation ID of the table being associated with the actionpair
158  * @buf: address of indirect data buffer
159  * @cd: pointer to command details structure or NULL
160  *
161  * Allocate ACL actionpair (direct 0x0C12)
162  *
163  * This command doesn't need and doesn't have its own command buffer
164  * but for response format is as specified in 'struct ice_aqc_acl_generic'
165  */
166 enum ice_status
ice_aq_alloc_actpair(struct ice_hw * hw,u16 alloc_id,struct ice_aqc_acl_generic * buf,struct ice_sq_cd * cd)167 ice_aq_alloc_actpair(struct ice_hw *hw, u16 alloc_id,
168 		     struct ice_aqc_acl_generic *buf, struct ice_sq_cd *cd)
169 {
170 	return ice_aq_actpair_a_d(hw, ice_aqc_opc_alloc_acl_actpair, alloc_id,
171 				  buf, cd);
172 }
173 
174 /**
175  * ice_aq_dealloc_actpair - dealloc actionpair for specified ACL table
176  * @hw: pointer to the HW struct
177  * @alloc_id: allocation ID of the table being associated with the actionpair
178  * @buf: address of indirect data buffer
179  * @cd: pointer to command details structure or NULL
180  *
181  *  Deallocate ACL actionpair (direct 0x0C13)
182  */
183 enum ice_status
ice_aq_dealloc_actpair(struct ice_hw * hw,u16 alloc_id,struct ice_aqc_acl_generic * buf,struct ice_sq_cd * cd)184 ice_aq_dealloc_actpair(struct ice_hw *hw, u16 alloc_id,
185 		       struct ice_aqc_acl_generic *buf, struct ice_sq_cd *cd)
186 {
187 	return ice_aq_actpair_a_d(hw, ice_aqc_opc_dealloc_acl_actpair, alloc_id,
188 				  buf, cd);
189 }
190 
191 /* Helper function to program/query ACL action pair */
192 static enum ice_status
ice_aq_actpair_p_q(struct ice_hw * hw,u16 opcode,u8 act_mem_idx,u16 act_entry_idx,struct ice_aqc_actpair * buf,struct ice_sq_cd * cd)193 ice_aq_actpair_p_q(struct ice_hw *hw, u16 opcode, u8 act_mem_idx,
194 		   u16 act_entry_idx, struct ice_aqc_actpair *buf,
195 		   struct ice_sq_cd *cd)
196 {
197 	struct ice_aqc_acl_actpair *cmd;
198 	struct ice_aq_desc desc;
199 
200 	ice_fill_dflt_direct_cmd_desc(&desc, opcode);
201 
202 	if (opcode == ice_aqc_opc_program_acl_actpair)
203 		desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
204 
205 	cmd = &desc.params.program_query_actpair;
206 	cmd->act_mem_index = act_mem_idx;
207 	cmd->act_entry_index = CPU_TO_LE16(act_entry_idx);
208 
209 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
210 }
211 
212 /**
213  * ice_aq_program_actpair - program ACL actionpair
214  * @hw: pointer to the HW struct
215  * @act_mem_idx: action memory index to program/update/query
216  * @act_entry_idx: the entry index in action memory to be programmed/updated
217  * @buf: address of indirect data buffer
218  * @cd: pointer to command details structure or NULL
219  *
220  * Program action entries (indirect 0x0C1C)
221  */
222 enum ice_status
ice_aq_program_actpair(struct ice_hw * hw,u8 act_mem_idx,u16 act_entry_idx,struct ice_aqc_actpair * buf,struct ice_sq_cd * cd)223 ice_aq_program_actpair(struct ice_hw *hw, u8 act_mem_idx, u16 act_entry_idx,
224 		       struct ice_aqc_actpair *buf, struct ice_sq_cd *cd)
225 {
226 	return ice_aq_actpair_p_q(hw, ice_aqc_opc_program_acl_actpair,
227 				  act_mem_idx, act_entry_idx, buf, cd);
228 }
229 
230 /**
231  * ice_aq_query_actpair - query ACL actionpair
232  * @hw: pointer to the HW struct
233  * @act_mem_idx: action memory index to program/update/query
234  * @act_entry_idx: the entry index in action memory to be programmed/updated
235  * @buf: address of indirect data buffer
236  * @cd: pointer to command details structure or NULL
237  *
238  * Query ACL actionpair (indirect 0x0C25)
239  */
240 enum ice_status
ice_aq_query_actpair(struct ice_hw * hw,u8 act_mem_idx,u16 act_entry_idx,struct ice_aqc_actpair * buf,struct ice_sq_cd * cd)241 ice_aq_query_actpair(struct ice_hw *hw, u8 act_mem_idx, u16 act_entry_idx,
242 		     struct ice_aqc_actpair *buf, struct ice_sq_cd *cd)
243 {
244 	return ice_aq_actpair_p_q(hw, ice_aqc_opc_query_acl_actpair,
245 				  act_mem_idx, act_entry_idx, buf, cd);
246 }
247 
248 /**
249  * ice_aq_dealloc_acl_res - deallocate ACL resources
250  * @hw: pointer to the HW struct
251  * @cd: pointer to command details structure or NULL
252  *
253  * De-allocate ACL resources (direct 0x0C1A). Used by SW to release all the
254  * resources allocated for it using a single command
255  */
ice_aq_dealloc_acl_res(struct ice_hw * hw,struct ice_sq_cd * cd)256 enum ice_status ice_aq_dealloc_acl_res(struct ice_hw *hw, struct ice_sq_cd *cd)
257 {
258 	struct ice_aq_desc desc;
259 
260 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_res);
261 
262 	return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
263 }
264 
265 /**
266  * ice_acl_prof_aq_send - sending ACL profile AQ commands
267  * @hw: pointer to the HW struct
268  * @opc: command opcode
269  * @prof_id: profile ID
270  * @buf: ptr to buffer
271  * @cd: pointer to command details structure or NULL
272  *
273  * This function sends ACL profile commands
274  */
275 static enum ice_status
ice_acl_prof_aq_send(struct ice_hw * hw,u16 opc,u8 prof_id,struct ice_aqc_acl_prof_generic_frmt * buf,struct ice_sq_cd * cd)276 ice_acl_prof_aq_send(struct ice_hw *hw, u16 opc, u8 prof_id,
277 		     struct ice_aqc_acl_prof_generic_frmt *buf,
278 		     struct ice_sq_cd *cd)
279 {
280 	struct ice_aq_desc desc;
281 
282 	ice_fill_dflt_direct_cmd_desc(&desc, opc);
283 	desc.params.profile.profile_id = prof_id;
284 	if (opc == ice_aqc_opc_program_acl_prof_extraction ||
285 	    opc == ice_aqc_opc_program_acl_prof_ranges)
286 		desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
287 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
288 }
289 
290 /**
291  * ice_prgm_acl_prof_xtrct - program ACL profile extraction sequence
292  * @hw: pointer to the HW struct
293  * @prof_id: profile ID
294  * @buf: ptr to buffer
295  * @cd: pointer to command details structure or NULL
296  *
297  * Program ACL profile extraction (indirect 0x0C1D)
298  */
299 enum ice_status
ice_prgm_acl_prof_xtrct(struct ice_hw * hw,u8 prof_id,struct ice_aqc_acl_prof_generic_frmt * buf,struct ice_sq_cd * cd)300 ice_prgm_acl_prof_xtrct(struct ice_hw *hw, u8 prof_id,
301 			struct ice_aqc_acl_prof_generic_frmt *buf,
302 			struct ice_sq_cd *cd)
303 {
304 	return ice_acl_prof_aq_send(hw, ice_aqc_opc_program_acl_prof_extraction,
305 				    prof_id, buf, cd);
306 }
307 
308 /**
309  * ice_query_acl_prof - query ACL profile
310  * @hw: pointer to the HW struct
311  * @prof_id: profile ID
312  * @buf: ptr to buffer (which will contain response of this command)
313  * @cd: pointer to command details structure or NULL
314  *
315  * Query ACL profile (indirect 0x0C21)
316  */
317 enum ice_status
ice_query_acl_prof(struct ice_hw * hw,u8 prof_id,struct ice_aqc_acl_prof_generic_frmt * buf,struct ice_sq_cd * cd)318 ice_query_acl_prof(struct ice_hw *hw, u8 prof_id,
319 		   struct ice_aqc_acl_prof_generic_frmt *buf,
320 		   struct ice_sq_cd *cd)
321 {
322 	return ice_acl_prof_aq_send(hw, ice_aqc_opc_query_acl_prof, prof_id,
323 				    buf, cd);
324 }
325 
326 /**
327  * ice_aq_acl_cntrs_chk_params - Checks ACL counter parameters
328  * @cntrs: ptr to buffer describing input and output params
329  *
330  * This function checks the counter bank range for counter type and returns
331  * success or failure.
332  */
ice_aq_acl_cntrs_chk_params(struct ice_acl_cntrs * cntrs)333 static enum ice_status ice_aq_acl_cntrs_chk_params(struct ice_acl_cntrs *cntrs)
334 {
335 	enum ice_status status = ICE_SUCCESS;
336 
337 	if (!cntrs || !cntrs->amount)
338 		return ICE_ERR_PARAM;
339 
340 	switch (cntrs->type) {
341 	case ICE_AQC_ACL_CNT_TYPE_SINGLE:
342 		/* Single counter type - configured to count either bytes
343 		 * or packets, the valid values for byte or packet counters
344 		 * shall be 0-3.
345 		 */
346 		if (cntrs->bank > ICE_AQC_ACL_MAX_CNT_SINGLE)
347 			status = ICE_ERR_OUT_OF_RANGE;
348 		break;
349 	case ICE_AQC_ACL_CNT_TYPE_DUAL:
350 		/* Pair counter type - counts number of bytes and packets
351 		 * The valid values for byte/packet counter duals shall be 0-1
352 		 */
353 		if (cntrs->bank > ICE_AQC_ACL_MAX_CNT_DUAL)
354 			status = ICE_ERR_OUT_OF_RANGE;
355 		break;
356 	default:
357 		/* Unspecified counter type - Invalid or error */
358 		status = ICE_ERR_PARAM;
359 	}
360 
361 	return status;
362 }
363 
364 /**
365  * ice_aq_alloc_acl_cntrs - allocate ACL counters
366  * @hw: pointer to the HW struct
367  * @cntrs: ptr to buffer describing input and output params
368  * @cd: pointer to command details structure or NULL
369  *
370  * Allocate ACL counters (indirect 0x0C16). This function attempts to
371  * allocate a contiguous block of counters. In case of failures, caller can
372  * attempt to allocate a smaller chunk. The allocation is considered
373  * unsuccessful if returned counter value is invalid. In this case it returns
374  * an error otherwise success.
375  */
376 enum ice_status
ice_aq_alloc_acl_cntrs(struct ice_hw * hw,struct ice_acl_cntrs * cntrs,struct ice_sq_cd * cd)377 ice_aq_alloc_acl_cntrs(struct ice_hw *hw, struct ice_acl_cntrs *cntrs,
378 		       struct ice_sq_cd *cd)
379 {
380 	struct ice_aqc_acl_alloc_counters *cmd;
381 	u16 first_cntr, last_cntr;
382 	struct ice_aq_desc desc;
383 	enum ice_status status;
384 
385 	/* check for invalid params */
386 	status = ice_aq_acl_cntrs_chk_params(cntrs);
387 	if (status)
388 		return status;
389 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_alloc_acl_counters);
390 	cmd = &desc.params.alloc_counters;
391 	cmd->counter_amount = cntrs->amount;
392 	cmd->counters_type = cntrs->type;
393 	cmd->bank_alloc = cntrs->bank;
394 	status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
395 	if (!status) {
396 		first_cntr = LE16_TO_CPU(cmd->ops.resp.first_counter);
397 		last_cntr = LE16_TO_CPU(cmd->ops.resp.last_counter);
398 		if (first_cntr == ICE_AQC_ACL_ALLOC_CNT_INVAL ||
399 		    last_cntr == ICE_AQC_ACL_ALLOC_CNT_INVAL)
400 			return ICE_ERR_OUT_OF_RANGE;
401 		cntrs->first_cntr = first_cntr;
402 		cntrs->last_cntr = last_cntr;
403 	}
404 	return status;
405 }
406 
407 /**
408  * ice_aq_dealloc_acl_cntrs - deallocate ACL counters
409  * @hw: pointer to the HW struct
410  * @cntrs: ptr to buffer describing input and output params
411  * @cd: pointer to command details structure or NULL
412  *
413  * De-allocate ACL counters (direct 0x0C17)
414  */
415 enum ice_status
ice_aq_dealloc_acl_cntrs(struct ice_hw * hw,struct ice_acl_cntrs * cntrs,struct ice_sq_cd * cd)416 ice_aq_dealloc_acl_cntrs(struct ice_hw *hw, struct ice_acl_cntrs *cntrs,
417 			 struct ice_sq_cd *cd)
418 {
419 	struct ice_aqc_acl_dealloc_counters *cmd;
420 	struct ice_aq_desc desc;
421 	enum ice_status status;
422 
423 	/* check for invalid params */
424 	status = ice_aq_acl_cntrs_chk_params(cntrs);
425 	if (status)
426 		return status;
427 
428 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_counters);
429 	cmd = &desc.params.dealloc_counters;
430 	cmd->first_counter = CPU_TO_LE16(cntrs->first_cntr);
431 	cmd->last_counter = CPU_TO_LE16(cntrs->last_cntr);
432 	cmd->counters_type = cntrs->type;
433 	cmd->bank_alloc = cntrs->bank;
434 	return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
435 }
436 
437 /**
438  * ice_prog_acl_prof_ranges - program ACL profile ranges
439  * @hw: pointer to the HW struct
440  * @prof_id: programmed or updated profile ID
441  * @buf: pointer to input buffer
442  * @cd: pointer to command details structure or NULL
443  *
444  * Program ACL profile ranges (indirect 0x0C1E)
445  */
446 enum ice_status
ice_prog_acl_prof_ranges(struct ice_hw * hw,u8 prof_id,struct ice_aqc_acl_profile_ranges * buf,struct ice_sq_cd * cd)447 ice_prog_acl_prof_ranges(struct ice_hw *hw, u8 prof_id,
448 			 struct ice_aqc_acl_profile_ranges *buf,
449 			 struct ice_sq_cd *cd)
450 {
451 	struct ice_aq_desc desc;
452 
453 	ice_fill_dflt_direct_cmd_desc(&desc,
454 				      ice_aqc_opc_program_acl_prof_ranges);
455 	desc.params.profile.profile_id = prof_id;
456 	desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
457 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
458 }
459 
460 /**
461  * ice_query_acl_prof_ranges - query ACL profile ranges
462  * @hw: pointer to the HW struct
463  * @prof_id: programmed or updated profile ID
464  * @buf: pointer to response buffer
465  * @cd: pointer to command details structure or NULL
466  *
467  * Query ACL profile ranges (indirect 0x0C22)
468  */
469 enum ice_status
ice_query_acl_prof_ranges(struct ice_hw * hw,u8 prof_id,struct ice_aqc_acl_profile_ranges * buf,struct ice_sq_cd * cd)470 ice_query_acl_prof_ranges(struct ice_hw *hw, u8 prof_id,
471 			  struct ice_aqc_acl_profile_ranges *buf,
472 			  struct ice_sq_cd *cd)
473 {
474 	struct ice_aq_desc desc;
475 
476 	ice_fill_dflt_direct_cmd_desc(&desc,
477 				      ice_aqc_opc_query_acl_prof_ranges);
478 	desc.params.profile.profile_id = prof_id;
479 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
480 }
481 
482 /**
483  * ice_aq_alloc_acl_scen - allocate ACL scenario
484  * @hw: pointer to the HW struct
485  * @scen_id: memory location to receive allocated scenario ID
486  * @buf: address of indirect data buffer
487  * @cd: pointer to command details structure or NULL
488  *
489  * Allocate ACL scenario (indirect 0x0C14)
490  */
491 enum ice_status
ice_aq_alloc_acl_scen(struct ice_hw * hw,u16 * scen_id,struct ice_aqc_acl_scen * buf,struct ice_sq_cd * cd)492 ice_aq_alloc_acl_scen(struct ice_hw *hw, u16 *scen_id,
493 		      struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
494 {
495 	struct ice_aqc_acl_alloc_scen *cmd;
496 	struct ice_aq_desc desc;
497 	enum ice_status status;
498 
499 	if (!scen_id)
500 		return ICE_ERR_PARAM;
501 
502 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_alloc_acl_scen);
503 	desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
504 	cmd = &desc.params.alloc_scen;
505 
506 	status = ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
507 	if (!status)
508 		*scen_id = LE16_TO_CPU(cmd->ops.resp.scen_id);
509 
510 	return status;
511 }
512 
513 /**
514  * ice_aq_dealloc_acl_scen - deallocate ACL scenario
515  * @hw: pointer to the HW struct
516  * @scen_id: scen_id to be deallocated (input and output field)
517  * @cd: pointer to command details structure or NULL
518  *
519  * Deallocate ACL scenario (direct 0x0C15)
520  */
521 enum ice_status
ice_aq_dealloc_acl_scen(struct ice_hw * hw,u16 scen_id,struct ice_sq_cd * cd)522 ice_aq_dealloc_acl_scen(struct ice_hw *hw, u16 scen_id, struct ice_sq_cd *cd)
523 {
524 	struct ice_aqc_acl_dealloc_scen *cmd;
525 	struct ice_aq_desc desc;
526 
527 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_scen);
528 	cmd = &desc.params.dealloc_scen;
529 	cmd->scen_id = CPU_TO_LE16(scen_id);
530 
531 	return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
532 }
533 
534 /**
535  * ice_aq_update_query_scen - update or query ACL scenario
536  * @hw: pointer to the HW struct
537  * @opcode: AQ command opcode for either query or update scenario
538  * @scen_id: scen_id to be updated or queried
539  * @buf: address of indirect data buffer
540  * @cd: pointer to command details structure or NULL
541  *
542  * Calls update or query ACL scenario
543  */
544 static enum ice_status
ice_aq_update_query_scen(struct ice_hw * hw,u16 opcode,u16 scen_id,struct ice_aqc_acl_scen * buf,struct ice_sq_cd * cd)545 ice_aq_update_query_scen(struct ice_hw *hw, u16 opcode, u16 scen_id,
546 			 struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
547 {
548 	struct ice_aqc_acl_update_query_scen *cmd;
549 	struct ice_aq_desc desc;
550 
551 	ice_fill_dflt_direct_cmd_desc(&desc, opcode);
552 	if (opcode == ice_aqc_opc_update_acl_scen)
553 		desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
554 	cmd = &desc.params.update_query_scen;
555 	cmd->scen_id = CPU_TO_LE16(scen_id);
556 
557 	return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
558 }
559 
560 /**
561  * ice_aq_update_acl_scen - update ACL scenario
562  * @hw: pointer to the HW struct
563  * @scen_id: scen_id to be updated
564  * @buf: address of indirect data buffer
565  * @cd: pointer to command details structure or NULL
566  *
567  * Update ACL scenario (indirect 0x0C1B)
568  */
569 enum ice_status
ice_aq_update_acl_scen(struct ice_hw * hw,u16 scen_id,struct ice_aqc_acl_scen * buf,struct ice_sq_cd * cd)570 ice_aq_update_acl_scen(struct ice_hw *hw, u16 scen_id,
571 		       struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
572 {
573 	return ice_aq_update_query_scen(hw, ice_aqc_opc_update_acl_scen,
574 					scen_id, buf, cd);
575 }
576 
577 /**
578  * ice_aq_query_acl_scen - query ACL scenario
579  * @hw: pointer to the HW struct
580  * @scen_id: scen_id to be queried
581  * @buf: address of indirect data buffer
582  * @cd: pointer to command details structure or NULL
583  *
584  * Query ACL scenario (indirect 0x0C23)
585  */
586 enum ice_status
ice_aq_query_acl_scen(struct ice_hw * hw,u16 scen_id,struct ice_aqc_acl_scen * buf,struct ice_sq_cd * cd)587 ice_aq_query_acl_scen(struct ice_hw *hw, u16 scen_id,
588 		      struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
589 {
590 	return ice_aq_update_query_scen(hw, ice_aqc_opc_query_acl_scen,
591 					scen_id, buf, cd);
592 }
593