From patchwork Fri Oct 15 06:49:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 101717 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 CFAD3A0C4C; Fri, 15 Oct 2021 08:49:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 331EE41194; Fri, 15 Oct 2021 08:49:20 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1B65841186 for ; Fri, 15 Oct 2021 08:49:19 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id CCD117F6F8; Fri, 15 Oct 2021 09:49:18 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 60C177F6C8; Fri, 15 Oct 2021 09:49:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 60C177F6C8 Authentication-Results: shelob.oktetlabs.ru/60C177F6C8; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Viacheslav Galaktionov , Andy Moreton Date: Fri, 15 Oct 2021 09:49:02 +0300 Message-Id: <20211015064903.3302489-3-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211015064903.3302489-1-andrew.rybchenko@oktetlabs.ru> References: <20211015064903.3302489-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/3] net/sfc: allow ports without MAE privilege 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" From: Viacheslav Galaktionov Register unprivileged ports in the switch domain registry in order to allow redirecting traffic to them. Differentiate between different levels of MAE support, update all MAE status checks. Signed-off-by: Viacheslav Galaktionov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 11 +++--- drivers/net/sfc/sfc_flow.c | 2 +- drivers/net/sfc/sfc_mae.c | 73 +++++++++++++++++++++--------------- drivers/net/sfc/sfc_mae.h | 3 +- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 8ec56a9ed5..43fb34dffa 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -187,7 +187,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; - if (mae->status == SFC_MAE_STATUS_SUPPORTED) { + if (mae->status == SFC_MAE_STATUS_SUPPORTED || + mae->status == SFC_MAE_STATUS_ADMIN) { dev_info->switch_info.name = dev->device->driver->name; dev_info->switch_info.domain_id = mae->switch_domain_id; dev_info->switch_info.port_id = mae->switch_port_id; @@ -2252,7 +2253,7 @@ sfc_representor_info_get(struct rte_eth_dev *dev, sfc_adapter_lock(sa); - if (sa->mae.status != SFC_MAE_STATUS_SUPPORTED) { + if (sa->mae.status != SFC_MAE_STATUS_ADMIN) { sfc_adapter_unlock(sa); return -ENOTSUP; } @@ -2698,7 +2699,7 @@ sfc_parse_switch_mode(struct sfc_adapter *sa, bool has_representors) goto fail_kvargs; if (switch_mode == NULL) { - sa->switchdev = encp->enc_mae_supported && + sa->switchdev = encp->enc_mae_admin && (!encp->enc_datapath_cap_evb || has_representors); } else if (strcasecmp(switch_mode, SFC_KVARG_SWITCH_MODE_LEGACY) == 0) { @@ -2833,9 +2834,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev, void *init_params) if (rc != 0) goto fail_attach; - if (sa->switchdev && sa->mae.status != SFC_MAE_STATUS_SUPPORTED) { + if (sa->switchdev && sa->mae.status != SFC_MAE_STATUS_ADMIN) { sfc_err(sa, - "failed to enable switchdev mode without MAE support"); + "failed to enable switchdev mode without admin MAE privilege"); rc = ENOTSUP; goto fail_switchdev_no_mae; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 81b9923644..d57235f358 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1275,7 +1275,7 @@ sfc_flow_parse_attr(struct sfc_adapter *sa, spec_filter->template.efs_rss_context = EFX_RSS_CONTEXT_DEFAULT; spec_filter->template.efs_priority = EFX_FILTER_PRI_MANUAL; } else { - if (mae->status != SFC_MAE_STATUS_SUPPORTED) { + if (mae->status != SFC_MAE_STATUS_ADMIN) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, "Transfer is not supported"); diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 4c5c7b776f..6a1385283b 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -197,23 +197,25 @@ sfc_mae_attach(struct sfc_adapter *sa) return 0; } - sfc_log_init(sa, "init MAE"); - rc = efx_mae_init(sa->nic); - if (rc != 0) - goto fail_mae_init; + if (encp->enc_mae_admin) { + sfc_log_init(sa, "init MAE"); + rc = efx_mae_init(sa->nic); + if (rc != 0) + goto fail_mae_init; - sfc_log_init(sa, "get MAE limits"); - rc = efx_mae_get_limits(sa->nic, &limits); - if (rc != 0) - goto fail_mae_get_limits; + sfc_log_init(sa, "get MAE limits"); + rc = efx_mae_get_limits(sa->nic, &limits); + if (rc != 0) + goto fail_mae_get_limits; - sfc_log_init(sa, "init MAE counter registry"); - rc = sfc_mae_counter_registry_init(&mae->counter_registry, - limits.eml_max_n_counters); - if (rc != 0) { - sfc_err(sa, "failed to init MAE counters registry for %u entries: %s", - limits.eml_max_n_counters, rte_strerror(rc)); - goto fail_counter_registry_init; + sfc_log_init(sa, "init MAE counter registry"); + rc = sfc_mae_counter_registry_init(&mae->counter_registry, + limits.eml_max_n_counters); + if (rc != 0) { + sfc_err(sa, "failed to init MAE counters registry for %u entries: %s", + limits.eml_max_n_counters, rte_strerror(rc)); + goto fail_counter_registry_init; + } } sfc_log_init(sa, "assign entity MPORT"); @@ -238,21 +240,28 @@ sfc_mae_attach(struct sfc_adapter *sa) if (rc != 0) goto fail_mae_assign_switch_port; - sfc_log_init(sa, "allocate encap. header bounce buffer"); - bounce_eh->buf_size = limits.eml_encap_header_size_limit; - bounce_eh->buf = rte_malloc("sfc_mae_bounce_eh", - bounce_eh->buf_size, 0); - if (bounce_eh->buf == NULL) - goto fail_mae_alloc_bounce_eh; - - mae->status = SFC_MAE_STATUS_SUPPORTED; - mae->nb_outer_rule_prios_max = limits.eml_max_n_outer_prios; - mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios; - mae->encap_types_supported = limits.eml_encap_types_supported; + if (encp->enc_mae_admin) { + sfc_log_init(sa, "allocate encap. header bounce buffer"); + bounce_eh->buf_size = limits.eml_encap_header_size_limit; + bounce_eh->buf = rte_malloc("sfc_mae_bounce_eh", + bounce_eh->buf_size, 0); + if (bounce_eh->buf == NULL) + goto fail_mae_alloc_bounce_eh; + + mae->nb_outer_rule_prios_max = limits.eml_max_n_outer_prios; + mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios; + mae->encap_types_supported = limits.eml_encap_types_supported; + } + TAILQ_INIT(&mae->outer_rules); TAILQ_INIT(&mae->encap_headers); TAILQ_INIT(&mae->action_sets); + if (encp->enc_mae_admin) + mae->status = SFC_MAE_STATUS_ADMIN; + else + mae->status = SFC_MAE_STATUS_SUPPORTED; + sfc_log_init(sa, "done"); return 0; @@ -261,11 +270,13 @@ sfc_mae_attach(struct sfc_adapter *sa) fail_mae_assign_switch_port: fail_mae_assign_switch_domain: fail_mae_assign_entity_mport: - sfc_mae_counter_registry_fini(&mae->counter_registry); + if (encp->enc_mae_admin) + sfc_mae_counter_registry_fini(&mae->counter_registry); fail_counter_registry_init: fail_mae_get_limits: - efx_mae_fini(sa->nic); + if (encp->enc_mae_admin) + efx_mae_fini(sa->nic); fail_mae_init: sfc_log_init(sa, "failed %d", rc); @@ -284,7 +295,7 @@ sfc_mae_detach(struct sfc_adapter *sa) mae->nb_action_rule_prios_max = 0; mae->status = SFC_MAE_STATUS_UNKNOWN; - if (status_prev != SFC_MAE_STATUS_SUPPORTED) + if (status_prev != SFC_MAE_STATUS_ADMIN) return; rte_free(mae->bounce_eh.buf); @@ -4036,9 +4047,9 @@ sfc_mae_switchdev_init(struct sfc_adapter *sa) return 0; } - if (mae->status != SFC_MAE_STATUS_SUPPORTED) { + if (mae->status != SFC_MAE_STATUS_ADMIN) { rc = ENOTSUP; - sfc_err(sa, "failed to init switchdev - no MAE support"); + sfc_err(sa, "failed to init switchdev - no admin MAE privilege"); goto fail_no_mae; } diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index 6c1a5bfee7..23dcf1e482 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -88,7 +88,8 @@ TAILQ_HEAD(sfc_mae_action_sets, sfc_mae_action_set); enum sfc_mae_status { SFC_MAE_STATUS_UNKNOWN = 0, SFC_MAE_STATUS_UNSUPPORTED, - SFC_MAE_STATUS_SUPPORTED + SFC_MAE_STATUS_SUPPORTED, + SFC_MAE_STATUS_ADMIN, }; /*