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 14A01A04A6; Thu, 27 Jan 2022 19:56:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7EB842784; Thu, 27 Jan 2022 19:56:05 +0100 (CET) Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) by mails.dpdk.org (Postfix) with ESMTP id E5B5740141 for ; Thu, 27 Jan 2022 19:56:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5109; q=dns/txt; s=iport; t=1643309765; x=1644519365; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3FpnY9EdomXyAkcLHYOR5dUzEeRs3FS7gWiHujmeS3I=; b=Gvt9g56IkZVw55vxkkeRC6q2+v3XSLDEVtONXmPYULIFTu/OBlQ+V8+Z Bc48AAJlLdxe58EivAANd2QMqcP65Z8l91COz2FcUW314wSTpRHIqhOp9 l6IgZ0Unm9b3XjwOBGVPK6/Fno2EbnQ41+Wqep8iAoOYEiv6PdsphhfxJ c=; X-IronPort-AV: E=Sophos;i="5.88,321,1635206400"; d="scan'208";a="963535297" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 27 Jan 2022 18:56:03 +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 20RIu2ii013113; Thu, 27 Jan 2022 18:56:03 GMT Received: by cisco.com (Postfix, from userid 392789) id 3D9AA20F2003; Thu, 27 Jan 2022 10:56:02 -0800 (PST) From: John Daley To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, John Daley , Hyong Youb Kim Subject: [PATCH v3] net/enic: add support for eCPRI matching Date: Thu, 27 Jan 2022 10:55:54 -0800 Message-Id: <20220127185554.14987-1-johndale@cisco.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220126214802.1412-1-johndale@cisco.com> References: <20220126214802.1412-1-johndale@cisco.com> 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 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 eCPRI message can be over Ethernet layer (.1Q supported also) or over UDP layer. Message header formats are the same in these two variants. Only up though the first packet header in the PDU can be matched. RSS on the eCPRI payload is not supported. Signed-off-by: John Daley Reviewed-by: Hyong Youb Kim --- v3: put new rte flow item feature in alphabetical order doc/guides/nics/features/enic.ini | 1 + doc/guides/rel_notes/release_22_03.rst | 1 + drivers/net/enic/enic_fm_flow.c | 67 +++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/enic.ini b/doc/guides/nics/features/enic.ini index 00231baf85..61bec4910e 100644 --- a/doc/guides/nics/features/enic.ini +++ b/doc/guides/nics/features/enic.ini @@ -39,6 +39,7 @@ x86-64 = Y Usage doc = Y [rte_flow items] +ecpri = Y eth = Y geneve = Y geneve_opt = Y diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 33be3241b9..6786eb3b48 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -58,6 +58,7 @@ New Features * **Updated Cisco enic driver.** * Added rte_flow support for matching GENEVE packets. + * Added rte_flow support for matching eCPRI packets. Removed Items ------------- diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c index bf04d714d0..f0bda19a70 100644 --- a/drivers/net/enic/enic_fm_flow.c +++ b/drivers/net/enic/enic_fm_flow.c @@ -237,6 +237,7 @@ static enic_copy_item_fn enic_fm_copy_item_vxlan; static enic_copy_item_fn enic_fm_copy_item_gtp; static enic_copy_item_fn enic_fm_copy_item_geneve; static enic_copy_item_fn enic_fm_copy_item_geneve_opt; +static enic_copy_item_fn enic_fm_copy_item_ecpri; /* Ingress actions */ static const enum rte_flow_action_type enic_fm_supported_ig_actions[] = { @@ -392,6 +393,15 @@ static const struct enic_fm_items enic_fm_items[] = { RTE_FLOW_ITEM_TYPE_END, }, }, + [RTE_FLOW_ITEM_TYPE_ECPRI] = { + .copy_item = enic_fm_copy_item_ecpri, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, }; static int @@ -877,6 +887,61 @@ enic_fm_copy_item_geneve_opt(struct copy_item_args *arg) return 0; } +/* Match eCPRI combined message header */ +static int +enic_fm_copy_item_ecpri(struct copy_item_args *arg) +{ + const struct rte_flow_item *item = arg->item; + const struct rte_flow_item_ecpri *spec = item->spec; + const struct rte_flow_item_ecpri *mask = item->mask; + struct fm_tcam_match_entry *entry = arg->fm_tcam_entry; + struct fm_header_set *fm_data, *fm_mask; + uint8_t *fm_data_to, *fm_mask_to; + + ENICPMD_FUNC_TRACE(); + + /* Tunneling not supported- only matching on inner eCPRI fields. */ + if (arg->header_level > 0) + return -EINVAL; + + /* Need both spec and mask */ + if (!spec || !mask) + return -EINVAL; + + fm_data = &entry->ftm_data.fk_hdrset[0]; + fm_mask = &entry->ftm_mask.fk_hdrset[0]; + + /* eCPRI can only follow L2/VLAN layer if ethernet type is 0xAEFE. */ + if (!(fm_data->fk_metadata & FKM_UDP) && + (fm_mask->l2.eth.fk_ethtype != UINT16_MAX || + rte_cpu_to_be_16(fm_data->l2.eth.fk_ethtype) != + RTE_ETHER_TYPE_ECPRI)) + return -EINVAL; + + if (fm_data->fk_metadata & FKM_UDP) { + /* eCPRI on UDP */ + fm_data->fk_header_select |= FKH_L4RAW; + fm_mask->fk_header_select |= FKH_L4RAW; + fm_data_to = &fm_data->l4.rawdata[sizeof(fm_data->l4.udp)]; + fm_mask_to = &fm_mask->l4.rawdata[sizeof(fm_data->l4.udp)]; + } else { + /* eCPRI directly after Etherent header */ + fm_data->fk_header_select |= FKH_L3RAW; + fm_mask->fk_header_select |= FKH_L3RAW; + fm_data_to = &fm_data->l3.rawdata[0]; + fm_mask_to = &fm_mask->l3.rawdata[0]; + } + + /* + * Use the raw L3 or L4 buffer to match eCPRI since fm_header_set does + * not have eCPRI header. Only 1st message header of PDU can be matched. + * "C" * bit ignored. + */ + memcpy(fm_data_to, spec, sizeof(*spec)); + memcpy(fm_mask_to, 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). @@ -2521,11 +2586,11 @@ enic_action_handle_get(struct enic_flowman *fm, struct fm_action *action_in, memcpy(fma, action_in, sizeof(*fma)); ah = calloc(1, sizeof(*ah)); - memcpy(&ah->key, action_in, sizeof(struct fm_action)); if (ah == NULL) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "enic: calloc(fm-action)"); + memcpy(&ah->key, action_in, sizeof(struct fm_action)); args[0] = FM_ACTION_ALLOC; args[1] = fm->cmd.pa; ret = flowman_cmd(fm, args, 2); -- 2.33.1