Skip to contentSkip to conversation

gve: unify driver name usage

PATCH Superseded Junfeng Guo 7 participants 12 messages Jul 7, 2023 – Jul 12, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gve: unify driver name usage

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")
---
 drivers/net/ethernet/google/gve/gve.h         |  1 +
 drivers/net/ethernet/google/gve/gve_adminq.c  | 10 +++++-----
 drivers/net/ethernet/google/gve/gve_ethtool.c |  2 +-
 drivers/net/ethernet/google/gve/gve_main.c    | 11 ++++++-----
 4 files changed, 13 insertions(+), 11 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -0
index 98eb78d98e9f..4b425bf71ede 100644
@@ -964,5 +964,6 @@ void gve_handle_report_stats(struct gve_priv *priv);
 /* exported by ethtool.c */
 extern const struct ethtool_ops gve_ethtool_ops;
 /* needed by ethtool */
+extern char gve_driver_name[];
 extern const char gve_version_str[];
 #endif /* _GVE_H_ */
drivers/net/ethernet/google/gve/gve_adminq.c +5 -5
index 252974202a3f..ae8f8c935bbe 100644
@@ -899,7 +899,7 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 
 int gve_adminq_report_link_speed(struct gve_priv *priv)
 {
-	union gve_adminq_command gvnic_cmd;
+	union gve_adminq_command gve_cmd;
 	dma_addr_t link_speed_region_bus;
 	__be64 *link_speed_region;
 	int err;
@@ -911,12 +911,12 @@ int gve_adminq_report_link_speed(struct gve_priv *priv)
 	if (!link_speed_region)
 		return -ENOMEM;
 
-	memset(&gvnic_cmd, 0, sizeof(gvnic_cmd));
-	gvnic_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);
-	gvnic_cmd.report_link_speed.link_speed_address =
+	memset(&gve_cmd, 0, sizeof(gve_cmd));
+	gve_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);
+	gve_cmd.report_link_speed.link_speed_address =
 		cpu_to_be64(link_speed_region_bus);
 
-	err = gve_adminq_execute_cmd(priv, &gvnic_cmd);
+	err = gve_adminq_execute_cmd(priv, &gve_cmd);
 
 	priv->link_speed = be64_to_cpu(*link_speed_region);
 	dma_free_coherent(&priv->pdev->dev, sizeof(*link_speed_region), link_speed_region,
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -1
index 50162ec9424d..233e5946905e 100644
@@ -15,7 +15,7 @@ static void gve_get_drvinfo(struct net_device *netdev,
 {
 	struct gve_priv *priv = netdev_priv(netdev);
 
-	strscpy(info->driver, "gve", sizeof(info->driver));
+	strscpy(info->driver, gve_driver_name, sizeof(info->driver));
 	strscpy(info->version, gve_version_str, sizeof(info->version));
 	strscpy(info->bus_info, pci_name(priv->pdev), sizeof(info->bus_info));
 }
drivers/net/ethernet/google/gve/gve_main.c +6 -5
index 8fb70db63b8b..e6f1711d9be0 100644
@@ -33,6 +33,7 @@
 #define MIN_TX_TIMEOUT_GAP (1000 * 10)
 #define DQO_TX_MAX	0x3FFFF
 
+char gve_driver_name[] = "gve";
 const char gve_version_str[] = GVE_VERSION;
 static const char gve_version_prefix[] = GVE_VERSION_PREFIX;
 
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);
 	if (err)
 		goto abort_with_enabled;
 
@@ -2393,8 +2394,8 @@ static const struct pci_device_id gve_id_table[] = {
 	{ }
 };
 
-static struct pci_driver gvnic_driver = {
-	.name		= "gvnic",
+static struct pci_driver gve_driver = {
+	.name		= gve_driver_name,
 	.id_table	= gve_id_table,
 	.probe		= gve_probe,
 	.remove		= gve_remove,
@@ -2405,10 +2406,10 @@ static struct pci_driver gvnic_driver = {
 #endif
 };
 
-module_pci_driver(gvnic_driver);
+module_pci_driver(gve_driver);
 
 MODULE_DEVICE_TABLE(pci, gve_id_table);
 MODULE_AUTHOR("Google, Inc.");
-MODULE_DESCRIPTION("gVNIC Driver");
+MODULE_DESCRIPTION("Google Virtual NIC Driver");
 MODULE_LICENSE("Dual MIT/GPL");
 MODULE_VERSION(GVE_VERSION);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Junfeng Guo

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")

---

The patch makes the driver strings much more consistent. Looks good to me.

Thanks,

#2 lore raw
Quoted 27 lines

-----Original Message-----
From: Kubiak, Michal <[email protected]>
Sent: Saturday, July 8, 2023 02:27
To: Guo, Junfeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

Quoted 7 lines · Junfeng Guo

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute

Engine Virtual NIC")

Quoted 4 lines

---

Quoted 5 lines

The patch makes the driver strings much more consistent. Looks good to me.

Thanks,

Thanks for the review!

maintainer
#3 lore raw
In reply to Junfeng Guo
Quoted 9 lines · On Fri, 7 Jul 2023 18:37:10 +0800 Junfeng Guo wrote:

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")

Google's maintainers definitely need to agree to this, because it's a user visible change. It can very well break someone's scripts.

Quoted 28 lines
drivers/net/ethernet/google/gve/gve.h +1 -0
index 98eb78d98e9f..4b425bf71ede 100644
@@ -964,5 +964,6 @@ void gve_handle_report_stats(struct gve_priv *priv);
 /* exported by ethtool.c */
 extern const struct ethtool_ops gve_ethtool_ops;
 /* needed by ethtool */
+extern char gve_driver_name[];
 extern const char gve_version_str[];
 #endif /* _GVE_H_ */
drivers/net/ethernet/google/gve/gve_adminq.c +1 -1
index 252974202a3f..ae8f8c935bbe 100644
@@ -899,7 +899,7 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 
 int gve_adminq_report_link_speed(struct gve_priv *priv)
 {
-	union gve_adminq_command gvnic_cmd;
+	union gve_adminq_command gve_cmd;
 	dma_addr_t link_speed_region_bus;
 	__be64 *link_speed_region;
 	int err;
@@ -911,12 +911,12 @@ int gve_adminq_report_link_speed(struct gve_priv *priv)
 	if (!link_speed_region)
 		return -ENOMEM;
 

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_report_link_speed(struct gve_priv *priv) · line 919

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_adminq.c +4 -4
-	memset(&gvnic_cmd, 0, sizeof(gvnic_cmd));
-	gvnic_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);
-	gvnic_cmd.report_link_speed.link_speed_address =
+	memset(&gve_cmd, 0, sizeof(gve_cmd));
+	gve_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);
+	gve_cmd.report_link_speed.link_speed_address =
 		cpu_to_be64(link_speed_region_bus);
 
-	err = gve_adminq_execute_cmd(priv, &gvnic_cmd);
+	err = gve_adminq_execute_cmd(priv, &gve_cmd);

What's the problem with the variable being called gvnic_cmd ? Please limit renames, if you want this to be a fix.

Signature · 1 line
pw-bot: cr
#4 lore raw
Quoted 20 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Saturday, July 8, 2023 06:20
To: Guo, Junfeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

Quoted 6 lines · On Fri, 7 Jul 2023 18:37:10 +0800 Junfeng Guo wrote:

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Quoted 7 lines
Quoted 1 line
Fixes 893ce44df565 ("gve: Add basic driver framework for Compute

Engine Virtual NIC")

Quoted 2 lines

Google's maintainers definitely need to agree to this, because it's a user visible change. It can very well break someone's scripts.

Sure, exactly!
Google's maintainers are also CC'ed to give decisive comments for this.

This patch is to align the inconsistencies for the driver name and the kernel module name, which may also help improve some scripts to avoid using exception mapping with two different names.

Quoted 41 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/net/ethernet/google/gve/gve.h

drivers/net/ethernet/google/gve/gve.h void gve_handle_report_stats(struct gve_priv

Quoted 4 lines

index 98eb78d98e9f..4b425bf71ede 100644

drivers/net/ethernet/google/gve/gve.h +0 -0
@@ -964,5 +964,6 @@ void gve_handle_report_stats(struct gve_priv

*priv);

Review

Quoted 7 lines
drivers/net/ethernet/google/gve/gve.h +1 -0
 /* exported by ethtool.c */
 extern const struct ethtool_ops gve_ethtool_ops;
 /* needed by ethtool */
+extern char gve_driver_name[];
 extern const char gve_version_str[];
 #endif /* _GVE_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/google/gve/gve_adminq.c

drivers/net/ethernet/google/gve/gve_adminq.c int

Quoted 4 lines

index 252974202a3f..ae8f8c935bbe 100644

drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
@@ -899,7 +899,7 @@ int

gve_adminq_verify_driver_compatibility(struct gve_priv *priv,

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_report_link_speed(struct

Quoted 9 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -1
 int gve_adminq_report_link_speed(struct gve_priv *priv)
 {
-	union gve_adminq_command gvnic_cmd;
+	union gve_adminq_command gve_cmd;
 	dma_addr_t link_speed_region_bus;
 	__be64 *link_speed_region;
 	int err;
@@ -911,12 +911,12 @@ int gve_adminq_report_link_speed(struct

gve_priv *priv)

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_report_link_speed(struct gve_priv *priv)

Quoted 5 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -2
 	if (!link_speed_region)
 		return -ENOMEM;
 
-	memset(&gvnic_cmd, 0, sizeof(gvnic_cmd));
-	gvnic_cmd.opcode =

cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_report_link_speed(struct gve_priv *priv)

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_adminq.c +2 -1
-	gvnic_cmd.report_link_speed.link_speed_address =
+	memset(&gve_cmd, 0, sizeof(gve_cmd));
+	gve_cmd.opcode =

cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);

Quoted 8 lines

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_report_link_speed(struct gve_priv *priv) · line 919

Quoted 5 lines
drivers/net/ethernet/google/gve/gve_adminq.c +2 -1
+	gve_cmd.report_link_speed.link_speed_address =
 		cpu_to_be64(link_speed_region_bus);
 
-	err = gve_adminq_execute_cmd(priv, &gvnic_cmd);
+	err = gve_adminq_execute_cmd(priv, &gve_cmd);

What's the problem with the variable being called gvnic_cmd ? Please limit renames, if you want this to be a fix.

Thanks for the comments!
Yes, this is not very related to the fixing purpose. Will remove this part in the coming version. Thanks!

Quoted 2 lines

--
pw-bot: cr

#5 lore raw

PATCH v2 1/1 gve: unify driver name usage

In reply to Junfeng Guo

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")

---
v2:
- Remove un-related variable name chang, just keep it as it is.

---
 drivers/net/ethernet/google/gve/gve.h         |  1 +
 drivers/net/ethernet/google/gve/gve_ethtool.c |  2 +-
 drivers/net/ethernet/google/gve/gve_main.c    | 11 ++++++-----
 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -0
index 98eb78d98e9f..4b425bf71ede 100644
@@ -964,5 +964,6 @@ void gve_handle_report_stats(struct gve_priv *priv);
 /* exported by ethtool.c */
 extern const struct ethtool_ops gve_ethtool_ops;
 /* needed by ethtool */
+extern char gve_driver_name[];
 extern const char gve_version_str[];
 #endif /* _GVE_H_ */
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -1
index 50162ec9424d..233e5946905e 100644
@@ -15,7 +15,7 @@ static void gve_get_drvinfo(struct net_device *netdev,
 {
 	struct gve_priv *priv = netdev_priv(netdev);
 
-	strscpy(info->driver, "gve", sizeof(info->driver));
+	strscpy(info->driver, gve_driver_name, sizeof(info->driver));
 	strscpy(info->version, gve_version_str, sizeof(info->version));
 	strscpy(info->bus_info, pci_name(priv->pdev), sizeof(info->bus_info));
 }
drivers/net/ethernet/google/gve/gve_main.c +6 -5
index 8fb70db63b8b..e6f1711d9be0 100644
@@ -33,6 +33,7 @@
 #define MIN_TX_TIMEOUT_GAP (1000 * 10)
 #define DQO_TX_MAX	0x3FFFF
 
+char gve_driver_name[] = "gve";
 const char gve_version_str[] = GVE_VERSION;
 static const char gve_version_prefix[] = GVE_VERSION_PREFIX;
 
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);
 	if (err)
 		goto abort_with_enabled;
 
@@ -2393,8 +2394,8 @@ static const struct pci_device_id gve_id_table[] = {
 	{ }
 };
 
-static struct pci_driver gvnic_driver = {
-	.name		= "gvnic",
+static struct pci_driver gve_driver = {
+	.name		= gve_driver_name,
 	.id_table	= gve_id_table,
 	.probe		= gve_probe,
 	.remove		= gve_remove,
@@ -2405,10 +2406,10 @@ static struct pci_driver gvnic_driver = {
 #endif
 };
 
-module_pci_driver(gvnic_driver);
+module_pci_driver(gve_driver);
 
 MODULE_DEVICE_TABLE(pci, gve_id_table);
 MODULE_AUTHOR("Google, Inc.");
-MODULE_DESCRIPTION("gVNIC Driver");
+MODULE_DESCRIPTION("Google Virtual NIC Driver");
 MODULE_LICENSE("Dual MIT/GPL");
 MODULE_VERSION(GVE_VERSION);
Signature · 1 line
2.25.1
#6 lore raw
Quoted 7 lines · Junfeng Guo

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")

You are posting this for net, and have a fixes tag. Please take a look at:

https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Do you think it fulfils those rules?

Andrew

#7 lore raw
In reply to Junfeng Guo
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 11 lines · On Sat, 8 Jul 2023 11:14:51 +0800 you wrote:

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

Fixes 893ce44df565 ("gve: Add basic driver framework for Compute Engine Virtual NIC")

[...]

Here is the summary with links:
- [net,v2] gve: unify driver name usage

    https://git.kernel.org/netdev/net/c/9d0aba98316d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#8 lore raw
In reply to Junfeng Guo

From: Junfeng Guo <[email protected]>
Date: Fri, 7 Jul 2023 18:37:10 +0800

Quoted 5 lines

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

[...]

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2204

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);

I won't repeat others' comments, but will comment on this. Passing just driver name with no unique identifiers makes it very confusing to read /proc/iomem et al.
Imagine you have 2 NICs in your system. Then, in /proc/iomem you will have:

gve 0x00001000-0x00002000
gve 0x00004000-0x00005000

Can you say which region belongs to which NIC? Nope.
If you really want to make this more "user friendly", you should make it possible for users to distinguish different NICs in your system. The easiest way:

	err = pci_request_regions(pdev, pci_name(pdev));

But you're not limited to this. Just make it unique.

(as a net-next commit obv)

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2207

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
 	if (err)
 		goto abort_with_enabled;
 

[...]

Thanks,
Olek

#9 lore raw
Quoted 32 lines

-----Original Message-----
From: Lobakin, Aleksander <[email protected]>
Sent: Tuesday, July 11, 2023 21:14
To: Guo, Junfeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

From: Junfeng Guo <[email protected]>
Date: Fri, 7 Jul 2023 18:37:10 +0800

Quoted 5 lines

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

[...]

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2204

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);

I won't repeat others' comments, but will comment on this. Passing just driver name with no unique identifiers makes it very confusing to read /proc/iomem et al.
Imagine you have 2 NICs in your system. Then, in /proc/iomem you will have:

Quoted 3 lines

gve 0x00001000-0x00002000
gve 0x00004000-0x00005000

Looks like, in real world, it is PCI BAR tree layers, take Intel ice as an example:

err = pcim_iomap_regions(pdev, BIT(ICE_BAR0), dev_driver_string(dev));

3b4000000000-3b7fffffffff : PCI Bus 0000:b7
3b7ffa000000-3b7ffe4fffff : PCI Bus 0000:b8

    3b7ffa000000-3b7ffbffffff : 0000:b8:00.0   <--- Different NIC, has different BDF
      3b7ffa000000-3b7ffbffffff : ice          <--- The region name is driver name.
    3b7ffc000000-3b7ffdffffff : 0000:b8:00.0
    3b7ffe000000-3b7ffe00ffff : 0000:b8:00.0
    3b7ffe010000-3b7ffe40ffff : 0000:b8:00.0

google/gve/gve_main.c:2203: err = pci_request_regions(pdev, "gvnic-cfg");
hisilicon/hns3/hns3pf/hclge_main.c:11350: ret = pci_request_regions(pdev, HCLGE_DRIVER_NAME);
hisilicon/hns3/hns3vf/hclgevf_main.c:2588: ret = pci_request_regions(pdev, HCLGEVF_DRIVER_NAME);
huawei/hinic/hinic_main.c:1362: err = pci_request_regions(pdev, HINIC_DRV_NAME);
intel/ixgbevf/ixgbevf_main.c:4544: err = pci_request_regions(pdev, ixgbevf_driver_name);
intel/ixgbevf/ixgbevf_main.c:4546: dev_err(&pdev->dev, "pci_request_regions failed 0x%x\n", err);
intel/e100.c:2865: if ((err = pci_request_regions(pdev, DRV_NAME))) {
intel/igbvf/netdev.c:2732: err = pci_request_regions(pdev, igbvf_driver_name);
intel/iavf/iavf_main.c:4849: err = pci_request_regions(pdev, iavf_driver_name);
intel/iavf/iavf_main.c:4852: "pci_request_regions failed 0x%x\n", err);
jme.c:2939: rc = pci_request_regions(pdev, DRV_NAME);

marvell/octeontx2/nic/otx2_pf.c:2793:   err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/nic/otx2_vf.c:534:    err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/mcs.c:1516:        err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/rvu.c:3238:        err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/cgx.c:1831:        err = pci_request_regions(pdev, DRV_NAME);
Quoted 18 lines

Can you say which region belongs to which NIC? Nope.
If you really want to make this more "user friendly", you should make it possible for users to distinguish different NICs in your system. The easiest way:

	err = pci_request_regions(pdev, pci_name(pdev));

But you're not limited to this. Just make it unique.

(as a net-next commit obv)

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2207

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
 	if (err)
 		goto abort_with_enabled;
 

[...]

Thanks,
Olek

#10 lore raw

From: Wang, Haiyue <[email protected]>
Date: Tue, 11 Jul 2023 19:24:36 +0200

Quoted 36 lines
Quoted 32 lines

-----Original Message-----
From: Lobakin, Aleksander <[email protected]>
Sent: Tuesday, July 11, 2023 21:14
To: Guo, Junfeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

From: Junfeng Guo <[email protected]>
Date: Fri, 7 Jul 2023 18:37:10 +0800

Quoted 5 lines

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

[...]

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2204

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);

I won't repeat others' comments, but will comment on this. Passing just driver name with no unique identifiers makes it very confusing to read /proc/iomem et al.
Imagine you have 2 NICs in your system. Then, in /proc/iomem you will have:

Quoted 3 lines

gve 0x00001000-0x00002000
gve 0x00004000-0x00005000

Quoted 8 lines

Looks like, in real world, it is PCI BAR tree layers, take Intel ice as an example:

err = pcim_iomap_regions(pdev, BIT(ICE_BAR0), dev_driver_string(dev));

3b4000000000-3b7fffffffff : PCI Bus 0000:b7
3b7ffa000000-3b7ffe4fffff : PCI Bus 0000:b8
3b7ffa000000-3b7ffbffffff : 0000:b8:00.0 <--- Different NIC, has different BDF
3b7ffa000000-3b7ffbffffff : ice <--- The region name is driver name.

I didn't say Intel drivers do that better ¯\_(ツ)_/¯

Why rely on that the kernel or something else will beautify the output for you or that the user won't do grep <drvname> /proc/iomem or something else? Or do that just because "look, it's done the same way in other drivers", which were taken into the tree years ago and sometimes with no detailed review?
There are efforts[0] time to time[1] to convert precisely what you are doing into what I'm asking for. Do they exist by mistake or...?

(the second link also shows that even pci_name() is not enough when you
map several BARs of the same device, but that's not the case this time)

Quoted 15 lines
    3b7ffc000000-3b7ffdffffff : 0000:b8:00.0
    3b7ffe000000-3b7ffe00ffff : 0000:b8:00.0
    3b7ffe010000-3b7ffe40ffff : 0000:b8:00.0

google/gve/gve_main.c:2203: err = pci_request_regions(pdev, "gvnic-cfg");
hisilicon/hns3/hns3pf/hclge_main.c:11350: ret = pci_request_regions(pdev, HCLGE_DRIVER_NAME);
hisilicon/hns3/hns3vf/hclgevf_main.c:2588: ret = pci_request_regions(pdev, HCLGEVF_DRIVER_NAME);
huawei/hinic/hinic_main.c:1362: err = pci_request_regions(pdev, HINIC_DRV_NAME);
intel/ixgbevf/ixgbevf_main.c:4544: err = pci_request_regions(pdev, ixgbevf_driver_name);
intel/ixgbevf/ixgbevf_main.c:4546: dev_err(&pdev->dev, "pci_request_regions failed 0x%x\n", err);
intel/e100.c:2865: if ((err = pci_request_regions(pdev, DRV_NAME))) {
intel/igbvf/netdev.c:2732: err = pci_request_regions(pdev, igbvf_driver_name);
intel/iavf/iavf_main.c:4849: err = pci_request_regions(pdev, iavf_driver_name);
intel/iavf/iavf_main.c:4852: "pci_request_regions failed 0x%x\n", err);
jme.c:2939: rc = pci_request_regions(pdev, DRV_NAME);

Quoted 25 lines
marvell/octeontx2/nic/otx2_pf.c:2793:   err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/nic/otx2_vf.c:534:    err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/mcs.c:1516:        err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/rvu.c:3238:        err = pci_request_regions(pdev, DRV_NAME);
marvell/octeontx2/af/cgx.c:1831:        err = pci_request_regions(pdev, DRV_NAME);
Quoted 18 lines

Can you say which region belongs to which NIC? Nope.
If you really want to make this more "user friendly", you should make it possible for users to distinguish different NICs in your system. The easiest way:

	err = pci_request_regions(pdev, pci_name(pdev));

But you're not limited to this. Just make it unique.

(as a net-next commit obv)

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2207

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
 	if (err)
 		goto abort_with_enabled;
 

[...]

Thanks,
Olek

[0]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0af6e21eed2778e68139941389460e2a00d6ef8e
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=35bd8c07db2ce8fd2834ef866240613a4ef982e7

Thanks,
Olek

#11 lore raw
Quoted 75 lines

-----Original Message-----
From: Lobakin, Aleksander <[email protected]>
Sent: Thursday, July 13, 2023 00:55
To: Wang, Haiyue <[email protected]>
Cc: Guo, Junfeng <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

From: Wang, Haiyue <[email protected]>
Date: Tue, 11 Jul 2023 19:24:36 +0200

Quoted 36 lines
Quoted 32 lines

-----Original Message-----
From: Lobakin, Aleksander <[email protected]>
Sent: Tuesday, July 11, 2023 21:14
To: Guo, Junfeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] gve: unify driver name usage

From: Junfeng Guo <[email protected]>
Date: Fri, 7 Jul 2023 18:37:10 +0800

Quoted 5 lines

Current codebase contained the usage of two different names for this driver (i.e., gvnic and gve), which is quite unfriendly for users to use, especially when trying to bind or unbind the driver manually. The corresponding kernel module is registered with the name of gve. It's more reasonable to align the name of the driver with the module.

[...]

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2204

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -2200,7 +2201,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	err = pci_request_regions(pdev, "gvnic-cfg");
+	err = pci_request_regions(pdev, gve_driver_name);

I won't repeat others' comments, but will comment on this. Passing just driver name with no unique identifiers makes it very confusing to read /proc/iomem et al.
Imagine you have 2 NICs in your system. Then, in /proc/iomem you will have:

Quoted 3 lines

gve 0x00001000-0x00002000
gve 0x00004000-0x00005000

Quoted 8 lines

Looks like, in real world, it is PCI BAR tree layers, take Intel ice as an example:

err = pcim_iomap_regions(pdev, BIT(ICE_BAR0), dev_driver_string(dev));

3b4000000000-3b7fffffffff : PCI Bus 0000:b7
3b7ffa000000-3b7ffe4fffff : PCI Bus 0000:b8
3b7ffa000000-3b7ffbffffff : 0000:b8:00.0 <--- Different NIC, has different BDF
3b7ffa000000-3b7ffbffffff : ice <--- The region name is driver name.

I didn't say Intel drivers do that better ¯\_(ツ)_/¯

Why rely on that the kernel or something else will beautify the output for you or that the user won't do grep <drvname> /proc/iomem or something else? Or do that just because "look, it's done the same way in other drivers", which were taken into the tree years ago and sometimes with no detailed review?
There are efforts[0] time to time[1] to convert precisely what you are doing into what I'm asking for. Do they exist by mistake or...?

(the second link also shows that even pci_name() is not enough when you
map several BARs of the same device, but that's not the case this time)

Quoted 3 lines
Quoted 3 lines

Thanks,
Olek

Quoted 6 lines

[0]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-
next.git/commit/?id=0af6e21eed2778e68139941389460e2a00d6ef8e
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-
next.git/commit/?id=35bd8c07db2ce8fd2834ef866240613a4ef982e7

I see, yes, making sense to beautify the output, and is nice for 'grep ..' to debug quickly, thanks for sharing more experience. :-)

Quoted 2 lines

Thanks,
Olek