[v11,1/5] net/enetfec: introduce NXP ENETFEC driver

Message ID 20211115071940.12942-2-apeksha.gupta@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series drivers/net: add NXP ENETFEC driver |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Apeksha Gupta Nov. 15, 2021, 7:19 a.m. UTC
  ENETFEC (Fast Ethernet Controller) is a network poll mode driver
for NXP SoC i.MX 8M Mini.

This patch adds skeleton for enetfec driver with probe function.

Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 MAINTAINERS                            |   7 ++
 doc/guides/nics/enetfec.rst            | 133 +++++++++++++++++++++++++
 doc/guides/nics/features/enetfec.ini   |   9 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_21_11.rst |   5 +
 drivers/net/enetfec/enet_ethdev.c      |  82 +++++++++++++++
 drivers/net/enetfec/enet_ethdev.h      |  18 ++++
 drivers/net/enetfec/enet_pmd_logs.h    |  31 ++++++
 drivers/net/enetfec/meson.build        |  10 ++
 drivers/net/enetfec/version.map        |   3 +
 drivers/net/meson.build                |   1 +
 11 files changed, 300 insertions(+)
 create mode 100644 doc/guides/nics/enetfec.rst
 create mode 100644 doc/guides/nics/features/enetfec.ini
 create mode 100644 drivers/net/enetfec/enet_ethdev.c
 create mode 100644 drivers/net/enetfec/enet_ethdev.h
 create mode 100644 drivers/net/enetfec/enet_pmd_logs.h
 create mode 100644 drivers/net/enetfec/meson.build
 create mode 100644 drivers/net/enetfec/version.map
  

Comments

Ferruh Yigit Nov. 15, 2021, 10:07 a.m. UTC | #1
On 11/15/2021 7:19 AM, Apeksha Gupta wrote:
> ENETFEC (Fast Ethernet Controller) is a network poll mode driver
> for NXP SoC i.MX 8M Mini.
> 
> This patch adds skeleton for enetfec driver with probe function.
> 
> Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
> Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

<...>

> --- /dev/null
> +++ b/drivers/net/enetfec/enet_ethdev.c
> @@ -0,0 +1,82 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright 2020-2021 NXP
> + */
> +
> +#include <stdio.h>
> +#include <fcntl.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <errno.h>
> +#include <sys/mman.h>
> +#include <rte_kvargs.h>
> +#include <ethdev_vdev.h>
> +#include <rte_bus_vdev.h>
> +#include <rte_dev.h>
> +#include <rte_ether.h>
> +#include "enet_pmd_logs.h"
> +#include "enet_ethdev.h"

Most probably you don't need all above headers, at least not in this patch.
  
Ferruh Yigit March 21, 2023, 6:03 p.m. UTC | #2
On 11/15/2021 7:19 AM, Apeksha Gupta wrote:
> +ENETFEC
> +-------
> +
> +This section provides an overview of the NXP ENETFEC and how it is
> +integrated into the DPDK. Driver is taken as **experimental** as driver
> +depends on a Linux kernel module 'enetfec-uio', which is not upstreamed
> +yet.


Hi Apeksha, Hemant,

I wonder what was the fate of the 'enetfec-uio' kernel module, is it
upstreamed?
Is there any change in the status of the driver?
  
Sachin Saxena (OSS) March 23, 2023, 6 a.m. UTC | #3
On 3/21/2023 11:33 PM, Ferruh Yigit wrote:
> On 11/15/2021 7:19 AM, Apeksha Gupta wrote:
>> +ENETFEC
>> +-------
>> +
>> +This section provides an overview of the NXP ENETFEC and how it is
>> +integrated into the DPDK. Driver is taken as **experimental** as driver
>> +depends on a Linux kernel module 'enetfec-uio', which is not upstreamed
>> +yet.
> 
> 
> Hi Apeksha, Hemant,
> 
> I wonder what was the fate of the 'enetfec-uio' kernel module, is it
> upstreamed?
> Is there any change in the status of the driver?
> 

It is not up-streamed yet as we got some review comments from internal 
Linux team. The re-use of PHY handling in enetfec-uio driver is point of 
objection.
So, we are currently working on changing the design and most probably, 
we may design new driver w/o UIO support.


---
Thanks,
Sachin Saxena
(NXP)
  
Ferruh Yigit March 23, 2023, 11:07 a.m. UTC | #4
On 3/23/2023 6:00 AM, Sachin Saxena (OSS) wrote:
> On 3/21/2023 11:33 PM, Ferruh Yigit wrote:
>> On 11/15/2021 7:19 AM, Apeksha Gupta wrote:
>>> +ENETFEC
>>> +-------
>>> +
>>> +This section provides an overview of the NXP ENETFEC and how it is
>>> +integrated into the DPDK. Driver is taken as **experimental** as driver
>>> +depends on a Linux kernel module 'enetfec-uio', which is not upstreamed
>>> +yet.
>>
>>
>> Hi Apeksha, Hemant,
>>
>> I wonder what was the fate of the 'enetfec-uio' kernel module, is it
>> upstreamed?
>> Is there any change in the status of the driver?
>>
> 
> It is not up-streamed yet as we got some review comments from internal
> Linux team. The re-use of PHY handling in enetfec-uio driver is point of
> objection.
> So, we are currently working on changing the design and most probably,
> we may design new driver w/o UIO support.
> 

Got it, thanks for update.

I assume users still can get this kernel module via SDK, right?
  
Sachin Saxena (OSS) March 23, 2023, 11:09 a.m. UTC | #5
On 3/23/2023 4:37 PM, Ferruh Yigit wrote:
> On 3/23/2023 6:00 AM, Sachin Saxena (OSS) wrote:
>> On 3/21/2023 11:33 PM, Ferruh Yigit wrote:
>>> On 11/15/2021 7:19 AM, Apeksha Gupta wrote:
>>>> +ENETFEC
>>>> +-------
>>>> +
>>>> +This section provides an overview of the NXP ENETFEC and how it is
>>>> +integrated into the DPDK. Driver is taken as **experimental** as driver
>>>> +depends on a Linux kernel module 'enetfec-uio', which is not upstreamed
>>>> +yet.
>>>
>>>
>>> Hi Apeksha, Hemant,
>>>
>>> I wonder what was the fate of the 'enetfec-uio' kernel module, is it
>>> upstreamed?
>>> Is there any change in the status of the driver?
>>>
>>
>> It is not up-streamed yet as we got some review comments from internal
>> Linux team. The re-use of PHY handling in enetfec-uio driver is point of
>> objection.
>> So, we are currently working on changing the design and most probably,
>> we may design new driver w/o UIO support.
>>
> 
> Got it, thanks for update.
> 
> I assume users still can get this kernel module via SDK, right?
> 

Yes.
  

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index e157e12f88..2aa81efe20 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -889,6 +889,13 @@  F: drivers/net/enetc/
 F: doc/guides/nics/enetc.rst
 F: doc/guides/nics/features/enetc.ini
 
+NXP enetfec - EXPERIMENTAL
+M: Apeksha Gupta <apeksha.gupta@nxp.com>
+M: Sachin Saxena <sachin.saxena@nxp.com>
+F: drivers/net/enetfec/
+F: doc/guides/nics/enetfec.rst
+F: doc/guides/nics/features/enetfec.ini
+
 NXP pfe
 M: Gagandeep Singh <g.singh@nxp.com>
 F: doc/guides/nics/pfe.rst
diff --git a/doc/guides/nics/enetfec.rst b/doc/guides/nics/enetfec.rst
new file mode 100644
index 0000000000..6a86295e34
--- /dev/null
+++ b/doc/guides/nics/enetfec.rst
@@ -0,0 +1,133 @@ 
+.. SPDX-License-Identifier: BSD-3-Clause
+   Copyright 2021 NXP
+
+ENETFEC Poll Mode Driver
+========================
+
+The ENETFEC NIC PMD (**librte_net_enetfec**) provides poll mode driver
+support for the inbuilt NIC found in the ** NXP i.MX 8M Mini** SoC.
+
+More information can be found at NXP Official Website
+<https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-processors/i-mx-8m-mini-arm-cortex-a53-cortex-m4-audio-voice-video:i.MX8MMINI>
+
+ENETFEC
+-------
+
+This section provides an overview of the NXP ENETFEC and how it is
+integrated into the DPDK. Driver is taken as **experimental** as driver
+depends on a Linux kernel module 'enetfec-uio', which is not upstreamed
+yet.
+
+Contents summary
+
+- ENETFEC overview
+- ENETFEC features
+- Supported ENETFEC SoCs
+- Prerequisites
+- Driver compilation and testing
+- Limitations
+
+ENETFEC Overview
+~~~~~~~~~~~~~~~~
+The i.MX 8M Mini Media Applications Processor is built to achieve both
+high performance and low power consumption. ENETFEC PMD is a hardware
+programmable packet forwarding engine to provide high performance
+Ethernet interface. It has only 1 GB Ethernet interface with RJ45
+connector.
+
+The diagram below shows a system level overview of ENETFEC:
+
+  .. code-block:: console
+
+   =====================================================
+   Userspace
+        +-----------------------------------------+
+        |             ENETFEC Driver              |
+        |        +-------------------------+      |
+        |        | virtual ethernet device |      |
+        +-----------------------------------------+
+                          ^   |
+                          |   |
+                          |   |
+                     RXQ  |   |	TXQ
+                          |   |
+                          |   v
+   =====================================================
+   Kernel Space
+                       +---------+
+                       | fec-uio |
+   ====================+=========+======================
+   Hardware
+        +-----------------------------------------+
+        |           i.MX 8M MINI EVK              |
+        |               +-----+                   |
+        |               | MAC |                   |
+        +---------------+-----+-------------------+
+                        | PHY |
+                        +-----+
+
+ENETFEC Ethernet driver is traditional DPDK PMD driver running in the
+userspace.'fec-uio' is the kernel driver. The MAC and PHY are the hardware
+blocks. ENETFEC 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. net_enetfec is logical Ethernet interface, created by ENETFEC
+driver.
+
+- ENETFEC driver registers the device in virtual device driver.
+- RTE framework scans and will invoke the probe function of ENETFEC driver.
+- The probe function will set the basic device registers and also setups BD rings.
+- On packet Rx the respective BD Ring status bit is set which is then used for
+  packet processing.
+- Then Tx is done first followed by Rx via logical interfaces.
+
+ENETFEC Features
+~~~~~~~~~~~~~~~~~
+
+- Linux
+- ARMv8
+
+Supported ENETFEC SoCs
+~~~~~~~~~~~~~~~~~~~~~~
+
+- i.MX 8M Mini
+
+Prerequisites
+~~~~~~~~~~~~~
+
+There are three main pre-requisites for executing ENETFEC PMD on a i.MX 8M Mini
+compatible board:
+
+1. **ARM 64 Tool Chain**
+
+   For example, the `*aarch64* Linaro Toolchain <https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz>`_.
+
+2. **Linux Kernel**
+
+   It can be obtained from `NXP's Github hosting <https://source.codeaurora.org/external/qoriq/qoriq-components/linux>`_.
+
+.. note::
+
+   Branch is 'lf-5.10.y'
+
+3. **Rootfile system**
+
+   Any *aarch64* supporting filesystem can be used. For example,
+   Ubuntu 18.04 LTS (Bionic) or 20.04 LTS(Focal) userland which can be obtained
+   from `here <http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.1-base-arm64.tar.gz>`_.
+
+4. The Ethernet device will be registered as virtual device, so ENETFEC has dependency on
+   **rte_bus_vdev** library and it is mandatory to use `--vdev` with value `net_enetfec` to
+   run DPDK application.
+
+Driver compilation and testing
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Follow instructions available in the document
+:ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+to launch **dpdk-testpmd**
+
+Limitations
+~~~~~~~~~~~
+
+- Multi queue is not supported.
diff --git a/doc/guides/nics/features/enetfec.ini b/doc/guides/nics/features/enetfec.ini
new file mode 100644
index 0000000000..bdfbdbd9d4
--- /dev/null
+++ b/doc/guides/nics/features/enetfec.ini
@@ -0,0 +1,9 @@ 
+;
+; Supported features of the 'enetfec' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux		     = Y
+ARMv8		     = Y
+Usage doc	     = Y
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 784d5d39f6..777fdab4a0 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -26,6 +26,7 @@  Network Interface Controller Drivers
     e1000em
     ena
     enetc
+    enetfec
     enic
     fm10k
     hinic
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 01923e2deb..6e80805cfd 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -221,6 +221,11 @@  New Features
   * Added NIC offloads for the PMD on Windows (TSO, VLAN strip, CRC keep).
   * Added socket direct mode bonding support.
 
+* **Added NXP ENETFEC PMD.**
+
+  Added the new ENETFEC driver for the NXP IMX8MMEVK platform. See the
+  :doc:`../nics/enetfec` NIC driver guide for more details on this new driver.
+
 * **Updated Solarflare network PMD.**
 
   Updated the Solarflare ``sfc_efx`` driver with changes including:
diff --git a/drivers/net/enetfec/enet_ethdev.c b/drivers/net/enetfec/enet_ethdev.c
new file mode 100644
index 0000000000..56bd199191
--- /dev/null
+++ b/drivers/net/enetfec/enet_ethdev.c
@@ -0,0 +1,82 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <rte_kvargs.h>
+#include <ethdev_vdev.h>
+#include <rte_bus_vdev.h>
+#include <rte_dev.h>
+#include <rte_ether.h>
+#include "enet_pmd_logs.h"
+#include "enet_ethdev.h"
+
+#define ENETFEC_NAME_PMD                net_enetfec
+
+static int
+enetfec_eth_init(struct rte_eth_dev *dev)
+{
+	rte_eth_dev_probing_finish(dev);
+	return 0;
+}
+
+static int
+pmd_enetfec_probe(struct rte_vdev_device *vdev)
+{
+	struct rte_eth_dev *dev = NULL;
+	struct enetfec_private *fep;
+	const char *name;
+	int rc;
+
+	name = rte_vdev_device_name(vdev);
+	ENETFEC_PMD_LOG(INFO, "Initializing pmd_fec for %s", name);
+
+	dev = rte_eth_vdev_allocate(vdev, sizeof(*fep));
+	if (dev == NULL)
+		return -ENOMEM;
+
+	/* setup board info structure */
+	fep = dev->data->dev_private;
+	fep->dev = dev;
+	rc = enetfec_eth_init(dev);
+	if (rc)
+		goto failed_init;
+
+	return 0;
+
+failed_init:
+	ENETFEC_PMD_ERR("Failed to init");
+	return rc;
+}
+
+static int
+pmd_enetfec_remove(struct rte_vdev_device *vdev)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+	int ret;
+
+	/* find the ethdev entry */
+	eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev));
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	ret = rte_eth_dev_release_port(eth_dev);
+	if (ret != 0)
+		return -EINVAL;
+
+	ENETFEC_PMD_INFO("Release enetfec sw device");
+	return 0;
+}
+
+static struct rte_vdev_driver pmd_enetfec_drv = {
+	.probe = pmd_enetfec_probe,
+	.remove = pmd_enetfec_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(ENETFEC_NAME_PMD, pmd_enetfec_drv);
+RTE_LOG_REGISTER_DEFAULT(enetfec_logtype_pmd, NOTICE);
diff --git a/drivers/net/enetfec/enet_ethdev.h b/drivers/net/enetfec/enet_ethdev.h
new file mode 100644
index 0000000000..7e941da972
--- /dev/null
+++ b/drivers/net/enetfec/enet_ethdev.h
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#ifndef __ENETFEC_ETHDEV_H__
+#define __ENETFEC_ETHDEV_H__
+
+/*
+ * ENETFEC can support 1 rx and tx queue..
+ */
+
+#define ENETFEC_MAX_Q		1
+
+struct enetfec_private {
+	struct rte_eth_dev	*dev;
+};
+
+#endif /*__ENETFEC_ETHDEV_H__*/
diff --git a/drivers/net/enetfec/enet_pmd_logs.h b/drivers/net/enetfec/enet_pmd_logs.h
new file mode 100644
index 0000000000..e7b3964a0e
--- /dev/null
+++ b/drivers/net/enetfec/enet_pmd_logs.h
@@ -0,0 +1,31 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#ifndef _ENETFEC_LOGS_H_
+#define _ENETFEC_LOGS_H_
+
+extern int enetfec_logtype_pmd;
+
+/* PMD related logs */
+#define ENETFEC_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, enetfec_logtype_pmd, "\nfec_net: %s()" \
+		fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() ENET_PMD_LOG(DEBUG, " >>")
+
+#define ENETFEC_PMD_DEBUG(fmt, args...) \
+	ENETFEC_PMD_LOG(DEBUG, fmt, ## args)
+#define ENETFEC_PMD_ERR(fmt, args...) \
+	ENETFEC_PMD_LOG(ERR, fmt, ## args)
+#define ENETFEC_PMD_INFO(fmt, args...) \
+	ENETFEC_PMD_LOG(INFO, fmt, ## args)
+
+#define ENETFEC_PMD_WARN(fmt, args...) \
+	ENETFEC_PMD_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define ENETFEC_DP_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, fmt, ## args)
+
+#endif /* _ENETFEC_LOGS_H_ */
diff --git a/drivers/net/enetfec/meson.build b/drivers/net/enetfec/meson.build
new file mode 100644
index 0000000000..42ec41502b
--- /dev/null
+++ b/drivers/net/enetfec/meson.build
@@ -0,0 +1,10 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2021 NXP
+
+if not is_linux
+    build = false
+    reason = 'only supported on linux'
+endif
+
+sources = files(
+        'enet_ethdev.c')
diff --git a/drivers/net/enetfec/version.map b/drivers/net/enetfec/version.map
new file mode 100644
index 0000000000..b66517b171
--- /dev/null
+++ b/drivers/net/enetfec/version.map
@@ -0,0 +1,3 @@ 
+DPDK_22 {
+        local: *;
+};
diff --git a/drivers/net/meson.build b/drivers/net/meson.build
index bcf488f203..04be346509 100644
--- a/drivers/net/meson.build
+++ b/drivers/net/meson.build
@@ -19,6 +19,7 @@  drivers = [
         'e1000',
         'ena',
         'enetc',
+        'enetfec',
         'enic',
         'failsafe',
         'fm10k',