diff mbox series

[RFC,v1,25/57] net: marvell: Remove PAGE_SIZE compile-time constant assumption

Message ID 20241014105912.3207374-25-ryan.roberts@arm.com (mailing list archive)
State New, archived
Headers show
Series Boot-time page size selection for arm64 | expand

Commit Message

Ryan Roberts Oct. 14, 2024, 10:58 a.m. UTC
To prepare for supporting boot-time page size selection, refactor code
to remove assumptions about PAGE_SIZE being compile-time constant. Code
intended to be equivalent when compile-time page size is active.

Updated sky2 "struct rx_ring_info" member frag_addr[] to contain enough
entries for the smallest supported page size.

Updated mvneta "struct mvneta_tx_queue" members tso_hdrs[] and
tso_hdrs_phys[] to contain enough entries for the smallest supported
page size.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---

***NOTE***
Any confused maintainers may want to read the cover note here for context:
https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/

 drivers/net/ethernet/marvell/mvneta.c | 9 ++++++---
 drivers/net/ethernet/marvell/sky2.h   | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 41894834fb53c..f3ac371d8f3a7 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -346,12 +346,15 @@ 
 
 /* The size of a TSO header page */
 #define MVNETA_TSO_PAGE_SIZE (2 * PAGE_SIZE)
+#define MVNETA_TSO_PAGE_SIZE_MIN (2 * PAGE_SIZE_MIN)
 
 /* Number of TSO headers per page. This should be a power of 2 */
 #define MVNETA_TSO_PER_PAGE (MVNETA_TSO_PAGE_SIZE / TSO_HEADER_SIZE)
+#define MVNETA_TSO_PER_PAGE_MIN (MVNETA_TSO_PAGE_SIZE_MIN / TSO_HEADER_SIZE)
 
 /* Maximum number of TSO header pages */
 #define MVNETA_MAX_TSO_PAGES (MVNETA_MAX_TXD / MVNETA_TSO_PER_PAGE)
+#define MVNETA_MAX_TSO_PAGES_MAX (MVNETA_MAX_TXD / MVNETA_TSO_PER_PAGE_MIN)
 
 /* descriptor aligned size */
 #define MVNETA_DESC_ALIGNED_SIZE	32
@@ -696,10 +699,10 @@  struct mvneta_tx_queue {
 	int next_desc_to_proc;
 
 	/* DMA buffers for TSO headers */
-	char *tso_hdrs[MVNETA_MAX_TSO_PAGES];
+	char *tso_hdrs[MVNETA_MAX_TSO_PAGES_MAX];
 
 	/* DMA address of TSO headers */
-	dma_addr_t tso_hdrs_phys[MVNETA_MAX_TSO_PAGES];
+	dma_addr_t tso_hdrs_phys[MVNETA_MAX_TSO_PAGES_MAX];
 
 	/* Affinity mask for CPUs*/
 	cpumask_t affinity_mask;
@@ -5895,7 +5898,7 @@  static int __init mvneta_driver_init(void)
 {
 	int ret;
 
-	BUILD_BUG_ON_NOT_POWER_OF_2(MVNETA_TSO_PER_PAGE);
+	BUILD_BUG_ON_NOT_POWER_OF_2(MVNETA_TSO_PER_PAGE_MIN);
 
 	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "net/mvneta:online",
 				      mvneta_cpu_online,
diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h
index 8d0bacf4e49cc..8ee73ae087dfc 100644
--- a/drivers/net/ethernet/marvell/sky2.h
+++ b/drivers/net/ethernet/marvell/sky2.h
@@ -2195,7 +2195,7 @@  struct rx_ring_info {
 	struct sk_buff	*skb;
 	dma_addr_t	data_addr;
 	DEFINE_DMA_UNMAP_LEN(data_size);
-	dma_addr_t	frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT ?: 1];
+	dma_addr_t	frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT_MIN ?: 1];
 };
 
 enum flow_control {