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 0E8E242B48; Fri, 19 May 2023 12:04:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE9604161A; Fri, 19 May 2023 12:04:31 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2051.outbound.protection.outlook.com [40.107.244.51]) by mails.dpdk.org (Postfix) with ESMTP id EFCED41148 for ; Fri, 19 May 2023 12:04:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B6X7Qk0G4YxewX56g28Q9d+jjsZhiwtqDJJrjmgKeeulMdjNeRpkHG0dyu1s2z9gMvNO5rODkC+v58+rIkEALS4PUqzhSemV/qnpygxMzb5Q9HqkWR6sxxKcxrixXOdT18lAVOFl0lagtbQ4EMTzIc9xEubzTRTmDlRAaOWOlsFUfWkVuaRNqvJQizFmAtniI8TKxmd570gH2DLpxgNiTVP+hjDf4MlNf/3vIfLgjkXyOeps4n+MAkWkUYgju4OANysLk6U0tuNBT84BALevw3gwiMipa2R9yiKEK8ZKI0scX1kuSq2XZ8mN0/EFBHvs/zIa2LdfS2QRMoPDKS1KxQ== 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=qDBKYVHQGNO8R7exX1hCKmuxUSjV7VvHu2w/ZCvbjkg=; b=kx8s5oEyPGks1reRAB3IJF6y5KAglGIRd7iVZD+rTfZEa9V545I08MoMyu9pXw6IOlk2gR6zFQkpGU91gm1ZpEr3ZFhGeRcWQdlmOPuNUyPfftjf780UWz47Mdq7s83ZjvtVgHaiSZG9JG+kTerCXYmrSK0Ka/DIWIGF2hdXFH/y5VBw7wKcvIXQU2mQnvCRvB1x3epQNBkkRSBY5bvk4LSGzt9WrpE/RqeTOyAz7BI9CLd+fxa7HbUHS1T7ghRKcvz/HWfckVQ5mWG/+cajxorHTrmv8o9ti8LHiQw7MgU1EAkXfA+tTETJAP/JXGmpIn/xpZkvVpPj2HC8batmhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qDBKYVHQGNO8R7exX1hCKmuxUSjV7VvHu2w/ZCvbjkg=; b=qOJszi+dVvSjqqyJ989sV34Gqxy/LAmXgTRQMWOy0soy2kksqvz4owNwhC29FklrXCjLF9RKV4V5a7+fdWSveUrVrDZaB6WzHkI5vhOAHAWSKfW1GAjpbB1w8f/oHC377t0dOw3IiDDpGqbKWHrqk7fusbwCR1QaUbdY1p29rdI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by IA0PR12MB7652.namprd12.prod.outlook.com (2603:10b6:208:434::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:04:27 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::7957:641d:6aba:3f9a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::7957:641d:6aba:3f9a%4]) with mapi id 15.20.6411.019; Fri, 19 May 2023 10:04:26 +0000 Message-ID: <7ed74e1f-11ed-7fc4-2ee5-1e646cbb3699@amd.com> Date: Fri, 19 May 2023 11:04:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Rushil Gupta , qi.z.zhang@intel.com, jingjing.wu@intel.com Cc: junfeng.guo@intel.com, joshwash@google.com, dev@dpdk.org, Jeroen de Borst References: <20230508191552.104540-1-rushilg@google.com> <20230519072600.1444309-1-rushilg@google.com> From: Ferruh Yigit Subject: Re: [PATCH] net/gve: check driver compatibility In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO3P123CA0003.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::8) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|IA0PR12MB7652:EE_ X-MS-Office365-Filtering-Correlation-Id: 77eaf1de-b652-4c26-38d9-08db58506d78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IPLduOmLioMUOIOXdcGOyOq77z+0XCuJxKcJjCxKmiHaatGP4FBS+fG97ATxfv+8P4jePH/2zQoJnUyXiSeLYcLB+85a4C/ksNCQqsfmxOOxAAq5AzRHTFq4u1b5pNdtfgOlA6zgimVNh/PCbbQc6igm4yARNOB2NsF5p20kiu4xGt26qywKVKRpug/vzWpzsAJQLM76rDjH+U3j+VdiwSrAaNY8ZJysBGee7/mroH82O/WoONsr8F68e8hE/8KQUchX7KY5ZZXymDYVPEG5tKiGmMpeSTxkmkvB1W117c51sWzyfXjZ0h5YDvKUQ6sDqKH+Jj7qm1/D4Mfx8HnIRXoXl1vrJND15MX/ftomLjKjrsTrtfXLL648aNl8dWuAK2nBqDW2kdrkoI2HiVa1HQRREAQVsZmrXemtoJHr9oDSMzYjHkadQltcQpnH0KShndG7J+0hvPA9+PYKZh6AN5OSiVY/piTTfqsQNvHOc3u4gZ3Z1sp/4dfz+IUfjNLPPjjFqPu2TNeHYaYC3Yvs9HCEga8hBF10Bf/qjrg8o0MHaCPyTHtw50LMntaWT2jAUxeawDf3f1OZOE+fn55/xRIyAVy2H9AmWsDvqtThIUUCHrP28Ggw+zN5EHLVnHubCwr/feD1okUaKtkBAOzMKr0waK0U8JJGhqOV414ZU1WIFqRf/okiYFXX0cJJJNtn X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(86362001)(31696002)(36756003)(316002)(66556008)(966005)(66946007)(66476007)(478600001)(4326008)(6666004)(6486002)(8936002)(8676002)(5660300002)(30864003)(2906002)(44832011)(38100700002)(41300700001)(2616005)(26005)(186003)(53546011)(6506007)(83380400001)(6512007)(31686004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SUp6bysvdkNETkVHOXNCYktwaENDR3BTSEJJZjZLRkhQN2ZyOEY4RDVZZElx?= =?utf-8?B?SW9rS05teUo3d1V4QlNpVEU0QU5aSDdPeGhDbERYQ2Ryd2UraW9Xa21FZ0xz?= =?utf-8?B?YTdxV3hTSDhHK3RJSld0cmhOTHVvUGZwbGhKL3NEQ09tMU9ET0NQc0drZWcv?= =?utf-8?B?SUJlL1JMb3h5RUcrNXpIMi9xZHRZOEZST0V2aEcwS0xyeS9jRXNrL3JCZlhs?= =?utf-8?B?SW5TS3Z4UG5xc0tsbFQxOEtZSzFlQXRzdkVZTTg0aG03bnJXaXhtaEVBc1FQ?= =?utf-8?B?NnJVMUo5anhaSEVLanZYd2dyN2NCaFl5S1kxRXpkQm53eGgyZHRCaE9tRzF1?=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nX2hwh?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77eaf1de-b652-4c26-38d9-08db58506d78 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:04:26.3965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jl/bdEsdvbbXOlbs4DyXmiQGkfta+4h2Ms5YOCdfkYf/bDFMH76JfL8Phpr8SgmL X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7652 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 On 5/19/2023 8:41 AM, Rushil Gupta wrote: > Hi Ferruh > I have updated the latest patch here: > http://patchwork.dpdk.org/project/dpdk/patch/20230519072600.1444309-1-rushilg@google.com/ > However, using calloc causes issue while executing verify-compatibility command. > > sudo dpdk-testpmd -a 00:04.0 -l 0-32 -- --forward-mode=rxonly --txq=16 > --rxq=16 --nb-cores=16 --stats-period 5 > ... > EAL: Using IOMMU type 8 (No-IOMMU) > EAL: Probe PCI driver: net_gve (1ae0:42) device: 0000:00:04.0 (socket -1) > gve_adminq_parse_err(): AQ command failed with status -9 > gve_init_priv(): Could not verify driver compatibility: err=-22 > EAL: Releasing PCI mapped resource for 0000:00:04.0 > ... > EAL: Error - exiting with code: 1 > > > This is probably because the adminq command is sharing memory to > report driver-info to the gvnic device and that needs to be in dpdk > memory. > > Hi Rushil, That is OK, I missed this requirement. Admin command passes pointers for device to process, what is the address type requirement here? Some other commands pass pysical address (iova address) via the command. Both 'calloc()' and 'rte_zmalloc()' returns (guest) virtual address, why one doesn't work but other does? Initial version was passing 'rte_memzone' pointer, are you updating the hyperviser side based on changes on dpdk side? And perhaps better to switch to 'rte_memzone_reserve_aligned()' as done initial version and pass (guest) pysical address via adminq, if that is the requirement? > > On Fri, May 19, 2023 at 12:26 AM Rushil Gupta wrote: >> >> Change gve_driver_info fields to report DPDK as OS type and DPDK RTE >> version as OS version, reserving driver_version fields for GVE driver >> version based on features. >> >> Signed-off-by: Rushil Gupta >> Signed-off-by: Joshua Washington >> Signed-off-by: Junfeng Guo >> Signed-off-by: Jeroen de Borst >> --- >> drivers/net/gve/base/gve.h | 3 -- >> drivers/net/gve/base/gve_adminq.c | 19 ++++++++++ >> drivers/net/gve/base/gve_adminq.h | 46 ++++++++++++++++++++++- >> drivers/net/gve/base/gve_osdep.h | 24 ++++++++++++ >> drivers/net/gve/gve_ethdev.c | 61 +++++++++++++++++++++++++------ >> drivers/net/gve/gve_ethdev.h | 2 +- >> drivers/net/gve/gve_version.c | 13 +++++++ >> drivers/net/gve/gve_version.h | 24 ++++++++++++ >> drivers/net/gve/meson.build | 5 ++- >> 9 files changed, 179 insertions(+), 18 deletions(-) >> create mode 100644 drivers/net/gve/gve_version.c >> create mode 100644 drivers/net/gve/gve_version.h >> >> diff --git a/drivers/net/gve/base/gve.h b/drivers/net/gve/base/gve.h >> index 2b7cf7d99b..f7b297e759 100644 >> --- a/drivers/net/gve/base/gve.h >> +++ b/drivers/net/gve/base/gve.h >> @@ -9,9 +9,6 @@ >> #include "gve_desc.h" >> #include "gve_desc_dqo.h" >> >> -#define GVE_VERSION "1.3.0" >> -#define GVE_VERSION_PREFIX "GVE-" >> - >> #ifndef GOOGLE_VENDOR_ID >> #define GOOGLE_VENDOR_ID 0x1ae0 >> #endif >> diff --git a/drivers/net/gve/base/gve_adminq.c b/drivers/net/gve/base/gve_adminq.c >> index e963f910a0..41202725e6 100644 >> --- a/drivers/net/gve/base/gve_adminq.c >> +++ b/drivers/net/gve/base/gve_adminq.c >> @@ -401,6 +401,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv, >> case GVE_ADMINQ_GET_PTYPE_MAP: >> priv->adminq_get_ptype_map_cnt++; >> break; >> + case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY: >> + priv->adminq_verify_driver_compatibility_cnt++; >> + break; >> default: >> PMD_DRV_LOG(ERR, "unknown AQ command opcode %d", opcode); >> } >> @@ -465,6 +468,22 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv, >> return gve_adminq_execute_cmd(priv, &cmd); >> } >> >> +int gve_adminq_verify_driver_compatibility(struct gve_priv *priv, >> + u64 driver_info_len, >> + dma_addr_t driver_info_addr) >> +{ >> + union gve_adminq_command cmd; >> + >> + memset(&cmd, 0, sizeof(cmd)); >> + cmd.opcode = cpu_to_be32(GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY); >> + cmd.verify_driver_compatibility = (struct gve_adminq_verify_driver_compatibility) { >> + .driver_info_len = cpu_to_be64(driver_info_len), >> + .driver_info_addr = cpu_to_be64(driver_info_addr), >> + }; >> + >> + return gve_adminq_execute_cmd(priv, &cmd); >> +} >> + >> int gve_adminq_deconfigure_device_resources(struct gve_priv *priv) >> { >> union gve_adminq_command cmd; >> diff --git a/drivers/net/gve/base/gve_adminq.h b/drivers/net/gve/base/gve_adminq.h >> index 05550119de..e30b184913 100644 >> --- a/drivers/net/gve/base/gve_adminq.h >> +++ b/drivers/net/gve/base/gve_adminq.h >> @@ -1,6 +1,6 @@ >> /* SPDX-License-Identifier: MIT >> * Google Virtual Ethernet (gve) driver >> - * Copyright (C) 2015-2022 Google, Inc. >> + * Copyright (C) 2015-2023 Google, Inc. >> */ >> >> #ifndef _GVE_ADMINQ_H >> @@ -23,6 +23,7 @@ enum gve_adminq_opcodes { >> GVE_ADMINQ_REPORT_STATS = 0xC, >> GVE_ADMINQ_REPORT_LINK_SPEED = 0xD, >> GVE_ADMINQ_GET_PTYPE_MAP = 0xE, >> + GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY = 0xF, >> }; >> >> /* Admin queue status codes */ >> @@ -145,6 +146,44 @@ enum gve_sup_feature_mask { >> }; >> >> #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0 >> +enum gve_driver_capbility { >> + gve_driver_capability_gqi_qpl = 0, >> + gve_driver_capability_gqi_rda = 1, >> + gve_driver_capability_dqo_qpl = 2, /* reserved for future use */ >> + gve_driver_capability_dqo_rda = 3, >> +}; >> + >> +#define GVE_CAP1(a) BIT((int)a) >> + >> +#define GVE_DRIVER_CAPABILITY_FLAGS1 \ >> + (GVE_CAP1(gve_driver_capability_gqi_qpl) | \ >> + GVE_CAP1(gve_driver_capability_gqi_rda) | \ >> + GVE_CAP1(gve_driver_capability_dqo_rda)) >> + >> +#define GVE_DRIVER_CAPABILITY_FLAGS2 0x0 >> +#define GVE_DRIVER_CAPABILITY_FLAGS3 0x0 >> +#define GVE_DRIVER_CAPABILITY_FLAGS4 0x0 >> + >> +struct gve_driver_info { >> + u8 os_type; /* 0x05 = DPDK */ >> + u8 driver_major; >> + u8 driver_minor; >> + u8 driver_sub; >> + __be32 os_version_major; >> + __be32 os_version_minor; >> + __be32 os_version_sub; >> + __be64 driver_capability_flags[4]; >> + u8 os_version_str1[OS_VERSION_STRLEN]; >> + u8 os_version_str2[OS_VERSION_STRLEN]; >> +}; >> + >> +struct gve_adminq_verify_driver_compatibility { >> + __be64 driver_info_len; >> + __be64 driver_info_addr; >> +}; >> + >> +GVE_CHECK_STRUCT_LEN(16, gve_adminq_verify_driver_compatibility); >> + >> >> struct gve_adminq_configure_device_resources { >> __be64 counter_array; >> @@ -345,6 +384,8 @@ union gve_adminq_command { >> struct gve_adminq_report_stats report_stats; >> struct gve_adminq_report_link_speed report_link_speed; >> struct gve_adminq_get_ptype_map get_ptype_map; >> + struct gve_adminq_verify_driver_compatibility >> + verify_driver_compatibility; >> }; >> }; >> u8 reserved[64]; >> @@ -378,4 +419,7 @@ struct gve_ptype_lut; >> int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv, >> struct gve_ptype_lut *ptype_lut); >> >> +int gve_adminq_verify_driver_compatibility(struct gve_priv *priv, >> + u64 driver_info_len, >> + dma_addr_t driver_info_addr); >> #endif /* _GVE_ADMINQ_H */ >> diff --git a/drivers/net/gve/base/gve_osdep.h b/drivers/net/gve/base/gve_osdep.h >> index abf3d379ae..5e8ae1eac6 100644 >> --- a/drivers/net/gve/base/gve_osdep.h >> +++ b/drivers/net/gve/base/gve_osdep.h >> @@ -21,9 +21,14 @@ >> #include >> #include >> #include >> +#include >> >> #include "../gve_logs.h" >> >> +#ifdef __linux__ >> +#include >> +#endif >> + >> typedef uint8_t u8; >> typedef uint16_t u16; >> typedef uint32_t u32; >> @@ -73,6 +78,12 @@ typedef rte_iova_t dma_addr_t; >> >> #define msleep(ms) rte_delay_ms(ms) >> >> +#define OS_VERSION_STRLEN 128 >> +struct os_version_string { >> + char os_version_str1[OS_VERSION_STRLEN]; >> + char os_version_str2[OS_VERSION_STRLEN]; >> +}; >> + >> /* These macros are used to generate compilation errors if a struct/union >> * is not exactly the correct length. It gives a divide by zero error if >> * the struct/union is not of the correct size, otherwise it creates an >> @@ -160,4 +171,17 @@ gve_free_dma_mem(struct gve_dma_mem *mem) >> mem->pa = 0; >> } >> >> +static inline void >> +populate_driver_version_strings(char *str1, char *str2) >> +{ >> + struct utsname uts; >> + if (uname(&uts) >= 0) { >> + /* release */ >> + rte_strscpy(str1, uts.release, >> + OS_VERSION_STRLEN); >> + /* version */ >> + rte_strscpy(str2, uts.version, >> + OS_VERSION_STRLEN); >> + } >> +} >> #endif /* _GVE_OSDEP_H_ */ >> diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c >> index 1dcb3b3a01..71d131fb41 100644 >> --- a/drivers/net/gve/gve_ethdev.c >> +++ b/drivers/net/gve/gve_ethdev.c >> @@ -5,21 +5,13 @@ >> #include "gve_ethdev.h" >> #include "base/gve_adminq.h" >> #include "base/gve_register.h" >> - >> -const char gve_version_str[] = GVE_VERSION; >> -static const char gve_version_prefix[] = GVE_VERSION_PREFIX; >> +#include "base/gve_osdep.h" >> +#include "gve_version.h" >> >> static void >> gve_write_version(uint8_t *driver_version_register) >> { >> - const char *c = gve_version_prefix; >> - >> - while (*c) { >> - writeb(*c, driver_version_register); >> - c++; >> - } >> - >> - c = gve_version_str; >> + const char *c = gve_version_string(); >> while (*c) { >> writeb(*c, driver_version_register); >> c++; >> @@ -245,6 +237,48 @@ gve_dev_close(struct rte_eth_dev *dev) >> return err; >> } >> >> +static int >> +gve_verify_driver_compatibility(struct gve_priv *priv) >> +{ >> + struct gve_driver_info *driver_info; >> + int err; >> + >> + driver_info = rte_zmalloc("driver info", >> + sizeof(struct gve_driver_info), 0); >> + if (driver_info == NULL) { >> + PMD_DRV_LOG(ERR, >> + "Could not alloc for verify driver compatibility"); >> + return -ENOMEM; >> + } >> + *driver_info = (struct gve_driver_info) { >> + .os_type = 5, /* DPDK */ >> + .driver_major = GVE_VERSION_MAJOR, >> + .driver_minor = GVE_VERSION_MINOR, >> + .driver_sub = GVE_VERSION_SUB, >> + .os_version_major = cpu_to_be32(DPDK_VERSION_MAJOR), >> + .os_version_minor = cpu_to_be32(DPDK_VERSION_MINOR), >> + .os_version_sub = cpu_to_be32(DPDK_VERSION_SUB), >> + .driver_capability_flags = { >> + cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS1), >> + cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS2), >> + cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS3), >> + cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS4), >> + }, >> + }; >> + >> + populate_driver_version_strings((char *)driver_info->os_version_str1, >> + (char *)driver_info->os_version_str2); >> + >> + err = gve_adminq_verify_driver_compatibility(priv, >> + sizeof(struct gve_driver_info), (dma_addr_t)driver_info); >> + /* It's ok if the device doesn't support this */ >> + if (err == -EOPNOTSUPP) >> + err = 0; >> + >> + rte_free(driver_info); >> + return err; >> +} >> + >> static int >> gve_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) >> { >> @@ -679,6 +713,11 @@ gve_init_priv(struct gve_priv *priv, bool skip_describe_device) >> PMD_DRV_LOG(ERR, "Failed to alloc admin queue: err=%d", err); >> return err; >> } >> + err = gve_verify_driver_compatibility(priv); >> + if (err) { >> + PMD_DRV_LOG(ERR, "Could not verify driver compatibility: err=%d", err); >> + goto free_adminq; >> + } >> >> if (skip_describe_device) >> goto setup_device; >> diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h >> index cd62debd22..c9bcfa553c 100644 >> --- a/drivers/net/gve/gve_ethdev.h >> +++ b/drivers/net/gve/gve_ethdev.h >> @@ -268,7 +268,7 @@ struct gve_priv { >> uint32_t adminq_report_stats_cnt; >> uint32_t adminq_report_link_speed_cnt; >> uint32_t adminq_get_ptype_map_cnt; >> - >> + uint32_t adminq_verify_driver_compatibility_cnt; >> volatile uint32_t state_flags; >> >> /* Gvnic device link speed from hypervisor. */ >> diff --git a/drivers/net/gve/gve_version.c b/drivers/net/gve/gve_version.c >> new file mode 100644 >> index 0000000000..5fe34dc179 >> --- /dev/null >> +++ b/drivers/net/gve/gve_version.c >> @@ -0,0 +1,13 @@ >> +/* SPDX-License-Identifier: BSD-3-Clause >> + * Copyright (C) 2015-2023 Google, Inc. >> + */ >> +#include "gve_version.h" >> + >> +const char *gve_version_string(void) >> +{ >> + static char gve_version[20]; >> + snprintf(gve_version, sizeof(gve_version), "%s%d.%d.%d", >> + GVE_VERSION_PREFIX, GVE_VERSION_MAJOR, GVE_VERSION_MINOR, >> + GVE_VERSION_SUB); >> + return gve_version; >> +} >> diff --git a/drivers/net/gve/gve_version.h b/drivers/net/gve/gve_version.h >> new file mode 100644 >> index 0000000000..4dd998dca1 >> --- /dev/null >> +++ b/drivers/net/gve/gve_version.h >> @@ -0,0 +1,24 @@ >> +/* SPDX-License-Identifier: BSD-3-Clause >> + * Copyright (C) 2015-2023 Google, Inc. >> + */ >> + >> +#ifndef _GVE_VERSION_H_ >> +#define _GVE_VERSION_H_ >> + >> +#include >> + >> +#define GVE_VERSION_PREFIX "DPDK-" >> +#define GVE_VERSION_MAJOR 1 >> +#define GVE_VERSION_MINOR 0 >> +#define GVE_VERSION_SUB 0 >> + >> +#define DPDK_VERSION_MAJOR (100 * RTE_VER_YEAR + RTE_VER_MONTH) >> +#define DPDK_VERSION_MINOR RTE_VER_MINOR >> +#define DPDK_VERSION_SUB RTE_VER_RELEASE >> + >> + >> +const char * >> +gve_version_string(void); >> + >> + >> +#endif /* GVE_VERSION_H */ >> diff --git a/drivers/net/gve/meson.build b/drivers/net/gve/meson.build >> index c9d87903f9..61d195009c 100644 >> --- a/drivers/net/gve/meson.build >> +++ b/drivers/net/gve/meson.build >> @@ -1,9 +1,9 @@ >> # SPDX-License-Identifier: BSD-3-Clause >> # Copyright(C) 2022 Intel Corporation >> >> -if is_windows >> +if not is_linux >> build = false >> - reason = 'not supported on Windows' >> + reason = 'only supported on Linux' >> subdir_done() >> endif >> >> @@ -14,5 +14,6 @@ sources = files( >> 'gve_rx_dqo.c', >> 'gve_tx_dqo.c', >> 'gve_ethdev.c', >> + 'gve_version.c', >> ) >> includes += include_directories('base') >> -- >> 2.40.1.698.g37aff9b760-goog >>