@@ -571,7 +571,6 @@ 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];
/* page_pool */
struct page_pool *page_pool;
@@ -580,6 +579,8 @@ struct fec_enet_priv_rx_q {
/* rx queue number, in the range 0-7 */
u8 id;
+
+ struct fec_enet_priv_txrx_info rx_skb_info[];
};
struct fec_stop_mode_gpr {
@@ -3339,6 +3339,8 @@ static int fec_enet_alloc_queue(struct net_device *ndev)
int i;
int ret = 0;
struct fec_enet_priv_tx_q *txq;
+ size_t rxq_sz = struct_size(fep->rx_queue[0], rx_skb_info, RX_RING_SIZE);
+
for (i = 0; i < fep->num_tx_queues; i++) {
txq = kzalloc(sizeof(*txq), GFP_KERNEL);
@@ -3364,8 +3366,7 @@ static int fec_enet_alloc_queue(struct net_device *ndev)
}
for (i = 0; i < fep->num_rx_queues; i++) {
- fep->rx_queue[i] = kzalloc(sizeof(*fep->rx_queue[i]),
- GFP_KERNEL);
+ fep->rx_queue[i] = kzalloc(rxq_sz, GFP_KERNEL);
if (!fep->rx_queue[i]) {
ret = -ENOMEM;
goto alloc_failed;
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. Refactored "struct fec_enet_priv_rx_q" to use a flexible array member for "rx_skb_info", since its length depends on 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/freescale/fec.h | 3 ++- drivers/net/ethernet/freescale/fec_main.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)