1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018, Intel Corporation. */
4 #include "ice_switch.h"
6 #define ICE_ETH_DA_OFFSET 0
7 #define ICE_ETH_ETHTYPE_OFFSET 12
8 #define ICE_ETH_VLAN_TCI_OFFSET 14
9 #define ICE_MAX_VLAN_ID 0xFFF
11 /* Dummy ethernet header needed in the ice_aqc_sw_rules_elem
12 * struct to configure any switch filter rules.
13 * {DA (6 bytes), SA(6 bytes),
14 * Ether type (2 bytes for header without VLAN tag) OR
15 * VLAN tag (4 bytes for header with VLAN tag) }
17 * Word on Hardcoded values
18 * byte 0 = 0x2: to identify it as locally administered DA MAC
19 * byte 6 = 0x2: to identify it as locally administered SA MAC
20 * byte 12 = 0x81 & byte 13 = 0x00:
21 * In case of VLAN filter first two bytes defines ether type (0x8100)
22 * and remaining two bytes are placeholder for programming a given VLAN id
23 * In case of Ether type filter it is treated as header without VLAN tag
24 * and byte 12 and 13 is used to program a given Ether type instead
26 #define DUMMY_ETH_HDR_LEN 16
27 static const u8 dummy_eth_header[DUMMY_ETH_HDR_LEN] = { 0x2, 0, 0, 0, 0, 0,
31 #define ICE_SW_RULE_RX_TX_ETH_HDR_SIZE \
32 (sizeof(struct ice_aqc_sw_rules_elem) - \
33 sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
34 sizeof(struct ice_sw_rule_lkup_rx_tx) + DUMMY_ETH_HDR_LEN - 1)
35 #define ICE_SW_RULE_RX_TX_NO_HDR_SIZE \
36 (sizeof(struct ice_aqc_sw_rules_elem) - \
37 sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
38 sizeof(struct ice_sw_rule_lkup_rx_tx) - 1)
39 #define ICE_SW_RULE_LG_ACT_SIZE(n) \
40 (sizeof(struct ice_aqc_sw_rules_elem) - \
41 sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
42 sizeof(struct ice_sw_rule_lg_act) - \
43 sizeof(((struct ice_sw_rule_lg_act *)0)->act) + \
44 ((n) * sizeof(((struct ice_sw_rule_lg_act *)0)->act)))
45 #define ICE_SW_RULE_VSI_LIST_SIZE(n) \
46 (sizeof(struct ice_aqc_sw_rules_elem) - \
47 sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
48 sizeof(struct ice_sw_rule_vsi_list) - \
49 sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi) + \
50 ((n) * sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi)))
53 * ice_aq_alloc_free_res - command to allocate/free resources
54 * @hw: pointer to the hw struct
55 * @num_entries: number of resource entries in buffer
56 * @buf: Indirect buffer to hold data parameters and response
57 * @buf_size: size of buffer for indirect commands
58 * @opc: pass in the command opcode
59 * @cd: pointer to command details structure or NULL
61 * Helper function to allocate/free resources using the admin queue commands
63 static enum ice_status
64 ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
65 struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
66 enum ice_adminq_opc opc, struct ice_sq_cd *cd)
68 struct ice_aqc_alloc_free_res_cmd *cmd;
69 struct ice_aq_desc desc;
71 cmd = &desc.params.sw_res_ctrl;
76 if (buf_size < (num_entries * sizeof(buf->elem[0])))
79 ice_fill_dflt_direct_cmd_desc(&desc, opc);
81 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
83 cmd->num_entries = cpu_to_le16(num_entries);
85 return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
89 * ice_aq_get_sw_cfg - get switch configuration
90 * @hw: pointer to the hardware structure
91 * @buf: pointer to the result buffer
92 * @buf_size: length of the buffer available for response
93 * @req_desc: pointer to requested descriptor
94 * @num_elems: pointer to number of elements
95 * @cd: pointer to command details structure or NULL
97 * Get switch configuration (0x0200) to be placed in 'buff'.
98 * This admin command returns information such as initial VSI/port number
99 * and switch ID it belongs to.
101 * NOTE: *req_desc is both an input/output parameter.
102 * The caller of this function first calls this function with *request_desc set
103 * to 0. If the response from f/w has *req_desc set to 0, all the switch
104 * configuration information has been returned; if non-zero (meaning not all
105 * the information was returned), the caller should call this function again
106 * with *req_desc set to the previous value returned by f/w to get the
107 * next block of switch configuration information.
109 * *num_elems is output only parameter. This reflects the number of elements
110 * in response buffer. The caller of this function to use *num_elems while
111 * parsing the response buffer.
113 static enum ice_status
114 ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf,
115 u16 buf_size, u16 *req_desc, u16 *num_elems,
116 struct ice_sq_cd *cd)
118 struct ice_aqc_get_sw_cfg *cmd;
119 enum ice_status status;
120 struct ice_aq_desc desc;
122 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sw_cfg);
123 cmd = &desc.params.get_sw_conf;
124 cmd->element = cpu_to_le16(*req_desc);
126 status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
128 *req_desc = le16_to_cpu(cmd->element);
129 *num_elems = le16_to_cpu(cmd->num_elems);
137 * @hw: pointer to the hw struct
138 * @vsi_ctx: pointer to a VSI context struct
139 * @cd: pointer to command details structure or NULL
141 * Add a VSI context to the hardware (0x0210)
144 ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
145 struct ice_sq_cd *cd)
147 struct ice_aqc_add_update_free_vsi_resp *res;
148 struct ice_aqc_add_get_update_free_vsi *cmd;
149 enum ice_status status;
150 struct ice_aq_desc desc;
152 cmd = &desc.params.vsi_cmd;
153 res = (struct ice_aqc_add_update_free_vsi_resp *)&desc.params.raw;
155 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_add_vsi);
157 if (!vsi_ctx->alloc_from_pool)
158 cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num |
159 ICE_AQ_VSI_IS_VALID);
161 cmd->vsi_flags = cpu_to_le16(vsi_ctx->flags);
163 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
165 status = ice_aq_send_cmd(hw, &desc, &vsi_ctx->info,
166 sizeof(vsi_ctx->info), cd);
169 vsi_ctx->vsi_num = le16_to_cpu(res->vsi_num) & ICE_AQ_VSI_NUM_M;
170 vsi_ctx->vsis_allocd = le16_to_cpu(res->vsi_used);
171 vsi_ctx->vsis_unallocated = le16_to_cpu(res->vsi_free);
179 * @hw: pointer to the hw struct
180 * @vsi_ctx: pointer to a VSI context struct
181 * @cd: pointer to command details structure or NULL
183 * Update VSI context in the hardware (0x0211)
186 ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
187 struct ice_sq_cd *cd)
189 struct ice_aqc_add_update_free_vsi_resp *resp;
190 struct ice_aqc_add_get_update_free_vsi *cmd;
191 struct ice_aq_desc desc;
192 enum ice_status status;
194 cmd = &desc.params.vsi_cmd;
195 resp = (struct ice_aqc_add_update_free_vsi_resp *)&desc.params.raw;
197 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_update_vsi);
199 cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num | ICE_AQ_VSI_IS_VALID);
201 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
203 status = ice_aq_send_cmd(hw, &desc, &vsi_ctx->info,
204 sizeof(vsi_ctx->info), cd);
207 vsi_ctx->vsis_allocd = le16_to_cpu(resp->vsi_used);
208 vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
216 * @hw: pointer to the hw struct
217 * @vsi_ctx: pointer to a VSI context struct
218 * @keep_vsi_alloc: keep VSI allocation as part of this PF's resources
219 * @cd: pointer to command details structure or NULL
221 * Get VSI context info from hardware (0x0213)
224 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
225 bool keep_vsi_alloc, struct ice_sq_cd *cd)
227 struct ice_aqc_add_update_free_vsi_resp *resp;
228 struct ice_aqc_add_get_update_free_vsi *cmd;
229 struct ice_aq_desc desc;
230 enum ice_status status;
232 cmd = &desc.params.vsi_cmd;
233 resp = (struct ice_aqc_add_update_free_vsi_resp *)&desc.params.raw;
235 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_free_vsi);
237 cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num | ICE_AQ_VSI_IS_VALID);
239 cmd->cmd_flags = cpu_to_le16(ICE_AQ_VSI_KEEP_ALLOC);
241 status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
243 vsi_ctx->vsis_allocd = le16_to_cpu(resp->vsi_used);
244 vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
251 * ice_aq_alloc_free_vsi_list
252 * @hw: pointer to the hw struct
253 * @vsi_list_id: VSI list id returned or used for lookup
254 * @lkup_type: switch rule filter lookup type
255 * @opc: switch rules population command type - pass in the command opcode
257 * allocates or free a VSI list resource
259 static enum ice_status
260 ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
261 enum ice_sw_lkup_type lkup_type,
262 enum ice_adminq_opc opc)
264 struct ice_aqc_alloc_free_res_elem *sw_buf;
265 struct ice_aqc_res_elem *vsi_ele;
266 enum ice_status status;
269 buf_len = sizeof(*sw_buf);
270 sw_buf = devm_kzalloc(ice_hw_to_dev(hw), buf_len, GFP_KERNEL);
272 return ICE_ERR_NO_MEMORY;
273 sw_buf->num_elems = cpu_to_le16(1);
275 if (lkup_type == ICE_SW_LKUP_MAC ||
276 lkup_type == ICE_SW_LKUP_MAC_VLAN ||
277 lkup_type == ICE_SW_LKUP_ETHERTYPE ||
278 lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
279 lkup_type == ICE_SW_LKUP_PROMISC ||
280 lkup_type == ICE_SW_LKUP_PROMISC_VLAN) {
281 sw_buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_VSI_LIST_REP);
282 } else if (lkup_type == ICE_SW_LKUP_VLAN) {
284 cpu_to_le16(ICE_AQC_RES_TYPE_VSI_LIST_PRUNE);
286 status = ICE_ERR_PARAM;
287 goto ice_aq_alloc_free_vsi_list_exit;
290 if (opc == ice_aqc_opc_free_res)
291 sw_buf->elem[0].e.sw_resp = cpu_to_le16(*vsi_list_id);
293 status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len, opc, NULL);
295 goto ice_aq_alloc_free_vsi_list_exit;
297 if (opc == ice_aqc_opc_alloc_res) {
298 vsi_ele = &sw_buf->elem[0];
299 *vsi_list_id = le16_to_cpu(vsi_ele->e.sw_resp);
302 ice_aq_alloc_free_vsi_list_exit:
303 devm_kfree(ice_hw_to_dev(hw), sw_buf);
308 * ice_aq_sw_rules - add/update/remove switch rules
309 * @hw: pointer to the hw struct
310 * @rule_list: pointer to switch rule population list
311 * @rule_list_sz: total size of the rule list in bytes
312 * @num_rules: number of switch rules in the rule_list
313 * @opc: switch rules population command type - pass in the command opcode
314 * @cd: pointer to command details structure or NULL
316 * Add(0x02a0)/Update(0x02a1)/Remove(0x02a2) switch rules commands to firmware
318 static enum ice_status
319 ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
320 u8 num_rules, enum ice_adminq_opc opc, struct ice_sq_cd *cd)
322 struct ice_aq_desc desc;
324 if (opc != ice_aqc_opc_add_sw_rules &&
325 opc != ice_aqc_opc_update_sw_rules &&
326 opc != ice_aqc_opc_remove_sw_rules)
327 return ICE_ERR_PARAM;
329 ice_fill_dflt_direct_cmd_desc(&desc, opc);
331 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
332 desc.params.sw_rules.num_rules_fltr_entry_index =
333 cpu_to_le16(num_rules);
334 return ice_aq_send_cmd(hw, &desc, rule_list, rule_list_sz, cd);
337 /* ice_init_port_info - Initialize port_info with switch configuration data
338 * @pi: pointer to port_info
339 * @vsi_port_num: VSI number or port number
340 * @type: Type of switch element (port or VSI)
341 * @swid: switch ID of the switch the element is attached to
342 * @pf_vf_num: PF or VF number
343 * @is_vf: true if the element is a VF, false otherwise
346 ice_init_port_info(struct ice_port_info *pi, u16 vsi_port_num, u8 type,
347 u16 swid, u16 pf_vf_num, bool is_vf)
350 case ICE_AQC_GET_SW_CONF_RESP_PHYS_PORT:
351 pi->lport = (u8)(vsi_port_num & ICE_LPORT_MASK);
353 pi->pf_vf_num = pf_vf_num;
355 pi->dflt_tx_vsi_num = ICE_DFLT_VSI_INVAL;
356 pi->dflt_rx_vsi_num = ICE_DFLT_VSI_INVAL;
359 ice_debug(pi->hw, ICE_DBG_SW,
360 "incorrect VSI/port type received\n");
365 /* ice_get_initial_sw_cfg - Get initial port and default VSI data
366 * @hw: pointer to the hardware structure
368 enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw)
370 struct ice_aqc_get_sw_cfg_resp *rbuf;
371 enum ice_status status;
376 rbuf = devm_kzalloc(ice_hw_to_dev(hw), ICE_SW_CFG_MAX_BUF_LEN,
380 return ICE_ERR_NO_MEMORY;
382 /* Multiple calls to ice_aq_get_sw_cfg may be required
383 * to get all the switch configuration information. The need
384 * for additional calls is indicated by ice_aq_get_sw_cfg
385 * writing a non-zero value in req_desc
388 status = ice_aq_get_sw_cfg(hw, rbuf, ICE_SW_CFG_MAX_BUF_LEN,
389 &req_desc, &num_elems, NULL);
394 for (i = 0; i < num_elems; i++) {
395 struct ice_aqc_get_sw_cfg_resp_elem *ele;
396 u16 pf_vf_num, swid, vsi_port_num;
400 ele = rbuf[i].elements;
401 vsi_port_num = le16_to_cpu(ele->vsi_port_num) &
402 ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M;
404 pf_vf_num = le16_to_cpu(ele->pf_vf_num) &
405 ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_M;
407 swid = le16_to_cpu(ele->swid);
409 if (le16_to_cpu(ele->pf_vf_num) &
410 ICE_AQC_GET_SW_CONF_RESP_IS_VF)
413 type = le16_to_cpu(ele->vsi_port_num) >>
414 ICE_AQC_GET_SW_CONF_RESP_TYPE_S;
416 if (type == ICE_AQC_GET_SW_CONF_RESP_VSI) {
417 /* FW VSI is not needed. Just continue. */
421 ice_init_port_info(hw->port_info, vsi_port_num,
422 type, swid, pf_vf_num, is_vf);
424 } while (req_desc && !status);
426 devm_kfree(ice_hw_to_dev(hw), (void *)rbuf);
431 * ice_fill_sw_info - Helper function to populate lb_en and lan_en
432 * @hw: pointer to the hardware structure
433 * @f_info: filter info structure to fill/update
435 * This helper function populates the lb_en and lan_en elements of the provided
436 * ice_fltr_info struct using the switch's type and characteristics of the
437 * switch rule being configured.
439 static void ice_fill_sw_info(struct ice_hw *hw, struct ice_fltr_info *f_info)
441 f_info->lb_en = false;
442 f_info->lan_en = false;
443 if ((f_info->flag & ICE_FLTR_TX) &&
444 (f_info->fltr_act == ICE_FWD_TO_VSI ||
445 f_info->fltr_act == ICE_FWD_TO_VSI_LIST ||
446 f_info->fltr_act == ICE_FWD_TO_Q ||
447 f_info->fltr_act == ICE_FWD_TO_QGRP)) {
448 f_info->lb_en = true;
449 if (!(hw->evb_veb && f_info->lkup_type == ICE_SW_LKUP_MAC &&
450 is_unicast_ether_addr(f_info->l_data.mac.mac_addr)))
451 f_info->lan_en = true;
456 * ice_fill_sw_rule - Helper function to fill switch rule structure
457 * @hw: pointer to the hardware structure
458 * @f_info: entry containing packet forwarding information
459 * @s_rule: switch rule structure to be filled in based on mac_entry
460 * @opc: switch rules population command type - pass in the command opcode
463 ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
464 struct ice_aqc_sw_rules_elem *s_rule, enum ice_adminq_opc opc)
466 u16 vlan_id = ICE_MAX_VLAN_ID + 1;
467 u8 eth_hdr[DUMMY_ETH_HDR_LEN];
472 if (opc == ice_aqc_opc_remove_sw_rules) {
473 s_rule->pdata.lkup_tx_rx.act = 0;
474 s_rule->pdata.lkup_tx_rx.index =
475 cpu_to_le16(f_info->fltr_rule_id);
476 s_rule->pdata.lkup_tx_rx.hdr_len = 0;
480 /* initialize the ether header with a dummy header */
481 memcpy(eth_hdr, dummy_eth_header, sizeof(dummy_eth_header));
482 ice_fill_sw_info(hw, f_info);
484 switch (f_info->fltr_act) {
486 act |= (f_info->fwd_id.vsi_id << ICE_SINGLE_ACT_VSI_ID_S) &
487 ICE_SINGLE_ACT_VSI_ID_M;
488 if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
489 act |= ICE_SINGLE_ACT_VSI_FORWARDING |
490 ICE_SINGLE_ACT_VALID_BIT;
492 case ICE_FWD_TO_VSI_LIST:
493 act |= ICE_SINGLE_ACT_VSI_LIST;
494 act |= (f_info->fwd_id.vsi_list_id <<
495 ICE_SINGLE_ACT_VSI_LIST_ID_S) &
496 ICE_SINGLE_ACT_VSI_LIST_ID_M;
497 if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
498 act |= ICE_SINGLE_ACT_VSI_FORWARDING |
499 ICE_SINGLE_ACT_VALID_BIT;
502 act |= ICE_SINGLE_ACT_TO_Q;
503 act |= (f_info->fwd_id.q_id << ICE_SINGLE_ACT_Q_INDEX_S) &
504 ICE_SINGLE_ACT_Q_INDEX_M;
506 case ICE_FWD_TO_QGRP:
507 act |= ICE_SINGLE_ACT_TO_Q;
508 act |= (f_info->qgrp_size << ICE_SINGLE_ACT_Q_REGION_S) &
509 ICE_SINGLE_ACT_Q_REGION_M;
511 case ICE_DROP_PACKET:
512 act |= ICE_SINGLE_ACT_VSI_FORWARDING | ICE_SINGLE_ACT_DROP;
519 act |= ICE_SINGLE_ACT_LB_ENABLE;
521 act |= ICE_SINGLE_ACT_LAN_ENABLE;
523 switch (f_info->lkup_type) {
524 case ICE_SW_LKUP_MAC:
525 daddr = f_info->l_data.mac.mac_addr;
527 case ICE_SW_LKUP_VLAN:
528 vlan_id = f_info->l_data.vlan.vlan_id;
529 if (f_info->fltr_act == ICE_FWD_TO_VSI ||
530 f_info->fltr_act == ICE_FWD_TO_VSI_LIST) {
531 act |= ICE_SINGLE_ACT_PRUNE;
532 act |= ICE_SINGLE_ACT_EGRESS | ICE_SINGLE_ACT_INGRESS;
535 case ICE_SW_LKUP_ETHERTYPE_MAC:
536 daddr = f_info->l_data.ethertype_mac.mac_addr;
538 case ICE_SW_LKUP_ETHERTYPE:
539 off = (__be16 *)ð_hdr[ICE_ETH_ETHTYPE_OFFSET];
540 *off = cpu_to_be16(f_info->l_data.ethertype_mac.ethertype);
542 case ICE_SW_LKUP_MAC_VLAN:
543 daddr = f_info->l_data.mac_vlan.mac_addr;
544 vlan_id = f_info->l_data.mac_vlan.vlan_id;
546 case ICE_SW_LKUP_PROMISC_VLAN:
547 vlan_id = f_info->l_data.mac_vlan.vlan_id;
549 case ICE_SW_LKUP_PROMISC:
550 daddr = f_info->l_data.mac_vlan.mac_addr;
556 s_rule->type = (f_info->flag & ICE_FLTR_RX) ?
557 cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX) :
558 cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_TX);
560 /* Recipe set depending on lookup type */
561 s_rule->pdata.lkup_tx_rx.recipe_id = cpu_to_le16(f_info->lkup_type);
562 s_rule->pdata.lkup_tx_rx.src = cpu_to_le16(f_info->src);
563 s_rule->pdata.lkup_tx_rx.act = cpu_to_le32(act);
566 ether_addr_copy(ð_hdr[ICE_ETH_DA_OFFSET], daddr);
568 if (!(vlan_id > ICE_MAX_VLAN_ID)) {
569 off = (__be16 *)ð_hdr[ICE_ETH_VLAN_TCI_OFFSET];
570 *off = cpu_to_be16(vlan_id);
573 /* Create the switch rule with the final dummy Ethernet header */
574 if (opc != ice_aqc_opc_update_sw_rules)
575 s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(sizeof(eth_hdr));
577 memcpy(s_rule->pdata.lkup_tx_rx.hdr, eth_hdr, sizeof(eth_hdr));
582 * @hw: pointer to the hardware structure
583 * @m_ent: the management entry for which sw marker needs to be added
584 * @sw_marker: sw marker to tag the Rx descriptor with
585 * @l_id: large action resource id
587 * Create a large action to hold software marker and update the switch rule
588 * entry pointed by m_ent with newly created large action
590 static enum ice_status
591 ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
592 u16 sw_marker, u16 l_id)
594 struct ice_aqc_sw_rules_elem *lg_act, *rx_tx;
595 /* For software marker we need 3 large actions
596 * 1. FWD action: FWD TO VSI or VSI LIST
597 * 2. GENERIC VALUE action to hold the profile id
598 * 3. GENERIC VALUE action to hold the software marker id
600 const u16 num_lg_acts = 3;
601 enum ice_status status;
607 if (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
608 return ICE_ERR_PARAM;
610 /* Create two back-to-back switch rules and submit them to the HW using
615 lg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_lg_acts);
616 rules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
617 lg_act = devm_kzalloc(ice_hw_to_dev(hw), rules_size, GFP_KERNEL);
619 return ICE_ERR_NO_MEMORY;
621 rx_tx = (struct ice_aqc_sw_rules_elem *)((u8 *)lg_act + lg_act_size);
623 /* Fill in the first switch rule i.e. large action */
624 lg_act->type = cpu_to_le16(ICE_AQC_SW_RULES_T_LG_ACT);
625 lg_act->pdata.lg_act.index = cpu_to_le16(l_id);
626 lg_act->pdata.lg_act.size = cpu_to_le16(num_lg_acts);
628 /* First action VSI forwarding or VSI list forwarding depending on how
631 vsi_info = (m_ent->vsi_count > 1) ?
632 m_ent->fltr_info.fwd_id.vsi_list_id :
633 m_ent->fltr_info.fwd_id.vsi_id;
635 act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
636 act |= (vsi_info << ICE_LG_ACT_VSI_LIST_ID_S) &
637 ICE_LG_ACT_VSI_LIST_ID_M;
638 if (m_ent->vsi_count > 1)
639 act |= ICE_LG_ACT_VSI_LIST;
640 lg_act->pdata.lg_act.act[0] = cpu_to_le32(act);
642 /* Second action descriptor type */
643 act = ICE_LG_ACT_GENERIC;
645 act |= (1 << ICE_LG_ACT_GENERIC_VALUE_S) & ICE_LG_ACT_GENERIC_VALUE_M;
646 lg_act->pdata.lg_act.act[1] = cpu_to_le32(act);
648 act = (7 << ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_VALUE_M;
650 /* Third action Marker value */
651 act |= ICE_LG_ACT_GENERIC;
652 act |= (sw_marker << ICE_LG_ACT_GENERIC_VALUE_S) &
653 ICE_LG_ACT_GENERIC_VALUE_M;
655 act |= (0 << ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_VALUE_M;
656 lg_act->pdata.lg_act.act[2] = cpu_to_le32(act);
658 /* call the fill switch rule to fill the lookup tx rx structure */
659 ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,
660 ice_aqc_opc_update_sw_rules);
662 /* Update the action to point to the large action id */
663 rx_tx->pdata.lkup_tx_rx.act =
664 cpu_to_le32(ICE_SINGLE_ACT_PTR |
665 ((l_id << ICE_SINGLE_ACT_PTR_VAL_S) &
666 ICE_SINGLE_ACT_PTR_VAL_M));
668 /* Use the filter rule id of the previously created rule with single
669 * act. Once the update happens, hardware will treat this as large
672 rx_tx->pdata.lkup_tx_rx.index =
673 cpu_to_le16(m_ent->fltr_info.fltr_rule_id);
675 status = ice_aq_sw_rules(hw, lg_act, rules_size, 2,
676 ice_aqc_opc_update_sw_rules, NULL);
678 m_ent->lg_act_idx = l_id;
679 m_ent->sw_marker_id = sw_marker;
682 devm_kfree(ice_hw_to_dev(hw), lg_act);
687 * ice_create_vsi_list_map
688 * @hw: pointer to the hardware structure
689 * @vsi_array: array of VSIs to form a VSI list
690 * @num_vsi: num VSI in the array
691 * @vsi_list_id: VSI list id generated as part of allocate resource
693 * Helper function to create a new entry of VSI list id to VSI mapping
694 * using the given VSI list id
696 static struct ice_vsi_list_map_info *
697 ice_create_vsi_list_map(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
700 struct ice_switch_info *sw = hw->switch_info;
701 struct ice_vsi_list_map_info *v_map;
704 v_map = devm_kcalloc(ice_hw_to_dev(hw), 1, sizeof(*v_map), GFP_KERNEL);
708 v_map->vsi_list_id = vsi_list_id;
710 for (i = 0; i < num_vsi; i++)
711 set_bit(vsi_array[i], v_map->vsi_map);
713 list_add(&v_map->list_entry, &sw->vsi_list_map_head);
718 * ice_update_vsi_list_rule
719 * @hw: pointer to the hardware structure
720 * @vsi_array: array of VSIs to form a VSI list
721 * @num_vsi: num VSI in the array
722 * @vsi_list_id: VSI list id generated as part of allocate resource
723 * @remove: Boolean value to indicate if this is a remove action
724 * @opc: switch rules population command type - pass in the command opcode
725 * @lkup_type: lookup type of the filter
727 * Call AQ command to add a new switch rule or update existing switch rule
728 * using the given VSI list id
730 static enum ice_status
731 ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
732 u16 vsi_list_id, bool remove, enum ice_adminq_opc opc,
733 enum ice_sw_lkup_type lkup_type)
735 struct ice_aqc_sw_rules_elem *s_rule;
736 enum ice_status status;
742 return ICE_ERR_PARAM;
744 if (lkup_type == ICE_SW_LKUP_MAC ||
745 lkup_type == ICE_SW_LKUP_MAC_VLAN ||
746 lkup_type == ICE_SW_LKUP_ETHERTYPE ||
747 lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
748 lkup_type == ICE_SW_LKUP_PROMISC ||
749 lkup_type == ICE_SW_LKUP_PROMISC_VLAN)
750 type = remove ? ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR :
751 ICE_AQC_SW_RULES_T_VSI_LIST_SET;
752 else if (lkup_type == ICE_SW_LKUP_VLAN)
753 type = remove ? ICE_AQC_SW_RULES_T_PRUNE_LIST_CLEAR :
754 ICE_AQC_SW_RULES_T_PRUNE_LIST_SET;
756 return ICE_ERR_PARAM;
758 s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(num_vsi);
759 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
761 return ICE_ERR_NO_MEMORY;
763 for (i = 0; i < num_vsi; i++)
764 s_rule->pdata.vsi_list.vsi[i] = cpu_to_le16(vsi_array[i]);
766 s_rule->type = cpu_to_le16(type);
767 s_rule->pdata.vsi_list.number_vsi = cpu_to_le16(num_vsi);
768 s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
770 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opc, NULL);
772 devm_kfree(ice_hw_to_dev(hw), s_rule);
777 * ice_create_vsi_list_rule - Creates and populates a VSI list rule
778 * @hw: pointer to the hw struct
779 * @vsi_array: array of VSIs to form a VSI list
780 * @num_vsi: number of VSIs in the array
781 * @vsi_list_id: stores the ID of the VSI list to be created
782 * @lkup_type: switch rule filter's lookup type
784 static enum ice_status
785 ice_create_vsi_list_rule(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
786 u16 *vsi_list_id, enum ice_sw_lkup_type lkup_type)
788 enum ice_status status;
791 for (i = 0; i < num_vsi; i++)
792 if (vsi_array[i] >= ICE_MAX_VSI)
793 return ICE_ERR_OUT_OF_RANGE;
795 status = ice_aq_alloc_free_vsi_list(hw, vsi_list_id, lkup_type,
796 ice_aqc_opc_alloc_res);
800 /* Update the newly created VSI list to include the specified VSIs */
801 return ice_update_vsi_list_rule(hw, vsi_array, num_vsi, *vsi_list_id,
802 false, ice_aqc_opc_add_sw_rules,
807 * ice_create_pkt_fwd_rule
808 * @hw: pointer to the hardware structure
809 * @f_entry: entry containing packet forwarding information
811 * Create switch rule with given filter information and add an entry
812 * to the corresponding filter management list to track this switch rule
815 static enum ice_status
816 ice_create_pkt_fwd_rule(struct ice_hw *hw,
817 struct ice_fltr_list_entry *f_entry)
819 struct ice_switch_info *sw = hw->switch_info;
820 struct ice_fltr_mgmt_list_entry *fm_entry;
821 struct ice_aqc_sw_rules_elem *s_rule;
822 enum ice_sw_lkup_type l_type;
823 enum ice_status status;
825 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
826 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
828 return ICE_ERR_NO_MEMORY;
829 fm_entry = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*fm_entry),
832 status = ICE_ERR_NO_MEMORY;
833 goto ice_create_pkt_fwd_rule_exit;
836 fm_entry->fltr_info = f_entry->fltr_info;
838 /* Initialize all the fields for the management entry */
839 fm_entry->vsi_count = 1;
840 fm_entry->lg_act_idx = ICE_INVAL_LG_ACT_INDEX;
841 fm_entry->sw_marker_id = ICE_INVAL_SW_MARKER_ID;
842 fm_entry->counter_index = ICE_INVAL_COUNTER_ID;
844 ice_fill_sw_rule(hw, &fm_entry->fltr_info, s_rule,
845 ice_aqc_opc_add_sw_rules);
847 status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
848 ice_aqc_opc_add_sw_rules, NULL);
850 devm_kfree(ice_hw_to_dev(hw), fm_entry);
851 goto ice_create_pkt_fwd_rule_exit;
854 f_entry->fltr_info.fltr_rule_id =
855 le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
856 fm_entry->fltr_info.fltr_rule_id =
857 le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
859 /* The book keeping entries will get removed when base driver
860 * calls remove filter AQ command
862 l_type = fm_entry->fltr_info.lkup_type;
863 if (l_type == ICE_SW_LKUP_MAC) {
864 mutex_lock(&sw->mac_list_lock);
865 list_add(&fm_entry->list_entry, &sw->mac_list_head);
866 mutex_unlock(&sw->mac_list_lock);
867 } else if (l_type == ICE_SW_LKUP_VLAN) {
868 mutex_lock(&sw->vlan_list_lock);
869 list_add(&fm_entry->list_entry, &sw->vlan_list_head);
870 mutex_unlock(&sw->vlan_list_lock);
871 } else if (l_type == ICE_SW_LKUP_ETHERTYPE ||
872 l_type == ICE_SW_LKUP_ETHERTYPE_MAC) {
873 mutex_lock(&sw->eth_m_list_lock);
874 list_add(&fm_entry->list_entry, &sw->eth_m_list_head);
875 mutex_unlock(&sw->eth_m_list_lock);
876 } else if (l_type == ICE_SW_LKUP_PROMISC ||
877 l_type == ICE_SW_LKUP_PROMISC_VLAN) {
878 mutex_lock(&sw->promisc_list_lock);
879 list_add(&fm_entry->list_entry, &sw->promisc_list_head);
880 mutex_unlock(&sw->promisc_list_lock);
881 } else if (fm_entry->fltr_info.lkup_type == ICE_SW_LKUP_MAC_VLAN) {
882 mutex_lock(&sw->mac_vlan_list_lock);
883 list_add(&fm_entry->list_entry, &sw->mac_vlan_list_head);
884 mutex_unlock(&sw->mac_vlan_list_lock);
886 status = ICE_ERR_NOT_IMPL;
888 ice_create_pkt_fwd_rule_exit:
889 devm_kfree(ice_hw_to_dev(hw), s_rule);
894 * ice_update_pkt_fwd_rule
895 * @hw: pointer to the hardware structure
896 * @rule_id: rule of previously created switch rule to update
897 * @vsi_list_id: VSI list id to be updated with
898 * @f_info: ice_fltr_info to pull other information for switch rule
900 * Call AQ command to update a previously created switch rule with a
903 static enum ice_status
904 ice_update_pkt_fwd_rule(struct ice_hw *hw, u16 rule_id, u16 vsi_list_id,
905 struct ice_fltr_info f_info)
907 struct ice_aqc_sw_rules_elem *s_rule;
908 struct ice_fltr_info tmp_fltr;
909 enum ice_status status;
911 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
912 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
914 return ICE_ERR_NO_MEMORY;
917 tmp_fltr.fltr_act = ICE_FWD_TO_VSI_LIST;
918 tmp_fltr.fwd_id.vsi_list_id = vsi_list_id;
920 ice_fill_sw_rule(hw, &tmp_fltr, s_rule,
921 ice_aqc_opc_update_sw_rules);
923 s_rule->pdata.lkup_tx_rx.index = cpu_to_le16(rule_id);
925 /* Update switch rule with new rule set to forward VSI list */
926 status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
927 ice_aqc_opc_update_sw_rules, NULL);
929 devm_kfree(ice_hw_to_dev(hw), s_rule);
934 * ice_handle_vsi_list_mgmt
935 * @hw: pointer to the hardware structure
936 * @m_entry: pointer to current filter management list entry
937 * @cur_fltr: filter information from the book keeping entry
938 * @new_fltr: filter information with the new VSI to be added
940 * Call AQ command to add or update previously created VSI list with new VSI.
942 * Helper function to do book keeping associated with adding filter information
943 * The algorithm to do the booking keeping is described below :
944 * When a VSI needs to subscribe to a given filter( MAC/VLAN/Ethtype etc.)
945 * if only one VSI has been added till now
946 * Allocate a new VSI list and add two VSIs
947 * to this list using switch rule command
948 * Update the previously created switch rule with the
949 * newly created VSI list id
950 * if a VSI list was previously created
951 * Add the new VSI to the previously created VSI list set
952 * using the update switch rule command
954 static enum ice_status
955 ice_handle_vsi_list_mgmt(struct ice_hw *hw,
956 struct ice_fltr_mgmt_list_entry *m_entry,
957 struct ice_fltr_info *cur_fltr,
958 struct ice_fltr_info *new_fltr)
960 enum ice_status status = 0;
963 if ((cur_fltr->fltr_act == ICE_FWD_TO_Q ||
964 cur_fltr->fltr_act == ICE_FWD_TO_QGRP))
965 return ICE_ERR_NOT_IMPL;
967 if ((new_fltr->fltr_act == ICE_FWD_TO_Q ||
968 new_fltr->fltr_act == ICE_FWD_TO_QGRP) &&
969 (cur_fltr->fltr_act == ICE_FWD_TO_VSI ||
970 cur_fltr->fltr_act == ICE_FWD_TO_VSI_LIST))
971 return ICE_ERR_NOT_IMPL;
973 if (m_entry->vsi_count < 2 && !m_entry->vsi_list_info) {
974 /* Only one entry existed in the mapping and it was not already
975 * a part of a VSI list. So, create a VSI list with the old and
981 /* A rule already exists with the new VSI being added */
982 if (cur_fltr->fwd_id.vsi_id == new_fltr->fwd_id.vsi_id)
983 return ICE_ERR_ALREADY_EXISTS;
985 vsi_id_arr[0] = cur_fltr->fwd_id.vsi_id;
986 vsi_id_arr[1] = new_fltr->fwd_id.vsi_id;
987 status = ice_create_vsi_list_rule(hw, &vsi_id_arr[0], 2,
989 new_fltr->lkup_type);
993 fltr_rule = cur_fltr->fltr_rule_id;
994 /* Update the previous switch rule of "MAC forward to VSI" to
995 * "MAC fwd to VSI list"
997 status = ice_update_pkt_fwd_rule(hw, fltr_rule, vsi_list_id,
1002 cur_fltr->fwd_id.vsi_list_id = vsi_list_id;
1003 cur_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
1004 m_entry->vsi_list_info =
1005 ice_create_vsi_list_map(hw, &vsi_id_arr[0], 2,
1008 /* If this entry was large action then the large action needs
1009 * to be updated to point to FWD to VSI list
1011 if (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID)
1013 ice_add_marker_act(hw, m_entry,
1014 m_entry->sw_marker_id,
1015 m_entry->lg_act_idx);
1017 u16 vsi_id = new_fltr->fwd_id.vsi_id;
1018 enum ice_adminq_opc opcode;
1020 /* A rule already exists with the new VSI being added */
1021 if (test_bit(vsi_id, m_entry->vsi_list_info->vsi_map))
1024 /* Update the previously created VSI list set with
1025 * the new VSI id passed in
1027 vsi_list_id = cur_fltr->fwd_id.vsi_list_id;
1028 opcode = ice_aqc_opc_update_sw_rules;
1030 status = ice_update_vsi_list_rule(hw, &vsi_id, 1, vsi_list_id,
1032 new_fltr->lkup_type);
1033 /* update VSI list mapping info with new VSI id */
1035 set_bit(vsi_id, m_entry->vsi_list_info->vsi_map);
1038 m_entry->vsi_count++;
1043 * ice_find_mac_entry
1044 * @hw: pointer to the hardware structure
1045 * @mac_addr: MAC address to search for
1047 * Helper function to search for a MAC entry using a given MAC address
1048 * Returns pointer to the entry if found.
1050 static struct ice_fltr_mgmt_list_entry *
1051 ice_find_mac_entry(struct ice_hw *hw, u8 *mac_addr)
1053 struct ice_fltr_mgmt_list_entry *m_list_itr, *mac_ret = NULL;
1054 struct ice_switch_info *sw = hw->switch_info;
1056 mutex_lock(&sw->mac_list_lock);
1057 list_for_each_entry(m_list_itr, &sw->mac_list_head, list_entry) {
1058 u8 *buf = &m_list_itr->fltr_info.l_data.mac.mac_addr[0];
1060 if (ether_addr_equal(buf, mac_addr)) {
1061 mac_ret = m_list_itr;
1065 mutex_unlock(&sw->mac_list_lock);
1070 * ice_add_shared_mac - Add one MAC shared filter rule
1071 * @hw: pointer to the hardware structure
1072 * @f_entry: structure containing MAC forwarding information
1074 * Adds or updates the book keeping list for the MAC addresses
1076 static enum ice_status
1077 ice_add_shared_mac(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1079 struct ice_fltr_info *new_fltr, *cur_fltr;
1080 struct ice_fltr_mgmt_list_entry *m_entry;
1082 new_fltr = &f_entry->fltr_info;
1084 m_entry = ice_find_mac_entry(hw, &new_fltr->l_data.mac.mac_addr[0]);
1086 return ice_create_pkt_fwd_rule(hw, f_entry);
1088 cur_fltr = &m_entry->fltr_info;
1090 return ice_handle_vsi_list_mgmt(hw, m_entry, cur_fltr, new_fltr);
1094 * ice_add_mac - Add a MAC address based filter rule
1095 * @hw: pointer to the hardware structure
1096 * @m_list: list of MAC addresses and forwarding information
1098 * IMPORTANT: When the ucast_shared flag is set to false and m_list has
1099 * multiple unicast addresses, the function assumes that all the
1100 * addresses are unique in a given add_mac call. It doesn't
1101 * check for duplicates in this case, removing duplicates from a given
1102 * list should be taken care of in the caller of this function.
1105 ice_add_mac(struct ice_hw *hw, struct list_head *m_list)
1107 struct ice_aqc_sw_rules_elem *s_rule, *r_iter;
1108 struct ice_fltr_list_entry *m_list_itr;
1109 u16 elem_sent, total_elem_left;
1110 enum ice_status status = 0;
1111 u16 num_unicast = 0;
1115 return ICE_ERR_PARAM;
1117 list_for_each_entry(m_list_itr, m_list, list_entry) {
1118 u8 *add = &m_list_itr->fltr_info.l_data.mac.mac_addr[0];
1120 if (m_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
1121 return ICE_ERR_PARAM;
1122 if (is_zero_ether_addr(add))
1123 return ICE_ERR_PARAM;
1124 if (is_unicast_ether_addr(add) && !hw->ucast_shared) {
1125 /* Don't overwrite the unicast address */
1126 if (ice_find_mac_entry(hw, add))
1127 return ICE_ERR_ALREADY_EXISTS;
1129 } else if (is_multicast_ether_addr(add) ||
1130 (is_unicast_ether_addr(add) && hw->ucast_shared)) {
1131 status = ice_add_shared_mac(hw, m_list_itr);
1133 m_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1136 m_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1140 /* Exit if no suitable entries were found for adding bulk switch rule */
1144 /* Allocate switch rule buffer for the bulk update for unicast */
1145 s_rule_size = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
1146 s_rule = devm_kcalloc(ice_hw_to_dev(hw), num_unicast, s_rule_size,
1149 return ICE_ERR_NO_MEMORY;
1152 list_for_each_entry(m_list_itr, m_list, list_entry) {
1153 struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
1154 u8 *addr = &f_info->l_data.mac.mac_addr[0];
1156 if (is_unicast_ether_addr(addr)) {
1157 ice_fill_sw_rule(hw, &m_list_itr->fltr_info,
1158 r_iter, ice_aqc_opc_add_sw_rules);
1159 r_iter = (struct ice_aqc_sw_rules_elem *)
1160 ((u8 *)r_iter + s_rule_size);
1164 /* Call AQ bulk switch rule update for all unicast addresses */
1166 /* Call AQ switch rule in AQ_MAX chunk */
1167 for (total_elem_left = num_unicast; total_elem_left > 0;
1168 total_elem_left -= elem_sent) {
1169 struct ice_aqc_sw_rules_elem *entry = r_iter;
1171 elem_sent = min(total_elem_left,
1172 (u16)(ICE_AQ_MAX_BUF_LEN / s_rule_size));
1173 status = ice_aq_sw_rules(hw, entry, elem_sent * s_rule_size,
1174 elem_sent, ice_aqc_opc_add_sw_rules,
1177 goto ice_add_mac_exit;
1178 r_iter = (struct ice_aqc_sw_rules_elem *)
1179 ((u8 *)r_iter + (elem_sent * s_rule_size));
1182 /* Fill up rule id based on the value returned from FW */
1184 list_for_each_entry(m_list_itr, m_list, list_entry) {
1185 struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
1186 u8 *addr = &f_info->l_data.mac.mac_addr[0];
1187 struct ice_switch_info *sw = hw->switch_info;
1188 struct ice_fltr_mgmt_list_entry *fm_entry;
1190 if (is_unicast_ether_addr(addr)) {
1191 f_info->fltr_rule_id =
1192 le16_to_cpu(r_iter->pdata.lkup_tx_rx.index);
1193 f_info->fltr_act = ICE_FWD_TO_VSI;
1194 /* Create an entry to track this MAC address */
1195 fm_entry = devm_kzalloc(ice_hw_to_dev(hw),
1196 sizeof(*fm_entry), GFP_KERNEL);
1198 status = ICE_ERR_NO_MEMORY;
1199 goto ice_add_mac_exit;
1201 fm_entry->fltr_info = *f_info;
1202 fm_entry->vsi_count = 1;
1203 /* The book keeping entries will get removed when
1204 * base driver calls remove filter AQ command
1206 mutex_lock(&sw->mac_list_lock);
1207 list_add(&fm_entry->list_entry, &sw->mac_list_head);
1208 mutex_unlock(&sw->mac_list_lock);
1210 r_iter = (struct ice_aqc_sw_rules_elem *)
1211 ((u8 *)r_iter + s_rule_size);
1216 devm_kfree(ice_hw_to_dev(hw), s_rule);
1221 * ice_find_vlan_entry
1222 * @hw: pointer to the hardware structure
1223 * @vlan_id: VLAN id to search for
1225 * Helper function to search for a VLAN entry using a given VLAN id
1226 * Returns pointer to the entry if found.
1228 static struct ice_fltr_mgmt_list_entry *
1229 ice_find_vlan_entry(struct ice_hw *hw, u16 vlan_id)
1231 struct ice_fltr_mgmt_list_entry *vlan_list_itr, *vlan_ret = NULL;
1232 struct ice_switch_info *sw = hw->switch_info;
1234 mutex_lock(&sw->vlan_list_lock);
1235 list_for_each_entry(vlan_list_itr, &sw->vlan_list_head, list_entry)
1236 if (vlan_list_itr->fltr_info.l_data.vlan.vlan_id == vlan_id) {
1237 vlan_ret = vlan_list_itr;
1241 mutex_unlock(&sw->vlan_list_lock);
1246 * ice_add_vlan_internal - Add one VLAN based filter rule
1247 * @hw: pointer to the hardware structure
1248 * @f_entry: filter entry containing one VLAN information
1250 static enum ice_status
1251 ice_add_vlan_internal(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1253 struct ice_fltr_info *new_fltr, *cur_fltr;
1254 struct ice_fltr_mgmt_list_entry *v_list_itr;
1257 new_fltr = &f_entry->fltr_info;
1258 /* VLAN id should only be 12 bits */
1259 if (new_fltr->l_data.vlan.vlan_id > ICE_MAX_VLAN_ID)
1260 return ICE_ERR_PARAM;
1262 vlan_id = new_fltr->l_data.vlan.vlan_id;
1263 v_list_itr = ice_find_vlan_entry(hw, vlan_id);
1265 u16 vsi_id = ICE_VSI_INVAL_ID;
1266 enum ice_status status;
1267 u16 vsi_list_id = 0;
1269 if (new_fltr->fltr_act == ICE_FWD_TO_VSI) {
1270 enum ice_sw_lkup_type lkup_type = new_fltr->lkup_type;
1272 /* All VLAN pruning rules use a VSI list.
1273 * Convert the action to forwarding to a VSI list.
1275 vsi_id = new_fltr->fwd_id.vsi_id;
1276 status = ice_create_vsi_list_rule(hw, &vsi_id, 1,
1281 new_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
1282 new_fltr->fwd_id.vsi_list_id = vsi_list_id;
1285 status = ice_create_pkt_fwd_rule(hw, f_entry);
1286 if (!status && vsi_id != ICE_VSI_INVAL_ID) {
1287 v_list_itr = ice_find_vlan_entry(hw, vlan_id);
1289 return ICE_ERR_DOES_NOT_EXIST;
1290 v_list_itr->vsi_list_info =
1291 ice_create_vsi_list_map(hw, &vsi_id, 1,
1298 cur_fltr = &v_list_itr->fltr_info;
1299 return ice_handle_vsi_list_mgmt(hw, v_list_itr, cur_fltr, new_fltr);
1303 * ice_add_vlan - Add VLAN based filter rule
1304 * @hw: pointer to the hardware structure
1305 * @v_list: list of VLAN entries and forwarding information
1308 ice_add_vlan(struct ice_hw *hw, struct list_head *v_list)
1310 struct ice_fltr_list_entry *v_list_itr;
1313 return ICE_ERR_PARAM;
1315 list_for_each_entry(v_list_itr, v_list, list_entry) {
1316 enum ice_status status;
1318 if (v_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_VLAN)
1319 return ICE_ERR_PARAM;
1321 status = ice_add_vlan_internal(hw, v_list_itr);
1323 v_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1326 v_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1332 * ice_remove_vsi_list_rule
1333 * @hw: pointer to the hardware structure
1334 * @vsi_list_id: VSI list id generated as part of allocate resource
1335 * @lkup_type: switch rule filter lookup type
1337 static enum ice_status
1338 ice_remove_vsi_list_rule(struct ice_hw *hw, u16 vsi_list_id,
1339 enum ice_sw_lkup_type lkup_type)
1341 struct ice_aqc_sw_rules_elem *s_rule;
1342 enum ice_status status;
1345 s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(0);
1346 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
1348 return ICE_ERR_NO_MEMORY;
1350 s_rule->type = cpu_to_le16(ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR);
1351 s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
1352 /* FW expects number of VSIs in vsi_list resource to be 0 for clear
1353 * command. Since memory is zero'ed out during initialization, it's not
1354 * necessary to explicitly initialize the variable to 0.
1357 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1,
1358 ice_aqc_opc_remove_sw_rules, NULL);
1360 /* Free the vsi_list resource that we allocated */
1361 status = ice_aq_alloc_free_vsi_list(hw, &vsi_list_id, lkup_type,
1362 ice_aqc_opc_free_res);
1364 devm_kfree(ice_hw_to_dev(hw), s_rule);
1369 * ice_handle_rem_vsi_list_mgmt
1370 * @hw: pointer to the hardware structure
1371 * @vsi_id: ID of the VSI to remove
1372 * @fm_list_itr: filter management entry for which the VSI list management
1375 static enum ice_status
1376 ice_handle_rem_vsi_list_mgmt(struct ice_hw *hw, u16 vsi_id,
1377 struct ice_fltr_mgmt_list_entry *fm_list_itr)
1379 struct ice_switch_info *sw = hw->switch_info;
1380 enum ice_status status = 0;
1381 enum ice_sw_lkup_type lkup_type;
1382 bool is_last_elem = true;
1383 bool conv_list = false;
1384 bool del_list = false;
1387 lkup_type = fm_list_itr->fltr_info.lkup_type;
1388 vsi_list_id = fm_list_itr->fltr_info.fwd_id.vsi_list_id;
1390 if (fm_list_itr->vsi_count > 1) {
1391 status = ice_update_vsi_list_rule(hw, &vsi_id, 1, vsi_list_id,
1393 ice_aqc_opc_update_sw_rules,
1397 fm_list_itr->vsi_count--;
1398 is_last_elem = false;
1399 clear_bit(vsi_id, fm_list_itr->vsi_list_info->vsi_map);
1402 /* For non-VLAN rules that forward packets to a VSI list, convert them
1403 * to forwarding packets to a VSI if there is only one VSI left in the
1404 * list. Unused lists are then removed.
1405 * VLAN rules need to use VSI lists even with only one VSI.
1407 if (fm_list_itr->fltr_info.fltr_act == ICE_FWD_TO_VSI_LIST) {
1408 if (lkup_type == ICE_SW_LKUP_VLAN) {
1409 del_list = is_last_elem;
1410 } else if (fm_list_itr->vsi_count == 1) {
1417 /* Remove the VSI list since it is no longer used */
1418 struct ice_vsi_list_map_info *vsi_list_info =
1419 fm_list_itr->vsi_list_info;
1421 status = ice_remove_vsi_list_rule(hw, vsi_list_id, lkup_type);
1428 rem_vsi_id = find_first_bit(vsi_list_info->vsi_map,
1431 /* Error out when the expected last element is not in
1434 if (rem_vsi_id == ICE_MAX_VSI)
1435 return ICE_ERR_OUT_OF_RANGE;
1437 /* Change the list entry action from VSI_LIST to VSI */
1438 fm_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1439 fm_list_itr->fltr_info.fwd_id.vsi_id = rem_vsi_id;
1442 list_del(&vsi_list_info->list_entry);
1443 devm_kfree(ice_hw_to_dev(hw), vsi_list_info);
1444 fm_list_itr->vsi_list_info = NULL;
1448 /* Convert the rule's forward action to forwarding packets to
1451 struct ice_aqc_sw_rules_elem *s_rule;
1453 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
1454 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE,
1457 return ICE_ERR_NO_MEMORY;
1459 ice_fill_sw_rule(hw, &fm_list_itr->fltr_info, s_rule,
1460 ice_aqc_opc_update_sw_rules);
1462 s_rule->pdata.lkup_tx_rx.index =
1463 cpu_to_le16(fm_list_itr->fltr_info.fltr_rule_id);
1465 status = ice_aq_sw_rules(hw, s_rule,
1466 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
1467 ice_aqc_opc_update_sw_rules, NULL);
1468 devm_kfree(ice_hw_to_dev(hw), s_rule);
1474 /* Remove the lookup rule */
1475 struct ice_aqc_sw_rules_elem *s_rule;
1477 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
1478 ICE_SW_RULE_RX_TX_NO_HDR_SIZE,
1481 return ICE_ERR_NO_MEMORY;
1483 ice_fill_sw_rule(hw, &fm_list_itr->fltr_info, s_rule,
1484 ice_aqc_opc_remove_sw_rules);
1486 status = ice_aq_sw_rules(hw, s_rule,
1487 ICE_SW_RULE_RX_TX_NO_HDR_SIZE, 1,
1488 ice_aqc_opc_remove_sw_rules, NULL);
1492 /* Remove a book keeping entry from the MAC address list */
1493 mutex_lock(&sw->mac_list_lock);
1494 list_del(&fm_list_itr->list_entry);
1495 mutex_unlock(&sw->mac_list_lock);
1496 devm_kfree(ice_hw_to_dev(hw), fm_list_itr);
1497 devm_kfree(ice_hw_to_dev(hw), s_rule);
1503 * ice_remove_mac_entry
1504 * @hw: pointer to the hardware structure
1505 * @f_entry: structure containing MAC forwarding information
1507 static enum ice_status
1508 ice_remove_mac_entry(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1510 struct ice_fltr_mgmt_list_entry *m_entry;
1514 add = &f_entry->fltr_info.l_data.mac.mac_addr[0];
1516 m_entry = ice_find_mac_entry(hw, add);
1518 return ICE_ERR_PARAM;
1520 vsi_id = f_entry->fltr_info.fwd_id.vsi_id;
1521 return ice_handle_rem_vsi_list_mgmt(hw, vsi_id, m_entry);
1525 * ice_remove_mac - remove a MAC address based filter rule
1526 * @hw: pointer to the hardware structure
1527 * @m_list: list of MAC addresses and forwarding information
1529 * This function removes either a MAC filter rule or a specific VSI from a
1530 * VSI list for a multicast MAC address.
1532 * Returns ICE_ERR_DOES_NOT_EXIST if a given entry was not added by
1533 * ice_add_mac. Caller should be aware that this call will only work if all
1534 * the entries passed into m_list were added previously. It will not attempt to
1535 * do a partial remove of entries that were found.
1538 ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)
1540 struct ice_aqc_sw_rules_elem *s_rule, *r_iter;
1541 u8 s_rule_size = ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
1542 struct ice_switch_info *sw = hw->switch_info;
1543 struct ice_fltr_mgmt_list_entry *m_entry;
1544 struct ice_fltr_list_entry *m_list_itr;
1545 u16 elem_sent, total_elem_left;
1546 enum ice_status status = 0;
1547 u16 num_unicast = 0;
1550 return ICE_ERR_PARAM;
1552 list_for_each_entry(m_list_itr, m_list, list_entry) {
1553 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1555 if (is_unicast_ether_addr(addr) && !hw->ucast_shared)
1557 else if (is_multicast_ether_addr(addr) ||
1558 (is_unicast_ether_addr(addr) && hw->ucast_shared))
1559 ice_remove_mac_entry(hw, m_list_itr);
1562 /* Exit if no unicast addresses found. Multicast switch rules
1563 * were added individually
1568 /* Allocate switch rule buffer for the bulk update for unicast */
1569 s_rule = devm_kcalloc(ice_hw_to_dev(hw), num_unicast, s_rule_size,
1572 return ICE_ERR_NO_MEMORY;
1575 list_for_each_entry(m_list_itr, m_list, list_entry) {
1576 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1578 if (is_unicast_ether_addr(addr)) {
1579 m_entry = ice_find_mac_entry(hw, addr);
1581 status = ICE_ERR_DOES_NOT_EXIST;
1582 goto ice_remove_mac_exit;
1585 ice_fill_sw_rule(hw, &m_entry->fltr_info,
1586 r_iter, ice_aqc_opc_remove_sw_rules);
1587 r_iter = (struct ice_aqc_sw_rules_elem *)
1588 ((u8 *)r_iter + s_rule_size);
1592 /* Call AQ bulk switch rule update for all unicast addresses */
1594 /* Call AQ switch rule in AQ_MAX chunk */
1595 for (total_elem_left = num_unicast; total_elem_left > 0;
1596 total_elem_left -= elem_sent) {
1597 struct ice_aqc_sw_rules_elem *entry = r_iter;
1599 elem_sent = min(total_elem_left,
1600 (u16)(ICE_AQ_MAX_BUF_LEN / s_rule_size));
1601 status = ice_aq_sw_rules(hw, entry, elem_sent * s_rule_size,
1602 elem_sent, ice_aqc_opc_remove_sw_rules,
1606 r_iter = (struct ice_aqc_sw_rules_elem *)
1607 ((u8 *)r_iter + s_rule_size);
1610 list_for_each_entry(m_list_itr, m_list, list_entry) {
1611 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1613 if (is_unicast_ether_addr(addr)) {
1614 m_entry = ice_find_mac_entry(hw, addr);
1616 return ICE_ERR_OUT_OF_RANGE;
1617 mutex_lock(&sw->mac_list_lock);
1618 list_del(&m_entry->list_entry);
1619 mutex_unlock(&sw->mac_list_lock);
1620 devm_kfree(ice_hw_to_dev(hw), m_entry);
1624 ice_remove_mac_exit:
1625 devm_kfree(ice_hw_to_dev(hw), s_rule);
1630 * ice_cfg_dflt_vsi - add filter rule to set/unset given VSI as default
1631 * VSI for the switch (represented by swid)
1632 * @hw: pointer to the hardware structure
1633 * @vsi_id: number of VSI to set as default
1634 * @set: true to add the above mentioned switch rule, false to remove it
1635 * @direction: ICE_FLTR_RX or ICE_FLTR_TX
1638 ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction)
1640 struct ice_aqc_sw_rules_elem *s_rule;
1641 struct ice_fltr_info f_info;
1642 enum ice_adminq_opc opcode;
1643 enum ice_status status;
1646 s_rule_size = set ? ICE_SW_RULE_RX_TX_ETH_HDR_SIZE :
1647 ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
1648 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
1650 return ICE_ERR_NO_MEMORY;
1652 memset(&f_info, 0, sizeof(f_info));
1654 f_info.lkup_type = ICE_SW_LKUP_DFLT;
1655 f_info.flag = direction;
1656 f_info.fltr_act = ICE_FWD_TO_VSI;
1657 f_info.fwd_id.vsi_id = vsi_id;
1659 if (f_info.flag & ICE_FLTR_RX) {
1660 f_info.src = hw->port_info->lport;
1662 f_info.fltr_rule_id =
1663 hw->port_info->dflt_rx_vsi_rule_id;
1664 } else if (f_info.flag & ICE_FLTR_TX) {
1665 f_info.src = vsi_id;
1667 f_info.fltr_rule_id =
1668 hw->port_info->dflt_tx_vsi_rule_id;
1672 opcode = ice_aqc_opc_add_sw_rules;
1674 opcode = ice_aqc_opc_remove_sw_rules;
1676 ice_fill_sw_rule(hw, &f_info, s_rule, opcode);
1678 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opcode, NULL);
1679 if (status || !(f_info.flag & ICE_FLTR_TX_RX))
1682 u16 index = le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
1684 if (f_info.flag & ICE_FLTR_TX) {
1685 hw->port_info->dflt_tx_vsi_num = vsi_id;
1686 hw->port_info->dflt_tx_vsi_rule_id = index;
1687 } else if (f_info.flag & ICE_FLTR_RX) {
1688 hw->port_info->dflt_rx_vsi_num = vsi_id;
1689 hw->port_info->dflt_rx_vsi_rule_id = index;
1692 if (f_info.flag & ICE_FLTR_TX) {
1693 hw->port_info->dflt_tx_vsi_num = ICE_DFLT_VSI_INVAL;
1694 hw->port_info->dflt_tx_vsi_rule_id = ICE_INVAL_ACT;
1695 } else if (f_info.flag & ICE_FLTR_RX) {
1696 hw->port_info->dflt_rx_vsi_num = ICE_DFLT_VSI_INVAL;
1697 hw->port_info->dflt_rx_vsi_rule_id = ICE_INVAL_ACT;
1702 devm_kfree(ice_hw_to_dev(hw), s_rule);
1707 * ice_remove_vlan_internal - Remove one VLAN based filter rule
1708 * @hw: pointer to the hardware structure
1709 * @f_entry: filter entry containing one VLAN information
1711 static enum ice_status
1712 ice_remove_vlan_internal(struct ice_hw *hw,
1713 struct ice_fltr_list_entry *f_entry)
1715 struct ice_fltr_info *new_fltr;
1716 struct ice_fltr_mgmt_list_entry *v_list_elem;
1719 new_fltr = &f_entry->fltr_info;
1721 v_list_elem = ice_find_vlan_entry(hw, new_fltr->l_data.vlan.vlan_id);
1723 return ICE_ERR_PARAM;
1725 vsi_id = f_entry->fltr_info.fwd_id.vsi_id;
1726 return ice_handle_rem_vsi_list_mgmt(hw, vsi_id, v_list_elem);
1730 * ice_remove_vlan - Remove VLAN based filter rule
1731 * @hw: pointer to the hardware structure
1732 * @v_list: list of VLAN entries and forwarding information
1735 ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list)
1737 struct ice_fltr_list_entry *v_list_itr;
1738 enum ice_status status = 0;
1741 return ICE_ERR_PARAM;
1743 list_for_each_entry(v_list_itr, v_list, list_entry) {
1744 status = ice_remove_vlan_internal(hw, v_list_itr);
1746 v_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1749 v_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1755 * ice_add_to_vsi_fltr_list - Add VSI filters to the list
1756 * @hw: pointer to the hardware structure
1757 * @vsi_id: ID of VSI to remove filters from
1758 * @lkup_list_head: pointer to the list that has certain lookup type filters
1759 * @vsi_list_head: pointer to the list pertaining to VSI with vsi_id
1761 static enum ice_status
1762 ice_add_to_vsi_fltr_list(struct ice_hw *hw, u16 vsi_id,
1763 struct list_head *lkup_list_head,
1764 struct list_head *vsi_list_head)
1766 struct ice_fltr_mgmt_list_entry *fm_entry;
1768 /* check to make sure VSI id is valid and within boundary */
1770 (sizeof(fm_entry->vsi_list_info->vsi_map) * BITS_PER_BYTE - 1))
1771 return ICE_ERR_PARAM;
1773 list_for_each_entry(fm_entry, lkup_list_head, list_entry) {
1774 struct ice_fltr_info *fi;
1776 fi = &fm_entry->fltr_info;
1777 if ((fi->fltr_act == ICE_FWD_TO_VSI &&
1778 fi->fwd_id.vsi_id == vsi_id) ||
1779 (fi->fltr_act == ICE_FWD_TO_VSI_LIST &&
1780 (test_bit(vsi_id, fm_entry->vsi_list_info->vsi_map)))) {
1781 struct ice_fltr_list_entry *tmp;
1783 /* this memory is freed up in the caller function
1784 * ice_remove_vsi_lkup_fltr() once filters for
1785 * this VSI are removed
1787 tmp = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*tmp),
1790 return ICE_ERR_NO_MEMORY;
1792 memcpy(&tmp->fltr_info, fi, sizeof(*fi));
1794 /* Expected below fields to be set to ICE_FWD_TO_VSI and
1795 * the particular VSI id since we are only removing this
1798 if (fi->fltr_act == ICE_FWD_TO_VSI_LIST) {
1799 tmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1800 tmp->fltr_info.fwd_id.vsi_id = vsi_id;
1803 list_add(&tmp->list_entry, vsi_list_head);
1810 * ice_remove_vsi_lkup_fltr - Remove lookup type filters for a VSI
1811 * @hw: pointer to the hardware structure
1812 * @vsi_id: ID of VSI to remove filters from
1813 * @lkup: switch rule filter lookup type
1816 ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_id,
1817 enum ice_sw_lkup_type lkup)
1819 struct ice_switch_info *sw = hw->switch_info;
1820 struct ice_fltr_list_entry *fm_entry;
1821 struct list_head remove_list_head;
1822 struct ice_fltr_list_entry *tmp;
1823 enum ice_status status;
1825 INIT_LIST_HEAD(&remove_list_head);
1827 case ICE_SW_LKUP_MAC:
1828 mutex_lock(&sw->mac_list_lock);
1829 status = ice_add_to_vsi_fltr_list(hw, vsi_id,
1832 mutex_unlock(&sw->mac_list_lock);
1834 ice_remove_mac(hw, &remove_list_head);
1835 goto free_fltr_list;
1838 case ICE_SW_LKUP_VLAN:
1839 mutex_lock(&sw->vlan_list_lock);
1840 status = ice_add_to_vsi_fltr_list(hw, vsi_id,
1841 &sw->vlan_list_head,
1843 mutex_unlock(&sw->vlan_list_lock);
1845 ice_remove_vlan(hw, &remove_list_head);
1846 goto free_fltr_list;
1849 case ICE_SW_LKUP_MAC_VLAN:
1850 case ICE_SW_LKUP_ETHERTYPE:
1851 case ICE_SW_LKUP_ETHERTYPE_MAC:
1852 case ICE_SW_LKUP_PROMISC:
1853 case ICE_SW_LKUP_PROMISC_VLAN:
1854 case ICE_SW_LKUP_DFLT:
1855 ice_debug(hw, ICE_DBG_SW,
1856 "Remove filters for this lookup type hasn't been implemented yet\n");
1862 list_for_each_entry_safe(fm_entry, tmp, &remove_list_head, list_entry) {
1863 list_del(&fm_entry->list_entry);
1864 devm_kfree(ice_hw_to_dev(hw), fm_entry);
1869 * ice_remove_vsi_fltr - Remove all filters for a VSI
1870 * @hw: pointer to the hardware structure
1871 * @vsi_id: ID of VSI to remove filters from
1873 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_id)
1875 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_MAC);
1876 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_MAC_VLAN);
1877 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_PROMISC);
1878 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_VLAN);
1879 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_DFLT);
1880 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_ETHERTYPE);
1881 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_ETHERTYPE_MAC);
1882 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_PROMISC_VLAN);