Skip to contentSkip to conversation

Add Mellanox BlueField Gigabit Ethernet driver

PATCH Superseded David Thompson 2 participants 6 messages Mar 10, 2021 – Mar 18, 2021

Subsystems (2)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Add Mellanox BlueField Gigabit Ethernet driver

This patch adds build and driver logic for the "mlxbf_gige" Ethernet driver from Mellanox Technologies. The second generation BlueField SoC from Mellanox supports an out-of-band GigaBit Ethernet management port to the Arm subsystem. This driver supports TCP/IP network connectivity for that port, and provides back-end routines to handle basic ethtool requests.

The driver interfaces to the Gigabit Ethernet block of BlueField SoC via MMIO accesses to registers, which contain control information or pointers describing transmit and receive resources. There is a single transmit queue, and the port supports transmit ring sizes of 4 to 256 entries. There is a single receive queue, and the port supports receive ring sizes of 32 to 32K entries. The transmit and receive rings are allocated from DMA coherent memory. There is a 16-bit producer and consumer index per ring to denote software ownership and hardware ownership, respectively.

The main driver logic such as probe(), remove(), and netdev ops are in "mlxbf_gige_main.c". Logic in "mlxbf_gige_rx.c" and "mlxbf_gige_tx.c" handles the packet processing for receive and transmit respectively.

The logic in "mlxbf_gige_ethtool.c" supports the handling of some basic ethtool requests: get driver info, get ring parameters, get registers, and get statistics.

The logic in "mlxbf_gige_mdio.c" is the driver controlling the Mellanox BlueField hardware that interacts with a PHY device via MDIO/MDC pins. This driver does the following:
- At driver probe time, it configures several BlueField MDIO parameters such as sample rate, full drive, voltage and MDC
- It defines functions to read and write MDIO registers and registers the MDIO bus.
- It defines the phy interrupt handler reporting a link up/down status change
- This driver's probe is invoked from the main driver logic while the phy interrupt handler is registered in ndo_open.

Driver limitations
- Only supports 1Gbps speed
- Only supports GMII protocol
- Supports maximum packet size of 2KB
- Does not support scatter-gather buffering

Testing
- Successful build of kernel for ARM64, ARM32, X86_64
- Tested ARM64 build on FastModels & Palladium
- Tested ARM64 build on several Mellanox boards that are built with the BlueField-2 SoC. The testing includes coverage in the areas of networking (e.g. ping, iperf, ifconfig, route), file transfers (e.g. SCP), and various ethtool options relevant to this driver.

v3 -> v4
Main driver module broken out into rx, tx, intr, and ethtool modules Removed some GPIO PHY interrupt logic; moved to GPIO_MLXBF2 driver
v2 -> v3
Added logic to handle PHY link up/down interrupts
Use streaming DMA mapping for packet buffers
Changed logic to use standard iopoll methods
Changed PHY logic to not allow C45 transactions
Enhanced the error handling in open() method
Enhanced start_xmit() method to use xmit_more mechanism Added support for ndo_get_stats64
Removed standard stats from "ethtool -S" output
v1 -> v2:
Fixed all warnings raised by "make C=1" and "make W=1"
a) Changed logic in mlxbf_gige_rx_deinit() and mlxbf_gige_tx_deinit() to initialize relevant pointers as NULL, not 0
b) Change mlxbf_gige_get_mac_rx_filter() to return void, as this function's return status is not used by caller
c) Fixed type definition of "buff" in mlxbf_gige_get_regs()

---
 drivers/net/ethernet/mellanox/Kconfig              |   1 +
 drivers/net/ethernet/mellanox/Makefile             |   1 +
 drivers/net/ethernet/mellanox/mlxbf_gige/Kconfig   |  13 +
 drivers/net/ethernet/mellanox/mlxbf_gige/Makefile  |   7 +
 .../net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h  | 182 +++++++++
 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c       | 140 +++++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_intr.c | 143 +++++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 454 +++++++++++++++++++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 187 +++++++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h |  78 ++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c   | 299 ++++++++++++++
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c   | 279 +++++++++++++
 12 files changed, 1784 insertions(+)
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/Kconfig
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/Makefile
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_intr.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c
drivers/net/ethernet/mellanox/Kconfig +1 -0
index ff6613a..b4f66eb 100644
@@ -22,5 +22,6 @@ source "drivers/net/ethernet/mellanox/mlx4/Kconfig"
 source "drivers/net/ethernet/mellanox/mlx5/core/Kconfig"
 source "drivers/net/ethernet/mellanox/mlxsw/Kconfig"
 source "drivers/net/ethernet/mellanox/mlxfw/Kconfig"
+source "drivers/net/ethernet/mellanox/mlxbf_gige/Kconfig"
 
 endif # NET_VENDOR_MELLANOX
drivers/net/ethernet/mellanox/Makefile +1 -0
index 79773ac..d4b5f54 100644
@@ -7,3 +7,4 @@ obj-$(CONFIG_MLX4_CORE) += mlx4/
 obj-$(CONFIG_MLX5_CORE) += mlx5/core/
 obj-$(CONFIG_MLXSW_CORE) += mlxsw/
 obj-$(CONFIG_MLXFW) += mlxfw/
+obj-$(CONFIG_MLXBF_GIGE) += mlxbf_gige/
drivers/net/ethernet/mellanox/mlxbf_gige/Kconfig new file +13 -0
new file mode 100644
index 0000000..0338ba5
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
+#
+# Mellanox GigE driver configuration
+#
+
+config MLXBF_GIGE
+	tristate "Mellanox Technologies BlueField Gigabit Ethernet support"
+	depends on (ARM64 || COMPILE_TEST) && ACPI && GPIO_MLXBF2
+	select PHYLIB
+	help
+	  The second generation BlueField SoC from Mellanox Technologies
+	  supports an out-of-band Gigabit Ethernet management port to the
+	  Arm subsystem.
drivers/net/ethernet/mellanox/mlxbf_gige/Makefile new file +7 -0
new file mode 100644
index 0000000..6caae3c
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
+
+obj-$(CONFIG_MLXBF_GIGE) += mlxbf_gige.o
+
+mlxbf_gige-y := mlxbf_gige_ethtool.o mlxbf_gige_intr.o \
+		mlxbf_gige_main.o mlxbf_gige_mdio.o \
+		mlxbf_gige_rx.o mlxbf_gige_tx.o
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h new file +182 -0

182 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c new file +140 -0

140 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_intr.c new file +143 -0

143 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +454 -0

454 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c new file +187 -0

187 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h new file +78 -0

78 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c new file +299 -0

299 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c new file +279 -0

279 lines not on this page · raw message

Signature · 1 line
2.1.2
#1 lore raw
Quoted 25 lines
(quoted diff) +24 -0
+static void mlxbf_gige_get_pauseparam(struct net_device *netdev,
+				      struct ethtool_pauseparam *pause)
+{
+	struct mlxbf_gige *priv = netdev_priv(netdev);
+
+	pause->autoneg = priv->aneg_pause;
+	pause->rx_pause = priv->tx_pause;
+	pause->tx_pause = priv->rx_pause;
+}
 
+static int mlxbf_gige_probe(struct platform_device *pdev)
+{
+	err = phy_connect_direct(netdev, phydev,
+				 mlxbf_gige_adjust_link,
+				 PHY_INTERFACE_MODE_GMII);
+	if (err) {
+		dev_err(&pdev->dev, "Could not attach to PHY\n");
+		mlxbf_gige_mdio_remove(priv);
+		return err;
+	}
+
+	/* MAC only supports 1000T full duplex mode */
+	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
+	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Full_BIT);
+	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
+	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
+
+	/* MAC supports symmetric flow control */
+	phy_support_sym_pause(phydev);
+
+	/* Enable pause */
+	priv->rx_pause = phydev->pause;
+	priv->tx_pause = phydev->pause;
+	priv->aneg_pause = AUTONEG_ENABLE;

Hi David

I'm pretty sure mlxbf_gige_get_pauseparam() is broken.

This is the only code which sets priv->rx_pause, etc. And this is before the PHY has had time to do anything. auto-neg has not completed so you have no idea what has been negotiated for pause. mlxbf_gige_adjust_link() should be adjusting priv->??_pause once the link has been established.

Andrew

#2 lore raw
Quoted 53 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Thursday, March 11, 2021 8:57 PM
To: David Thompson <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Liming Sun <[email protected]>; Asmaa Mnebhi <[email protected]>
Subject: Re: [PATCH net-next v4] Add Mellanox BlueField Gigabit Ethernet driver

Quoted 11 lines
(quoted diff) +10 -0
+static void mlxbf_gige_get_pauseparam(struct net_device *netdev,
+				      struct ethtool_pauseparam *pause) {
+	struct mlxbf_gige *priv = netdev_priv(netdev);
+
+	pause->autoneg = priv->aneg_pause;
+	pause->rx_pause = priv->tx_pause;
+	pause->tx_pause = priv->rx_pause;
+}
 
+static int mlxbf_gige_probe(struct platform_device *pdev) {
+	err = phy_connect_direct(netdev, phydev,

Review

Quoted 10 lines
(quoted diff) +10 -0
+				 mlxbf_gige_adjust_link,
+				 PHY_INTERFACE_MODE_GMII);
+	if (err) {
+		dev_err(&pdev->dev, "Could not attach to PHY\n");
+		mlxbf_gige_mdio_remove(priv);
+		return err;
+	}
+
+	/* MAC only supports 1000T full duplex mode */
+	phy_remove_link_mode(phydev,

ETHTOOL_LINK_MODE_1000baseT_Half_BIT);

Review

Quoted 1 line
(quoted diff) +1 -0
+	phy_remove_link_mode(phydev,

ETHTOOL_LINK_MODE_100baseT_Full_BIT);

Review

Quoted 1 line
(quoted diff) +1 -0
+	phy_remove_link_mode(phydev,

ETHTOOL_LINK_MODE_100baseT_Half_BIT);

Review

Quoted 1 line
(quoted diff) +1 -0
+	phy_remove_link_mode(phydev,

ETHTOOL_LINK_MODE_10baseT_Full_BIT);

Review

Quoted 1 line
(quoted diff) +1 -0
+	phy_remove_link_mode(phydev,

ETHTOOL_LINK_MODE_10baseT_Half_BIT);

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 396

Quoted 8 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +8 -0
+
+	/* MAC supports symmetric flow control */
+	phy_support_sym_pause(phydev);
+
+	/* Enable pause */
+	priv->rx_pause = phydev->pause;
+	priv->tx_pause = phydev->pause;
+	priv->aneg_pause = AUTONEG_ENABLE;

Hi David

I'm pretty sure mlxbf_gige_get_pauseparam() is broken.

Quoted 7 lines

This is the only code which sets priv->rx_pause, etc. And this is before the PHY has had time to do anything. auto-neg has not completed so you have no idea what has been negotiated for pause.
mlxbf_gige_adjust_link() should be adjusting priv->??_pause once the link has been established.

Andrew

Yes, good point Andrew. I will modify mlxbf_gige_adjust_link() to set the private pause parameters after the "link up" event.

- Dave

#3 lore raw
In reply to David Thompson
Quoted 12 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +11 -0
+#define DRV_VERSION 1.19
 
+static int mlxbf_gige_probe(struct platform_device *pdev)
+{
+	unsigned int phy_int_gpio;
+	struct phy_device *phydev;
+	struct net_device *netdev;
+	struct resource *mac_res;
+	struct resource *llu_res;
+	struct resource *plu_res;
+	struct mlxbf_gige *priv;
+	void __iomem *llu_base;

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 272

Quoted 10 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +10 -0
+	void __iomem *plu_base;
+	void __iomem *base;
+	int addr, version;
+	u64 control;
+	int err = 0;
+
+	if (device_property_read_u32(&pdev->dev, "version", &version)) {
+		dev_err(&pdev->dev, "Version Info not found\n");
+		return -EINVAL;
+	}

Is this a device tree property? ACPI? If it is device tree property you need to document the binding, Documentation/devicetree/bindinds/...

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 278

Quoted 6 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +6 -0
+
+	if (version != (int)DRV_VERSION) {
+		dev_err(&pdev->dev, "Version Mismatch. Expected %d Returned %d\n",
+			(int)DRV_VERSION, version);
+		return -EINVAL;
+	}

That is odd. Doubt odd. First of, why (int)1.19? Why not just set DRV_VERSION to 1? This is the only place you use this, so the .19 seems pointless. Secondly, what does this version in DT/ACPI actually represent? The hardware version? Then you should be using a compatible string? Or read a hardware register which tells you have hardware version.

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 354

Quoted 4 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +4 -0
+
+	err = device_property_read_u32(&pdev->dev, "phy-int-gpio", &phy_int_gpio);
+	if (err < 0)
+		phy_int_gpio = MLXBF_GIGE_DEFAULT_PHY_INT_GPIO;

Again, this probably needs documenting. This is not how you do interrupts with DT. I also don't think it is correct for ACPI, but i don't know ACPI.

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 365

Quoted 5 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +5 -0
+	phydev = phy_find_first(priv->mdiobus);
+	if (!phydev) {
+		mlxbf_gige_mdio_remove(priv);
+		return -ENODEV;
+	}

If you are using DT, please use a phandle to the device on the MDIO bus.

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 376

Quoted 7 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +7 -0
+	/* Sets netdev->phydev to phydev; which will eventually
+	 * be used in ioctl calls.
+	 * Cannot pass NULL handler.
+	 */
+	err = phy_connect_direct(netdev, phydev,
+				 mlxbf_gige_adjust_link,
+				 PHY_INTERFACE_MODE_GMII);

It does a lot more than just set netdev->phydev. I'm not sure this comment has any real value.

Andrew

#4 lore raw
Quoted 24 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Thursday, March 11, 2021 9:20 PM
To: David Thompson <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Liming Sun <[email protected]>; Asmaa Mnebhi <[email protected]>
Subject: Re: [PATCH net-next v4] Add Mellanox BlueField Gigabit Ethernet driver

Quoted 16 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +15 -0
+#define DRV_VERSION 1.19
 
+static int mlxbf_gige_probe(struct platform_device *pdev) {
+	unsigned int phy_int_gpio;
+	struct phy_device *phydev;
+	struct net_device *netdev;
+	struct resource *mac_res;
+	struct resource *llu_res;
+	struct resource *plu_res;
+	struct mlxbf_gige *priv;
+	void __iomem *llu_base;
+	void __iomem *plu_base;
+	void __iomem *base;
+	int addr, version;
+	u64 control;
+	int err = 0;
Quoted 9 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 272

Quoted 5 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +5 -0
+
+	if (device_property_read_u32(&pdev->dev, "version", &version)) {
+		dev_err(&pdev->dev, "Version Info not found\n");
+		return -EINVAL;
+	}

Is this a device tree property? ACPI? If it is device tree property you need to document the binding, Documentation/devicetree/bindinds/...

This driver gets its properties from an ACPI table, not from device tree. The "version" property is read from the ACPI table, and if an incompatible table version is found the driver does not load. This logic allows the version of the driver and the version of the ACPI table to change and compatibility is ensured. If there's a different/better way to do this, please let me know.

Quoted 4 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c

Quoted 3 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +3 -0
+
+	if (version != (int)DRV_VERSION) {
+		dev_err(&pdev->dev, "Version Mismatch. Expected %d

Returned %d\n",

Quoted 10 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 278

Quoted 3 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +3 -0
+			(int)DRV_VERSION, version);
+		return -EINVAL;
+	}

That is odd. Doubt odd. First of, why (int)1.19? Why not just set DRV_VERSION to 1? This is the only place you use this, so the .19 seems pointless. Secondly, what does this version in DT/ACPI actually represent? The hardware version? Then you should be using a compatible string? Or read a hardware register which tells you have hardware version.

The value of DRV_VERSION is 1.19 because it specifies the <major>.<minor> version of the driver. This value is used by the MODULE_VERSION() macro. During the review of a prior patch version I was told to remove the use of the MODULE_VERSION() macro, so it is not shown here in this review. Please
let me know if the removal of MODULE_VERSION() is advised. There could
be a different #define, e.g. "ACPI_TABLE_VERSION 1" instead of overloading the DRV_VERSION via the (int) cast. That would probably make more sense.

Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	err = device_property_read_u32(&pdev->dev, "phy-int-gpio",

&phy_int_gpio);

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 354

Quoted 2 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +2 -0
+	if (err < 0)
+		phy_int_gpio = MLXBF_GIGE_DEFAULT_PHY_INT_GPIO;

Again, this probably needs documenting. This is not how you do interrupts with DT. I also don't think it is correct for ACPI, but i don't know ACPI.

Right, the "phy-int-gpio" is a property read from the ACPI table. Is there a convention for ACPI table use/documentation?

Quoted 8 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 365

Quoted 5 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +5 -0
+	phydev = phy_find_first(priv->mdiobus);
+	if (!phydev) {
+		mlxbf_gige_mdio_remove(priv);
+		return -ENODEV;
+	}

If you are using DT, please use a phandle to the device on the MDIO bus.

The code is not using DT.

Quoted 11 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 376

Quoted 7 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +7 -0
+	/* Sets netdev->phydev to phydev; which will eventually
+	 * be used in ioctl calls.
+	 * Cannot pass NULL handler.
+	 */
+	err = phy_connect_direct(netdev, phydev,
+				 mlxbf_gige_adjust_link,
+				 PHY_INTERFACE_MODE_GMII);

It does a lot more than just set netdev->phydev. I'm not sure this comment has any real value.

Quoted 1 line

Andrew

Yes, good point. This comment will be updated for completeness or removed.

Regards,
Dave

#5 lore raw
Quoted 9 lines
Quoted 8 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 272

Quoted 4 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +4 -0
+	if (device_property_read_u32(&pdev->dev, "version", &version)) {
+		dev_err(&pdev->dev, "Version Info not found\n");
+		return -EINVAL;
+	}

Is this a device tree property? ACPI? If it is device tree property you need to document the binding, Documentation/devicetree/bindinds/...

Quoted 5 lines

This driver gets its properties from an ACPI table, not from device tree. The "version" property is read from the ACPI table, and if an incompatible table version is found the driver does not load. This logic allows the version of the driver and the version of the ACPI table to change and compatibility is ensured. If there's a different/better way to do this, please let me know.

I tend to avoid ACPI. DT seems a better system. DT tries hard to not break backwards compatibility. Hence it is not really versioned. The fact you are versioning things and won't load if there is a version mismatch suggests you don't think backward compatibility is that important. I personally would not have a version, and promise to keep backwards compatibility. The current properties you have seem simple enough.

Quoted 16 lines
Quoted 5 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c

Quoted 4 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +3 -0
+
+	if (version != (int)DRV_VERSION) {
+		dev_err(&pdev->dev, "Version Mismatch. Expected %d

Returned %d\n",

Quoted 10 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 278

Quoted 3 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +3 -0
+			(int)DRV_VERSION, version);
+		return -EINVAL;
+	}

That is odd. Doubt odd. First of, why (int)1.19? Why not just set DRV_VERSION to 1? This is the only place you use this, so the .19 seems pointless. Secondly, what does this version in DT/ACPI actually represent? The hardware version? Then you should be using a compatible string? Or read a hardware register which tells you have hardware version.

Quoted 2 lines

The value of DRV_VERSION is 1.19 because it specifies the <major>.<minor> version of the driver.

Driver versions are pretty pointless. Don't you expect somebody to back port this into a vendor kernel? Everything around it has changed. What does this version then tell you? Nothing particularly useful, since what you really want to know is the release tag in the source tree, so you have the driver and everything around it you can then debug.

Quoted 10 lines
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	err = device_property_read_u32(&pdev->dev, "phy-int-gpio",

&phy_int_gpio);

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 354

Quoted 2 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +2 -0
+	if (err < 0)
+		phy_int_gpio = MLXBF_GIGE_DEFAULT_PHY_INT_GPIO;

Again, this probably needs documenting. This is not how you do interrupts with DT. I also don't think it is correct for ACPI, but i don't know ACPI.

Quoted 2 lines

Right, the "phy-int-gpio" is a property read from the ACPI table. Is there a convention for ACPI table use/documentation?

https://www.kernel.org/doc/html/latest/firmware-guide/acpi/gpio-properties.html

This seems to be the correct way to describe GPIOs in ACPI. But you are using the GPIO as an interrupt sources. Either you need to get the GPIO descriptor and then map it to an interrupt, or there might be another way to describe interrupts in ACPI. I very much doubt device_property_read_u32() is the correct way to do this, but as i said, i try to avoid ACPI.

Quoted 10 lines
Quoted 8 lines

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c line 365

Quoted 5 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c new file +5 -0
+	phydev = phy_find_first(priv->mdiobus);
+	if (!phydev) {
+		mlxbf_gige_mdio_remove(priv);
+		return -ENODEV;
+	}

If you are using DT, please use a phandle to the device on the MDIO bus.

The code is not using DT.

Yes, you just have to hope the first device on the bus is the correct device.

Andrew