MLX4 drivers for OpenWrt

Hi folks,

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


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.

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
  TITLE:=Mellanox ConnectX-3 and ConnectX-3 Pro Ethernet Adaptor
  FILES:= \
        $(LINUX_DIR)/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko \
        CONFIG_MLX4_CORE \
        CONFIG_MLX4_EN \
  AUTOLOAD:=$(call AutoLoad,50,mlx4_en)

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

$(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/ 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!


Did you install the linuxptp package?

I wonder why I can't find the packages you just mentioned?

There are some mlx kernel modules packages mentionned here.

Are those what you want ?

Is that enough for openwrt to connect to mlx kernel modules?

Sorry, I just searched for mlx on openwrt packages. I don't have openwrt on my computers that have mlx cards, so I cannot test. But I believe that if they are available they have been tested working, at least once...

I wonder why there is already a driver but that port is a link down?

Did you try: ip link set dev enpXXX up ?

Executing that command line works, right? :thinking:

May I ask if every reboot the device has to ssh into openwrt? Is there any way to automate it?

Nothing has to ssh into openwrt, so no need to automate it. You only ssh into openwrt to do something there when you need to.

So after executing the above command, what will happen if the device reboots? :thinking: