From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00054.outbound.protection.outlook.com [40.107.0.54]) by dpdk.org (Postfix) with ESMTP id 9B48E2C52 for ; Fri, 26 Oct 2018 23:47:41 +0200 (CEST) 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=MDblJt/4FOTeYgQISbeGsp5swWu5vpiB/LzfKWfUSpw=; b=KZAIhIK1pS4jgmiw+qJSaAMQqNn/663K4GO2kDCjihFcBdmLJUsX+LBe+fDpFI2dQNoijrQCC+V0MsGUIueRbsMziySuVHUev9Zxe1fw2h4uIv86tnSCkqrMsBas/HQ3Fi/jkIPQFS8rLP65woxbscG5lo5mtlRVOT+l8njLvlw= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4076.eurprd05.prod.outlook.com (52.134.66.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Fri, 26 Oct 2018 21:47:40 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.025; Fri, 26 Oct 2018 21:47:40 +0000 From: Yongseok Koh To: Tom Barbette CC: "dev@dpdk.org" , Shahaf Shuler Thread-Topic: [dpdk-dev] [PATCH v2] mlx5: Support for rte_eth_rx_queue_count Thread-Index: AQHUbTr9Jo9tiWficEmGUAN18vFTjqUyEIYA Date: Fri, 26 Oct 2018 21:47:40 +0000 Message-ID: <20181026214729.GA13615@mtidpdk.mti.labs.mlnx> References: <1540565309-135175-1-git-send-email-barbette@kth.se> In-Reply-To: <1540565309-135175-1-git-send-email-barbette@kth.se> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR04CA0010.namprd04.prod.outlook.com (2603:10b6:a03:40::23) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4076; 6:pj5xHRR5fidpDVGQabh0QWYSImb5Fa+WWe0nW/bcmvPSUa8aY5t7EMzYV8dDgE/o6kUf1qW4z98TsBdhs0V9PIUVyUE7A5T0VJgDMWBnZAJ9gI8FAySKimPtceMsEW2egLDaRhb+2K2p7Z/PPpeaDS2XuCgtVNdh8FB/v3NiritXrKw4fm/4ItVupUy/PtjQs9ZNvv2Cvpk7iKVVgDARjxVjxNiu5HU+4hkwNkijnzGR70WNa3vgT5rCLqSX44LMb658DNC74pbpoLZJs1yrptQ0XI4ZcQSbQ1dgQSQQzkBwWzORfRZsJ7TnfWMDltwchQRA95K6vkoSknOzj0mtqMf5+2frxk8ia6AgmMh+tuhfIrh3szmvFTpFwR4FdrrnEgQkzxQo0c3Y/XiHk85//AMMMeassRaW0knUIhE7I76B5kYjQNw64becD/zZ8dSKjGqJU/iRr0Zf6LnuOvOOtQ==; 5:U7prDPM7KF/mSB5AQPbfvjfM1Z5jd4y2pRkLk2a/ZPZ8u7mrWXxdfMIjPeXB0d6NTbTOsLWV3EnG80LOEBc6f/jiUEGXNC/GW/TcRCMgcaqsOR1nucAnQ0QTECxG14PN5vjhj/XcFssdt2xvdVSEOekMIMBEeZf7RS1hczFia2U=; 7:ykIUSWiEwpr7c0+mO037tgtlYCx36XWL5ePBNfwlRiOUbjemGDbmCOz2aB5l17KIc5FCM0LBD7jlsuCMeFXe+LBnr//wyplcTfFYa1F4QI9+Fv/KQiwBvUE0Wpervmp5snrmQ9tI/jOo2RjrXedN2KbOYc/kl2/IA6BThwMCxspjaizhO2pfqHCUmwDoPOxUc5yaq/niCessC/Dw536PUXBaofQZu+hvFQt/Kf3jj2rY+7PoDa+drdsUJYD69h8a x-ms-office365-filtering-correlation-id: 6b2e2eb4-9676-44c2-0753-08d63b8ca69f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4076; x-ms-traffictypediagnostic: DB3PR0502MB4076: 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)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB4076; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4076; x-forefront-prvs: 083751FCA6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(366004)(346002)(396003)(39860400002)(199004)(189003)(6436002)(106356001)(86362001)(6486002)(105586002)(1076002)(5250100002)(229853002)(33656002)(316002)(6916009)(6116002)(2906002)(53936002)(9686003)(3846002)(6512007)(6246003)(478600001)(107886003)(256004)(14454004)(54906003)(476003)(26005)(66066001)(99286004)(33896004)(2900100001)(305945005)(186003)(486006)(102836004)(4326008)(345774005)(11346002)(446003)(7736002)(6506007)(386003)(71200400001)(71190400001)(76176011)(81156014)(8676002)(25786009)(5660300001)(8936002)(81166006)(52116002)(68736007)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4076; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: aanB0y7wzmbsU71SVAmDsYzrnFDgqBqlPZifR9GpodXEE2QZgyxG2ssjExEFAWTM5JSoLY4HIXX0Z9qNtqMy0wu+18jTOUJN8swPerUwFiGd93iddHsBZob0mtYVb2Z13Me0EJ+STRSGjBbKPjKG+ebzK6hLXDLo1Jk+pdIL3/QPGg+a7/UyyDDo/aaUMjeLd90wH5WMlckkQ7XBJOxAn3MGSsJzi5zun5Iv7caNMLTmbuB8QQiXjucJewXk6dZxoXtckXRqLyJ4euZaI/fyKIby0fRQ+zEMTTFniVL2UijxuCY9Vh+CD3hQxOnq39/TTx8xlXAAxoBeHU1+KxqdmIxAbCqeycAeBwEuLEVwEPg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <410CD17CEEF4D94CA5E2B8D73996E1AF@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b2e2eb4-9676-44c2-0753-08d63b8ca69f X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2018 21:47:40.2998 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4076 Subject: Re: [dpdk-dev] [PATCH v2] 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: Fri, 26 Oct 2018 21:47:41 -0000 On Fri, Oct 26, 2018 at 04:48:29PM +0200, Tom Barbette wrote: > This patch adds support for the rx_queue_count API in mlx5 driver >=20 > Changes in v2: > * Fixed styling issues > * Fix missing return >=20 > Signed-off-by: Tom Barbette > --- Thank you for your contribution! It is good but I have a few small comments. Mostly cosmetic ones. > drivers/net/mlx5/mlx5.c | 1 + > drivers/net/mlx5/mlx5_rxtx.c | 60 +++++++++++++++++++++++++++++++++++++-= ------ > drivers/net/mlx5/mlx5_rxtx.h | 1 + > 3 files changed, 53 insertions(+), 9 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..cafb084 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. I know you just copied it but I'd like to fix it by this opportunity. :-) Please change 'rx' to 'Rx'. Same for 'tx' > - * @param[in] offset > - * The index of the descriptor in the ring. > + * @param tx_queue > + * The tx queue. 'tx' -> 'Rx' > * > * @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,57 @@ 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); > + 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. 'tx' -> 'Rx' > + */ > +int > +mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset) > +{ > + struct mlx5_rxq_data *rxq =3D rx_queue; > + Please remove this blank line. We only allow a blank line between variable declarations and the body. > + uint32_t used =3D rx_queue_count(rxq); To be honest, there's a known issue that should've been fixed before. It is= only vaild for regular Rx burst. In mlx5, there are three types of rx_burst - mlx5_rx_burst(), mlx5_rx_burst_mprq() and mlx5_rx_burst_vec(). You can refe= r to mlx5_select_rx_function(). Among them, this works only with mlx5_rx_burst()= . So, if you don't mind can you please add two sanity checks here? { 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 tx_queue > + * The tx queue. Parameters are dev and rx_queue_id. > + * > + * @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; > + > + rxq =3D (*priv->rxqs)[rx_queue_id]; > + if (!rxq) { > + rte_errno =3D EINVAL; > + return -rte_errno; > + } And please do the same check here. if (dev->rx_pkt_burst !=3D mlx5_rx_burst) { rte_errno =3D ENOTSUP; return -rte_errno; } > + Please remove this blank line. Thanks, Yongseok > + 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); > --=20 > 2.7.4 >=20