MLX4 drivers for OpenWrt

Hi folks,

What package would I find the Mellanox MLX4 drivers in? The source is here:

Thanks,
Seb

Folks - any help here?

I have a Mellanox Connectx-3 10Gig PCIE card but it is not recognised in OpenWRT, the drivers are in the Linux mainline. https://github.com/torvalds/linux/tree/master/drivers/net/ethernet/mellanox/mlx4

Would I need to build these specifically for OpenWRT?

Yes, you will have to add a package for them to OpenWrt's kernel package. See the following for a rough example:

Thanks! So this will be my first time, excuse the potentially dumb/obvious....

Do I need to build the drivers first as well as creating the package definition? Or does the package definition (if selected) cause it to be built from Linux source when I build OpenWRT?

You first need to package up mlx4_core, mlx4_en and mlx4_ib, then you can select these new packaged modules - before you can finally build OpenWrt including these modules.

Ok, so I think I have this.

I don't need mlx4_ib as that is the infiniband driver, just mlx4_core and mlx4_en.

Do I need seperate package definitions for mlx4_core and mlx4_en? I wondered if they could be combined, I see it done in other driver in the KCONFIG parameter.

The makefile for mlx4 is:

# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MLX4_CORE)		+= mlx4_core.o

mlx4_core-y :=	alloc.o catas.o cmd.o cq.o eq.o fw.o fw_qos.o icm.o intf.o \
		main.o mcg.o mr.o pd.o port.o profile.o qp.o reset.o sense.o \
		srq.o resource_tracker.o crdump.o

obj-$(CONFIG_MLX4_EN)               += mlx4_en.o

mlx4_en-y := 	en_main.o en_tx.o en_rx.o en_ethtool.o en_port.o en_cq.o \
		en_resources.o en_netdev.o en_selftest.o en_clock.o
mlx4_en-$(CONFIG_MLX4_EN_DCB) += en_dcb_nl.o

So if I make my package definition this:

define KernelPackage/mlx4_en
  SUBMENU:=$(NETWORK_DEVICES_MENU)
  DEPENDS:=+kmod-ptp
  TITLE:=Mellanox ConnectX-3 and ConnectX-3 Pro Ethernet Adaptor
  FILES:= \
        $(LINUX_DIR)/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko \
        $(LINUX_DIR)/drivers/net/ethernet/mellanox/mlx4/mlx4_core.ko
  KCONFIG:= \
        CONFIG_MLX4_CORE \
        CONFIG_MLX4_EN \
        CONFIG_MLX4_DEBUG=n
  AUTOLOAD:=$(call AutoLoad,50,mlx4_en)
endef

define KernelPackage/mlx4_en/description
  Kernel module for Mellanox ConnectX-3 and ConnectX-3 Pro Ethernet Adaptors
endef

$(eval $(call KernelPackage,mlx4_en))

That should build both driver modules?

I'm still missing something... building OpenWRT now gives me this:

ERROR: module '/home/seb/openwrt/build_dir/target-i386_pentium4_musl/linux-x86_generic/linux-4.14.171/drivers/net/ethernet/mellanox/mlx4_en.ko' is missing.
modules/netdevices.mk:959: recipe for target '/home/seb/openwrt/bin/targets/x86/generic/packages/kmod-mlx4_en_4.14.171-1_i386_pentium4.ipk' failed
make[3]: *** [/home/seb/openwrt/bin/targets/x86/generic/packages/kmod-mlx4_en_4.14.171-1_i386_pentium4.ipk] Error 1

Ah damn. Realized my own mistake. There should be an additional directory in the path... /mlx4/

Missed a dependency (ptp) that stopped it compiling, but otherwise it worked a charm.

Have updated the package stanza aboce for future reference.

All good!

1 Like