Commit 3bb06c8a authored by Wei Fang's avatar Wei Fang Committed by Jakub Kicinski
Browse files

net: fec: remove rx_align from fec_enet_private



The rx_align was introduced by the commit 41ef84ce ("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 95698ff6 ("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.

Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20251119025148.2817602-5-wei.fang@nxp.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 63083d59
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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;
+14 −5
Original line number Diff line number Diff line
@@ -3438,6 +3438,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)
@@ -4072,10 +4085,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;
@@ -4164,10 +4175,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;