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 33F7743B97; Thu, 29 Feb 2024 20:29:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2157542DDD; Thu, 29 Feb 2024 20:29:16 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2132.outbound.protection.outlook.com [40.107.20.132]) by mails.dpdk.org (Postfix) with ESMTP id 1CF31427DE for ; Thu, 29 Feb 2024 20:29:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ceu2LbokRmVQs0nEUE4njSZ+GJakcI7Z3Ll6f+rf+q2SaF7gim9Me7R38QTmb1C23BHimtqm+wbTqmC5GnjSOAiCc1ZFWpAqHS6+49D9JQnYvuAau41MFn0W0/TsI20PN1TRl7KuGd5qJ9GcPUZPsC7je+oaaEg1rTdOsQ8/VEB0FCu6SehgvkGKHM9xRm1a8xJzgriFFeOhV3LDj3bLa539Aojh9RmaHivC1v5Jj3xPamM2Nb4INAkxQB+c7+NH5MVCwViUFNBsmiIiPnVigbKJKtmhLOnbnZEHfkrjl2SnwIkMrKaXafH0qnZhJhi40mC/LSm/3EUOxSjOJpJL7Q== 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=f/BWnb/bGNCcGYUxPFTdAX4DIh97VImmFvvnMJi03mw=; b=AqdsoQGMd3Dhhw1oJ27ee6vrJQBx3nNBWGwF/KNm9856/PPPm1kHoKMsyrAq+W76aNzjicSc4aF5t/6W60/lt8EH0irFyPof+dk1SEz8XxY0mosLC2qkeJxHENwFI44P7kUTy0EjggaOBcMZvEDOB2kn5dPRkXBHSqligMB+uDl1/EQTVTP4ncVia/qL0PBaCVSa9NEUzg/rW4Epz0D/fXv3Aw6x8RMuqE0zbwj30+r+lviVdtmLAj0EqMIwc8erPHfynJuGjjseOUzbmPoNHki+uobqdfBshEy37vhgVpSCoBtvLQqeLx0UQm0fGrePkPDUJnnMaBa4HsuORCTPCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f/BWnb/bGNCcGYUxPFTdAX4DIh97VImmFvvnMJi03mw=; b=UjtE0wyYfHnAYP2WoV+/8ZpqWz/GAIQ+MBUi6lThgVYhsyd9y0kX+go4BxfxhisSyqczg5awSMXEgH8oKvEiADloS/bChMORWQxqT2EBS2aRTnKbkrqDQgSgaVqrk33Gm2vnvQw8od8gA7FOYVjJDMnIa2CmW7Hm6f09DJivuA4= Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com (2603:10a6:102:26b::17) by VI1PR83MB0480.EURPRD83.prod.outlook.com (2603:10a6:800:19a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.26; Thu, 29 Feb 2024 19:29:11 +0000 Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::f0b:6b7f:eef8:2bcc]) by PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::f0b:6b7f:eef8:2bcc%2]) with mapi id 15.20.7339.026; Thu, 29 Feb 2024 19:29:11 +0000 From: Alan Elder To: Long Li , Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" , stephen Subject: [PATCH] net/netvsc: fix number Tx queues > Rx queues Thread-Topic: [PATCH] net/netvsc: fix number Tx queues > Rx queues Thread-Index: AdprRTOynwRWp6iEQ1Sp/Ut/PyIh7g== Date: Thu, 29 Feb 2024 19:29:11 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=979ac031-206c-4225-b627-540697dac625; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2024-02-29T19:11:26Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR83MB0526:EE_|VI1PR83MB0480:EE_ x-ms-office365-filtering-correlation-id: afcbbe1b-615b-4c12-1752-08dc395cb4bf x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oAA420IEvrrHn2cS/sER0z10tM4iS+/AoiVXIA2Iq1V33bOwt/2YlCve5/41kWwVnxj2v5eCYrfgftNSCb6CWga1Cb10f5dGuk6uDgTaODUekrLKqTYJMjqlwpfahwRTFm51xE4vcCyVuvWnhb+1IUZEHyhV97dNX1utj66VALVLHpP3zgJTX2Ct3OgV5EqR/zHcANAbDUWJ75azEynwceKW9R7yChqy5sjMG8/5zYUpN5DH8X4mtH6WeZMOpABo74/PGHn5r/idjOKN0lRM5U8dGC+nCOPXKzFej3o4VyvzGrhcusXUIjcXtKHVViaYj0+agHwWPk5mdRGBYjxzY81iR3H7ls7NF655W4azS5da0YCOL+VrsRASNs0OXTkiydxmovPM5lHrSHXqDvRxnYZijVhDrFjQ+GEh/Kti85TvWeTMQgqPR5xTrcTyANliTvPQqvDmY+ZVt6sB00P5b/A89XiQ0D1fHoj6NolKqnf4JdVscGEf097OxLOL6f2pB/lDllZNrWx1K8sQO2LsJ3d6+d3TSDVDMYFuLJAJ+uGlhsnbkoQZN9Oe0DAjCFyKhjw9aqSlti4idrLj4h2GWIH08cv8DDxVpZgE1l4AG16faC3czJCY/zxjg5EGnv1uH9WOorieBvpQmUb2AvmkP+O1w3l67kOhrU5dJOdbj3QAN22S0XYb329qhAtlpSHql3MCXZLUX+9Ng/MuePSwagtsOVgnszJz7Es8sqjpuWQ= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR83MB0526.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(38070700009); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?R8B+GkSrH6VDik4BKvD/CLkdpqsJ3HMWBbuoaZreOdEr2IcDGhNrak+f5rOM?= =?us-ascii?Q?AErS2Ry7DeMJNcajlzUa8jDj9zFuhy55NqBIU7+PQZklUlcuaZ1jFqHmtDPo?= =?us-ascii?Q?cE2rcEkoFVeHHTACcJfTvnnjihF/R9xZ7gV5LKwwi6LZpWGLi8M/F5r1gu51?= =?us-ascii?Q?LRzPcwj/swQEwy78HXARx8de56l+O9/E4Fzi8hFiYLySMCsU9lQcOfKPeThO?= =?us-ascii?Q?svsy0GrDVgfLYwiAJeczfsnVuxUxiFVdvNlhXCSakAsLrudxq2nyqUegXYoH?= =?us-ascii?Q?D4RksIp7M6HdEEu6aXLjiXRAVNWDNKwzq2SmALURbPv9ZVQLvPLnUcB3iLzT?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956mvCAH9BGVrxUE7TUkGsglXKrKBJqRxSDxZ/OzCAXe?= =?us-ascii?Q?8eOTHGe/DAtHfFyZLk008SnyRUGDLDw+77ITR8j2ORXbOkZvhLwDIZD+fKCF?= =?us-ascii?Q?Gou/rSUcTW3sieeXlDe6ft7svjybgtsAcrVCPOn+6A7/GKyFoxC0bs7W8V1t?= =?us-ascii?Q?m0n0WY3QCitNxbJdQkiNv/FBeLwhgcyLOSFz2uiJGOyc5nwpYY7xrVvsTGjl?= =?us-ascii?Q?174eXo9BXuWo7NSR8OOEPDQEBvzlMOlcZKeAuXLMZmKjSqB1F1OHGMWY+lQd?= =?us-ascii?Q?6bN8H5r24CvFbUUzthhtnhh8IFZaYABSoirP?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR83MB0526.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afcbbe1b-615b-4c12-1752-08dc395cb4bf X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Feb 2024 19:29:11.1553 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LHKdXY0pAt8i7v/gB/uMi+ji0tQTE/EVTKI70txEwkb2yKs0jRUoAOQe4cIYF4gnWXZIhqlsJSA15y49Bf376Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR83MB0480 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 The previous code allowed the number of Tx queues to be set higher than the number of Rx queues. If a packet was sent on a Tx queue with index >=3D number Rx queues there was a segfault. This commit fixes the issue by creating an Rx queue for every Tx queue meaning that an event buffer is allocated to handle receiving Tx completion messages. mbuf pool and Rx ring are not allocated for these additional Rx queues and RSS configuration ensures that no packets are received on them. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Cc: sthemmin@microsoft.com Cc: stable@dpdk.org Signed-off-by: Alan Elder --- drivers/net/netvsc/hn_ethdev.c | 9 ++++++++ drivers/net/netvsc/hn_rxtx.c | 40 ++++++++++++++++++++++++++++++++++ drivers/net/netvsc/hn_var.h | 1 + 3 files changed, 50 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.= c index b8a32832d7..4111f26a37 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -313,6 +313,15 @@ static int hn_rss_reta_update(struct rte_eth_dev *dev, =20 if (reta_conf[idx].mask & mask) hv->rss_ind[i] =3D reta_conf[idx].reta[shift]; + + /* + * Ensure we don't allow config that directs traffic to an Rx + * queue that we aren't going to poll + */ + if (hv->rss_ind[i] >=3D dev->data->nb_rx_queues) { + PMD_DRV_LOG(ERR, "RSS distributing traffic to invalid Rx queue"); + return -EINVAL; + } } =20 err =3D hn_rndis_conf_rss(hv, NDIS_RSS_FLAG_DISABLE); diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 9bf1ec5509..e4f6b25cee 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -243,6 +243,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev, { struct hn_data *hv =3D dev->data->dev_private; struct hn_tx_queue *txq; + struct hn_rx_queue *rxq; char name[RTE_MEMPOOL_NAMESIZE]; uint32_t tx_free_thresh; int err =3D -ENOMEM; @@ -301,6 +302,22 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev, goto error; } =20 + /* + * If there are more Tx queues than Rx queues, allocate rx_queues + * with event buffer so that Tx completion messages can still be + * received + */ + if (queue_idx >=3D dev->data->nb_rx_queues) { + rxq =3D hn_rx_queue_alloc(hv, queue_idx, socket_id); + /* + * Don't allocate mbuf pool or rx ring. RSS is always configured + * to ensure packets aren't received by this Rx queue. + */ + rxq->mb_pool =3D NULL; + rxq->rx_ring =3D NULL; + dev->data->rx_queues[queue_idx] =3D rxq; + } + txq->agg_szmax =3D RTE_MIN(hv->chim_szmax, hv->rndis_agg_size); txq->agg_pktmax =3D hv->rndis_agg_pkts; txq->agg_align =3D hv->rndis_agg_align; @@ -364,6 +381,13 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint1= 6_t qid) if (!txq) return; =20 + /* + * Free any Rx queues allocated for a Tx queue without a corresponding + * Rx queue + */ + if (qid >=3D dev->data->nb_rx_queues) + hn_rx_queue_free_common(dev->data->rx_queues[qid]); + rte_mempool_free(txq->txdesc_pool); =20 rte_memzone_free(txq->tx_rndis_mz); @@ -942,6 +966,13 @@ hn_dev_rx_queue_setup(struct rte_eth_dev *dev, if (queue_idx =3D=3D 0) { rxq =3D hv->primary; } else { + /* + * If the number of Tx queues was previously greater than + * the number of Rx queues, we may already have allocated + * an rxq. If so, free it now before allocating a new one. + */ + hn_rx_queue_free_common(dev->data->rx_queues[queue_idx]); + rxq =3D hn_rx_queue_alloc(hv, queue_idx, socket_id); if (!rxq) return -ENOMEM; @@ -998,6 +1029,15 @@ hn_rx_queue_free(struct hn_rx_queue *rxq, bool keep_p= rimary) if (keep_primary && rxq =3D=3D rxq->hv->primary) return; =20 + hn_rx_queue_free_common(rxq); +} + +static void +hn_rx_queue_free_common(struct hn_rx_queue *rxq) +{ + if (!rxq) + return; + rte_free(rxq->rxbuf_info); rte_free(rxq->event_buf); rte_free(rxq); diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index ba86129ff6..ca599957c0 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -216,6 +216,7 @@ int hn_dev_tx_descriptor_status(void *arg, uint16_t off= set); struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv, uint16_t queue_id, unsigned int socket_id); +static void hn_rx_queue_free_common(struct hn_rx_queue *rxq); int hn_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, --=20 2.25.1