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];
473 if (opc == ice_aqc_opc_remove_sw_rules) {
474 s_rule->pdata.lkup_tx_rx.act = 0;
475 s_rule->pdata.lkup_tx_rx.index =
476 cpu_to_le16(f_info->fltr_rule_id);
477 s_rule->pdata.lkup_tx_rx.hdr_len = 0;
481 /* initialize the ether header with a dummy header */
482 memcpy(eth_hdr, dummy_eth_header, sizeof(dummy_eth_header));
483 ice_fill_sw_info(hw, f_info);
485 switch (f_info->fltr_act) {
487 act |= (f_info->fwd_id.vsi_id << ICE_SINGLE_ACT_VSI_ID_S) &
488 ICE_SINGLE_ACT_VSI_ID_M;
489 if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
490 act |= ICE_SINGLE_ACT_VSI_FORWARDING |
491 ICE_SINGLE_ACT_VALID_BIT;
493 case ICE_FWD_TO_VSI_LIST:
494 act |= ICE_SINGLE_ACT_VSI_LIST;
495 act |= (f_info->fwd_id.vsi_list_id <<
496 ICE_SINGLE_ACT_VSI_LIST_ID_S) &
497 ICE_SINGLE_ACT_VSI_LIST_ID_M;
498 if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
499 act |= ICE_SINGLE_ACT_VSI_FORWARDING |
500 ICE_SINGLE_ACT_VALID_BIT;
503 act |= ICE_SINGLE_ACT_TO_Q;
504 act |= (f_info->fwd_id.q_id << ICE_SINGLE_ACT_Q_INDEX_S) &
505 ICE_SINGLE_ACT_Q_INDEX_M;
507 case ICE_DROP_PACKET:
508 act |= ICE_SINGLE_ACT_VSI_FORWARDING | ICE_SINGLE_ACT_DROP |
509 ICE_SINGLE_ACT_VALID_BIT;
511 case ICE_FWD_TO_QGRP:
512 q_rgn = f_info->qgrp_size > 0 ?
513 (u8)ilog2(f_info->qgrp_size) : 0;
514 act |= ICE_SINGLE_ACT_TO_Q;
515 act |= (f_info->fwd_id.q_id << ICE_SINGLE_ACT_Q_INDEX_S) &
516 ICE_SINGLE_ACT_Q_INDEX_M;
517 act |= (q_rgn << ICE_SINGLE_ACT_Q_REGION_S) &
518 ICE_SINGLE_ACT_Q_REGION_M;
525 act |= ICE_SINGLE_ACT_LB_ENABLE;
527 act |= ICE_SINGLE_ACT_LAN_ENABLE;
529 switch (f_info->lkup_type) {
530 case ICE_SW_LKUP_MAC:
531 daddr = f_info->l_data.mac.mac_addr;
533 case ICE_SW_LKUP_VLAN:
534 vlan_id = f_info->l_data.vlan.vlan_id;
535 if (f_info->fltr_act == ICE_FWD_TO_VSI ||
536 f_info->fltr_act == ICE_FWD_TO_VSI_LIST) {
537 act |= ICE_SINGLE_ACT_PRUNE;
538 act |= ICE_SINGLE_ACT_EGRESS | ICE_SINGLE_ACT_INGRESS;
541 case ICE_SW_LKUP_ETHERTYPE_MAC:
542 daddr = f_info->l_data.ethertype_mac.mac_addr;
544 case ICE_SW_LKUP_ETHERTYPE:
545 off = (__be16 *)ð_hdr[ICE_ETH_ETHTYPE_OFFSET];
546 *off = cpu_to_be16(f_info->l_data.ethertype_mac.ethertype);
548 case ICE_SW_LKUP_MAC_VLAN:
549 daddr = f_info->l_data.mac_vlan.mac_addr;
550 vlan_id = f_info->l_data.mac_vlan.vlan_id;
552 case ICE_SW_LKUP_PROMISC_VLAN:
553 vlan_id = f_info->l_data.mac_vlan.vlan_id;
555 case ICE_SW_LKUP_PROMISC:
556 daddr = f_info->l_data.mac_vlan.mac_addr;
562 s_rule->type = (f_info->flag & ICE_FLTR_RX) ?
563 cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX) :
564 cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_TX);
566 /* Recipe set depending on lookup type */
567 s_rule->pdata.lkup_tx_rx.recipe_id = cpu_to_le16(f_info->lkup_type);
568 s_rule->pdata.lkup_tx_rx.src = cpu_to_le16(f_info->src);
569 s_rule->pdata.lkup_tx_rx.act = cpu_to_le32(act);
572 ether_addr_copy(ð_hdr[ICE_ETH_DA_OFFSET], daddr);
574 if (!(vlan_id > ICE_MAX_VLAN_ID)) {
575 off = (__be16 *)ð_hdr[ICE_ETH_VLAN_TCI_OFFSET];
576 *off = cpu_to_be16(vlan_id);
579 /* Create the switch rule with the final dummy Ethernet header */
580 if (opc != ice_aqc_opc_update_sw_rules)
581 s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(sizeof(eth_hdr));
583 memcpy(s_rule->pdata.lkup_tx_rx.hdr, eth_hdr, sizeof(eth_hdr));
588 * @hw: pointer to the hardware structure
589 * @m_ent: the management entry for which sw marker needs to be added
590 * @sw_marker: sw marker to tag the Rx descriptor with
591 * @l_id: large action resource id
593 * Create a large action to hold software marker and update the switch rule
594 * entry pointed by m_ent with newly created large action
596 static enum ice_status
597 ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
598 u16 sw_marker, u16 l_id)
600 struct ice_aqc_sw_rules_elem *lg_act, *rx_tx;
601 /* For software marker we need 3 large actions
602 * 1. FWD action: FWD TO VSI or VSI LIST
603 * 2. GENERIC VALUE action to hold the profile id
604 * 3. GENERIC VALUE action to hold the software marker id
606 const u16 num_lg_acts = 3;
607 enum ice_status status;
613 if (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
614 return ICE_ERR_PARAM;
616 /* Create two back-to-back switch rules and submit them to the HW using
621 lg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_lg_acts);
622 rules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
623 lg_act = devm_kzalloc(ice_hw_to_dev(hw), rules_size, GFP_KERNEL);
625 return ICE_ERR_NO_MEMORY;
627 rx_tx = (struct ice_aqc_sw_rules_elem *)((u8 *)lg_act + lg_act_size);
629 /* Fill in the first switch rule i.e. large action */
630 lg_act->type = cpu_to_le16(ICE_AQC_SW_RULES_T_LG_ACT);
631 lg_act->pdata.lg_act.index = cpu_to_le16(l_id);
632 lg_act->pdata.lg_act.size = cpu_to_le16(num_lg_acts);
634 /* First action VSI forwarding or VSI list forwarding depending on how
637 vsi_info = (m_ent->vsi_count > 1) ?
638 m_ent->fltr_info.fwd_id.vsi_list_id :
639 m_ent->fltr_info.fwd_id.vsi_id;
641 act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
642 act |= (vsi_info << ICE_LG_ACT_VSI_LIST_ID_S) &
643 ICE_LG_ACT_VSI_LIST_ID_M;
644 if (m_ent->vsi_count > 1)
645 act |= ICE_LG_ACT_VSI_LIST;
646 lg_act->pdata.lg_act.act[0] = cpu_to_le32(act);
648 /* Second action descriptor type */
649 act = ICE_LG_ACT_GENERIC;
651 act |= (1 << ICE_LG_ACT_GENERIC_VALUE_S) & ICE_LG_ACT_GENERIC_VALUE_M;
652 lg_act->pdata.lg_act.act[1] = cpu_to_le32(act);
654 act = (ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX <<
655 ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_OFFSET_M;
657 /* Third action Marker value */
658 act |= ICE_LG_ACT_GENERIC;
659 act |= (sw_marker << ICE_LG_ACT_GENERIC_VALUE_S) &
660 ICE_LG_ACT_GENERIC_VALUE_M;
662 lg_act->pdata.lg_act.act[2] = cpu_to_le32(act);
664 /* call the fill switch rule to fill the lookup tx rx structure */
665 ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,
666 ice_aqc_opc_update_sw_rules);
668 /* Update the action to point to the large action id */
669 rx_tx->pdata.lkup_tx_rx.act =
670 cpu_to_le32(ICE_SINGLE_ACT_PTR |
671 ((l_id << ICE_SINGLE_ACT_PTR_VAL_S) &
672 ICE_SINGLE_ACT_PTR_VAL_M));
674 /* Use the filter rule id of the previously created rule with single
675 * act. Once the update happens, hardware will treat this as large
678 rx_tx->pdata.lkup_tx_rx.index =
679 cpu_to_le16(m_ent->fltr_info.fltr_rule_id);
681 status = ice_aq_sw_rules(hw, lg_act, rules_size, 2,
682 ice_aqc_opc_update_sw_rules, NULL);
684 m_ent->lg_act_idx = l_id;
685 m_ent->sw_marker_id = sw_marker;
688 devm_kfree(ice_hw_to_dev(hw), lg_act);
693 * ice_create_vsi_list_map
694 * @hw: pointer to the hardware structure
695 * @vsi_array: array of VSIs to form a VSI list
696 * @num_vsi: num VSI in the array
697 * @vsi_list_id: VSI list id generated as part of allocate resource
699 * Helper function to create a new entry of VSI list id to VSI mapping
700 * using the given VSI list id
702 static struct ice_vsi_list_map_info *
703 ice_create_vsi_list_map(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
706 struct ice_switch_info *sw = hw->switch_info;
707 struct ice_vsi_list_map_info *v_map;
710 v_map = devm_kcalloc(ice_hw_to_dev(hw), 1, sizeof(*v_map), GFP_KERNEL);
714 v_map->vsi_list_id = vsi_list_id;
716 for (i = 0; i < num_vsi; i++)
717 set_bit(vsi_array[i], v_map->vsi_map);
719 list_add(&v_map->list_entry, &sw->vsi_list_map_head);
724 * ice_update_vsi_list_rule
725 * @hw: pointer to the hardware structure
726 * @vsi_array: array of VSIs to form a VSI list
727 * @num_vsi: num VSI in the array
728 * @vsi_list_id: VSI list id generated as part of allocate resource
729 * @remove: Boolean value to indicate if this is a remove action
730 * @opc: switch rules population command type - pass in the command opcode
731 * @lkup_type: lookup type of the filter
733 * Call AQ command to add a new switch rule or update existing switch rule
734 * using the given VSI list id
736 static enum ice_status
737 ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
738 u16 vsi_list_id, bool remove, enum ice_adminq_opc opc,
739 enum ice_sw_lkup_type lkup_type)
741 struct ice_aqc_sw_rules_elem *s_rule;
742 enum ice_status status;
748 return ICE_ERR_PARAM;
750 if (lkup_type == ICE_SW_LKUP_MAC ||
751 lkup_type == ICE_SW_LKUP_MAC_VLAN ||
752 lkup_type == ICE_SW_LKUP_ETHERTYPE ||
753 lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
754 lkup_type == ICE_SW_LKUP_PROMISC ||
755 lkup_type == ICE_SW_LKUP_PROMISC_VLAN)
756 type = remove ? ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR :
757 ICE_AQC_SW_RULES_T_VSI_LIST_SET;
758 else if (lkup_type == ICE_SW_LKUP_VLAN)
759 type = remove ? ICE_AQC_SW_RULES_T_PRUNE_LIST_CLEAR :
760 ICE_AQC_SW_RULES_T_PRUNE_LIST_SET;
762 return ICE_ERR_PARAM;
764 s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(num_vsi);
765 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
767 return ICE_ERR_NO_MEMORY;
769 for (i = 0; i < num_vsi; i++)
770 s_rule->pdata.vsi_list.vsi[i] = cpu_to_le16(vsi_array[i]);
772 s_rule->type = cpu_to_le16(type);
773 s_rule->pdata.vsi_list.number_vsi = cpu_to_le16(num_vsi);
774 s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
776 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opc, NULL);
778 devm_kfree(ice_hw_to_dev(hw), s_rule);
783 * ice_create_vsi_list_rule - Creates and populates a VSI list rule
784 * @hw: pointer to the hw struct
785 * @vsi_array: array of VSIs to form a VSI list
786 * @num_vsi: number of VSIs in the array
787 * @vsi_list_id: stores the ID of the VSI list to be created
788 * @lkup_type: switch rule filter's lookup type
790 static enum ice_status
791 ice_create_vsi_list_rule(struct ice_hw *hw, u16 *vsi_array, u16 num_vsi,
792 u16 *vsi_list_id, enum ice_sw_lkup_type lkup_type)
794 enum ice_status status;
797 for (i = 0; i < num_vsi; i++)
798 if (vsi_array[i] >= ICE_MAX_VSI)
799 return ICE_ERR_OUT_OF_RANGE;
801 status = ice_aq_alloc_free_vsi_list(hw, vsi_list_id, lkup_type,
802 ice_aqc_opc_alloc_res);
806 /* Update the newly created VSI list to include the specified VSIs */
807 return ice_update_vsi_list_rule(hw, vsi_array, num_vsi, *vsi_list_id,
808 false, ice_aqc_opc_add_sw_rules,
813 * ice_create_pkt_fwd_rule
814 * @hw: pointer to the hardware structure
815 * @f_entry: entry containing packet forwarding information
817 * Create switch rule with given filter information and add an entry
818 * to the corresponding filter management list to track this switch rule
821 static enum ice_status
822 ice_create_pkt_fwd_rule(struct ice_hw *hw,
823 struct ice_fltr_list_entry *f_entry)
825 struct ice_switch_info *sw = hw->switch_info;
826 struct ice_fltr_mgmt_list_entry *fm_entry;
827 struct ice_aqc_sw_rules_elem *s_rule;
828 enum ice_sw_lkup_type l_type;
829 enum ice_status status;
831 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
832 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
834 return ICE_ERR_NO_MEMORY;
835 fm_entry = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*fm_entry),
838 status = ICE_ERR_NO_MEMORY;
839 goto ice_create_pkt_fwd_rule_exit;
842 fm_entry->fltr_info = f_entry->fltr_info;
844 /* Initialize all the fields for the management entry */
845 fm_entry->vsi_count = 1;
846 fm_entry->lg_act_idx = ICE_INVAL_LG_ACT_INDEX;
847 fm_entry->sw_marker_id = ICE_INVAL_SW_MARKER_ID;
848 fm_entry->counter_index = ICE_INVAL_COUNTER_ID;
850 ice_fill_sw_rule(hw, &fm_entry->fltr_info, s_rule,
851 ice_aqc_opc_add_sw_rules);
853 status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
854 ice_aqc_opc_add_sw_rules, NULL);
856 devm_kfree(ice_hw_to_dev(hw), fm_entry);
857 goto ice_create_pkt_fwd_rule_exit;
860 f_entry->fltr_info.fltr_rule_id =
861 le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
862 fm_entry->fltr_info.fltr_rule_id =
863 le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
865 /* The book keeping entries will get removed when base driver
866 * calls remove filter AQ command
868 l_type = fm_entry->fltr_info.lkup_type;
869 if (l_type == ICE_SW_LKUP_MAC) {
870 mutex_lock(&sw->mac_list_lock);
871 list_add(&fm_entry->list_entry, &sw->mac_list_head);
872 mutex_unlock(&sw->mac_list_lock);
873 } else if (l_type == ICE_SW_LKUP_VLAN) {
874 mutex_lock(&sw->vlan_list_lock);
875 list_add(&fm_entry->list_entry, &sw->vlan_list_head);
876 mutex_unlock(&sw->vlan_list_lock);
877 } else if (l_type == ICE_SW_LKUP_ETHERTYPE ||
878 l_type == ICE_SW_LKUP_ETHERTYPE_MAC) {
879 mutex_lock(&sw->eth_m_list_lock);
880 list_add(&fm_entry->list_entry, &sw->eth_m_list_head);
881 mutex_unlock(&sw->eth_m_list_lock);
882 } else if (l_type == ICE_SW_LKUP_PROMISC ||
883 l_type == ICE_SW_LKUP_PROMISC_VLAN) {
884 mutex_lock(&sw->promisc_list_lock);
885 list_add(&fm_entry->list_entry, &sw->promisc_list_head);
886 mutex_unlock(&sw->promisc_list_lock);
887 } else if (fm_entry->fltr_info.lkup_type == ICE_SW_LKUP_MAC_VLAN) {
888 mutex_lock(&sw->mac_vlan_list_lock);
889 list_add(&fm_entry->list_entry, &sw->mac_vlan_list_head);
890 mutex_unlock(&sw->mac_vlan_list_lock);
892 status = ICE_ERR_NOT_IMPL;
894 ice_create_pkt_fwd_rule_exit:
895 devm_kfree(ice_hw_to_dev(hw), s_rule);
900 * ice_update_pkt_fwd_rule
901 * @hw: pointer to the hardware structure
902 * @rule_id: rule of previously created switch rule to update
903 * @vsi_list_id: VSI list id to be updated with
904 * @f_info: ice_fltr_info to pull other information for switch rule
906 * Call AQ command to update a previously created switch rule with a
909 static enum ice_status
910 ice_update_pkt_fwd_rule(struct ice_hw *hw, u16 rule_id, u16 vsi_list_id,
911 struct ice_fltr_info f_info)
913 struct ice_aqc_sw_rules_elem *s_rule;
914 struct ice_fltr_info tmp_fltr;
915 enum ice_status status;
917 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
918 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
920 return ICE_ERR_NO_MEMORY;
923 tmp_fltr.fltr_act = ICE_FWD_TO_VSI_LIST;
924 tmp_fltr.fwd_id.vsi_list_id = vsi_list_id;
926 ice_fill_sw_rule(hw, &tmp_fltr, s_rule,
927 ice_aqc_opc_update_sw_rules);
929 s_rule->pdata.lkup_tx_rx.index = cpu_to_le16(rule_id);
931 /* Update switch rule with new rule set to forward VSI list */
932 status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
933 ice_aqc_opc_update_sw_rules, NULL);
935 devm_kfree(ice_hw_to_dev(hw), s_rule);
940 * ice_handle_vsi_list_mgmt
941 * @hw: pointer to the hardware structure
942 * @m_entry: pointer to current filter management list entry
943 * @cur_fltr: filter information from the book keeping entry
944 * @new_fltr: filter information with the new VSI to be added
946 * Call AQ command to add or update previously created VSI list with new VSI.
948 * Helper function to do book keeping associated with adding filter information
949 * The algorithm to do the booking keeping is described below :
950 * When a VSI needs to subscribe to a given filter( MAC/VLAN/Ethtype etc.)
951 * if only one VSI has been added till now
952 * Allocate a new VSI list and add two VSIs
953 * to this list using switch rule command
954 * Update the previously created switch rule with the
955 * newly created VSI list id
956 * if a VSI list was previously created
957 * Add the new VSI to the previously created VSI list set
958 * using the update switch rule command
960 static enum ice_status
961 ice_handle_vsi_list_mgmt(struct ice_hw *hw,
962 struct ice_fltr_mgmt_list_entry *m_entry,
963 struct ice_fltr_info *cur_fltr,
964 struct ice_fltr_info *new_fltr)
966 enum ice_status status = 0;
969 if ((cur_fltr->fltr_act == ICE_FWD_TO_Q ||
970 cur_fltr->fltr_act == ICE_FWD_TO_QGRP))
971 return ICE_ERR_NOT_IMPL;
973 if ((new_fltr->fltr_act == ICE_FWD_TO_Q ||
974 new_fltr->fltr_act == ICE_FWD_TO_QGRP) &&
975 (cur_fltr->fltr_act == ICE_FWD_TO_VSI ||
976 cur_fltr->fltr_act == ICE_FWD_TO_VSI_LIST))
977 return ICE_ERR_NOT_IMPL;
979 if (m_entry->vsi_count < 2 && !m_entry->vsi_list_info) {
980 /* Only one entry existed in the mapping and it was not already
981 * a part of a VSI list. So, create a VSI list with the old and
987 /* A rule already exists with the new VSI being added */
988 if (cur_fltr->fwd_id.vsi_id == new_fltr->fwd_id.vsi_id)
989 return ICE_ERR_ALREADY_EXISTS;
991 vsi_id_arr[0] = cur_fltr->fwd_id.vsi_id;
992 vsi_id_arr[1] = new_fltr->fwd_id.vsi_id;
993 status = ice_create_vsi_list_rule(hw, &vsi_id_arr[0], 2,
995 new_fltr->lkup_type);
999 fltr_rule = cur_fltr->fltr_rule_id;
1000 /* Update the previous switch rule of "MAC forward to VSI" to
1001 * "MAC fwd to VSI list"
1003 status = ice_update_pkt_fwd_rule(hw, fltr_rule, vsi_list_id,
1008 cur_fltr->fwd_id.vsi_list_id = vsi_list_id;
1009 cur_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
1010 m_entry->vsi_list_info =
1011 ice_create_vsi_list_map(hw, &vsi_id_arr[0], 2,
1014 /* If this entry was large action then the large action needs
1015 * to be updated to point to FWD to VSI list
1017 if (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID)
1019 ice_add_marker_act(hw, m_entry,
1020 m_entry->sw_marker_id,
1021 m_entry->lg_act_idx);
1023 u16 vsi_id = new_fltr->fwd_id.vsi_id;
1024 enum ice_adminq_opc opcode;
1026 if (!m_entry->vsi_list_info)
1029 /* A rule already exists with the new VSI being added */
1030 if (test_bit(vsi_id, m_entry->vsi_list_info->vsi_map))
1033 /* Update the previously created VSI list set with
1034 * the new VSI id passed in
1036 vsi_list_id = cur_fltr->fwd_id.vsi_list_id;
1037 opcode = ice_aqc_opc_update_sw_rules;
1039 status = ice_update_vsi_list_rule(hw, &vsi_id, 1, vsi_list_id,
1041 new_fltr->lkup_type);
1042 /* update VSI list mapping info with new VSI id */
1044 set_bit(vsi_id, m_entry->vsi_list_info->vsi_map);
1047 m_entry->vsi_count++;
1052 * ice_find_mac_entry
1053 * @hw: pointer to the hardware structure
1054 * @mac_addr: MAC address to search for
1056 * Helper function to search for a MAC entry using a given MAC address
1057 * Returns pointer to the entry if found.
1059 static struct ice_fltr_mgmt_list_entry *
1060 ice_find_mac_entry(struct ice_hw *hw, u8 *mac_addr)
1062 struct ice_fltr_mgmt_list_entry *m_list_itr, *mac_ret = NULL;
1063 struct ice_switch_info *sw = hw->switch_info;
1065 mutex_lock(&sw->mac_list_lock);
1066 list_for_each_entry(m_list_itr, &sw->mac_list_head, list_entry) {
1067 u8 *buf = &m_list_itr->fltr_info.l_data.mac.mac_addr[0];
1069 if (ether_addr_equal(buf, mac_addr)) {
1070 mac_ret = m_list_itr;
1074 mutex_unlock(&sw->mac_list_lock);
1079 * ice_add_shared_mac - Add one MAC shared filter rule
1080 * @hw: pointer to the hardware structure
1081 * @f_entry: structure containing MAC forwarding information
1083 * Adds or updates the book keeping list for the MAC addresses
1085 static enum ice_status
1086 ice_add_shared_mac(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1088 struct ice_fltr_info *new_fltr, *cur_fltr;
1089 struct ice_fltr_mgmt_list_entry *m_entry;
1091 new_fltr = &f_entry->fltr_info;
1093 m_entry = ice_find_mac_entry(hw, &new_fltr->l_data.mac.mac_addr[0]);
1095 return ice_create_pkt_fwd_rule(hw, f_entry);
1097 cur_fltr = &m_entry->fltr_info;
1099 return ice_handle_vsi_list_mgmt(hw, m_entry, cur_fltr, new_fltr);
1103 * ice_add_mac - Add a MAC address based filter rule
1104 * @hw: pointer to the hardware structure
1105 * @m_list: list of MAC addresses and forwarding information
1107 * IMPORTANT: When the ucast_shared flag is set to false and m_list has
1108 * multiple unicast addresses, the function assumes that all the
1109 * addresses are unique in a given add_mac call. It doesn't
1110 * check for duplicates in this case, removing duplicates from a given
1111 * list should be taken care of in the caller of this function.
1114 ice_add_mac(struct ice_hw *hw, struct list_head *m_list)
1116 struct ice_aqc_sw_rules_elem *s_rule, *r_iter;
1117 struct ice_fltr_list_entry *m_list_itr;
1118 u16 elem_sent, total_elem_left;
1119 enum ice_status status = 0;
1120 u16 num_unicast = 0;
1124 return ICE_ERR_PARAM;
1126 list_for_each_entry(m_list_itr, m_list, list_entry) {
1127 u8 *add = &m_list_itr->fltr_info.l_data.mac.mac_addr[0];
1129 if (m_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
1130 return ICE_ERR_PARAM;
1131 if (is_zero_ether_addr(add))
1132 return ICE_ERR_PARAM;
1133 if (is_unicast_ether_addr(add) && !hw->ucast_shared) {
1134 /* Don't overwrite the unicast address */
1135 if (ice_find_mac_entry(hw, add))
1136 return ICE_ERR_ALREADY_EXISTS;
1138 } else if (is_multicast_ether_addr(add) ||
1139 (is_unicast_ether_addr(add) && hw->ucast_shared)) {
1140 status = ice_add_shared_mac(hw, m_list_itr);
1142 m_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1145 m_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1149 /* Exit if no suitable entries were found for adding bulk switch rule */
1153 /* Allocate switch rule buffer for the bulk update for unicast */
1154 s_rule_size = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
1155 s_rule = devm_kcalloc(ice_hw_to_dev(hw), num_unicast, s_rule_size,
1158 return ICE_ERR_NO_MEMORY;
1161 list_for_each_entry(m_list_itr, m_list, list_entry) {
1162 struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
1163 u8 *addr = &f_info->l_data.mac.mac_addr[0];
1165 if (is_unicast_ether_addr(addr)) {
1166 ice_fill_sw_rule(hw, &m_list_itr->fltr_info,
1167 r_iter, ice_aqc_opc_add_sw_rules);
1168 r_iter = (struct ice_aqc_sw_rules_elem *)
1169 ((u8 *)r_iter + s_rule_size);
1173 /* Call AQ bulk switch rule update for all unicast addresses */
1175 /* Call AQ switch rule in AQ_MAX chunk */
1176 for (total_elem_left = num_unicast; total_elem_left > 0;
1177 total_elem_left -= elem_sent) {
1178 struct ice_aqc_sw_rules_elem *entry = r_iter;
1180 elem_sent = min(total_elem_left,
1181 (u16)(ICE_AQ_MAX_BUF_LEN / s_rule_size));
1182 status = ice_aq_sw_rules(hw, entry, elem_sent * s_rule_size,
1183 elem_sent, ice_aqc_opc_add_sw_rules,
1186 goto ice_add_mac_exit;
1187 r_iter = (struct ice_aqc_sw_rules_elem *)
1188 ((u8 *)r_iter + (elem_sent * s_rule_size));
1191 /* Fill up rule id based on the value returned from FW */
1193 list_for_each_entry(m_list_itr, m_list, list_entry) {
1194 struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
1195 u8 *addr = &f_info->l_data.mac.mac_addr[0];
1196 struct ice_switch_info *sw = hw->switch_info;
1197 struct ice_fltr_mgmt_list_entry *fm_entry;
1199 if (is_unicast_ether_addr(addr)) {
1200 f_info->fltr_rule_id =
1201 le16_to_cpu(r_iter->pdata.lkup_tx_rx.index);
1202 f_info->fltr_act = ICE_FWD_TO_VSI;
1203 /* Create an entry to track this MAC address */
1204 fm_entry = devm_kzalloc(ice_hw_to_dev(hw),
1205 sizeof(*fm_entry), GFP_KERNEL);
1207 status = ICE_ERR_NO_MEMORY;
1208 goto ice_add_mac_exit;
1210 fm_entry->fltr_info = *f_info;
1211 fm_entry->vsi_count = 1;
1212 /* The book keeping entries will get removed when
1213 * base driver calls remove filter AQ command
1215 mutex_lock(&sw->mac_list_lock);
1216 list_add(&fm_entry->list_entry, &sw->mac_list_head);
1217 mutex_unlock(&sw->mac_list_lock);
1219 r_iter = (struct ice_aqc_sw_rules_elem *)
1220 ((u8 *)r_iter + s_rule_size);
1225 devm_kfree(ice_hw_to_dev(hw), s_rule);
1230 * ice_find_vlan_entry
1231 * @hw: pointer to the hardware structure
1232 * @vlan_id: VLAN id to search for
1234 * Helper function to search for a VLAN entry using a given VLAN id
1235 * Returns pointer to the entry if found.
1237 static struct ice_fltr_mgmt_list_entry *
1238 ice_find_vlan_entry(struct ice_hw *hw, u16 vlan_id)
1240 struct ice_fltr_mgmt_list_entry *vlan_list_itr, *vlan_ret = NULL;
1241 struct ice_switch_info *sw = hw->switch_info;
1243 mutex_lock(&sw->vlan_list_lock);
1244 list_for_each_entry(vlan_list_itr, &sw->vlan_list_head, list_entry)
1245 if (vlan_list_itr->fltr_info.l_data.vlan.vlan_id == vlan_id) {
1246 vlan_ret = vlan_list_itr;
1250 mutex_unlock(&sw->vlan_list_lock);
1255 * ice_add_vlan_internal - Add one VLAN based filter rule
1256 * @hw: pointer to the hardware structure
1257 * @f_entry: filter entry containing one VLAN information
1259 static enum ice_status
1260 ice_add_vlan_internal(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1262 struct ice_fltr_info *new_fltr, *cur_fltr;
1263 struct ice_fltr_mgmt_list_entry *v_list_itr;
1266 new_fltr = &f_entry->fltr_info;
1267 /* VLAN id should only be 12 bits */
1268 if (new_fltr->l_data.vlan.vlan_id > ICE_MAX_VLAN_ID)
1269 return ICE_ERR_PARAM;
1271 vlan_id = new_fltr->l_data.vlan.vlan_id;
1272 v_list_itr = ice_find_vlan_entry(hw, vlan_id);
1274 u16 vsi_id = ICE_VSI_INVAL_ID;
1275 enum ice_status status;
1276 u16 vsi_list_id = 0;
1278 if (new_fltr->fltr_act == ICE_FWD_TO_VSI) {
1279 enum ice_sw_lkup_type lkup_type = new_fltr->lkup_type;
1281 /* All VLAN pruning rules use a VSI list.
1282 * Convert the action to forwarding to a VSI list.
1284 vsi_id = new_fltr->fwd_id.vsi_id;
1285 status = ice_create_vsi_list_rule(hw, &vsi_id, 1,
1290 new_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
1291 new_fltr->fwd_id.vsi_list_id = vsi_list_id;
1294 status = ice_create_pkt_fwd_rule(hw, f_entry);
1295 if (!status && vsi_id != ICE_VSI_INVAL_ID) {
1296 v_list_itr = ice_find_vlan_entry(hw, vlan_id);
1298 return ICE_ERR_DOES_NOT_EXIST;
1299 v_list_itr->vsi_list_info =
1300 ice_create_vsi_list_map(hw, &vsi_id, 1,
1307 cur_fltr = &v_list_itr->fltr_info;
1308 return ice_handle_vsi_list_mgmt(hw, v_list_itr, cur_fltr, new_fltr);
1312 * ice_add_vlan - Add VLAN based filter rule
1313 * @hw: pointer to the hardware structure
1314 * @v_list: list of VLAN entries and forwarding information
1317 ice_add_vlan(struct ice_hw *hw, struct list_head *v_list)
1319 struct ice_fltr_list_entry *v_list_itr;
1322 return ICE_ERR_PARAM;
1324 list_for_each_entry(v_list_itr, v_list, list_entry) {
1325 enum ice_status status;
1327 if (v_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_VLAN)
1328 return ICE_ERR_PARAM;
1330 status = ice_add_vlan_internal(hw, v_list_itr);
1332 v_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1335 v_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1341 * ice_remove_vsi_list_rule
1342 * @hw: pointer to the hardware structure
1343 * @vsi_list_id: VSI list id generated as part of allocate resource
1344 * @lkup_type: switch rule filter lookup type
1346 static enum ice_status
1347 ice_remove_vsi_list_rule(struct ice_hw *hw, u16 vsi_list_id,
1348 enum ice_sw_lkup_type lkup_type)
1350 struct ice_aqc_sw_rules_elem *s_rule;
1351 enum ice_status status;
1354 s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(0);
1355 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
1357 return ICE_ERR_NO_MEMORY;
1359 s_rule->type = cpu_to_le16(ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR);
1360 s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
1361 /* FW expects number of VSIs in vsi_list resource to be 0 for clear
1362 * command. Since memory is zero'ed out during initialization, it's not
1363 * necessary to explicitly initialize the variable to 0.
1366 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1,
1367 ice_aqc_opc_remove_sw_rules, NULL);
1369 /* Free the vsi_list resource that we allocated */
1370 status = ice_aq_alloc_free_vsi_list(hw, &vsi_list_id, lkup_type,
1371 ice_aqc_opc_free_res);
1373 devm_kfree(ice_hw_to_dev(hw), s_rule);
1378 * ice_handle_rem_vsi_list_mgmt
1379 * @hw: pointer to the hardware structure
1380 * @vsi_id: ID of the VSI to remove
1381 * @fm_list_itr: filter management entry for which the VSI list management
1384 static enum ice_status
1385 ice_handle_rem_vsi_list_mgmt(struct ice_hw *hw, u16 vsi_id,
1386 struct ice_fltr_mgmt_list_entry *fm_list_itr)
1388 struct ice_switch_info *sw = hw->switch_info;
1389 enum ice_status status = 0;
1390 enum ice_sw_lkup_type lkup_type;
1391 bool is_last_elem = true;
1392 bool conv_list = false;
1393 bool del_list = false;
1396 lkup_type = fm_list_itr->fltr_info.lkup_type;
1397 vsi_list_id = fm_list_itr->fltr_info.fwd_id.vsi_list_id;
1399 if (fm_list_itr->vsi_count > 1) {
1400 status = ice_update_vsi_list_rule(hw, &vsi_id, 1, vsi_list_id,
1402 ice_aqc_opc_update_sw_rules,
1406 fm_list_itr->vsi_count--;
1407 is_last_elem = false;
1408 clear_bit(vsi_id, fm_list_itr->vsi_list_info->vsi_map);
1411 /* For non-VLAN rules that forward packets to a VSI list, convert them
1412 * to forwarding packets to a VSI if there is only one VSI left in the
1413 * list. Unused lists are then removed.
1414 * VLAN rules need to use VSI lists even with only one VSI.
1416 if (fm_list_itr->fltr_info.fltr_act == ICE_FWD_TO_VSI_LIST) {
1417 if (lkup_type == ICE_SW_LKUP_VLAN) {
1418 del_list = is_last_elem;
1419 } else if (fm_list_itr->vsi_count == 1) {
1426 /* Remove the VSI list since it is no longer used */
1427 struct ice_vsi_list_map_info *vsi_list_info =
1428 fm_list_itr->vsi_list_info;
1430 status = ice_remove_vsi_list_rule(hw, vsi_list_id, lkup_type);
1437 rem_vsi_id = find_first_bit(vsi_list_info->vsi_map,
1440 /* Error out when the expected last element is not in
1443 if (rem_vsi_id == ICE_MAX_VSI)
1444 return ICE_ERR_OUT_OF_RANGE;
1446 /* Change the list entry action from VSI_LIST to VSI */
1447 fm_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1448 fm_list_itr->fltr_info.fwd_id.vsi_id = rem_vsi_id;
1451 list_del(&vsi_list_info->list_entry);
1452 devm_kfree(ice_hw_to_dev(hw), vsi_list_info);
1453 fm_list_itr->vsi_list_info = NULL;
1457 /* Convert the rule's forward action to forwarding packets to
1460 struct ice_aqc_sw_rules_elem *s_rule;
1462 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
1463 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE,
1466 return ICE_ERR_NO_MEMORY;
1468 ice_fill_sw_rule(hw, &fm_list_itr->fltr_info, s_rule,
1469 ice_aqc_opc_update_sw_rules);
1471 s_rule->pdata.lkup_tx_rx.index =
1472 cpu_to_le16(fm_list_itr->fltr_info.fltr_rule_id);
1474 status = ice_aq_sw_rules(hw, s_rule,
1475 ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
1476 ice_aqc_opc_update_sw_rules, NULL);
1477 devm_kfree(ice_hw_to_dev(hw), s_rule);
1483 /* Remove the lookup rule */
1484 struct ice_aqc_sw_rules_elem *s_rule;
1486 s_rule = devm_kzalloc(ice_hw_to_dev(hw),
1487 ICE_SW_RULE_RX_TX_NO_HDR_SIZE,
1490 return ICE_ERR_NO_MEMORY;
1492 ice_fill_sw_rule(hw, &fm_list_itr->fltr_info, s_rule,
1493 ice_aqc_opc_remove_sw_rules);
1495 status = ice_aq_sw_rules(hw, s_rule,
1496 ICE_SW_RULE_RX_TX_NO_HDR_SIZE, 1,
1497 ice_aqc_opc_remove_sw_rules, NULL);
1501 /* Remove a book keeping entry from the MAC address list */
1502 mutex_lock(&sw->mac_list_lock);
1503 list_del(&fm_list_itr->list_entry);
1504 mutex_unlock(&sw->mac_list_lock);
1505 devm_kfree(ice_hw_to_dev(hw), fm_list_itr);
1506 devm_kfree(ice_hw_to_dev(hw), s_rule);
1512 * ice_remove_mac_entry
1513 * @hw: pointer to the hardware structure
1514 * @f_entry: structure containing MAC forwarding information
1516 static enum ice_status
1517 ice_remove_mac_entry(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
1519 struct ice_fltr_mgmt_list_entry *m_entry;
1523 add = &f_entry->fltr_info.l_data.mac.mac_addr[0];
1525 m_entry = ice_find_mac_entry(hw, add);
1527 return ICE_ERR_PARAM;
1529 vsi_id = f_entry->fltr_info.fwd_id.vsi_id;
1530 return ice_handle_rem_vsi_list_mgmt(hw, vsi_id, m_entry);
1534 * ice_remove_mac - remove a MAC address based filter rule
1535 * @hw: pointer to the hardware structure
1536 * @m_list: list of MAC addresses and forwarding information
1538 * This function removes either a MAC filter rule or a specific VSI from a
1539 * VSI list for a multicast MAC address.
1541 * Returns ICE_ERR_DOES_NOT_EXIST if a given entry was not added by
1542 * ice_add_mac. Caller should be aware that this call will only work if all
1543 * the entries passed into m_list were added previously. It will not attempt to
1544 * do a partial remove of entries that were found.
1547 ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)
1549 struct ice_aqc_sw_rules_elem *s_rule, *r_iter;
1550 u8 s_rule_size = ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
1551 struct ice_switch_info *sw = hw->switch_info;
1552 struct ice_fltr_mgmt_list_entry *m_entry;
1553 struct ice_fltr_list_entry *m_list_itr;
1554 u16 elem_sent, total_elem_left;
1555 enum ice_status status = 0;
1556 u16 num_unicast = 0;
1559 return ICE_ERR_PARAM;
1561 list_for_each_entry(m_list_itr, m_list, list_entry) {
1562 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1564 if (is_unicast_ether_addr(addr) && !hw->ucast_shared)
1566 else if (is_multicast_ether_addr(addr) ||
1567 (is_unicast_ether_addr(addr) && hw->ucast_shared))
1568 ice_remove_mac_entry(hw, m_list_itr);
1571 /* Exit if no unicast addresses found. Multicast switch rules
1572 * were added individually
1577 /* Allocate switch rule buffer for the bulk update for unicast */
1578 s_rule = devm_kcalloc(ice_hw_to_dev(hw), num_unicast, s_rule_size,
1581 return ICE_ERR_NO_MEMORY;
1584 list_for_each_entry(m_list_itr, m_list, list_entry) {
1585 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1587 if (is_unicast_ether_addr(addr)) {
1588 m_entry = ice_find_mac_entry(hw, addr);
1590 status = ICE_ERR_DOES_NOT_EXIST;
1591 goto ice_remove_mac_exit;
1594 ice_fill_sw_rule(hw, &m_entry->fltr_info,
1595 r_iter, ice_aqc_opc_remove_sw_rules);
1596 r_iter = (struct ice_aqc_sw_rules_elem *)
1597 ((u8 *)r_iter + s_rule_size);
1601 /* Call AQ bulk switch rule update for all unicast addresses */
1603 /* Call AQ switch rule in AQ_MAX chunk */
1604 for (total_elem_left = num_unicast; total_elem_left > 0;
1605 total_elem_left -= elem_sent) {
1606 struct ice_aqc_sw_rules_elem *entry = r_iter;
1608 elem_sent = min(total_elem_left,
1609 (u16)(ICE_AQ_MAX_BUF_LEN / s_rule_size));
1610 status = ice_aq_sw_rules(hw, entry, elem_sent * s_rule_size,
1611 elem_sent, ice_aqc_opc_remove_sw_rules,
1615 r_iter = (struct ice_aqc_sw_rules_elem *)
1616 ((u8 *)r_iter + s_rule_size);
1619 list_for_each_entry(m_list_itr, m_list, list_entry) {
1620 u8 *addr = m_list_itr->fltr_info.l_data.mac.mac_addr;
1622 if (is_unicast_ether_addr(addr)) {
1623 m_entry = ice_find_mac_entry(hw, addr);
1625 return ICE_ERR_OUT_OF_RANGE;
1626 mutex_lock(&sw->mac_list_lock);
1627 list_del(&m_entry->list_entry);
1628 mutex_unlock(&sw->mac_list_lock);
1629 devm_kfree(ice_hw_to_dev(hw), m_entry);
1633 ice_remove_mac_exit:
1634 devm_kfree(ice_hw_to_dev(hw), s_rule);
1639 * ice_cfg_dflt_vsi - add filter rule to set/unset given VSI as default
1640 * VSI for the switch (represented by swid)
1641 * @hw: pointer to the hardware structure
1642 * @vsi_id: number of VSI to set as default
1643 * @set: true to add the above mentioned switch rule, false to remove it
1644 * @direction: ICE_FLTR_RX or ICE_FLTR_TX
1647 ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction)
1649 struct ice_aqc_sw_rules_elem *s_rule;
1650 struct ice_fltr_info f_info;
1651 enum ice_adminq_opc opcode;
1652 enum ice_status status;
1655 s_rule_size = set ? ICE_SW_RULE_RX_TX_ETH_HDR_SIZE :
1656 ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
1657 s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
1659 return ICE_ERR_NO_MEMORY;
1661 memset(&f_info, 0, sizeof(f_info));
1663 f_info.lkup_type = ICE_SW_LKUP_DFLT;
1664 f_info.flag = direction;
1665 f_info.fltr_act = ICE_FWD_TO_VSI;
1666 f_info.fwd_id.vsi_id = vsi_id;
1668 if (f_info.flag & ICE_FLTR_RX) {
1669 f_info.src = hw->port_info->lport;
1671 f_info.fltr_rule_id =
1672 hw->port_info->dflt_rx_vsi_rule_id;
1673 } else if (f_info.flag & ICE_FLTR_TX) {
1674 f_info.src = vsi_id;
1676 f_info.fltr_rule_id =
1677 hw->port_info->dflt_tx_vsi_rule_id;
1681 opcode = ice_aqc_opc_add_sw_rules;
1683 opcode = ice_aqc_opc_remove_sw_rules;
1685 ice_fill_sw_rule(hw, &f_info, s_rule, opcode);
1687 status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opcode, NULL);
1688 if (status || !(f_info.flag & ICE_FLTR_TX_RX))
1691 u16 index = le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
1693 if (f_info.flag & ICE_FLTR_TX) {
1694 hw->port_info->dflt_tx_vsi_num = vsi_id;
1695 hw->port_info->dflt_tx_vsi_rule_id = index;
1696 } else if (f_info.flag & ICE_FLTR_RX) {
1697 hw->port_info->dflt_rx_vsi_num = vsi_id;
1698 hw->port_info->dflt_rx_vsi_rule_id = index;
1701 if (f_info.flag & ICE_FLTR_TX) {
1702 hw->port_info->dflt_tx_vsi_num = ICE_DFLT_VSI_INVAL;
1703 hw->port_info->dflt_tx_vsi_rule_id = ICE_INVAL_ACT;
1704 } else if (f_info.flag & ICE_FLTR_RX) {
1705 hw->port_info->dflt_rx_vsi_num = ICE_DFLT_VSI_INVAL;
1706 hw->port_info->dflt_rx_vsi_rule_id = ICE_INVAL_ACT;
1711 devm_kfree(ice_hw_to_dev(hw), s_rule);
1716 * ice_remove_vlan_internal - Remove one VLAN based filter rule
1717 * @hw: pointer to the hardware structure
1718 * @f_entry: filter entry containing one VLAN information
1720 static enum ice_status
1721 ice_remove_vlan_internal(struct ice_hw *hw,
1722 struct ice_fltr_list_entry *f_entry)
1724 struct ice_fltr_info *new_fltr;
1725 struct ice_fltr_mgmt_list_entry *v_list_elem;
1728 new_fltr = &f_entry->fltr_info;
1730 v_list_elem = ice_find_vlan_entry(hw, new_fltr->l_data.vlan.vlan_id);
1732 return ICE_ERR_PARAM;
1734 vsi_id = f_entry->fltr_info.fwd_id.vsi_id;
1735 return ice_handle_rem_vsi_list_mgmt(hw, vsi_id, v_list_elem);
1739 * ice_remove_vlan - Remove VLAN based filter rule
1740 * @hw: pointer to the hardware structure
1741 * @v_list: list of VLAN entries and forwarding information
1744 ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list)
1746 struct ice_fltr_list_entry *v_list_itr;
1747 enum ice_status status = 0;
1750 return ICE_ERR_PARAM;
1752 list_for_each_entry(v_list_itr, v_list, list_entry) {
1753 status = ice_remove_vlan_internal(hw, v_list_itr);
1755 v_list_itr->status = ICE_FLTR_STATUS_FW_FAIL;
1758 v_list_itr->status = ICE_FLTR_STATUS_FW_SUCCESS;
1764 * ice_add_to_vsi_fltr_list - Add VSI filters to the list
1765 * @hw: pointer to the hardware structure
1766 * @vsi_id: ID of VSI to remove filters from
1767 * @lkup_list_head: pointer to the list that has certain lookup type filters
1768 * @vsi_list_head: pointer to the list pertaining to VSI with vsi_id
1770 static enum ice_status
1771 ice_add_to_vsi_fltr_list(struct ice_hw *hw, u16 vsi_id,
1772 struct list_head *lkup_list_head,
1773 struct list_head *vsi_list_head)
1775 struct ice_fltr_mgmt_list_entry *fm_entry;
1777 /* check to make sure VSI id is valid and within boundary */
1779 (sizeof(fm_entry->vsi_list_info->vsi_map) * BITS_PER_BYTE - 1))
1780 return ICE_ERR_PARAM;
1782 list_for_each_entry(fm_entry, lkup_list_head, list_entry) {
1783 struct ice_fltr_info *fi;
1785 fi = &fm_entry->fltr_info;
1786 if ((fi->fltr_act == ICE_FWD_TO_VSI &&
1787 fi->fwd_id.vsi_id == vsi_id) ||
1788 (fi->fltr_act == ICE_FWD_TO_VSI_LIST &&
1789 (test_bit(vsi_id, fm_entry->vsi_list_info->vsi_map)))) {
1790 struct ice_fltr_list_entry *tmp;
1792 /* this memory is freed up in the caller function
1793 * ice_remove_vsi_lkup_fltr() once filters for
1794 * this VSI are removed
1796 tmp = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*tmp),
1799 return ICE_ERR_NO_MEMORY;
1801 memcpy(&tmp->fltr_info, fi, sizeof(*fi));
1803 /* Expected below fields to be set to ICE_FWD_TO_VSI and
1804 * the particular VSI id since we are only removing this
1807 if (fi->fltr_act == ICE_FWD_TO_VSI_LIST) {
1808 tmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1809 tmp->fltr_info.fwd_id.vsi_id = vsi_id;
1812 list_add(&tmp->list_entry, vsi_list_head);
1819 * ice_remove_vsi_lkup_fltr - Remove lookup type filters for a VSI
1820 * @hw: pointer to the hardware structure
1821 * @vsi_id: ID of VSI to remove filters from
1822 * @lkup: switch rule filter lookup type
1825 ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_id,
1826 enum ice_sw_lkup_type lkup)
1828 struct ice_switch_info *sw = hw->switch_info;
1829 struct ice_fltr_list_entry *fm_entry;
1830 struct list_head remove_list_head;
1831 struct ice_fltr_list_entry *tmp;
1832 enum ice_status status;
1834 INIT_LIST_HEAD(&remove_list_head);
1836 case ICE_SW_LKUP_MAC:
1837 mutex_lock(&sw->mac_list_lock);
1838 status = ice_add_to_vsi_fltr_list(hw, vsi_id,
1841 mutex_unlock(&sw->mac_list_lock);
1843 ice_remove_mac(hw, &remove_list_head);
1844 goto free_fltr_list;
1847 case ICE_SW_LKUP_VLAN:
1848 mutex_lock(&sw->vlan_list_lock);
1849 status = ice_add_to_vsi_fltr_list(hw, vsi_id,
1850 &sw->vlan_list_head,
1852 mutex_unlock(&sw->vlan_list_lock);
1854 ice_remove_vlan(hw, &remove_list_head);
1855 goto free_fltr_list;
1858 case ICE_SW_LKUP_MAC_VLAN:
1859 case ICE_SW_LKUP_ETHERTYPE:
1860 case ICE_SW_LKUP_ETHERTYPE_MAC:
1861 case ICE_SW_LKUP_PROMISC:
1862 case ICE_SW_LKUP_PROMISC_VLAN:
1863 case ICE_SW_LKUP_DFLT:
1864 ice_debug(hw, ICE_DBG_SW,
1865 "Remove filters for this lookup type hasn't been implemented yet\n");
1871 list_for_each_entry_safe(fm_entry, tmp, &remove_list_head, list_entry) {
1872 list_del(&fm_entry->list_entry);
1873 devm_kfree(ice_hw_to_dev(hw), fm_entry);
1878 * ice_remove_vsi_fltr - Remove all filters for a VSI
1879 * @hw: pointer to the hardware structure
1880 * @vsi_id: ID of VSI to remove filters from
1882 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_id)
1884 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_MAC);
1885 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_MAC_VLAN);
1886 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_PROMISC);
1887 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_VLAN);
1888 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_DFLT);
1889 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_ETHERTYPE);
1890 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_ETHERTYPE_MAC);
1891 ice_remove_vsi_lkup_fltr(hw, vsi_id, ICE_SW_LKUP_PROMISC_VLAN);