From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4ECC0A04DD; Tue, 20 Oct 2020 11:29:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B5AEE26E; Tue, 20 Oct 2020 11:14:58 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 6A62AC81A for ; Tue, 20 Oct 2020 11:14:11 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.64]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id D38CD60083 for ; Tue, 20 Oct 2020 09:14:09 +0000 (UTC) Received: from us4-mdac16-68.ut7.mdlocal (unknown [10.7.64.187]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id D2D4C2009B for ; Tue, 20 Oct 2020 09:14:09 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.34]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5937D22004F for ; Tue, 20 Oct 2020 09:14:09 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 10327600053 for ; Tue, 20 Oct 2020 09:14:09 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 10:14:00 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 10:14:00 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09K9Dxlj028395; Tue, 20 Oct 2020 10:13:59 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id DC0BC1613A9; Tue, 20 Oct 2020 10:13:59 +0100 (BST) From: Andrew Rybchenko To: CC: Ivan Malov Date: Tue, 20 Oct 2020 10:13:00 +0100 Message-ID: <1603185222-14831-21-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603185222-14831-1-git-send-email-arybchenko@solarflare.com> References: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> <1603185222-14831-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25736.003 X-TM-AS-Result: No-1.032200-8.000000-10 X-TMASE-MatchedRID: qT3lr2YLwToZbIsB9jb3Y26HurDH4PpP6KbGBEfATCZwkdIrVt8X1VDT Kayi2ZF6pVG0HeSt+ryWGRCs++FM0t1RkEnBFAu+nFVnNmvv47uWODD/yzpvd7Zk7gsuflVKFQL H9fnGRScEURg1j2RVWB0HR7lIrhJk24NXD3gRmYDN+qWlu2ZxaNi5W7Rf+s6QR2YNIFh+clGGc4 vJ+XLGs+qdK1begbbxbgyxO8sQKN8K9DOkPuNII7dHEv7sR/OwfglgnB0nDhN7uKMeruD2hrBXu d9Ra+w0tk2AwjDNBTuAMuqetGVetnyef22ep6XYxlblqLlYqXIRvQlel5Wbwj2ppL+O5aOxnqxQ Z6OEQ8DJibW/yIPDduygLTPX5amJxhj3j1MW6TyUhH8b6j2vAHEu4PVSZXBnayrPn5ppScvw7Jx wU0EvZMqEROLb/+yO4/0Jvn0rwAJmtL4Dw+zNb9T2H03zzU1J X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.032200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603185249-zUUuxNiLUUB8 X-PPE-DISP: 1603185249;zUUuxNiLUUB8 Subject: [dpdk-dev] [PATCH v2 20/62] common/sfc_efx/base: support adding DELIVER action to a set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: Ivan Malov Introduce a mechanism for adding actions to an action set and add support for DELIVER action. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 11 +- drivers/common/sfc_efx/base/efx_impl.h | 11 ++ drivers/common/sfc_efx/base/efx_mae.c | 141 ++++++++++++++++++ .../sfc_efx/rte_common_sfc_efx_version.map | 1 + 4 files changed, 163 insertions(+), 1 deletion(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 8d88834c30..6f63a6ecd0 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4094,11 +4094,14 @@ typedef struct efx_mport_sel_s { uint32_t sel; } efx_mport_sel_t; +#define EFX_MPORT_NULL (0U) + /* * Get MPORT selector of a physical port. * * The resulting MPORT selector is opaque to the caller and can be - * passed as an argument to efx_mae_match_spec_mport_set(). + * passed as an argument to efx_mae_match_spec_mport_set() + * and efx_mae_action_set_populate_deliver(). */ LIBEFX_API extern __checkReturn efx_rc_t @@ -4163,6 +4166,12 @@ 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_deliver( + __in efx_mae_actions_t *spec, + __in const efx_mport_sel_t *mportp); + LIBEFX_API extern __checkReturn boolean_t efx_mae_action_set_specs_equal( diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 86ef8e1b92..927324c85c 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1699,7 +1699,18 @@ struct efx_mae_match_spec_s { } emms_mask_value_pairs; }; +typedef enum efx_mae_action_e { + /* DELIVER is always the last action. */ + EFX_MAE_ACTION_DELIVER, + + EFX_MAE_NACTIONS +} efx_mae_action_t; + typedef struct efx_mae_actions_s { + /* Bitmap of actions in spec, indexed by action type */ + uint32_t emass_actions; + + efx_mport_sel_t emass_deliver_mport; } efx_mae_actions_t; #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 01b2e311a5..47611c4397 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -641,6 +641,147 @@ 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_deliver( + __in efx_mae_actions_t *spec, + __in size_t arg_size, + __in_bcount(arg_size) const uint8_t *arg) +{ + efx_rc_t rc; + + if (arg_size != sizeof (spec->emass_deliver_mport)) { + rc = EINVAL; + goto fail1; + } + + if (arg == NULL) { + rc = EINVAL; + goto fail2; + } + + memcpy(&spec->emass_deliver_mport, arg, arg_size); + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + +typedef struct efx_mae_action_desc_s { + /* Action specific handler */ + efx_rc_t (*emad_add)(efx_mae_actions_t *, + size_t, const uint8_t *); +} efx_mae_action_desc_t; + +static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { + [EFX_MAE_ACTION_DELIVER] = { + .emad_add = efx_mae_action_set_add_deliver + } +}; + +static const uint32_t efx_mae_action_ordered_map = + (1U << EFX_MAE_ACTION_DELIVER); + +static const uint32_t efx_mae_action_repeat_map = 0; + +/* + * Add an action to an action set. + * + * This has to be invoked in the desired action order. + * An out-of-order action request will be turned down. + */ +static __checkReturn efx_rc_t +efx_mae_action_set_spec_populate( + __in efx_mae_actions_t *spec, + __in efx_mae_action_t type, + __in size_t arg_size, + __in_bcount(arg_size) const uint8_t *arg) +{ + uint32_t action_mask; + efx_rc_t rc; + + EFX_STATIC_ASSERT(EFX_MAE_NACTIONS <= + (sizeof (efx_mae_action_ordered_map) * 8)); + EFX_STATIC_ASSERT(EFX_MAE_NACTIONS <= + (sizeof (efx_mae_action_repeat_map) * 8)); + + EFX_STATIC_ASSERT(EFX_MAE_ACTION_DELIVER + 1 == EFX_MAE_NACTIONS); + + if (type >= EFX_ARRAY_SIZE(efx_mae_actions)) { + rc = EINVAL; + goto fail1; + } + + action_mask = (1U << type); + + if ((spec->emass_actions & action_mask) != 0) { + /* The action set already contains this action. */ + if ((efx_mae_action_repeat_map & action_mask) == 0) { + /* Cannot add another non-repeatable action. */ + rc = ENOTSUP; + goto fail2; + } + } + + if ((efx_mae_action_ordered_map & action_mask) != 0) { + uint32_t later_actions_mask = + efx_mae_action_ordered_map & + ~(action_mask | (action_mask - 1)); + + if ((spec->emass_actions & later_actions_mask) != 0) { + /* Cannot add an action after later ordered actions. */ + rc = ENOTSUP; + goto fail3; + } + } + + if (efx_mae_actions[type].emad_add != NULL) { + rc = efx_mae_actions[type].emad_add(spec, arg_size, arg); + if (rc != 0) + goto fail4; + } + + spec->emass_actions |= action_mask; + + return (0); + +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_action_set_populate_deliver( + __in efx_mae_actions_t *spec, + __in const efx_mport_sel_t *mportp) +{ + const uint8_t *arg; + efx_rc_t rc; + + if (mportp == NULL) { + rc = EINVAL; + goto fail1; + } + + arg = (const uint8_t *)&mportp->sel; + + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_DELIVER, sizeof (mportp->sel), arg)); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + __checkReturn boolean_t efx_mae_action_set_specs_equal( __in const efx_mae_actions_t *left, diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map index 86ed437e8d..d2a5d58ae8 100644 --- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map +++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map @@ -85,6 +85,7 @@ INTERNAL { efx_mac_stats_upload; efx_mac_up; + efx_mae_action_set_populate_deliver; efx_mae_action_set_spec_fini; efx_mae_action_set_spec_init; efx_mae_action_set_specs_equal; -- 2.17.1