From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30041.outbound.protection.outlook.com [40.107.3.41]) by dpdk.org (Postfix) with ESMTP id BDEC02B91 for ; Sun, 28 Oct 2018 10:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pHD0jJ0R2iX4jOu4SMiYNABTF8Tv/b+r7PTVUO7tIJI=; b=gF2GZkfhbxbRjFPOnKamnytyL6wjT3A1pLqe+dUIKE0wH3ekAMrzvYNyOeA5hT1Hdl+ZNoa+GmZbudPYfz1ZiwYn+xBQak1rgXpAdmZNBGFBSzvsSQDoDfyw2wR9To1FOvyf3FwCh8e+KJ48WPDp/WhGArWQNM1VsE3ZGClsKxU= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB4971.eurprd05.prod.outlook.com (20.176.236.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Sun, 28 Oct 2018 09:37:06 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::80e:e6b:baf2:d973]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::80e:e6b:baf2:d973%3]) with mapi id 15.20.1273.025; Sun, 28 Oct 2018 09:37:06 +0000 From: Shahaf Shuler To: Tom Barbette , "dev@dpdk.org" , Ferruh Yigit , Thomas Monjalon , Andrew Rybchenko , "olivier.matz@6wind.com" CC: Yongseok Koh Thread-Topic: [PATCH v4] mlx5: Support for rte_eth_rx_queue_count Thread-Index: AQHUbgdFa7YpZOBUAEWIgl1+xlkwxaU0YpJw Date: Sun, 28 Oct 2018 09:37:06 +0000 Message-ID: References: <1540653055-67051-1-git-send-email-barbette@kth.se> In-Reply-To: <1540653055-67051-1-git-send-email-barbette@kth.se> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR05MB4971; 6:nM4GeMYtONEAy2IKG1dh5isHNCi1K3dI3rwuY/AjktVMjP8eIKcs3zPD3p6/27ckvcFucPyl9/c3mI014w4NyU1Ks4i4HQ9sxXRpZ0pjGilz+97Tx27VZPSihHiHejOw81Sm0agyrgdLzHTHi32XDYIafHcy8WWecpi/lKkJZf/ol6YYJCs0ugnjwn0kF6SW3NWuiE3+OgFvFC8RbLDAfW3hOrX+pATi/bSuRCHrDco7EzsJy+LRZ/jg/u7jhgcMGqC6RHI1CHVCWMAKi0StQZ/IM9WWcncgATC+iyzkXyr3LsAMAXFXAO3z5m78kg01FdU9tsB5DptRmoJmQr7OMmmCy1SQjhI4IJG3/TZN+7tCS1AU0sMLThS3NSAWXHSuXN1Rg7fDxf/gsJ97OfJkhP/ia29is78YOmyVStbhgDE70tJNg+4CfTEgXBJebDTZpGpRTC699eQ4yrvWLF1iKA==; 5:H5Q/EBKYCG+ZH+svFXdJlfhQ3fiKiqcBzrEx9GxGAL1zr00wYzLd1mmy9LuAGQUEXlA4fMxGPzqNDR3YK2Atq4z+VUVJQjKsrLvidk0Dl3cgoFmypaUuh3LruIRMUwUUc8TMsU1nQOG5vs6VIgOkBPCgc+bjv26k6Ek42CuJ6FY=; 7:LDBqWZssEG1fis0mxD79dt7vuxrfdv6m4HTNKRfEPNx+Cpub/1bUbU/YKw+8kLxARlxFIRGeX3UvRRQRo57NoOuiYLt0DzGtTsgGDywqkp4/bczj6M/P4D9nODY62P3tL5K6a8KO5bZODhVkY0ce5A== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 2b3b51ea-5c34-4471-75e6-08d63cb8ed09 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4971; x-ms-traffictypediagnostic: DB7PR05MB4971: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:DB7PR05MB4971; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4971; x-forefront-prvs: 0839D067E7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(136003)(189003)(199004)(97736004)(14454004)(74316002)(305945005)(33656002)(71190400001)(478600001)(7736002)(8676002)(71200400001)(4326008)(25786009)(26005)(8936002)(81156014)(81166006)(256004)(476003)(11346002)(446003)(66066001)(486006)(186003)(6506007)(2906002)(105586002)(106356001)(2501003)(5250100002)(102836004)(68736007)(76176011)(316002)(86362001)(575784001)(7696005)(2900100001)(3846002)(5660300001)(55016002)(9686003)(229853002)(6116002)(6436002)(99286004)(53936002)(6246003)(110136005)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4971; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 179LV7oduiSyCN5bsYU0SwVRfXBQ9MH3jrwrubhUCDrRfpzdm9jcu3XpQBK9RZTCmnMzANtnmdTuFDZR/ziAhJFXKY/KteN+pFYu3DBZiUqsxGH+a0CsCtZuMzVY1sgh3eHPZCvqkl4I0yQExdM5vR521BbqIwd2012x1Wd7Yc38zZ5QdPfF/DV0Ac0zI008ruzQIvAF6uOxQ5RVgZO3oxJGbCERQzuusG8jJI94a5vUnh9brByHUO1eq1kJSOvZDnAIY0eXIYpP7tvD1guF0BxsufdHSID06yABGIp+Z9FM4u3cNfhmqk5vRJuVxPzYmMl14S9FjT/obN4hENnBkgsQ2w0f8K2HN77diATwuZM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b3b51ea-5c34-4471-75e6-08d63cb8ed09 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2018 09:37:06.5591 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4971 Subject: Re: [dpdk-dev] [PATCH v4] mlx5: Support for rte_eth_rx_queue_count 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: , X-List-Received-Date: Sun, 28 Oct 2018 09:37:08 -0000 Hi Tom, Adding ethdev maintainers and Oliver as the author of the new API.=20 Saturday, October 27, 2018 6:11 PM, Tom Barbette: > Subject: [PATCH v4] mlx5: Support for rte_eth_rx_queue_count >=20 I have a more basic question. The rte_eth_rx_queue_count is a very old API, more or less from the beginni= ng of DPDK.=20 We progressed from then and a newer API to check the descriptor status was = introduced @DPDK17.05 : rte_eth_rx_descriptor_status, see commit[1]. There is also a plan to deprecate it once all drivers will support the new = API. With the new API you can check the number of available descriptors on a sim= ilar way.=20 So my question is, is the new API enough for your functionality? If not, wh= at it is missing? I would prefer to improve the new one instead of starting= to support the old one.=20 [1] commit b1b700ce7d6fe0db9152f73e8e00394fc2756e60 = =20 Author: Olivier Matz = =20 Date: Wed Mar 29 10:36:28 2017 +0200 = =20 = =20 ethdev: add descriptor status API = =20 = =20 Introduce a new API to get the status of a descriptor. = =20 = =20 For Rx, it is almost similar to rx_descriptor_done API, except it = =20 differentiates "used" descriptors (which are hold by the driver and not returned to the hardware). = =20 = =20 For Tx, it is a new API. = =20 = =20 The descriptor_done() API, and probably the rx_queue_count() API could= =20 be replaced by this new API as soon as it is implemented on all PMDs. = =20 = =20 Signed-off-by: Olivier Matz = =20 Reviewed-by: Andrew Rybchenko =20 =20 > This patch adds support for the rx_queue_count API in mlx5 driver >=20 > Changes in v2: > * Fixed styling issues > * Fix missing return >=20 > Changes in v3: > * Fix styling comments and checks as per Yongseok Koh > comments. Thanks ! >=20 > Changes in v4: > * Fix compiling issue because of a line that disappeared in v3 >=20 > Signed-off-by: Tom Barbette > --- > drivers/net/mlx5/mlx5.c | 1 + > drivers/net/mlx5/mlx5_rxtx.c | 78 > ++++++++++++++++++++++++++++++++++++++------ > drivers/net/mlx5/mlx5_rxtx.h | 1 + > 3 files changed, 70 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > ec63bc6..6fccadd 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -375,6 +375,7 @@ const struct eth_dev_ops mlx5_dev_ops =3D { > .filter_ctrl =3D mlx5_dev_filter_ctrl, > .rx_descriptor_status =3D mlx5_rx_descriptor_status, > .tx_descriptor_status =3D mlx5_tx_descriptor_status, > + .rx_queue_count =3D mlx5_rx_queue_count, > .rx_queue_intr_enable =3D mlx5_rx_intr_enable, > .rx_queue_intr_disable =3D mlx5_rx_intr_disable, > .is_removed =3D mlx5_is_removed, > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > index 2d14f8a..2126205 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.c > +++ b/drivers/net/mlx5/mlx5_rxtx.c > @@ -417,20 +417,17 @@ mlx5_tx_descriptor_status(void *tx_queue, > uint16_t offset) } >=20 > /** > - * DPDK callback to check the status of a rx descriptor. > + * Internal function to compute the number of used descriptors in an RX > + queue > * > - * @param rx_queue > - * The rx queue. > - * @param[in] offset > - * The index of the descriptor in the ring. > + * @param rxq > + * The Rx queue. > * > * @return > - * The status of the tx descriptor. > + * The number of used rx descriptor. > */ > -int > -mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset) > +static uint32_t > +rx_queue_count(struct mlx5_rxq_data *rxq) > { > - struct mlx5_rxq_data *rxq =3D rx_queue; > struct rxq_zip *zip =3D &rxq->zip; > volatile struct mlx5_cqe *cqe; > const unsigned int cqe_n =3D (1 << rxq->cqe_n); @@ -461,12 +458,73 > @@ mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset) > cqe =3D &(*rxq->cqes)[cq_ci & cqe_cnt]; > } > used =3D RTE_MIN(used, (1U << rxq->elts_n) - 1); > - if (offset < used) > + return used; > +} > + > +/** > + * DPDK callback to check the status of a rx descriptor. > + * > + * @param rx_queue > + * The Rx queue. > + * @param[in] offset > + * The index of the descriptor in the ring. > + * > + * @return > + * The status of the tx descriptor. > + */ > +int > +mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset) { > + struct mlx5_rxq_data *rxq =3D rx_queue; > + struct mlx5_rxq_ctrl *rxq_ctrl =3D > + container_of(rxq, struct mlx5_rxq_ctrl, rxq); > + struct rte_eth_dev *dev =3D ETH_DEV(rxq_ctrl->priv); > + > + if (dev->rx_pkt_burst !=3D mlx5_rx_burst) { > + rte_errno =3D ENOTSUP; > + return -rte_errno; > + } > + if (offset >=3D (1 << rxq->elts_n)) { > + rte_errno =3D EINVAL; > + return -rte_errno; > + } > + if (offset < rx_queue_count(rxq)) > return RTE_ETH_RX_DESC_DONE; > return RTE_ETH_RX_DESC_AVAIL; > } >=20 > /** > + * DPDK callback to get the number of used descriptors in a RX queue > + * > + * @param dev > + * Pointer to the device structure. > + * > + * @param rx_queue_id > + * The Rx queue. > + * > + * @return > + * The number of used rx descriptor. > + * -EINVAL if the queue is invalid > + */ > +uint32_t > +mlx5_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) { > + struct priv *priv =3D dev->data->dev_private; > + struct mlx5_rxq_data *rxq; > + > + if (dev->rx_pkt_burst !=3D mlx5_rx_burst) { > + rte_errno =3D ENOTSUP; > + return -rte_errno; > + } > + rxq =3D (*priv->rxqs)[rx_queue_id]; > + if (!rxq) { > + rte_errno =3D EINVAL; > + return -rte_errno; > + } > + return rx_queue_count(rxq); > +} > + > +/** > * DPDK callback for TX. > * > * @param dpdk_txq > diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h > index 48ed2b2..c82059b 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -345,6 +345,7 @@ uint16_t removed_rx_burst(void *dpdk_rxq, struct > rte_mbuf **pkts, > uint16_t pkts_n); > int mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset); int > mlx5_tx_descriptor_status(void *tx_queue, uint16_t offset); > +uint32_t mlx5_rx_queue_count(struct rte_eth_dev *dev, uint16_t > +rx_queue_id); >=20 > /* Vectorized version of mlx5_rxtx.c */ int > mlx5_check_raw_vec_tx_support(struct rte_eth_dev *dev); > -- > 2.7.4