Skip to contentSkip to conversation

NET: FEC: dynamtic check DMA desc buff type

PATCH Applied Frank Li 6 participants 7 messages Jan 4, 2013 – Mar 20, 2013

Subsystems (3)
lore
Share & tools
lore

Frank Li

author
#0 lore raw

PATCH v3 1/1 NET: FEC: dynamtic check DMA desc buff type

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

---
change from v2->v3:
1. s/DAM/DMA/
2. s/descript/descriptor/g
3. s/QUICK/QUIRK/g

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
index ec490d7..6048dc8 100644
@@ -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
index d4d19b3..b7d58fe 100644
@@ -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
index c5a3bc1..4862394 100644
@@ -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
Acked-by on v3 1/1
#1 lore raw
Quoted 8 lines · Frank Li

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Two minor comments, otherwise:

drivers/net/ethernet/freescale/fec.c fec_probe(struct platform_device *pdev) · line 1621

Quoted 6 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;
+

fep already is zeroed, so this is unnecessary.

Quoted 6 lines
drivers/net/ethernet/freescale/fec.c +0 -0
 	if (!fep->hwp) {
 		ret = -ENOMEM;
 		goto failed_ioremap;
@@ -1628,19 +1673,19 @@ fec_probe(struct platform_device *pdev)
 		goto failed_clk;
 	}

drivers/net/ethernet/freescale/fec.c fec_probe(struct platform_device *pdev) · line 1682

Quoted 10 lines
drivers/net/ethernet/freescale/fec.c +3 -2
 
-#ifdef CONFIG_FEC_PTP
 	fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
+	fep->bufdesc_ex =
+		pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
 	if (IS_ERR(fep->clk_ptp)) {
 		ret = PTR_ERR(fep->clk_ptp);
-		goto failed_clk;
+		fep->bufdesc_ex = 0;
 	}

Since you remove the goto you can remove the 'ret =' aswell.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer Applied
#2 lore raw
In reply to Frank Li

From: Frank Li <[email protected]>
Date: Fri, 4 Jan 2013 10:04:23 +0800

Quoted 8 lines

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Applied.

#3 lore raw
In reply to Frank Li

Hello,

Quoted 6 lines · Frank Li

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Your patch (now as ff43da86c69d76a726ffe7d1666148960dc1d108 in v3.9-rc1) breaks building with CONFIG_FEC=m:

ERROR: "fec_ptp_init" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_ioctl" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_start_cyclecounter" [drivers/net/ethernet/freescale/fec.ko] undefined!

IMHO you should build fec.o and fec_ptp.o into the same module as they cannot live without each other anyhow.

Having said I wonder if it would be worthwile to support FEC without PTP_1588_CLOCK. For example make the above three functions static inlines if CONFIG_PTP_1588_CLOCK=n and drop the select on the latter.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw
Quoted 12 lines · Uwe Kleine-K?nig

Hello,

Quoted 6 lines · Frank Li

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Your patch (now as ff43da86c69d76a726ffe7d1666148960dc1d108 in v3.9-rc1) breaks building with CONFIG_FEC=m:

Quoted 6 lines

ERROR: "fec_ptp_init" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_ioctl" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_start_cyclecounter" [drivers/net/ethernet/freescale/fec.ko] undefined!

IMHO you should build fec.o and fec_ptp.o into the same module as they cannot live without each other anyhow.

They are in the same module. So I don't see how that error is possible.

Quoted 3 lines

Having said I wonder if it would be worthwile to support FEC without PTP_1588_CLOCK. For example make the above three functions static inlines if CONFIG_PTP_1588_CLOCK=n and drop the select on the latter.

See previous discussions:
<http://thread.gmane.org/gmane.linux.kernel/1363200/focus=1376659>,
<http://thread.gmane.org/gmane.linux.network/247963>,
<http://thread.gmane.org/gmane.linux.network/247823/focus=248173>

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#5 lore raw
Quoted 13 lines · Ben Hutchings
Quoted 12 lines · Uwe Kleine-K?nig

Hello,

Quoted 6 lines · Frank Li

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Your patch (now as ff43da86c69d76a726ffe7d1666148960dc1d108 in v3.9-rc1) breaks building with CONFIG_FEC=m:

Quoted 8 lines
Quoted 6 lines

ERROR: "fec_ptp_init" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_ioctl" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_start_cyclecounter" [drivers/net/ethernet/freescale/fec.ko] undefined!

IMHO you should build fec.o and fec_ptp.o into the same module as they cannot live without each other anyhow.

They are in the same module. So I don't see how that error is possible.

Sorry, I misread the Makefile. They are either both built as modules or both built-in, but they are separate modules.

Ben.

Quoted 11 lines
Quoted 3 lines

Having said I wonder if it would be worthwile to support FEC without PTP_1588_CLOCK. For example make the above three functions static inlines if CONFIG_PTP_1588_CLOCK=n and drop the select on the latter.

See previous discussions:
<http://thread.gmane.org/gmane.linux.kernel/1363200/focus=1376659>,
<http://thread.gmane.org/gmane.linux.network/247963>,
<http://thread.gmane.org/gmane.linux.network/247823/focus=248173>

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#6 lore raw
In reply to Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-K?nig

Hello,

Quoted 4 lines · Frank Li

MX6 and mx28 support enhanced DMA descriptor buff to support 1588 ptp. But MX25, MX3x, MX5x can't support enhanced DMA descriptor buff. Check fec type and choose correct DMA descriptor buff type.

Quoted 8 lines
Quoted 2 lines

Remove static config CONFIG_FEC_PTP.
ptp function will be auto detected.

Your patch (now as ff43da86c69d76a726ffe7d1666148960dc1d108 in v3.9-rc1) breaks building with CONFIG_FEC=m:

ERROR: "fec_ptp_init" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_ioctl" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_start_cyclecounter" [drivers/net/ethernet/freescale/fec.ko] undefined!

What about this fix?

---
 drivers/net/ethernet/freescale/fec_ptp.c |    3 +++
 1 file changed, 3 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/freescale/fec_ptp.c
index 1f17ca0..0d8df40 100644

drivers/net/ethernet/freescale/fec_ptp.c +1 -0
@@ -128,6 +128,7 @@ void fec_ptp_start_cyclecounter(struct net_device *ndev)
 
 	spin_unlock_irqrestore(&fep->tmreg_lock, flags);
 }
+EXPORT_SYMBOL(fec_ptp_start_cyclecounter);
 
 /**
  * fec_ptp_adjfreq - adjust ptp cycle frequency
@@ -318,6 +319,7 @@ int fec_ptp_ioctl(struct net_device *ndev, struct

ifreq *ifr, int cmd)
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-EFAULT : 0;
}
+EXPORT_SYMBOL(fec_ptp_ioctl);

/**
* fec_time_keep - call timecounter_read every second to avoid timer overrun
@@ -383,3 +385,4 @@ void fec_ptp_init(struct net_device *ndev, struct platform_device *pdev)
pr_info("registered PHC device on %s\n", ndev->name);
}
}
+EXPORT_SYMBOL(fec_ptp_init);

Signature · 1 line
1.7.9.5