drivers/net: add NXP FEC-UIO driver
Subsystems (4)
cover drivers/net: add NXP FEC-UIO driver
This patch series introduce the fec-uio driver, supported for the inbuilt NIC found in the NXP i.MX 8M Mini SoC. Basic hardware initialization is performed in kernel via userspace input/output(UIO) to support FEC ethernet device detection in user space.
Userspace PMD uses standard UIO interface to access kernel for PHY initialisation and for mapping the allocated memory of register & buffer descriptor with DPDK which gives access to non-cacheable memory for buffer descriptor.
Module fec-uio.ko will get generated. imx8mm-evk-dpdk.dtb is required to support fec-uio driver.
Apeksha Gupta (5):
dt-bindings: add binding for fec-uio
net: fec: fec-uio driver
ARM64: defconfig: Add config for fec-uio
MAINTAINERS: add new file
arm64: dts: imx8mm-evk-dpdk: dts for fec-uio driver
.../devicetree/bindings/net/fsl,fec-uio.yaml | 32 ++ MAINTAINERS | 6 + arch/arm64/boot/dts/freescale/Makefile | 1 + .../boot/dts/freescale/imx8mm-evk-dpdk.dts | 10 + arch/arm64/configs/defconfig | 1 + drivers/net/ethernet/freescale/Kconfig | 10 + drivers/net/ethernet/freescale/Makefile | 7 +- drivers/net/ethernet/freescale/fec_uio.c | 437 ++++++++++++++++++ 8 files changed, 501 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/fsl,fec-uio.yaml create mode 100644 arch/arm64/boot/dts/freescale/imx8mm-evk-dpdk.dts create mode 100644 drivers/net/ethernet/freescale/fec_uio.c
Signature · 1 line
2.17.1
PATCH 1/5 dt-bindings: add binding for fec-uio
binding 'fsl,fec-uio.yaml' represents the basic hardware initialization which is performed in fec-uio via userspace input/output to support FEC ethernet device detection in user space.
--- .../devicetree/bindings/net/fsl,fec-uio.yaml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/fsl,fec-uio.yaml
Documentation/devicetree/bindings/net/fsl,fec-uio.yaml new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/fsl,fec-uio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP Fast Ethernet Controller (FEC) with UIO + +maintainers: + - Apeksha Gupta <[email protected]> + - Sachin Saxena <[email protected]> + +description: + This binding represents the basic hardware initialization which is + performed in fec-uio via userspace input/output, to support fec + ethernet device detection in user space. + +allOf: + - $ref: "fsl,fec.yaml#" + +properties: + compatible: + const: fsl,imx8mm-fec-uio + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false
Signature · 1 line
2.17.1
PATCH 2/5 net: fec: fec-uio driver
In reply to Apeksha Guptai.mx: fec-uio driver
This patch adds the userspace support. In this basic hardware initialization is performed in kernel via userspace input/output, while the majority of code is written in the userspace.
Module fec-uio.ko is generated. imx8mm-evk-dpdk.dtb is required to support fec-uio driver.
--- drivers/net/ethernet/freescale/Kconfig | 10 + drivers/net/ethernet/freescale/Makefile | 7 +- drivers/net/ethernet/freescale/fec_uio.c | 437 +++++++++++++++++++++++ 3 files changed, 451 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/freescale/fec_uio.c
drivers/net/ethernet/freescale/Kconfig +10 -0
@@ -33,6 +33,16 @@ config FEC Say Y here if you want to use the built-in 10/100 Fast ethernet controller on some Motorola ColdFire and Freescale i.MX processors. +config FEC_UIO + tristate "FEC_UIO ethernet controller (i.MX 8M Mini CPU)" + default n + select UIO + help + Say Y here if you want to use the built-in 10/100/1000-Mbit/s Fast + ethernet controller on Freescale i.MX 8M Mini processor. Basic + hardware initialization is performed in kernel via UIO, fec-uio + driver adds the userspace support. + config FEC_MPC52xx tristate "FEC MPC52xx driver" depends on PPC_MPC52xx && PPC_BESTCOMM
drivers/net/ethernet/freescale/Makefile +4 -3
@@ -2,11 +2,12 @@ # # Makefile for the Freescale network device drivers. # - -common-objs := fec_phy.o +common-obj := fec_phy.o obj-$(CONFIG_FEC) += fec.o -fec-objs :=fec_main.o fec_ptp.o $(common-objs) +fec-objs :=fec_main.o fec_ptp.o $(common-obj) +obj-$(CONFIG_FEC_UIO) += enetfec_uio.o +enetfec_uio-objs := fec_uio.o $(common-obj) obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y)
drivers/net/ethernet/freescale/fec_uio.c new file +437 -0
437 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 2/5] net: fec: fec-uio driver
Quoted 6 lines · Apeksha Gupta
i.mx: fec-uio driver
This patch adds the userspace support. In this basic hardware initialization is performed in kernel via userspace input/output, while the majority of code is written in the userspace.
Where do i find this usespace code. Please include a URL to a git repo.
drivers/net/ethernet/freescale/fec_uio.c line 77
Quoted 3 lines
drivers/net/ethernet/freescale/fec_uio.c new file +3
-0+static unsigned char macaddr[ETH_ALEN ]; +module_param_array (macaddr, byte,NULL ,0 ); +MODULE_PARM_DESC (macaddr,"FEC Ethernet MAC address" );
No module parameters please. Use the standard device tree bindings.
Quoted 14 lines
drivers/net/ethernet/freescale/fec_uio.c new file +14
-0+static int fec_enet_uio_init (struct net_device *ndev) +{ +unsigned int total_tx_ring_size =0 , total_rx_ring_size =0 ; +struct fec_enet_private *fep =netdev_priv (ndev); +unsigned int dsize =sizeof (struct bufdesc ); +unsigned short tx_ring_size, rx_ring_size; +int ret, i; + +/* Check mask of the streaming and coherent API */ + ret =dma_set_mask_and_coherent (&fep->pdev->dev,DMA_BIT_MASK (32 )); +if (ret <0 ) { +dev_warn (&fep->pdev->dev,"No suitable DMA available\n" ); +return ret; + }
drivers/net/ethernet/freescale/fec_uio.c line 174
Quoted 10 lines
drivers/net/ethernet/freescale/fec_uio.c new file +10
-0+ + tx_ring_size =TX_RING_SIZE ; + rx_ring_size =RX_RING_SIZE ; + +for (i =0 ; i <FEC_ENET_MAX_TX_QS ; i++) + total_tx_ring_size += tx_ring_size; +for (i =0 ; i <FEC_ENET_MAX_RX_QS ; i++) + total_rx_ring_size += rx_ring_size; + + bd_size = (total_tx_ring_size + total_rx_ring_size) * dsize;
These are the buffer descriptors, not buffers themselves. I assume the user space driver is allocating the buffer? And your userspace then set the descriptor to point to user allocated memory? Or some other memory in the address space, and overwrite whatever you want on the next DMA? Or DMAing kernel memory out as frames?
Quoted 5 lines
drivers/net/ethernet/freescale/fec_uio.c new file +5
-0+static int +fec_enet_uio_probe (struct platform_device *pdev) +{ +struct fec_uio_devinfo *dev_info; +const struct of_device_id *of_id;
drivers/net/ethernet/freescale/fec_uio.c line 204
Quoted 10 lines
drivers/net/ethernet/freescale/fec_uio.c new file +10
-0+struct fec_enet_private *fep; +struct net_device *ndev; +u32 ecntl =ETHER_EN ; +static int dev_id; +bool reset_again; +int ret =0 ; + +/* Init network device */ + ndev =alloc_etherdev_mq (sizeof (struct fec_enet_private ) + +FEC_PRIV_SIZE ,FEC_MAX_Q );
Why do you need this. This is not a netdev driver, since it does not connect to the network stack.
drivers/net/ethernet/freescale/fec_uio.c line 393
Quoted 9 lines
drivers/net/ethernet/freescale/fec_uio.c new file +9
-0+static int +fec_enet_uio_remove (struct platform_device *pdev) +{ +struct net_device *ndev =platform_get_drvdata (pdev); +struct fec_enet_private *fep =netdev_priv (ndev); + +kfree (fec_dev); +iounmap (fep->hwp); +dma_free_coherent (&fep->pdev->dev, bd_size, cbd_base, bd_dma);
Don't you have to assume that the userspace driver has crashed and burned, leaving the hardware in an undefined state. It could still be receiving, into buffers we have no idea about. Don't you need to stop the hardware, and then wait for all DMA activity to stop, and only then can you free the buffer descriptors?
Andrew
PATCH 3/5 ARM64: defconfig: Add config for fec-uio
In reply to Apeksha GuptaThis enables fec-uio driver on imx8mm.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -320,6 +320,7 @@ CONFIG_BNX2X=m CONFIG_MACB=y CONFIG_THUNDER_NIC_PF=y CONFIG_FEC=y +CONFIG_FEC_UIO=m CONFIG_FSL_FMAN=y CONFIG_FSL_DPAA_ETH=y CONFIG_FSL_DPAA2_ETH=y
Signature · 1 line
2.17.1
PATCH 4/5 MAINTAINERS: add new file
In reply to Apeksha GuptaFor fec-uio driver, maintainers and fec_uio.c file added.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -7460,6 +7460,12 @@ F: drivers/net/ethernet/freescale/fec_phy.c F: drivers/net/ethernet/freescale/fec_phy.h F: drivers/net/ethernet/freescale/fec_ptp.c +FREESCALE IMX / FEC-UIO DRIVER +M: Apeksha Gupta <[email protected]> +M: Sachin Saxena <[email protected]> +F: Documentation/devicetree/bindings/net/fsl,fec-uio.yaml +F: drivers/net/ethernet/freescale/fec_uio.c + FREESCALE IMX / MXC FRAMEBUFFER DRIVER M: Sascha Hauer <[email protected]> R: Pengutronix Kernel Team <[email protected]>
Signature · 1 line
2.17.1
PATCH 5/5 arm64: dts: imx8mm-evk-dpdk: dts for fec-uio driver
In reply to Apeksha GuptaNew DTS file 'imx8mm-evk-dpdk.dts' is added to support fec ethernet device detection in user space DPDK application via fec-uio driver.
--- arch/arm64/boot/dts/freescale/Makefile | 1 + arch/arm64/boot/dts/freescale/imx8mm-evk-dpdk.dts | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 arch/arm64/boot/dts/freescale/imx8mm-evk-dpdk.dts
arch/arm64/boot/dts/freescale/Makefile +1 -0
@@ -33,6 +33,7 @@ dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-lx2162a-qds.dtb dtb-$(CONFIG_ARCH_MXC) += imx8mm-beacon-kit.dtb dtb-$(CONFIG_ARCH_MXC) += imx8mm-evk.dtb +dtb-$(CONFIG_ARCH_MXC) += imx8mm-evk-dpdk.dtb dtb-$(CONFIG_ARCH_MXC) += imx8mm-ddr4-evk.dtb dtb-$(CONFIG_ARCH_MXC) += imx8mm-icore-mx8mm-ctouch2.dtb dtb-$(CONFIG_ARCH_MXC) += imx8mm-icore-mx8mm-edimm2.2.dtb
arch/arm64/boot/dts/freescale/imx8mm-evk-dpdk.dts new file +10 -0
@@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 NXP + */ + +#include "imx8mm-evk.dts" + +&fec1 { + compatible = "fsl,imx8mm-fec-uio"; +};
Signature · 1 line
2.17.1
Re: [PATCH 5/5] arm64: dts: imx8mm-evk-dpdk: dts for fec-uio driver
Quoted 3 lines · Apeksha Gupta
New DTS file '
imx8mm-evk-dpdk.dts' is added to support fec ethernet device detection in user space DPDK application via fec-uio driver.
Isn't DPDK in its own parallel universe? It is not in mainline? A quick grep of drivers/net does not find anything. I think you are submitting this to the wrong universe. You should be using XDP with mainline.
Andrew
[[email protected] doesn't exist in the public, which is quite annoying when you reply to an email and the MTA doesn't accept it due to invalid domains]
Quoted 4 lines
This patch series introduce the fec-uio driver, supported for the inbuilt NIC found in the NXP i.MX 8M Mini SoC. Basic hardware initialization is performed in kernel via userspace input/output(UIO) to support FEC ethernet device detection in user space.
Could you elaborate for what this driver is needed? Doesn't the imx8mm already have a network driver? What is the difference between them?
As a user, I couldn't find what this is all about, neither in this commit message nor in the Kconfig help text.
Quoted 7 lines
Userspace PMD uses standard UIO interface to access kernel for PHY initialisation and for mapping the allocated memory of register & buffer descriptor with DPDK which gives access to non-cacheable memory for buffer descriptor.
Module fec-uio.ko will get generated. imx8mm-evk-dpdk.dtb is required to support fec-uio driver.
-michael