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