1 From 25d189ea016270d1d7ab67eafc57bc8989b5381c Mon Sep 17 00:00:00 2001
2 From: Akhil Goyal <akhil.goyal@nxp.com>
3 Date: Fri, 13 Apr 2018 15:41:28 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: support for userspace networking
6 This patch adds the userspace mode support to fsl_ppfe network driver.
7 In the new mode, basic hardware initialization is performed in kernel, while
8 the datapath and HIF handling is the responsibility of the userspace.
10 The new command line parameter is added to initialize the ppfe module
11 in userspace mode. By default the module remains in kernelspace networking
13 To enable userspace mode, use "insmod pfe.ko us=1"
15 Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
16 Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
18 drivers/staging/fsl_ppfe/pfe_eth.c | 21 +++++++++++++++++++--
19 drivers/staging/fsl_ppfe/pfe_mod.c | 15 +++++++++++++++
20 drivers/staging/fsl_ppfe/pfe_mod.h | 2 ++
21 3 files changed, 36 insertions(+), 2 deletions(-)
23 --- a/drivers/staging/fsl_ppfe/pfe_eth.c
24 +++ b/drivers/staging/fsl_ppfe/pfe_eth.c
25 @@ -2296,6 +2296,8 @@ static int pfe_eth_init_one(struct pfe *
30 + emac_txq_cnt = EMAC_TXQ_CNT;
31 /* Create an ethernet device instance */
32 ndev = alloc_etherdev_mq(sizeof(*priv), emac_txq_cnt);
34 @@ -2342,6 +2344,9 @@ static int pfe_eth_init_one(struct pfe *
44 @@ -2381,6 +2386,8 @@ static int pfe_eth_init_one(struct pfe *
45 netdev_err(ndev, "register_netdev() failed\n");
50 device_init_wakeup(&ndev->dev, WAKE_MAGIC);
52 if (!(priv->einfo->phy_flags & GEMAC_NO_PHY)) {
53 @@ -2392,6 +2399,12 @@ static int pfe_eth_init_one(struct pfe *
59 + phy_start(priv->phydev);
63 netif_carrier_on(ndev);
65 /* Create all the sysfs files */
66 @@ -2403,6 +2416,8 @@ static int pfe_eth_init_one(struct pfe *
72 unregister_netdev(ndev);
74 pfe_eth_mdio_exit(priv->mii_bus);
75 @@ -2449,9 +2464,11 @@ static void pfe_eth_exit_one(struct pfe_
77 netif_info(priv, probe, priv->ndev, "%s\n", __func__);
79 - pfe_eth_sysfs_exit(priv->ndev);
81 + pfe_eth_sysfs_exit(priv->ndev);
83 - unregister_netdev(priv->ndev);
84 + unregister_netdev(priv->ndev);
87 if (!(priv->einfo->phy_flags & GEMAC_NO_PHY))
88 pfe_phy_exit(priv->ndev);
89 --- a/drivers/staging/fsl_ppfe/pfe_mod.c
90 +++ b/drivers/staging/fsl_ppfe/pfe_mod.c
92 #include <linux/dma-mapping.h>
96 +module_param(us, uint, 0444);
97 +MODULE_PARM_DESC(us, "0: module enabled for kernel networking (DEFAULT)\n"
98 + "1: module enabled for userspace networking\n");
102 @@ -56,6 +60,9 @@ int pfe_probe(struct pfe *pfe)
107 + goto firmware_init;
109 rc = pfe_hif_lib_init(pfe);
112 @@ -64,6 +71,7 @@ int pfe_probe(struct pfe *pfe)
117 rc = pfe_firmware_init(pfe);
120 @@ -99,6 +107,9 @@ err_ctrl:
121 pfe_firmware_exit(pfe);
130 @@ -131,10 +142,14 @@ int pfe_remove(struct pfe *pfe)
132 pfe_firmware_exit(pfe);
139 pfe_hif_lib_exit(pfe);
145 --- a/drivers/staging/fsl_ppfe/pfe_mod.h
146 +++ b/drivers/staging/fsl_ppfe/pfe_mod.h
148 #include <linux/device.h>
149 #include <linux/elf.h>
151 +extern unsigned int us;