From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1A9FA0C43; Tue, 13 Jul 2021 04:35:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B65740DDE; Tue, 13 Jul 2021 04:35:41 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 09EA24069E for ; Tue, 13 Jul 2021 04:35:39 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10043"; a="207069218" X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="207069218" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 19:35:37 -0700 X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="561955424" Received: from shwdenpg235.ccr.corp.intel.com ([10.253.106.22]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 19:35:36 -0700 From: Alvin Zhang To: qi.z.zhang@intel.com Cc: dev@dpdk.org, Alvin Zhang Date: Tue, 13 Jul 2021 10:35:30 +0800 Message-Id: <20210713023530.1732-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20210329054923.11424-1-alvinx.zhang@intel.com> References: <20210329054923.11424-1-alvinx.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] net/ice/base: support MPLS ethertype switch filter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add MPLS training packet and offsets. Add check to identify MPLS ethertype filters. For example: testpmd> flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 \ type is 0x8847 / end actions queue index 2 / end This flow will result in all the matched ingress packets be forwarded to queue 2. Signed-off-by: Alvin Zhang --- drivers/net/ice/base/ice_switch.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 229b355..5926635 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -16,6 +16,7 @@ #define ICE_TCP_PROTO_ID 0x06 #define ICE_GTPU_PROFILE 24 #define ICE_ETH_P_8021Q 0x8100 +#define ICE_MPLS_ETHER_ID 0x8847 /* Dummy ethernet header needed in the ice_aqc_sw_rules_elem * struct to configure any switch filter rules. @@ -320,6 +321,25 @@ struct ice_dummy_pkt_offsets { 0x00, 0x00, /* 2 bytes for 4 byte alignment */ }; +/* offset info for MAC + MPLS dummy packet */ +static const struct ice_dummy_pkt_offsets dummy_mpls_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +/* Dummy packet for MAC + MPLS */ +static const u8 dummy_mpls_packet[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x88, 0x47, /* ICE_ETYPE_OL 12 */ + 0x00, 0x00, 0x01, 0x00, + + 0x00, 0x00, /* 2 bytes for 4 byte alignment */ +}; + /* 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[] = { { ICE_MAC_OFOS, 0 }, @@ -7857,7 +7877,7 @@ bool ice_is_prof_rule(enum ice_sw_tunnel_type type) const struct ice_dummy_pkt_offsets **offsets) { bool tcp = false, udp = false, ipv6 = false, vlan = false; - bool gre = false; + bool gre = false, mpls = false; u16 i; for (i = 0; i < lkups_cnt; i++) { @@ -7893,6 +7913,11 @@ bool ice_is_prof_rule(enum ice_sw_tunnel_type type) lkups[i].m_u.ipv4_hdr.protocol == 0xFF) tcp = true; + else if (lkups[i].type == ICE_ETYPE_OL && + lkups[i].h_u.ethertype.ethtype_id == + CPU_TO_BE16(ICE_MPLS_ETHER_ID) && + lkups[i].m_u.ethertype.ethtype_id == 0xFFFF) + mpls = true; } if ((tun_type == ICE_SW_TUN_AND_NON_TUN_QINQ || @@ -8263,6 +8288,10 @@ bool ice_is_prof_rule(enum ice_sw_tunnel_type type) *pkt = dummy_vlan_tcp_packet; *pkt_len = sizeof(dummy_vlan_tcp_packet); *offsets = dummy_vlan_tcp_packet_offsets; + } else if (mpls) { + *pkt = dummy_mpls_packet; + *pkt_len = sizeof(dummy_mpls_packet); + *offsets = dummy_mpls_packet_offsets; } else { *pkt = dummy_tcp_packet; *pkt_len = sizeof(dummy_tcp_packet); -- 1.8.3.1