From nobody Tue Jun 30 05:29:29 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 427F7C433EF for ; Mon, 24 Jan 2022 17:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244644AbiAXRdE (ORCPT ); Mon, 24 Jan 2022 12:33:04 -0500 Received: from mga02.intel.com ([134.134.136.20]:36486 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244625AbiAXRdB (ORCPT ); Mon, 24 Jan 2022 12:33:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643045581; x=1674581581; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vk8Ctinacbdxy38wRdR0uuN/XLqkpyNoVx7BWthChTM=; b=IBJ7R4YLvgC8eU0jZ+Rp9uHG+59boiihDcGInSsNdERL7PakEUurlW2y FxnExtmYyGk6CBdomO9zabSYJAjBKZqwSUUiLIvmYW9nAYWV0wBmHJLXm dURn1kH9qzkfHpRBoZYjja0RgqxrprJnCVYgTX5qkICCoImA3hcwdUWL3 AHdgAQ4iuZdjrWP/P5KGY0AbBv+V1RfUD+mbrhwE458x1r8QAPEL3qEwg g8IVyGjSQskzKFSuSa7wbL/K/a+YPy6u+zJ3FnLSTw3CGkAEfJyo8qO2Q iSDjfNoOd6DAHfdaOvOfLONg7RqlS4H2w6FTT8+fieBeX11rBPLClFS8G w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="233463923" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="233463923" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 09:33:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="580463170" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga008.fm.intel.com with ESMTP; 24 Jan 2022 09:32:58 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 20OHWuIp010465; Mon, 24 Jan 2022 17:32:57 GMT From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Jesse Brandeburg , Maciej Fijalkowski , Michal Swiatkowski , Martyna Szapar-Mudlaw , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/4] ice: switch: add and use u16[] aliases to ice_adv_lkup_elem::{h,m}_u Date: Mon, 24 Jan 2022 18:31:12 +0100 Message-Id: <20220124173116.739083-2-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124173116.739083-1-alexandr.lobakin@intel.com> References: <20220124173116.739083-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ice_adv_lkup_elem fields h_u and m_u are being accessed as raw u16 arrays in several places. To reduce cast and braces burden, add permanent array-of-u16 aliases with the same size as the `union ice_prot_hdr` itself via anonymous unions to the actual struct declaration, and just access them directly. This: - removes the need to cast the union to u16[] and then dereference it each time -> reduces the horizon for potential bugs; - improves -Warray-bounds coverage -- the array size is now known at compilation time; - addresses cppcheck complaints. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/ice/ice_switch.c | 15 +++++++-------- drivers/net/ethernet/intel/ice/ice_switch.h | 12 ++++++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethe= rnet/intel/ice/ice_switch.c index cda005503052..3056ae85711a 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -5188,12 +5188,12 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem = *lkups, u16 lkups_cnt, * over any significant packet data. */ for (j =3D 0; j < len / sizeof(u16); j++) - if (((u16 *)&lkups[i].m_u)[j]) + if (lkups[i].m_raw[j]) ((u16 *)(pkt + offset))[j] =3D (((u16 *)(pkt + offset))[j] & - ~((u16 *)&lkups[i].m_u)[j]) | - (((u16 *)&lkups[i].h_u)[j] & - ((u16 *)&lkups[i].m_u)[j]); + ~lkups[i].m_raw[j]) | + (lkups[i].h_raw[j] & + lkups[i].m_raw[j]); } =20 s_rule->pdata.lkup_tx_rx.hdr_len =3D cpu_to_le16(pkt_len); @@ -5442,11 +5442,10 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_= lkup_elem *lkups, /* get # of words we need to match */ word_cnt =3D 0; for (i =3D 0; i < lkups_cnt; i++) { - u16 j, *ptr; + u16 j; =20 - ptr =3D (u16 *)&lkups[i].m_u; - for (j =3D 0; j < sizeof(lkups->m_u) / sizeof(u16); j++) - if (ptr[j] !=3D 0) + for (j =3D 0; j < ARRAY_SIZE(lkups->m_raw); j++) + if (lkups[i].m_raw[j]) word_cnt++; } =20 diff --git a/drivers/net/ethernet/intel/ice/ice_switch.h b/drivers/net/ethe= rnet/intel/ice/ice_switch.h index d8334beaaa8a..496c3f160035 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.h +++ b/drivers/net/ethernet/intel/ice/ice_switch.h @@ -127,8 +127,16 @@ struct ice_fltr_info { =20 struct ice_adv_lkup_elem { enum ice_protocol_type type; - union ice_prot_hdr h_u; /* Header values */ - union ice_prot_hdr m_u; /* Mask of header values to match */ + union { + union ice_prot_hdr h_u; /* Header values */ + /* Used to iterate over the headers */ + u16 h_raw[sizeof(union ice_prot_hdr) / sizeof(u16)]; + }; + union { + union ice_prot_hdr m_u; /* Mask of header values to match */ + /* Used to iterate over header mask */ + u16 m_raw[sizeof(union ice_prot_hdr) / sizeof(u16)]; + }; }; =20 struct ice_sw_act_ctrl { --=20 2.34.1 From nobody Tue Jun 30 05:29:29 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C79BC433EF for ; Mon, 24 Jan 2022 17:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244648AbiAXRdK (ORCPT ); Mon, 24 Jan 2022 12:33:10 -0500 Received: from mga05.intel.com ([192.55.52.43]:34775 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244641AbiAXRdE (ORCPT ); Mon, 24 Jan 2022 12:33:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643045584; x=1674581584; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F4h1rZCbd2h5IDu/b6Bx1veFO7oqf0n33MOXfWPn0Gc=; b=SCTOUVpGM2KbPh8GM+bo1h4LebQvzakGhqV6+RHmtL9hIcSCjSjlCioj XIlyRApEywMan5c/BJMcZaCmQkmfpnZpYVWskvG+jjJ0BM7wiyO9Ho8Ei /lQKeiRvQ2PaJbShz9ApqcGBpTYA8b9fFciSQbchqyLO2ahEmAR8CsOZf T4OnJC2DGeowQ5nIiLw73+9oLRXDMddu+GNoq/FocHEG7m9TEsskdvvOl BLY+tfWy0/kwYkhOe/DUfkkRPI3gUbLOpylKQthD0dhoSvoH/u+G5dkke 2B1aFZ5UlfFeXH9bA339MkcqGVOwOnialf0DcBOMSilrLnTJA2YeakYzt Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="332455455" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="332455455" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 09:33:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="624155622" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga002.fm.intel.com with ESMTP; 24 Jan 2022 09:33:01 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 20OHWuIq010465; Mon, 24 Jan 2022 17:32:58 GMT From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Jesse Brandeburg , Maciej Fijalkowski , Michal Swiatkowski , Martyna Szapar-Mudlaw , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/4] ice: switch: unobscurify bitops loop in ice_fill_adv_dummy_packet() Date: Mon, 24 Jan 2022 18:31:13 +0100 Message-Id: <20220124173116.739083-3-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124173116.739083-1-alexandr.lobakin@intel.com> References: <20220124173116.739083-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A loop performing header modification according to the provided mask in ice_fill_adv_dummy_packet() is very cryptic (and error-prone). Replace two identical cast-deferences with a variable. Replace three struct-member-array-accesses with a variable. Invert the condition, reduce the indentation by one -> eliminate line wraps. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/ice/ice_switch.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethe= rnet/intel/ice/ice_switch.c index 3056ae85711a..834ac8eebfaa 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -5187,13 +5187,15 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem = *lkups, u16 lkups_cnt, * indicated by the mask to make sure we don't improperly write * over any significant packet data. */ - for (j =3D 0; j < len / sizeof(u16); j++) - if (lkups[i].m_raw[j]) - ((u16 *)(pkt + offset))[j] =3D - (((u16 *)(pkt + offset))[j] & - ~lkups[i].m_raw[j]) | - (lkups[i].h_raw[j] & - lkups[i].m_raw[j]); + for (j =3D 0; j < len / sizeof(u16); j++) { + u16 *ptr =3D (u16 *)(pkt + offset); + u16 mask =3D lkups[i].m_raw[j]; + + if (!mask) + continue; + + ptr[j] =3D (ptr[j] & ~mask) | (lkups[i].h_raw[j] & mask); + } } =20 s_rule->pdata.lkup_tx_rx.hdr_len =3D cpu_to_le16(pkt_len); --=20 2.34.1 From nobody Tue Jun 30 05:29:29 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F4F7C433EF for ; Mon, 24 Jan 2022 17:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbiAXRdH (ORCPT ); Mon, 24 Jan 2022 12:33:07 -0500 Received: from mga06.intel.com ([134.134.136.31]:39630 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244632AbiAXRdD (ORCPT ); Mon, 24 Jan 2022 12:33:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643045583; x=1674581583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kBJ1SG6vg2SenVTaOJYxd9H3FrALl/x7ebtfa8yZEZU=; b=kH4ohnf+9pjSwH7WG843YUEGr/gTr+t6wLgc/1LRsmWBrd5bmLRVcs2m GYqhlAQftGPsmCqZ65ZztXTqJ/ENkwEiT+ZKyp6o5LTj/edroQGlxrVn8 owZ0WAflJhRQvrNUdxIT+Xjh5qE37AGzOzHBY6SuiqSfgz0U5kFQuAaZM Vc6NllLWzuAqq/A2hkiizK8Qx3uqbboJ06xRKJdMv8/nLQSbvAN8f4Kvp PLYvD7G8lPMV9v9zOjafzhf3TR5Z8dn3EWOXB6aLMNjayL/W8nftRZOUY 8Y1auJGH8sPxqs5HFWQU519DFldy4LA/TvN0If3T0RS7Uoyt82iV7hP01 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="306815722" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="306815722" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 09:33:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="617323792" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jan 2022 09:32:59 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 20OHWuIr010465; Mon, 24 Jan 2022 17:32:58 GMT From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Jesse Brandeburg , Maciej Fijalkowski , Michal Swiatkowski , Martyna Szapar-Mudlaw , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/4] ice: switch: use a struct to pass packet template params Date: Mon, 24 Jan 2022 18:31:14 +0100 Message-Id: <20220124173116.739083-4-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124173116.739083-1-alexandr.lobakin@intel.com> References: <20220124173116.739083-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ice_find_dummy_packet() contains a lot of boilerplate code and a nice room for copy-paste mistakes. Instead of passing 3 separate pointers back and forth to get packet template (dummy) params, directly return a structure containing them. Then, use a macro to compose compound literals and avoid code duplication on return path. Now, dummy packet type/name is needed only once to return a full correct triple pkt-pkt_len-offsets, and those are all one-liners. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/ice/ice_switch.c | 164 +++++++------------- 1 file changed, 59 insertions(+), 105 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethe= rnet/intel/ice/ice_switch.c index 834ac8eebfaa..557b45f660ea 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -35,6 +35,20 @@ struct ice_dummy_pkt_offsets { u16 offset; /* ICE_PROTOCOL_LAST indicates end of list */ }; =20 +struct ice_dummy_pkt_profile { + const struct ice_dummy_pkt_offsets *offsets; + const u8 *pkt; + u16 pkt_len; +}; + +#define ICE_PKT_PROFILE(type) ({ \ + (struct ice_dummy_pkt_profile){ \ + .pkt =3D dummy_##type##_packet, \ + .pkt_len =3D sizeof(dummy_##type##_packet), \ + .offsets =3D dummy_##type##_packet_offsets, \ + }; \ +}) + static const struct ice_dummy_pkt_offsets dummy_gre_tcp_packet_offsets[] = =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, @@ -4960,11 +4974,9 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv= _lkup_elem *lkups, * @pkt_len: packet length of dummy packet * @offsets: pointer to receive the pointer to the offsets for the packet */ -static void +static struct ice_dummy_pkt_profile ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, - enum ice_sw_tunnel_type tun_type, - const u8 **pkt, u16 *pkt_len, - const struct ice_dummy_pkt_offsets **offsets) + enum ice_sw_tunnel_type tun_type) { bool tcp =3D false, udp =3D false, ipv6 =3D false, vlan =3D false; bool ipv6_il =3D false; @@ -4994,100 +5006,49 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lk= ups, u16 lkups_cnt, } =20 if (tun_type =3D=3D ICE_SW_TUN_NVGRE) { - if (tcp && ipv6_il) { - *pkt =3D dummy_gre_ipv6_tcp_packet; - *pkt_len =3D sizeof(dummy_gre_ipv6_tcp_packet); - *offsets =3D dummy_gre_ipv6_tcp_packet_offsets; - return; - } - if (tcp) { - *pkt =3D dummy_gre_tcp_packet; - *pkt_len =3D sizeof(dummy_gre_tcp_packet); - *offsets =3D dummy_gre_tcp_packet_offsets; - return; - } - if (ipv6_il) { - *pkt =3D dummy_gre_ipv6_udp_packet; - *pkt_len =3D sizeof(dummy_gre_ipv6_udp_packet); - *offsets =3D dummy_gre_ipv6_udp_packet_offsets; - return; - } - *pkt =3D dummy_gre_udp_packet; - *pkt_len =3D sizeof(dummy_gre_udp_packet); - *offsets =3D dummy_gre_udp_packet_offsets; - return; + if (tcp && ipv6_il) + return ICE_PKT_PROFILE(gre_ipv6_tcp); + else if (tcp) + return ICE_PKT_PROFILE(gre_tcp); + else if (ipv6_il) + return ICE_PKT_PROFILE(gre_ipv6_udp); + else + return ICE_PKT_PROFILE(gre_udp); } =20 if (tun_type =3D=3D ICE_SW_TUN_VXLAN || tun_type =3D=3D ICE_SW_TUN_GENEVE) { - if (tcp && ipv6_il) { - *pkt =3D dummy_udp_tun_ipv6_tcp_packet; - *pkt_len =3D sizeof(dummy_udp_tun_ipv6_tcp_packet); - *offsets =3D dummy_udp_tun_ipv6_tcp_packet_offsets; - return; - } - if (tcp) { - *pkt =3D dummy_udp_tun_tcp_packet; - *pkt_len =3D sizeof(dummy_udp_tun_tcp_packet); - *offsets =3D dummy_udp_tun_tcp_packet_offsets; - return; - } - if (ipv6_il) { - *pkt =3D dummy_udp_tun_ipv6_udp_packet; - *pkt_len =3D sizeof(dummy_udp_tun_ipv6_udp_packet); - *offsets =3D dummy_udp_tun_ipv6_udp_packet_offsets; - return; - } - *pkt =3D dummy_udp_tun_udp_packet; - *pkt_len =3D sizeof(dummy_udp_tun_udp_packet); - *offsets =3D dummy_udp_tun_udp_packet_offsets; - return; + if (tcp && ipv6_il) + return ICE_PKT_PROFILE(udp_tun_ipv6_tcp); + else if (tcp) + return ICE_PKT_PROFILE(udp_tun_tcp); + else if (ipv6_il) + return ICE_PKT_PROFILE(udp_tun_ipv6_udp); + else + return ICE_PKT_PROFILE(udp_tun_udp); } =20 if (udp && !ipv6) { - if (vlan) { - *pkt =3D dummy_vlan_udp_packet; - *pkt_len =3D sizeof(dummy_vlan_udp_packet); - *offsets =3D dummy_vlan_udp_packet_offsets; - return; - } - *pkt =3D dummy_udp_packet; - *pkt_len =3D sizeof(dummy_udp_packet); - *offsets =3D dummy_udp_packet_offsets; - return; + if (vlan) + return ICE_PKT_PROFILE(vlan_udp); + else + return ICE_PKT_PROFILE(udp); } else if (udp && ipv6) { - if (vlan) { - *pkt =3D dummy_vlan_udp_ipv6_packet; - *pkt_len =3D sizeof(dummy_vlan_udp_ipv6_packet); - *offsets =3D dummy_vlan_udp_ipv6_packet_offsets; - return; - } - *pkt =3D dummy_udp_ipv6_packet; - *pkt_len =3D sizeof(dummy_udp_ipv6_packet); - *offsets =3D dummy_udp_ipv6_packet_offsets; - return; + if (vlan) + return ICE_PKT_PROFILE(vlan_udp_ipv6); + else + return ICE_PKT_PROFILE(udp_ipv6); } else if ((tcp && ipv6) || ipv6) { - if (vlan) { - *pkt =3D dummy_vlan_tcp_ipv6_packet; - *pkt_len =3D sizeof(dummy_vlan_tcp_ipv6_packet); - *offsets =3D dummy_vlan_tcp_ipv6_packet_offsets; - return; - } - *pkt =3D dummy_tcp_ipv6_packet; - *pkt_len =3D sizeof(dummy_tcp_ipv6_packet); - *offsets =3D dummy_tcp_ipv6_packet_offsets; - return; + if (vlan) + return ICE_PKT_PROFILE(vlan_tcp_ipv6); + else + return ICE_PKT_PROFILE(tcp_ipv6); } =20 - if (vlan) { - *pkt =3D dummy_vlan_tcp_packet; - *pkt_len =3D sizeof(dummy_vlan_tcp_packet); - *offsets =3D dummy_vlan_tcp_packet_offsets; - } else { - *pkt =3D dummy_tcp_packet; - *pkt_len =3D sizeof(dummy_tcp_packet); - *offsets =3D dummy_tcp_packet_offsets; - } + if (vlan) + return ICE_PKT_PROFILE(vlan_tcp); + + return ICE_PKT_PROFILE(tcp); } =20 /** @@ -5104,8 +5065,7 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups= , u16 lkups_cnt, static int ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, struct ice_aqc_sw_rules_elem *s_rule, - const u8 *dummy_pkt, u16 pkt_len, - const struct ice_dummy_pkt_offsets *offsets) + const struct ice_dummy_pkt_profile *profile) { u8 *pkt; u16 i; @@ -5115,9 +5075,10 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *= lkups, u16 lkups_cnt, */ pkt =3D s_rule->pdata.lkup_tx_rx.hdr; =20 - memcpy(pkt, dummy_pkt, pkt_len); + memcpy(pkt, profile->pkt, profile->pkt_len); =20 for (i =3D 0; i < lkups_cnt; i++) { + const struct ice_dummy_pkt_offsets *offsets =3D profile->offsets; enum ice_protocol_type type; u16 offset =3D 0, len =3D 0, j; bool found =3D false; @@ -5198,7 +5159,7 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *l= kups, u16 lkups_cnt, } } =20 - s_rule->pdata.lkup_tx_rx.hdr_len =3D cpu_to_le16(pkt_len); + s_rule->pdata.lkup_tx_rx.hdr_len =3D cpu_to_le16(profile->pkt_len); =20 return 0; } @@ -5421,12 +5382,11 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_= lkup_elem *lkups, struct ice_rule_query_data *added_entry) { struct ice_adv_fltr_mgmt_list_entry *m_entry, *adv_fltr =3D NULL; - u16 rid =3D 0, i, pkt_len, rule_buf_sz, vsi_handle; - const struct ice_dummy_pkt_offsets *pkt_offsets; struct ice_aqc_sw_rules_elem *s_rule =3D NULL; + u16 rid =3D 0, i, rule_buf_sz, vsi_handle; + struct ice_dummy_pkt_profile profile; struct list_head *rule_head; struct ice_switch_info *sw; - const u8 *pkt =3D NULL; u16 word_cnt; u32 act =3D 0; int status; @@ -5454,13 +5414,8 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_l= kup_elem *lkups, if (!word_cnt || word_cnt > ICE_MAX_CHAIN_WORDS) return -EINVAL; =20 - /* make sure that we can locate a dummy packet */ - ice_find_dummy_packet(lkups, lkups_cnt, rinfo->tun_type, &pkt, &pkt_len, - &pkt_offsets); - if (!pkt) { - status =3D -EINVAL; - goto err_ice_add_adv_rule; - } + /* locate a dummy packet */ + profile =3D ice_find_dummy_packet(lkups, lkups_cnt, rinfo->tun_type); =20 if (!(rinfo->sw_act.fltr_act =3D=3D ICE_FWD_TO_VSI || rinfo->sw_act.fltr_act =3D=3D ICE_FWD_TO_Q || @@ -5501,7 +5456,7 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lk= up_elem *lkups, } return status; } - rule_buf_sz =3D ICE_SW_RULE_RX_TX_NO_HDR_SIZE + pkt_len; + rule_buf_sz =3D ICE_SW_RULE_RX_TX_NO_HDR_SIZE + profile.pkt_len; s_rule =3D kzalloc(rule_buf_sz, GFP_KERNEL); if (!s_rule) return -ENOMEM; @@ -5561,15 +5516,14 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_= lkup_elem *lkups, s_rule->pdata.lkup_tx_rx.recipe_id =3D cpu_to_le16(rid); s_rule->pdata.lkup_tx_rx.act =3D cpu_to_le32(act); =20 - status =3D ice_fill_adv_dummy_packet(lkups, lkups_cnt, s_rule, pkt, - pkt_len, pkt_offsets); + status =3D ice_fill_adv_dummy_packet(lkups, lkups_cnt, s_rule, &profile); if (status) goto err_ice_add_adv_rule; =20 if (rinfo->tun_type !=3D ICE_NON_TUN) { status =3D ice_fill_adv_packet_tun(hw, rinfo->tun_type, s_rule->pdata.lkup_tx_rx.hdr, - pkt_offsets); + profile.offsets); if (status) goto err_ice_add_adv_rule; } --=20 2.34.1 From nobody Tue Jun 30 05:29:29 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C45CC433EF for ; Mon, 24 Jan 2022 17:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244715AbiAXRdZ (ORCPT ); Mon, 24 Jan 2022 12:33:25 -0500 Received: from mga17.intel.com ([192.55.52.151]:16093 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244667AbiAXRdS (ORCPT ); Mon, 24 Jan 2022 12:33:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643045597; x=1674581597; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gCeImJKbrgw9VI8s/j6tZwCq2OiZ54ak/rjb6IbQbG0=; b=iGV3s8ko1R4A2ZG9grCIcUp55KjgcuO0fhnrsOqTSaWOSYA0jLm7qRBB VbJ+zST7Y1wTt+AQAYqPbT0JjfT+IXwOaeq+u9Oho2U5XA18GXS8CaAgO wwi8mRMdZjmQZFwEoVvDLccmVXCRcQrPujH+DA3DAbpa5N7/rIFGK6hJR hr2sCdFueeISOstT88uYjh7wqgiiksFsnWSTLeqkgFcRa6DO4oi+3ZjjF tfJ//ujwJZ475x5fIvWbdZp0z1S8RVjrpTVTGHGcC5QhMwyp/de/6LHgz ng7r0R6Cu/cmzbC+r/dSCv6hFeSqp5bJOsw8awDh9bcGHMFakv6eaKR00 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226773823" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226773823" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 09:33:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="520030865" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga007.jf.intel.com with ESMTP; 24 Jan 2022 09:33:00 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 20OHWuIs010465; Mon, 24 Jan 2022 17:32:59 GMT From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Jesse Brandeburg , Maciej Fijalkowski , Michal Swiatkowski , Martyna Szapar-Mudlaw , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/4] ice: switch: use convenience macros to declare dummy pkt templates Date: Mon, 24 Jan 2022 18:31:15 +0100 Message-Id: <20220124173116.739083-5-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124173116.739083-1-alexandr.lobakin@intel.com> References: <20220124173116.739083-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Declarations of dummy/template packet headers and offsets can be minified to improve readability and simplify adding new templates. Move all the repetitive constructions into two macros and let them do the name and type expansions. Linewrap removal is yet another positive side effect. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/ice/ice_switch.c | 83 +++++++++++---------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethe= rnet/intel/ice/ice_switch.c index 557b45f660ea..a892298bb243 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -41,15 +41,22 @@ struct ice_dummy_pkt_profile { u16 pkt_len; }; =20 +#define ICE_PKT_OFFSETS(type) \ + static const struct ice_dummy_pkt_offsets \ + ice_dummy_##type##_packet_offsets[] + +#define ICE_PKT_TEMPLATE(type) \ + static const u8 ice_dummy_##type##_packet[] + #define ICE_PKT_PROFILE(type) ({ \ (struct ice_dummy_pkt_profile){ \ - .pkt =3D dummy_##type##_packet, \ - .pkt_len =3D sizeof(dummy_##type##_packet), \ - .offsets =3D dummy_##type##_packet_offsets, \ + .pkt =3D ice_dummy_##type##_packet, \ + .pkt_len =3D sizeof(ice_dummy_##type##_packet), \ + .offsets =3D ice_dummy_##type##_packet_offsets, \ }; \ }) =20 -static const struct ice_dummy_pkt_offsets dummy_gre_tcp_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(gre_tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -61,7 +68,7 @@ static const struct ice_dummy_pkt_offsets dummy_gre_tcp_p= acket_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_gre_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(gre_tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -96,7 +103,7 @@ static const u8 dummy_gre_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00 }; =20 -static const struct ice_dummy_pkt_offsets dummy_gre_udp_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(gre_udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -108,7 +115,7 @@ static const struct ice_dummy_pkt_offsets dummy_gre_udp= _packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_gre_udp_packet[] =3D { +ICE_PKT_TEMPLATE(gre_udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -140,7 +147,7 @@ static const u8 dummy_gre_udp_packet[] =3D { 0x00, 0x08, 0x00, 0x00, }; =20 -static const struct ice_dummy_pkt_offsets dummy_udp_tun_tcp_packet_offsets= [] =3D { +ICE_PKT_OFFSETS(udp_tun_tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -155,7 +162,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_tun= _tcp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_udp_tun_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(udp_tun_tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -193,7 +200,7 @@ static const u8 dummy_udp_tun_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00 }; =20 -static const struct ice_dummy_pkt_offsets dummy_udp_tun_udp_packet_offsets= [] =3D { +ICE_PKT_OFFSETS(udp_tun_udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -208,7 +215,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_tun= _udp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_udp_tun_udp_packet[] =3D { +ICE_PKT_TEMPLATE(udp_tun_udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -243,8 +250,7 @@ static const u8 dummy_udp_tun_udp_packet[] =3D { 0x00, 0x08, 0x00, 0x00, }; =20 -static const struct ice_dummy_pkt_offsets -dummy_gre_ipv6_tcp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(gre_ipv6_tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -256,7 +262,7 @@ dummy_gre_ipv6_tcp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_gre_ipv6_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(gre_ipv6_tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -296,8 +302,7 @@ static const u8 dummy_gre_ipv6_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00 }; =20 -static const struct ice_dummy_pkt_offsets -dummy_gre_ipv6_udp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(gre_ipv6_udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -309,7 +314,7 @@ dummy_gre_ipv6_udp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_gre_ipv6_udp_packet[] =3D { +ICE_PKT_TEMPLATE(gre_ipv6_udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -346,8 +351,7 @@ static const u8 dummy_gre_ipv6_udp_packet[] =3D { 0x00, 0x08, 0x00, 0x00, }; =20 -static const struct ice_dummy_pkt_offsets -dummy_udp_tun_ipv6_tcp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(udp_tun_ipv6_tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -362,7 +366,7 @@ dummy_udp_tun_ipv6_tcp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_udp_tun_ipv6_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(udp_tun_ipv6_tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -405,8 +409,7 @@ static const u8 dummy_udp_tun_ipv6_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00 }; =20 -static const struct ice_dummy_pkt_offsets -dummy_udp_tun_ipv6_udp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(udp_tun_ipv6_udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -421,7 +424,7 @@ dummy_udp_tun_ipv6_udp_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_udp_tun_ipv6_udp_packet[] =3D { +ICE_PKT_TEMPLATE(udp_tun_ipv6_udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -462,7 +465,7 @@ static const u8 dummy_udp_tun_ipv6_udp_packet[] =3D { }; =20 /* offset info for MAC + IPv4 + UDP dummy packet */ -static const struct ice_dummy_pkt_offsets dummy_udp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -471,7 +474,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_pac= ket_offsets[] =3D { }; =20 /* Dummy packet for MAC + IPv4 + UDP */ -static const u8 dummy_udp_packet[] =3D { +ICE_PKT_TEMPLATE(udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -491,7 +494,7 @@ static const u8 dummy_udp_packet[] =3D { }; =20 /* offset info for MAC + VLAN + IPv4 + UDP dummy packet */ -static const struct ice_dummy_pkt_offsets dummy_vlan_udp_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(vlan_udp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_VLAN_OFOS, 12 }, { ICE_ETYPE_OL, 16 }, @@ -501,7 +504,7 @@ static const struct ice_dummy_pkt_offsets dummy_vlan_ud= p_packet_offsets[] =3D { }; =20 /* C-tag (801.1Q), IPv4:UDP dummy packet */ -static const u8 dummy_vlan_udp_packet[] =3D { +ICE_PKT_TEMPLATE(vlan_udp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -523,7 +526,7 @@ static const u8 dummy_vlan_udp_packet[] =3D { }; =20 /* offset info for MAC + IPv4 + TCP dummy packet */ -static const struct ice_dummy_pkt_offsets dummy_tcp_packet_offsets[] =3D { +ICE_PKT_OFFSETS(tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV4_OFOS, 14 }, @@ -532,7 +535,7 @@ static const struct ice_dummy_pkt_offsets dummy_tcp_pac= ket_offsets[] =3D { }; =20 /* Dummy packet for MAC + IPv4 + TCP */ -static const u8 dummy_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -555,7 +558,7 @@ static const u8 dummy_tcp_packet[] =3D { }; =20 /* offset info for MAC + VLAN (C-tag, 802.1Q) + IPv4 + TCP dummy packet */ -static const struct ice_dummy_pkt_offsets dummy_vlan_tcp_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(vlan_tcp) =3D { { ICE_MAC_OFOS, 0 }, { ICE_VLAN_OFOS, 12 }, { ICE_ETYPE_OL, 16 }, @@ -565,7 +568,7 @@ static const struct ice_dummy_pkt_offsets dummy_vlan_tc= p_packet_offsets[] =3D { }; =20 /* C-tag (801.1Q), IPv4:TCP dummy packet */ -static const u8 dummy_vlan_tcp_packet[] =3D { +ICE_PKT_TEMPLATE(vlan_tcp) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -589,7 +592,7 @@ static const u8 dummy_vlan_tcp_packet[] =3D { 0x00, 0x00, /* 2 bytes for 4 byte alignment */ }; =20 -static const struct ice_dummy_pkt_offsets dummy_tcp_ipv6_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(tcp_ipv6) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV6_OFOS, 14 }, @@ -597,7 +600,7 @@ static const struct ice_dummy_pkt_offsets dummy_tcp_ipv= 6_packet_offsets[] =3D { { ICE_PROTOCOL_LAST, 0 }, }; =20 -static const u8 dummy_tcp_ipv6_packet[] =3D { +ICE_PKT_TEMPLATE(tcp_ipv6) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -625,8 +628,7 @@ static const u8 dummy_tcp_ipv6_packet[] =3D { }; =20 /* C-tag (802.1Q): IPv6 + TCP */ -static const struct ice_dummy_pkt_offsets -dummy_vlan_tcp_ipv6_packet_offsets[] =3D { +ICE_PKT_OFFSETS(vlan_tcp_ipv6) =3D { { ICE_MAC_OFOS, 0 }, { ICE_VLAN_OFOS, 12 }, { ICE_ETYPE_OL, 16 }, @@ -636,7 +638,7 @@ dummy_vlan_tcp_ipv6_packet_offsets[] =3D { }; =20 /* C-tag (802.1Q), IPv6 + TCP dummy packet */ -static const u8 dummy_vlan_tcp_ipv6_packet[] =3D { +ICE_PKT_TEMPLATE(vlan_tcp_ipv6) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -666,7 +668,7 @@ static const u8 dummy_vlan_tcp_ipv6_packet[] =3D { }; =20 /* IPv6 + UDP */ -static const struct ice_dummy_pkt_offsets dummy_udp_ipv6_packet_offsets[] = =3D { +ICE_PKT_OFFSETS(udp_ipv6) =3D { { ICE_MAC_OFOS, 0 }, { ICE_ETYPE_OL, 12 }, { ICE_IPV6_OFOS, 14 }, @@ -675,7 +677,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_ipv= 6_packet_offsets[] =3D { }; =20 /* IPv6 + UDP dummy packet */ -static const u8 dummy_udp_ipv6_packet[] =3D { +ICE_PKT_TEMPLATE(udp_ipv6) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -703,8 +705,7 @@ static const u8 dummy_udp_ipv6_packet[] =3D { }; =20 /* C-tag (802.1Q): IPv6 + UDP */ -static const struct ice_dummy_pkt_offsets -dummy_vlan_udp_ipv6_packet_offsets[] =3D { +ICE_PKT_OFFSETS(vlan_udp_ipv6) =3D { { ICE_MAC_OFOS, 0 }, { ICE_VLAN_OFOS, 12 }, { ICE_ETYPE_OL, 16 }, @@ -714,7 +715,7 @@ dummy_vlan_udp_ipv6_packet_offsets[] =3D { }; =20 /* C-tag (802.1Q), IPv6 + UDP dummy packet */ -static const u8 dummy_vlan_udp_ipv6_packet[] =3D { +ICE_PKT_TEMPLATE(vlan_udp_ipv6) =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, --=20 2.34.1 From nobody Tue Jun 30 05:29:29 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 139B0C433F5 for ; Mon, 24 Jan 2022 17:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244653AbiAXRd2 (ORCPT ); Mon, 24 Jan 2022 12:33:28 -0500 Received: from mga17.intel.com ([192.55.52.151]:16093 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244671AbiAXRdU (ORCPT ); Mon, 24 Jan 2022 12:33:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643045600; x=1674581600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gZqimtRzu5wF1fDqE5G7NopEsGNpcEmrpuiOvwmSMjI=; b=fG25Q/TOur5dh722ZsfAsErd8+SoqVCirXdjX32dOCmnl2uNkIBR3dwX dvGVDYpMp77V2hPwdW7iWCBIA9ToKnH2CgiuYpRMMYpBudPW8Kr/xMK98 b4BvUU8rvPjwwgjzfN8PZP6U7CfVO7xV6kWqw4X3cAvZmScRZ96gV7Vst eFRU7f90Q8AsBxHioPi9D4GJSuxJxanebSKjfaJ2EKW9oPE0cc6MhQ/lR jKEIwQW+B5gaiiskthsi7SNjlWGSRht1WzC0/dFV3GNeBLJhcd900C0je oyjHkq71r5G+LxRGUHtF/fDAw1rFyeK/ErihbOv1V3qdMBmP62lVhEY9b A==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226773831" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226773831" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 09:33:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="520030867" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga007.jf.intel.com with ESMTP; 24 Jan 2022 09:33:01 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 20OHWuIt010465; Mon, 24 Jan 2022 17:33:00 GMT From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Jesse Brandeburg , Maciej Fijalkowski , Michal Swiatkowski , Martyna Szapar-Mudlaw , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: ice: Add support for inner etype in switchdev Date: Mon, 24 Jan 2022 18:31:16 +0100 Message-Id: <20220124173116.739083-6-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124173116.739083-1-alexandr.lobakin@intel.com> References: <20220124173116.739083-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Martyna Szapar-Mudlaw Enable support for adding TC rules that filter on the inner EtherType field of tunneled packet headers. Signed-off-by: Martyna Szapar-Mudlaw Reviewed-by: Alexander Lobakin --- drivers/net/ethernet/intel/ice/ice_protocol_type.h | 2 + drivers/net/ethernet/intel/ice/ice_switch.c | 272 +++++++++++++++++= +++- drivers/net/ethernet/intel/ice/ice_tc_lib.c | 15 +- 3 files changed, 277 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_protocol_type.h b/drivers/n= et/ethernet/intel/ice/ice_protocol_type.h index 695b6dd61dc27..385deaa021acb 100644 --- a/drivers/net/ethernet/intel/ice/ice_protocol_type.h +++ b/drivers/net/ethernet/intel/ice/ice_protocol_type.h @@ -29,6 +29,7 @@ enum ice_protocol_type { ICE_MAC_OFOS =3D 0, ICE_MAC_IL, ICE_ETYPE_OL, + ICE_ETYPE_IL, ICE_VLAN_OFOS, ICE_IPV4_OFOS, ICE_IPV4_IL, @@ -92,6 +93,7 @@ enum ice_prot_id { #define ICE_MAC_OFOS_HW 1 #define ICE_MAC_IL_HW 4 #define ICE_ETYPE_OL_HW 9 +#define ICE_ETYPE_IL_HW 10 #define ICE_VLAN_OF_HW 16 #define ICE_VLAN_OL_HW 17 #define ICE_IPV4_OFOS_HW 32 diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethe= rnet/intel/ice/ice_switch.c index 9c40a8d58c715..d98aa35c03377 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -41,6 +41,7 @@ static const struct ice_dummy_pkt_offsets dummy_gre_tcp_p= acket_offsets[] =3D { { ICE_IPV4_OFOS, 14 }, { ICE_NVGRE, 34 }, { ICE_MAC_IL, 42 }, + { ICE_ETYPE_IL, 54 }, { ICE_IPV4_IL, 56 }, { ICE_TCP_IL, 76 }, { ICE_PROTOCOL_LAST, 0 }, @@ -65,7 +66,8 @@ static const u8 dummy_gre_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_IL 54 */ =20 0x45, 0x00, 0x00, 0x14, /* ICE_IPV4_IL 56 */ 0x00, 0x00, 0x00, 0x00, @@ -86,6 +88,7 @@ static const struct ice_dummy_pkt_offsets dummy_gre_udp_p= acket_offsets[] =3D { { ICE_IPV4_OFOS, 14 }, { ICE_NVGRE, 34 }, { ICE_MAC_IL, 42 }, + { ICE_ETYPE_IL, 54 }, { ICE_IPV4_IL, 56 }, { ICE_UDP_ILOS, 76 }, { ICE_PROTOCOL_LAST, 0 }, @@ -110,7 +113,8 @@ static const u8 dummy_gre_udp_packet[] =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_IL 54 */ =20 0x45, 0x00, 0x00, 0x14, /* ICE_IPV4_IL 56 */ 0x00, 0x00, 0x00, 0x00, @@ -131,6 +135,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_tun= _tcp_packet_offsets[] =3D { { ICE_GENEVE, 42 }, { ICE_VXLAN_GPE, 42 }, { ICE_MAC_IL, 50 }, + { ICE_ETYPE_IL, 62 }, { ICE_IPV4_IL, 64 }, { ICE_TCP_IL, 84 }, { ICE_PROTOCOL_LAST, 0 }, @@ -158,7 +163,8 @@ static const u8 dummy_udp_tun_tcp_packet[] =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_IL 62 */ =20 0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_IL 64 */ 0x00, 0x01, 0x00, 0x00, @@ -182,6 +188,7 @@ static const struct ice_dummy_pkt_offsets dummy_udp_tun= _udp_packet_offsets[] =3D { { ICE_GENEVE, 42 }, { ICE_VXLAN_GPE, 42 }, { ICE_MAC_IL, 50 }, + { ICE_ETYPE_IL, 62 }, { ICE_IPV4_IL, 64 }, { ICE_UDP_ILOS, 84 }, { ICE_PROTOCOL_LAST, 0 }, @@ -209,7 +216,8 @@ static const u8 dummy_udp_tun_udp_packet[] =3D { 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_IL 62 */ =20 0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_IL 64 */ 0x00, 0x01, 0x00, 0x00, @@ -221,6 +229,224 @@ static const u8 dummy_udp_tun_udp_packet[] =3D { 0x00, 0x08, 0x00, 0x00, }; =20 +static const struct ice_dummy_pkt_offsets +dummy_gre_ipv6_tcp_packet_offsets[] =3D { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_NVGRE, 34 }, + { ICE_MAC_IL, 42 }, + { ICE_ETYPE_IL, 54 }, + { ICE_IPV6_IL, 56 }, + { ICE_TCP_IL, 96 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_gre_ipv6_tcp_packet[] =3D { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x66, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x2F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x80, 0x00, 0x65, 0x58, /* ICE_NVGRE 34 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x86, 0xdd, /* ICE_ETYPE_IL 54 */ + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 56 */ + 0x00, 0x08, 0x06, 0x40, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 96 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x50, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +static const struct ice_dummy_pkt_offsets +dummy_gre_ipv6_udp_packet_offsets[] =3D { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_NVGRE, 34 }, + { ICE_MAC_IL, 42 }, + { ICE_ETYPE_IL, 54 }, + { ICE_IPV6_IL, 56 }, + { ICE_UDP_ILOS, 96 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_gre_ipv6_udp_packet[] =3D { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x5a, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x2F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x80, 0x00, 0x65, 0x58, /* ICE_NVGRE 34 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x86, 0xdd, /* ICE_ETYPE_IL 54 */ + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 56 */ + 0x00, 0x08, 0x11, 0x40, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 96 */ + 0x00, 0x08, 0x00, 0x00, +}; + +static const struct ice_dummy_pkt_offsets +dummy_udp_tun_ipv6_tcp_packet_offsets[] =3D { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_UDP_OF, 34 }, + { ICE_VXLAN, 42 }, + { ICE_GENEVE, 42 }, + { ICE_VXLAN_GPE, 42 }, + { ICE_MAC_IL, 50 }, + { ICE_ETYPE_IL, 62 }, + { ICE_IPV6_IL, 64 }, + { ICE_TCP_IL, 104 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_udp_tun_ipv6_tcp_packet[] =3D { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x6e, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x01, 0x00, 0x00, + 0x40, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */ + 0x00, 0x5a, 0x00, 0x00, + + 0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x86, 0xdd, /* ICE_ETYPE_IL 62 */ + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */ + 0x00, 0x08, 0x06, 0x40, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 104 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x50, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +static const struct ice_dummy_pkt_offsets +dummy_udp_tun_ipv6_udp_packet_offsets[] =3D { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_UDP_OF, 34 }, + { ICE_VXLAN, 42 }, + { ICE_GENEVE, 42 }, + { ICE_VXLAN_GPE, 42 }, + { ICE_MAC_IL, 50 }, + { ICE_ETYPE_IL, 62 }, + { ICE_IPV6_IL, 64 }, + { ICE_UDP_ILOS, 104 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_udp_tun_ipv6_udp_packet[] =3D { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x62, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */ + 0x00, 0x4e, 0x00, 0x00, + + 0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x86, 0xdd, /* ICE_ETYPE_IL 62 */ + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */ + 0x00, 0x08, 0x11, 0x40, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 104 */ + 0x00, 0x08, 0x00, 0x00, +}; + /* offset info for MAC + IPv4 + UDP dummy packet */ static const struct ice_dummy_pkt_offsets dummy_udp_packet_offsets[] =3D { { ICE_MAC_OFOS, 0 }, @@ -3818,6 +4044,7 @@ static const struct ice_prot_ext_tbl_entry ice_prot_e= xt[ICE_PROTOCOL_LAST] =3D { { ICE_MAC_OFOS, { 0, 2, 4, 6, 8, 10, 12 } }, { ICE_MAC_IL, { 0, 2, 4, 6, 8, 10, 12 } }, { ICE_ETYPE_OL, { 0 } }, + { ICE_ETYPE_IL, { 0 } }, { ICE_VLAN_OFOS, { 2, 0 } }, { ICE_IPV4_OFOS, { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 } }, { ICE_IPV4_IL, { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 } }, @@ -3837,6 +4064,7 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_= PROTOCOL_LAST] =3D { { ICE_MAC_OFOS, ICE_MAC_OFOS_HW }, { ICE_MAC_IL, ICE_MAC_IL_HW }, { ICE_ETYPE_OL, ICE_ETYPE_OL_HW }, + { ICE_ETYPE_IL, ICE_ETYPE_IL_HW }, { ICE_VLAN_OFOS, ICE_VLAN_OL_HW }, { ICE_IPV4_OFOS, ICE_IPV4_OFOS_HW }, { ICE_IPV4_IL, ICE_IPV4_IL_HW }, @@ -4818,6 +5046,7 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups= , u16 lkups_cnt, const struct ice_dummy_pkt_offsets **offsets) { bool tcp =3D false, udp =3D false, ipv6 =3D false, vlan =3D false; + bool ipv6_il =3D false; u16 i; =20 for (i =3D 0; i < lkups_cnt; i++) { @@ -4833,18 +5062,35 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lku= ps, u16 lkups_cnt, lkups[i].h_u.ethertype.ethtype_id =3D=3D cpu_to_be16(ICE_IPV6_ETHER_ID) && lkups[i].m_u.ethertype.ethtype_id =3D=3D - cpu_to_be16(0xFFFF)) + cpu_to_be16(0xFFFF)) ipv6 =3D true; + else if (lkups[i].type =3D=3D ICE_ETYPE_IL && + lkups[i].h_u.ethertype.ethtype_id =3D=3D + cpu_to_be16(ICE_IPV6_ETHER_ID) && + lkups[i].m_u.ethertype.ethtype_id =3D=3D + cpu_to_be16(0xFFFF)) + ipv6_il =3D true; } =20 if (tun_type =3D=3D ICE_SW_TUN_NVGRE) { + if (tcp && ipv6_il) { + *pkt =3D dummy_gre_ipv6_tcp_packet; + *pkt_len =3D sizeof(dummy_gre_ipv6_tcp_packet); + *offsets =3D dummy_gre_ipv6_tcp_packet_offsets; + return; + } if (tcp) { *pkt =3D dummy_gre_tcp_packet; *pkt_len =3D sizeof(dummy_gre_tcp_packet); *offsets =3D dummy_gre_tcp_packet_offsets; return; } - + if (ipv6_il) { + *pkt =3D dummy_gre_ipv6_udp_packet; + *pkt_len =3D sizeof(dummy_gre_ipv6_udp_packet); + *offsets =3D dummy_gre_ipv6_udp_packet_offsets; + return; + } *pkt =3D dummy_gre_udp_packet; *pkt_len =3D sizeof(dummy_gre_udp_packet); *offsets =3D dummy_gre_udp_packet_offsets; @@ -4853,13 +5099,24 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lku= ps, u16 lkups_cnt, =20 if (tun_type =3D=3D ICE_SW_TUN_VXLAN || tun_type =3D=3D ICE_SW_TUN_GENEVE) { + if (tcp && ipv6_il) { + *pkt =3D dummy_udp_tun_ipv6_tcp_packet; + *pkt_len =3D sizeof(dummy_udp_tun_ipv6_tcp_packet); + *offsets =3D dummy_udp_tun_ipv6_tcp_packet_offsets; + return; + } if (tcp) { *pkt =3D dummy_udp_tun_tcp_packet; *pkt_len =3D sizeof(dummy_udp_tun_tcp_packet); *offsets =3D dummy_udp_tun_tcp_packet_offsets; return; } - + if (ipv6_il) { + *pkt =3D dummy_udp_tun_ipv6_udp_packet; + *pkt_len =3D sizeof(dummy_udp_tun_ipv6_udp_packet); + *offsets =3D dummy_udp_tun_ipv6_udp_packet_offsets; + return; + } *pkt =3D dummy_udp_tun_udp_packet; *pkt_len =3D sizeof(dummy_udp_tun_udp_packet); *offsets =3D dummy_udp_tun_udp_packet_offsets; @@ -4965,6 +5222,7 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *l= kups, u16 lkups_cnt, len =3D sizeof(struct ice_ether_hdr); break; case ICE_ETYPE_OL: + case ICE_ETYPE_IL: len =3D sizeof(struct ice_ethtype_hdr); break; case ICE_VLAN_OFOS: diff --git a/drivers/net/ethernet/intel/ice/ice_tc_lib.c b/drivers/net/ethe= rnet/intel/ice/ice_tc_lib.c index 65cf32eb40466..424c74ca7d693 100644 --- a/drivers/net/ethernet/intel/ice/ice_tc_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_tc_lib.c @@ -33,9 +33,7 @@ ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_= 4_hdrs *headers, if (flags & ICE_TC_FLWR_FIELD_ENC_DEST_L4_PORT) lkups_cnt++; =20 - /* currently inner etype filter isn't supported */ - if ((flags & ICE_TC_FLWR_FIELD_ETH_TYPE_ID) && - fltr->tunnel_type =3D=3D TNL_LAST) + if (flags & ICE_TC_FLWR_FIELD_ETH_TYPE_ID) lkups_cnt++; =20 /* are MAC fields specified? */ @@ -64,6 +62,11 @@ static enum ice_protocol_type ice_proto_type_from_mac(bo= ol inner) return inner ? ICE_MAC_IL : ICE_MAC_OFOS; } =20 +static enum ice_protocol_type ice_proto_type_from_etype(bool inner) +{ + return inner ? ICE_ETYPE_IL : ICE_ETYPE_OL; +} + static enum ice_protocol_type ice_proto_type_from_ipv4(bool inner) { return inner ? ICE_IPV4_IL : ICE_IPV4_OFOS; @@ -224,8 +227,10 @@ ice_tc_fill_rules(struct ice_hw *hw, u32 flags, =20 headers =3D &tc_fltr->inner_headers; inner =3D true; - } else if (flags & ICE_TC_FLWR_FIELD_ETH_TYPE_ID) { - list[i].type =3D ICE_ETYPE_OL; + } + + if (flags & ICE_TC_FLWR_FIELD_ETH_TYPE_ID) { + list[i].type =3D ice_proto_type_from_etype(inner); list[i].h_u.ethertype.ethtype_id =3D headers->l2_key.n_proto; list[i].m_u.ethertype.ethtype_id =3D headers->l2_mask.n_proto; i++; --=20 cgit 1.2.3-1.el7