net/ice/base: add ACL module
[dpdk.git] / drivers / net / ice / base / ice_acl.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2020
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
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
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
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
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
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
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
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
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
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
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
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  * ACL - de-allocate (direct 0x0C1A) resources. Used by SW to release all the
254  * resources allocated for it using a single command
255  */
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
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_extrt - 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  * ACL - program ACL profile extraction (indirect 0x0C1D)
298  */
299 enum ice_status
300 ice_prgm_acl_prof_extrt(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  * ACL - query ACL profile (indirect 0x0C21)
316  */
317 enum ice_status
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  */
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  * ACL - allocate (indirect 0x0C16) counters. 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
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  * ACL - de-allocate (direct 0x0C17) counters.
414  * This function deallocate ACL counters.
415  */
416 enum ice_status
417 ice_aq_dealloc_acl_cntrs(struct ice_hw *hw, struct ice_acl_cntrs *cntrs,
418                          struct ice_sq_cd *cd)
419 {
420         struct ice_aqc_acl_dealloc_counters *cmd;
421         struct ice_aq_desc desc;
422         enum ice_status status;
423
424         /* check for invalid params */
425         status = ice_aq_acl_cntrs_chk_params(cntrs);
426         if (status)
427                 return status;
428
429         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_counters);
430         cmd = &desc.params.dealloc_counters;
431         cmd->first_counter = CPU_TO_LE16(cntrs->first_cntr);
432         cmd->last_counter = CPU_TO_LE16(cntrs->last_cntr);
433         cmd->counters_type = cntrs->type;
434         cmd->bank_alloc = cntrs->bank;
435         return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
436 }
437
438 /**
439  * ice_aq_query_acl_cntrs - query ACL counter
440  * @hw: pointer to the HW struct
441  * @bank: queries counter bank
442  * @index: queried counter index
443  * @cntr_val: pointer to counter or packet counter value
444  * @cd: pointer to command details structure or NULL
445  *
446  * ACL - query ACL counter (direct 0x0C27)
447  */
448 enum ice_status
449 ice_aq_query_acl_cntrs(struct ice_hw *hw, u8 bank, u16 index, u64 *cntr_val,
450                        struct ice_sq_cd *cd)
451 {
452         struct ice_aqc_acl_query_counter *cmd;
453         struct ice_aq_desc desc;
454         enum ice_status status;
455
456         if (!cntr_val)
457                 return ICE_ERR_PARAM;
458
459         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_query_acl_counter);
460         cmd = &desc.params.query_counter;
461         cmd->counter_index = CPU_TO_LE16(index);
462         cmd->counter_bank = bank;
463         status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
464         if (!status) {
465                 __le64 resp_val = 0;
466
467                 ice_memcpy(&resp_val, cmd->ops.resp.val,
468                            sizeof(cmd->ops.resp.val), ICE_NONDMA_TO_NONDMA);
469                 *cntr_val = LE64_TO_CPU(resp_val);
470         }
471         return status;
472 }
473
474 /**
475  * ice_prog_acl_prof_ranges - program ACL profile ranges
476  * @hw: pointer to the HW struct
477  * @prof_id: programmed or updated profile ID
478  * @buf: pointer to input buffer
479  * @cd: pointer to command details structure or NULL
480  *
481  * ACL - program ACL profile ranges (indirect 0x0C1E)
482  */
483 enum ice_status
484 ice_prog_acl_prof_ranges(struct ice_hw *hw, u8 prof_id,
485                          struct ice_aqc_acl_profile_ranges *buf,
486                          struct ice_sq_cd *cd)
487 {
488         struct ice_aq_desc desc;
489
490         ice_fill_dflt_direct_cmd_desc(&desc,
491                                       ice_aqc_opc_program_acl_prof_ranges);
492         desc.params.profile.profile_id = prof_id;
493         desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
494         return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
495 }
496
497 /**
498  * ice_query_acl_prof_ranges - query ACL profile ranges
499  * @hw: pointer to the HW struct
500  * @prof_id: programmed or updated profile ID
501  * @buf: pointer to response buffer
502  * @cd: pointer to command details structure or NULL
503  *
504  * ACL - query ACL profile ranges (indirect 0x0C22)
505  */
506 enum ice_status
507 ice_query_acl_prof_ranges(struct ice_hw *hw, u8 prof_id,
508                           struct ice_aqc_acl_profile_ranges *buf,
509                           struct ice_sq_cd *cd)
510 {
511         struct ice_aq_desc desc;
512
513         ice_fill_dflt_direct_cmd_desc(&desc,
514                                       ice_aqc_opc_query_acl_prof_ranges);
515         desc.params.profile.profile_id = prof_id;
516         return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
517 }
518
519 /**
520  * ice_aq_alloc_acl_scen - allocate ACL scenario
521  * @hw: pointer to the HW struct
522  * @scen_id: memory location to receive allocated scenario ID
523  * @buf: address of indirect data buffer
524  * @cd: pointer to command details structure or NULL
525  *
526  * Allocate ACL scenario (indirect 0x0C14)
527  */
528 enum ice_status
529 ice_aq_alloc_acl_scen(struct ice_hw *hw, u16 *scen_id,
530                       struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
531 {
532         struct ice_aqc_acl_alloc_scen *cmd;
533         struct ice_aq_desc desc;
534         enum ice_status status;
535
536         if (!scen_id)
537                 return ICE_ERR_PARAM;
538
539         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_alloc_acl_scen);
540         desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
541         cmd = &desc.params.alloc_scen;
542
543         status = ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
544         if (!status)
545                 *scen_id = LE16_TO_CPU(cmd->ops.resp.scen_id);
546
547         return status;
548 }
549
550 /**
551  * ice_aq_dealloc_acl_scen - deallocate ACL scenario
552  * @hw: pointer to the HW struct
553  * @scen_id: scen_id to be deallocated (input and output field)
554  * @cd: pointer to command details structure or NULL
555  *
556  * Deallocate ACL scenario (direct 0x0C15)
557  */
558 enum ice_status
559 ice_aq_dealloc_acl_scen(struct ice_hw *hw, u16 scen_id, struct ice_sq_cd *cd)
560 {
561         struct ice_aqc_acl_dealloc_scen *cmd;
562         struct ice_aq_desc desc;
563
564         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dealloc_acl_scen);
565         cmd = &desc.params.dealloc_scen;
566         cmd->scen_id = CPU_TO_LE16(scen_id);
567
568         return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
569 }
570
571 /**
572  * ice_aq_update_query_scen - update or query ACL scenario
573  * @hw: pointer to the HW struct
574  * @opcode: aq command opcode for either query or update scenario
575  * @scen_id: scen_id to be updated or queried
576  * @buf: address of indirect data buffer
577  * @cd: pointer to command details structure or NULL
578  *
579  * Calls update or query ACL scenario
580  */
581 static enum ice_status
582 ice_aq_update_query_scen(struct ice_hw *hw, u16 opcode, u16 scen_id,
583                          struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
584 {
585         struct ice_aqc_acl_update_query_scen *cmd;
586         struct ice_aq_desc desc;
587
588         ice_fill_dflt_direct_cmd_desc(&desc, opcode);
589         if (opcode == ice_aqc_opc_update_acl_scen)
590                 desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
591         cmd = &desc.params.update_query_scen;
592         cmd->scen_id = CPU_TO_LE16(scen_id);
593
594         return ice_aq_send_cmd(hw, &desc, buf, sizeof(*buf), cd);
595 }
596
597 /**
598  * ice_aq_update_acl_scen - update ACL scenario
599  * @hw: pointer to the HW struct
600  * @scen_id: scen_id to be updated
601  * @buf: address of indirect data buffer
602  * @cd: pointer to command details structure or NULL
603  *
604  * Update ACL scenario (indirect 0x0C1B)
605  */
606 enum ice_status
607 ice_aq_update_acl_scen(struct ice_hw *hw, u16 scen_id,
608                        struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
609 {
610         return ice_aq_update_query_scen(hw, ice_aqc_opc_update_acl_scen,
611                                         scen_id, buf, cd);
612 }
613
614 /**
615  * ice_aq_query_acl_scen - query ACL scenario
616  * @hw: pointer to the HW struct
617  * @scen_id: scen_id to be queried
618  * @buf: address of indirect data buffer
619  * @cd: pointer to command details structure or NULL
620  *
621  * Query ACL scenario (indirect 0x0C23)
622  */
623 enum ice_status
624 ice_aq_query_acl_scen(struct ice_hw *hw, u16 scen_id,
625                       struct ice_aqc_acl_scen *buf, struct ice_sq_cd *cd)
626 {
627         return ice_aq_update_query_scen(hw, ice_aqc_opc_query_acl_scen,
628                                         scen_id, buf, cd);
629 }