1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2018-2023, Intel Corporation. */
4 /* flow director ethtool support for ice */
11 static struct in6_addr full_ipv6_addr_mask = {
14 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
20 static struct in6_addr zero_ipv6_addr_mask = {
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 /* calls to ice_flow_add_prof require the number of segments in the array
30 * for segs_cnt. In this code that is one more than the index.
32 #define TNL_SEG_CNT(_TNL_) ((_TNL_) + 1)
35 * ice_fltr_to_ethtool_flow - convert filter type values to ethtool
37 * @flow: filter type to be converted
39 * Returns the corresponding ethtool flow type.
41 static int ice_fltr_to_ethtool_flow(enum ice_fltr_ptype flow)
44 case ICE_FLTR_PTYPE_NONF_ETH:
46 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
48 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
50 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
52 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
53 return IPV4_USER_FLOW;
54 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
56 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
58 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
60 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
61 return IPV6_USER_FLOW;
63 /* 0 is undefined ethtool flow */
69 * ice_ethtool_flow_to_fltr - convert ethtool flow type to filter enum
70 * @eth: Ethtool flow type to be converted
74 static enum ice_fltr_ptype ice_ethtool_flow_to_fltr(int eth)
78 return ICE_FLTR_PTYPE_NONF_ETH;
80 return ICE_FLTR_PTYPE_NONF_IPV4_TCP;
82 return ICE_FLTR_PTYPE_NONF_IPV4_UDP;
84 return ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
86 return ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
88 return ICE_FLTR_PTYPE_NONF_IPV6_TCP;
90 return ICE_FLTR_PTYPE_NONF_IPV6_UDP;
92 return ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
94 return ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
96 return ICE_FLTR_PTYPE_NONF_NONE;
101 * ice_is_mask_valid - check mask field set
102 * @mask: full mask to check
103 * @field: field for which mask should be valid
105 * If the mask is fully set return true. If it is not valid for field return
108 static bool ice_is_mask_valid(u64 mask, u64 field)
110 return (mask & field) == field;
114 * ice_get_ethtool_fdir_entry - fill ethtool structure with fdir filter data
115 * @hw: hardware structure that contains filter list
116 * @cmd: ethtool command data structure to receive the filter data
118 * Returns 0 on success and -EINVAL on failure
120 int ice_get_ethtool_fdir_entry(struct ice_hw *hw, struct ethtool_rxnfc *cmd)
122 struct ethtool_rx_flow_spec *fsp;
123 struct ice_fdir_fltr *rule;
127 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
129 mutex_lock(&hw->fdir_fltr_lock);
131 rule = ice_fdir_find_fltr_by_idx(hw, fsp->location);
133 if (!rule || fsp->location != rule->fltr_id) {
138 fsp->flow_type = ice_fltr_to_ethtool_flow(rule->flow_type);
140 memset(&fsp->m_u, 0, sizeof(fsp->m_u));
141 memset(&fsp->m_ext, 0, sizeof(fsp->m_ext));
143 switch (fsp->flow_type) {
145 fsp->h_u.ether_spec = rule->eth;
146 fsp->m_u.ether_spec = rule->eth_mask;
149 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
150 fsp->h_u.usr_ip4_spec.proto = 0;
151 fsp->h_u.usr_ip4_spec.l4_4_bytes = rule->ip.v4.l4_header;
152 fsp->h_u.usr_ip4_spec.tos = rule->ip.v4.tos;
153 fsp->h_u.usr_ip4_spec.ip4src = rule->ip.v4.src_ip;
154 fsp->h_u.usr_ip4_spec.ip4dst = rule->ip.v4.dst_ip;
155 fsp->m_u.usr_ip4_spec.ip4src = rule->mask.v4.src_ip;
156 fsp->m_u.usr_ip4_spec.ip4dst = rule->mask.v4.dst_ip;
157 fsp->m_u.usr_ip4_spec.ip_ver = 0xFF;
158 fsp->m_u.usr_ip4_spec.proto = 0;
159 fsp->m_u.usr_ip4_spec.l4_4_bytes = rule->mask.v4.l4_header;
160 fsp->m_u.usr_ip4_spec.tos = rule->mask.v4.tos;
165 fsp->h_u.tcp_ip4_spec.psrc = rule->ip.v4.src_port;
166 fsp->h_u.tcp_ip4_spec.pdst = rule->ip.v4.dst_port;
167 fsp->h_u.tcp_ip4_spec.ip4src = rule->ip.v4.src_ip;
168 fsp->h_u.tcp_ip4_spec.ip4dst = rule->ip.v4.dst_ip;
169 fsp->m_u.tcp_ip4_spec.psrc = rule->mask.v4.src_port;
170 fsp->m_u.tcp_ip4_spec.pdst = rule->mask.v4.dst_port;
171 fsp->m_u.tcp_ip4_spec.ip4src = rule->mask.v4.src_ip;
172 fsp->m_u.tcp_ip4_spec.ip4dst = rule->mask.v4.dst_ip;
175 fsp->h_u.usr_ip6_spec.l4_4_bytes = rule->ip.v6.l4_header;
176 fsp->h_u.usr_ip6_spec.tclass = rule->ip.v6.tc;
177 fsp->h_u.usr_ip6_spec.l4_proto = rule->ip.v6.proto;
178 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->ip.v6.src_ip,
179 sizeof(struct in6_addr));
180 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->ip.v6.dst_ip,
181 sizeof(struct in6_addr));
182 memcpy(fsp->m_u.tcp_ip6_spec.ip6src, rule->mask.v6.src_ip,
183 sizeof(struct in6_addr));
184 memcpy(fsp->m_u.tcp_ip6_spec.ip6dst, rule->mask.v6.dst_ip,
185 sizeof(struct in6_addr));
186 fsp->m_u.usr_ip6_spec.l4_4_bytes = rule->mask.v6.l4_header;
187 fsp->m_u.usr_ip6_spec.tclass = rule->mask.v6.tc;
188 fsp->m_u.usr_ip6_spec.l4_proto = rule->mask.v6.proto;
193 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->ip.v6.src_ip,
194 sizeof(struct in6_addr));
195 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->ip.v6.dst_ip,
196 sizeof(struct in6_addr));
197 fsp->h_u.tcp_ip6_spec.psrc = rule->ip.v6.src_port;
198 fsp->h_u.tcp_ip6_spec.pdst = rule->ip.v6.dst_port;
199 memcpy(fsp->m_u.tcp_ip6_spec.ip6src,
200 rule->mask.v6.src_ip,
201 sizeof(struct in6_addr));
202 memcpy(fsp->m_u.tcp_ip6_spec.ip6dst,
203 rule->mask.v6.dst_ip,
204 sizeof(struct in6_addr));
205 fsp->m_u.tcp_ip6_spec.psrc = rule->mask.v6.src_port;
206 fsp->m_u.tcp_ip6_spec.pdst = rule->mask.v6.dst_port;
207 fsp->h_u.tcp_ip6_spec.tclass = rule->ip.v6.tc;
208 fsp->m_u.tcp_ip6_spec.tclass = rule->mask.v6.tc;
214 if (rule->dest_ctl == ICE_FLTR_PRGM_DESC_DEST_DROP_PKT)
215 fsp->ring_cookie = RX_CLS_FLOW_DISC;
217 fsp->ring_cookie = rule->orig_q_index;
219 idx = ice_ethtool_flow_to_fltr(fsp->flow_type);
220 if (idx == ICE_FLTR_PTYPE_NONF_NONE) {
221 dev_err(ice_hw_to_dev(hw), "Missing input index for flow_type %d\n",
227 mutex_unlock(&hw->fdir_fltr_lock);
232 * ice_get_fdir_fltr_ids - fill buffer with filter IDs of active filters
233 * @hw: hardware structure containing the filter list
234 * @cmd: ethtool command data structure
235 * @rule_locs: ethtool array passed in from OS to receive filter IDs
237 * Returns 0 as expected for success by ethtool
240 ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd,
243 struct ice_fdir_fltr *f_rule;
244 unsigned int cnt = 0;
247 /* report total rule count */
248 cmd->data = ice_get_fdir_cnt_all(hw);
250 mutex_lock(&hw->fdir_fltr_lock);
252 list_for_each_entry(f_rule, &hw->fdir_list_head, fltr_node) {
253 if (cnt == cmd->rule_cnt) {
257 rule_locs[cnt] = f_rule->fltr_id;
262 mutex_unlock(&hw->fdir_fltr_lock);
269 * ice_fdir_remap_entries - update the FDir entries in profile
270 * @prof: FDir structure pointer
271 * @tun: tunneled or non-tunneled packet
272 * @idx: FDir entry index
275 ice_fdir_remap_entries(struct ice_fd_hw_prof *prof, int tun, int idx)
277 if (idx != prof->cnt && tun < ICE_FD_HW_SEG_MAX) {
280 for (i = idx; i < (prof->cnt - 1); i++) {
283 old_entry_h = prof->entry_h[i + 1][tun];
284 prof->entry_h[i][tun] = old_entry_h;
285 prof->vsi_h[i] = prof->vsi_h[i + 1];
288 prof->entry_h[i][tun] = 0;
294 * ice_fdir_rem_adq_chnl - remove an ADQ channel from HW filter rules
295 * @hw: hardware structure containing filter list
296 * @vsi_idx: VSI handle
298 void ice_fdir_rem_adq_chnl(struct ice_hw *hw, u16 vsi_idx)
305 for (flow = 0; flow < ICE_FLTR_PTYPE_MAX; flow++) {
306 struct ice_fd_hw_prof *prof = hw->fdir_prof[flow];
309 if (!prof || !prof->cnt)
312 for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
313 u64 prof_id = prof->prof_id[tun];
315 for (i = 0; i < prof->cnt; i++) {
316 if (prof->vsi_h[i] != vsi_idx)
319 prof->entry_h[i][tun] = 0;
324 /* after clearing FDir entries update the remaining */
325 ice_fdir_remap_entries(prof, tun, i);
327 /* find flow profile corresponding to prof_id and clear
328 * vsi_idx from bitmap.
330 status = ice_flow_rem_vsi_prof(hw, vsi_idx, prof_id);
332 dev_err(ice_hw_to_dev(hw), "ice_flow_rem_vsi_prof() failed status=%d\n",
341 * ice_fdir_get_hw_prof - return the ice_fd_hw_proc associated with a flow
342 * @hw: hardware structure containing the filter list
343 * @blk: hardware block
344 * @flow: FDir flow type to release
346 static struct ice_fd_hw_prof *
347 ice_fdir_get_hw_prof(struct ice_hw *hw, enum ice_block blk, int flow)
349 if (blk == ICE_BLK_FD && hw->fdir_prof)
350 return hw->fdir_prof[flow];
356 * ice_fdir_erase_flow_from_hw - remove a flow from the HW profile tables
357 * @hw: hardware structure containing the filter list
358 * @blk: hardware block
359 * @flow: FDir flow type to release
362 ice_fdir_erase_flow_from_hw(struct ice_hw *hw, enum ice_block blk, int flow)
364 struct ice_fd_hw_prof *prof = ice_fdir_get_hw_prof(hw, blk, flow);
370 for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
371 u64 prof_id = prof->prof_id[tun];
374 for (j = 0; j < prof->cnt; j++) {
377 if (!prof->entry_h[j][tun] || !prof->vsi_h[j])
379 vsi_num = ice_get_hw_vsi_num(hw, prof->vsi_h[j]);
380 ice_rem_prof_id_flow(hw, blk, vsi_num, prof_id);
381 ice_flow_rem_entry(hw, blk, prof->entry_h[j][tun]);
382 prof->entry_h[j][tun] = 0;
384 ice_flow_rem_prof(hw, blk, prof_id);
389 * ice_fdir_rem_flow - release the ice_flow structures for a filter type
390 * @hw: hardware structure containing the filter list
391 * @blk: hardware block
392 * @flow_type: FDir flow type to release
395 ice_fdir_rem_flow(struct ice_hw *hw, enum ice_block blk,
396 enum ice_fltr_ptype flow_type)
398 int flow = (int)flow_type & ~FLOW_EXT;
399 struct ice_fd_hw_prof *prof;
402 prof = ice_fdir_get_hw_prof(hw, blk, flow);
406 ice_fdir_erase_flow_from_hw(hw, blk, flow);
407 for (i = 0; i < prof->cnt; i++)
409 for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
410 if (!prof->fdir_seg[tun])
412 devm_kfree(ice_hw_to_dev(hw), prof->fdir_seg[tun]);
413 prof->fdir_seg[tun] = NULL;
419 * ice_fdir_release_flows - release all flows in use for later replay
420 * @hw: pointer to HW instance
422 void ice_fdir_release_flows(struct ice_hw *hw)
426 /* release Flow Director HW table entries */
427 for (flow = 0; flow < ICE_FLTR_PTYPE_MAX; flow++)
428 ice_fdir_erase_flow_from_hw(hw, ICE_BLK_FD, flow);
432 * ice_fdir_replay_flows - replay HW Flow Director filter info
433 * @hw: pointer to HW instance
435 void ice_fdir_replay_flows(struct ice_hw *hw)
439 for (flow = 0; flow < ICE_FLTR_PTYPE_MAX; flow++) {
442 if (!hw->fdir_prof[flow] || !hw->fdir_prof[flow]->cnt)
444 for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
445 struct ice_flow_prof *hw_prof;
446 struct ice_fd_hw_prof *prof;
449 prof = hw->fdir_prof[flow];
450 ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX,
451 prof->fdir_seg[tun], TNL_SEG_CNT(tun),
453 for (j = 0; j < prof->cnt; j++) {
454 enum ice_flow_priority prio;
458 prio = ICE_FLOW_PRIO_NORMAL;
459 err = ice_flow_add_entry(hw, ICE_BLK_FD,
463 prio, prof->fdir_seg,
466 dev_err(ice_hw_to_dev(hw), "Could not replay Flow Director, flow type %d\n",
470 prof->prof_id[tun] = hw_prof->id;
471 prof->entry_h[j][tun] = entry_h;
478 * ice_parse_rx_flow_user_data - deconstruct user-defined data
479 * @fsp: pointer to ethtool Rx flow specification
480 * @data: pointer to userdef data structure for storage
482 * Returns 0 on success, negative error value on failure
485 ice_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,
486 struct ice_rx_flow_userdef *data)
490 memset(data, 0, sizeof(*data));
491 if (!(fsp->flow_type & FLOW_EXT))
494 value = be64_to_cpu(*((__force __be64 *)fsp->h_ext.data));
495 mask = be64_to_cpu(*((__force __be64 *)fsp->m_ext.data));
499 #define ICE_USERDEF_FLEX_WORD_M GENMASK_ULL(15, 0)
500 #define ICE_USERDEF_FLEX_OFFS_S 16
501 #define ICE_USERDEF_FLEX_OFFS_M GENMASK_ULL(31, ICE_USERDEF_FLEX_OFFS_S)
502 #define ICE_USERDEF_FLEX_FLTR_M GENMASK_ULL(31, 0)
504 /* 0x1fe is the maximum value for offsets stored in the internal
507 #define ICE_USERDEF_FLEX_MAX_OFFS_VAL 0x1fe
509 if (!ice_is_mask_valid(mask, ICE_USERDEF_FLEX_FLTR_M) ||
510 value > ICE_USERDEF_FLEX_FLTR_M)
513 data->flex_word = value & ICE_USERDEF_FLEX_WORD_M;
514 data->flex_offset = FIELD_GET(ICE_USERDEF_FLEX_OFFS_M, value);
515 if (data->flex_offset > ICE_USERDEF_FLEX_MAX_OFFS_VAL)
518 data->flex_fltr = true;
524 * ice_fdir_num_avail_fltr - return the number of unused flow director filters
525 * @hw: pointer to hardware structure
526 * @vsi: software VSI structure
528 * There are 2 filter pools: guaranteed and best effort(shared). Each VSI can
529 * use filters from either pool. The guaranteed pool is divided between VSIs.
530 * The best effort filter pool is common to all VSIs and is a device shared
531 * resource pool. The number of filters available to this VSI is the sum of
532 * the VSIs guaranteed filter pool and the global available best effort
535 * Returns the number of available flow director filters to this VSI
537 int ice_fdir_num_avail_fltr(struct ice_hw *hw, struct ice_vsi *vsi)
539 u16 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
543 /* total guaranteed filters assigned to this VSI */
544 num_guar = vsi->num_gfltr;
546 /* total global best effort filters */
547 num_be = hw->func_caps.fd_fltr_best_effort;
549 /* Subtract the number of programmed filters from the global values */
550 switch (hw->mac_type) {
552 num_guar -= FIELD_GET(E830_VSIQF_FD_CNT_FD_GCNT_M,
553 rd32(hw, VSIQF_FD_CNT(vsi_num)));
554 num_be -= FIELD_GET(E830_GLQF_FD_CNT_FD_BCNT_M,
555 rd32(hw, GLQF_FD_CNT));
559 num_guar -= FIELD_GET(E800_VSIQF_FD_CNT_FD_GCNT_M,
560 rd32(hw, VSIQF_FD_CNT(vsi_num)));
561 num_be -= FIELD_GET(E800_GLQF_FD_CNT_FD_BCNT_M,
562 rd32(hw, GLQF_FD_CNT));
565 return num_guar + num_be;
569 * ice_fdir_alloc_flow_prof - allocate FDir flow profile structure(s)
570 * @hw: HW structure containing the FDir flow profile structure(s)
571 * @flow: flow type to allocate the flow profile for
573 * Allocate the fdir_prof and fdir_prof[flow] if not already created. Return 0
574 * on success and negative on error.
577 ice_fdir_alloc_flow_prof(struct ice_hw *hw, enum ice_fltr_ptype flow)
582 if (!hw->fdir_prof) {
583 hw->fdir_prof = devm_kcalloc(ice_hw_to_dev(hw),
585 sizeof(*hw->fdir_prof),
591 if (!hw->fdir_prof[flow]) {
592 hw->fdir_prof[flow] = devm_kzalloc(ice_hw_to_dev(hw),
593 sizeof(**hw->fdir_prof),
595 if (!hw->fdir_prof[flow])
603 * ice_fdir_prof_vsi_idx - find or insert a vsi_idx in structure
604 * @prof: pointer to flow director HW profile
605 * @vsi_idx: vsi_idx to locate
607 * return the index of the vsi_idx. if vsi_idx is not found insert it
608 * into the vsi_h table.
611 ice_fdir_prof_vsi_idx(struct ice_fd_hw_prof *prof, int vsi_idx)
615 for (idx = 0; idx < prof->cnt; idx++)
616 if (prof->vsi_h[idx] == vsi_idx)
619 if (idx == prof->cnt)
620 prof->vsi_h[prof->cnt++] = vsi_idx;
625 * ice_fdir_set_hw_fltr_rule - Configure HW tables to generate a FDir rule
626 * @pf: pointer to the PF structure
627 * @seg: protocol header description pointer
629 * @tun: FDir segment to program
632 ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
633 enum ice_fltr_ptype flow, enum ice_fd_hw_seg tun)
635 struct device *dev = ice_pf_to_dev(pf);
636 struct ice_vsi *main_vsi, *ctrl_vsi;
637 struct ice_flow_seg_info *old_seg;
638 struct ice_flow_prof *prof = NULL;
639 struct ice_fd_hw_prof *hw_prof;
640 struct ice_hw *hw = &pf->hw;
647 main_vsi = ice_get_main_vsi(pf);
651 ctrl_vsi = ice_get_ctrl_vsi(pf);
655 err = ice_fdir_alloc_flow_prof(hw, flow);
659 hw_prof = hw->fdir_prof[flow];
660 old_seg = hw_prof->fdir_seg[tun];
662 /* This flow_type already has a changed input set.
663 * If it matches the requested input set then we are
664 * done. Or, if it's different then it's an error.
666 if (!memcmp(old_seg, seg, sizeof(*seg)))
669 /* if there are FDir filters using this flow,
672 if (hw->fdir_fltr_cnt[flow]) {
673 dev_err(dev, "Failed to add filter. Flow director filters on each port must have the same input set.\n");
677 if (ice_is_arfs_using_perfect_flow(hw, flow)) {
678 dev_err(dev, "aRFS using perfect flow type %d, cannot change input set\n",
683 /* remove HW filter definition */
684 ice_fdir_rem_flow(hw, ICE_BLK_FD, flow);
687 /* Adding a profile, but there is only one header supported.
688 * That is the final parameters are 1 header (segment), no
689 * actions (NULL) and zero actions 0.
691 err = ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX, seg,
692 TNL_SEG_CNT(tun), false, &prof);
695 err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id, main_vsi->idx,
696 main_vsi->idx, ICE_FLOW_PRIO_NORMAL,
700 err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id, main_vsi->idx,
701 ctrl_vsi->idx, ICE_FLOW_PRIO_NORMAL,
706 hw_prof->fdir_seg[tun] = seg;
707 hw_prof->prof_id[tun] = prof->id;
708 hw_prof->entry_h[0][tun] = entry1_h;
709 hw_prof->entry_h[1][tun] = entry2_h;
710 hw_prof->vsi_h[0] = main_vsi->idx;
711 hw_prof->vsi_h[1] = ctrl_vsi->idx;
715 for (idx = 1; idx < ICE_CHNL_MAX_TC; idx++) {
719 if (!ice_is_adq_active(pf) || !main_vsi->tc_map_vsi[idx])
723 vsi_h = main_vsi->tc_map_vsi[idx]->idx;
724 err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id,
725 main_vsi->idx, vsi_h,
726 ICE_FLOW_PRIO_NORMAL, seg,
729 dev_err(dev, "Could not add Channel VSI %d to flow group\n",
734 vsi_idx = ice_fdir_prof_vsi_idx(hw_prof,
735 main_vsi->tc_map_vsi[idx]->idx);
736 hw_prof->entry_h[vsi_idx][tun] = entry1_h;
743 hw_prof->fdir_seg[tun] = NULL;
745 /* The variable del_last will be used to determine when to clean up
746 * the VSI group data. The VSI data is not needed if there are no
750 for (idx = 0; idx < ICE_FD_HW_SEG_MAX; idx++)
751 if (hw_prof->fdir_seg[idx]) {
756 for (idx = 0; idx < hw_prof->cnt; idx++) {
757 u16 vsi_num = ice_get_hw_vsi_num(hw, hw_prof->vsi_h[idx]);
759 if (!hw_prof->entry_h[idx][tun])
761 ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof->id);
762 ice_flow_rem_entry(hw, ICE_BLK_FD, hw_prof->entry_h[idx][tun]);
763 hw_prof->entry_h[idx][tun] = 0;
765 hw_prof->vsi_h[idx] = 0;
770 ice_rem_prof_id_flow(hw, ICE_BLK_FD,
771 ice_get_hw_vsi_num(hw, main_vsi->idx), prof->id);
772 ice_flow_rem_entry(hw, ICE_BLK_FD, entry1_h);
774 ice_flow_rem_prof(hw, ICE_BLK_FD, prof->id);
775 dev_err(dev, "Failed to add filter. Flow director filters on each port must have the same input set.\n");
781 * ice_set_init_fdir_seg
782 * @seg: flow segment for programming
783 * @l3_proto: ICE_FLOW_SEG_HDR_IPV4 or ICE_FLOW_SEG_HDR_IPV6
784 * @l4_proto: ICE_FLOW_SEG_HDR_TCP or ICE_FLOW_SEG_HDR_UDP
786 * Set the configuration for perfect filters to the provided flow segment for
787 * programming the HW filter. This is to be called only when initializing
788 * filters as this function it assumes no filters exist.
791 ice_set_init_fdir_seg(struct ice_flow_seg_info *seg,
792 enum ice_flow_seg_hdr l3_proto,
793 enum ice_flow_seg_hdr l4_proto)
795 enum ice_flow_field src_addr, dst_addr, src_port, dst_port;
800 if (l3_proto == ICE_FLOW_SEG_HDR_IPV4) {
801 src_addr = ICE_FLOW_FIELD_IDX_IPV4_SA;
802 dst_addr = ICE_FLOW_FIELD_IDX_IPV4_DA;
803 } else if (l3_proto == ICE_FLOW_SEG_HDR_IPV6) {
804 src_addr = ICE_FLOW_FIELD_IDX_IPV6_SA;
805 dst_addr = ICE_FLOW_FIELD_IDX_IPV6_DA;
810 if (l4_proto == ICE_FLOW_SEG_HDR_TCP) {
811 src_port = ICE_FLOW_FIELD_IDX_TCP_SRC_PORT;
812 dst_port = ICE_FLOW_FIELD_IDX_TCP_DST_PORT;
813 } else if (l4_proto == ICE_FLOW_SEG_HDR_UDP) {
814 src_port = ICE_FLOW_FIELD_IDX_UDP_SRC_PORT;
815 dst_port = ICE_FLOW_FIELD_IDX_UDP_DST_PORT;
820 ICE_FLOW_SET_HDRS(seg, l3_proto | l4_proto);
822 /* IP source address */
823 ice_flow_set_fld(seg, src_addr, ICE_FLOW_FLD_OFF_INVAL,
824 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL, false);
826 /* IP destination address */
827 ice_flow_set_fld(seg, dst_addr, ICE_FLOW_FLD_OFF_INVAL,
828 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL, false);
830 /* Layer 4 source port */
831 ice_flow_set_fld(seg, src_port, ICE_FLOW_FLD_OFF_INVAL,
832 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL, false);
834 /* Layer 4 destination port */
835 ice_flow_set_fld(seg, dst_port, ICE_FLOW_FLD_OFF_INVAL,
836 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL, false);
842 * ice_create_init_fdir_rule
846 * Return error value or 0 on success.
849 ice_create_init_fdir_rule(struct ice_pf *pf, enum ice_fltr_ptype flow)
851 struct ice_flow_seg_info *seg, *tun_seg;
852 struct device *dev = ice_pf_to_dev(pf);
853 struct ice_hw *hw = &pf->hw;
856 /* if there is already a filter rule for kind return -EINVAL */
857 if (hw->fdir_prof && hw->fdir_prof[flow] &&
858 hw->fdir_prof[flow]->fdir_seg[0])
861 seg = devm_kzalloc(dev, sizeof(*seg), GFP_KERNEL);
865 tun_seg = devm_kcalloc(dev, ICE_FD_HW_SEG_MAX, sizeof(*tun_seg),
868 devm_kfree(dev, seg);
872 if (flow == ICE_FLTR_PTYPE_NONF_IPV4_TCP)
873 ret = ice_set_init_fdir_seg(seg, ICE_FLOW_SEG_HDR_IPV4,
874 ICE_FLOW_SEG_HDR_TCP);
875 else if (flow == ICE_FLTR_PTYPE_NONF_IPV4_UDP)
876 ret = ice_set_init_fdir_seg(seg, ICE_FLOW_SEG_HDR_IPV4,
877 ICE_FLOW_SEG_HDR_UDP);
878 else if (flow == ICE_FLTR_PTYPE_NONF_IPV6_TCP)
879 ret = ice_set_init_fdir_seg(seg, ICE_FLOW_SEG_HDR_IPV6,
880 ICE_FLOW_SEG_HDR_TCP);
881 else if (flow == ICE_FLTR_PTYPE_NONF_IPV6_UDP)
882 ret = ice_set_init_fdir_seg(seg, ICE_FLOW_SEG_HDR_IPV6,
883 ICE_FLOW_SEG_HDR_UDP);
889 /* add filter for outer headers */
890 ret = ice_fdir_set_hw_fltr_rule(pf, seg, flow, ICE_FD_HW_SEG_NON_TUN);
892 /* could not write filter, free memory */
895 /* make tunneled filter HW entries if possible */
896 memcpy(&tun_seg[1], seg, sizeof(*seg));
897 ret = ice_fdir_set_hw_fltr_rule(pf, tun_seg, flow, ICE_FD_HW_SEG_TUN);
899 /* could not write tunnel filter, but outer header filter
902 devm_kfree(dev, tun_seg);
904 set_bit(flow, hw->fdir_perfect_fltr);
907 devm_kfree(dev, tun_seg);
908 devm_kfree(dev, seg);
914 * ice_set_fdir_ip4_seg
915 * @seg: flow segment for programming
916 * @tcp_ip4_spec: mask data from ethtool
917 * @l4_proto: Layer 4 protocol to program
918 * @perfect_fltr: only valid on success; returns true if perfect filter,
921 * Set the mask data into the flow segment to be used to program HW
922 * table based on provided L4 protocol for IPv4
925 ice_set_fdir_ip4_seg(struct ice_flow_seg_info *seg,
926 struct ethtool_tcpip4_spec *tcp_ip4_spec,
927 enum ice_flow_seg_hdr l4_proto, bool *perfect_fltr)
929 enum ice_flow_field src_port, dst_port;
931 /* make sure we don't have any empty rule */
932 if (!tcp_ip4_spec->psrc && !tcp_ip4_spec->ip4src &&
933 !tcp_ip4_spec->pdst && !tcp_ip4_spec->ip4dst)
936 /* filtering on TOS not supported */
937 if (tcp_ip4_spec->tos)
940 if (l4_proto == ICE_FLOW_SEG_HDR_TCP) {
941 src_port = ICE_FLOW_FIELD_IDX_TCP_SRC_PORT;
942 dst_port = ICE_FLOW_FIELD_IDX_TCP_DST_PORT;
943 } else if (l4_proto == ICE_FLOW_SEG_HDR_UDP) {
944 src_port = ICE_FLOW_FIELD_IDX_UDP_SRC_PORT;
945 dst_port = ICE_FLOW_FIELD_IDX_UDP_DST_PORT;
946 } else if (l4_proto == ICE_FLOW_SEG_HDR_SCTP) {
947 src_port = ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT;
948 dst_port = ICE_FLOW_FIELD_IDX_SCTP_DST_PORT;
953 *perfect_fltr = true;
954 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 | l4_proto);
956 /* IP source address */
957 if (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF))
958 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV4_SA,
959 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
960 ICE_FLOW_FLD_OFF_INVAL, false);
961 else if (!tcp_ip4_spec->ip4src)
962 *perfect_fltr = false;
966 /* IP destination address */
967 if (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF))
968 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV4_DA,
969 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
970 ICE_FLOW_FLD_OFF_INVAL, false);
971 else if (!tcp_ip4_spec->ip4dst)
972 *perfect_fltr = false;
976 /* Layer 4 source port */
977 if (tcp_ip4_spec->psrc == htons(0xFFFF))
978 ice_flow_set_fld(seg, src_port, ICE_FLOW_FLD_OFF_INVAL,
979 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
981 else if (!tcp_ip4_spec->psrc)
982 *perfect_fltr = false;
986 /* Layer 4 destination port */
987 if (tcp_ip4_spec->pdst == htons(0xFFFF))
988 ice_flow_set_fld(seg, dst_port, ICE_FLOW_FLD_OFF_INVAL,
989 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
991 else if (!tcp_ip4_spec->pdst)
992 *perfect_fltr = false;
1000 * ice_set_fdir_ip4_usr_seg
1001 * @seg: flow segment for programming
1002 * @usr_ip4_spec: ethtool userdef packet offset
1003 * @perfect_fltr: only valid on success; returns true if perfect filter,
1006 * Set the offset data into the flow segment to be used to program HW
1010 ice_set_fdir_ip4_usr_seg(struct ice_flow_seg_info *seg,
1011 struct ethtool_usrip4_spec *usr_ip4_spec,
1014 /* first 4 bytes of Layer 4 header */
1015 if (usr_ip4_spec->l4_4_bytes)
1017 if (usr_ip4_spec->tos)
1019 if (usr_ip4_spec->ip_ver)
1021 /* Filtering on Layer 4 protocol not supported */
1022 if (usr_ip4_spec->proto)
1024 /* empty rules are not valid */
1025 if (!usr_ip4_spec->ip4src && !usr_ip4_spec->ip4dst)
1028 *perfect_fltr = true;
1029 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4);
1031 /* IP source address */
1032 if (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF))
1033 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV4_SA,
1034 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1035 ICE_FLOW_FLD_OFF_INVAL, false);
1036 else if (!usr_ip4_spec->ip4src)
1037 *perfect_fltr = false;
1041 /* IP destination address */
1042 if (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF))
1043 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV4_DA,
1044 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1045 ICE_FLOW_FLD_OFF_INVAL, false);
1046 else if (!usr_ip4_spec->ip4dst)
1047 *perfect_fltr = false;
1055 * ice_set_fdir_ip6_seg
1056 * @seg: flow segment for programming
1057 * @tcp_ip6_spec: mask data from ethtool
1058 * @l4_proto: Layer 4 protocol to program
1059 * @perfect_fltr: only valid on success; returns true if perfect filter,
1062 * Set the mask data into the flow segment to be used to program HW
1063 * table based on provided L4 protocol for IPv6
1066 ice_set_fdir_ip6_seg(struct ice_flow_seg_info *seg,
1067 struct ethtool_tcpip6_spec *tcp_ip6_spec,
1068 enum ice_flow_seg_hdr l4_proto, bool *perfect_fltr)
1070 enum ice_flow_field src_port, dst_port;
1072 /* make sure we don't have any empty rule */
1073 if (!memcmp(tcp_ip6_spec->ip6src, &zero_ipv6_addr_mask,
1074 sizeof(struct in6_addr)) &&
1075 !memcmp(tcp_ip6_spec->ip6dst, &zero_ipv6_addr_mask,
1076 sizeof(struct in6_addr)) &&
1077 !tcp_ip6_spec->psrc && !tcp_ip6_spec->pdst)
1080 /* filtering on TC not supported */
1081 if (tcp_ip6_spec->tclass)
1084 if (l4_proto == ICE_FLOW_SEG_HDR_TCP) {
1085 src_port = ICE_FLOW_FIELD_IDX_TCP_SRC_PORT;
1086 dst_port = ICE_FLOW_FIELD_IDX_TCP_DST_PORT;
1087 } else if (l4_proto == ICE_FLOW_SEG_HDR_UDP) {
1088 src_port = ICE_FLOW_FIELD_IDX_UDP_SRC_PORT;
1089 dst_port = ICE_FLOW_FIELD_IDX_UDP_DST_PORT;
1090 } else if (l4_proto == ICE_FLOW_SEG_HDR_SCTP) {
1091 src_port = ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT;
1092 dst_port = ICE_FLOW_FIELD_IDX_SCTP_DST_PORT;
1097 *perfect_fltr = true;
1098 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 | l4_proto);
1100 if (!memcmp(tcp_ip6_spec->ip6src, &full_ipv6_addr_mask,
1101 sizeof(struct in6_addr)))
1102 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV6_SA,
1103 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1104 ICE_FLOW_FLD_OFF_INVAL, false);
1105 else if (!memcmp(tcp_ip6_spec->ip6src, &zero_ipv6_addr_mask,
1106 sizeof(struct in6_addr)))
1107 *perfect_fltr = false;
1111 if (!memcmp(tcp_ip6_spec->ip6dst, &full_ipv6_addr_mask,
1112 sizeof(struct in6_addr)))
1113 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV6_DA,
1114 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1115 ICE_FLOW_FLD_OFF_INVAL, false);
1116 else if (!memcmp(tcp_ip6_spec->ip6dst, &zero_ipv6_addr_mask,
1117 sizeof(struct in6_addr)))
1118 *perfect_fltr = false;
1122 /* Layer 4 source port */
1123 if (tcp_ip6_spec->psrc == htons(0xFFFF))
1124 ice_flow_set_fld(seg, src_port, ICE_FLOW_FLD_OFF_INVAL,
1125 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1127 else if (!tcp_ip6_spec->psrc)
1128 *perfect_fltr = false;
1132 /* Layer 4 destination port */
1133 if (tcp_ip6_spec->pdst == htons(0xFFFF))
1134 ice_flow_set_fld(seg, dst_port, ICE_FLOW_FLD_OFF_INVAL,
1135 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1137 else if (!tcp_ip6_spec->pdst)
1138 *perfect_fltr = false;
1146 * ice_set_fdir_ip6_usr_seg
1147 * @seg: flow segment for programming
1148 * @usr_ip6_spec: ethtool userdef packet offset
1149 * @perfect_fltr: only valid on success; returns true if perfect filter,
1152 * Set the offset data into the flow segment to be used to program HW
1156 ice_set_fdir_ip6_usr_seg(struct ice_flow_seg_info *seg,
1157 struct ethtool_usrip6_spec *usr_ip6_spec,
1160 /* filtering on Layer 4 bytes not supported */
1161 if (usr_ip6_spec->l4_4_bytes)
1163 /* filtering on TC not supported */
1164 if (usr_ip6_spec->tclass)
1166 /* filtering on Layer 4 protocol not supported */
1167 if (usr_ip6_spec->l4_proto)
1169 /* empty rules are not valid */
1170 if (!memcmp(usr_ip6_spec->ip6src, &zero_ipv6_addr_mask,
1171 sizeof(struct in6_addr)) &&
1172 !memcmp(usr_ip6_spec->ip6dst, &zero_ipv6_addr_mask,
1173 sizeof(struct in6_addr)))
1176 *perfect_fltr = true;
1177 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6);
1179 if (!memcmp(usr_ip6_spec->ip6src, &full_ipv6_addr_mask,
1180 sizeof(struct in6_addr)))
1181 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV6_SA,
1182 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1183 ICE_FLOW_FLD_OFF_INVAL, false);
1184 else if (!memcmp(usr_ip6_spec->ip6src, &zero_ipv6_addr_mask,
1185 sizeof(struct in6_addr)))
1186 *perfect_fltr = false;
1190 if (!memcmp(usr_ip6_spec->ip6dst, &full_ipv6_addr_mask,
1191 sizeof(struct in6_addr)))
1192 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_IPV6_DA,
1193 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1194 ICE_FLOW_FLD_OFF_INVAL, false);
1195 else if (!memcmp(usr_ip6_spec->ip6dst, &zero_ipv6_addr_mask,
1196 sizeof(struct in6_addr)))
1197 *perfect_fltr = false;
1205 * ice_fdir_vlan_valid - validate VLAN data for Flow Director rule
1206 * @dev: network interface device structure
1207 * @fsp: pointer to ethtool Rx flow specification
1209 * Return: true if vlan data is valid, false otherwise
1211 static bool ice_fdir_vlan_valid(struct device *dev,
1212 struct ethtool_rx_flow_spec *fsp)
1214 if (fsp->m_ext.vlan_etype && !eth_type_vlan(fsp->h_ext.vlan_etype))
1217 if (fsp->m_ext.vlan_tci && ntohs(fsp->h_ext.vlan_tci) >= VLAN_N_VID)
1220 /* proto and vlan must have vlan-etype defined */
1221 if (fsp->m_u.ether_spec.h_proto && fsp->m_ext.vlan_tci &&
1222 !fsp->m_ext.vlan_etype) {
1223 dev_warn(dev, "Filter with proto and vlan require also vlan-etype");
1231 * ice_set_ether_flow_seg - set address and protocol segments for ether flow
1232 * @dev: network interface device structure
1233 * @seg: flow segment for programming
1234 * @eth_spec: mask data from ethtool
1236 * Return: 0 on success and errno in case of error.
1238 static int ice_set_ether_flow_seg(struct device *dev,
1239 struct ice_flow_seg_info *seg,
1240 struct ethhdr *eth_spec)
1242 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_ETH);
1244 /* empty rules are not valid */
1245 if (is_zero_ether_addr(eth_spec->h_source) &&
1246 is_zero_ether_addr(eth_spec->h_dest) &&
1251 if (eth_spec->h_proto == htons(0xFFFF)) {
1252 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_ETH_TYPE,
1253 ICE_FLOW_FLD_OFF_INVAL,
1254 ICE_FLOW_FLD_OFF_INVAL,
1255 ICE_FLOW_FLD_OFF_INVAL, false);
1256 } else if (eth_spec->h_proto) {
1257 dev_warn(dev, "Only 0x0000 or 0xffff proto mask is allowed for flow-type ether");
1261 /* Source MAC address */
1262 if (is_broadcast_ether_addr(eth_spec->h_source))
1263 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_ETH_SA,
1264 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1265 ICE_FLOW_FLD_OFF_INVAL, false);
1266 else if (!is_zero_ether_addr(eth_spec->h_source))
1269 /* Destination MAC address */
1270 if (is_broadcast_ether_addr(eth_spec->h_dest))
1271 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_ETH_DA,
1272 ICE_FLOW_FLD_OFF_INVAL, ICE_FLOW_FLD_OFF_INVAL,
1273 ICE_FLOW_FLD_OFF_INVAL, false);
1274 else if (!is_zero_ether_addr(eth_spec->h_dest))
1280 dev_warn(dev, "Only 00:00:00:00:00:00 or ff:ff:ff:ff:ff:ff MAC address mask is allowed for flow-type ether");
1285 * ice_set_fdir_vlan_seg - set vlan segments for ether flow
1286 * @seg: flow segment for programming
1287 * @ext_masks: masks for additional RX flow fields
1289 * Return: 0 on success and errno in case of error.
1292 ice_set_fdir_vlan_seg(struct ice_flow_seg_info *seg,
1293 struct ethtool_flow_ext *ext_masks)
1295 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_VLAN);
1297 if (ext_masks->vlan_etype) {
1298 if (ext_masks->vlan_etype != htons(0xFFFF))
1301 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_S_VLAN,
1302 ICE_FLOW_FLD_OFF_INVAL,
1303 ICE_FLOW_FLD_OFF_INVAL,
1304 ICE_FLOW_FLD_OFF_INVAL, false);
1307 if (ext_masks->vlan_tci) {
1308 if (ext_masks->vlan_tci != htons(0xFFFF))
1311 ice_flow_set_fld(seg, ICE_FLOW_FIELD_IDX_C_VLAN,
1312 ICE_FLOW_FLD_OFF_INVAL,
1313 ICE_FLOW_FLD_OFF_INVAL,
1314 ICE_FLOW_FLD_OFF_INVAL, false);
1321 * ice_cfg_fdir_xtrct_seq - Configure extraction sequence for the given filter
1323 * @fsp: pointer to ethtool Rx flow specification
1324 * @user: user defined data from flow specification
1326 * Returns 0 on success.
1329 ice_cfg_fdir_xtrct_seq(struct ice_pf *pf, struct ethtool_rx_flow_spec *fsp,
1330 struct ice_rx_flow_userdef *user)
1332 struct ice_flow_seg_info *seg, *tun_seg;
1333 struct device *dev = ice_pf_to_dev(pf);
1334 enum ice_fltr_ptype fltr_idx;
1335 struct ice_hw *hw = &pf->hw;
1336 bool perfect_filter = false;
1339 seg = devm_kzalloc(dev, sizeof(*seg), GFP_KERNEL);
1343 tun_seg = devm_kcalloc(dev, ICE_FD_HW_SEG_MAX, sizeof(*tun_seg),
1346 devm_kfree(dev, seg);
1350 switch (fsp->flow_type & ~FLOW_EXT) {
1352 ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec,
1353 ICE_FLOW_SEG_HDR_TCP,
1357 ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec,
1358 ICE_FLOW_SEG_HDR_UDP,
1362 ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec,
1363 ICE_FLOW_SEG_HDR_SCTP,
1366 case IPV4_USER_FLOW:
1367 ret = ice_set_fdir_ip4_usr_seg(seg, &fsp->m_u.usr_ip4_spec,
1371 ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec,
1372 ICE_FLOW_SEG_HDR_TCP,
1376 ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec,
1377 ICE_FLOW_SEG_HDR_UDP,
1381 ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec,
1382 ICE_FLOW_SEG_HDR_SCTP,
1385 case IPV6_USER_FLOW:
1386 ret = ice_set_fdir_ip6_usr_seg(seg, &fsp->m_u.usr_ip6_spec,
1390 ret = ice_set_ether_flow_seg(dev, seg, &fsp->m_u.ether_spec);
1391 if (!ret && (fsp->m_ext.vlan_etype || fsp->m_ext.vlan_tci)) {
1392 if (!ice_fdir_vlan_valid(dev, fsp)) {
1396 ret = ice_set_fdir_vlan_seg(seg, &fsp->m_ext);
1405 /* tunnel segments are shifted up one. */
1406 memcpy(&tun_seg[1], seg, sizeof(*seg));
1408 if (user && user->flex_fltr) {
1409 perfect_filter = false;
1410 ice_flow_add_fld_raw(seg, user->flex_offset,
1411 ICE_FLTR_PRGM_FLEX_WORD_SIZE,
1412 ICE_FLOW_FLD_OFF_INVAL,
1413 ICE_FLOW_FLD_OFF_INVAL);
1414 ice_flow_add_fld_raw(&tun_seg[1], user->flex_offset,
1415 ICE_FLTR_PRGM_FLEX_WORD_SIZE,
1416 ICE_FLOW_FLD_OFF_INVAL,
1417 ICE_FLOW_FLD_OFF_INVAL);
1420 fltr_idx = ice_ethtool_flow_to_fltr(fsp->flow_type & ~FLOW_EXT);
1422 assign_bit(fltr_idx, hw->fdir_perfect_fltr, perfect_filter);
1424 /* add filter for outer headers */
1425 ret = ice_fdir_set_hw_fltr_rule(pf, seg, fltr_idx,
1426 ICE_FD_HW_SEG_NON_TUN);
1427 if (ret == -EEXIST) {
1428 /* Rule already exists, free memory and count as success */
1432 /* could not write filter, free memory */
1436 /* make tunneled filter HW entries if possible */
1437 memcpy(&tun_seg[1], seg, sizeof(*seg));
1438 ret = ice_fdir_set_hw_fltr_rule(pf, tun_seg, fltr_idx,
1440 if (ret == -EEXIST) {
1441 /* Rule already exists, free memory and count as success */
1442 devm_kfree(dev, tun_seg);
1445 /* could not write tunnel filter, but outer filter exists */
1446 devm_kfree(dev, tun_seg);
1452 devm_kfree(dev, tun_seg);
1453 devm_kfree(dev, seg);
1459 * ice_update_per_q_fltr
1461 * @q_index: queue index
1462 * @inc: true to increment or false to decrement per queue filter count
1464 * This function is used to keep track of per queue sideband filters
1466 static void ice_update_per_q_fltr(struct ice_vsi *vsi, u32 q_index, bool inc)
1468 struct ice_rx_ring *rx_ring;
1470 if (!vsi->num_rxq || q_index >= vsi->num_rxq)
1473 rx_ring = vsi->rx_rings[q_index];
1474 if (!rx_ring || !rx_ring->ch)
1478 atomic_inc(&rx_ring->ch->num_sb_fltr);
1480 atomic_dec_if_positive(&rx_ring->ch->num_sb_fltr);
1484 * ice_fdir_write_fltr - send a flow director filter to the hardware
1485 * @pf: PF data structure
1486 * @input: filter structure
1487 * @add: true adds filter and false removed filter
1488 * @is_tun: true adds inner filter on tunnel and false outer headers
1490 * returns 0 on success and negative value on error
1493 ice_fdir_write_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input, bool add,
1496 struct device *dev = ice_pf_to_dev(pf);
1497 struct ice_hw *hw = &pf->hw;
1498 struct ice_fltr_desc desc;
1499 struct ice_vsi *ctrl_vsi;
1504 ctrl_vsi = ice_get_ctrl_vsi(pf);
1508 pkt = devm_kzalloc(dev, ICE_FDIR_MAX_RAW_PKT_SIZE, GFP_KERNEL);
1511 frag_pkt = devm_kzalloc(dev, ICE_FDIR_MAX_RAW_PKT_SIZE, GFP_KERNEL);
1517 ice_fdir_get_prgm_desc(hw, input, &desc, add);
1518 err = ice_fdir_get_gen_prgm_pkt(hw, input, pkt, false, is_tun);
1521 err = ice_prgm_fdir_fltr(ctrl_vsi, &desc, pkt);
1525 /* repeat for fragment packet */
1526 has_frag = ice_fdir_has_frag(input->flow_type);
1528 /* does not return error */
1529 ice_fdir_get_prgm_desc(hw, input, &desc, add);
1530 err = ice_fdir_get_gen_prgm_pkt(hw, input, frag_pkt, true,
1534 err = ice_prgm_fdir_fltr(ctrl_vsi, &desc, frag_pkt);
1538 devm_kfree(dev, frag_pkt);
1544 devm_kfree(dev, frag_pkt);
1546 devm_kfree(dev, pkt);
1550 devm_kfree(dev, frag_pkt);
1555 * ice_fdir_write_all_fltr - send a flow director filter to the hardware
1556 * @pf: PF data structure
1557 * @input: filter structure
1558 * @add: true adds filter and false removed filter
1560 * returns 0 on success and negative value on error
1563 ice_fdir_write_all_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input,
1569 for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
1570 bool is_tun = tun == ICE_FD_HW_SEG_TUN;
1573 if (is_tun && !ice_get_open_tunnel_port(&pf->hw, &port_num, TNL_ALL))
1575 err = ice_fdir_write_fltr(pf, input, add, is_tun);
1583 * ice_fdir_replay_fltrs - replay filters from the HW filter list
1584 * @pf: board private structure
1586 void ice_fdir_replay_fltrs(struct ice_pf *pf)
1588 struct ice_fdir_fltr *f_rule;
1589 struct ice_hw *hw = &pf->hw;
1591 list_for_each_entry(f_rule, &hw->fdir_list_head, fltr_node) {
1592 int err = ice_fdir_write_all_fltr(pf, f_rule, true);
1595 dev_dbg(ice_pf_to_dev(pf), "Flow Director error %d, could not reprogram filter %d\n",
1596 err, f_rule->fltr_id);
1601 * ice_fdir_create_dflt_rules - create default perfect filters
1602 * @pf: PF data structure
1604 * Returns 0 for success or error.
1606 int ice_fdir_create_dflt_rules(struct ice_pf *pf)
1610 /* Create perfect TCP and UDP rules in hardware. */
1611 err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_TCP);
1615 err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_UDP);
1619 err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_TCP);
1623 err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_UDP);
1629 * ice_fdir_del_all_fltrs - Delete all flow director filters
1630 * @vsi: the VSI being changed
1632 * This function needs to be called while holding hw->fdir_fltr_lock
1634 void ice_fdir_del_all_fltrs(struct ice_vsi *vsi)
1636 struct ice_fdir_fltr *f_rule, *tmp;
1637 struct ice_pf *pf = vsi->back;
1638 struct ice_hw *hw = &pf->hw;
1640 list_for_each_entry_safe(f_rule, tmp, &hw->fdir_list_head, fltr_node) {
1641 ice_fdir_write_all_fltr(pf, f_rule, false);
1642 ice_fdir_update_cntrs(hw, f_rule->flow_type, false);
1643 list_del(&f_rule->fltr_node);
1644 devm_kfree(ice_pf_to_dev(pf), f_rule);
1649 * ice_vsi_manage_fdir - turn on/off flow director
1650 * @vsi: the VSI being changed
1651 * @ena: boolean value indicating if this is an enable or disable request
1653 void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena)
1655 struct ice_pf *pf = vsi->back;
1656 struct ice_hw *hw = &pf->hw;
1657 enum ice_fltr_ptype flow;
1660 set_bit(ICE_FLAG_FD_ENA, pf->flags);
1661 ice_fdir_create_dflt_rules(pf);
1665 mutex_lock(&hw->fdir_fltr_lock);
1666 if (!test_and_clear_bit(ICE_FLAG_FD_ENA, pf->flags))
1669 ice_fdir_del_all_fltrs(vsi);
1672 for (flow = ICE_FLTR_PTYPE_NONF_NONE; flow < ICE_FLTR_PTYPE_MAX;
1674 if (hw->fdir_prof[flow])
1675 ice_fdir_rem_flow(hw, ICE_BLK_FD, flow);
1678 mutex_unlock(&hw->fdir_fltr_lock);
1682 * ice_fdir_do_rem_flow - delete flow and possibly add perfect flow
1684 * @flow_type: FDir flow type to release
1687 ice_fdir_do_rem_flow(struct ice_pf *pf, enum ice_fltr_ptype flow_type)
1689 struct ice_hw *hw = &pf->hw;
1690 bool need_perfect = false;
1692 if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
1693 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
1694 flow_type == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
1695 flow_type == ICE_FLTR_PTYPE_NONF_IPV6_UDP)
1696 need_perfect = true;
1698 if (need_perfect && test_bit(flow_type, hw->fdir_perfect_fltr))
1701 ice_fdir_rem_flow(hw, ICE_BLK_FD, flow_type);
1703 ice_create_init_fdir_rule(pf, flow_type);
1707 * ice_fdir_update_list_entry - add or delete a filter from the filter list
1709 * @input: filter structure
1710 * @fltr_idx: ethtool index of filter to modify
1712 * returns 0 on success and negative on errors
1715 ice_fdir_update_list_entry(struct ice_pf *pf, struct ice_fdir_fltr *input,
1718 struct ice_fdir_fltr *old_fltr;
1719 struct ice_hw *hw = &pf->hw;
1720 struct ice_vsi *vsi;
1723 /* Do not update filters during reset */
1724 if (ice_is_reset_in_progress(pf->state))
1727 vsi = ice_get_main_vsi(pf);
1731 old_fltr = ice_fdir_find_fltr_by_idx(hw, fltr_idx);
1733 err = ice_fdir_write_all_fltr(pf, old_fltr, false);
1736 ice_fdir_update_cntrs(hw, old_fltr->flow_type, false);
1737 /* update sb-filters count, specific to ring->channel */
1738 ice_update_per_q_fltr(vsi, old_fltr->orig_q_index, false);
1739 if (!input && !hw->fdir_fltr_cnt[old_fltr->flow_type])
1740 /* we just deleted the last filter of flow_type so we
1741 * should also delete the HW filter info.
1743 ice_fdir_do_rem_flow(pf, old_fltr->flow_type);
1744 list_del(&old_fltr->fltr_node);
1745 devm_kfree(ice_hw_to_dev(hw), old_fltr);
1749 ice_fdir_list_add_fltr(hw, input);
1750 /* update sb-filters count, specific to ring->channel */
1751 ice_update_per_q_fltr(vsi, input->orig_q_index, true);
1752 ice_fdir_update_cntrs(hw, input->flow_type, true);
1757 * ice_del_fdir_ethtool - delete Flow Director filter
1758 * @vsi: pointer to target VSI
1759 * @cmd: command to add or delete Flow Director filter
1761 * Returns 0 on success and negative values for failure
1763 int ice_del_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd)
1765 struct ethtool_rx_flow_spec *fsp =
1766 (struct ethtool_rx_flow_spec *)&cmd->fs;
1767 struct ice_pf *pf = vsi->back;
1768 struct ice_hw *hw = &pf->hw;
1771 if (!test_bit(ICE_FLAG_FD_ENA, pf->flags))
1774 /* Do not delete filters during reset */
1775 if (ice_is_reset_in_progress(pf->state)) {
1776 dev_err(ice_pf_to_dev(pf), "Device is resetting - deleting Flow Director filters not supported during reset\n");
1780 if (test_bit(ICE_FD_FLUSH_REQ, pf->state))
1783 mutex_lock(&hw->fdir_fltr_lock);
1784 val = ice_fdir_update_list_entry(pf, NULL, fsp->location);
1785 mutex_unlock(&hw->fdir_fltr_lock);
1791 * ice_update_ring_dest_vsi - update dest ring and dest VSI
1792 * @vsi: pointer to target VSI
1793 * @dest_vsi: ptr to dest VSI index
1794 * @ring: ptr to dest ring
1796 * This function updates destination VSI and queue if user specifies
1797 * target queue which falls in channel's (aka ADQ) queue region
1800 ice_update_ring_dest_vsi(struct ice_vsi *vsi, u16 *dest_vsi, u32 *ring)
1802 struct ice_channel *ch;
1804 list_for_each_entry(ch, &vsi->ch_list, list) {
1808 /* make sure to locate corresponding channel based on "queue"
1811 if ((*ring < ch->base_q) ||
1812 (*ring >= (ch->base_q + ch->num_rxq)))
1815 /* update the dest_vsi based on channel */
1816 *dest_vsi = ch->ch_vsi->idx;
1818 /* update the "ring" to be correct based on channel */
1819 *ring -= ch->base_q;
1824 * ice_set_fdir_input_set - Set the input set for Flow Director
1825 * @vsi: pointer to target VSI
1826 * @fsp: pointer to ethtool Rx flow specification
1827 * @input: filter structure
1830 ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp,
1831 struct ice_fdir_fltr *input)
1833 s16 q_index = ICE_FDIR_NO_QUEUE_IDX;
1834 u16 orig_q_index = 0;
1841 if (!vsi || !fsp || !input)
1847 dest_vsi = vsi->idx;
1848 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) {
1849 dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DROP_PKT;
1851 u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie);
1852 u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
1855 dev_err(ice_pf_to_dev(pf), "Failed to add filter. Flow director filters are not supported on VF queues.\n");
1859 if (ring >= vsi->num_rxq)
1862 orig_q_index = ring;
1863 ice_update_ring_dest_vsi(vsi, &dest_vsi, &ring);
1864 dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
1868 input->fltr_id = fsp->location;
1869 input->q_index = q_index;
1870 flow_type = fsp->flow_type & ~FLOW_EXT;
1872 /* Record the original queue index as specified by user.
1873 * with channel configuration 'q_index' becomes relative
1876 input->orig_q_index = orig_q_index;
1877 input->dest_vsi = dest_vsi;
1878 input->dest_ctl = dest_ctl;
1879 input->fltr_status = ICE_FLTR_PRGM_DESC_FD_STATUS_FD_ID;
1880 input->cnt_index = ICE_FD_SB_STAT_IDX(hw->fd_ctr_base);
1881 input->flow_type = ice_ethtool_flow_to_fltr(flow_type);
1883 if (fsp->flow_type & FLOW_EXT) {
1884 memcpy(input->ext_data.usr_def, fsp->h_ext.data,
1885 sizeof(input->ext_data.usr_def));
1886 input->ext_data.vlan_type = fsp->h_ext.vlan_etype;
1887 input->ext_data.vlan_tag = fsp->h_ext.vlan_tci;
1888 memcpy(input->ext_mask.usr_def, fsp->m_ext.data,
1889 sizeof(input->ext_mask.usr_def));
1890 input->ext_mask.vlan_type = fsp->m_ext.vlan_etype;
1891 input->ext_mask.vlan_tag = fsp->m_ext.vlan_tci;
1894 switch (flow_type) {
1898 input->ip.v4.dst_port = fsp->h_u.tcp_ip4_spec.pdst;
1899 input->ip.v4.src_port = fsp->h_u.tcp_ip4_spec.psrc;
1900 input->ip.v4.dst_ip = fsp->h_u.tcp_ip4_spec.ip4dst;
1901 input->ip.v4.src_ip = fsp->h_u.tcp_ip4_spec.ip4src;
1902 input->mask.v4.dst_port = fsp->m_u.tcp_ip4_spec.pdst;
1903 input->mask.v4.src_port = fsp->m_u.tcp_ip4_spec.psrc;
1904 input->mask.v4.dst_ip = fsp->m_u.tcp_ip4_spec.ip4dst;
1905 input->mask.v4.src_ip = fsp->m_u.tcp_ip4_spec.ip4src;
1907 case IPV4_USER_FLOW:
1908 input->ip.v4.dst_ip = fsp->h_u.usr_ip4_spec.ip4dst;
1909 input->ip.v4.src_ip = fsp->h_u.usr_ip4_spec.ip4src;
1910 input->ip.v4.l4_header = fsp->h_u.usr_ip4_spec.l4_4_bytes;
1911 input->ip.v4.proto = fsp->h_u.usr_ip4_spec.proto;
1912 input->ip.v4.ip_ver = fsp->h_u.usr_ip4_spec.ip_ver;
1913 input->ip.v4.tos = fsp->h_u.usr_ip4_spec.tos;
1914 input->mask.v4.dst_ip = fsp->m_u.usr_ip4_spec.ip4dst;
1915 input->mask.v4.src_ip = fsp->m_u.usr_ip4_spec.ip4src;
1916 input->mask.v4.l4_header = fsp->m_u.usr_ip4_spec.l4_4_bytes;
1917 input->mask.v4.proto = fsp->m_u.usr_ip4_spec.proto;
1918 input->mask.v4.ip_ver = fsp->m_u.usr_ip4_spec.ip_ver;
1919 input->mask.v4.tos = fsp->m_u.usr_ip4_spec.tos;
1924 memcpy(input->ip.v6.dst_ip, fsp->h_u.usr_ip6_spec.ip6dst,
1925 sizeof(struct in6_addr));
1926 memcpy(input->ip.v6.src_ip, fsp->h_u.usr_ip6_spec.ip6src,
1927 sizeof(struct in6_addr));
1928 input->ip.v6.dst_port = fsp->h_u.tcp_ip6_spec.pdst;
1929 input->ip.v6.src_port = fsp->h_u.tcp_ip6_spec.psrc;
1930 input->ip.v6.tc = fsp->h_u.tcp_ip6_spec.tclass;
1931 memcpy(input->mask.v6.dst_ip, fsp->m_u.tcp_ip6_spec.ip6dst,
1932 sizeof(struct in6_addr));
1933 memcpy(input->mask.v6.src_ip, fsp->m_u.tcp_ip6_spec.ip6src,
1934 sizeof(struct in6_addr));
1935 input->mask.v6.dst_port = fsp->m_u.tcp_ip6_spec.pdst;
1936 input->mask.v6.src_port = fsp->m_u.tcp_ip6_spec.psrc;
1937 input->mask.v6.tc = fsp->m_u.tcp_ip6_spec.tclass;
1939 case IPV6_USER_FLOW:
1940 memcpy(input->ip.v6.dst_ip, fsp->h_u.usr_ip6_spec.ip6dst,
1941 sizeof(struct in6_addr));
1942 memcpy(input->ip.v6.src_ip, fsp->h_u.usr_ip6_spec.ip6src,
1943 sizeof(struct in6_addr));
1944 input->ip.v6.l4_header = fsp->h_u.usr_ip6_spec.l4_4_bytes;
1945 input->ip.v6.tc = fsp->h_u.usr_ip6_spec.tclass;
1947 /* if no protocol requested, use IPPROTO_NONE */
1948 if (!fsp->m_u.usr_ip6_spec.l4_proto)
1949 input->ip.v6.proto = IPPROTO_NONE;
1951 input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto;
1953 memcpy(input->mask.v6.dst_ip, fsp->m_u.usr_ip6_spec.ip6dst,
1954 sizeof(struct in6_addr));
1955 memcpy(input->mask.v6.src_ip, fsp->m_u.usr_ip6_spec.ip6src,
1956 sizeof(struct in6_addr));
1957 input->mask.v6.l4_header = fsp->m_u.usr_ip6_spec.l4_4_bytes;
1958 input->mask.v6.tc = fsp->m_u.usr_ip6_spec.tclass;
1959 input->mask.v6.proto = fsp->m_u.usr_ip6_spec.l4_proto;
1962 input->eth = fsp->h_u.ether_spec;
1963 input->eth_mask = fsp->m_u.ether_spec;
1966 /* not doing un-parsed flow types */
1974 * ice_add_fdir_ethtool - Add/Remove Flow Director filter
1975 * @vsi: pointer to target VSI
1976 * @cmd: command to add or delete Flow Director filter
1978 * Returns 0 on success and negative values for failure
1980 int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd)
1982 struct ice_rx_flow_userdef userdata;
1983 struct ethtool_rx_flow_spec *fsp;
1984 struct ice_fdir_fltr *input;
1998 dev = ice_pf_to_dev(pf);
2000 if (!test_bit(ICE_FLAG_FD_ENA, pf->flags))
2003 /* Do not program filters during reset */
2004 if (ice_is_reset_in_progress(pf->state)) {
2005 dev_err(dev, "Device is resetting - adding Flow Director filters not supported during reset\n");
2009 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
2011 if (ice_parse_rx_flow_user_data(fsp, &userdata))
2014 if (fsp->flow_type & FLOW_MAC_EXT)
2017 ret = ice_cfg_fdir_xtrct_seq(pf, fsp, &userdata);
2021 max_location = ice_get_fdir_cnt_all(hw);
2022 if (fsp->location >= max_location) {
2023 dev_err(dev, "Failed to add filter. The number of ntuple filters or provided location exceed max %d.\n",
2028 /* return error if not an update and no available filters */
2029 fltrs_needed = ice_get_open_tunnel_port(hw, &tunnel_port, TNL_ALL) ? 2 : 1;
2030 if (!ice_fdir_find_fltr_by_idx(hw, fsp->location) &&
2031 ice_fdir_num_avail_fltr(hw, pf->vsi[vsi->idx]) < fltrs_needed) {
2032 dev_err(dev, "Failed to add filter. The maximum number of flow director filters has been reached.\n");
2036 input = devm_kzalloc(dev, sizeof(*input), GFP_KERNEL);
2040 ret = ice_set_fdir_input_set(vsi, fsp, input);
2044 mutex_lock(&hw->fdir_fltr_lock);
2045 if (ice_fdir_is_dup_fltr(hw, input)) {
2050 if (userdata.flex_fltr) {
2051 input->flex_fltr = true;
2052 input->flex_word = cpu_to_be16(userdata.flex_word);
2053 input->flex_offset = userdata.flex_offset;
2056 input->cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
2057 input->fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_THREE;
2058 input->comp_report = ICE_FXD_FLTR_QW0_COMP_REPORT_SW_FAIL;
2060 /* input struct is added to the HW filter list */
2061 ret = ice_fdir_update_list_entry(pf, input, fsp->location);
2065 ret = ice_fdir_write_all_fltr(pf, input, true);
2067 goto remove_sw_rule;
2072 ice_fdir_update_cntrs(hw, input->flow_type, false);
2073 /* update sb-filters count, specific to ring->channel */
2074 ice_update_per_q_fltr(vsi, input->orig_q_index, false);
2075 list_del(&input->fltr_node);
2077 mutex_unlock(&hw->fdir_fltr_lock);
2080 devm_kfree(dev, input);