net: fec_mxc: Fix DM driver issue in recv
PATCH v3 1/6 net: fec_mxc: Fix DM driver issue in recv
From: Ye Li <[email protected]>
When using ethernet DM driver, the recv interface has a change with non-DM interface, that driver needs to set the packet pointer and provide it to upper layer to process.
In fec driver, the fecmxc_recv functions does not handle the packet pointer parameter. This may cause crash in upper layer processing because the packet pointer is not set.
This patch allocates a buffer for the packet pointer and free it through free_pkt interface.
---
V3: None
V2:
Fix build warning for mx28
drivers/net/fec_mxc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/net/fec_mxc.c +23 -0
@@ -806,7 +806,16 @@ static int fec_recv(struct eth_device *dev)uint16_t bd_status;ulong addr, size, end;int i; + +#ifdef CONFIG_DM_ETH + *packetp =memalign (ARCH_DMA_MINALIGN ,FEC_MAX_PKT_SIZE ); +if (*packetp ==0 ) { +printf ("%s: error allocating packetp\n" , __func__); +return -ENOMEM ; + } +#else ALLOC_CACHE_ALIGN_BUFFER (uchar, buff,FEC_MAX_PKT_SIZE ); +#endif /* Check if any critical events have happened */ ievent =readl (&fec->eth->ievent);
@@ -882,8 +891,13 @@ static int fec_recv(struct eth_device *dev)#ifdef CONFIG_FEC_MXC_SWAP_PACKET swap_packet ((uint32_t *)addr, frame_length);#endif + +#ifdef CONFIG_DM_ETH +memcpy (*packetp, (char *)addr, frame_length); +#else memcpy (buff, (char *)addr, frame_length);net_process_received_packet (buff, frame_length); +#endif len = frame_length; }else {if (bd_status &FEC_RBD_ERR )
@@ -1201,10 +1215,19 @@ static int fecmxc_read_rom_hwaddr(struct udevice *dev)return fec_get_hwaddr (priv->dev_id, pdata->enetaddr); } +static int fecmxc_free_pkt (struct udevice *dev,uchar *packet,int length) +{ +if (packet) +free (packet); + +return 0 ; +} +static const struct eth_ops fecmxc_ops = { .start = fecmxc_init, .send = fecmxc_send, .recv = fecmxc_recv, + .free_pkt = fecmxc_free_pkt, .stop = fecmxc_halt, .write_hwaddr = fecmxc_set_hwaddr, .read_rom_hwaddr = fecmxc_read_rom_hwaddr,
Signature · 1 line
2.14.1
PATCH v3 2/6 net: fec_mxc: simplify fec_get_miibus
No need to provide two prototype for this function. Use ulong for the first parameter, then this function could be shared for DM/non DM case.
---
V3:
None
V2:
Drop uneccessary ulong
drivers/net/fec_mxc.c | 15 +++------------ include/netdev.h | 6 +----- 2 files changed, 4 insertions(+), 17 deletions(-)
drivers/net/fec_mxc.c +3 -12
@@ -1011,18 +1011,9 @@ static void fec_free_descs(struct fec_priv *fec)free (fec->tbd_base); } -#ifdef CONFIG_DM_ETH -struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id) -#else -struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id) -#endif +struct mii_dev *fec_get_miibus (ulong base_addr,int dev_id) { -#ifdef CONFIG_DM_ETH -struct fec_priv *priv =dev_get_priv (dev); -struct ethernet_regs *eth = priv->eth; -#else -struct ethernet_regs *eth = (struct ethernet_regs *)(ulong )base_addr; -#endif +struct ethernet_regs *eth = (struct ethernet_regs *)base_addr;struct mii_dev *bus;int ret;
@@ -1282,7 +1273,7 @@ static int fecmxc_probe(struct udevice *dev)fec_reg_setup (priv); priv->dev_id = (dev_id ==-1 ) ?0 : dev_id; - bus =fec_get_miibus (dev, dev_id); + bus =fec_get_miibus ((ulong )priv->eth, dev_id);if (!bus) { ret = -ENOMEM ; goto err_mii;
include/netdev.h +1 -5
@@ -119,11 +119,7 @@ static inline int pci_eth_init(bd_t *bis)return num; } -#ifdef CONFIG_DM_ETH -struct mii_dev *fec_get_miibus (struct udevice *dev,int dev_id); -#else -struct mii_dev *fec_get_miibus (uint32_t base_addr,int dev_id); -#endif +struct mii_dev *fec_get_miibus (ulong base_addr,int dev_id);#ifdef CONFIG_PHYLIB struct phy_device ;
Signature · 1 line
2.14.1
[U-Boot] net: fec_mxc: simplify fec_get_miibus
Hi Peng,
https://patchwork.ozlabs.org/patch/892193/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 3/6 net: fec: set dev->seq to priv->dev_id
In reply to Peng FanTo platforms has two enet interface, using dev->seq could avoid conflict.
i.MX6UL/ULL evk board net get the wrong MAC address from fuse, eth1 get MAC0 address, eth0 get MAC1 address from fuse. Set the priv->dev_id to device->seq as the real net interface alias id then .fec_get_hwaddr() read the related MAC address from fuse.
---
V3: None
V2: None
drivers/net/fec_mxc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/fec_mxc.c +2 -3
@@ -1250,7 +1250,6 @@ static int fecmxc_probe(struct udevice *dev)struct eth_pdata *pdata =dev_get_platdata (dev);struct fec_priv *priv =dev_get_priv (dev);struct mii_dev *bus =NULL ; -int dev_id =-1 ;uint32_t start;int ret;
@@ -1271,9 +1270,9 @@ static int fecmxc_probe(struct udevice *dev) }fec_reg_setup (priv); - priv->dev_id = (dev_id ==-1 ) ?0 : dev_id; - bus =fec_get_miibus ((ulong )priv->eth, dev_id); + priv->dev_id = dev->seq; + bus =fec_get_miibus ((ulong )priv->eth, dev->seq);if (!bus) { ret = -ENOMEM ; goto err_mii;
Signature · 1 line
2.14.1
[U-Boot] net: fec: set dev->seq to priv->dev_id
Hi Peng,
https://patchwork.ozlabs.org/patch/892212/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 4/6 net: fec: sharing MDIO for two enet controllers
In reply to Peng FanOn i.MX6SX, 6UL and 7D, there are two enet controllers each has a MDIO port. But Some boards share one MDIO port for the two enets. So introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate the MDIO port for sharing.
In Kconfig, user needs enable CONFIG_FEC_MXC_SHARE_MDIO first to enter the CONFIG_FEC_MXC_MDIO_BASE.
To i.MX28, adapt to use the new config
---
V3:
Fix build error. Add a new FEC_MXC_SHARE_MDIO Kconfig for MDIO.
drivers/net/Kconfig | 13 ++++++++++++- drivers/net/fec_mxc.c | 8 ++++++-- include/configs/mx28evk.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-)
drivers/net/Kconfig +12 -1
@@ -147,9 +147,20 @@ config ETHOC help This MAC is present in OpenRISC and Xtensa XTFPGA boards. +config FEC_MXC_SHARE_MDIO + bool "Share the MDIO bus for FEC controller" + depends on FEC_MXC + +config FEC_MXC_MDIO_BASE + hex "MDIO base address for the FEC controller" + depends on FEC_MXC_SHARE_MDIO + help + This specifies the MDIO registers base address. It is used when + two FEC controllers share MDIO bus. + config FEC_MXC bool "FEC Ethernet controller" - depends on MX5 || MX6 + depends on MX5 || MX6 || MX7 help This driver supports the 10/100 Fast Ethernet controller for NXP i.MX processors.
drivers/net/fec_mxc.c +6 -2
@@ -1145,12 +1145,12 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)#endif int ret; -#ifdef CONFIG_MX28 +#ifdef CONFIG_FEC_MXC_MDIO_BASE /* * The i.MX28 has two ethernet interfaces, but they are not equal. * Only the first one can access the MDIO bus. */ - base_mii =MXS_ENET0_BASE ; + base_mii =CONFIG_FEC_MXC_MDIO_BASE ;#else base_mii = addr;#endif
@@ -1272,7 +1272,11 @@ static int fecmxc_probe(struct udevice *dev)fec_reg_setup (priv); priv->dev_id = dev->seq; +#ifdef CONFIG_FEC_MXC_MDIO_BASE + bus =fec_get_miibus ((ulong )CONFIG_FEC_MXC_MDIO_BASE , dev->seq); +#else bus =fec_get_miibus ((ulong )priv->eth, dev->seq); +#endif if (!bus) { ret = -ENOMEM ; goto err_mii;
include/configs/mx28evk.h +1 -0
@@ -65,6 +65,7 @@/* FEC Ethernet on SoC */ #ifdef CONFIG_CMD_NET #define CONFIG_FEC_MXC +#define CONFIG_FEC_MXC_MDIO_BASE MXS_ENET0_BASE#define CONFIG_MX28_FEC_MAC_IN_OCOTP #endif
Signature · 1 line
2.14.1
[U-Boot] net: fec: sharing MDIO for two enet controllers
Hi Peng,
https://patchwork.ozlabs.org/patch/892216/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 5/6 net: fex_mxc: add i.MX6UL/SX/SL compatible
In reply to Peng FanAdd i.MX6UL/SX/SL compatible.
---
V3: None
V2: None
drivers/net/fec_mxc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/fec_mxc.c +3 -0
@@ -1342,6 +1342,9 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)static const struct udevice_id fecmxc_ids[] = { { .compatible ="fsl,imx6q-fec" }, + { .compatible ="fsl,imx6sl-fec" }, + { .compatible ="fsl,imx6sx-fec" }, + { .compatible ="fsl,imx6ul-fec" }, { } };
Signature · 1 line
2.14.1
[U-Boot] net: fex_mxc: add i.MX6UL/SX/SL compatible
Hi Peng,
https://patchwork.ozlabs.org/patch/892214/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 6/6 net: fec: Fix issue in DM probe timeout
In reply to Peng FanFrom: Ye Li <[email protected]>
Since the probe function has changed to reset FEC controller prior than setup PHY. If reset FEC controller timeout, the priv->phydev is not initialized, so can't free it.
---
V3: New
drivers/net/fec_mxc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/fec_mxc.c +1 -2
@@ -1291,12 +1291,11 @@ static int fecmxc_probe(struct udevice *dev)return 0 ; -err_timeout: -free (priv->phydev); err_phy:mdio_unregister (bus);free (bus); err_mii: +err_timeout:fec_free_descs (priv);return ret; }
Signature · 1 line
2.14.1
PATCH v3 6/6 net: fec: Fix issue in DM probe timeout
Quoted 7 lines · Peng Fan
From: Ye Li <[email protected]>
Since the probe function has changed to reset FEC controller prior than setup PHY. If reset FEC controller timeout, the
priv->phydevis not initialized, so can't free it.Signed-off-by Ye Li <[email protected]>
[U-Boot] net: fec: Fix issue in DM probe timeout
In reply to Peng FanHi Peng,
https://patchwork.ozlabs.org/patch/892217/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
Hi Peng,
https://patchwork.ozlabs.org/patch/892215/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe