Add custom Ethernet module

This commit is contained in:
Rodrigo Arias 2024-09-05 07:41:54 +02:00
parent 6f12ec6372
commit 6239191835
4 changed files with 92 additions and 24 deletions

View File

@ -0,0 +1,21 @@
diff --git a/drivers/xxvnet_carv.c b/drivers/xxvnet_carv.c
index d3f60f9..9fd4c21 100644
--- a/drivers/xxvnet_carv.c
+++ b/drivers/xxvnet_carv.c
@@ -36,6 +36,7 @@
#include <linux/iopoll.h>
#include <linux/random.h>
#include <linux/clk.h>
+#include <linux/platform_device.h>
#include "xxvnet_carv.h"
@@ -1511,7 +1512,7 @@ axienet_dma_probe(struct platform_device *pdev, struct net_device *ndev)
spin_lock_init(&q->tx_lock);
spin_lock_init(&q->rx_lock);
- netif_napi_add(ndev, &lp->napi, axienet_rx_poll, AXIENET_NAPI_WEIGHT);
+ netif_napi_add(ndev, &lp->napi, axienet_rx_poll);
return 0;
}

View File

@ -0,0 +1,7 @@
diff --git a/drivers/Kbuild b/drivers/Kbuild
index 28d6c0f..7f02860 100644
--- a/drivers/Kbuild
+++ b/drivers/Kbuild
@@ -1,2 +1 @@
obj-m := xxvnet_carv.o
-obj-m := xilinx_dma.o

View File

@ -0,0 +1,23 @@
diff --git a/drivers/xxvnet_carv.c b/drivers/xxvnet_carv.c
index eb664bb..d3f60f9 100644
--- a/drivers/xxvnet_carv.c
+++ b/drivers/xxvnet_carv.c
@@ -1435,12 +1435,12 @@ static void axienet_poll_controller(struct net_device *ndev)
{
struct axienet_local *lp = netdev_priv(ndev);
- disable_irq(lp->tx_irq);
- disable_irq(lp->rx_irq);
- axienet_rx_irq(lp->tx_irq, ndev);
- axienet_tx_irq(lp->rx_irq, ndev);
- enable_irq(lp->tx_irq);
- enable_irq(lp->rx_irq);
+ disable_irq(lp->dq->tx_irq);
+ disable_irq(lp->dq->rx_irq);
+ axienet_rx_irq(lp->dq->tx_irq, ndev);
+ axienet_tx_irq(lp->dq->rx_irq, ndev);
+ enable_irq(lp->dq->tx_irq);
+ enable_irq(lp->dq->rx_irq);
}
#endif

View File

@ -74,6 +74,14 @@
boot.kernelPackages = pkgs.linuxPackages_latest;
boot = {
extraModulePackages = [
# Add the custom Ethernet module
pkgs.xilinx-axienet-carv
];
kernelModules = [
# Load the Ethernet module by default
"xilinx_axienet_carv"
];
kernelPatches = [
{
name = assert false; "sbi-early-console";
@ -418,29 +426,38 @@
#./ox-alveo-platform-plic.patch
];
});
# opensbi = prev.opensbi.overrideAttrs (old: {
# #NIX_DEBUG=5;
# # Compile dts to dtb form
# #nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ prev.buildPackages.dtc ];
# #preBuild = ''
# # dtc -O dtb -o ox.dtb ${./ox.dts}
# #'';
# makeFlags = old.makeFlags ++ [
# "PLATFORM=fpga/sargantana_alveo"
# #"PLATFORM_RISCV_ISA=rv64imafd" # No compressed instructions
# "PLATFORM_RISCV_ISA=rv64g" # No compressed instructions
# #"PLATFORM_RISCV_ABI=lp64d"
# "FW_PAYLOAD_PATH=${final.uboot}/u-boot-nodtb.bin"
# #"FW_FDT_PATH=ox.dtb"
# ];
# patches = [ ./alveo-uart-sbi-hack.patch ];
# });
# opensbi = prev.opensbi.overrideAttrs (old: {
# makeFlags = old.makeFlags ++ [
# "PLATFORM=fpga/openpiton"
# "FW_PAYLOAD_PATH=${final.uboot}/u-boot-nodtb.bin"
# ];
# patches = [ ./opensbi-lagarto-hun.patch ];
# });
# Custom kernel driver for the Ethernet
xilinx-axienet-carv = let
kernel = config.boot.kernelPackages.kernel;
in prev.stdenv.mkDerivation rec {
pname = "xilinx-axienet-carv";
version = src.shortRev;
src = builtins.fetchGit {
url = "git@gitlab-internal.bsc.es:meep/meep-os/lagarto-openpiton-sdk.git";
rev = "d2ae2e788bf1cc60676599184a9ec1128cc81d81";
ref = "master";
};
patches = [
./ethernet-driver-poll.patch
./ethernet-driver-build.patch
./ethernet-driver-kbuild.patch
];
preConfigure = ''
export sourceRoot=$PWD/drivers
cd drivers
#rm Makefile
'';
nativeBuildInputs = kernel.moduleBuildDependencies;
makeFlags = kernel.makeFlags ++ [
"-C"
"${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"M=$(PWD)"
];
buildFlags = [ "modules" ];
installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
installTargets = [ "modules_install" ];
};
}) ];
}