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 C086EA0C47; Tue, 26 Oct 2021 03:17:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F34B40A4B; Tue, 26 Oct 2021 03:17:02 +0200 (CEST) Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) by mails.dpdk.org (Postfix) with ESMTP id B5A274003E for ; Tue, 26 Oct 2021 03:17:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=7078; q=dns/txt; s=iport; t=1635211020; x=1636420620; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=p8RTOczWNl0DnJHljmaghTR4a9odAmCMT9WIxbSHad4=; b=V0jy1sOPL7diTPMvGfWLf4OVvrRBC+Trpy3Rn505mBVZvZ9IL4J1Be7c RAP/TOMEYmQx3FpsqHHD7Er0nu23DTiRb3ZhH1m8g8Lo3tUyt+clZi2Pf f1gLVjGceUhN8g2z+JqPNeIhoLPObz2xHju2VA8AmhpQac8fSiVjBRdeD Q=; X-IronPort-AV: E=Sophos;i="5.87,181,1631577600"; d="scan'208";a="793291222" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 26 Oct 2021 01:16:59 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id 19Q1GxYb016358; Tue, 26 Oct 2021 01:16:59 GMT Received: by cisco.com (Postfix, from userid 392789) id 6F28A20F2005; Mon, 25 Oct 2021 18:16:59 -0700 (PDT) From: John Daley To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, John Daley , Hyong Youb Kim Date: Mon, 25 Oct 2021 18:16:56 -0700 Message-Id: <20211026011656.17013-1-johndale@cisco.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: rcdn-core-4.cisco.com Subject: [dpdk-dev] [PATCH] net/enic: support GTP header flow matching 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 GTP, GTP-U, GTP-C header fields can be matched, however NIC does not support GTP tunneling so no items after the GTP header can be specified. If a GTP-U or GTP-C item is specified without a preceding UDP item, the UDP destination port is implicitly matched. For GTP, the destination UDP port must be specified but its value is not enforced. Signed-off-by: John Daley Reviewed-by: Hyong Youb Kim --- doc/guides/nics/enic.rst | 2 + doc/guides/nics/features/enic.ini | 3 + doc/guides/rel_notes/release_21_11.rst | 4 + drivers/net/enic/enic_fm_flow.c | 119 +++++++++++++++++++++++++ 4 files changed, 128 insertions(+) diff --git a/doc/guides/nics/enic.rst b/doc/guides/nics/enic.rst index f2ee49fe82..5e2054fc8a 100644 --- a/doc/guides/nics/enic.rst +++ b/doc/guides/nics/enic.rst @@ -473,6 +473,8 @@ RTE_MBUF_F_RX_VLAN_STRIPPED mbuf flags would not be set. This mode is enabled wi packets and then receive them normally. These require 1400 series VIC adapters and latest firmware. - RAW items are limited to matching UDP tunnel headers like VXLAN. + - GTP, GTP-C and GTP-U header matching is enabled, however matching items within + the tunnel is not supported. - For 1400 VICs, all flows using the RSS action on a port use same hash configuration. The RETA is ignored. The queues used in the RSS group must be sequential. There is a performance hit if the number of queues is not a power of 2. diff --git a/doc/guides/nics/features/enic.ini b/doc/guides/nics/features/enic.ini index 3064336162..1177752c15 100644 --- a/doc/guides/nics/features/enic.ini +++ b/doc/guides/nics/features/enic.ini @@ -40,6 +40,9 @@ Usage doc = Y [rte_flow items] eth = Y +gtp = Y +gtpc = Y +gtpu = Y ipv4 = Y ipv6 = Y raw = Y diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 1ccac87b73..2cee5347f3 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -154,6 +154,10 @@ New Features * Implement support for tunnel offload. * Updated HWRM API to version 1.10.2.44 +* **Updated Cisco enic driver.** + + * Added rte_flow support for matching GTP, GTP-C and GTP-U headers. + * **Updated Intel e1000 emulated driver.** * Added Intel e1000 support on Windows. diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c index 2c60bb864e..e318a5f828 100644 --- a/drivers/net/enic/enic_fm_flow.c +++ b/drivers/net/enic/enic_fm_flow.c @@ -235,6 +235,7 @@ static enic_copy_item_fn enic_fm_copy_item_tcp; static enic_copy_item_fn enic_fm_copy_item_udp; static enic_copy_item_fn enic_fm_copy_item_vlan; static enic_copy_item_fn enic_fm_copy_item_vxlan; +static enic_copy_item_fn enic_fm_copy_item_gtp; /* Ingress actions */ static const enum rte_flow_action_type enic_fm_supported_ig_actions[] = { @@ -346,6 +347,30 @@ static const struct enic_fm_items enic_fm_items[] = { RTE_FLOW_ITEM_TYPE_END, }, }, + [RTE_FLOW_ITEM_TYPE_GTP] = { + .copy_item = enic_fm_copy_item_gtp, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_GTPC] = { + .copy_item = enic_fm_copy_item_gtp, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_GTPU] = { + .copy_item = enic_fm_copy_item_gtp, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, }; static int @@ -629,6 +654,100 @@ enic_fm_copy_item_vxlan(struct copy_item_args *arg) return 0; } +static int +enic_fm_copy_item_gtp(struct copy_item_args *arg) +{ + const struct rte_flow_item *item = arg->item; + const struct rte_flow_item_gtp *spec = item->spec; + const struct rte_flow_item_gtp *mask = item->mask; + struct fm_tcam_match_entry *entry = arg->fm_tcam_entry; + struct fm_header_set *fm_data, *fm_mask; + int off; + uint16_t udp_gtp_uc_port = 0; + + ENICPMD_FUNC_TRACE(); + /* Only 2 header levels (outer and inner) allowed */ + if (arg->header_level > 0) + return -EINVAL; + + fm_data = &entry->ftm_data.fk_hdrset[0]; + fm_mask = &entry->ftm_mask.fk_hdrset[0]; + + switch (item->type) { + case RTE_FLOW_ITEM_TYPE_GTP: + { + /* For vanilla GTP, the UDP destination port must be specified + * but value of the port is not enforced here. + */ + if (!(fm_data->fk_metadata & FKM_UDP) || + !(fm_data->fk_header_select & FKH_UDP) || + fm_data->l4.udp.fk_dest == 0) + return -EINVAL; + if (!(fm_mask->fk_metadata & FKM_UDP) || + !(fm_mask->fk_header_select & FKH_UDP) || + fm_mask->l4.udp.fk_dest != 0xFFFF) + return -EINVAL; + break; + } + case RTE_FLOW_ITEM_TYPE_GTPC: + { + udp_gtp_uc_port = RTE_GTPC_UDP_PORT; + break; + } + case RTE_FLOW_ITEM_TYPE_GTPU: + { + udp_gtp_uc_port = RTE_GTPU_UDP_PORT; + break; + } + default: + RTE_ASSERT(0); + } + + /* The GTP-C or GTP-U UDP destination port must be matched. */ + if (udp_gtp_uc_port) { + if (fm_data->fk_metadata & FKM_UDP && + fm_data->fk_header_select & FKH_UDP && + rte_be_to_cpu_16(fm_data->l4.udp.fk_dest) != + udp_gtp_uc_port) + return -EINVAL; + if (fm_mask->fk_metadata & FKM_UDP && + fm_mask->fk_header_select & FKH_UDP && + fm_mask->l4.udp.fk_dest != 0xFFFF) + return -EINVAL; + + /* In any case, add match for GTP-C GTP-U UDP dst port */ + fm_data->fk_metadata |= FKM_UDP; + fm_data->fk_header_select |= FKH_UDP; + fm_data->l4.udp.fk_dest = udp_gtp_uc_port; + fm_mask->fk_metadata |= FKM_UDP; + fm_mask->fk_header_select |= FKH_UDP; + fm_mask->l4.udp.fk_dest = 0xFFFF; + } + + /* NIC does not support GTP tunnels. No Items are allowed after this. + * This prevents the specificaiton of further items. + */ + arg->header_level = 0; + + /* Match all if no spec */ + if (!spec) + return 0; + if (!mask) + mask = &rte_flow_item_gtp_mask; + + /* + * Use the raw L4 buffer to match GTP as fm_header_set does not have + * GTP header. UDP dst port must be specifiec. Using the raw buffer + * does not affect such UDP item, since we skip UDP in the raw buffer. + */ + fm_data->fk_header_select |= FKH_L4RAW; + fm_mask->fk_header_select |= FKH_L4RAW; + off = sizeof(fm_data->l4.udp); + memcpy(&fm_data->l4.rawdata[off], spec, sizeof(*spec)); + memcpy(&fm_mask->l4.rawdata[off], mask, sizeof(*mask)); + return 0; +} + /* * Currently, raw pattern match is very limited. It is intended for matching * UDP tunnel header (e.g. vxlan or geneve). -- 2.26.2