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 0C6E042A5E; Thu, 4 May 2023 17:06:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9466C41144; Thu, 4 May 2023 17:06:41 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2051.outbound.protection.outlook.com [40.107.212.51]) by mails.dpdk.org (Postfix) with ESMTP id BB676410DC for ; Thu, 4 May 2023 17:06:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QuYcrz8qENf7ztTEw0pJ+W5vk8Lu3To1LM9EjwBQE5X2/ZN1yynb67JugtV78a7/lXG+o8v9XDM2DZAe1bgardwdcfTO+jzYadxyvStjwvhxioMuI6b0H4slS6Lw8XZa8sbCldGDHp8daJ4z+g8Gz0Ps40SvBKgxyL4OrpZ42Zg3m48tRZBfcWhNDbpJPtffvxrHfgstoTHyAOzCiJNLYhEeGIbrRSpN3uwrstrADmSyxujYmMJH3pIX5qZdEgoruxw5tuGvoKT/vn3NBicXrsZVbP1Sge/ZzMR+gYp8tuyrxORP9lKTRkL6tLbYlkaEtaFibkWKvRja4SpRpZ9aiA== 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=0EjXr9u0+BFIHT4SvmEAUNRZgscC8dUdsize3aD47ek=; b=FJvQY1LStxdCkkTacRTO3INAh/tkDF2pQDX6oW+KtWpMuQKXPKFJjpM253Paf1zYo5UjnayIjeczaHDkAyV+05Ya9rcYAJTz26h4dzd0EYKnRt0ntn8AcJCdhVdY+7X2IPkMDF+GuNLUIERcNAqcS0gLEiuq/37aqfXvWqcNGDLkdDzY0QazwNpgKYKtjxko3z7XOi78s/faWm2Ukx0Jy7jg0gZ9/ZBa/t5X/mLw2721wBCz0MYUVg9X/s0hFzf835xySkpta71nVJ+5YIaSgWwdZjg+oqSdpoPJRFulkPc8yuaJ1UnAwpXvqF4trg1iYrpnr4wzhqm2HGRpa6B+5g== 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=0EjXr9u0+BFIHT4SvmEAUNRZgscC8dUdsize3aD47ek=; b=Vf0UHQG7zTTlcKQFx41odSr8rrfdPG8oJwJ8gvHsgGLLxb7Ve4E1rB6v6bodKS2IKsFnE7T2rrhYcezKsSjmvmaxv4/1GRp1KQIf9vU1MjdN8zmsnl9Hyo3TZ7Cn7ATEnYkx/FoA2ICjjrgA1kmveJ3nSBmJ8wvbhwafuu6T1S0= 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 LV3PR12MB9213.namprd12.prod.outlook.com (2603:10b6:408:1a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26; Thu, 4 May 2023 15:06:38 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::e818:77ea:75b5:f8cc]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::e818:77ea:75b5:f8cc%5]) with mapi id 15.20.6363.022; Thu, 4 May 2023 15:06:38 +0000 Message-ID: Date: Thu, 4 May 2023 16:06:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 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: <20230414051454.1245936-1-rushilg@google.com> <20230426213700.2668699-1-rushilg@google.com> From: Ferruh Yigit Subject: Re: [PATCH] net/gve: Check whether the driver is compatible with the device presented. In-Reply-To: <20230426213700.2668699-1-rushilg@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0510.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::17) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|LV3PR12MB9213:EE_ X-MS-Office365-Filtering-Correlation-Id: fd5b49be-208f-4897-bbec-08db4cb128a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J7q//54Ulk44zLEBpVoqtO9ZaoUmBDmgIDUcg9AJ2bcvqQvJsII46wtD3P/y3/7GYXUA3cjtmSzX5dpdyhunwODAtmOWLirHTgpeQhrOK7UJh/F5Y3eVtpfhSfI/EwaK561r2Nu8jr7olF4Zn6G+JuT0mSk625vitO4BwRaK9YeZdQDMg5fTHLhgv6Z23y0Tqsysfzf/29tBZIBEYZqLRWGpQa7ogLdasvFNQG6flmjoADCChRtgNPJUrBW5aQBkKjohM+jXlDkU9J1A/XSeofPfDXsOPBi7c9BmFBipg5ewhFXnTh32NZ5bkmriTjaHuN0CVVUkEqO/3+b6aGBFYzLRv8Hd4SLLycLFLaUfkmke0c4/XU0pqKEsor1FOObMhSGq3BM4oqu3C+AK51D4FG1xxP/iQwpHut9VXjMq/moJWx4RK8vX7uQUAxih1xMy7t3o+ax1CtsksjNDE+cyYbmyV7P1fti5im6egmv6jU1zNMr7xCdoqH+OIB7VcmvypjMpUkL60ftq65+5ZN+/HCdrljD4HLXR/qemdgZHGqPV5sDvriG0pkXRnqdEyIAlgFgfgszS+q4y2eS/xD9s5LEiZiZkNFV5fRJIyj42NDuPr0nzdcNMicGYgTOKBOoLN2Oa4XUqup475aej20enIQ== 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)(376002)(346002)(366004)(136003)(39860400002)(396003)(451199021)(30864003)(478600001)(6666004)(31686004)(2906002)(44832011)(8676002)(8936002)(5660300002)(36756003)(4326008)(316002)(66946007)(66556008)(6506007)(66476007)(26005)(6486002)(966005)(41300700001)(83380400001)(53546011)(6512007)(38100700002)(186003)(31696002)(2616005)(86362001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?azdnK1BDN0dOc3ZZWXJuR0pRTHg1bWN1eHFPY2w2ZFNqRk1DT1paS0gxY0xp?= =?utf-8?B?TnczM1QzbDNMZUFoancwenVkRmt0cTJLaTlDazZmRlZQNkFtaGNYbjgyUDhS?= =?utf-8?B?OURQK1cwYzdDdmo0N3czNU9GUXF6V3BSR3hUMmIzOFpNdmVhM1NHUElKMUVY?= =?utf-8?B?bzFMWXg2WE9JZFFYY0xXVUpNU0RESzNOc0tjOVUvb0hOWkZTRXdORm43aXpk?= =?utf-8?B?SXg2ZWNpWi9FYVpySzFDRFo0Z0xIMHJRQXBHRTZrTmdJOTJ2SVpDaWgwNjJG?= =?utf-8?B?Q1pLQU8yekp2Q3djQmpSRjBFdmswZFNFUDlBTmhaaXdkY204dS9oU2EydXJX?= =?utf-8?B?dFNadGNDT2lpNzdjRDBCSXg1VEZmN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X-MS-Exchange-CrossTenant-Network-Message-Id: fd5b49be-208f-4897-bbec-08db4cb128a8 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 15:06:38.1110 (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: tdSJHwvkNp7JW+y5yzyQSL/dHQRaAhNV4jS5zpcH35bnezKZK10Sdq+elpQBImBC X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9213 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 4/26/2023 10:37 PM, 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. > './devtools/check-git-log.sh' is giving some warnings, can you please check them? Contribution guide documentation may help to fix reported issues: https://doc.dpdk.org/guides/contributing/patches.html#commit-messages-subject-line > Depends-on: series-27687 > > 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 | 49 ++++++++++++++++++++++- > drivers/net/gve/base/gve_osdep.h | 36 +++++++++++++++++ > drivers/net/gve/gve_ethdev.c | 65 +++++++++++++++++++++++++------ > drivers/net/gve/gve_ethdev.h | 2 +- > drivers/net/gve/gve_version.c | 14 +++++++ > drivers/net/gve/gve_version.h | 25 ++++++++++++ > drivers/net/gve/meson.build | 1 + > 9 files changed, 198 insertions(+), 16 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 2dc4507acb..89f9654a72 100644 > --- a/drivers/net/gve/base/gve.h > +++ b/drivers/net/gve/base/gve.h > @@ -8,9 +8,6 @@ > > #include "gve_desc.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 e745b709b2..2e5099a5b0 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..edac32f031 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,47 @@ 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_CAP2(a) BIT(((int)a) - 64) > +#define GVE_CAP3(a) BIT(((int)a) - 128) > +#define GVE_CAP3(a) BIT(((int)a) - 192) GVE_CAP2, GVE_CAP3 & GVE_CAP4 seems not used, do we need to add them now? And I guess '(((int)a) - 64)' usage is to unset some bits, will it be better to '(a & ~(1 << 6))' ? > + > +#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); > + It looks like we need a static assert helper for DPDK, I will try to send something. > > struct gve_adminq_configure_device_resources { > __be64 counter_array; > @@ -345,6 +387,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 +422,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 7cb73002f4..a5efa8543e 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; > @@ -69,6 +74,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 > @@ -79,6 +90,12 @@ typedef rte_iova_t dma_addr_t; > #define GVE_CHECK_UNION_LEN(n, X) enum gve_static_asset_enum_##X \ > { gve_static_assert_##X = (n) / ((sizeof(union X) == (n)) ? 1 : 0) } > > +#ifndef LINUX_VERSION_MAJOR > +#define LINUX_VERSION_MAJOR (((LINUX_VERSION_CODE) >> 16) & 0xff) > +#define LINUX_VERSION_SUBLEVEL (((LINUX_VERSION_CODE) >> 8) & 0xff) > +#define LINUX_VERSION_PATCHLEVEL ((LINUX_VERSION_CODE) & 0xff) > +#endif > + Do we need Linux version macros in DPDK? They are not used at all. > static __rte_always_inline u8 > readb(volatile void *addr) > { > @@ -156,4 +173,23 @@ gve_free_dma_mem(struct gve_dma_mem *mem) > mem->pa = 0; > } > > +static inline void > +populate_driver_version_strings(struct os_version_string *os_version_str) > +{ > +#ifdef __linux__ > + struct utsname uts; > + if (uname(&uts) >= 0) { > + /* release */ > + rte_strscpy(os_version_str->os_version_str1, uts.release, > + sizeof(os_version_str->os_version_str1)); > + /* version */ > + rte_strscpy(os_version_str->os_version_str2, uts.version, > + sizeof(os_version_str->os_version_str2)); > + } Since OS type is reported as DPDK, do we need underlying Linux release information to the FW? If not we can remove #ifdef and 'uname()' to reduce platform specific code. > +#else > + /* gVNIC is currently not supported on OS like FreeBSD */ meson file only disable for Windows, for FreeBSD driver is compiled. If driver is only supported on Linux, can you change the meson file to reflec this? > + RTE_SET_USED(os_version_str); > +#endif > +} > + > #endif /* _GVE_OSDEP_H_ */ > diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c > index cf28a4a3b7..1d6e134fff 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++; > @@ -265,6 +257,52 @@ gve_dev_close(struct rte_eth_dev *dev) > return err; > } > > +static int > +gve_verify_driver_compatibility(struct gve_priv *priv) > +{ > + const struct rte_memzone *driver_info_bus; What does '_bus' indicates in the variable name? > + struct gve_driver_info *driver_info; > + int err; > + > + driver_info_bus = rte_memzone_reserve_aligned("verify_driver_compatibility", > + sizeof(struct gve_driver_info), > + rte_socket_id(), > + RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE); There is no benefit to use DPDK memory APIs for this usage, a 'malloc()' will do the work, and maybe better as compilers/static analyzers recognizes it more. > + if (driver_info_bus == NULL) { > + PMD_DRV_LOG(ERR, > + "Could not alloc memzone for driver compatibility"); > + return -ENOMEM; > + } > + driver_info = (struct gve_driver_info *)driver_info_bus->addr; > + *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((struct os_version_string *)&driver_info->os_version_str1); > + If you pass two strings as parameter to 'populate_driver_version_strings()' can you get rid of interim type "struct os_version_string" and above casting? > + err = gve_adminq_verify_driver_compatibility(priv, > + sizeof(struct gve_driver_info), (dma_addr_t)driver_info_bus); > + > + /* It's ok if the device doesn't support this */ > + if (err == -EOPNOTSUPP) > + err = 0; Is this error saying DPDK version is not supported? Where a change should go to be able to identify and verify DPDK platform in GVE? Does it require continious update as DPDK get updated? > + > + rte_memzone_free(driver_info_bus); > + return err; > +} > + > static int > gve_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) > { > @@ -672,6 +710,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 42a02cf5d4..23ccff37d3 100644 > --- a/drivers/net/gve/gve_ethdev.h > +++ b/drivers/net/gve/gve_ethdev.h > @@ -222,7 +222,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..7eaa689d90 > --- /dev/null > +++ b/drivers/net/gve/gve_version.c > @@ -0,0 +1,14 @@ > +/* SPDX-License-Identifier: MIT > + * Google Virtual Ethernet (gve) driver > + * Copyright (C) 2015-2023 Google, Inc. > + */ This is not base code, but DPDK layer, license should be BSD-3. > +#include "gve_version.h" > + > +const char *gve_version_string(void) > +{ > + static char gve_version[10]; > + 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..9af6a00568 > --- /dev/null > +++ b/drivers/net/gve/gve_version.h > @@ -0,0 +1,25 @@ > +/* SPDX-License-Identifier: MIT > + * Google Virtual Ethernet (gve) driver > + * Copyright (C) 2015-2023 Google, Inc. > + */ > + This is not base code, but DPDK layer, license should be BSD-3. > +#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 > + Is this GVE base version, or DPDK gve version? Previous version information was "GVE-1.3.0", now it is becoming "DPDK-1.0.0", is this breaking the version link with GVE base version and creating a new versioning scheme for DPDK GVE driver? Btw, documentation still has "v1.3.0. GVE base code", should it be updated as well? > +#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 > + RTE_VER_RELEASE is 1 (-rc1), 2 (-rc2), etc... And if it is not release candidate it is always 99, so it may not be very usefull for the official releases and changes frequently for the development tree, are you sure to use this value? > + > +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 af0010c01c..a37c4bafa2 100644 > --- a/drivers/net/gve/meson.build > +++ b/drivers/net/gve/meson.build > @@ -12,5 +12,6 @@ sources = files( > 'gve_rx.c', > 'gve_tx.c', > 'gve_ethdev.c', > + 'gve_version.c', > ) > includes += include_directories('base')