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 79C3443C27; Fri, 8 Mar 2024 19:09:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 469B840274; Fri, 8 Mar 2024 19:09:57 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2114.outbound.protection.outlook.com [40.107.241.114]) by mails.dpdk.org (Postfix) with ESMTP id 23AD840151 for ; Fri, 8 Mar 2024 19:09:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xu8878qB6SFiriWSC3gP1WZOAsurLeJqi/zmAqttkZajymeF8ZeRE6MjiOeIVklh4FVU7Zx08LlR/0j6/Y7hlUdMlHihMwjs5TQUc5kYtsffTikfD+2uF/aDZusxNm8Fr07jHtOeFnE1H7mwiuU3ZQz/ZixAN3wjHv0DcIEUBWhyzDOS4L/gvlEUZcgDXUPpZebKSg/frlfimniGK7WZ/XJFetFclX2gfMf209iTCwQPMtkNVyisX9gEd2g69hEnkY79UZNAg+9q39El7uXePb5R6lJ0Nd6J1Cl92ZM/L6WiTtrHOcL1vQQrk2FtkGPa7A5w+tkqjM8HkTjliyZJRQ== 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=Vud6X+Eu/DUX1BYRVUxDaMWXpMPuQwT+BgsTIH/u+I8=; b=oTnzw9pmOXH26h1wdgWV+9l7vtqcsVXTE3pSVe99w42nvd5d8pEjg/IjlijtTqswqXa6wrS2JqLSlmFboo2bSQ1tbJfY2mbkHx0r6+9Nh+RGByC0Z77g2jliaP3ezdZXhb6M45UwFZQncmVITwZ+3tpjGK2K7NBfb3mxNWEq5vxoK1hT+5W/lSfL5ALr5p00UAPxCeLRo52eg7K+x+z8BbJcQqZ5vfzoHpJJGhhXxZI2HYUfQ0p/gafsVLcRnfiTIURKF43qimIEZByPzkukmWGxEBlr8xGUUnb2vovi5XFGEpYNiwRQ+GlIJd8boCTNmjkgiGQGBvHzI4rLFco3dQ== 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=Vud6X+Eu/DUX1BYRVUxDaMWXpMPuQwT+BgsTIH/u+I8=; b=AOHCgpSJQ50jzz/rNz6qz7i4saPlOJHz7o0zsFg8Qt1SoPBpU5GcY3UQt9wQi6z+PL0PSF309PzuZsdPEsWjNSJpemhEBH6WfKUJZb4fyeh7stFXsaN1TRNUUKtSvP2M7FT8ThztTMtA143Div/DvneTwTdvcq2TWN2ZqHWeC/E= Received: from DU0PR83MB0532.EURPRD83.prod.outlook.com (2603:10a6:10:314::5) by PA6PR83MB0646.EURPRD83.prod.outlook.com (2603:10a6:102:3d7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.0; Fri, 8 Mar 2024 18:09:53 +0000 Received: from DU0PR83MB0532.EURPRD83.prod.outlook.com ([fe80::d876:e1dc:284a:fc57]) by DU0PR83MB0532.EURPRD83.prod.outlook.com ([fe80::d876:e1dc:284a:fc57%6]) with mapi id 15.20.7386.011; Fri, 8 Mar 2024 18:09:53 +0000 From: Alan Elder To: Alan Elder , Long Li , Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" , stephen Subject: [PATCH v2] net/netvsc: fix number Tx queues > Rx queues Thread-Topic: [PATCH v2] net/netvsc: fix number Tx queues > Rx queues Thread-Index: AQHacYPRvICdWr2D80SqgVYZcULqOg== Date: Fri, 8 Mar 2024 18:09:53 +0000 Message-ID: References: In-Reply-To: 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: DU0PR83MB0532:EE_|PA6PR83MB0646:EE_ x-ms-office365-filtering-correlation-id: 314dfb61-b63e-4139-3293-08dc3f9af405 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: LGG+4r41JAtc54oIHs5UhmvPZBQW9Ax3h10R54wxJeFl5pl+YEs40aCX7NXxc5/Uxt/78sIjTmeqsCvImdpuaaQBXjQzwGzWyMWsq7Zj9zfjlHl3SPOW7F1MjsKDlkXu5nzdnk4TcJxNS9WWrlyHjhFcD5pypWdQFUeERkSR33sUEeyklZK20KDLv3A7jYjf+qtmv3alL1+AqtsJu8aKcUmPyfE5Wex+M/VyLLXKIPXCRHhb8cJ7rYsQefdRKFDMRzXiudM0ftjjw5noWKIgKUrMVUfnLd91Iv9YAvLqzrAbi54ZABVzIIjq19eI8ci95g2TpINcxVUu50dvrY7+lE2ODz/kmaW1lxIbVPL1Y9aU/EqbZ/8G+LTPDDOG39fdJ9F6l9ahCCwbU/q8LyqntlcWOihQ4qJQUW+Svtu8v57LqApeHMpSYZrD4kZmLmi6f0TVu2/Mx+Vf49kbCjUwPUYfMONuhnXLatmB+t5wGE5oRiIuRel3ZnsWnK88mLt9/5gd3RdkBnVFMCiW3gQuDeEu16gPkMyF/2Bhf9IPZR/Lekec/Cm88GRogRFfLkr2uLt/6vG5M9UwAHSL6CULSXU2zuKT/YL1iFPE2jjnd25eH1uPxqaZaVGCCQ82KlZMus0qGyi6ZbPwVjpe0hULZa9jA/95OLNZ6syYE84uWZvWC92A1W97/dGd214+bbHd20hGoaxwxyfH/A+ierNvdrCBBvorn6psEd1anQRX/Rw= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR83MB0532.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(38070700009); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7pJTEq2kiec/1+taFrUrPUA+nP98EsFanGqe1h/21/XmLQcNdZAd8mCIj7Hc?= =?us-ascii?Q?XOUvt+D37ix2lB4ArDJlZmkU4HhwYcWB9yM2+5Bt62d3CU+1xR5YSqV6RwO8?= =?us-ascii?Q?Rp3ds/M+FwlAPI/PHR2YNevTk7PXlR07y+npI1hiws39rsIu5fNvs7JewA0I?= =?us-ascii?Q?bnVS/YabNeEyY4q8BQV/iJnlojQPWKKds+t5DA8vk6WO9Dn1RMKvw3htOqq0?= =?us-ascii?Q?klTdS6hX5A5S6QdpbU6tc7qTgAZude0ixfO6sOGo2lIhNIUVdbTZKio1M9Zu?= =?us-ascii?Q?iXK8T/i5NTP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?us-ascii?Q?FE8PKVhwm0xLgT6p0oIF+9H/XNmz1DZDb1iQIJVbR7cmzoTVHK5abRw0mH6k?= =?us-ascii?Q?pBj4nMq7vV9aFR+ckqdnwwVaON6jh76BJ+bpPVuKDhX79ARJhGgq9EkwxZRI?= =?us-ascii?Q?8HNJNRhPbx9VsGfvgYUdEWG2KXEWZSrDvSJm7TfeMwjQrEMNuMclNT/hgF7O?= =?us-ascii?Q?2rESfUkHXmik09jfxN2QCjZgK/NmCcxJqMfUae6I5frFQWPGaY5phUA69JXg?= =?us-ascii?Q?9H77eSFT+8uhK+pg5Pg0LPzH+FiFkQaqSLEIVvV1ywxLfpvrXO/Ng2AJnxF+?= =?us-ascii?Q?fk4EQr0lqEPxJOUDNk9c9lFFrxnxiNlNB43D?= 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: DU0PR83MB0532.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 314dfb61-b63e-4139-3293-08dc3f9af405 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2024 18:09:53.0664 (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: yLyonPpsLcPVp6/Pka7AxZpLz6SRIAMpY9zJ5ymSFpFMOAsFQd/BuXchgCsw4du/rYtf6E6bAuXgrL0/zJrGlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA6PR83MB0646 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 --- v2: * Remove function declaration for static non-member function --- drivers/net/netvsc/hn_ethdev.c | 9 +++++++ drivers/net/netvsc/hn_rxtx.c | 46 +++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.= c index b8a32832d7..d7e3f12346 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..c0aaeaa972 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; @@ -354,6 +371,17 @@ static void hn_txd_put(struct hn_tx_queue *txq, struct= hn_txdesc *txd) rte_mempool_put(txq->txdesc_pool, txd); } =20 +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); +} + void hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) { @@ -364,6 +392,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 +977,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,9 +1040,7 @@ hn_rx_queue_free(struct hn_rx_queue *rxq, bool keep_pr= imary) if (keep_primary && rxq =3D=3D rxq->hv->primary) return; =20 - rte_free(rxq->rxbuf_info); - rte_free(rxq->event_buf); - rte_free(rxq); + hn_rx_queue_free_common(rxq); } =20 void --=20 2.25.1