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 1BB6C42C04; Thu, 1 Jun 2023 16:36:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBC1342D17; Thu, 1 Jun 2023 16:36:02 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 856AD42D0B for ; Thu, 1 Jun 2023 16:36:01 +0200 (CEST) Received: from localhost.localdomain (unknown [141.136.91.67]) (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 agw.arknetworks.am (Postfix) with ESMTPSA id 6FF1DE0455; Thu, 1 Jun 2023 18:36:00 +0400 (+04) From: Artemii Morozov To: dev@dpdk.org Cc: Ivan Malov , Viacheslav Galaktionov , Andrew Rybchenko , Andy Moreton Subject: [PATCH v3 2/3] common/sfc_efx/base: add support to enable VLAN stripping Date: Thu, 1 Jun 2023 18:35:44 +0400 Message-Id: <20230601143545.95362-3-artemii.morozov@arknetworks.am> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230601143545.95362-1-artemii.morozov@arknetworks.am> References: <20230601081203.70142-2-artemii.morozov@arknetworks.am> <20230601143545.95362-1-artemii.morozov@arknetworks.am> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 To enable VLAN stripping, two conditions must be met: the corresponding flag must be set and the appropriate RX prefix should be requested. VLAN stripping is supported for ef100 datapath only. Signed-off-by: Artemii Morozov Reviewed-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++ drivers/common/sfc_efx/base/ef10_impl.h | 1 + drivers/common/sfc_efx/base/efx.h | 9 +++++++++ drivers/common/sfc_efx/base/efx_filter.c | 3 ++- drivers/common/sfc_efx/base/efx_impl.h | 1 + drivers/common/sfc_efx/base/efx_rx.c | 17 +++++++++++++++++ drivers/common/sfc_efx/base/rhead_rx.c | 3 +++ 7 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c index d6940011c0..7371451098 100644 --- a/drivers/common/sfc_efx/base/ef10_filter.c +++ b/drivers/common/sfc_efx/base/ef10_filter.c @@ -338,6 +338,11 @@ efx_mcdi_filter_op_add( FILTER_OP_V3_IN_MATCH_SET_FLAG, 1); } + if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) { + MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS, + FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1); + } + efx_mcdi_execute(enp, &req); if (req.emr_rc != 0) { @@ -852,6 +857,16 @@ ef10_filter_add_internal( hash = ef10_filter_hash(spec); + /* + * VLAN stripping is offload at the device level, and it should be + * applied to all filters if it has been applied at least once before. + * Knowledge of device level vlan strip offload being enabled comes from + * the default RxQ flags, albeit the flag may be set on any queue. + * But only default RxQ affects this 'eft_strip_vlan' decision. + */ + if (eftp->eft_strip_vlan) + spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP; + /* * FIXME: Add support for inserting filters of different priorities * and removing lower priority multicast filters (bug 42378) @@ -2010,6 +2025,9 @@ ef10_filter_reconfigure( else filter_flags = 0; + if (table->eft_strip_vlan) + filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP; + /* Mark old filters which may need to be removed */ ef10_filter_mark_old_filters(enp); @@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set( EFSYS_ASSERT(using_rss == B_FALSE); table->eft_using_rss = B_FALSE; #endif + if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP) + table->eft_strip_vlan = B_TRUE; table->eft_default_rxq = erp; } @@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear( table->eft_default_rxq = NULL; table->eft_using_rss = B_FALSE; + table->eft_strip_vlan = B_FALSE; } diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h index 877aedad45..017e561f19 100644 --- a/drivers/common/sfc_efx/base/ef10_impl.h +++ b/drivers/common/sfc_efx/base/ef10_impl.h @@ -1287,6 +1287,7 @@ typedef struct ef10_filter_table_s { ef10_filter_entry_t eft_entry[EFX_EF10_FILTER_TBL_ROWS]; efx_rxq_t *eft_default_rxq; boolean_t eft_using_rss; + boolean_t eft_strip_vlan; uint32_t eft_unicst_filter_indexes[ EFX_EF10_FILTER_UNICAST_FILTERS_MAX]; uint32_t eft_unicst_filter_count; diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index ac89b418e0..508d0a802d 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -3101,6 +3101,10 @@ typedef enum efx_rxq_type_e { * Request user flag field in the Rx prefix of a queue. */ #define EFX_RXQ_FLAG_USER_FLAG 0x20 +/* + * Request vlan tci field in the Rx prefix of a queue. + */ +#define EFX_RXQ_FLAG_VLAN_STRIP 0x40 LIBEFX_API extern __checkReturn efx_rc_t @@ -3455,6 +3459,11 @@ efx_tx_qdestroy( #define EFX_FILTER_FLAG_ACTION_FLAG 0x20 /* Set match mark on the received packet */ #define EFX_FILTER_FLAG_ACTION_MARK 0x40 +/* + * Request that the first tag in the outer L2 header be stripped + * and TCI be indicated in Rx prefix. + */ +#define EFX_FILTER_FLAG_VLAN_STRIP 0x80 typedef uint8_t efx_filter_flags_t; diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c index 83c37ff859..778ed0c370 100644 --- a/drivers/common/sfc_efx/base/efx_filter.c +++ b/drivers/common/sfc_efx/base/efx_filter.c @@ -322,7 +322,8 @@ efx_filter_spec_init_rx( EFSYS_ASSERT3P(spec, !=, NULL); EFSYS_ASSERT3P(erp, !=, NULL); EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS | - EFX_FILTER_FLAG_RX_SCATTER)) == 0); + EFX_FILTER_FLAG_RX_SCATTER | + EFX_FILTER_FLAG_VLAN_STRIP)) == 0); memset(spec, 0, sizeof (*spec)); spec->efs_priority = priority; diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 45e99d01c5..c45669e077 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1045,6 +1045,7 @@ struct efx_rxq_s { efsys_mem_t *er_esmp; efx_evq_rxq_state_t *er_ev_qstate; efx_rx_prefix_layout_t er_prefix_layout; + uint16_t er_flags; }; #define EFX_RXQ_MAGIC 0x15022005 diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c index 61726a9f0b..55ffa82033 100644 --- a/drivers/common/sfc_efx/base/efx_rx.c +++ b/drivers/common/sfc_efx/base/efx_rx.c @@ -925,6 +925,7 @@ efx_rx_qcreate_internal( erp->er_index = index; erp->er_mask = ndescs - 1; erp->er_esmp = esmp; + erp->er_flags = 0; if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp, ndescs, id, flags, eep, erp)) != 0) @@ -943,11 +944,27 @@ efx_rx_qcreate_internal( } } + if (flags & EFX_RXQ_FLAG_VLAN_STRIP) { + const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout; + const efx_rx_prefix_field_info_t *vlan_tci_field; + + vlan_tci_field = + &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI]; + if (vlan_tci_field->erpfi_width_bits == 0) { + rc = ENOTSUP; + goto fail6; + } + + erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP; + } + enp->en_rx_qcount++; *erpp = erp; return (0); +fail6: + EFSYS_PROBE(fail6); fail5: EFSYS_PROBE(fail5); diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c index d0ac5c02f8..3453227388 100644 --- a/drivers/common/sfc_efx/base/rhead_rx.c +++ b/drivers/common/sfc_efx/base/rhead_rx.c @@ -640,6 +640,9 @@ rhead_rx_qcreate( if (flags & EFX_RXQ_FLAG_USER_FLAG) fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG; + if (flags & EFX_RXQ_FLAG_VLAN_STRIP) + fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI; + /* * LENGTH is required in EF100 host interface, as receive events * do not include the packet length. -- 2.34.1