From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AACFCD37BE for ; Mon, 11 May 2026 14:07:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 71F6980F65; Mon, 11 May 2026 14:07:47 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id bTqQktwvUV67; Mon, 11 May 2026 14:07:45 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2A0E8815CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1778508463; bh=SLWJXmJHxUBZlNttKtXum/bW1vym+VMxNxxsDzz5Bio=; h=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V9WAjrXCjqfAgU/bki7Y9rDtHUVhOgYb76C/xGeX1fonh8AHAkTndjR/YkTA0MtEn 76ELdqLKZpAd+nsrsnCmdk/W3qwTtiJhv72CvQ/OV2OfzggeBpWyTIwxLHK6mQmuHL zIa9iMmQQwVgozW9/KRyQuwg++FYpkJw+83t/+y6jmJBJvHTxD08+8gYSg9aMtZQ5r qwn0+tbjvm3oGCEuZ7xs6khtWcOXSSQoFpIIUSSjDiQgWJeUfww5+H0zJH+jPYBOJN 7zDrDZ3cAhPWc/0jKDiyKm8vyXCSM3sGb/MK5k04KiU8tX86++ori1GldDKbbrSYll RdRghLjdbZ8pw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 2A0E8815CA; Mon, 11 May 2026 14:07:43 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id BC135272 for ; Mon, 11 May 2026 14:07:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B972440376 for ; Mon, 11 May 2026 14:07:40 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3iDaOckx7UC2 for ; Mon, 11 May 2026 14:07:39 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.10; helo=mgamail.intel.com; envelope-from=marcin.szycik@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org B731940338 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B731940338 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by smtp2.osuosl.org (Postfix) with ESMTPS id B731940338 for ; Mon, 11 May 2026 14:07:39 +0000 (UTC) X-CSE-ConnectionGUID: cZlBWIcPQ++StnJi5kzQLQ== X-CSE-MsgGUID: kVF78P6RRAavglSdUdbV3w== X-IronPort-AV: E=McAfee;i="6800,10657,11783"; a="90771772" X-IronPort-AV: E=Sophos;i="6.23,229,1770624000"; d="scan'208";a="90771772" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2026 07:07:39 -0700 X-CSE-ConnectionGUID: PLlYoXJtTpGERkyu98UBpA== X-CSE-MsgGUID: yI+5ltMvR5yFY75VvqBZaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,229,1770624000"; d="scan'208";a="267820331" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa002.jf.intel.com with ESMTP; 11 May 2026 07:07:37 -0700 Received: from gond.igk.intel.com (gond.igk.intel.com [10.123.220.52]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 5448C2FC4B; Mon, 11 May 2026 15:07:36 +0100 (IST) From: Marcin Szycik To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, sandeep.penigalapati@intel.com, ananth.s@intel.com, alexander.duyck@gmail.com, Lukasz Czapnik Date: Mon, 11 May 2026 15:07:09 +0200 Message-ID: <20260511130710.38801-11-marcin.szycik@linux.intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260511130710.38801-1-marcin.szycik@linux.intel.com> References: <20260511130710.38801-1-marcin.szycik@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778508459; x=1810044459; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=phRqB6t2RbitombNAaAsoDcdVsrG7LyYYVCbYvuqyw4=; b=dubE0HpMHOblCAMtTYL1x5yRtTm3oOQ0y7oWdpfsgHQAFSFcbdN5+Yja Q4tdBj8ZJumNW77O5Ws2u7FIy5uZ1sKRkf9O4iuJrziUJlJmXHiWQ3SqA JypkPX9VFXm9xBquic7Pzw5GgsoMSbNAWAc3UvNUh/txqck17JgrBeQ// 1tagYe8VTSqToc45jAEMvJuuKoVDQiPFAIQ3oNwfon0FSGC7+YGD/HZyk Yyvbv18KWZiUWN8wbgU0JjJriCSm3zzpyRpAngifWW8Cvynocd27JXxIr jhMFP6C/rz0YZ0W1IvAu4FscPk/Zlryw82fMfawid6ImSHLpcuFX6xCEo g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=dubE0HpM Subject: [Intel-wired-lan] [PATCH iwl-next v3 10/10] ice: use ACL for ntuple rules that conflict with FDir X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Lukasz Czapnik Flow Director can keep only one input set per flow type. After ACL support was added for ethtool ntuple rules, the driver still only selected ACL for rules with partial masks. That leaves a gap for rules with full masks that still require a different input set than the one already programmed for Flow Director. Such rules go through the FDir path, build a different extraction sequence and then fail because the existing FDir profile cannot be reused. Detect this case before programming the rule. Build the candidate IP flow segment, compare it with the active non-tunneled FDir profile and, when the input sets differ, offload the rule through ACL if ACL is available. Refactor the IP flow segment setup into a helper so the same logic can be used both by the extraction-sequence configuration path and by the conflict check. Signed-off-by: Lukasz Czapnik --- v3: * Include flex fields in test_seg to avoid false conflict detection * Skip conflict check early for ETHER_FLOW v2: * Add this patch --- .../ethernet/intel/ice/ice_ethtool_ntuple.c | 168 +++++++++++++----- 1 file changed, 121 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c b/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c index 99ef9059628a..b90f40eb98a4 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c @@ -1400,6 +1400,115 @@ ice_set_fdir_vlan_seg(struct ice_flow_seg_info *seg, return 0; } +/** + * ice_set_fdir_ip_flow_seg - set IP flow segment based on ethtool flow type + * @fsp: pointer to ethtool Rx flow specification + * @seg: flow segment for programming + * @perfect_fltr: valid on success; returns true if perfect fltr, false if not + * + * Return: 0 on success and errno in case of error. + */ +static int ice_set_fdir_ip_flow_seg(struct ethtool_rx_flow_spec *fsp, + struct ice_flow_seg_info *seg, + bool *perfect_fltr) +{ + switch (fsp->flow_type & ~FLOW_EXT) { + case TCP_V4_FLOW: + return ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, + ICE_FLOW_SEG_HDR_TCP, perfect_fltr); + case UDP_V4_FLOW: + return ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, + ICE_FLOW_SEG_HDR_UDP, perfect_fltr); + case SCTP_V4_FLOW: + return ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, + ICE_FLOW_SEG_HDR_SCTP, + perfect_fltr); + case IPV4_USER_FLOW: + return ice_set_fdir_ip4_usr_seg(seg, &fsp->m_u.usr_ip4_spec, + perfect_fltr); + case TCP_V6_FLOW: + return ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, + ICE_FLOW_SEG_HDR_TCP, perfect_fltr); + case UDP_V6_FLOW: + return ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, + ICE_FLOW_SEG_HDR_UDP, perfect_fltr); + case SCTP_V6_FLOW: + return ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, + ICE_FLOW_SEG_HDR_SCTP, + perfect_fltr); + case IPV6_USER_FLOW: + return ice_set_fdir_ip6_usr_seg(seg, &fsp->m_u.usr_ip6_spec, + perfect_fltr); + default: + return -EINVAL; + } +} + +/** + * ice_fdir_has_input_set_conflict - Check conflict with existing FD filters + * @pf: PF structure + * @fsp: pointer to ethtool Rx flow specification + * @user: user-defined data parsed from flow specification + * + * Checks if adding this filter to Flow Director would cause an input set + * mismatch with existing filters for the same flow type by building + * the segment and comparing with existing profiles. + * + * Return: true if there's a conflict (use ACL), false otherwise (can use FD) + */ +static bool +ice_fdir_has_input_set_conflict(struct ice_pf *pf, + struct ethtool_rx_flow_spec *fsp, + const struct ice_rx_flow_userdef *user) +{ + struct ice_flow_seg_info *test_seg, *old_seg; + bool perfect_fltr = false, conflict = false; + struct ice_fd_hw_prof *hw_prof; + struct ice_hw *hw = &pf->hw; + enum ice_fltr_ptype flow; + int err; + + if ((fsp->flow_type & ~FLOW_EXT) == ETHER_FLOW) + return false; + + flow = ice_ethtool_flow_to_fltr(fsp->flow_type & ~FLOW_EXT); + if (flow >= ICE_FLTR_PTYPE_MAX || !hw->fdir_prof || + !hw->fdir_prof[flow]) { + return false; + } + + hw_prof = hw->fdir_prof[flow]; + old_seg = hw_prof->fdir_seg[ICE_FD_HW_SEG_NON_TUN]; + + if (!old_seg || hw->fdir_fltr_cnt[flow] == 0) + return false; + + test_seg = kzalloc_obj(*test_seg); + if (!test_seg) + return false; + + err = ice_set_fdir_ip_flow_seg(fsp, test_seg, &perfect_fltr); + + if (err) { + kfree(test_seg); + return false; + } + + if (user && user->flex_fltr) + ice_flow_add_fld_raw(test_seg, user->flex_offset, + ICE_FLTR_PRGM_FLEX_WORD_SIZE, + ICE_FLOW_FLD_OFF_INVAL, + ICE_FLOW_FLD_OFF_INVAL); + + /* Compare the test segment with the existing segment */ + if (memcmp(old_seg, test_seg, sizeof(*test_seg)) != 0) + conflict = true; + + kfree(test_seg); + + return conflict; +} + /** * ice_cfg_fdir_xtrct_seq - Configure extraction sequence for the given filter * @pf: PF structure @@ -1430,57 +1539,16 @@ ice_cfg_fdir_xtrct_seq(struct ice_pf *pf, struct ethtool_rx_flow_spec *fsp, return -ENOMEM; } - switch (fsp->flow_type & ~FLOW_EXT) { - case TCP_V4_FLOW: - ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, - ICE_FLOW_SEG_HDR_TCP, - &perfect_filter); - break; - case UDP_V4_FLOW: - ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, - ICE_FLOW_SEG_HDR_UDP, - &perfect_filter); - break; - case SCTP_V4_FLOW: - ret = ice_set_fdir_ip4_seg(seg, &fsp->m_u.tcp_ip4_spec, - ICE_FLOW_SEG_HDR_SCTP, - &perfect_filter); - break; - case IPV4_USER_FLOW: - ret = ice_set_fdir_ip4_usr_seg(seg, &fsp->m_u.usr_ip4_spec, - &perfect_filter); - break; - case TCP_V6_FLOW: - ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, - ICE_FLOW_SEG_HDR_TCP, - &perfect_filter); - break; - case UDP_V6_FLOW: - ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, - ICE_FLOW_SEG_HDR_UDP, - &perfect_filter); - break; - case SCTP_V6_FLOW: - ret = ice_set_fdir_ip6_seg(seg, &fsp->m_u.tcp_ip6_spec, - ICE_FLOW_SEG_HDR_SCTP, - &perfect_filter); - break; - case IPV6_USER_FLOW: - ret = ice_set_fdir_ip6_usr_seg(seg, &fsp->m_u.usr_ip6_spec, - &perfect_filter); - break; - case ETHER_FLOW: + if ((fsp->flow_type & ~FLOW_EXT) == ETHER_FLOW) { ret = ice_set_ether_flow_seg(dev, seg, &fsp->m_u.ether_spec); if (!ret && (fsp->m_ext.vlan_etype || fsp->m_ext.vlan_tci)) { - if (!ice_fdir_vlan_valid(dev, fsp)) { + if (!ice_fdir_vlan_valid(dev, fsp)) ret = -EINVAL; - break; - } - ret = ice_set_fdir_vlan_seg(seg, &fsp->m_ext); + else + ret = ice_set_fdir_vlan_seg(seg, &fsp->m_ext); } - break; - default: - ret = -EINVAL; + } else { + ret = ice_set_fdir_ip_flow_seg(fsp, seg, &perfect_filter); } if (ret) goto err_exit; @@ -2215,6 +2283,12 @@ int ice_add_ntuple_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd) if (pf->hw.acl_tbl && ice_is_acl_filter(fsp)) return ice_acl_add_rule_ethtool(vsi, cmd); + /* Check if this would cause input set conflict with existing FD filters + */ + if (pf->hw.acl_tbl && ice_fdir_has_input_set_conflict(pf, fsp, + &userdata)) + return ice_acl_add_rule_ethtool(vsi, cmd); + ret = ice_cfg_fdir_xtrct_seq(pf, fsp, &userdata); if (ret) return ret; -- 2.49.0