Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct

Jacob Keller
2025-11-03T23:36:35Z

[-- Attachment #1.1: Type: text/plain, Size: 1900 bytes --]

On 11/3/2025 2:27 AM, Lorenzo Bianconi wrote:
> Do not allocate memory for rx-only fields for hw tx queues and for tx-only
> fields for hw rx queues.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/ethernet/airoha/airoha_eth.h | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
> index fbbc58133364baefafed30299ca0626c686b668e..750dd3e5dfecb5d3d0ff754f6a92ffa000db3343 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.h
> +++ b/drivers/net/ethernet/airoha/airoha_eth.h
> @@ -185,19 +185,27 @@ struct airoha_queue {
> spinlock_t lock;
> struct airoha_queue_entry *entry;
> struct airoha_qdma_desc *desc;
> - u16 head;
> - u16 tail;
>
> int queued;
> int ndesc;
> - int free_thr;
> - int buf_size;
>
> struct napi_struct napi;
> - struct page_pool *page_pool;
> - struct sk_buff *skb;
>
> - struct list_head tx_list;
> + union {
> + struct { /* rx */
> + u16 head;
> + u16 tail;
> + int buf_size;
> +
> + struct page_pool *page_pool;
> + struct sk_buff *skb;
> + };
> +
> + struct { /* tx */
> + struct list_head tx_list;
> + int free_thr;
> + };
> + };

This does save some memory since a given queue now is limited by the
size of the larger of the Tx or Rx portion.

You could completely separate the Tx and Rx queue structures, but that
ends up with a bunch of typing issues to deal with since all the
functions take a airoha_queue structure currently.

I think some recent work has been making use of struct_group() for
situations like this, but its not that valuable if you don't need to
quickly check the size of the group.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

> };
>
> struct airoha_tx_irq_queue {
>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]