NET: FEC: dynamtic check DMA desc buff type
Subsystems (3)
PATCH v2 1/1 NET: FEC: dynamtic check DMA desc buff type
MX6 and mx28 support enhanced DMA descript buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descript buff. Check fec type and choose correct DAM descript buff type.
Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.
---
change from v1->v2:
1. remove CONFIG_FEC_PTP
2. fix code style issue. pass checkpatch
3. fix issue "return bdp++", return value is not added
4. remove unnecessary module parameter fec_ptp_enable
5. change get_nextdesc to fec_enet_get_nextdesc
drivers/net/ethernet/freescale/Kconfig | 9 +-- drivers/net/ethernet/freescale/Makefile | 3 +- drivers/net/ethernet/freescale/fec.c | 175 +++++++++++++++++++------------ drivers/net/ethernet/freescale/fec.h | 16 +-- 4 files changed, 116 insertions(+), 87 deletions(-)
drivers/net/ethernet/freescale/Kconfig +1 -8
@@ -26,6 +26,7 @@ config FEC ARCH_MXC || SOC_IMX28) default ARCH_MXC || SOC_IMX28 if ARM select PHYLIB + select PTP_1588_CLOCK ---help--- 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.
@@ -92,12 +93,4 @@ config GIANFAR This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx, and MPC86xx family of chips, and the FEC on the 8540. -config FEC_PTP - bool "PTP Hardware Clock (PHC)" - depends on FEC && ARCH_MXC && !SOC_IMX25 && !SOC_IMX27 && !SOC_IMX35 && !SOC_IMX5 - select PTP_1588_CLOCK - --help--- - Say Y here if you want to use PTP Hardware Clock (PHC) in the - driver. Only the basic clock operations have been implemented. - endif # NET_VENDOR_FREESCALE
drivers/net/ethernet/freescale/Makefile +1 -2
@@ -2,8 +2,7 @@ # Makefile for the Freescale network device drivers. # -obj-$(CONFIG_FEC) += fec.o -obj-$(CONFIG_FEC_PTP) += fec_ptp.o +obj-$(CONFIG_FEC) += fec.o fec_ptp.o obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y) obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o
drivers/net/ethernet/freescale/fec.c +108 -67
383 lines not on this page · raw message
drivers/net/ethernet/freescale/fec.h +6 -10
@@ -13,11 +13,9 @@#define FEC_H /****************************************************************************/ -#ifdef CONFIG_FEC_PTP #include <linux/clocksource.h> #include <linux/net_tstamp.h> #include <linux/ptp_clock_kernel.h> -#endif #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ defined(CONFIG_M520x) || defined(CONFIG_M532x) || \
@@ -94,14 +92,17 @@ struct bufdesc {unsigned short cbd_datlen;/* Data length */ unsigned short cbd_sc;/* Control and status info */ unsigned long cbd_bufaddr;/* Buffer address */ -#ifdef CONFIG_FEC_PTP +}; + +struct bufdesc_ex { +struct bufdesc desc;unsigned long cbd_esc;unsigned long cbd_prot;unsigned long cbd_bdu;unsigned long ts;unsigned short res0[4 ]; -#endif }; +#else struct bufdesc { unsigned short cbd_sc; /* Control and status info */
@@ -203,9 +204,7 @@ struct fec_enet_private {struct clk *clk_ipg;struct clk *clk_ahb; -#ifdef CONFIG_FEC_PTP struct clk *clk_ptp; -#endif /* The saved address of a sent-in-place packet/buffer, for skfree(). */ unsigned char *tx_bounce[TX_RING_SIZE ];
@@ -243,8 +242,8 @@ struct fec_enet_private {int full_duplex;struct completion mdio_done;int irq[FEC_IRQ_NUM ]; +int bufdesc_ex; -#ifdef CONFIG_FEC_PTP struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_caps;unsigned long last_overflow_check;
@@ -257,15 +256,12 @@ struct fec_enet_private {int hwts_rx_en;int hwts_tx_en; struct timer_list time_keep; -#endif }; -#ifdef CONFIG_FEC_PTP void fec_ptp_init (struct net_device *ndev,struct platform_device *pdev);void fec_ptp_start_cyclecounter (struct net_device *ndev);int fec_ptp_ioctl (struct net_device *ndev,struct ifreq *ifr,int cmd); -#endif /****************************************************************************/ #endif /* FEC_H */
Signature · 1 line
1.7.1
Quoted 3 lines · Frank Li
MX6 and mx28 support enhanced DMA descript buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descript buff. Check fec type and choose correct DAM descript buff type.
^^^
s/DAM/DMA/
s/descript/descriptor/g
[...]
drivers/net/ethernet/freescale/fec.c line 80
Quoted 10 lines
drivers/net/ethernet/freescale/fec.c +2
-0@@ -76,6 +76,8 @@#define FEC_QUIRK_USE_GASKET (1 << 2)/* Controller has GBIT support */ #define FEC_QUIRK_HAS_GBIT (1 << 3) +/* Controller has extend desc buffer */ +#define FEC_QUICK_HAS_BUFDESC_EX (1 << 4)
^^^^^
As Sascha has already pointed out, this should be 'QUIRK' rather than 'QUICK' (like in the preceeding lines)!
drivers/net/ethernet/freescale/fec.c static struct platform_device_id fec_devtype[] = { · line 99
Quoted 9 lines
drivers/net/ethernet/freescale/fec.c +2
-1static struct platform_device_id fec_devtype[] = { {@@ -93,7 +95,8 @@ static struct platform_device_id fec_devtype[] = { .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME, }, { .name = "imx6q-fec", - .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT, + .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | + FEC_QUICK_HAS_BUFDESC_EX,
^^^^^
same as above.
[...]
Quoted 10 lines
drivers/net/ethernet/freescale/fec.c +2
-0@@ -1574,6 +1617,8 @@ fec_probe(struct platform_device *pdev) fep->pdev = pdev; fep->dev_id = dev_id++; + fep->bufdesc_ex =0 ; +if (!fep->hwp) { ret = -ENOMEM ; goto failed_ioremap;
drivers/net/ethernet/freescale/fec.c fec_probe(struct platform_device *pdev) · line 1678
Quoted 7 lines
drivers/net/ethernet/freescale/fec.c +2
-1@@ -1628,19 +1673,19 @@ fec_probe(struct platform_device *pdev) goto failed_clk; } -#ifdef CONFIG_FEC_PTP fep->clk_ptp =devm_clk_get (&pdev->dev,"ptp" ); + fep->bufdesc_ex = + pdev->id_entry->driver_data &FEC_QUICK_HAS_BUFDESC_EX ;
^^^^^
same as above.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
2012/12/28 Lothar Wa?mann <[email protected]>:
Quoted 49 lines
Quoted 3 lines · Frank Li
MX6 and mx28 support enhanced DMA descript buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descript buff. Check fec type and choose correct DAM descript buff type.
^^^s/DAM/DMA/
s/descript/descriptor/g[...]
drivers/net/ethernet/freescale/fec.c line 80
Quoted 10 lines
drivers/net/ethernet/freescale/fec.c +2
-0@@ -76,6 +76,8 @@#define FEC_QUIRK_USE_GASKET (1 << 2)/* Controller has GBIT support */ #define FEC_QUIRK_HAS_GBIT (1 << 3) +/* Controller has extend desc buffer */ +#define FEC_QUICK_HAS_BUFDESC_EX (1 << 4)^^^^^As Sascha has already pointed out, this should be 'QUIRK' rather than 'QUICK' (like in the preceeding lines)!
drivers/net/ethernet/freescale/fec.c static struct platform_device_id fec_devtype[] = { · line 99
Quoted 9 lines
drivers/net/ethernet/freescale/fec.c +2
-1static struct platform_device_id fec_devtype[] = { {@@ -93,7 +95,8 @@ static struct platform_device_id fec_devtype[] = { .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME, }, { .name = "imx6q-fec", - .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT, + .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | + FEC_QUICK_HAS_BUFDESC_EX,^^^^^same as above.
[...]
Quoted 13 lines
drivers/net/ethernet/freescale/fec.c +2
-0@@ -1574,6 +1617,8 @@ fec_probe(struct platform_device *pdev) fep->pdev = pdev; fep->dev_id = dev_id++; + fep->bufdesc_ex =0 ; +if (!fep->hwp) { ret = -ENOMEM ; goto failed_ioremap;@@ -1628,19 +1673,19 @@ fec_probe(struct platform_device *pdev) goto failed_clk; }
Quoted 6 lines
drivers/net/ethernet/freescale/fec.c fec_probe(struct platform_device *pdev) · line 1678
Quoted 4 lines
drivers/net/ethernet/freescale/fec.c +2
-1-#ifdef CONFIG_FEC_PTP fep->clk_ptp =devm_clk_get (&pdev->dev,"ptp" ); + fep->bufdesc_ex = + pdev->id_entry->driver_data &FEC_QUICK_HAS_BUFDESC_EX ;^^^^^same as above.
Okay, I will fix it after new year holiday.
Quoted 13 lines
Lothar Wa?mann
--
___________________________________________________________Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________