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 B348EA00C2; Wed, 23 Feb 2022 19:49:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E13C41178; Wed, 23 Feb 2022 19:49:01 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2063.outbound.protection.outlook.com [40.107.237.63]) by mails.dpdk.org (Postfix) with ESMTP id 076AE41169 for ; Wed, 23 Feb 2022 19:48:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BwxEsUmYP5iKy6cTmFsFKz+HVhThd+XEmPJ6t9MMT/tsr2P1N+z8Wa/BQVT3c6mGNntdrG2rx9m6mBP6GHPPwTyFE3HJ8v3C3QUMpdqA6/48dthjj1wdmE7BQDEZRMudm1438MSzX+xj7GZAzLSLpKwU0rmHPnAimCQCWKrm/Bs6jx4hrCdcWUmF7DuQvnyIZMoIvWHEJHQf8TjGOwmWlgMbZe+qr8YcHCDCCl9sxQ0s6VPbHsFkpZF9J2qHN2UyeHuRnFgIsldI6ZAcouC3hitt1E5FN0eiya/siVNLGQCtKFmJtDUdScfhIi06MokAOk8ARXyp5fGH/kZq95ZN6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2VaDGWiAwATw0b8NJSAIEKlm+uw1wtlA6Psm47dMQlo=; b=DVHjETkzXMH2BbCPzuBgQV1BDDIqPeUbjEl28LTGnHXy/xoA5nTkNjg5bOMVGAZL+FYeiouH3UETqGzGLJw8ii4RtUzucC1HOYfK6T4Li1DFvM3BFE6KByNVtawoEOO+qASDUxpj0UDl/PsvG+hx1eBVardu5WBsul6nyTJF04R26GWUdQxwzTVF/VK7dsLIcO5X9hVYoOB0zLCJ1BwRQmEwAoRQgbykShXMzZDa/SqKCimvzbOx6Z3/jq1SZ89/cEhZ8JyIc15VuGJ53OUXm4HcpUd7pavBkSHfz7E+CJjSNTzckvJVaUVb+8B/2u7QVaRxSmkluVJwhbBblXT2PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2VaDGWiAwATw0b8NJSAIEKlm+uw1wtlA6Psm47dMQlo=; b=eZWSok1wf8es9Z4KaoSQ4Q33b9Th4QCEO42cU9HEDiVKnUZ5Z1RDsRZ3nWMV52b8KIXz+Hj1hMStPD+OnsjGob9DP7RqNIIelcB04voD+Pu+Ifa7B6ZyYDC8KyO0ETgkRyQtjwRWU3+ZaYK0fX2gLT4EeRaYh4afCrQb4E4IWEnorIK/4t19b+ww+NA0raX5H4Wn/pNM2a3TC85ky6hXwBaM3jZ75YU06SYf78ka/9uIr/RbR5FnvmVVxzZgiouBbf0IA2l2EHRQoJYeg3FQmRbxEplT3kprAb2NTpKIC4bR1ICNyhJ7VbcNfZAC76XRHjHg6s7ChP/4nHIyRdoSSw== Received: from MWHPR14CA0066.namprd14.prod.outlook.com (2603:10b6:300:81::28) by DM6PR12MB2923.namprd12.prod.outlook.com (2603:10b6:5:180::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.27; Wed, 23 Feb 2022 18:48:55 +0000 Received: from CO1NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::29) by MWHPR14CA0066.outlook.office365.com (2603:10b6:300:81::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21 via Frontend Transport; Wed, 23 Feb 2022 18:48:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT021.mail.protection.outlook.com (10.13.175.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5017.22 via Frontend Transport; Wed, 23 Feb 2022 18:48:54 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 23 Feb 2022 18:48:54 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Wed, 23 Feb 2022 10:48:53 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Wed, 23 Feb 2022 10:48:52 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH v2 6/6] net/mlx5: support queue/RSS action for external RxQ Date: Wed, 23 Feb 2022 20:48:35 +0200 Message-ID: <20220223184835.3061161-7-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223184835.3061161-1-michaelba@nvidia.com> References: <20220222210416.2669519-1-michaelba@nvidia.com> <20220223184835.3061161-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1804e37a-2b69-4ba4-e363-08d9f6fd248b X-MS-TrafficTypeDiagnostic: DM6PR12MB2923:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6pEYGxoGXolHThcvqtrkzh/PdYhkVK/0eF8U5Xx/Eae0nFYFo9uB2GOuUjVgKi/zRVPUrbyNUaaig7EJmV8hdriJ/e0JZ0eJEBJGUOzJanES/6OkOt47ZQYwuSxEmzCNwo7dKvDcWgxqeONUb3Bv/cVfTj3Bp0zji1/PoyKWz7NDxDRbB22wm/zkEdBeVoXCo0EL/qNxh8usypfuKMDWP/xAfBr60gsxVj/Tuddlp23jH90ruFku+vkzvKS9jbcTOw4/loXE08h2nx9RMeZaACxVP3lcF810NddQPkWEbEbWReCnsV6jKQ1Q87VnxOj78PFf4VbCQu2dqeUMTysk6ZEBvscgycaTL/haZfRL963KW5RB6iAoAqNamTNqJZ+JFxt3nP/+MDxP6hh++ubkE5fd9Jbwehs3oWLsJz37jI4TEGinRtaqkfT1yICyvny3HqxPkD2xUBQWJP9CKVU/EzvusotofxxGu1LMqQt8aTcvasa2/HZNm6v70bKqlHF3PKHVm6t6Jem0qqzkxGuDE+D7QnCIqifXvJaUY+mH9VSqV91mNnwkR/9BOPVn08iJ80O/+Mlmmhe7Vw8kMWcQE6hILRaIc36F38n9LVjtQwTOpe5i1/IFc58EuuhC/CeHEEnMarU6/H7re+sh7ekYZsmjXQGubNAIwy6HJBqRdgngYa14mLvxDhUeVEhQWR2KmBWo9+Q4P0KJblEnu7aDqg== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2906002)(86362001)(82310400004)(356005)(55016003)(81166007)(40460700003)(36860700001)(6916009)(54906003)(7696005)(6666004)(26005)(107886003)(8676002)(36756003)(508600001)(316002)(70586007)(5660300002)(4326008)(336012)(30864003)(8936002)(6286002)(186003)(426003)(70206006)(47076005)(83380400001)(2616005)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 18:48:54.8536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1804e37a-2b69-4ba4-e363-08d9f6fd248b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2923 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 Add support queue/RSS action for external RxQ. In indirection table creation, the queue index will be taken from mapping array. This feature supports neither LRO nor Hairpin. Signed-off-by: Michael Baum --- doc/guides/nics/mlx5.rst | 1 + doc/guides/rel_notes/release_22_03.rst | 1 + drivers/net/mlx5/mlx5.c | 8 +- drivers/net/mlx5/mlx5_devx.c | 30 +++++-- drivers/net/mlx5/mlx5_flow.c | 29 +++++-- drivers/net/mlx5/mlx5_rx.h | 30 +++++++ drivers/net/mlx5/mlx5_rxq.c | 116 +++++++++++++++++++++++-- 7 files changed, 189 insertions(+), 26 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 8956cd1dd8..34be031360 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -38,6 +38,7 @@ Features - Multiple TX and RX queues. - Shared Rx queue. - Rx queue delay drop. +- Support steering for external Rx queue created outside the PMD. - Support for scattered TX frames. - Advanced support for scattered Rx frames with tunable buffer attributes. - IPv4, IPv6, TCPv4, TCPv6, UDPv4 and UDPv6 RSS on any number of queues. diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index acd56e0a80..c093616d7f 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -123,6 +123,7 @@ New Features Updated the Mellanox mlx5 driver with new features and improvements, including: * Support ConnectX-7 capability to schedule traffic sending on timestamp + * Support steering for external Rx queue created outside the PMD. * **Updated Wangxun ngbe driver.** diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 415e0fe2f2..9760f52b46 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1855,8 +1855,6 @@ mlx5_dev_close(struct rte_eth_dev *dev) close(priv->nl_socket_rdma); if (priv->vmwa_context) mlx5_vlan_vmwa_exit(priv->vmwa_context); - if (priv->ext_rxqs) - mlx5_free(priv->ext_rxqs); ret = mlx5_hrxq_verify(dev); if (ret) DRV_LOG(WARNING, "port %u some hash Rx queue still remain", @@ -1869,6 +1867,10 @@ mlx5_dev_close(struct rte_eth_dev *dev) if (ret) DRV_LOG(WARNING, "port %u some Rx queue objects still remain", dev->data->port_id); + ret = mlx5_ext_rxq_verify(dev); + if (ret) + DRV_LOG(WARNING, "Port %u some external RxQ still remain.", + dev->data->port_id); ret = mlx5_rxq_verify(dev); if (ret) DRV_LOG(WARNING, "port %u some Rx queues still remain", @@ -1887,6 +1889,8 @@ mlx5_dev_close(struct rte_eth_dev *dev) dev->data->port_id); if (priv->hrxqs) mlx5_list_destroy(priv->hrxqs); + if (priv->ext_rxqs) + mlx5_free(priv->ext_rxqs); /* * Free the shared context in last turn, because the cleanup * routines above may use some shared fields, like diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index e4bc90a30e..8aa68d9658 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -580,13 +580,21 @@ mlx5_devx_ind_table_create_rqt_attr(struct rte_eth_dev *dev, return rqt_attr; } for (i = 0; i != queues_n; ++i) { - struct mlx5_rxq_priv *rxq = mlx5_rxq_get(dev, queues[i]); + if (mlx5_is_external_rxq(dev, queues[i])) { + struct mlx5_external_rxq *ext_rxq = + mlx5_ext_rxq_get(dev, queues[i]); - MLX5_ASSERT(rxq != NULL); - if (rxq->ctrl->is_hairpin) - rqt_attr->rq_list[i] = rxq->ctrl->obj->rq->id; - else - rqt_attr->rq_list[i] = rxq->devx_rq.rq->id; + rqt_attr->rq_list[i] = ext_rxq->hw_id; + } else { + struct mlx5_rxq_priv *rxq = + mlx5_rxq_get(dev, queues[i]); + + MLX5_ASSERT(rxq != NULL); + if (rxq->ctrl->is_hairpin) + rqt_attr->rq_list[i] = rxq->ctrl->obj->rq->id; + else + rqt_attr->rq_list[i] = rxq->devx_rq.rq->id; + } } MLX5_ASSERT(i > 0); for (j = 0; i != rqt_n; ++j, ++i) @@ -711,7 +719,13 @@ mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t i; /* NULL queues designate drop queue. */ - if (ind_tbl->queues != NULL) { + if (ind_tbl->queues == NULL) { + is_hairpin = priv->drop_queue.rxq->ctrl->is_hairpin; + } else if (mlx5_is_external_rxq(dev, ind_tbl->queues[0])) { + /* External RxQ supports neither Hairpin nor LRO. */ + is_hairpin = false; + lro = false; + } else { is_hairpin = mlx5_rxq_is_hairpin(dev, ind_tbl->queues[0]); /* Enable TIR LRO only if all the queues were configured for. */ for (i = 0; i < ind_tbl->queues_n; ++i) { @@ -723,8 +737,6 @@ mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key, break; } } - } else { - is_hairpin = priv->drop_queue.rxq->ctrl->is_hairpin; } memset(tir_attr, 0, sizeof(*tir_attr)); tir_attr->disp_type = MLX5_TIRC_DISP_TYPE_INDIRECT; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 58f0aba294..96f3402418 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1631,6 +1631,12 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "can't have 2 fate actions in" " same flow"); + if (attr->egress) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, + "queue action not supported for egress."); + if (mlx5_is_external_rxq(dev, queue->index)) + return 0; if (!priv->rxqs_n) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -1645,11 +1651,6 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, RTE_FLOW_ERROR_TYPE_ACTION_CONF, &queue->index, "queue is not configured"); - if (attr->egress) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, - "queue action not supported for " - "egress"); return 0; } @@ -1664,7 +1665,7 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, * Size of the @p queues array. * @param[out] error * On error, filled with a textual error description. - * @param[out] queue + * @param[out] queue_idx * On error, filled with an offending queue index in @p queues array. * * @return @@ -1677,17 +1678,27 @@ mlx5_validate_rss_queues(struct rte_eth_dev *dev, { const struct mlx5_priv *priv = dev->data->dev_private; bool is_hairpin = false; + bool is_ext_rss = false; uint32_t i; for (i = 0; i != queues_n; ++i) { - struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev, - queues[i]); + struct mlx5_rxq_ctrl *rxq_ctrl; + if (mlx5_is_external_rxq(dev, queues[0])) { + is_ext_rss = true; + continue; + } + if (is_ext_rss) { + *error = "Combining external and regular RSS queues is not supported"; + *queue_idx = i; + return -ENOTSUP; + } if (queues[i] >= priv->rxqs_n) { *error = "queue index out of range"; *queue_idx = i; return -EINVAL; } + rxq_ctrl = mlx5_rxq_ctrl_get(dev, queues[i]); if (rxq_ctrl == NULL) { *error = "queue is not configured"; *queue_idx = i; @@ -1782,7 +1793,7 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, "L4 partial RSS requested but L4 RSS" " type not specified"); - if (!priv->rxqs_n) + if (!priv->rxqs_n && priv->ext_rxqs == NULL) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, "No Rx queues configured"); diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 754c526464..29652a8c9f 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -18,6 +18,7 @@ #include "mlx5.h" #include "mlx5_autoconf.h" +#include "rte_pmd_mlx5.h" /* Support tunnel matching. */ #define MLX5_FLOW_TUNNEL 10 @@ -217,8 +218,14 @@ uint32_t mlx5_rxq_deref(struct rte_eth_dev *dev, uint16_t idx); struct mlx5_rxq_priv *mlx5_rxq_get(struct rte_eth_dev *dev, uint16_t idx); struct mlx5_rxq_ctrl *mlx5_rxq_ctrl_get(struct rte_eth_dev *dev, uint16_t idx); struct mlx5_rxq_data *mlx5_rxq_data_get(struct rte_eth_dev *dev, uint16_t idx); +struct mlx5_external_rxq *mlx5_ext_rxq_ref(struct rte_eth_dev *dev, + uint16_t idx); +uint32_t mlx5_ext_rxq_deref(struct rte_eth_dev *dev, uint16_t idx); +struct mlx5_external_rxq *mlx5_ext_rxq_get(struct rte_eth_dev *dev, + uint16_t idx); int mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); +int mlx5_ext_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); int mlx5_ind_table_obj_verify(struct rte_eth_dev *dev); struct mlx5_ind_table_obj *mlx5_ind_table_obj_get(struct rte_eth_dev *dev, @@ -638,4 +645,27 @@ mlx5_mprq_enabled(struct rte_eth_dev *dev) return n == n_ibv; } +/** + * Check whether given RxQ is external. + * + * @param dev + * Pointer to Ethernet device. + * @param queue_idx + * Rx queue index. + * + * @return + * True if is external RxQ, otherwise false. + */ +static __rte_always_inline bool +mlx5_is_external_rxq(struct rte_eth_dev *dev, uint16_t queue_idx) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_external_rxq *rxq; + + if (!priv->ext_rxqs || queue_idx < MLX5_EXTERNAL_RX_QUEUE_ID_MIN) + return false; + rxq = &priv->ext_rxqs[queue_idx - MLX5_EXTERNAL_RX_QUEUE_ID_MIN]; + return !!__atomic_load_n(&rxq->refcnt, __ATOMIC_RELAXED); +} + #endif /* RTE_PMD_MLX5_RX_H_ */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 145da2dbbb..22679755a4 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2084,6 +2084,65 @@ mlx5_rxq_data_get(struct rte_eth_dev *dev, uint16_t idx) return rxq == NULL ? NULL : &rxq->ctrl->rxq; } +/** + * Increase an external Rx queue reference count. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * External RX queue index. + * + * @return + * A pointer to the queue if it exists, NULL otherwise. + */ +struct mlx5_external_rxq * +mlx5_ext_rxq_ref(struct rte_eth_dev *dev, uint16_t idx) +{ + struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx); + + __atomic_fetch_add(&rxq->refcnt, 1, __ATOMIC_RELAXED); + return rxq; +} + +/** + * Decrease an external Rx queue reference count. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * External RX queue index. + * + * @return + * Updated reference count. + */ +uint32_t +mlx5_ext_rxq_deref(struct rte_eth_dev *dev, uint16_t idx) +{ + struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx); + + return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED); +} + +/** + * Get an external Rx queue. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * External Rx queue index. + * + * @return + * A pointer to the queue if it exists, NULL otherwise. + */ +struct mlx5_external_rxq * +mlx5_ext_rxq_get(struct rte_eth_dev *dev, uint16_t idx) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + MLX5_ASSERT(mlx5_is_external_rxq(dev, idx)); + return &priv->ext_rxqs[idx - MLX5_EXTERNAL_RX_QUEUE_ID_MIN]; +} + /** * Release a Rx queue. * @@ -2167,6 +2226,37 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) return ret; } +/** + * Verify the external Rx Queue list is empty. + * + * @param dev + * Pointer to Ethernet device. + * + * @return + * The number of object not released. + */ +int +mlx5_ext_rxq_verify(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_external_rxq *rxq; + uint16_t i; + int ret = 0; + + if (priv->ext_rxqs == NULL) + return 0; + + for (i = MLX5_EXTERNAL_RX_QUEUE_ID_MIN; i <= UINT16_MAX ; ++i) { + rxq = mlx5_ext_rxq_get(dev, i); + if (rxq->refcnt < 2) + continue; + DRV_LOG(DEBUG, "Port %u external RxQ %u still referenced.", + dev->data->port_id, i); + ++ret; + } + return ret; +} + /** * Check whether RxQ type is Hairpin. * @@ -2182,8 +2272,11 @@ bool mlx5_rxq_is_hairpin(struct rte_eth_dev *dev, uint16_t idx) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev, idx); + struct mlx5_rxq_ctrl *rxq_ctrl; + if (mlx5_is_external_rxq(dev, idx)) + return false; + rxq_ctrl = mlx5_rxq_ctrl_get(dev, idx); return (idx < priv->rxqs_n && rxq_ctrl != NULL && rxq_ctrl->is_hairpin); } @@ -2361,9 +2454,16 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev, if (ref_qs) for (i = 0; i != queues_n; ++i) { - if (mlx5_rxq_ref(dev, queues[i]) == NULL) { - ret = -rte_errno; - goto error; + if (mlx5_is_external_rxq(dev, queues[i])) { + if (mlx5_ext_rxq_ref(dev, queues[i]) == NULL) { + ret = -rte_errno; + goto error; + } + } else { + if (mlx5_rxq_ref(dev, queues[i]) == NULL) { + ret = -rte_errno; + goto error; + } } } ret = priv->obj_ops.ind_table_new(dev, n, ind_tbl); @@ -2374,8 +2474,12 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev, error: if (ref_qs) { err = rte_errno; - for (j = 0; j < i; j++) - mlx5_rxq_deref(dev, queues[j]); + for (j = 0; j < i; j++) { + if (mlx5_is_external_rxq(dev, queues[j])) + mlx5_ext_rxq_deref(dev, queues[j]); + else + mlx5_rxq_deref(dev, queues[j]); + } rte_errno = err; } DRV_LOG(DEBUG, "Port %u cannot setup indirection table.", -- 2.25.1