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 84652A04DD; Tue, 20 Oct 2020 10:59:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D20C8BC6C; Tue, 20 Oct 2020 10:49:44 +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 B76F1BBA6 for ; Tue, 20 Oct 2020 10:49:02 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.60]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 02CE560089 for ; Tue, 20 Oct 2020 08:49:01 +0000 (UTC) Received: from us4-mdac16-7.ut7.mdlocal (unknown [10.7.65.75]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 0380B200A0 for ; Tue, 20 Oct 2020 08:49:01 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.33]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 74A511C0054 for ; Tue, 20 Oct 2020 08:49:00 +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 2AD1FA80061 for ; Tue, 20 Oct 2020 08:49:00 +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 09:48:50 +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 09:48:50 +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 09K8mnG3030820; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 15C961616D5; Tue, 20 Oct 2020 09:48:50 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:48:11 +0100 Message-ID: <1603183709-23420-45-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> References: <1603183709-23420-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.065200-8.000000-10 X-TMASE-MatchedRID: 3ksEd+Y0lhRu0gVhNXVDBHYZxYoZm58FK1PH96GPPGCZfDRE1uqSgu1+ sfrt9AWI2XHJ0L4jOIRTvVffeIwvQ4SH/KD/7QRgnFVnNmvv47tLXPA26IG0hN9RlPzeVuQQbaa h63IrZyfR1p6w/8fEozoDS4rfut35X+8u+zQ7JmKqDSBu0tUhr4HLFWR93TgkHWtVZN0asTi1lc oibF/5wUxwpTUboUzT7uiIyPP00Otw1/wpADjDvGhCG8qMW+KyBnIRIVcCWN9s98Z8fG/6kS9+7 r4Ve5ORzAGZU0rgjylsMyD1FAVfKvzEorjs/fJlD3uYMxd01bd9LQinZ4QefPcjNeVeWlqY+gtH j7OwNO2tdP9AzJTY3NtLmhUDutwNn7lxBBp+zgrK30zxQlCIv9vosV/0Q+z83J0NP0GJI4sA1B7 YuKd0v85ZpbBQ5omwWXp4ELZuAse+BLCmO4JWR9pAu0sLxpSoQ8G+yYJYYdZRZDsGiXQioL4jxK nHJRLcVcr204P67pw= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-1.065200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183740-LszZGc9bMFIM X-PPE-DISP: 1603183740;LszZGc9bMFIM Subject: [dpdk-dev] [PATCH 44/62] net/sfc: support flow action PORT ID in transfer rules 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 The action handler will use MAE action DELIVER with MPORT of the PCIe function associated with a given DPDK port ID. The DPDK port must not relate to a different physical device. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/sfc_mae.c | 33 ++++++++++++++++++++ drivers/net/sfc/sfc_switch.c | 58 ++++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_switch.h | 6 ++++ 4 files changed, 99 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index ba73391d5f..7b8c1c8527 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -218,6 +218,8 @@ Supported actions (***transfer*** rules): - VF +- PORT_ID + - DROP Validating flow rules depends on the firmware variant. diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 64cd6b0e9b..f309efa2cf 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -30,6 +30,7 @@ sfc_mae_assign_entity_mport(struct sfc_adapter *sa, int sfc_mae_attach(struct sfc_adapter *sa) { + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); struct sfc_mae_switch_port_request switch_port_request = {0}; const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); efx_mport_sel_t entity_mport; @@ -67,6 +68,12 @@ sfc_mae_attach(struct sfc_adapter *sa) sfc_log_init(sa, "assign RTE switch port"); switch_port_request.type = SFC_MAE_SWITCH_PORT_INDEPENDENT; switch_port_request.entity_mportp = &entity_mport; + /* + * As of now, the driver does not support representors, so + * RTE ethdev MPORT simply matches that of the entity. + */ + switch_port_request.ethdev_mportp = &entity_mport; + switch_port_request.ethdev_port_id = sas->port_id; rc = sfc_mae_assign_switch_port(mae->switch_domain_id, &switch_port_request, &mae->switch_port_id); @@ -793,6 +800,27 @@ sfc_mae_rule_parse_action_pf_vf(struct sfc_adapter *sa, return efx_mae_action_set_populate_deliver(spec, &mport); } +static int +sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa, + const struct rte_flow_action_port_id *conf, + efx_mae_actions_t *spec) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + struct sfc_mae *mae = &sa->mae; + efx_mport_sel_t mport; + uint16_t port_id; + int rc; + + port_id = (conf->original != 0) ? sas->port_id : conf->id; + + rc = sfc_mae_switch_port_by_ethdev(mae->switch_domain_id, + port_id, &mport); + if (rc != 0) + return rc; + + return efx_mae_action_set_populate_deliver(spec, &mport); +} + static int sfc_mae_rule_parse_action(struct sfc_adapter *sa, const struct rte_flow_action *action, @@ -848,6 +876,11 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, bundle->actions_mask); rc = sfc_mae_rule_parse_action_pf_vf(sa, action->conf, spec); break; + case RTE_FLOW_ACTION_TYPE_PORT_ID: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PORT_ID, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_port_id(sa, action->conf, spec); + break; case RTE_FLOW_ACTION_TYPE_DROP: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DROP, bundle->actions_mask); diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index 395fc40263..bdea2a2446 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -41,10 +41,22 @@ * This mapping comprises a port type to ensure that RTE switch port ID * of a represented entity and that of its representor are different in * the case when the entity gets plugged into DPDK and not into a guest. + * + * Entry data also comprises RTE ethdev's own MPORT. This value + * coincides with the entity MPORT in the case of independent ports. + * In the case of representors, this ID is not a selector and refers + * to an allocatable object (that is, it's likely to change on RTE + * ethdev replug). Flow API backend must use this value rather + * than entity_mport to support flow rule action PORT_ID. */ struct sfc_mae_switch_port { TAILQ_ENTRY(sfc_mae_switch_port) switch_domain_ports; + /** RTE ethdev MPORT */ + efx_mport_sel_t ethdev_mport; + /** RTE ethdev port ID */ + uint16_t ethdev_port_id; + /** Entity (PCIe function) MPORT selector */ efx_mport_sel_t entity_mport; /** Port type (independent/representor) */ @@ -263,6 +275,9 @@ sfc_mae_assign_switch_port(uint16_t switch_domain_id, TAILQ_INSERT_TAIL(&domain->ports, port, switch_domain_ports); done: + port->ethdev_mport = *req->ethdev_mportp; + port->ethdev_port_id = req->ethdev_port_id; + *switch_port_id = port->id; rte_spinlock_unlock(&sfc_mae_switch.lock); @@ -274,3 +289,46 @@ sfc_mae_assign_switch_port(uint16_t switch_domain_id, rte_spinlock_unlock(&sfc_mae_switch.lock); return rc; } + +/* This function expects to be called only when the lock is held */ +static int +sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel) +{ + struct sfc_mae_switch_domain *domain; + struct sfc_mae_switch_port *port; + + SFC_ASSERT(rte_spinlock_is_locked(&sfc_mae_switch.lock)); + + if (ethdev_port_id == RTE_MAX_ETHPORTS) + return EINVAL; + + domain = sfc_mae_find_switch_domain_by_id(switch_domain_id); + if (domain == NULL) + return EINVAL; + + TAILQ_FOREACH(port, &domain->ports, switch_domain_ports) { + if (port->ethdev_port_id == ethdev_port_id) { + *mport_sel = port->ethdev_mport; + return 0; + } + } + + return ENOENT; +} + +int +sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel) +{ + int rc; + + rte_spinlock_lock(&sfc_mae_switch.lock); + rc = sfc_mae_find_switch_port_by_ethdev(switch_domain_id, + ethdev_port_id, mport_sel); + rte_spinlock_unlock(&sfc_mae_switch.lock); + + return rc; +} diff --git a/drivers/net/sfc/sfc_switch.h b/drivers/net/sfc/sfc_switch.h index 9845ac8801..96ece95654 100644 --- a/drivers/net/sfc/sfc_switch.h +++ b/drivers/net/sfc/sfc_switch.h @@ -32,6 +32,8 @@ enum sfc_mae_switch_port_type { struct sfc_mae_switch_port_request { enum sfc_mae_switch_port_type type; const efx_mport_sel_t *entity_mportp; + const efx_mport_sel_t *ethdev_mportp; + uint16_t ethdev_port_id; }; int sfc_mae_assign_switch_domain(struct sfc_adapter *sa, @@ -41,6 +43,10 @@ int sfc_mae_assign_switch_port(uint16_t switch_domain_id, const struct sfc_mae_switch_port_request *req, uint16_t *switch_port_id); +int sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel); + #ifdef __cplusplus } #endif -- 2.17.1