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 7BAD8426D6; Fri, 6 Oct 2023 22:09:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6623440685; Fri, 6 Oct 2023 22:09:14 +0200 (CEST) Received: from DM5PR00CU002.outbound.protection.outlook.com (mail-centralusazon11021026.outbound.protection.outlook.com [52.101.62.26]) by mails.dpdk.org (Postfix) with ESMTP id 87A32402E1 for ; Fri, 6 Oct 2023 22:09:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2+4UMu5AAd1BjWnWYK08HCbPmTXjtQUV/uIJN7tU0ZqM1OWD9SGueL0X6qS8QCptyMWOvSsRt4ZQvK9XItZLTltOTTu8sRckV7AS2030Wvro4Jh2J5auit9oUHwZ8lGBquGTREkMGd4Yn9FPKjj1CSiHbZBNZhsG9zu7ckmexCGVdcazr0FDUzyPoM/ShsbIHPJgddbhrl/eVWxdJ1jqQSaP1jJCGkAAj2Sc45P9voM4S1CJAiw9YfiZGSaeTZUb3Lwu+WRnW7uHDJ1dSpyyoF0ilS700C+Mu4ozKW72v7sBdDcwtL5M6aYm3WC0tEPI++17RrEe9wjzpFi6zS+Ug== 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=Lot9nT4Rcthd48RvtglmBjcIM5DlKXxQ8wpu00QunEA=; b=dKYzd9Tmyr7ivLyqHAVM/kAdj7q3j2nSUEW6iPQsE7VFQM3kbyax6fO57pSuc3vC9WBGtGipd2pvWpsmfdJqhVWEnVeAG4cka3+f3xh89p6O5GTAT2R2oVI0pZucrMFlaq3mn1s4aglP1Q4ma2Qj/cEEJ5KuN9Jr5AIOoFIRn602nOhu6mookxpWrg/RdBMbn8YVUIkSR40RZkpdMxESy/fZxyAcBAoxGLrXukCY30lwyROgyEbE7s2h0ngZjpXPg5yW2ZV3UcApgVGNe+UEhP/X1cg5XwIxjOnnhz+CLKvF2LsMiXeH2NbGSGBycxoErbeJ211BMed3py2bgawUow== 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=Lot9nT4Rcthd48RvtglmBjcIM5DlKXxQ8wpu00QunEA=; b=NW3lWNa224pfCukiR0yhMQZMwQ0cO3Zf48DQxxS529XY2GCUwQnB/zwojykXdyH3sCUqJ0H55oHbIL6H0O+xylPlkzJetD+Zcsvy6fQv75KlBwtgYlw9jOkIUIy5zb2OE9Zs9nEWtEMqChmPKBIpkw3mbF3/vIebBxjW+GSA2vY= Received: from MN0PR21MB3120.namprd21.prod.outlook.com (2603:10b6:208:374::18) by PH7PR21MB3356.namprd21.prod.outlook.com (2603:10b6:510:1dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.15; Fri, 6 Oct 2023 20:09:10 +0000 Received: from MN0PR21MB3120.namprd21.prod.outlook.com ([fe80::5e3d:e9ea:72b1:393b]) by MN0PR21MB3120.namprd21.prod.outlook.com ([fe80::5e3d:e9ea:72b1:393b%6]) with mapi id 15.20.6886.016; Fri, 6 Oct 2023 20:09:10 +0000 From: Sam Andrew To: "dev@dpdk.org" , "ferruh.yigit@amd.com" , "andrew.rybchenko@oktetlabs.ru" , Long Li Subject: [PATCH v2] net/netvsc: add support for mtu_set Thread-Topic: [PATCH v2] net/netvsc: add support for mtu_set Thread-Index: AQHZ+JD3DK4OrtnD50+1ZRScBu5UrA== Date: Fri, 6 Oct 2023 20:09:09 +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=bcee6afe-e6b0-45e8-b277-eff8a22f3d92; 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=2023-10-05T23:13:52Z; 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: MN0PR21MB3120:EE_|PH7PR21MB3356:EE_ x-ms-office365-filtering-correlation-id: e49d423f-b616-4b26-c794-08dbc6a81a26 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1jlpj+1OmKVdsh/lGu+vl0mJA6V13DV7aPlR0tkYqn6lPzmq57COyaL4TYCMX3rI6xQ1giMwLiaEPOlsdsff5vm4QU0A6g3NOzQ46+FeDicTeuw+oe0GE5AdA83UXyRr5wKQEpGkV9hnIIHhTa+e7OfvBpXqRIDFyWdEAKbOxDqxAbrhwoy5ILUz4OuYtZNpYjeuH/m32FR9vxho0nLkWZO9HIvC6f3hfxHqxb2KjxWiQ7ch63bIW7NpCE2RpzQP+TjB8v+FcXa+Om6GrGSBlD6R2xASn26pPo+5EBInu9Js7z4SLkjrdi2HvgGr7t+tAf+ngSg8HPtmgYRxsvCgF4L4tukIKGIB5ZZWdneDAHIxFNG25XohEoFR33W34iS5qZRCxlDGeMx6ArhYxH9Bm1KGVag77PPskbqy9tCSVAoep6DbHgE8PnV5Cw0L7C3czcAtISeoPO0wTBM6lxlF3iSn/q7+IrEBhY+PH/p7RnmFdo816qcMMWCEUlqMnNZdJkL2MIf2qnJaV7PUka9jTeVaTPO1LwMUD48mrNBPc6r1sNcY/3m3v4Unp+27/eOzH7A21S9TfxijY5kc4Urt/04Prcmzl3QnbN1BMnLziTh2Dd6++LrRsWY6F7JvKDB7xyCPkiC6jKdF38tOLrXap8x/dqJLQ49//2AMQL1ug7k= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN0PR21MB3120.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(396003)(366004)(346002)(136003)(39860400002)(230922051799003)(186009)(64100799003)(1800799009)(451199024)(6506007)(7696005)(10290500003)(478600001)(71200400001)(83380400001)(9686003)(2906002)(26005)(30864003)(8990500004)(316002)(41300700001)(6636002)(76116006)(66476007)(66556008)(66946007)(66446008)(5660300002)(52536014)(8676002)(8936002)(64756008)(110136005)(33656002)(122000001)(38070700005)(38100700002)(86362001)(82960400001)(82950400001)(55016003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zc23JyvFXNKrVE2XwVOLIZhEPTzN08Df9eG24tUWKNBF1EQyT99AR6s3lpVK?= =?us-ascii?Q?GS05pVRlVPbnXg4Qpeka1nu7J9jpVgGLnK1Kudve+lbOV3zul60KxHJlMpVg?= =?us-ascii?Q?zBAF7kl8pntJi/APMw2rmyQ7jv2vGDEE9DTGEHl2zA0doYE9NG+s766pn7ow?= =?us-ascii?Q?WPq/xOBmd+Xa5tXUiN0oe+b2yvpwoNcMZtKhtJmSXCyBANhngg1S20ow3IYh?= =?us-ascii?Q?DllupbQJlHlbkWlkNP28OLYeRRNU31iYkEy3DH74tG1l17nqOkmDAR5ckXzu?= =?us-ascii?Q?j8boitEG8iKVfICswuIl1AfyVZq4S6KPNnIjX1ty13hWEK5pC8iELz0ahv/K?= =?us-ascii?Q?TRc8LnRJGDgqGj0FtfL26s+I6SGINtPMCEXbfG25B+CCJMLU9rr5n0BNMrrs?= =?us-ascii?Q?GNdTfOpPuZqMXZQHflMEVrxjm84lvd10xmDgX7XXae9mNYPH1qUqjXsdukQ6?= =?us-ascii?Q?jp+Qv4SQyEqivR+Y1uO/DYkC05R6OrzON3Z/t9u+tIws2T/bX5f7gnm/zgfE?= =?us-ascii?Q?fWLBEm8jZoUCrTh3ydA8A2VN6FPY9qrnp9XfynHTtgKYvWdGs6hqGZXfRtdu?= =?us-ascii?Q?mrypwCUpZGdr2m1MEq+IAl9ftn+ucEF5bHgAxBtZfdjQIME4rpzzmkT9Es+d?= =?us-ascii?Q?sqlTpX0CF1FTpb/Nuz0ndWAZH/4vC93nJyIajYlw3yf+xM+KLj5wxXKduvvW?= =?us-ascii?Q?7RBDNDrCDBpC2ezo85sScnBhLT9ebTdlWiO9U34LWEaX/rlmSIxRkjVoh5GR?= =?us-ascii?Q?oQPySD3bEUeh38+o69pTRyb7gUu3reIShNW2nelQ5lDgYxmUr5gdKKaD2nYz?= =?us-ascii?Q?aZMvcJidfZadta0htcG5MOERnlxtKtd+J0g2E59TjAWdOzkuzm7B76+yaxJF?= =?us-ascii?Q?ylT4p1JV7Fb5R5RgxjppDUOHVFGKsGGnvmgkCbSrbcbjPASrBg+sim2zUuCc?= =?us-ascii?Q?EsTq75ataEIC8QLo96oprcIu/c5AKh2zVHrz1X1uVqCdy7hM3R6n9+m2X57z?= =?us-ascii?Q?2mtNAO6CKO1IF8AqYWGw3MBBqOq9ipJVzRz0RZbjzjfhSiSyPFXUem+YODUm?= =?us-ascii?Q?BTNyHB1tBthRijXvmcmuxt+52z0OVpDXSI5iCBaxYCvPCYhBlXX72ts3mnG8?= =?us-ascii?Q?cbE9pMqCOTXCnAYfiKf2YKdzclnyQfFFU882Kj4N2dP3G4RivtGBZj6LnWiB?= =?us-ascii?Q?b5Tb6zVKbOWcPSbMSJcjrt14dwky8wooJCDv37vXOOaC0V7o7LY8fZW2uRQ5?= =?us-ascii?Q?LnrS6aUn+2/J3mBMK2S9p8Sv2N/aZQuvY5UH7YAsFs5RHJGFWLw1RmWpZ5oT?= =?us-ascii?Q?l3ALtl6x2MveIEYlMpH8hV1nVOsPDrjQsBWhN5/OTaj0WDTmPSRzpr7XERNU?= =?us-ascii?Q?a3rbUCUbA1i1ZT8h/BL4UM5eW/OEgNkNuoAuOdOUi/+KUZOiNuP44rq5zLij?= =?us-ascii?Q?P36i1hbxkO8q8AskxMinz6Z/Np7Ke/fWx/uXI+YRYJEXeDit1yREnujjf8rQ?= =?us-ascii?Q?nkalIPKX7VRL0c0q6CPApE9663B2h7bQ7l3D?= 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: MN0PR21MB3120.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e49d423f-b616-4b26-c794-08dbc6a81a26 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Oct 2023 20:09:09.8132 (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: 9Su2li1jm2aY1rOZWar+FRtkr6//1I7CfMeOKmFcHyetnZXlUUE0hVqBkFFjeHq8Rqbl9A+8sq6lzGNuGV5q9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR21MB3356 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 for changing the netvsc MTU. The MTU can only be set at nvs initialization, therefore to change the MTU the underlying vmbus channel(s) are torn down and the vmbus device unmapped and remapped. The existing rx and tx queue(s) are reconnected to the new vmbus channel(s). Signed-off-by: Sam Andrew --- v2: Fix coding style issue --- drivers/bus/vmbus/vmbus_common.c | 4 +- drivers/net/netvsc/hn_ethdev.c | 185 +++++++++++++++++++++++++------ drivers/net/netvsc/hn_rndis.c | 7 ++ drivers/net/netvsc/hn_rndis.h | 1 + drivers/net/netvsc/hn_var.h | 3 +- drivers/net/netvsc/hn_vf.c | 23 +++- 6 files changed, 188 insertions(+), 35 deletions(-) diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_com= mon.c index 95f3ad78bc..fd205e8ac3 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -39,7 +39,9 @@ vmbus_map_resource(void *requested_addr, int fd, off_t of= fset, size_t size, "mmap(%d, %p, %zu, %ld) failed: %s", fd, requested_addr, size, (long)offset, strerror(errno)); - } + } else + VMBUS_LOG(DEBUG, " VMBUS memory mapped at %p", + mapaddr); return mapaddr; } =20 diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.= c index d0bbc0a4c0..f3419add3e 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -1059,37 +1059,6 @@ hn_dev_close(struct rte_eth_dev *dev) return ret; } =20 -static const struct eth_dev_ops hn_eth_dev_ops =3D { - .dev_configure =3D hn_dev_configure, - .dev_start =3D hn_dev_start, - .dev_stop =3D hn_dev_stop, - .dev_close =3D hn_dev_close, - .dev_infos_get =3D hn_dev_info_get, - .txq_info_get =3D hn_dev_tx_queue_info, - .rxq_info_get =3D hn_dev_rx_queue_info, - .dev_supported_ptypes_get =3D hn_vf_supported_ptypes, - .promiscuous_enable =3D hn_dev_promiscuous_enable, - .promiscuous_disable =3D hn_dev_promiscuous_disable, - .allmulticast_enable =3D hn_dev_allmulticast_enable, - .allmulticast_disable =3D hn_dev_allmulticast_disable, - .set_mc_addr_list =3D hn_dev_mc_addr_list, - .reta_update =3D hn_rss_reta_update, - .reta_query =3D hn_rss_reta_query, - .rss_hash_update =3D hn_rss_hash_update, - .rss_hash_conf_get =3D hn_rss_hash_conf_get, - .tx_queue_setup =3D hn_dev_tx_queue_setup, - .tx_queue_release =3D hn_dev_tx_queue_release, - .tx_done_cleanup =3D hn_dev_tx_done_cleanup, - .rx_queue_setup =3D hn_dev_rx_queue_setup, - .rx_queue_release =3D hn_dev_rx_queue_release, - .link_update =3D hn_dev_link_update, - .stats_get =3D hn_dev_stats_get, - .stats_reset =3D hn_dev_stats_reset, - .xstats_get =3D hn_dev_xstats_get, - .xstats_get_names =3D hn_dev_xstats_get_names, - .xstats_reset =3D hn_dev_xstats_reset, -}; - /* * Setup connection between PMD and kernel. */ @@ -1129,12 +1098,158 @@ hn_detach(struct hn_data *hv) hn_rndis_detach(hv); } =20 +/* + * Connects EXISTING rx/tx queues to NEW vmbus channel(s), and + * re-initializes NDIS and RNDIS, including re-sending initial + * NDIS/RNDIS configuration. To be used after the underlying vmbus + * has been un- and re-mapped, e.g. as must happen when the device + * MTU is changed. + */ +static int +hn_reinit(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct hn_data *hv =3D dev->data->dev_private; + struct hn_rx_queue **rxqs =3D (struct hn_rx_queue **)dev->data->rx_queues= ; + struct hn_tx_queue **txqs =3D (struct hn_tx_queue **)dev->data->tx_queues= ; + int i, ret =3D 0; + + /* Point primary queues at new primary channel */ + rxqs[0]->chan =3D hv->channels[0]; + txqs[0]->chan =3D hv->channels[0]; + + ret =3D hn_attach(hv, mtu); + if (ret) + return ret; + + /* Create vmbus subchannels, additional RNDIS configuration */ + ret =3D hn_dev_configure(dev); + if (ret) + return ret; + + /* Point any additional queues at new subchannels */ + for (i =3D 1; i < dev->data->nb_rx_queues; i++) + rxqs[i]->chan =3D hv->channels[i]; + for (i =3D 1; i < dev->data->nb_tx_queues; i++) + txqs[i]->chan =3D hv->channels[i]; + + return ret; +} + +static int +hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct hn_data *hv =3D dev->data->dev_private; + unsigned int orig_mtu =3D dev->data->mtu; + uint32_t rndis_mtu; + int ret =3D 0; + int i; + + if (dev->data->dev_started) { + PMD_DRV_LOG(ERR, "Device must be stopped before changing MTU"); + return -EIO; + } + + /* Change MTU of underlying VF dev first, if it exists */ + ret =3D hn_vf_mtu_set(dev, mtu); + if (ret) + return ret; + + /* Release channel resources */ + hn_detach(hv); + + /* Close any secondary vmbus channels */ + for (i =3D 1; i < hv->num_queues; i++) + rte_vmbus_chan_close(hv->channels[i]); + + /* Close primary vmbus channel */ + rte_free(hv->channels[0]); + + /* Unmap and re-map vmbus device */ + rte_vmbus_unmap_device(hv->vmbus); + ret =3D rte_vmbus_map_device(hv->vmbus); + if (ret) { + /* This is a catastrophic error - the device is unusable */ + PMD_DRV_LOG(ERR, "Could not re-map vmbus device!"); + return ret; + } + + /* Update pointers to re-mapped UIO resources */ + hv->rxbuf_res =3D hv->vmbus->resource[HV_RECV_BUF_MAP]; + hv->chim_res =3D hv->vmbus->resource[HV_SEND_BUF_MAP]; + + /* Re-open the primary vmbus channel */ + ret =3D rte_vmbus_chan_open(hv->vmbus, &hv->channels[0]); + if (ret) { + /* This is a catastrophic error - the device is unusable */ + PMD_DRV_LOG(ERR, "Could not re-open vmbus channel!"); + return ret; + } + + rte_vmbus_set_latency(hv->vmbus, hv->channels[0], hv->latency); + + ret =3D hn_reinit(dev, mtu); + if (!ret) + goto out; + + /* In case of error, attempt to restore original MTU */ + ret =3D hn_reinit(dev, orig_mtu); + if (ret) + PMD_DRV_LOG(ERR, "Restoring original MTU failed for netvsc"); + + ret =3D hn_vf_mtu_set(dev, orig_mtu); + if (ret) + PMD_DRV_LOG(ERR, "Restoring original MTU failed for VF"); + +out: + if (hn_rndis_get_mtu(hv, &rndis_mtu)) { + PMD_DRV_LOG(ERR, "Could not get MTU via RNDIS"); + } else { + dev->data->mtu =3D (uint16_t)rndis_mtu; + PMD_DRV_LOG(DEBUG, "RNDIS MTU is %u", dev->data->mtu); + } + + return ret; +} + +static const struct eth_dev_ops hn_eth_dev_ops =3D { + .dev_configure =3D hn_dev_configure, + .dev_start =3D hn_dev_start, + .dev_stop =3D hn_dev_stop, + .dev_close =3D hn_dev_close, + .dev_infos_get =3D hn_dev_info_get, + .txq_info_get =3D hn_dev_tx_queue_info, + .rxq_info_get =3D hn_dev_rx_queue_info, + .dev_supported_ptypes_get =3D hn_vf_supported_ptypes, + .promiscuous_enable =3D hn_dev_promiscuous_enable, + .promiscuous_disable =3D hn_dev_promiscuous_disable, + .allmulticast_enable =3D hn_dev_allmulticast_enable, + .allmulticast_disable =3D hn_dev_allmulticast_disable, + .set_mc_addr_list =3D hn_dev_mc_addr_list, + .mtu_set =3D hn_dev_mtu_set, + .reta_update =3D hn_rss_reta_update, + .reta_query =3D hn_rss_reta_query, + .rss_hash_update =3D hn_rss_hash_update, + .rss_hash_conf_get =3D hn_rss_hash_conf_get, + .tx_queue_setup =3D hn_dev_tx_queue_setup, + .tx_queue_release =3D hn_dev_tx_queue_release, + .tx_done_cleanup =3D hn_dev_tx_done_cleanup, + .rx_queue_setup =3D hn_dev_rx_queue_setup, + .rx_queue_release =3D hn_dev_rx_queue_release, + .link_update =3D hn_dev_link_update, + .stats_get =3D hn_dev_stats_get, + .stats_reset =3D hn_dev_stats_reset, + .xstats_get =3D hn_dev_xstats_get, + .xstats_get_names =3D hn_dev_xstats_get_names, + .xstats_reset =3D hn_dev_xstats_reset, +}; + static int eth_hn_dev_init(struct rte_eth_dev *eth_dev) { struct hn_data *hv =3D eth_dev->data->dev_private; struct rte_device *device =3D eth_dev->device; struct rte_vmbus_device *vmbus; + uint32_t mtu; unsigned int rxr_cnt; int err, max_chan; =20 @@ -1218,6 +1333,12 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev) if (err) goto failed; =20 + err =3D hn_rndis_get_mtu(hv, &mtu); + if (err) + goto failed; + eth_dev->data->mtu =3D (uint16_t)mtu; + PMD_INIT_LOG(DEBUG, "RNDIS MTU is %u", eth_dev->data->mtu); + err =3D hn_rndis_get_eaddr(hv, eth_dev->data->mac_addrs->addr_bytes); if (err) goto failed; @@ -1272,7 +1393,7 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev) =20 hn_detach(hv); hn_chim_uninit(eth_dev); - rte_vmbus_chan_close(hv->primary->chan); + rte_vmbus_chan_close(hv->channels[0]); rte_free(hv->primary); ret =3D rte_eth_dev_owner_delete(hv->owner.id); if (ret !=3D 0) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c index 29c6009b2c..778f86f2bf 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -1111,6 +1111,13 @@ hn_rndis_get_eaddr(struct hn_data *hv, uint8_t *eadd= r) return 0; } =20 +int +hn_rndis_get_mtu(struct hn_data *hv, uint32_t *mtu) +{ + return hn_rndis_query(hv, OID_GEN_MAXIMUM_FRAME_SIZE, NULL, 0, + mtu, sizeof(uint32_t)); +} + int hn_rndis_get_linkstatus(struct hn_data *hv) { diff --git a/drivers/net/netvsc/hn_rndis.h b/drivers/net/netvsc/hn_rndis.h index 9a8251fc2f..7f40f6221d 100644 --- a/drivers/net/netvsc/hn_rndis.h +++ b/drivers/net/netvsc/hn_rndis.h @@ -10,6 +10,7 @@ void hn_rndis_link_status(struct rte_eth_dev *dev, const = void *msg); int hn_rndis_attach(struct hn_data *hv); void hn_rndis_detach(struct hn_data *hv); int hn_rndis_get_eaddr(struct hn_data *hv, uint8_t *eaddr); +int hn_rndis_get_mtu(struct hn_data *hv, uint32_t *mtu); int hn_rndis_get_linkstatus(struct hn_data *hv); int hn_rndis_get_linkspeed(struct hn_data *hv); int hn_rndis_set_rxfilter(struct hn_data *hv, uint32_t filter); diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index e1f8e69a28..e37946804d 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -13,7 +13,7 @@ * Tunable ethdev params */ #define HN_MIN_RX_BUF_SIZE 1024 -#define HN_MAX_XFER_LEN 2048 +#define HN_MAX_XFER_LEN RTE_ETHER_MAX_JUMBO_FRAME_LEN #define HN_MAX_MAC_ADDRS 1 #define HN_MAX_CHANNELS 64 =20 @@ -287,6 +287,7 @@ int hn_vf_rss_hash_update(struct rte_eth_dev *dev, int hn_vf_reta_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size); +int hn_vf_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); int hn_eth_rmv_event_callback(uint16_t port_id, enum rte_eth_event_type event __rte_unused, void *cb_arg, void *out __rte_unused); diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index 782395d805..90cb6f6923 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -239,7 +239,7 @@ int hn_vf_add(struct rte_eth_dev *dev, struct hn_data *= hv) =20 port =3D hv->vf_ctx.vf_port; =20 - /* If the primary device has started, this is a VF host add. + /* If the primary device has started, this is a VF hot add. * Configure and start VF device. */ if (dev->data->dev_started) { @@ -264,6 +264,12 @@ int hn_vf_add(struct rte_eth_dev *dev, struct hn_data = *hv) goto exit; } =20 + ret =3D hn_vf_mtu_set(dev, dev->data->mtu); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to set VF MTU"); + goto exit; + } + PMD_DRV_LOG(NOTICE, "Starting VF port %d", port); ret =3D rte_eth_dev_start(port); if (ret) { @@ -778,3 +784,18 @@ int hn_vf_reta_hash_update(struct rte_eth_dev *dev, =20 return ret; } + +int hn_vf_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct hn_data *hv =3D dev->data->dev_private; + struct rte_eth_dev *vf_dev; + int ret =3D 0; + + rte_rwlock_read_lock(&hv->vf_lock); + vf_dev =3D hn_get_vf_dev(hv); + if (hv->vf_ctx.vf_vsc_switched && vf_dev) + ret =3D vf_dev->dev_ops->mtu_set(vf_dev, mtu); + rte_rwlock_read_unlock(&hv->vf_lock); + + return ret; +} --=20 2.42.0.windows.2