Skip to contentSkip to conversation

mlxbf_gige: add BlueField-3 support

PATCH Superseded David Thompson 3 participants 9 messages Oct 27, 2022 – Oct 28, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover mlxbf_gige: add BlueField-3 support

This patch series adds driver logic to the "mlxbf_gige" Ethernet driver in order to support the third generation BlueField SoC (BF3). The existing "mlxbf_gige" driver is extended with BF3-specific logic and run-time decisions are made by the driver depending on the SoC generation (BF2 vs. BF3).

The BF3 SoC is similar to BF2 SoC with regards to transmit and receive packet processing:
* Driver rings usage; consumer & producer indices
* Single queue for receive and transmit
* DMA operation

The differences between BF3 and BF2 are:
* In addition to supporting 1Gbps interface speed, the BF3 SoC adds support for 10Mbps and 100Mbps interface speeds
* BF3 requires SerDes config logic to support its SGMII interface
* BF3 adds support for "ethtool -s" for interface speed config
* BF3 utilizes different MDIO logic for accessing the board-level PHY device

Testing
- Successful build of kernel for ARM64, ARM32, X86_64
- Tested ARM64 build on FastModels, Palladium, SoC

David Thompson (4):
mlxbf_gige: add MDIO support for BlueField-3
mlxbf_gige: support 10M/100M/1G speeds on BlueField-3
mlxbf_gige: add BlueField-3 Serdes configuration
mlxbf_gige: add BlueField-3 ethtool_ops

 .../net/ethernet/mellanox/mlxbf_gige/Makefile |    3 +-
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h |   34 +-
 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c  |   16 +-
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c     |  170 ++-
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio.c     |  185 +--
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h |   53 +
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h |   54 +
 .../mellanox/mlxbf_gige/mlxbf_gige_regs.h     |   22 +
 .../mellanox/mlxbf_gige/mlxbf_gige_uphy.c     | 1191 +++++++++++++++++
 .../mellanox/mlxbf_gige/mlxbf_gige_uphy.h     |  398 ++++++
 10 files changed, 2027 insertions(+), 99 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.h
Signature · 1 line
2.30.1
#1 lore raw

PATCH 1/4 mlxbf_gige: add MDIO support for BlueField-3

This patch adds initial MDIO support for the BlueField-3 SoC. Separate header files for the BlueField-2 and the BlueField-3 SoCs have been created. These header files hold the SoC-specific MDIO macros since the register offsets and bit fields have changed. Also, in BlueField-3 there is a separate register for writing and reading the MDIO data. Finally, instead of having "if" statements everywhere to differentiate between SoC-specific logic, a mlxbf_gige_mdio_gw_t struct was created for this purpose.

---
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h |  19 ++
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c     |   2 +
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio.c     | 172 +++++++++++++-----
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h |  53 ++++++
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h |  54 ++++++
 .../mellanox/mlxbf_gige/mlxbf_gige_regs.h     |   1 +
 6 files changed, 251 insertions(+), 50 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h +19 -0
index 5a1027b07215..421a0b1b766c 100644
@@ -67,6 +67,23 @@ struct mlxbf_gige_stats {
 	u64 rx_filter_discard_pkts;
 };
 
+struct mlxbf_gige_reg_param {
+	u32 mask;
+	u32 shift;
+};
+
+struct mlxbf_gige_mdio_gw {
+	u32 gw_address;
+	u32 read_data_address;
+	struct mlxbf_gige_reg_param busy;
+	struct mlxbf_gige_reg_param write_data;
+	struct mlxbf_gige_reg_param read_data;
+	struct mlxbf_gige_reg_param devad;
+	struct mlxbf_gige_reg_param partad;
+	struct mlxbf_gige_reg_param opcode;
+	struct mlxbf_gige_reg_param st1;
+};
+
 struct mlxbf_gige {
 	void __iomem *base;
 	void __iomem *llu_base;
@@ -102,6 +119,8 @@ struct mlxbf_gige {
 	u8 valid_polarity;
 	struct napi_struct napi;
 	struct mlxbf_gige_stats stats;
+	u8 hw_version;
+	struct mlxbf_gige_mdio_gw *mdio_gw;
 };
 
 /* Rx Work Queue Element definitions */
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +2 -0
index 2292d63a279c..e08c07e914c1 100644
@@ -315,6 +315,8 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
 
 	spin_lock_init(&priv->lock);
 
+	priv->hw_version = readq(base + MLXBF_GIGE_VERSION);
+
 	/* Attach MDIO device */
 	err = mlxbf_gige_mdio_probe(pdev, priv);
 	if (err)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c +122 -50

256 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h new file +53 -0

53 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h new file +54 -0

54 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h +1 -0
index 7be3a793984d..8d52dbef4adf 100644
@@ -10,6 +10,7 @@
 
 #define MLXBF_GIGE_VERSION                            0x0000
 #define MLXBF_GIGE_VERSION_BF2                        0x0
+#define MLXBF_GIGE_VERSION_BF3                        0x1
 #define MLXBF_GIGE_STATUS                             0x0010
 #define MLXBF_GIGE_STATUS_READY                       BIT(0)
 #define MLXBF_GIGE_INT_STATUS                         0x0028
Signature · 1 line
2.30.1
#2 lore raw

PATCH 2/4 mlxbf_gige: support 10M/100M/1G speeds on BlueField-3

In reply to David Thompson

The BlueField-3 OOB interface supports 10Mbps, 100Mbps, and 1Gbps speeds. The external PHY is responsible for autonegotiating the speed with the link partner. Once the autonegotiation is done, the BlueField PLU needs to be configured accordingly.

This patch does two things:
1) Initialize the advertised control flow/duplex/speed in the probe based on the BlueField SoC generation (2 or 3)
2) Adjust the PLU speed config in the PHY interrupt handler

---
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h |   8 ++
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c     | 109 +++++++++++++++---
 .../mellanox/mlxbf_gige/mlxbf_gige_regs.h     |  21 ++++
 3 files changed, 123 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h +8 -0
index 421a0b1b766c..a453b9cd9033 100644
@@ -14,6 +14,7 @@
 #include <linux/irqreturn.h>
 #include <linux/netdevice.h>
 #include <linux/irq.h>
+#include <linux/phy.h>
 
 /* The silicon design supports a maximum RX ring size of
  * 32K entries. Based on current testing this maximum size
@@ -84,6 +85,12 @@ struct mlxbf_gige_mdio_gw {
 	struct mlxbf_gige_reg_param st1;
 };
 
+struct mlxbf_gige_link_cfg {
+	void (*set_phy_link_mode)(struct phy_device *phydev);
+	void (*adjust_link)(struct net_device *netdev);
+	phy_interface_t phy_mode;
+};
+
 struct mlxbf_gige {
 	void __iomem *base;
 	void __iomem *llu_base;
@@ -121,6 +128,7 @@ struct mlxbf_gige {
 	struct mlxbf_gige_stats stats;
 	u8 hw_version;
 	struct mlxbf_gige_mdio_gw *mdio_gw;
+	int prev_speed;
 };
 
 /* Rx Work Queue Element definitions */
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +94 -15

132 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h +21 -0
index 8d52dbef4adf..cd0973229c9b 100644
@@ -8,6 +8,8 @@
 #ifndef __MLXBF_GIGE_REGS_H__
 #define __MLXBF_GIGE_REGS_H__
 
+#include <linux/bitfield.h>
+
 #define MLXBF_GIGE_VERSION                            0x0000
 #define MLXBF_GIGE_VERSION_BF2                        0x0
 #define MLXBF_GIGE_VERSION_BF3                        0x1
@@ -78,4 +80,23 @@
  */
 #define MLXBF_GIGE_MMIO_REG_SZ                        (MLXBF_GIGE_MAC_CFG + 8)
 
+#define MLXBF_GIGE_PLU_TX_REG0                        0x80
+#define MLXBF_GIGE_PLU_TX_IPG_SIZE_MASK               GENMASK(11, 0)
+#define MLXBF_GIGE_PLU_TX_SGMII_MODE_MASK             GENMASK(15, 14)
+
+#define MLXBF_GIGE_PLU_RX_REG0                        0x10
+#define MLXBF_GIGE_PLU_RX_SGMII_MODE_MASK             GENMASK(25, 24)
+
+#define MLXBF_GIGE_1G_SGMII_MODE                      0x0
+#define MLXBF_GIGE_10M_SGMII_MODE                     0x1
+#define MLXBF_GIGE_100M_SGMII_MODE                    0x2
+
+/* ipg_size default value for 1G is fixed by HW to 11 + End = 12.
+ * So for 100M it is 12 * 10 - 1 = 119
+ * For 10M, it is 12 * 100 - 1 = 1199
+ */
+#define MLXBF_GIGE_1G_IPG_SIZE                        11
+#define MLXBF_GIGE_100M_IPG_SIZE                      119
+#define MLXBF_GIGE_10M_IPG_SIZE                       1199
+
 #endif /* !defined(__MLXBF_GIGE_REGS_H__) */
Signature · 1 line
2.30.1
#7 lore raw

PATCH 4/4 mlxbf_gige: add BlueField-3 ethtool_ops

In reply to David Thompson

This patch adds logic to support initialization of a BlueField-3 specific "ethtool_ops" data structure. The BlueField-3 data structure supports the "set_link_ksettings" callback, while the BlueField-2 data structure does not.

---
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h    |  3 ++-
 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c     | 16 +++++++++++++++-
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c        |  4 +++-
 3 files changed, 20 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h +2 -1
index e9bd09ee0b1f..cbabdac3ecb0 100644
@@ -200,7 +200,8 @@ struct sk_buff *mlxbf_gige_alloc_skb(struct mlxbf_gige *priv,
 int mlxbf_gige_request_irqs(struct mlxbf_gige *priv);
 void mlxbf_gige_free_irqs(struct mlxbf_gige *priv);
 int mlxbf_gige_poll(struct napi_struct *napi, int budget);
-extern const struct ethtool_ops mlxbf_gige_ethtool_ops;
+extern const struct ethtool_ops mlxbf_gige_bf2_ethtool_ops;
+extern const struct ethtool_ops mlxbf_gige_bf3_ethtool_ops;
 void mlxbf_gige_update_tx_wqe_next(struct mlxbf_gige *priv);
 
 #endif /* !defined(__MLXBF_GIGE_H__) */
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c +15 -1
index 41ebef25a930..92c1c9e7f4cb 100644
@@ -124,7 +124,7 @@ static void mlxbf_gige_get_pauseparam(struct net_device *netdev,
 	pause->tx_pause = 1;
 }
 
-const struct ethtool_ops mlxbf_gige_ethtool_ops = {
+const struct ethtool_ops mlxbf_gige_bf2_ethtool_ops = {
 	.get_link		= ethtool_op_get_link,
 	.get_ringparam		= mlxbf_gige_get_ringparam,
 	.get_regs_len           = mlxbf_gige_get_regs_len,
@@ -136,3 +136,17 @@ const struct ethtool_ops mlxbf_gige_ethtool_ops = {
 	.get_pauseparam		= mlxbf_gige_get_pauseparam,
 	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 };
+
+const struct ethtool_ops mlxbf_gige_bf3_ethtool_ops = {
+	.get_link		= ethtool_op_get_link,
+	.get_ringparam		= mlxbf_gige_get_ringparam,
+	.get_regs_len           = mlxbf_gige_get_regs_len,
+	.get_regs               = mlxbf_gige_get_regs,
+	.get_strings            = mlxbf_gige_get_strings,
+	.get_sset_count         = mlxbf_gige_get_sset_count,
+	.get_ethtool_stats      = mlxbf_gige_get_ethtool_stats,
+	.nway_reset		= phy_ethtool_nway_reset,
+	.get_pauseparam		= mlxbf_gige_get_pauseparam,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
+};
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +3 -1
index 16a404a49d28..77dea6564e65 100644
@@ -436,7 +436,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
 
 	SET_NETDEV_DEV(netdev, &pdev->dev);
 	netdev->netdev_ops = &mlxbf_gige_netdev_ops;
-	netdev->ethtool_ops = &mlxbf_gige_ethtool_ops;
 	priv = netdev_priv(netdev);
 	priv->netdev = netdev;
 
@@ -453,9 +452,12 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
 	priv->hw_version = soc_version;
 
 	if (priv->hw_version == MLXBF_GIGE_VERSION_BF3) {
+		netdev->ethtool_ops = &mlxbf_gige_bf3_ethtool_ops;
 		err = mlxbf_gige_config_uphy(priv);
 		if (err)
 			return err;
+	} else {
+		netdev->ethtool_ops = &mlxbf_gige_bf2_ethtool_ops;
 	}
 
 	/* Attach MDIO device */
Signature · 1 line
2.30.1
#4 lore raw

PATCH 3/4 mlxbf_gige: add BlueField-3 Serdes configuration

In reply to David Thompson

The BlueField-3 out-of-band Ethernet interface requires SerDes configuration. There are two aspects to this:

Configuration of PLL:
1) Initialize UPHY registers to values dependent on p1clk clock
2) Load PLL best known values via the gateway register
3) Set the fuses to tune up the SerDes voltage
4) Lock the PLL
5) Get the lanes out of functional reset.
6) Configure the UPHY microcontroller via gateway reads/writes

Configuration of lanes:
1) Configure and open TX lanes
2) Configure and open RX lanes

---
 .../net/ethernet/mellanox/mlxbf_gige/Makefile |    3 +-
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h |    4 +-
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c     |   57 +-
 .../mellanox/mlxbf_gige/mlxbf_gige_mdio.c     |   37 -
 .../mellanox/mlxbf_gige/mlxbf_gige_uphy.c     | 1191 +++++++++++++++++
 .../mellanox/mlxbf_gige/mlxbf_gige_uphy.h     |  398 ++++++
 6 files changed, 1646 insertions(+), 44 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.h
drivers/net/ethernet/mellanox/mlxbf_gige/Makefile +2 -1
index a97c2bef846b..524af17cad9c 100644
@@ -7,4 +7,5 @@ mlxbf_gige-y := mlxbf_gige_ethtool.o \
 		mlxbf_gige_main.o \
 		mlxbf_gige_mdio.o \
 		mlxbf_gige_rx.o   \
-		mlxbf_gige_tx.o
+		mlxbf_gige_tx.o   \
+		mlxbf_gige_uphy.o
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h +3 -1
index a453b9cd9033..e9bd09ee0b1f 100644
@@ -100,6 +100,7 @@ struct mlxbf_gige {
 	struct platform_device *pdev;
 	void __iomem *mdio_io;
 	void __iomem *clk_io;
+	void __iomem *fuse_gw_io;
 	struct mii_bus *mdiobus;
 	spinlock_t lock;      /* for packet processing indices */
 	u16 rx_q_entries;
@@ -166,7 +167,8 @@ enum mlxbf_gige_res {
 	MLXBF_GIGE_RES_GPIO0,
 	MLXBF_GIGE_RES_LLU,
 	MLXBF_GIGE_RES_PLU,
-	MLXBF_GIGE_RES_CLK
+	MLXBF_GIGE_RES_CLK,
+	MLXBF_GIGE_RES_FUSE_GW
 };
 
 /* Version of register data returned by mlxbf_gige_get_regs() */
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +52 -5

92 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c +0 -37
index 7ac06fd31011..043edf57e36b 100644
@@ -113,24 +113,6 @@ static struct mlxbf_gige_mdio_gw mlxbf_gige_mdio_gw_t[] = {
 /* Busy bit is set by software and cleared by hardware */
 #define MLXBF_GIGE_MDIO_SET_BUSY	0x1
 
-#define MLXBF_GIGE_BF2_COREPLL_ADDR 0x02800c30
-#define MLXBF_GIGE_BF2_COREPLL_SIZE 0x0000000c
-#define MLXBF_GIGE_BF3_COREPLL_ADDR 0x13409824
-#define MLXBF_GIGE_BF3_COREPLL_SIZE 0x00000010
-
-static struct resource corepll_params[] = {
-	[MLXBF_GIGE_VERSION_BF2] = {
-		.start = MLXBF_GIGE_BF2_COREPLL_ADDR,
-		.end = MLXBF_GIGE_BF2_COREPLL_ADDR + MLXBF_GIGE_BF2_COREPLL_SIZE - 1,
-		.name = "COREPLL_RES"
-	},
-	[MLXBF_GIGE_VERSION_BF3] = {
-		.start = MLXBF_GIGE_BF3_COREPLL_ADDR,
-		.end = MLXBF_GIGE_BF3_COREPLL_ADDR + MLXBF_GIGE_BF3_COREPLL_SIZE - 1,
-		.name = "COREPLL_RES"
-	}
-};
-
 /* Returns core clock i1clk in Hz */
 static u64 calculate_i1clk(struct mlxbf_gige *priv)
 {
@@ -294,31 +276,12 @@ static void mlxbf_gige_mdio_cfg(struct mlxbf_gige *priv)
 int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	int ret;
 
-	if (priv->hw_version > MLXBF_GIGE_VERSION_BF3)
-		return -ENODEV;
-
 	priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9);
 	if (IS_ERR(priv->mdio_io))
 		return PTR_ERR(priv->mdio_io);
 
-	/* clk resource shared with other drivers so cannot use
-	 * devm_platform_ioremap_resource
-	 */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_CLK);
-	if (!res) {
-		/* For backward compatibility with older ACPI tables, also keep
-		 * CLK resource internal to the driver.
-		 */
-		res = &corepll_params[priv->hw_version];
-	}
-
-	priv->clk_io = devm_ioremap(dev, res->start, resource_size(res));
-	if (!priv->clk_io)
-		return -ENOMEM;
-
 	priv->mdio_gw = &mlxbf_gige_mdio_gw_t[priv->hw_version];
 
 	mlxbf_gige_mdio_cfg(priv);
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c new file +1191 -0

1,191 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.h new file +398 -0

398 lines not on this page · raw message

Signature · 1 line
2.30.1
#3 lore raw

Re: [PATCH net-next v1 2/4] mlxbf_gige: support 10M/100M/1G speeds on BlueField-3

In reply to David Thompson

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c static const struct net_device_ops mlxbf_gige_netdev_ops = { · line 282

Quoted 10 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +10 -0
+static void mlxbf_gige_bf3_adjust_link(struct net_device *netdev)
+{
+	struct mlxbf_gige *priv = netdev_priv(netdev);
+	struct phy_device *phydev = netdev->phydev;
+	unsigned long flags;
+	u8 sgmii_mode;
+	u16 ipg_size;
+	u32 val;
+
+	spin_lock_irqsave(&priv->lock, flags);

What are you protecting with this spinlock?

phylib holds the phy mutex while it calls the adjust_link method, so calls to it are serialised.

Andrew

#5 lore raw

Re: [PATCH net-next v1 3/4] mlxbf_gige: add BlueField-3 Serdes configuration

In reply to David Thompson
Quoted 8 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c new file +8 -0
+mlxbf_gige_clm_init[] = {
+	{.addr = 0x001, .wdata = 0x0105},
+	{.addr = 0x008, .wdata = 0x0001},
+	{.addr = 0x00B, .wdata = 0x8420},
+	{.addr = 0x00E, .wdata = 0x0110},
+	{.addr = 0x010, .wdata = 0x3010},
+	{.addr = 0x027, .wdata = 0x0104},
+	{.addr = 0x02F, .wdata = 0x09EA},

drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c line 33

Quoted 10 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c new file +10 -0
+	{.addr = 0x055, .wdata = 0x0008},
+	{.addr = 0x058, .wdata = 0x0088},
+	{.addr = 0x072, .wdata = 0x3222},
+	{.addr = 0x073, .wdata = 0x7654},
+	{.addr = 0x074, .wdata = 0xBA98},
+	{.addr = 0x075, .wdata = 0xDDDC}
+};
+
+#define MLXBF_GIGE_UPHY_CLM_INIT_NUM_ENTRIES \
+	(sizeof(mlxbf_gige_clm_init) / sizeof(struct mlxbf_gige_uphy_cfg_reg))

ARRAY_SIZE() ?

You have a lot of completely undocumented black magic here. And these tables are quite large. I'm wondering if it really should be considered firmware, and loaded on demand from /lib/firmware ?

Andrew

#8 lore raw

Re: [PATCH net-next v1 4/4] mlxbf_gige: add BlueField-3 ethtool_ops

In reply to David Thompson
Quoted 4 lines · David Thompson

This patch adds logic to support initialization of a BlueField-3 specific "ethtool_ops" data structure. The BlueField-3 data structure supports the "set_link_ksettings" callback, while the BlueField-2 data structure does not.

Why?

I _think_, so long as the supported values have been set correctly in the phydev, set_link_ksettings should not be able to set anything for BF2 which it cannot support.

Andrew

#6 lore raw

RE: [PATCH net-next v1 3/4] mlxbf_gige: add BlueField-3 Serdes configuration

In reply to Andrew Lunn
Quoted 9 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c new file +9 -0
+mlxbf_gige_clm_init[] = {
+	{.addr = 0x001, .wdata = 0x0105},
+	{.addr = 0x008, .wdata = 0x0001},
+	{.addr = 0x00B, .wdata = 0x8420},
+	{.addr = 0x00E, .wdata = 0x0110},
+	{.addr = 0x010, .wdata = 0x3010},
+	{.addr = 0x027, .wdata = 0x0104},
+	{.addr = 0x02F, .wdata = 0x09EA},
+	{.addr = 0x055, .wdata = 0x0008},

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

Quoted 10 lines
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_uphy.c new file +10 -0
+	{.addr = 0x058, .wdata = 0x0088},
+	{.addr = 0x072, .wdata = 0x3222},
+	{.addr = 0x073, .wdata = 0x7654},
+	{.addr = 0x074, .wdata = 0xBA98},
+	{.addr = 0x075, .wdata = 0xDDDC}
+};
+
+#define MLXBF_GIGE_UPHY_CLM_INIT_NUM_ENTRIES \
+	(sizeof(mlxbf_gige_clm_init) / sizeof(struct 
+mlxbf_gige_uphy_cfg_reg))

ARRAY_SIZE() ?

You have a lot of completely undocumented black magic here. And these tables are quite large. I'm wondering if it really should be considered firmware, and loaded on demand from /lib/firmware ?

Hi Andrew,
We can add comments to document the "black magic" tables. The NVIDIA serdes has a lot of speed features and lane configurations. The lowest and simplest speed is 1G/1lane (the only one we support in this driver). there is an internal microcontroller which needs to be configured to implement all this. These tables were given to us as the hardware recipes to program serdes to operate in 1G/1 lane. We would prefer to keep all this code in one place i.e. as part of this driver.