From patchwork Thu Sep 2 14:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 97820 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 4B7B4A0C4C; Thu, 2 Sep 2021 16:24:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB7FC406A3; Thu, 2 Sep 2021 16:24:12 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id BFC954003C for ; Thu, 2 Sep 2021 16:24:09 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.121.157]) (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 7B5867F6C2; Thu, 2 Sep 2021 17:24:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 7B5867F6C2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1630592649; bh=d13QPjIE1BqphbLQrxSGgE4bDZZ7EctKy+GiEVdT5DI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iIDkadRANBc20iTwdjltnvfVLMpeI/CbFdouWXHKjMe7EnW2UJrV6a+X2CIauxfVB yWzFEwJWCR+8M5dcshv74PRqzdU4esioD21UQiwl7qB/bnM45Q3IztO226yfx5ohpt JI4q0Khzc2ji5wKP4Dk9KZY1NwR2TzmJYPnr4y2k= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Thu, 2 Sep 2021 17:23:56 +0300 Message-Id: <20210902142359.28138-3-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210902142359.28138-1-ivan.malov@oktetlabs.ru> References: <20210902142359.28138-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/5] net/sfc: provide API to negotiate supported Rx meta features 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" This is a preparation step. Later patches will make features FLAG and MARK on EF100 native Rx datapath available to users. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_flow.c | 10 +++++----- drivers/net/sfc/sfc_mae.c | 22 ++++++++++++++++++++-- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 331e06bac6..2812d76cbb 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -312,6 +312,8 @@ struct sfc_adapter { boolean_t tso; boolean_t tso_encap; + uint64_t negotiated_rx_meta; + uint32_t rxd_wait_timeout_ns; }; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2db0d000c3..57bcccdb1b 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1859,6 +1859,27 @@ sfc_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t ethdev_qid) return sap->dp_rx->intr_disable(rxq_info->dp); } +static int +sfc_negotiate_rx_meta(struct rte_eth_dev *dev, uint64_t *features) +{ + struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); + + sfc_adapter_lock(sa); + + if ((sa->priv.dp_rx->features & SFC_DP_RX_FEAT_FLOW_FLAG) != 0) + sa->negotiated_rx_meta |= RTE_ETH_RX_META_USER_FLAG; + + if ((sa->priv.dp_rx->features & SFC_DP_RX_FEAT_FLOW_MARK) != 0) + sa->negotiated_rx_meta |= RTE_ETH_RX_META_USER_MARK; + + sa->negotiated_rx_meta &= *features; + *features = sa->negotiated_rx_meta; + + sfc_adapter_unlock(sa); + + return 0; +} + static const struct eth_dev_ops sfc_eth_dev_ops = { .dev_configure = sfc_dev_configure, .dev_start = sfc_dev_start, @@ -1906,6 +1927,7 @@ static const struct eth_dev_ops sfc_eth_dev_ops = { .xstats_get_by_id = sfc_xstats_get_by_id, .xstats_get_names_by_id = sfc_xstats_get_names_by_id, .pool_ops_supported = sfc_pool_ops_supported, + .negotiate_rx_meta = sfc_negotiate_rx_meta, }; /** @@ -1998,6 +2020,18 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev) goto fail_dp_rx_name; } + if (strcmp(dp_rx->dp.name, SFC_KVARG_DATAPATH_EF10_ESSB) == 0) { + /* + * Datapath EF10 ESSB is available only on EF10 NICs running + * Rx FW variant DPDK, which always provides fields FLAG and + * MARK in Rx prefix, so point this fact out below. This way, + * legacy applications from EF10 era, which are not aware of + * rte_eth_negotiate_rx_meta(), can keep the workflow intact. + */ + sa->negotiated_rx_meta |= RTE_ETH_RX_META_USER_FLAG; + sa->negotiated_rx_meta |= RTE_ETH_RX_META_USER_MARK; + } + sfc_notice(sa, "use %s Rx datapath", sas->dp_rx_name); rc = sfc_kvargs_process(sa, SFC_KVARG_TX_DATAPATH, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 4f5993a68d..a2034b5f5e 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1759,7 +1759,7 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, int rc; struct sfc_flow_spec *spec = &flow->spec; struct sfc_flow_spec_filter *spec_filter = &spec->filter; - const unsigned int dp_rx_features = sa->priv.dp_rx->features; + const uint64_t rx_meta = sa->negotiated_rx_meta; uint32_t actions_set = 0; const uint32_t fate_actions_mask = (1UL << RTE_FLOW_ACTION_TYPE_QUEUE) | (1UL << RTE_FLOW_ACTION_TYPE_RSS) | @@ -1827,10 +1827,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, if ((actions_set & mark_actions_mask) != 0) goto fail_actions_overlap; - if ((dp_rx_features & SFC_DP_RX_FEAT_FLOW_FLAG) == 0) { + if ((rx_meta & RTE_ETH_RX_META_USER_FLAG) == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "FLAG action is not supported on the current Rx datapath"); + "Action FLAG is unsupported on the current Rx datapath or has not been negotiated"); return -rte_errno; } @@ -1844,10 +1844,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, if ((actions_set & mark_actions_mask) != 0) goto fail_actions_overlap; - if ((dp_rx_features & SFC_DP_RX_FEAT_FLOW_MARK) == 0) { + if ((rx_meta & RTE_ETH_RX_META_USER_MARK) == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "MARK action is not supported on the current Rx datapath"); + "Action MARK is unsupported on the current Rx datapath or has not been negotiated"); return -rte_errno; } diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 4b520bc619..89c161ef88 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -2963,6 +2963,7 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, efx_mae_actions_t *spec, struct rte_flow_error *error) { + const uint64_t rx_meta = sa->negotiated_rx_meta; bool custom_error = B_FALSE; int rc = 0; @@ -3012,12 +3013,29 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, case RTE_FLOW_ACTION_TYPE_FLAG: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_FLAG, bundle->actions_mask); - rc = efx_mae_action_set_populate_flag(spec); + if ((rx_meta & RTE_ETH_RX_META_USER_FLAG) != 0) { + rc = efx_mae_action_set_populate_flag(spec); + } else { + rc = rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + action, + "Action FLAG has not been negotiated"); + custom_error = B_TRUE; + } break; case RTE_FLOW_ACTION_TYPE_MARK: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_MARK, bundle->actions_mask); - rc = sfc_mae_rule_parse_action_mark(sa, action->conf, spec); + if ((rx_meta & RTE_ETH_RX_META_USER_MARK) != 0) { + rc = sfc_mae_rule_parse_action_mark(sa, action->conf, + spec); + } else { + rc = rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + action, + "Action MARK has not been negotiated"); + custom_error = B_TRUE; + } break; case RTE_FLOW_ACTION_TYPE_PHY_PORT: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PHY_PORT,