From patchwork Fri Mar 12 09:31:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 88996 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D30D7A0547; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D2A71607ED; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 340E24067E for ; Fri, 12 Mar 2021 10:31:49 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id C8BF07F530; Fri, 12 Mar 2021 12:31:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru C8BF07F530 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541508; bh=lcLB1YnvdclFFkeJB0nSQzYMYyUi/Hj0+//nve4jL3w=; h=From:To:Cc:Subject:Date; b=WfRzMOu0JzNjcJp2urFGwyv2bH3eRbCxYOcHcQZerpXv4aO8fw4ucHSbplyA0gfC7 k3dqUbe6jhVYEDNkfhIIlNf6R7zcqYMzDwU6bomW4NckVwg9/PejqTYx1XffV2brYr j+mhcRYvKEo4WohhBFXHr5px0Vb2zjydTJ2Meaq4= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ori Kam , Thomas Monjalon , Ferruh Yigit Date: Fri, 12 Mar 2021 12:31:34 +0300 Message-Id: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 01/10] ethdev: reuse header definition in flow pattern item ETH 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" One ought to reuse existing header structs in flow items. This particular item contains non-header fields, so it's important to keep the header fields in a separate struct. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton Acked-by: Ori Kam --- lib/librte_ethdev/rte_flow.h | 44 ++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 669e677e9..96fd93ee1 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -728,22 +728,32 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * * Matches an Ethernet header. * - * The @p type field either stands for "EtherType" or "TPID" when followed - * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In - * the latter case, @p type refers to that of the outer header, with the - * inner EtherType/TPID provided by the subsequent pattern item. This is the - * same order as on the wire. - * If the @p type field contains a TPID value, then only tagged packets with the - * specified TPID will match the pattern. - * The field @p has_vlan can be used to match any type of tagged packets, - * instead of using the @p type field. - * If the @p type and @p has_vlan fields are not specified, then both tagged - * and untagged packets will match the pattern. + * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType + * or TPID, depending on whether the item is followed by a VLAN item or not. If + * two VLAN items follow, the sub-field refers to the outer one, which, in turn, + * contains the inner TPID in the similar header field. The innermost VLAN item + * contains a layer-3 EtherType. All of that follows the order seen on the wire. + * + * If the field in question contains a TPID value, only tagged packets with the + * specified TPID will match the pattern. Alternatively, it's possible to match + * any type of tagged packets by means of the field @p has_vlan rather than use + * the EtherType/TPID field. Also, it's possible to leave the two fields unused. + * If this is the case, both tagged and untagged packets will match the pattern. */ +RTE_STD_C11 struct rte_flow_item_eth { - struct rte_ether_addr dst; /**< Destination MAC. */ - struct rte_ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType or TPID. */ + union { + struct { + /* + * These fields are retained for compatibility. + * Please switch to the new header field below. + */ + struct rte_ether_addr dst; /**< Destination MAC. */ + struct rte_ether_addr src; /**< Source MAC. */ + rte_be16_t type; /**< EtherType or TPID. */ + }; + struct rte_ether_hdr hdr; + }; uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */ uint32_t reserved:31; /**< Reserved, must be zero. */ }; @@ -751,9 +761,9 @@ struct rte_flow_item_eth { /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplus static const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", - .src.addr_bytes = "\xff\xff\xff\xff\xff\xff", - .type = RTE_BE16(0x0000), + .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.ether_type = RTE_BE16(0x0000), }; #endif From patchwork Fri Mar 12 09:31:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 88997 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7431FA0547; Fri, 12 Mar 2021 10:31:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7E44716084D; Fri, 12 Mar 2021 10:31:51 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 593A01607ED for ; Fri, 12 Mar 2021 10:31:49 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 0DC0D7F540; Fri, 12 Mar 2021 12:31:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 0DC0D7F540 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541509; bh=FamZGMlRHqddOq750auHdvKrK0nFyaJ91v6ar4PfG5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FO3mAx5PdHnKlleNux3a4UWkIeVSTJhiBql5ScjdM1kPvlacDWVeMaEtcS3VjJax3 Nws8qYCmTBP0gD+A11XzENv6klZ9dO/jnCwYrVHugxVYwO5eu0G4vkOqxCsI5oIPve cA8Mah7QgbiAhagsAXrdpdyH4Dk2O5KBsCI2+NKE= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ori Kam , Thomas Monjalon , Ferruh Yigit Date: Fri, 12 Mar 2021 12:31:35 +0300 Message-Id: <20210312093143.28186-2-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 02/10] ethdev: reuse header definition in flow pattern item VLAN 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" One ought to reuse existing header structs in flow items. This particular item contains non-header fields, so it's important to keep the header fields in a separate struct. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton Acked-by: Ori Kam --- lib/librte_ethdev/rte_flow.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 96fd93ee1..b9b349669 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -778,13 +778,23 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * If a @p VLAN item is present in the pattern, then only tagged packets will * match the pattern. * The field @p has_more_vlan can be used to match any type of tagged packets, - * instead of using the @p inner_type field. - * If the @p inner_type and @p has_more_vlan fields are not specified, + * instead of using the @p eth_proto field of @p hdr. + * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified, * then any tagged packets will match the pattern. */ +RTE_STD_C11 struct rte_flow_item_vlan { - rte_be16_t tci; /**< Tag control information. */ - rte_be16_t inner_type; /**< Inner EtherType or TPID. */ + union { + struct { + /* + * These fields are retained for compatibility. + * Please switch to the new header field below. + */ + rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ + }; + struct rte_vlan_hdr hdr; + }; uint32_t has_more_vlan:1; /**< Packet header contains at least one more VLAN, after this VLAN. */ uint32_t reserved:31; /**< Reserved, must be zero. */ @@ -793,8 +803,8 @@ struct rte_flow_item_vlan { /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tci = RTE_BE16(0x0fff), - .inner_type = RTE_BE16(0x0000), + .hdr.vlan_tci = RTE_BE16(0x0fff), + .hdr.eth_proto = RTE_BE16(0x0000), }; #endif From patchwork Fri Mar 12 09:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 88998 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 94741A0547; Fri, 12 Mar 2021 10:32:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE92A16085B; Fri, 12 Mar 2021 10:31:52 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 9150D4067E for ; Fri, 12 Mar 2021 10:31:49 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 4EE2A7F578; Fri, 12 Mar 2021 12:31:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 4EE2A7F578 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541509; bh=5xruwNVl02NgzTYUzEgdqaK9Hfp5FFuZPK13esraQKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GEr2ZNiO96siGrhsDqNQGz2hDBzg0FJ8k82jhLmv2pNTpO4XldL863HA7RADpmf7N Z8wu4aTHjuy9geyJg9yEQg4z8QUK64jf0OnomN7fw+Oz2YdAUpJViN7vTyxaZ9ryaj yCErK5G4lkOtQBLwqqSflBNx6xlmd+QnKe0nddOo= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Olivier Matz Date: Fri, 12 Mar 2021 12:31:36 +0300 Message-Id: <20210312093143.28186-3-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 03/10] net: clarify endianness of 32-bit fields in VXLAN headers 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" These fields have network byte order. Highlight it using dedicated type. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- lib/librte_net/rte_vxlan.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/librte_net/rte_vxlan.h b/lib/librte_net/rte_vxlan.h index 2ad606165..929fa7a1d 100644 --- a/lib/librte_net/rte_vxlan.h +++ b/lib/librte_net/rte_vxlan.h @@ -13,6 +13,7 @@ #include +#include #include @@ -30,8 +31,8 @@ extern "C" { * Reserved fields (24 bits and 8 bits) */ struct rte_vxlan_hdr { - uint32_t vx_flags; /**< flag (8) + Reserved (24). */ - uint32_t vx_vni; /**< VNI (24) + Reserved (8). */ + rte_be32_t vx_flags; /**< flag (8) + Reserved (24). */ + rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */ } __rte_packed; /** VXLAN tunnel header length. */ @@ -48,7 +49,7 @@ struct rte_vxlan_gpe_hdr { uint8_t vx_flags; /**< flag (8). */ uint8_t reserved[2]; /**< Reserved (16). */ uint8_t proto; /**< next-protocol (8). */ - uint32_t vx_vni; /**< VNI (24) + Reserved (8). */ + rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */ } __rte_packed; /** VXLAN-GPE tunnel header length. */ From patchwork Fri Mar 12 09:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 88999 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0114A0547; Fri, 12 Mar 2021 10:32:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 049FE160867; Fri, 12 Mar 2021 10:31:54 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id CB8CB1607ED for ; Fri, 12 Mar 2021 10:31:49 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 89E007F589; Fri, 12 Mar 2021 12:31:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 89E007F589 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541509; bh=eYwOpT2ykv6yFIDdbERLa5d1DceF+zGU4Rd9V88f1Jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GZyLCZU92GApMki9h109NgELEXnMpx30mVyH6R3MqIiKArah/9tGpaSrOrU8ACBsQ a76Wgn9G89oEVExy3XZxALJPTBnjeJXF4oRHsdYGziUj8F4UwU53jj1IsZsFf+AIF/ ZxCua5baeGCgLVJ+6T4U1dU3gGn4iE0iBf/AQqHU= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ori Kam , Thomas Monjalon , Ferruh Yigit Date: Fri, 12 Mar 2021 12:31:37 +0300 Message-Id: <20210312093143.28186-4-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 04/10] ethdev: reuse header definition in flow pattern item VXLAN 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" One ought to reuse existing header structs in flow items. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- lib/librte_ethdev/rte_flow.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index b9b349669..56c97829c 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -954,18 +955,31 @@ static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = { * RTE_FLOW_ITEM_TYPE_VXLAN. * * Matches a VXLAN header (RFC 7348). + * + * Fields @p flags, @p rsvd0, @p vni and @rsvd1 are left here for compatibility. + * Consumers of this item definition are encouraged to use field @p hdr instead. */ +RTE_STD_C11 struct rte_flow_item_vxlan { - uint8_t flags; /**< Normally 0x08 (I flag). */ - uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */ - uint8_t vni[3]; /**< VXLAN identifier. */ - uint8_t rsvd1; /**< Reserved, normally 0x00. */ + union { + struct { + /* + * These fields are retained for compatibility. + * Please switch to the new header field below. + */ + uint8_t flags; /**< Normally 0x08 (I flag). */ + uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */ + uint8_t vni[3]; /**< VXLAN identifier. */ + uint8_t rsvd1; /**< Reserved, normally 0x00. */ + }; + struct rte_vxlan_hdr hdr; + }; }; /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .vni = "\xff\xff\xff", + .hdr.vx_vni = RTE_BE32(__builtin_constant_p(0xffffff << 8)), }; #endif From patchwork Fri Mar 12 09:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89000 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C6F0FA0547; Fri, 12 Mar 2021 10:32:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47CA0160873; Fri, 12 Mar 2021 10:31:55 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1DD0F4067E for ; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id C5D5E7F5AA; Fri, 12 Mar 2021 12:31:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru C5D5E7F5AA DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541509; bh=YQH7nHiEa4z0tFavWNtLIcJ0gJKdYBL6Axw/gdPbdks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=puwEfCQIgvC1k4IEx2gtTs6JCV4KGj06jeWmmLkJ9mSYU6CG6Uo7ORuIdQZWYgqt5 yojFWpN03MOEnSg9RiAL3NXdWqXWBt/kqGM9I+pKNbp9jtrPypb1R3MAnxtYaerHSk MiVz41xACCN/XxnzZ0LlZd+p5Ql3LtSD6XwvWXjs= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ray Kinsella , Neil Horman Date: Fri, 12 Mar 2021 12:31:38 +0300 Message-Id: <20210312093143.28186-5-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 05/10] common/sfc_efx/base: support encap. header provisioning 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" Let the client allocate / free encap. headers. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 21 ++++ drivers/common/sfc_efx/base/efx_mae.c | 155 ++++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 2 + 3 files changed, 178 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index ccf9c7ab8..4a738e589 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4070,6 +4070,7 @@ typedef struct efx_mae_limits_s { uint32_t eml_max_n_action_prios; uint32_t eml_max_n_outer_prios; uint32_t eml_encap_types_supported; + uint32_t eml_encap_header_size_limit; } efx_mae_limits_t; LIBEFX_API @@ -4324,6 +4325,26 @@ efx_mae_match_spec_outer_rule_id_set( __in efx_mae_match_spec_t *spec, __in const efx_mae_rule_id_t *or_idp); +/* Encap. header ID */ +typedef struct efx_mae_eh_id_s { + uint32_t id; +} efx_mae_eh_id_t; + +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_encap_header_alloc( + __in efx_nic_t *enp, + __in efx_tunnel_protocol_t encap_type, + __in_bcount(header_size) uint8_t *header_data, + __in size_t header_size, + __out efx_mae_eh_id_t *eh_idp); + +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_encap_header_free( + __in efx_nic_t *enp, + __in const efx_mae_eh_id_t *eh_idp); + /* Action set ID */ typedef struct efx_mae_aset_id_s { uint32_t id; diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 338a0013f..798867963 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -353,6 +353,8 @@ efx_mae_get_limits( emlp->eml_max_n_outer_prios = maep->em_max_n_outer_prios; emlp->eml_max_n_action_prios = maep->em_max_n_action_prios; emlp->eml_encap_types_supported = maep->em_encap_types_supported; + emlp->eml_encap_header_size_limit = + MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2; return (0); @@ -1691,6 +1693,159 @@ efx_mae_match_spec_outer_rule_id_set( return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_mae_encap_header_alloc( + __in efx_nic_t *enp, + __in efx_tunnel_protocol_t encap_type, + __in_bcount(header_size) uint8_t *header_data, + __in size_t header_size, + __out efx_mae_eh_id_t *eh_idp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_LENMAX_MCDI2, + MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN); + uint32_t encap_type_mcdi; + efx_mae_eh_id_t eh_id; + efx_rc_t rc; + + EFX_STATIC_ASSERT(sizeof (eh_idp->id) == + MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_LEN); + + EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID == + MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_NULL); + + if (encp->enc_mae_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + switch (encap_type) { + case EFX_TUNNEL_PROTOCOL_NONE: + encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NONE; + break; + case EFX_TUNNEL_PROTOCOL_VXLAN: + encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_VXLAN; + break; + case EFX_TUNNEL_PROTOCOL_GENEVE: + encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_GENEVE; + break; + case EFX_TUNNEL_PROTOCOL_NVGRE: + encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NVGRE; + break; + default: + rc = ENOTSUP; + goto fail2; + } + + if (header_size > + MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2) { + rc = EINVAL; + goto fail3; + } + + req.emr_cmd = MC_CMD_MAE_ENCAP_HEADER_ALLOC; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_LEN(header_size); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN; + + MCDI_IN_SET_DWORD(req, + MAE_ENCAP_HEADER_ALLOC_IN_ENCAP_TYPE, encap_type_mcdi); + + memcpy(payload + MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_OFST, + header_data, header_size); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail4; + } + + if (req.emr_out_length_used < MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN) { + rc = EMSGSIZE; + goto fail5; + } + + eh_id.id = MCDI_OUT_DWORD(req, + MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID); + + if (eh_id.id == EFX_MAE_RSRC_ID_INVALID) { + rc = ENOENT; + goto fail6; + } + + eh_idp->id = eh_id.id; + + return (0); + +fail6: + EFSYS_PROBE(fail6); +fail5: + EFSYS_PROBE(fail5); +fail4: + EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_mae_encap_header_free( + __in efx_nic_t *enp, + __in const efx_mae_eh_id_t *eh_idp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_MAE_ENCAP_HEADER_FREE_IN_LEN(1), + MC_CMD_MAE_ENCAP_HEADER_FREE_OUT_LEN(1)); + efx_rc_t rc; + + if (encp->enc_mae_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + req.emr_cmd = MC_CMD_MAE_ENCAP_HEADER_FREE; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_MAE_ENCAP_HEADER_FREE_IN_LEN(1); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_MAE_ENCAP_HEADER_FREE_OUT_LEN(1); + + MCDI_IN_SET_DWORD(req, MAE_ENCAP_HEADER_FREE_IN_EH_ID, eh_idp->id); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail2; + } + + if (MCDI_OUT_DWORD(req, MAE_ENCAP_HEADER_FREE_OUT_FREED_EH_ID) != + eh_idp->id) { + /* Firmware failed to remove the encap. header. */ + rc = EAGAIN; + goto fail3; + } + + return (0); + fail3: EFSYS_PROBE(fail3); fail2: diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 403feeaf1..168899d51 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -98,6 +98,8 @@ INTERNAL { efx_mae_action_set_spec_fini; efx_mae_action_set_spec_init; efx_mae_action_set_specs_equal; + efx_mae_encap_header_alloc; + efx_mae_encap_header_free; efx_mae_fini; efx_mae_get_limits; efx_mae_init; From patchwork Fri Mar 12 09:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89001 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F1E9A0547; Fri, 12 Mar 2021 10:32:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77B8E16087B; Fri, 12 Mar 2021 10:31:56 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 690D61607EE for ; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 118527F5AB; Fri, 12 Mar 2021 12:31:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 118527F5AB DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541510; bh=eLbcKi5t5dU77ct6iQRmTzxKGAEq8Bu6aJlGTmMbsG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WUT7XHr55ev1ULL1TMBjvc51tbQNVkD+dPmPgdqwwSf2gPT0wYBQXGwewfrM9+KIq /3excS/ohC7Fkiab6bJMc6b1BG7VHvJDzn/dvY1vADpBDeZSykt2yhyweGy032gXVw k+SJvlPcZNS+3SIBFexasB2Xk4K5a3UMkA+rgzYk= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ray Kinsella , Neil Horman Date: Fri, 12 Mar 2021 12:31:39 +0300 Message-Id: <20210312093143.28186-6-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 06/10] common/sfc_efx/base: support adding action ENCAP to a set 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" For convenience, there are two separate APIs provided, one for adding the action and one for setting the encap. header ID. This design allows the client driver to first build the action set specification (which validates the order of the actions) and, if everything is correct, proceed with allocation of the resource utilised by the action set (encap. header). This facilitates clarity of the client code and its efficiency. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 16 ++++ drivers/common/sfc_efx/base/efx_impl.h | 12 +++ drivers/common/sfc_efx/base/efx_mae.c | 126 ++++++++++++++++++++++++- drivers/common/sfc_efx/version.map | 2 + 4 files changed, 153 insertions(+), 3 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 4a738e589..052946aa3 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4252,6 +4252,15 @@ efx_mae_action_set_populate_vlan_push( __in uint16_t tpid_be, __in uint16_t tci_be); +/* + * Use efx_mae_action_set_fill_in_eh_id() to set ID of the allocated + * encap. header in the specification prior to action set allocation. + */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_populate_encap( + __in efx_mae_actions_t *spec); + LIBEFX_API extern __checkReturn efx_rc_t efx_mae_action_set_populate_flag( @@ -4345,6 +4354,13 @@ efx_mae_encap_header_free( __in efx_nic_t *enp, __in const efx_mae_eh_id_t *eh_idp); +/* See description before efx_mae_action_set_populate_encap(). */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_fill_in_eh_id( + __in efx_mae_actions_t *spec, + __in const efx_mae_eh_id_t *eh_idp); + /* Action set ID */ typedef struct efx_mae_aset_id_s { uint32_t id; diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 1005dd0aa..0adf43c26 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1709,6 +1709,7 @@ typedef enum efx_mae_action_e { /* These actions are strictly ordered. */ EFX_MAE_ACTION_VLAN_POP, EFX_MAE_ACTION_VLAN_PUSH, + EFX_MAE_ACTION_ENCAP, /* * These actions are not strictly ordered and can @@ -1736,6 +1737,10 @@ typedef struct efx_mae_action_vlan_push_s { uint16_t emavp_tci_be; } efx_mae_action_vlan_push_t; +typedef struct efx_mae_actions_rsrc_s { + efx_mae_eh_id_t emar_eh_id; +} efx_mae_actions_rsrc_t; + struct efx_mae_actions_s { /* Bitmap of actions in spec, indexed by action type */ uint32_t ema_actions; @@ -1746,6 +1751,13 @@ struct efx_mae_actions_s { EFX_MAE_VLAN_PUSH_MAX_NTAGS]; uint32_t ema_mark_value; efx_mport_sel_t ema_deliver_mport; + + /* + * Always keep this at the end of the struct since + * efx_mae_action_set_specs_equal() relies on that + * to make sure that resource IDs are not compared. + */ + efx_mae_actions_rsrc_t ema_rsrc; }; #endif /* EFSYS_OPT_MAE */ diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 798867963..896500de0 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -994,6 +994,8 @@ efx_mae_action_set_spec_init( goto fail1; } + spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID; + *specp = spec; return (0); @@ -1085,6 +1087,50 @@ efx_mae_action_set_add_vlan_push( return (rc); } +static __checkReturn efx_rc_t +efx_mae_action_set_add_encap( + __in efx_mae_actions_t *spec, + __in size_t arg_size, + __in_bcount(arg_size) const uint8_t *arg) +{ + efx_rc_t rc; + + /* + * Adding this specific action to an action set spec and setting encap. + * header ID in the spec are two individual steps. This design allows + * the client driver to avoid encap. header allocation when it simply + * needs to check the order of actions submitted by user ("validate"), + * without actually allocating an action set and inserting a rule. + * + * For now, mark encap. header ID as invalid; the caller will invoke + * efx_mae_action_set_fill_in_eh_id() to override the field prior + * to action set allocation; otherwise, the allocation will fail. + */ + spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID; + + /* + * As explained above, there are no arguments to handle here. + * efx_mae_action_set_fill_in_eh_id() will take care of them. + */ + if (arg_size != 0) { + rc = EINVAL; + goto fail1; + } + + if (arg != NULL) { + rc = EINVAL; + goto fail2; + } + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + static __checkReturn efx_rc_t efx_mae_action_set_add_flag( __in efx_mae_actions_t *spec, @@ -1187,6 +1233,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { [EFX_MAE_ACTION_VLAN_PUSH] = { .emad_add = efx_mae_action_set_add_vlan_push }, + [EFX_MAE_ACTION_ENCAP] = { + .emad_add = efx_mae_action_set_add_encap + }, [EFX_MAE_ACTION_FLAG] = { .emad_add = efx_mae_action_set_add_flag }, @@ -1201,6 +1250,7 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { static const uint32_t efx_mae_action_ordered_map = (1U << EFX_MAE_ACTION_VLAN_POP) | (1U << EFX_MAE_ACTION_VLAN_PUSH) | + (1U << EFX_MAE_ACTION_ENCAP) | (1U << EFX_MAE_ACTION_FLAG) | (1U << EFX_MAE_ACTION_MARK) | (1U << EFX_MAE_ACTION_DELIVER); @@ -1317,6 +1367,20 @@ efx_mae_action_set_populate_vlan_push( EFX_MAE_ACTION_VLAN_PUSH, sizeof (action), arg)); } + __checkReturn efx_rc_t +efx_mae_action_set_populate_encap( + __in efx_mae_actions_t *spec) +{ + /* + * There is no argument to pass encap. header ID, thus, one does not + * need to allocate an encap. header while parsing application input. + * This is useful since building an action set may be done simply to + * validate a rule, whilst resource allocation usually consumes time. + */ + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_ENCAP, 0, NULL)); +} + __checkReturn efx_rc_t efx_mae_action_set_populate_flag( __in efx_mae_actions_t *spec) @@ -1389,7 +1453,22 @@ efx_mae_action_set_specs_equal( __in const efx_mae_actions_t *left, __in const efx_mae_actions_t *right) { - return ((memcmp(left, right, sizeof (*left)) == 0) ? B_TRUE : B_FALSE); + size_t cmp_size = EFX_FIELD_OFFSET(efx_mae_actions_t, ema_rsrc); + + /* + * An action set specification consists of two parts. The first part + * indicates what actions are included in the action set, as well as + * extra quantitative values (in example, the number of VLAN tags to + * push). The second part comprises resource IDs used by the actions. + * + * A resource, in example, a counter, is allocated from the hardware + * by the client, and it's the client who is responsible for keeping + * track of allocated resources and comparing resource IDs if needed. + * + * In this API, don't compare resource IDs in the two specifications. + */ + + return ((memcmp(left, right, cmp_size) == 0) ? B_TRUE : B_FALSE); } __checkReturn efx_rc_t @@ -1846,6 +1925,46 @@ efx_mae_encap_header_free( return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_mae_action_set_fill_in_eh_id( + __in efx_mae_actions_t *spec, + __in const efx_mae_eh_id_t *eh_idp) +{ + efx_rc_t rc; + + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_ENCAP)) == 0) { + /* + * The caller has not intended to have action ENCAP originally, + * hence, this attempt to indicate encap. header ID is invalid. + */ + rc = EINVAL; + goto fail1; + } + + if (spec->ema_rsrc.emar_eh_id.id != EFX_MAE_RSRC_ID_INVALID) { + /* The caller attempts to indicate encap. header ID twice. */ + rc = EINVAL; + goto fail2; + } + + if (eh_idp->id == EFX_MAE_RSRC_ID_INVALID) { + rc = EINVAL; + goto fail3; + } + + spec->ema_rsrc.emar_eh_id.id = eh_idp->id; + + return (0); + fail3: EFSYS_PROBE(fail3); fail2: @@ -1889,8 +2008,6 @@ efx_mae_action_set_alloc( MAE_ACTION_SET_ALLOC_IN_COUNTER_LIST_ID, EFX_MAE_RSRC_ID_INVALID); MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_COUNTER_ID, EFX_MAE_RSRC_ID_INVALID); - MCDI_IN_SET_DWORD(req, - MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID, EFX_MAE_RSRC_ID_INVALID); MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop); @@ -1920,6 +2037,9 @@ efx_mae_action_set_alloc( spec->ema_vlan_push_descs[outer_tag_idx].emavp_tci_be); } + MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID, + spec->ema_rsrc.emar_eh_id.id); + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_FLAG)) != 0) { MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, MAE_ACTION_SET_ALLOC_IN_FLAG, 1); diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 168899d51..f33a2a08e 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -88,9 +88,11 @@ INTERNAL { efx_mae_action_rule_insert; efx_mae_action_rule_remove; efx_mae_action_set_alloc; + efx_mae_action_set_fill_in_eh_id; efx_mae_action_set_free; efx_mae_action_set_populate_deliver; efx_mae_action_set_populate_drop; + efx_mae_action_set_populate_encap; efx_mae_action_set_populate_flag; efx_mae_action_set_populate_mark; efx_mae_action_set_populate_vlan_pop; From patchwork Fri Mar 12 09:31:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89002 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F988A0547; Fri, 12 Mar 2021 10:32:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA0EC160883; Fri, 12 Mar 2021 10:31:57 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id A3F79160846 for ; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 57F527F5AE; Fri, 12 Mar 2021 12:31:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 57F527F5AE DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541510; bh=B+EfaYfS/EkgWEFMcaSOjKk6Pki4UHrjU8rMr1R2jjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CylHS8nA1liczrWWsLp+st0XA8P61CHAX5arA6RI7yGbxjIibFJPbOh5FHzsv+HiC EMsrYoEkFHZIKdMf7qDhEa/bNIxRub5Ov20/mjYsbSzavtCDYOFt5wAX3+yDgU5Q9S obfE5CheRTUYPBaGH1ofjXmj2Ozrq8l2L3NGAGKI= From: Ivan Malov To: dev@dpdk.org Cc: Igor Romanov , Andrew Rybchenko , Andy Moreton Date: Fri, 12 Mar 2021 12:31:40 +0300 Message-Id: <20210312093143.28186-7-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 07/10] net/sfc: change MAE rule actions parse API 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" From: Igor Romanov Current API signature makes it hard to add other entities that belong to a flow specification. Pass the flow specification so that additional members can be accessed through the spec. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ivan Malov --- drivers/net/sfc/sfc_flow.c | 3 +-- drivers/net/sfc/sfc_mae.c | 8 ++++---- drivers/net/sfc/sfc_mae.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index ab1d2cc59..2c78473b5 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -2440,8 +2440,7 @@ sfc_flow_parse_rte_to_mae(struct rte_eth_dev *dev, if (rc != 0) return rc; - rc = sfc_mae_rule_parse_actions(sa, actions, &spec_mae->action_set, - error); + rc = sfc_mae_rule_parse_actions(sa, actions, spec_mae, error); if (rc != 0) return rc; diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 15c5c3975..50efd47ad 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -2093,7 +2093,7 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, int sfc_mae_rule_parse_actions(struct sfc_adapter *sa, const struct rte_flow_action actions[], - struct sfc_mae_action_set **action_setp, + struct sfc_flow_spec_mae *spec_mae, struct rte_flow_error *error) { struct sfc_mae_actions_bundle bundle = {0}; @@ -2127,13 +2127,13 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, if (rc != 0) goto fail_rule_parse_action; - *action_setp = sfc_mae_action_set_attach(sa, spec); - if (*action_setp != NULL) { + spec_mae->action_set = sfc_mae_action_set_attach(sa, spec); + if (spec_mae->action_set != NULL) { efx_mae_action_set_spec_fini(sa->nic, spec); return 0; } - rc = sfc_mae_action_set_add(sa, spec, action_setp); + rc = sfc_mae_action_set_add(sa, spec, &spec_mae->action_set); if (rc != 0) goto fail_action_set_add; diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index bf432638c..00987af61 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -197,7 +197,7 @@ int sfc_mae_rule_parse_pattern(struct sfc_adapter *sa, struct rte_flow_error *error); int sfc_mae_rule_parse_actions(struct sfc_adapter *sa, const struct rte_flow_action actions[], - struct sfc_mae_action_set **action_setp, + struct sfc_flow_spec_mae *spec_mae, struct rte_flow_error *error); sfc_flow_verify_cb_t sfc_mae_flow_verify; sfc_flow_insert_cb_t sfc_mae_flow_insert; From patchwork Fri Mar 12 09:31:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89003 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41AD3A0547; Fri, 12 Mar 2021 10:32:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EC85160888; Fri, 12 Mar 2021 10:31:59 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id DECD61607EE for ; Fri, 12 Mar 2021 10:31:50 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 9EB977F5B3; Fri, 12 Mar 2021 12:31:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 9EB977F5B3 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541510; bh=d9cRU0SCoMmkl39ZgqegvRhmWGEBBcKIwSixO53C/3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=laELoId+L+m3fuVuVlv1LicYU6ir6fbYBcbl8LgWDTDLbMDexU+XtGK7hy9tW1wNk nd6Zod9BycqTmqbjYIXNEZcHJxgwCiADd0NP86a2VvGl2WX7ELQ6FTMqIb4lBa99UN d2gmsAdX5cQxFCppgGPipbnd4gReC3OtG57EpIUo= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Date: Fri, 12 Mar 2021 12:31:41 +0300 Message-Id: <20210312093143.28186-8-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 08/10] net/sfc: support action VXLAN ENCAP in MAE backend 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" Provide necessary facilities for handling this action. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mae.c | 550 +++++++++++++++++++++++++++++++++++++- drivers/net/sfc/sfc_mae.h | 29 ++ 2 files changed, 572 insertions(+), 7 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 50efd47ad..79a1bd91d 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -9,7 +9,9 @@ #include +#include #include +#include #include "efx.h" @@ -35,6 +37,7 @@ sfc_mae_attach(struct sfc_adapter *sa) const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); efx_mport_sel_t entity_mport; struct sfc_mae *mae = &sa->mae; + struct sfc_mae_bounce_eh *bounce_eh = &mae->bounce_eh; efx_mae_limits_t limits; int rc; @@ -80,17 +83,26 @@ sfc_mae_attach(struct sfc_adapter *sa) if (rc != 0) goto fail_mae_assign_switch_port; + sfc_log_init(sa, "allocate encap. header bounce buffer"); + bounce_eh->buf_size = limits.eml_encap_header_size_limit; + bounce_eh->buf = rte_malloc("sfc_mae_bounce_eh", + bounce_eh->buf_size, 0); + if (bounce_eh->buf == NULL) + goto fail_mae_alloc_bounce_eh; + mae->status = SFC_MAE_STATUS_SUPPORTED; mae->nb_outer_rule_prios_max = limits.eml_max_n_outer_prios; mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios; mae->encap_types_supported = limits.eml_encap_types_supported; TAILQ_INIT(&mae->outer_rules); + TAILQ_INIT(&mae->encap_headers); TAILQ_INIT(&mae->action_sets); sfc_log_init(sa, "done"); return 0; +fail_mae_alloc_bounce_eh: fail_mae_assign_switch_port: fail_mae_assign_switch_domain: fail_mae_assign_entity_mport: @@ -117,6 +129,8 @@ sfc_mae_detach(struct sfc_adapter *sa) if (status_prev != SFC_MAE_STATUS_SUPPORTED) return; + rte_free(mae->bounce_eh.buf); + efx_mae_fini(sa->nic); sfc_log_init(sa, "done"); @@ -254,8 +268,165 @@ sfc_mae_outer_rule_disable(struct sfc_adapter *sa, return 0; } +static struct sfc_mae_encap_header * +sfc_mae_encap_header_attach(struct sfc_adapter *sa, + const struct sfc_mae_bounce_eh *bounce_eh) +{ + struct sfc_mae_encap_header *encap_header; + struct sfc_mae *mae = &sa->mae; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + TAILQ_FOREACH(encap_header, &mae->encap_headers, entries) { + if (encap_header->size == bounce_eh->size && + memcmp(encap_header->buf, bounce_eh->buf, + bounce_eh->size) == 0) { + ++(encap_header->refcnt); + return encap_header; + } + } + + return NULL; +} + +static int +sfc_mae_encap_header_add(struct sfc_adapter *sa, + const struct sfc_mae_bounce_eh *bounce_eh, + struct sfc_mae_encap_header **encap_headerp) +{ + struct sfc_mae_encap_header *encap_header; + struct sfc_mae *mae = &sa->mae; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + encap_header = rte_zmalloc("sfc_mae_encap_header", + sizeof(*encap_header), 0); + if (encap_header == NULL) + return ENOMEM; + + encap_header->size = bounce_eh->size; + + encap_header->buf = rte_malloc("sfc_mae_encap_header_buf", + encap_header->size, 0); + if (encap_header->buf == NULL) { + rte_free(encap_header); + return ENOMEM; + } + + rte_memcpy(encap_header->buf, bounce_eh->buf, bounce_eh->size); + + encap_header->refcnt = 1; + encap_header->type = bounce_eh->type; + encap_header->fw_rsrc.eh_id.id = EFX_MAE_RSRC_ID_INVALID; + + TAILQ_INSERT_TAIL(&mae->encap_headers, encap_header, entries); + + *encap_headerp = encap_header; + + return 0; +} + +static void +sfc_mae_encap_header_del(struct sfc_adapter *sa, + struct sfc_mae_encap_header *encap_header) +{ + struct sfc_mae *mae = &sa->mae; + + if (encap_header == NULL) + return; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + SFC_ASSERT(encap_header->refcnt != 0); + + --(encap_header->refcnt); + + if (encap_header->refcnt != 0) + return; + + SFC_ASSERT(encap_header->fw_rsrc.eh_id.id == EFX_MAE_RSRC_ID_INVALID); + SFC_ASSERT(encap_header->fw_rsrc.refcnt == 0); + + TAILQ_REMOVE(&mae->encap_headers, encap_header, entries); + rte_free(encap_header->buf); + rte_free(encap_header); +} + +static int +sfc_mae_encap_header_enable(struct sfc_adapter *sa, + struct sfc_mae_encap_header *encap_header, + efx_mae_actions_t *action_set_spec) +{ + struct sfc_mae_fw_rsrc *fw_rsrc; + int rc; + + if (encap_header == NULL) + return 0; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + fw_rsrc = &encap_header->fw_rsrc; + + if (fw_rsrc->refcnt == 0) { + SFC_ASSERT(fw_rsrc->eh_id.id == EFX_MAE_RSRC_ID_INVALID); + SFC_ASSERT(encap_header->buf != NULL); + SFC_ASSERT(encap_header->size != 0); + + rc = efx_mae_encap_header_alloc(sa->nic, encap_header->type, + encap_header->buf, + encap_header->size, + &fw_rsrc->eh_id); + if (rc != 0) + return rc; + } + + rc = efx_mae_action_set_fill_in_eh_id(action_set_spec, + &fw_rsrc->eh_id); + if (rc != 0) { + if (fw_rsrc->refcnt == 0) { + (void)efx_mae_encap_header_free(sa->nic, + &fw_rsrc->eh_id); + } + return rc; + } + + ++(fw_rsrc->refcnt); + + return 0; +} + +static int +sfc_mae_encap_header_disable(struct sfc_adapter *sa, + struct sfc_mae_encap_header *encap_header) +{ + struct sfc_mae_fw_rsrc *fw_rsrc; + int rc; + + if (encap_header == NULL) + return 0; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + fw_rsrc = &encap_header->fw_rsrc; + + SFC_ASSERT(fw_rsrc->eh_id.id != EFX_MAE_RSRC_ID_INVALID); + SFC_ASSERT(fw_rsrc->refcnt != 0); + + if (fw_rsrc->refcnt == 1) { + rc = efx_mae_encap_header_free(sa->nic, &fw_rsrc->eh_id); + if (rc != 0) + return rc; + + fw_rsrc->eh_id.id = EFX_MAE_RSRC_ID_INVALID; + } + + --(fw_rsrc->refcnt); + + return 0; +} + static struct sfc_mae_action_set * sfc_mae_action_set_attach(struct sfc_adapter *sa, + const struct sfc_mae_encap_header *encap_header, const efx_mae_actions_t *spec) { struct sfc_mae_action_set *action_set; @@ -264,7 +435,8 @@ sfc_mae_action_set_attach(struct sfc_adapter *sa, SFC_ASSERT(sfc_adapter_is_locked(sa)); TAILQ_FOREACH(action_set, &mae->action_sets, entries) { - if (efx_mae_action_set_specs_equal(action_set->spec, spec)) { + if (action_set->encap_header == encap_header && + efx_mae_action_set_specs_equal(action_set->spec, spec)) { ++(action_set->refcnt); return action_set; } @@ -276,6 +448,7 @@ sfc_mae_action_set_attach(struct sfc_adapter *sa, static int sfc_mae_action_set_add(struct sfc_adapter *sa, efx_mae_actions_t *spec, + struct sfc_mae_encap_header *encap_header, struct sfc_mae_action_set **action_setp) { struct sfc_mae_action_set *action_set; @@ -289,6 +462,7 @@ sfc_mae_action_set_add(struct sfc_adapter *sa, action_set->refcnt = 1; action_set->spec = spec; + action_set->encap_header = encap_header; action_set->fw_rsrc.aset_id.id = EFX_MAE_RSRC_ID_INVALID; @@ -317,6 +491,7 @@ sfc_mae_action_set_del(struct sfc_adapter *sa, SFC_ASSERT(action_set->fw_rsrc.refcnt == 0); efx_mae_action_set_spec_fini(sa->nic, action_set->spec); + sfc_mae_encap_header_del(sa, action_set->encap_header); TAILQ_REMOVE(&mae->action_sets, action_set, entries); rte_free(action_set); } @@ -325,6 +500,7 @@ static int sfc_mae_action_set_enable(struct sfc_adapter *sa, struct sfc_mae_action_set *action_set) { + struct sfc_mae_encap_header *encap_header = action_set->encap_header; struct sfc_mae_fw_rsrc *fw_rsrc = &action_set->fw_rsrc; int rc; @@ -334,10 +510,18 @@ sfc_mae_action_set_enable(struct sfc_adapter *sa, SFC_ASSERT(fw_rsrc->aset_id.id == EFX_MAE_RSRC_ID_INVALID); SFC_ASSERT(action_set->spec != NULL); + rc = sfc_mae_encap_header_enable(sa, encap_header, + action_set->spec); + if (rc != 0) + return rc; + rc = efx_mae_action_set_alloc(sa->nic, action_set->spec, &fw_rsrc->aset_id); - if (rc != 0) + if (rc != 0) { + (void)sfc_mae_encap_header_disable(sa, encap_header); + return rc; + } } ++(fw_rsrc->refcnt); @@ -362,6 +546,10 @@ sfc_mae_action_set_disable(struct sfc_adapter *sa, return rc; fw_rsrc->aset_id.id = EFX_MAE_RSRC_ID_INVALID; + + rc = sfc_mae_encap_header_disable(sa, action_set->encap_header); + if (rc != 0) + return rc; } --(fw_rsrc->refcnt); @@ -1936,6 +2124,307 @@ sfc_mae_rule_parse_action_of_set_vlan_pcp( bundle->vlan_push_tci |= rte_cpu_to_be_16(vlan_tci_pcp); } +struct sfc_mae_parsed_item { + const struct rte_flow_item *item; + size_t proto_header_ofst; + size_t proto_header_size; +}; + +/* + * For each 16-bit word of the given header, override + * bits enforced by the corresponding 16-bit mask. + */ +static void +sfc_mae_header_force_item_masks(uint8_t *header_buf, + const struct sfc_mae_parsed_item *parsed_items, + unsigned int nb_parsed_items) +{ + unsigned int item_idx; + + for (item_idx = 0; item_idx < nb_parsed_items; ++item_idx) { + const struct sfc_mae_parsed_item *parsed_item; + const struct rte_flow_item *item; + size_t proto_header_size; + size_t ofst; + + parsed_item = &parsed_items[item_idx]; + proto_header_size = parsed_item->proto_header_size; + item = parsed_item->item; + + for (ofst = 0; ofst < proto_header_size; + ofst += sizeof(rte_be16_t)) { + rte_be16_t *wp = RTE_PTR_ADD(header_buf, ofst); + const rte_be16_t *w_maskp; + const rte_be16_t *w_specp; + + w_maskp = RTE_PTR_ADD(item->mask, ofst); + w_specp = RTE_PTR_ADD(item->spec, ofst); + + *wp &= ~(*w_maskp); + *wp |= (*w_specp & *w_maskp); + } + + header_buf += proto_header_size; + } +} + +#define SFC_IPV4_TTL_DEF 0x40 +#define SFC_IPV6_VTC_FLOW_DEF 0x60000000 +#define SFC_IPV6_HOP_LIMITS_DEF 0xff +#define SFC_VXLAN_FLAGS_DEF 0x08000000 + +static int +sfc_mae_rule_parse_action_vxlan_encap( + struct sfc_mae *mae, + const struct rte_flow_action_vxlan_encap *conf, + efx_mae_actions_t *spec, + struct rte_flow_error *error) +{ + struct sfc_mae_bounce_eh *bounce_eh = &mae->bounce_eh; + struct rte_flow_item *pattern = conf->definition; + uint8_t *buf = bounce_eh->buf; + + /* This array will keep track of non-VOID pattern items. */ + struct sfc_mae_parsed_item parsed_items[1 /* Ethernet */ + + 2 /* VLAN tags */ + + 1 /* IPv4 or IPv6 */ + + 1 /* UDP */ + + 1 /* VXLAN */]; + unsigned int nb_parsed_items = 0; + + size_t eth_ethertype_ofst = offsetof(struct rte_ether_hdr, ether_type); + uint8_t dummy_buf[RTE_MAX(sizeof(struct rte_ipv4_hdr), + sizeof(struct rte_ipv6_hdr))]; + struct rte_ipv4_hdr *ipv4 = (void *)dummy_buf; + struct rte_ipv6_hdr *ipv6 = (void *)dummy_buf; + struct rte_vxlan_hdr *vxlan = NULL; + struct rte_udp_hdr *udp = NULL; + unsigned int nb_vlan_tags = 0; + size_t next_proto_ofst = 0; + size_t ethertype_ofst = 0; + uint64_t exp_items; + + if (pattern == NULL) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "The encap. header definition is NULL"); + } + + bounce_eh->type = EFX_TUNNEL_PROTOCOL_VXLAN; + bounce_eh->size = 0; + + /* + * Process pattern items and remember non-VOID ones. + * Defer applying masks until after the complete header + * has been built from the pattern items. + */ + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_ETH); + + for (; pattern->type != RTE_FLOW_ITEM_TYPE_END; ++pattern) { + struct sfc_mae_parsed_item *parsed_item; + const uint64_t exp_items_extra_vlan[] = { + RTE_BIT64(RTE_FLOW_ITEM_TYPE_VLAN), 0 + }; + size_t proto_header_size; + rte_be16_t *ethertypep; + uint8_t *next_protop; + uint8_t *buf_cur; + + if (pattern->spec == NULL) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "NULL item spec in the encap. header"); + } + + if (pattern->mask == NULL) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "NULL item mask in the encap. header"); + } + + if (pattern->last != NULL) { + /* This is not a match pattern, so disallow range. */ + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "Range item in the encap. header"); + } + + if (pattern->type == RTE_FLOW_ITEM_TYPE_VOID) { + /* Handle VOID separately, for clarity. */ + continue; + } + + if ((exp_items & RTE_BIT64(pattern->type)) == 0) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "Unexpected item in the encap. header"); + } + + parsed_item = &parsed_items[nb_parsed_items]; + buf_cur = buf + bounce_eh->size; + + switch (pattern->type) { + case RTE_FLOW_ITEM_TYPE_ETH: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_ETH, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_eth, + hdr) != 0); + + proto_header_size = sizeof(struct rte_ether_hdr); + + ethertype_ofst = eth_ethertype_ofst; + + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_VLAN) | + RTE_BIT64(RTE_FLOW_ITEM_TYPE_IPV4) | + RTE_BIT64(RTE_FLOW_ITEM_TYPE_IPV6); + break; + case RTE_FLOW_ITEM_TYPE_VLAN: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_VLAN, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_vlan, + hdr) != 0); + + proto_header_size = sizeof(struct rte_vlan_hdr); + + ethertypep = RTE_PTR_ADD(buf, eth_ethertype_ofst); + *ethertypep = RTE_BE16(RTE_ETHER_TYPE_QINQ); + + ethertypep = RTE_PTR_ADD(buf, ethertype_ofst); + *ethertypep = RTE_BE16(RTE_ETHER_TYPE_VLAN); + + ethertype_ofst = + bounce_eh->size + + offsetof(struct rte_vlan_hdr, eth_proto); + + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_IPV4) | + RTE_BIT64(RTE_FLOW_ITEM_TYPE_IPV6); + exp_items |= exp_items_extra_vlan[nb_vlan_tags]; + + ++nb_vlan_tags; + break; + case RTE_FLOW_ITEM_TYPE_IPV4: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_IPV4, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_ipv4, + hdr) != 0); + + proto_header_size = sizeof(struct rte_ipv4_hdr); + + ethertypep = RTE_PTR_ADD(buf, ethertype_ofst); + *ethertypep = RTE_BE16(RTE_ETHER_TYPE_IPV4); + + next_proto_ofst = + bounce_eh->size + + offsetof(struct rte_ipv4_hdr, next_proto_id); + + ipv4 = (struct rte_ipv4_hdr *)buf_cur; + + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_UDP); + break; + case RTE_FLOW_ITEM_TYPE_IPV6: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_IPV6, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_ipv6, + hdr) != 0); + + proto_header_size = sizeof(struct rte_ipv6_hdr); + + ethertypep = RTE_PTR_ADD(buf, ethertype_ofst); + *ethertypep = RTE_BE16(RTE_ETHER_TYPE_IPV6); + + next_proto_ofst = bounce_eh->size + + offsetof(struct rte_ipv6_hdr, proto); + + ipv6 = (struct rte_ipv6_hdr *)buf_cur; + + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_UDP); + break; + case RTE_FLOW_ITEM_TYPE_UDP: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_UDP, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_udp, + hdr) != 0); + + proto_header_size = sizeof(struct rte_udp_hdr); + + next_protop = RTE_PTR_ADD(buf, next_proto_ofst); + *next_protop = IPPROTO_UDP; + + udp = (struct rte_udp_hdr *)buf_cur; + + exp_items = RTE_BIT64(RTE_FLOW_ITEM_TYPE_VXLAN); + break; + case RTE_FLOW_ITEM_TYPE_VXLAN: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ITEM_TYPE_VXLAN, + exp_items); + RTE_BUILD_BUG_ON(offsetof(struct rte_flow_item_vxlan, + hdr) != 0); + + proto_header_size = sizeof(struct rte_vxlan_hdr); + + vxlan = (struct rte_vxlan_hdr *)buf_cur; + + udp->dst_port = RTE_BE16(RTE_VXLAN_DEFAULT_PORT); + udp->dgram_len = RTE_BE16(sizeof(*udp) + + sizeof(*vxlan)); + udp->dgram_cksum = 0; + + exp_items = 0; + break; + default: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "Unknown item in the encap. header"); + } + + if (bounce_eh->size + proto_header_size > bounce_eh->buf_size) { + return rte_flow_error_set(error, E2BIG, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "The encap. header is too big"); + } + + if ((proto_header_size & 1) != 0) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "Odd layer size in the encap. header"); + } + + rte_memcpy(buf_cur, pattern->spec, proto_header_size); + bounce_eh->size += proto_header_size; + + parsed_item->item = pattern; + parsed_item->proto_header_size = proto_header_size; + ++nb_parsed_items; + } + + if (exp_items != 0) { + /* Parsing item VXLAN would have reset exp_items to 0. */ + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "No item VXLAN in the encap. header"); + } + + /* One of the pointers (ipv4, ipv6) referes to a dummy area. */ + ipv4->version_ihl = RTE_IPV4_VHL_DEF; + ipv4->time_to_live = SFC_IPV4_TTL_DEF; + ipv4->total_length = RTE_BE16(sizeof(*ipv4) + sizeof(*udp) + + sizeof(*vxlan)); + /* The HW cannot compute this checksum. */ + ipv4->hdr_checksum = 0; + ipv4->hdr_checksum = rte_ipv4_cksum(ipv4); + + ipv6->vtc_flow = RTE_BE32(SFC_IPV6_VTC_FLOW_DEF); + ipv6->hop_limits = SFC_IPV6_HOP_LIMITS_DEF; + ipv6->payload_len = udp->dgram_len; + + vxlan->vx_flags = RTE_BE32(SFC_VXLAN_FLAGS_DEF); + + /* Take care of the masks. */ + sfc_mae_header_force_item_masks(buf, parsed_items, nb_parsed_items); + + return (spec != NULL) ? efx_mae_action_set_populate_encap(spec) : 0; +} + static int sfc_mae_rule_parse_action_mark(const struct rte_flow_action_mark *conf, efx_mae_actions_t *spec) @@ -2016,6 +2505,7 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, efx_mae_actions_t *spec, struct rte_flow_error *error) { + bool custom_error = B_FALSE; int rc = 0; switch (action->type) { @@ -2039,6 +2529,14 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, bundle->actions_mask); sfc_mae_rule_parse_action_of_set_vlan_pcp(action->conf, bundle); break; + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_vxlan_encap(&sa->mae, + action->conf, + spec, error); + custom_error = B_TRUE; + break; case RTE_FLOW_ACTION_TYPE_FLAG: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_FLAG, bundle->actions_mask); @@ -2080,24 +2578,49 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, "Unsupported action"); } - if (rc != 0) { + if (rc == 0) { + bundle->actions_mask |= (1ULL << action->type); + } else if (!custom_error) { rc = rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "Failed to request the action"); - } else { - bundle->actions_mask |= (1ULL << action->type); } return rc; } +static void +sfc_mae_bounce_eh_invalidate(struct sfc_mae_bounce_eh *bounce_eh) +{ + bounce_eh->type = EFX_TUNNEL_PROTOCOL_NONE; +} + +static int +sfc_mae_process_encap_header(struct sfc_adapter *sa, + const struct sfc_mae_bounce_eh *bounce_eh, + struct sfc_mae_encap_header **encap_headerp) +{ + if (bounce_eh->type == EFX_TUNNEL_PROTOCOL_NONE) { + encap_headerp = NULL; + return 0; + } + + *encap_headerp = sfc_mae_encap_header_attach(sa, bounce_eh); + if (*encap_headerp != NULL) + return 0; + + return sfc_mae_encap_header_add(sa, bounce_eh, encap_headerp); +} + int sfc_mae_rule_parse_actions(struct sfc_adapter *sa, const struct rte_flow_action actions[], struct sfc_flow_spec_mae *spec_mae, struct rte_flow_error *error) { + struct sfc_mae_encap_header *encap_header = NULL; struct sfc_mae_actions_bundle bundle = {0}; const struct rte_flow_action *action; + struct sfc_mae *mae = &sa->mae; efx_mae_actions_t *spec; int rc; @@ -2111,6 +2634,9 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, if (rc != 0) goto fail_action_set_spec_init; + /* Cleanup after previous encap. header bounce buffer usage. */ + sfc_mae_bounce_eh_invalidate(&mae->bounce_eh); + for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { rc = sfc_mae_actions_bundle_sync(action, &bundle, spec, error); @@ -2127,19 +2653,29 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, if (rc != 0) goto fail_rule_parse_action; - spec_mae->action_set = sfc_mae_action_set_attach(sa, spec); + rc = sfc_mae_process_encap_header(sa, &mae->bounce_eh, &encap_header); + if (rc != 0) + goto fail_process_encap_header; + + spec_mae->action_set = sfc_mae_action_set_attach(sa, encap_header, + spec); if (spec_mae->action_set != NULL) { + sfc_mae_encap_header_del(sa, encap_header); efx_mae_action_set_spec_fini(sa->nic, spec); return 0; } - rc = sfc_mae_action_set_add(sa, spec, &spec_mae->action_set); + rc = sfc_mae_action_set_add(sa, spec, encap_header, + &spec_mae->action_set); if (rc != 0) goto fail_action_set_add; return 0; fail_action_set_add: + sfc_mae_encap_header_del(sa, encap_header); + +fail_process_encap_header: fail_rule_parse_action: efx_mae_action_set_spec_fini(sa->nic, spec); diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index 00987af61..c08fa545b 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -27,6 +27,7 @@ struct sfc_mae_fw_rsrc { union { efx_mae_aset_id_t aset_id; efx_mae_rule_id_t rule_id; + efx_mae_eh_id_t eh_id; }; }; @@ -41,11 +42,24 @@ struct sfc_mae_outer_rule { TAILQ_HEAD(sfc_mae_outer_rules, sfc_mae_outer_rule); +/** Encap. header registry entry */ +struct sfc_mae_encap_header { + TAILQ_ENTRY(sfc_mae_encap_header) entries; + unsigned int refcnt; + uint8_t *buf; + size_t size; + efx_tunnel_protocol_t type; + struct sfc_mae_fw_rsrc fw_rsrc; +}; + +TAILQ_HEAD(sfc_mae_encap_headers, sfc_mae_encap_header); + /** Action set registry entry */ struct sfc_mae_action_set { TAILQ_ENTRY(sfc_mae_action_set) entries; unsigned int refcnt; efx_mae_actions_t *spec; + struct sfc_mae_encap_header *encap_header; struct sfc_mae_fw_rsrc fw_rsrc; }; @@ -58,6 +72,17 @@ enum sfc_mae_status { SFC_MAE_STATUS_SUPPORTED }; +/* + * Encap. header bounce buffer. It is used to store header data + * when parsing the header definition in the action VXLAN_ENCAP. + */ +struct sfc_mae_bounce_eh { + uint8_t *buf; + size_t buf_size; + size_t size; + efx_tunnel_protocol_t type; +}; + struct sfc_mae { /** Assigned switch domain identifier */ uint16_t switch_domain_id; @@ -73,8 +98,12 @@ struct sfc_mae { uint32_t encap_types_supported; /** Outer rule registry */ struct sfc_mae_outer_rules outer_rules; + /** Encap. header registry */ + struct sfc_mae_encap_headers encap_headers; /** Action set registry */ struct sfc_mae_action_sets action_sets; + /** Encap. header bounce buffer */ + struct sfc_mae_bounce_eh bounce_eh; }; struct sfc_adapter; From patchwork Fri Mar 12 09:31:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89004 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6EA79A0547; Fri, 12 Mar 2021 10:32:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DC65160890; Fri, 12 Mar 2021 10:32:00 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 18675160849 for ; Fri, 12 Mar 2021 10:31:51 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id DA3DA7F5B8; Fri, 12 Mar 2021 12:31:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru DA3DA7F5B8 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541510; bh=rVhCMRAaR5ExHk6sZZNtqhX1okazdi1EF1rlIBYBwNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=p86LZWVQfiT83lY9qcoQbm3i5+hoRxN0cqVm7jkPpZnFAotYFL39iqqLn36T57Km4 QWlVMs4A8Ns051nZnV0jnBCjGKBIIE6OzCKSr/tSxHH0xoIOk5oCKyNCRRJQg6H/hG MMOFIdlrOM2/Kn0HV/amYUnkNp/FYnG0nh1Wau8o= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ray Kinsella , Neil Horman Date: Fri, 12 Mar 2021 12:31:42 +0300 Message-Id: <20210312093143.28186-9-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 09/10] common/sfc_efx/base: support adding action DECAP to a set 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" The action has no arguments. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 5 +++ drivers/common/sfc_efx/base/efx_impl.h | 1 + drivers/common/sfc_efx/base/efx_mae.c | 48 ++++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 4 files changed, 55 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 052946aa3..fe643de96 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4240,6 +4240,11 @@ efx_mae_action_set_spec_fini( __in efx_nic_t *enp, __in efx_mae_actions_t *spec); +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_populate_decap( + __in efx_mae_actions_t *spec); + LIBEFX_API extern __checkReturn efx_rc_t efx_mae_action_set_populate_vlan_pop( diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 0adf43c26..7ee9ddec7 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1707,6 +1707,7 @@ struct efx_mae_match_spec_s { typedef enum efx_mae_action_e { /* These actions are strictly ordered. */ + EFX_MAE_ACTION_DECAP, EFX_MAE_ACTION_VLAN_POP, EFX_MAE_ACTION_VLAN_PUSH, EFX_MAE_ACTION_ENCAP, diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 896500de0..b384c009a 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1013,6 +1013,37 @@ efx_mae_action_set_spec_fini( EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec); } +static __checkReturn efx_rc_t +efx_mae_action_set_add_decap( + __in efx_mae_actions_t *spec, + __in size_t arg_size, + __in_bcount(arg_size) const uint8_t *arg) +{ + efx_rc_t rc; + + _NOTE(ARGUNUSED(spec)) + + if (arg_size != 0) { + rc = EINVAL; + goto fail1; + } + + if (arg != NULL) { + rc = EINVAL; + goto fail2; + } + + /* This action does not have any arguments, so do nothing here. */ + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + static __checkReturn efx_rc_t efx_mae_action_set_add_vlan_pop( __in efx_mae_actions_t *spec, @@ -1227,6 +1258,9 @@ typedef struct efx_mae_action_desc_s { } efx_mae_action_desc_t; static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { + [EFX_MAE_ACTION_DECAP] = { + .emad_add = efx_mae_action_set_add_decap + }, [EFX_MAE_ACTION_VLAN_POP] = { .emad_add = efx_mae_action_set_add_vlan_pop }, @@ -1248,6 +1282,7 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { }; static const uint32_t efx_mae_action_ordered_map = + (1U << EFX_MAE_ACTION_DECAP) | (1U << EFX_MAE_ACTION_VLAN_POP) | (1U << EFX_MAE_ACTION_VLAN_PUSH) | (1U << EFX_MAE_ACTION_ENCAP) | @@ -1343,6 +1378,14 @@ efx_mae_action_set_spec_populate( return (rc); } + __checkReturn efx_rc_t +efx_mae_action_set_populate_decap( + __in efx_mae_actions_t *spec) +{ + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_DECAP, 0, NULL)); +} + __checkReturn efx_rc_t efx_mae_action_set_populate_vlan_pop( __in efx_mae_actions_t *spec) @@ -2009,6 +2052,11 @@ efx_mae_action_set_alloc( MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_COUNTER_ID, EFX_MAE_RSRC_ID_INVALID); + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_DECAP)) != 0) { + MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, + MAE_ACTION_SET_ALLOC_IN_DECAP, 1); + } + MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop); diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index f33a2a08e..b55e8567e 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -90,6 +90,7 @@ INTERNAL { efx_mae_action_set_alloc; efx_mae_action_set_fill_in_eh_id; efx_mae_action_set_free; + efx_mae_action_set_populate_decap; efx_mae_action_set_populate_deliver; efx_mae_action_set_populate_drop; efx_mae_action_set_populate_encap; From patchwork Fri Mar 12 09:31:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 89005 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54FE9A0547; Fri, 12 Mar 2021 10:32:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A861160898; Fri, 12 Mar 2021 10:32:01 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 6331E16084A for ; Fri, 12 Mar 2021 10:31:51 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 1FC467F5BC; Fri, 12 Mar 2021 12:31:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1FC467F5BC DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1615541511; bh=4c20trM6g6UkeMkSRDEWVIquTZQ2m13BCyNZBDc4rcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rcRA4dx4Ka+Nba/tjLHUeUlRGfZ/9Ryk8KZm/2TkVKjIQEbY9vtqKUn4TMOF9q2Jz MLzVPsz3ii1QcDt5L3N0375N2OpKH3LJEeaKv+aX1r6vjgZ+/3spiPGRp2fl1HfhGA 4alRdHYVGDYa2rUVeb7cvwiWt1C1tnrNZs25fy8g= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Date: Fri, 12 Mar 2021 12:31:43 +0300 Message-Id: <20210312093143.28186-10-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 10/10] net/sfc: support action VXLAN DECAP in transfer rules 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" If there is no VXLAN among pattern items, the action will be turned down. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mae.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 79a1bd91d..1d67a4be2 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -2501,6 +2501,7 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa, static int sfc_mae_rule_parse_action(struct sfc_adapter *sa, const struct rte_flow_action *action, + const struct sfc_mae_outer_rule *outer_rule, struct sfc_mae_actions_bundle *bundle, efx_mae_actions_t *spec, struct rte_flow_error *error) @@ -2509,6 +2510,15 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, int rc = 0; switch (action->type) { + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_VXLAN_DECAP, + bundle->actions_mask); + if (outer_rule == NULL || + outer_rule->encap_type != EFX_TUNNEL_PROTOCOL_VXLAN) + rc = EINVAL; + else + rc = efx_mae_action_set_populate_decap(spec); + break; case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, bundle->actions_mask); @@ -2643,8 +2653,8 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, if (rc != 0) goto fail_rule_parse_action; - rc = sfc_mae_rule_parse_action(sa, action, &bundle, spec, - error); + rc = sfc_mae_rule_parse_action(sa, action, spec_mae->outer_rule, + &bundle, spec, error); if (rc != 0) goto fail_rule_parse_action; }