Skip to contentSkip to conversation

net: fec: do some cleanup for the driver

PATCH Superseded Wei Fang 4 participants 11 messages Nov 17, 2025 – Nov 18, 2025

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wei Fang

author maintainer
#0 lore raw

v2 cover net: fec: do some cleanup for the driver

This patch set removes some unnecessary or invalid code from the FEC driver. See each patch for details.

---
v2 changes:
1. Improve the commit message
2. Remove the "#ifdef" guard for fec_enet_register_offset_6ul
3. Add a BUILD_BUG_ON() test to ensure that FEC_ENET_XDP_HEADROOM provides the required alignment.
4. Collect Reviewed-by tag
v1: https://lore.kernel.org/imx/[email protected]/
---

Wei Fang (5):
net: fec: remove useless conditional preprocessor directives
net: fec: simplify the conditional preprocessor directives
net: fec: remove struct fec_enet_priv_txrx_info
net: fec: remove rx_align from fec_enet_private
net: fec: remove duplicate macros of the BD status

 drivers/net/ethernet/freescale/fec.h      |  30 +------
 drivers/net/ethernet/freescale/fec_main.c | 101 ++++++++++------------
 2 files changed, 47 insertions(+), 84 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v2 1/5 net: fec: remove useless conditional preprocessor directives

The conditional preprocessor directive was added to fix build errors on the MCF5272 platform, see commit d13919301d9a ("net: fec: Fix build for MCF5272"). The compilation errors were originally caused by some register macros not being defined on that platform.

The driver now uses quirks to dynamically handle platform differences, and for MCF5272, its quirks is 0, so it does not support RACC and GBIT Ethernet. So these preprocessor directives are no longer required and can be safely removed without causing build or functional issue.

---
 drivers/net/ethernet/freescale/fec_main.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +0 -6
index 742f3e81cc7c..e0e84f2979c8 100644
@@ -1773,7 +1773,6 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
 	__fec32 cbd_bufaddr;
 	u32 sub_len = 4;
 
-#if !defined(CONFIG_M5272)
 	/*If it has the FEC_QUIRK_HAS_RACC quirk property, the bit of
 	 * FEC_RACC_SHIFT16 is set by default in the probe function.
 	 */
@@ -1781,7 +1780,6 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
 		data_start += 2;
 		sub_len += 2;
 	}
-#endif
 
 #if defined(CONFIG_COLDFIRE) && !defined(CONFIG_COLDFIRE_COHERENT_DMA)
 	/*
@@ -2515,9 +2513,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 		phy_set_max_speed(phy_dev, 1000);
 		phy_remove_link_mode(phy_dev,
 				     ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
-#if !defined(CONFIG_M5272)
 		phy_support_sym_pause(phy_dev);
-#endif
 	}
 	else
 		phy_set_max_speed(phy_dev, 100);
@@ -4400,11 +4396,9 @@ fec_probe(struct platform_device *pdev)
 	fep->num_rx_queues = num_rx_qs;
 	fep->num_tx_queues = num_tx_qs;
 
-#if !defined(CONFIG_M5272)
 	/* default enable pause frame auto negotiation */
 	if (fep->quirks & FEC_QUIRK_HAS_GBIT)
 		fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
-#endif
 
 	/* Select default pin state */
 	pinctrl_pm_select_default_state(&pdev->dev);
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v2 2/5 net: fec: simplify the conditional preprocessor directives

In reply to Wei Fang

From the Kconfig file, we can see CONFIG_FEC depends on the following platform-related options.

ColdFire: M523x, M527x, M5272, M528x, M520x and M532x
S32: ARCH_S32 (ARM64)
i.MX: SOC_IMX28 and ARCH_MXC (ARM and ARM64)

Based on the code of fec driver, only some macro definitions on the M5272 platform are different from those on other platforms. Therefore, we can simplify the following complex preprocessor directives to "if !defined(CONFIG_M5272)".

"#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
     defined(CONFIG_M528x) || defined(CONFIG_M520x) || \
     defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
     defined(CONFIG_ARM64)"

In addition, remove the "#ifdef" guard for fec_enet_register_offset_6ul, so that we can safely remove the preprocessor directive from fec_enet_get_regs().

---
 drivers/net/ethernet/freescale/fec.h      |  4 +-
 drivers/net/ethernet/freescale/fec_main.c | 57 +++++++++--------------
 2 files changed, 23 insertions(+), 38 deletions(-)
drivers/net/ethernet/freescale/fec.h +1 -3
index 41e0d85d15da..8e438f6e7ec4 100644
@@ -24,9 +24,7 @@
 #include <linux/timecounter.h>
 #include <net/xdp.h>
 
-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
-    defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
-    defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
+#if !defined(CONFIG_M5272) || defined(CONFIG_COMPILE_TEST)
 /*
  *	Just figures, Motorola would have to change the offsets for
  *	registers in the same peripheral device on different models
drivers/net/ethernet/freescale/fec_main.c +22 -35

94 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 2/5
#3 lore raw

Re: [PATCH v2 net-next 2/5] net: fec: simplify the conditional preprocessor directives

Quoted 17 lines · Wei Fang

From the Kconfig file, we can see CONFIG_FEC depends on the following platform-related options.

ColdFire: M523x, M527x, M5272, M528x, M520x and M532x
S32: ARCH_S32 (ARM64)
i.MX: SOC_IMX28 and ARCH_MXC (ARM and ARM64)

Based on the code of fec driver, only some macro definitions on the M5272 platform are different from those on other platforms. Therefore, we can simplify the following complex preprocessor directives to "if !defined(CONFIG_M5272)".

"#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
     defined(CONFIG_M528x) || defined(CONFIG_M520x) || \
     defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
     defined(CONFIG_ARM64)"
Quoted 6 lines

In addition, remove the "#ifdef" guard for fec_enet_register_offset_6ul, so that we can safely remove the preprocessor directive from fec_enet_get_regs().

---

Quoted 124 lines
 drivers/net/ethernet/freescale/fec.h      |  4 +-
 drivers/net/ethernet/freescale/fec_main.c | 57 +++++++++--------------
 2 files changed, 23 insertions(+), 38 deletions(-)
drivers/net/ethernet/freescale/fec.h +1 -3
index 41e0d85d15da..8e438f6e7ec4 100644
@@ -24,9 +24,7 @@
 #include <linux/timecounter.h>
 #include <net/xdp.h>
 
-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
-    defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
-    defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
+#if !defined(CONFIG_M5272) || defined(CONFIG_COMPILE_TEST)
 /*
  *	Just figures, Motorola would have to change the offsets for
  *	registers in the same peripheral device on different models
drivers/net/ethernet/freescale/fec_main.c +22 -36
index e0e84f2979c8..9cf579a8ac0f 100644
@@ -253,9 +253,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
  * size bits. Other FEC hardware does not, so we need to take that into
  * account when setting it.
  */
-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
-    defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
-    defined(CONFIG_ARM64)
+#ifndef CONFIG_M5272
 #define	OPT_ARCH_HAS_MAX_FL	1
 #else
 #define	OPT_ARCH_HAS_MAX_FL	0
@@ -2704,9 +2702,7 @@ static int fec_enet_get_regs_len(struct net_device *ndev)
 }
 
 /* List of registers that can be safety be read to dump them with ethtool */
-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
-	defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
-	defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
+#if !defined(CONFIG_M5272) || defined(CONFIG_COMPILE_TEST)
 static __u32 fec_enet_register_version = 2;
 static u32 fec_enet_register_offset[] = {
 	FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0,
@@ -2737,6 +2733,21 @@ static u32 fec_enet_register_offset[] = {
 	IEEE_R_DROP, IEEE_R_FRAME_OK, IEEE_R_CRC, IEEE_R_ALIGN, IEEE_R_MACERR,
 	IEEE_R_FDXFC, IEEE_R_OCTETS_OK
 };
+#else
+static __u32 fec_enet_register_version = 1;
+static u32 fec_enet_register_offset[] = {
+	FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0,
+	FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0,
+	FEC_X_DES_ACTIVE_1, FEC_X_DES_ACTIVE_2, FEC_MII_DATA, FEC_MII_SPEED,
+	FEC_R_BOUND, FEC_R_FSTART, FEC_X_WMRK, FEC_X_FSTART, FEC_R_CNTRL,
+	FEC_MAX_FRM_LEN, FEC_X_CNTRL, FEC_ADDR_LOW, FEC_ADDR_HIGH,
+	FEC_GRP_HASH_TABLE_HIGH, FEC_GRP_HASH_TABLE_LOW, FEC_R_DES_START_0,
+	FEC_R_DES_START_1, FEC_R_DES_START_2, FEC_X_DES_START_0,
+	FEC_X_DES_START_1, FEC_X_DES_START_2, FEC_R_BUFF_SIZE_0,
+	FEC_R_BUFF_SIZE_1, FEC_R_BUFF_SIZE_2
+};
+#endif
+
 /* for i.MX6ul */
 static u32 fec_enet_register_offset_6ul[] = {
 	FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0,
@@ -2762,48 +2773,24 @@ static u32 fec_enet_register_offset_6ul[] = {
 	IEEE_R_DROP, IEEE_R_FRAME_OK, IEEE_R_CRC, IEEE_R_ALIGN, IEEE_R_MACERR,
 	IEEE_R_FDXFC, IEEE_R_OCTETS_OK
 };
-#else
-static __u32 fec_enet_register_version = 1;
-static u32 fec_enet_register_offset[] = {
-	FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0,
-	FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0,
-	FEC_X_DES_ACTIVE_1, FEC_X_DES_ACTIVE_2, FEC_MII_DATA, FEC_MII_SPEED,
-	FEC_R_BOUND, FEC_R_FSTART, FEC_X_WMRK, FEC_X_FSTART, FEC_R_CNTRL,
-	FEC_MAX_FRM_LEN, FEC_X_CNTRL, FEC_ADDR_LOW, FEC_ADDR_HIGH,
-	FEC_GRP_HASH_TABLE_HIGH, FEC_GRP_HASH_TABLE_LOW, FEC_R_DES_START_0,
-	FEC_R_DES_START_1, FEC_R_DES_START_2, FEC_X_DES_START_0,
-	FEC_X_DES_START_1, FEC_X_DES_START_2, FEC_R_BUFF_SIZE_0,
-	FEC_R_BUFF_SIZE_1, FEC_R_BUFF_SIZE_2
-};
-#endif
 
 static void fec_enet_get_regs(struct net_device *ndev,
 			      struct ethtool_regs *regs, void *regbuf)
 {
+	u32 reg_cnt = ARRAY_SIZE(fec_enet_register_offset);
 	struct fec_enet_private *fep = netdev_priv(ndev);
 	u32 __iomem *theregs = (u32 __iomem *)fep->hwp;
+	u32 *reg_list = fec_enet_register_offset;
 	struct device *dev = &fep->pdev->dev;
 	u32 *buf = (u32 *)regbuf;
 	u32 i, off;
 	int ret;
-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
-	defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
-	defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
-	u32 *reg_list;
-	u32 reg_cnt;
-
-	if (!of_machine_is_compatible("fsl,imx6ul")) {
-		reg_list = fec_enet_register_offset;
-		reg_cnt = ARRAY_SIZE(fec_enet_register_offset);
-	} else {
+
+	if (of_machine_is_compatible("fsl,imx6ul")) {
 		reg_list = fec_enet_register_offset_6ul;
 		reg_cnt = ARRAY_SIZE(fec_enet_register_offset_6ul);
 	}
-#else
-	/* coldfire */
-	static u32 *reg_list = fec_enet_register_offset;
-	static const u32 reg_cnt = ARRAY_SIZE(fec_enet_register_offset);
-#endif
+
 	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0)
 		return;
--

2.34.1

#4 lore raw

Re: [PATCH v2 net-next 2/5] net: fec: simplify the conditional preprocessor directives

In reply to Wei Fang
kernel test robot noticed the following build errors:

Hi Wei,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.18-rc5]
[also build test ERROR on next-20251117]
[cannot apply to net-next/main net/main linus/master v6.18-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Fang/net-fec-remove-useless-conditional-preprocessor-directives/20251117-183058
base:   v6.18-rc5
patch link:    https://lore.kernel.org/r/20251117101921.1862427-3-wei.fang%40nxp.com
patch subject: [PATCH v2 net-next 2/5] net: fec: simplify the conditional preprocessor directives
config: m68k-m5272c3_defconfig (https://download.01.org/0day-ci/archive/20251118/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251118/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/net/ethernet/freescale/fec_main.c:2766:50: error: 'FEC_MIB_CTRLSTAT' undeclared here (not in a function)
    2766 |         FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL,
         |                                                  ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2767:51: error: 'FEC_OPD' undeclared here (not in a function); did you mean 'FEC_H'?
    2767 |         FEC_X_CNTRL, FEC_ADDR_LOW, FEC_ADDR_HIGH, FEC_OPD, FEC_TXIC0, FEC_RXIC0,
         |                                                   ^~~~~~~
         |                                                   FEC_H
>> drivers/net/ethernet/freescale/fec_main.c:2768:9: error: 'FEC_HASH_TABLE_HIGH' undeclared here (not in a function); did you mean 'FEC_GRP_HASH_TABLE_HIGH'?
    2768 |         FEC_HASH_TABLE_HIGH, FEC_HASH_TABLE_LOW, FEC_GRP_HASH_TABLE_HIGH,
         |         ^~~~~~~~~~~~~~~~~~~
         |         FEC_GRP_HASH_TABLE_HIGH
>> drivers/net/ethernet/freescale/fec_main.c:2768:30: error: 'FEC_HASH_TABLE_LOW' undeclared here (not in a function); did you mean 'FEC_GRP_HASH_TABLE_LOW'?
    2768 |         FEC_HASH_TABLE_HIGH, FEC_HASH_TABLE_LOW, FEC_GRP_HASH_TABLE_HIGH,
         |                              ^~~~~~~~~~~~~~~~~~
         |                              FEC_GRP_HASH_TABLE_LOW
>> drivers/net/ethernet/freescale/fec_main.c:2770:47: error: 'FEC_R_FIFO_RSFL' undeclared here (not in a function); did you mean 'FEC_FIFO_RAM'?
    2770 |         FEC_X_DES_START_0, FEC_R_BUFF_SIZE_0, FEC_R_FIFO_RSFL, FEC_R_FIFO_RSEM,
         |                                               ^~~~~~~~~~~~~~~
         |                                               FEC_FIFO_RAM
>> drivers/net/ethernet/freescale/fec_main.c:2770:64: error: 'FEC_R_FIFO_RSEM' undeclared here (not in a function); did you mean 'FEC_FIFO_RAM'?
    2770 |         FEC_X_DES_START_0, FEC_R_BUFF_SIZE_0, FEC_R_FIFO_RSFL, FEC_R_FIFO_RSEM,
         |                                                                ^~~~~~~~~~~~~~~
         |                                                                FEC_FIFO_RAM
>> drivers/net/ethernet/freescale/fec_main.c:2771:9: error: 'FEC_R_FIFO_RAEM' undeclared here (not in a function); did you mean 'FEC_FIFO_RAM'?
    2771 |         FEC_R_FIFO_RAEM, FEC_R_FIFO_RAFL, FEC_RACC,
         |         ^~~~~~~~~~~~~~~
         |         FEC_FIFO_RAM
>> drivers/net/ethernet/freescale/fec_main.c:2771:26: error: 'FEC_R_FIFO_RAFL' undeclared here (not in a function); did you mean 'FEC_FIFO_RAM'?
    2771 |         FEC_R_FIFO_RAEM, FEC_R_FIFO_RAFL, FEC_RACC,
         |                          ^~~~~~~~~~~~~~~
         |                          FEC_FIFO_RAM
>> drivers/net/ethernet/freescale/fec_main.c:2771:43: error: 'FEC_RACC' undeclared here (not in a function); did you mean 'FEC_RXIC1'?
    2771 |         FEC_R_FIFO_RAEM, FEC_R_FIFO_RAFL, FEC_RACC,
         |                                           ^~~~~~~~
         |                                           FEC_RXIC1
>> drivers/net/ethernet/freescale/fec_main.c:2772:9: error: 'RMON_T_DROP' undeclared here (not in a function)
    2772 |         RMON_T_DROP, RMON_T_PACKETS, RMON_T_BC_PKT, RMON_T_MC_PKT,
         |         ^~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2772:22: error: 'RMON_T_PACKETS' undeclared here (not in a function)
    2772 |         RMON_T_DROP, RMON_T_PACKETS, RMON_T_BC_PKT, RMON_T_MC_PKT,
         |                      ^~~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2772:38: error: 'RMON_T_BC_PKT' undeclared here (not in a function)
    2772 |         RMON_T_DROP, RMON_T_PACKETS, RMON_T_BC_PKT, RMON_T_MC_PKT,
         |                                      ^~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2772:53: error: 'RMON_T_MC_PKT' undeclared here (not in a function)
    2772 |         RMON_T_DROP, RMON_T_PACKETS, RMON_T_BC_PKT, RMON_T_MC_PKT,
         |                                                     ^~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2773:9: error: 'RMON_T_CRC_ALIGN' undeclared here (not in a function)
    2773 |         RMON_T_CRC_ALIGN, RMON_T_UNDERSIZE, RMON_T_OVERSIZE, RMON_T_FRAG,
         |         ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2773:27: error: 'RMON_T_UNDERSIZE' undeclared here (not in a function)
    2773 |         RMON_T_CRC_ALIGN, RMON_T_UNDERSIZE, RMON_T_OVERSIZE, RMON_T_FRAG,
         |                           ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2773:45: error: 'RMON_T_OVERSIZE' undeclared here (not in a function)
    2773 |         RMON_T_CRC_ALIGN, RMON_T_UNDERSIZE, RMON_T_OVERSIZE, RMON_T_FRAG,
         |                                             ^~~~~~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2773:62: error: 'RMON_T_FRAG' undeclared here (not in a function)
    2773 |         RMON_T_CRC_ALIGN, RMON_T_UNDERSIZE, RMON_T_OVERSIZE, RMON_T_FRAG,
         |                                                              ^~~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2774:9: error: 'RMON_T_JAB' undeclared here (not in a function)
    2774 |         RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
         |         ^~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2774:21: error: 'RMON_T_COL' undeclared here (not in a function)
    2774 |         RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
         |                     ^~~~~~~~~~
>> drivers/net/ethernet/freescale/fec_main.c:2774:33: error: 'RMON_T_P64' undeclared here (not in a function)
    2774 |         RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
         |                                 ^~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2774:45: error: 'RMON_T_P65TO127' undeclared here (not in a function)
    2774 |         RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
         |                                             ^~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2774:62: error: 'RMON_T_P128TO255' undeclared here (not in a function)
    2774 |         RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
         |                                                              ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2775:9: error: 'RMON_T_P256TO511' undeclared here (not in a function)
    2775 |         RMON_T_P256TO511, RMON_T_P512TO1023, RMON_T_P1024TO2047,
         |         ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2775:27: error: 'RMON_T_P512TO1023' undeclared here (not in a function)
    2775 |         RMON_T_P256TO511, RMON_T_P512TO1023, RMON_T_P1024TO2047,
         |                           ^~~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2775:46: error: 'RMON_T_P1024TO2047' undeclared here (not in a function)
    2775 |         RMON_T_P256TO511, RMON_T_P512TO1023, RMON_T_P1024TO2047,
         |                                              ^~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2776:9: error: 'RMON_T_P_GTE2048' undeclared here (not in a function)
    2776 |         RMON_T_P_GTE2048, RMON_T_OCTETS,
         |         ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2776:27: error: 'RMON_T_OCTETS' undeclared here (not in a function)
    2776 |         RMON_T_P_GTE2048, RMON_T_OCTETS,
         |                           ^~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2777:9: error: 'IEEE_T_DROP' undeclared here (not in a function)
    2777 |         IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
         |         ^~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2777:22: error: 'IEEE_T_FRAME_OK' undeclared here (not in a function)
    2777 |         IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
         |                      ^~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2777:39: error: 'IEEE_T_1COL' undeclared here (not in a function)
    2777 |         IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
         |                                       ^~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2777:52: error: 'IEEE_T_MCOL' undeclared here (not in a function)
    2777 |         IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
         |                                                    ^~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2777:65: error: 'IEEE_T_DEF' undeclared here (not in a function)
    2777 |         IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
         |                                                                 ^~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2778:9: error: 'IEEE_T_LCOL' undeclared here (not in a function)
    2778 |         IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
         |         ^~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2778:22: error: 'IEEE_T_EXCOL' undeclared here (not in a function)
    2778 |         IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
         |                      ^~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2778:36: error: 'IEEE_T_MACERR' undeclared here (not in a function)
    2778 |         IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
         |                                    ^~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2778:51: error: 'IEEE_T_CSERR' undeclared here (not in a function)
    2778 |         IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
         |                                                   ^~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2778:65: error: 'IEEE_T_SQE' undeclared here (not in a function)
    2778 |         IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
         |                                                                 ^~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2779:9: error: 'IEEE_T_FDXFC' undeclared here (not in a function)
    2779 |         IEEE_T_FDXFC, IEEE_T_OCTETS_OK,
         |         ^~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2779:23: error: 'IEEE_T_OCTETS_OK' undeclared here (not in a function)
    2779 |         IEEE_T_FDXFC, IEEE_T_OCTETS_OK,
         |                       ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2780:9: error: 'RMON_R_PACKETS' undeclared here (not in a function)
    2780 |         RMON_R_PACKETS, RMON_R_BC_PKT, RMON_R_MC_PKT, RMON_R_CRC_ALIGN,
         |         ^~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2780:25: error: 'RMON_R_BC_PKT' undeclared here (not in a function)
    2780 |         RMON_R_PACKETS, RMON_R_BC_PKT, RMON_R_MC_PKT, RMON_R_CRC_ALIGN,
         |                         ^~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2780:40: error: 'RMON_R_MC_PKT' undeclared here (not in a function)
    2780 |         RMON_R_PACKETS, RMON_R_BC_PKT, RMON_R_MC_PKT, RMON_R_CRC_ALIGN,
         |                                        ^~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2780:55: error: 'RMON_R_CRC_ALIGN' undeclared here (not in a function)
    2780 |         RMON_R_PACKETS, RMON_R_BC_PKT, RMON_R_MC_PKT, RMON_R_CRC_ALIGN,
         |                                                       ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2781:9: error: 'RMON_R_UNDERSIZE' undeclared here (not in a function)
    2781 |         RMON_R_UNDERSIZE, RMON_R_OVERSIZE, RMON_R_FRAG, RMON_R_JAB,
         |         ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2781:27: error: 'RMON_R_OVERSIZE' undeclared here (not in a function)
    2781 |         RMON_R_UNDERSIZE, RMON_R_OVERSIZE, RMON_R_FRAG, RMON_R_JAB,
         |                           ^~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2781:44: error: 'RMON_R_FRAG' undeclared here (not in a function)
    2781 |         RMON_R_UNDERSIZE, RMON_R_OVERSIZE, RMON_R_FRAG, RMON_R_JAB,
         |                                            ^~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2781:57: error: 'RMON_R_JAB' undeclared here (not in a function)
    2781 |         RMON_R_UNDERSIZE, RMON_R_OVERSIZE, RMON_R_FRAG, RMON_R_JAB,
         |                                                         ^~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2782:9: error: 'RMON_R_RESVD_O' undeclared here (not in a function)
    2782 |         RMON_R_RESVD_O, RMON_R_P64, RMON_R_P65TO127, RMON_R_P128TO255,
         |         ^~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2782:25: error: 'RMON_R_P64' undeclared here (not in a function)
    2782 |         RMON_R_RESVD_O, RMON_R_P64, RMON_R_P65TO127, RMON_R_P128TO255,
         |                         ^~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2782:37: error: 'RMON_R_P65TO127' undeclared here (not in a function)
    2782 |         RMON_R_RESVD_O, RMON_R_P64, RMON_R_P65TO127, RMON_R_P128TO255,
         |                                     ^~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2782:54: error: 'RMON_R_P128TO255' undeclared here (not in a function)
    2782 |         RMON_R_RESVD_O, RMON_R_P64, RMON_R_P65TO127, RMON_R_P128TO255,
         |                                                      ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2783:9: error: 'RMON_R_P256TO511' undeclared here (not in a function)
    2783 |         RMON_R_P256TO511, RMON_R_P512TO1023, RMON_R_P1024TO2047,
         |         ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/fec_main.c:2783:27: error: 'RMON_R_P512TO1023' undeclared here (not in a function)
    2783 |         RMON_R_P256TO511, RMON_R_P512TO1023, RMON_R_P1024TO2047,

vim +/FEC_MIB_CTRLSTAT +2766 drivers/net/ethernet/freescale/fec_main.c

53607ca2565548 Wei Fang        2025-11-17  2762  
0a8b43b12dd78d Juergen Borleis 2022-10-24  2763  /* for i.MX6ul */
0a8b43b12dd78d Juergen Borleis 2022-10-24  2764  static u32 fec_enet_register_offset_6ul[] = {
0a8b43b12dd78d Juergen Borleis 2022-10-24  2765  	FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2766  	FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2767  	FEC_X_CNTRL, FEC_ADDR_LOW, FEC_ADDR_HIGH, FEC_OPD, FEC_TXIC0, FEC_RXIC0,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2768  	FEC_HASH_TABLE_HIGH, FEC_HASH_TABLE_LOW, FEC_GRP_HASH_TABLE_HIGH,
0a8b43b12dd78d Juergen Borleis 2022-10-24  2769  	FEC_GRP_HASH_TABLE_LOW, FEC_X_WMRK, FEC_R_DES_START_0,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2770  	FEC_X_DES_START_0, FEC_R_BUFF_SIZE_0, FEC_R_FIFO_RSFL, FEC_R_FIFO_RSEM,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2771  	FEC_R_FIFO_RAEM, FEC_R_FIFO_RAFL, FEC_RACC,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2772  	RMON_T_DROP, RMON_T_PACKETS, RMON_T_BC_PKT, RMON_T_MC_PKT,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2773  	RMON_T_CRC_ALIGN, RMON_T_UNDERSIZE, RMON_T_OVERSIZE, RMON_T_FRAG,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2774  	RMON_T_JAB, RMON_T_COL, RMON_T_P64, RMON_T_P65TO127, RMON_T_P128TO255,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2775  	RMON_T_P256TO511, RMON_T_P512TO1023, RMON_T_P1024TO2047,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2776  	RMON_T_P_GTE2048, RMON_T_OCTETS,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2777  	IEEE_T_DROP, IEEE_T_FRAME_OK, IEEE_T_1COL, IEEE_T_MCOL, IEEE_T_DEF,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2778  	IEEE_T_LCOL, IEEE_T_EXCOL, IEEE_T_MACERR, IEEE_T_CSERR, IEEE_T_SQE,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2779  	IEEE_T_FDXFC, IEEE_T_OCTETS_OK,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2780  	RMON_R_PACKETS, RMON_R_BC_PKT, RMON_R_MC_PKT, RMON_R_CRC_ALIGN,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2781  	RMON_R_UNDERSIZE, RMON_R_OVERSIZE, RMON_R_FRAG, RMON_R_JAB,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2782  	RMON_R_RESVD_O, RMON_R_P64, RMON_R_P65TO127, RMON_R_P128TO255,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2783  	RMON_R_P256TO511, RMON_R_P512TO1023, RMON_R_P1024TO2047,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2784  	RMON_R_P_GTE2048, RMON_R_OCTETS,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2785  	IEEE_R_DROP, IEEE_R_FRAME_OK, IEEE_R_CRC, IEEE_R_ALIGN, IEEE_R_MACERR,
0a8b43b12dd78d Juergen Borleis 2022-10-24 @2786  	IEEE_R_FDXFC, IEEE_R_OCTETS_OK
0a8b43b12dd78d Juergen Borleis 2022-10-24  2787  };

db65f35f50e031 Philippe Reynes 2015-05-11 2788

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#5 lore raw

PATCH v2 3/5 net: fec: remove struct fec_enet_priv_txrx_info

In reply to Wei Fang

The struct fec_enet_priv_txrx_info has three members: offset, page and skb. The offset is only initialized in the driver and is not used, the skb is never initialized and used in the driver. The both will not be used in the future. Therefore, replace struct fec_enet_priv_txrx_info bedirectly with struct page.

---
 drivers/net/ethernet/freescale/fec.h      |  8 +-------
 drivers/net/ethernet/freescale/fec_main.c | 11 +++++------
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/net/ethernet/freescale/fec.h +1 -7
index 8e438f6e7ec4..c5bbc2c16a4f 100644
@@ -528,12 +528,6 @@ struct bufdesc_prop {
 	unsigned char dsize_log2;
 };
 
-struct fec_enet_priv_txrx_info {
-	int	offset;
-	struct	page *page;
-	struct  sk_buff *skb;
-};
-
 enum {
 	RX_XDP_REDIRECT = 0,
 	RX_XDP_PASS,
@@ -573,7 +567,7 @@ struct fec_enet_priv_tx_q {
 
 struct fec_enet_priv_rx_q {
 	struct bufdesc_prop bd;
-	struct  fec_enet_priv_txrx_info rx_skb_info[RX_RING_SIZE];
+	struct page *rx_buf[RX_RING_SIZE];
 
 	/* page_pool */
 	struct page_pool *page_pool;
drivers/net/ethernet/freescale/fec_main.c +5 -6
index 9cf579a8ac0f..1408e3e6650a 100644
@@ -1655,8 +1655,7 @@ static int fec_enet_update_cbd(struct fec_enet_priv_rx_q *rxq,
 	if (unlikely(!new_page))
 		return -ENOMEM;
 
-	rxq->rx_skb_info[index].page = new_page;
-	rxq->rx_skb_info[index].offset = FEC_ENET_XDP_HEADROOM;
+	rxq->rx_buf[index] = new_page;
 	phys_addr = page_pool_get_dma_addr(new_page) + FEC_ENET_XDP_HEADROOM;
 	bdp->cbd_bufaddr = cpu_to_fec32(phys_addr);
 
@@ -1834,7 +1833,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
 		ndev->stats.rx_bytes += pkt_len;
 
 		index = fec_enet_get_bd_index(bdp, &rxq->bd);
-		page = rxq->rx_skb_info[index].page;
+		page = rxq->rx_buf[index];
 		cbd_bufaddr = bdp->cbd_bufaddr;
 		if (fec_enet_update_cbd(rxq, bdp, index)) {
 			ndev->stats.rx_dropped++;
@@ -3309,7 +3308,8 @@ static void fec_enet_free_buffers(struct net_device *ndev)
 	for (q = 0; q < fep->num_rx_queues; q++) {
 		rxq = fep->rx_queue[q];
 		for (i = 0; i < rxq->bd.ring_size; i++)
-			page_pool_put_full_page(rxq->page_pool, rxq->rx_skb_info[i].page, false);
+			page_pool_put_full_page(rxq->page_pool, rxq->rx_buf[i],
+						false);
 
 		for (i = 0; i < XDP_STATS_TOTAL; i++)
 			rxq->stats[i] = 0;
@@ -3443,8 +3443,7 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue)
 		phys_addr = page_pool_get_dma_addr(page) + FEC_ENET_XDP_HEADROOM;
 		bdp->cbd_bufaddr = cpu_to_fec32(phys_addr);
 
-		rxq->rx_skb_info[i].page = page;
-		rxq->rx_skb_info[i].offset = FEC_ENET_XDP_HEADROOM;
+		rxq->rx_buf[i] = page;
 		bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY);
 
 		if (fep->bufdesc_ex) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 3/5
#6 lore raw

Re: [PATCH v2 net-next 3/5] net: fec: remove struct fec_enet_priv_txrx_info

Quoted 5 lines · Wei Fang

The struct fec_enet_priv_txrx_info has three members: offset, page and skb. The offset is only initialized in the driver and is not used, the skb is never initialized and used in the driver. The both will not be used in the future. Therefore, replace struct fec_enet_priv_txrx_info bedirectly with struct page.

directly?

Quoted 79 lines
---
 drivers/net/ethernet/freescale/fec.h      |  8 +-------
 drivers/net/ethernet/freescale/fec_main.c | 11 +++++------
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/net/ethernet/freescale/fec.h +1 -7
index 8e438f6e7ec4..c5bbc2c16a4f 100644
@@ -528,12 +528,6 @@ struct bufdesc_prop {
 	unsigned char dsize_log2;
 };
 
-struct fec_enet_priv_txrx_info {
-	int	offset;
-	struct	page *page;
-	struct  sk_buff *skb;
-};
-
 enum {
 	RX_XDP_REDIRECT = 0,
 	RX_XDP_PASS,
@@ -573,7 +567,7 @@ struct fec_enet_priv_tx_q {
 
 struct fec_enet_priv_rx_q {
 	struct bufdesc_prop bd;
-	struct  fec_enet_priv_txrx_info rx_skb_info[RX_RING_SIZE];
+	struct page *rx_buf[RX_RING_SIZE];
 
 	/* page_pool */
 	struct page_pool *page_pool;
drivers/net/ethernet/freescale/fec_main.c +5 -7
index 9cf579a8ac0f..1408e3e6650a 100644
@@ -1655,8 +1655,7 @@ static int fec_enet_update_cbd(struct fec_enet_priv_rx_q *rxq,
 	if (unlikely(!new_page))
 		return -ENOMEM;
 
-	rxq->rx_skb_info[index].page = new_page;
-	rxq->rx_skb_info[index].offset = FEC_ENET_XDP_HEADROOM;
+	rxq->rx_buf[index] = new_page;
 	phys_addr = page_pool_get_dma_addr(new_page) + FEC_ENET_XDP_HEADROOM;
 	bdp->cbd_bufaddr = cpu_to_fec32(phys_addr);
 
@@ -1834,7 +1833,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
 		ndev->stats.rx_bytes += pkt_len;
 
 		index = fec_enet_get_bd_index(bdp, &rxq->bd);
-		page = rxq->rx_skb_info[index].page;
+		page = rxq->rx_buf[index];
 		cbd_bufaddr = bdp->cbd_bufaddr;
 		if (fec_enet_update_cbd(rxq, bdp, index)) {
 			ndev->stats.rx_dropped++;
@@ -3309,7 +3308,8 @@ static void fec_enet_free_buffers(struct net_device *ndev)
 	for (q = 0; q < fep->num_rx_queues; q++) {
 		rxq = fep->rx_queue[q];
 		for (i = 0; i < rxq->bd.ring_size; i++)
-			page_pool_put_full_page(rxq->page_pool, rxq->rx_skb_info[i].page, false);
+			page_pool_put_full_page(rxq->page_pool, rxq->rx_buf[i],
+						false);
 
 		for (i = 0; i < XDP_STATS_TOTAL; i++)
 			rxq->stats[i] = 0;
@@ -3443,8 +3443,7 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue)
 		phys_addr = page_pool_get_dma_addr(page) + FEC_ENET_XDP_HEADROOM;
 		bdp->cbd_bufaddr = cpu_to_fec32(phys_addr);
 
-		rxq->rx_skb_info[i].page = page;
-		rxq->rx_skb_info[i].offset = FEC_ENET_XDP_HEADROOM;
+		rxq->rx_buf[i] = page;
 		bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY);
 
 		if (fep->bufdesc_ex) {
--

2.34.1

author maintainer
#7 lore raw

RE: [PATCH v2 net-next 3/5] net: fec: remove struct fec_enet_priv_txrx_info

Quoted 8 lines · Wei Fang
Quoted 5 lines

The struct fec_enet_priv_txrx_info has three members: offset, page and skb. The offset is only initialized in the driver and is not used, the skb is never initialized and used in the driver. The both will not be used in the future. Therefore, replace struct fec_enet_priv_txrx_info bedirectly with struct page.

directly?

Thanks for catching this, I will fix it.

Quoted 3 lines
author maintainer
#8 lore raw

PATCH v2 4/5 net: fec: remove rx_align from fec_enet_private

In reply to Wei Fang

The rx_align was introduced by the commit 41ef84ce4c72 ("net: fec: change FEC alignment according to i.mx6 sx requirement"). Because the i.MX6 SX requires RX buffer must be 64 bytes alignment.

Since the commit 95698ff6177b ("net: fec: using page pool to manage RX buffers"), the address of the RX buffer is always the page address plus FEC_ENET_XDP_HEADROOM which is 256 bytes, so the RX buffer is always 64-byte aligned. Therefore, rx_align has no effect since that commit, and we can safely remove it.

In addition, to prevent future modifications to FEC_ENET_XDP_HEADROOM, a BUILD_BUG_ON() test has been added to the driver, which ensures that FEC_ENET_XDP_HEADROOM provides the required alignment.

---
 drivers/net/ethernet/freescale/fec.h      |  1 -
 drivers/net/ethernet/freescale/fec_main.c | 19 ++++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/fec.h +0 -1
index c5bbc2c16a4f..a25dca9c7d71 100644
@@ -660,7 +660,6 @@ struct fec_enet_private {
 	struct pm_qos_request pm_qos_req;
 
 	unsigned int tx_align;
-	unsigned int rx_align;
 
 	/* hw interrupt coalesce */
 	unsigned int rx_pkts_itr;
drivers/net/ethernet/freescale/fec_main.c +14 -5
index 1408e3e6650a..785bae8e1699 100644
@@ -3435,6 +3435,19 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue)
 		return err;
 	}
 
+	/* Some platforms require the RX buffer must be 64 bytes alignment.
+	 * Some platforms require 16 bytes alignment. And some platforms
+	 * require 4 bytes alignment. But since the page pool have been
+	 * introduced into the driver, the address of RX buffer is always
+	 * the page address plus FEC_ENET_XDP_HEADROOM, and
+	 * FEC_ENET_XDP_HEADROOM is 256 bytes. Therefore, this address can
+	 * satisfy all platforms. To prevent future modifications to
+	 * FEC_ENET_XDP_HEADROOM from ignoring this hardware limitation, a
+	 * BUILD_BUG_ON() test has been added, which ensures that
+	 * FEC_ENET_XDP_HEADROOM provides the required alignment.
+	 */
+	BUILD_BUG_ON(FEC_ENET_XDP_HEADROOM & 0x3f);
+
 	for (i = 0; i < rxq->bd.ring_size; i++) {
 		page = page_pool_dev_alloc_pages(rxq->page_pool);
 		if (!page)
@@ -4069,10 +4082,8 @@ static int fec_enet_init(struct net_device *ndev)
 
 	WARN_ON(dsize != (1 << dsize_log2));
 #if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
-	fep->rx_align = 0xf;
 	fep->tx_align = 0xf;
 #else
-	fep->rx_align = 0x3;
 	fep->tx_align = 0x3;
 #endif
 	fep->rx_pkts_itr = FEC_ITR_ICFT_DEFAULT;
@@ -4161,10 +4172,8 @@ static int fec_enet_init(struct net_device *ndev)
 		fep->csum_flags |= FLAG_RX_CSUM_ENABLED;
 	}
 
-	if (fep->quirks & FEC_QUIRK_HAS_MULTI_QUEUES) {
+	if (fep->quirks & FEC_QUIRK_HAS_MULTI_QUEUES)
 		fep->tx_align = 0;
-		fep->rx_align = 0x3f;
-	}
 
 	ndev->hw_features = ndev->features;
 
Signature · 1 line
2.34.1
author maintainer
#9 lore raw

PATCH v2 5/5 net: fec: remove duplicate macros of the BD status

In reply to Wei Fang

There are two sets of macros used to define the status bits of TX and RX BDs, one is the BD_SC_xx macros, the other one is the BD_ENET_xx macros. For the BD_SC_xx macros, only BD_SC_WRAP is used in the driver. But the BD_ENET_xx macros are more widely used in the driver, and they define more bits of the BD status. Therefore, remove the BD_SC_xx macros from now on.

---
 drivers/net/ethernet/freescale/fec.h      | 17 -----------------
 drivers/net/ethernet/freescale/fec_main.c |  8 ++++----
 2 files changed, 4 insertions(+), 21 deletions(-)
drivers/net/ethernet/freescale/fec.h +0 -17
index a25dca9c7d71..7b4d1fc8e7eb 100644
@@ -240,23 +240,6 @@ struct bufdesc_ex {
 	__fec16 res0[4];
 };
 
-/*
- *	The following definitions courtesy of commproc.h, which where
- *	Copyright (c) 1997 Dan Malek ([email protected]).
- */
-#define BD_SC_EMPTY	((ushort)0x8000)	/* Receive is empty */
-#define BD_SC_READY	((ushort)0x8000)	/* Transmit is ready */
-#define BD_SC_WRAP	((ushort)0x2000)	/* Last buffer descriptor */
-#define BD_SC_INTRPT	((ushort)0x1000)	/* Interrupt on change */
-#define BD_SC_CM	((ushort)0x0200)	/* Continuous mode */
-#define BD_SC_ID	((ushort)0x0100)	/* Rec'd too many idles */
-#define BD_SC_P		((ushort)0x0100)	/* xmt preamble */
-#define BD_SC_BR	((ushort)0x0020)	/* Break received */
-#define BD_SC_FR	((ushort)0x0010)	/* Framing error */
-#define BD_SC_PR	((ushort)0x0008)	/* Parity error */
-#define BD_SC_OV	((ushort)0x0002)	/* Overrun */
-#define BD_SC_CD	((ushort)0x0001)	/* ?? */
-
 /* Buffer descriptor control/status used by Ethernet receive.
  */
 #define BD_ENET_RX_EMPTY	((ushort)0x8000)
drivers/net/ethernet/freescale/fec_main.c +4 -4
index 785bae8e1699..0bc93fa15ebd 100644
@@ -1010,7 +1010,7 @@ static void fec_enet_bd_init(struct net_device *dev)
 
 		/* Set the last buffer to wrap */
 		bdp = fec_enet_get_prevdesc(bdp, &rxq->bd);
-		bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP);
+		bdp->cbd_sc |= cpu_to_fec16(BD_ENET_RX_WRAP);
 
 		rxq->bd.cur = rxq->bd.base;
 	}
@@ -1060,7 +1060,7 @@ static void fec_enet_bd_init(struct net_device *dev)
 
 		/* Set the last buffer to wrap */
 		bdp = fec_enet_get_prevdesc(bdp, &txq->bd);
-		bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP);
+		bdp->cbd_sc |= cpu_to_fec16(BD_ENET_TX_WRAP);
 		txq->dirty_tx = bdp;
 	}
 }
@@ -3469,7 +3469,7 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue)
 
 	/* Set the last buffer to wrap. */
 	bdp = fec_enet_get_prevdesc(bdp, &rxq->bd);
-	bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP);
+	bdp->cbd_sc |= cpu_to_fec16(BD_ENET_RX_WRAP);
 	return 0;
 
  err_alloc:
@@ -3505,7 +3505,7 @@ fec_enet_alloc_txq_buffers(struct net_device *ndev, unsigned int queue)
 
 	/* Set the last buffer to wrap. */
 	bdp = fec_enet_get_prevdesc(bdp, &txq->bd);
-	bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP);
+	bdp->cbd_sc |= cpu_to_fec16(BD_ENET_TX_WRAP);
 
 	return 0;
 
Signature · 1 line
2.34.1
maintainer
#10 lore raw
In reply to Wei Fang
Quoted 2 lines · On Mon, 17 Nov 2025 18:19:16 +0800 Wei Fang wrote:

This patch set removes some unnecessary or invalid code from the FEC driver. See each patch for details.

Does not apply:

$ git pw series apply  1024201
Failed to apply patch:
Applying: net: fec: remove useless conditional preprocessor directives
Applying: net: fec: simplify the conditional preprocessor directives
Applying: net: fec: remove struct fec_enet_priv_txrx_info
error: sha1 information is lacking or useless (drivers/net/ethernet/freescale/fec_main.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 net: fec: remove struct fec_enet_priv_txrx_info

If there's a dependency in net or on the list please wait for it to be merged into net-next.

Signature · 1 line
pw-bot: cr