* [PATCH net-next 0/2] net: airoha: Allow mapping out-of-order DMA tx descriptors
@ 2025-11-03 10:27 Lorenzo Bianconi
2025-11-03 10:27 ` [PATCH net-next 1/2] net: airoha: Add the capability to consume " Lorenzo Bianconi
2025-11-03 10:27 ` [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct Lorenzo Bianconi
0 siblings, 2 replies; 11+ messages in thread
From: Lorenzo Bianconi @ 2025-11-03 10:27 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Lorenzo Bianconi
Cc: linux-arm-kernel, linux-mediatek, netdev, Xuegang Lu
Add the capability to consume out-of-order DMA tx descriptors. This
feature is useful when multiple flows are queued on the same hw tx queue
since it allows to fully utilize the available tx DMA descriptors and to
avoid the starvation of high-priority flow we have in the current
codebase due to head-of-line blocking introduced by low-priority flows.
Reorganize airoha_queue struct.
---
Lorenzo Bianconi (2):
net: airoha: Add the capability to consume out-of-order DMA tx descriptors
net: airoha: Reorganize airoha_queue struct
drivers/net/ethernet/airoha/airoha_eth.c | 87 +++++++++++++++-----------------
drivers/net/ethernet/airoha/airoha_eth.h | 27 +++++++---
2 files changed, 61 insertions(+), 53 deletions(-)
---
base-commit: 01cc760632b875c4ad0d8fec0b0c01896b8a36d4
change-id: 20251017-airoha-tx-linked-list-0adb92b8a92d
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH net-next 1/2] net: airoha: Add the capability to consume out-of-order DMA tx descriptors 2025-11-03 10:27 [PATCH net-next 0/2] net: airoha: Allow mapping out-of-order DMA tx descriptors Lorenzo Bianconi @ 2025-11-03 10:27 ` Lorenzo Bianconi 2025-11-03 23:32 ` Jacob Keller 2025-11-05 2:30 ` Jakub Kicinski 2025-11-03 10:27 ` [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct Lorenzo Bianconi 1 sibling, 2 replies; 11+ messages in thread From: Lorenzo Bianconi @ 2025-11-03 10:27 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lorenzo Bianconi Cc: linux-arm-kernel, linux-mediatek, netdev, Xuegang Lu EN7581 and AN7583 SoCs are capable of DMA mapping non-linear tx skbs on non-consecutive DMA descriptors. This feature is useful when multiple flows are queued on the same hw tx queue since it allows to fully utilize the available tx DMA descriptors and to avoid the starvation of high-priority flow we have in the current codebase due to head-of-line blocking introduced by low-priority flows. Tested-by: Xuegang Lu <xuegang.lu@airoha.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- drivers/net/ethernet/airoha/airoha_eth.c | 87 +++++++++++++++----------------- drivers/net/ethernet/airoha/airoha_eth.h | 7 ++- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c index 688faf999e4c0a30d53a25877b4a81a33ec7fca2..b717e3efe53cc9c86be8a39e7f9b03cc592e7281 100644 --- a/drivers/net/ethernet/airoha/airoha_eth.c +++ b/drivers/net/ethernet/airoha/airoha_eth.c @@ -892,19 +892,13 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget) dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, DMA_TO_DEVICE); - memset(e, 0, sizeof(*e)); + e->dma_addr = 0; + list_add_tail(&e->list, &q->tx_list); + WRITE_ONCE(desc->msg0, 0); WRITE_ONCE(desc->msg1, 0); q->queued--; - /* completion ring can report out-of-order indexes if hw QoS - * is enabled and packets with different priority are queued - * to same DMA ring. Take into account possible out-of-order - * reports incrementing DMA ring tail pointer - */ - while (q->tail != q->head && !q->entry[q->tail].dma_addr) - q->tail = (q->tail + 1) % q->ndesc; - if (skb) { u16 queue = skb_get_queue_mapping(skb); struct netdev_queue *txq; @@ -949,6 +943,7 @@ static int airoha_qdma_init_tx_queue(struct airoha_queue *q, q->ndesc = size; q->qdma = qdma; q->free_thr = 1 + MAX_SKB_FRAGS; + INIT_LIST_HEAD(&q->tx_list); q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry), GFP_KERNEL); @@ -961,9 +956,9 @@ static int airoha_qdma_init_tx_queue(struct airoha_queue *q, return -ENOMEM; for (i = 0; i < q->ndesc; i++) { - u32 val; + u32 val = FIELD_PREP(QDMA_DESC_DONE_MASK, 1); - val = FIELD_PREP(QDMA_DESC_DONE_MASK, 1); + list_add_tail(&q->entry[i].list, &q->tx_list); WRITE_ONCE(q->desc[i].ctrl, cpu_to_le32(val)); } @@ -973,9 +968,9 @@ static int airoha_qdma_init_tx_queue(struct airoha_queue *q, airoha_qdma_wr(qdma, REG_TX_RING_BASE(qid), dma_addr); airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(qid), TX_RING_CPU_IDX_MASK, - FIELD_PREP(TX_RING_CPU_IDX_MASK, q->head)); + FIELD_PREP(TX_RING_CPU_IDX_MASK, 0)); airoha_qdma_rmw(qdma, REG_TX_DMA_IDX(qid), TX_RING_DMA_IDX_MASK, - FIELD_PREP(TX_RING_DMA_IDX_MASK, q->head)); + FIELD_PREP(TX_RING_DMA_IDX_MASK, 0)); return 0; } @@ -1031,17 +1026,21 @@ static int airoha_qdma_init_tx(struct airoha_qdma *qdma) static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q) { struct airoha_eth *eth = q->qdma->eth; + int i; spin_lock_bh(&q->lock); - while (q->queued) { - struct airoha_queue_entry *e = &q->entry[q->tail]; + for (i = 0; i < q->ndesc; i++) { + struct airoha_queue_entry *e = &q->entry[i]; + + if (!e->dma_addr) + continue; dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, DMA_TO_DEVICE); dev_kfree_skb_any(e->skb); + e->dma_addr = 0; e->skb = NULL; - - q->tail = (q->tail + 1) % q->ndesc; + list_add_tail(&e->list, &q->tx_list); q->queued--; } spin_unlock_bh(&q->lock); @@ -1883,20 +1882,6 @@ static u32 airoha_get_dsa_tag(struct sk_buff *skb, struct net_device *dev) #endif } -static bool airoha_dev_tx_queue_busy(struct airoha_queue *q, u32 nr_frags) -{ - u32 tail = q->tail <= q->head ? q->tail + q->ndesc : q->tail; - u32 index = q->head + nr_frags; - - /* completion napi can free out-of-order tx descriptors if hw QoS is - * enabled and packets with different priorities are queued to the same - * DMA ring. Take into account possible out-of-order reports checking - * if the tx queue is full using circular buffer head/tail pointers - * instead of the number of queued packets. - */ - return index >= tail; -} - static int airoha_get_fe_port(struct airoha_gdm_port *port) { struct airoha_qdma *qdma = port->qdma; @@ -1919,8 +1904,10 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, struct airoha_gdm_port *port = netdev_priv(dev); struct airoha_qdma *qdma = port->qdma; u32 nr_frags, tag, msg0, msg1, len; + struct airoha_queue_entry *e; struct netdev_queue *txq; struct airoha_queue *q; + LIST_HEAD(tx_list); void *data; int i, qid; u16 index; @@ -1966,7 +1953,7 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, txq = netdev_get_tx_queue(dev, qid); nr_frags = 1 + skb_shinfo(skb)->nr_frags; - if (airoha_dev_tx_queue_busy(q, nr_frags)) { + if (q->queued + nr_frags >= q->ndesc) { /* not enough space in the queue */ netif_tx_stop_queue(txq); spin_unlock_bh(&q->lock); @@ -1975,11 +1962,13 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, len = skb_headlen(skb); data = skb->data; - index = q->head; + + e = list_first_entry(&q->tx_list, struct airoha_queue_entry, + list); + index = e - q->entry; for (i = 0; i < nr_frags; i++) { struct airoha_qdma_desc *desc = &q->desc[index]; - struct airoha_queue_entry *e = &q->entry[index]; skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; dma_addr_t addr; u32 val; @@ -1989,7 +1978,15 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, if (unlikely(dma_mapping_error(dev->dev.parent, addr))) goto error_unmap; - index = (index + 1) % q->ndesc; + __list_del_entry(&e->list); + list_add_tail(&e->list, &tx_list); + e->skb = i ? NULL : skb; + e->dma_addr = addr; + e->dma_len = len; + + e = list_first_entry(&q->tx_list, struct airoha_queue_entry, + list); + index = e - q->entry; val = FIELD_PREP(QDMA_DESC_LEN_MASK, len); if (i < nr_frags - 1) @@ -2002,15 +1999,9 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, WRITE_ONCE(desc->msg1, cpu_to_le32(msg1)); WRITE_ONCE(desc->msg2, cpu_to_le32(0xffff)); - e->skb = i ? NULL : skb; - e->dma_addr = addr; - e->dma_len = len; - data = skb_frag_address(frag); len = skb_frag_size(frag); } - - q->head = index; q->queued += i; skb_tx_timestamp(skb); @@ -2019,7 +2010,7 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, if (netif_xmit_stopped(txq) || !netdev_xmit_more()) airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(qid), TX_RING_CPU_IDX_MASK, - FIELD_PREP(TX_RING_CPU_IDX_MASK, q->head)); + FIELD_PREP(TX_RING_CPU_IDX_MASK, index)); if (q->ndesc - q->queued < q->free_thr) netif_tx_stop_queue(txq); @@ -2029,10 +2020,14 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, return NETDEV_TX_OK; error_unmap: - for (i--; i >= 0; i--) { - index = (q->head + i) % q->ndesc; - dma_unmap_single(dev->dev.parent, q->entry[index].dma_addr, - q->entry[index].dma_len, DMA_TO_DEVICE); + while (!list_empty(&tx_list)) { + e = list_first_entry(&tx_list, struct airoha_queue_entry, + list); + __list_del_entry(&e->list); + dma_unmap_single(dev->dev.parent, e->dma_addr, e->dma_len, + DMA_TO_DEVICE); + e->dma_addr = 0; + list_add_tail(&e->list, &q->tx_list); } spin_unlock_bh(&q->lock); diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h index eb27a4ff51984ef376c6e94607ee2dc1a806488b..fbbc58133364baefafed30299ca0626c686b668e 100644 --- a/drivers/net/ethernet/airoha/airoha_eth.h +++ b/drivers/net/ethernet/airoha/airoha_eth.h @@ -169,7 +169,10 @@ enum trtcm_param { struct airoha_queue_entry { union { void *buf; - struct sk_buff *skb; + struct { + struct list_head list; + struct sk_buff *skb; + }; }; dma_addr_t dma_addr; u16 dma_len; @@ -193,6 +196,8 @@ struct airoha_queue { struct napi_struct napi; struct page_pool *page_pool; struct sk_buff *skb; + + struct list_head tx_list; }; struct airoha_tx_irq_queue { -- 2.51.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/2] net: airoha: Add the capability to consume out-of-order DMA tx descriptors 2025-11-03 10:27 ` [PATCH net-next 1/2] net: airoha: Add the capability to consume " Lorenzo Bianconi @ 2025-11-03 23:32 ` Jacob Keller 2025-11-05 2:30 ` Jakub Kicinski 1 sibling, 0 replies; 11+ messages in thread From: Jacob Keller @ 2025-11-03 23:32 UTC (permalink / raw) To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni Cc: linux-arm-kernel, linux-mediatek, netdev, Xuegang Lu [-- Attachment #1.1: Type: text/plain, Size: 1234 bytes --] On 11/3/2025 2:27 AM, Lorenzo Bianconi wrote: > EN7581 and AN7583 SoCs are capable of DMA mapping non-linear tx skbs on > non-consecutive DMA descriptors. This feature is useful when multiple > flows are queued on the same hw tx queue since it allows to fully utilize > the available tx DMA descriptors and to avoid the starvation of > high-priority flow we have in the current codebase due to head-of-line > blocking introduced by low-priority flows. > > Tested-by: Xuegang Lu <xuegang.lu@airoha.com> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > --- > drivers/net/ethernet/airoha/airoha_eth.c | 87 +++++++++++++++----------------- > drivers/net/ethernet/airoha/airoha_eth.h | 7 ++- > 2 files changed, 47 insertions(+), 47 deletions(-) > > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c > index 688faf999e4c0a30d53a25877b4a81a33ec7fca2..b717e3efe53cc9c86be8a39e7f9b03cc592e7281 100644 > --- a/drivers/net/ethernet/airoha/airoha_eth.c > +++ b/drivers/net/ethernet/airoha/airoha_eth.c > @@ -892,19 +892,13 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget) > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 236 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/2] net: airoha: Add the capability to consume out-of-order DMA tx descriptors 2025-11-03 10:27 ` [PATCH net-next 1/2] net: airoha: Add the capability to consume " Lorenzo Bianconi 2025-11-03 23:32 ` Jacob Keller @ 2025-11-05 2:30 ` Jakub Kicinski 2025-11-05 8:18 ` Lorenzo Bianconi 1 sibling, 1 reply; 11+ messages in thread From: Jakub Kicinski @ 2025-11-05 2:30 UTC (permalink / raw) To: Lorenzo Bianconi Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev, Xuegang Lu On Mon, 03 Nov 2025 11:27:55 +0100 Lorenzo Bianconi wrote: > + __list_del_entry(&e->list); > + list_add_tail(&e->list, &tx_list); list_move_tail() > + e->skb = i ? NULL : skb; > + e->dma_addr = addr; > + e->dma_len = len; > + > + e = list_first_entry(&q->tx_list, struct airoha_queue_entry, > + list); > + index = e - q->entry; > > val = FIELD_PREP(QDMA_DESC_LEN_MASK, len); > if (i < nr_frags - 1) > @@ -2029,10 +2020,14 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, > return NETDEV_TX_OK; > > error_unmap: > - for (i--; i >= 0; i--) { > - index = (q->head + i) % q->ndesc; > - dma_unmap_single(dev->dev.parent, q->entry[index].dma_addr, > - q->entry[index].dma_len, DMA_TO_DEVICE); > + while (!list_empty(&tx_list)) { > + e = list_first_entry(&tx_list, struct airoha_queue_entry, > + list); > + __list_del_entry(&e->list); > + dma_unmap_single(dev->dev.parent, e->dma_addr, e->dma_len, > + DMA_TO_DEVICE); > + e->dma_addr = 0; > + list_add_tail(&e->list, &q->tx_list); and here ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/2] net: airoha: Add the capability to consume out-of-order DMA tx descriptors 2025-11-05 2:30 ` Jakub Kicinski @ 2025-11-05 8:18 ` Lorenzo Bianconi 0 siblings, 0 replies; 11+ messages in thread From: Lorenzo Bianconi @ 2025-11-05 8:18 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev, Xuegang Lu [-- Attachment #1: Type: text/plain, Size: 1268 bytes --] On Nov 04, Jakub Kicinski wrote: > On Mon, 03 Nov 2025 11:27:55 +0100 Lorenzo Bianconi wrote: > > + __list_del_entry(&e->list); > > + list_add_tail(&e->list, &tx_list); > > list_move_tail() ack, I will fix it in v2. > > > + e->skb = i ? NULL : skb; > > + e->dma_addr = addr; > > + e->dma_len = len; > > + > > + e = list_first_entry(&q->tx_list, struct airoha_queue_entry, > > + list); > > + index = e - q->entry; > > > > val = FIELD_PREP(QDMA_DESC_LEN_MASK, len); > > if (i < nr_frags - 1) > > > @@ -2029,10 +2020,14 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, > > return NETDEV_TX_OK; > > > > error_unmap: > > - for (i--; i >= 0; i--) { > > - index = (q->head + i) % q->ndesc; > > - dma_unmap_single(dev->dev.parent, q->entry[index].dma_addr, > > - q->entry[index].dma_len, DMA_TO_DEVICE); > > + while (!list_empty(&tx_list)) { > > + e = list_first_entry(&tx_list, struct airoha_queue_entry, > > + list); > > + __list_del_entry(&e->list); > > + dma_unmap_single(dev->dev.parent, e->dma_addr, e->dma_len, > > + DMA_TO_DEVICE); > > + e->dma_addr = 0; > > + list_add_tail(&e->list, &q->tx_list); > > and here ack, I will fix it in v2. Regards, Lorenzo [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-03 10:27 [PATCH net-next 0/2] net: airoha: Allow mapping out-of-order DMA tx descriptors Lorenzo Bianconi 2025-11-03 10:27 ` [PATCH net-next 1/2] net: airoha: Add the capability to consume " Lorenzo Bianconi @ 2025-11-03 10:27 ` Lorenzo Bianconi 2025-11-03 23:36 ` Jacob Keller 2025-11-05 2:32 ` Jakub Kicinski 1 sibling, 2 replies; 11+ messages in thread From: Lorenzo Bianconi @ 2025-11-03 10:27 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lorenzo Bianconi Cc: linux-arm-kernel, linux-mediatek, netdev 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; + }; + }; }; struct airoha_tx_irq_queue { -- 2.51.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-03 10:27 ` [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct Lorenzo Bianconi @ 2025-11-03 23:36 ` Jacob Keller 2025-11-05 2:32 ` Jakub Kicinski 1 sibling, 0 replies; 11+ messages in thread From: Jacob Keller @ 2025-11-03 23:36 UTC (permalink / raw) To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni Cc: linux-arm-kernel, linux-mediatek, netdev [-- 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 --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-03 10:27 ` [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct Lorenzo Bianconi 2025-11-03 23:36 ` Jacob Keller @ 2025-11-05 2:32 ` Jakub Kicinski 2025-11-05 7:53 ` Lorenzo Bianconi 1 sibling, 1 reply; 11+ messages in thread From: Jakub Kicinski @ 2025-11-05 2:32 UTC (permalink / raw) To: Lorenzo Bianconi Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev On Mon, 03 Nov 2025 11:27:56 +0100 Lorenzo Bianconi wrote: > Do not allocate memory for rx-only fields for hw tx queues and for tx-only > fields for hw rx queues. Could you share more details (pahole) Given that napi_struct is in the same struct, 20B is probably not going to make much difference? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-05 2:32 ` Jakub Kicinski @ 2025-11-05 7:53 ` Lorenzo Bianconi 2025-11-06 0:28 ` Jakub Kicinski 0 siblings, 1 reply; 11+ messages in thread From: Lorenzo Bianconi @ 2025-11-05 7:53 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev [-- Attachment #1: Type: text/plain, Size: 3500 bytes --] > On Mon, 03 Nov 2025 11:27:56 +0100 Lorenzo Bianconi wrote: > > Do not allocate memory for rx-only fields for hw tx queues and for tx-only > > fields for hw rx queues. > > Could you share more details (pahole) > Given that napi_struct is in the same struct, 20B is probably not going > to make much difference? I agree the difference is not huge, I added this patch mainly for code readability. If you prefer I can drop the patch, I do not have a strong opinion about it. What do you think? net-next: struct airoha_queue { struct airoha_qdma * qdma; /* 0 8 */ spinlock_t lock; /* 8 4 */ /* XXX 4 bytes hole, try to pack */ struct airoha_queue_entry * entry; /* 16 8 */ struct airoha_qdma_desc * desc; /* 24 8 */ u16 head; /* 32 2 */ u16 tail; /* 34 2 */ int queued; /* 36 4 */ int ndesc; /* 40 4 */ int free_thr; /* 44 4 */ int buf_size; /* 48 4 */ /* XXX 4 bytes hole, try to pack */ struct napi_struct napi __attribute__((__aligned__(8))); /* 56 496 */ /* XXX last struct has 1 hole */ /* --- cacheline 8 boundary (512 bytes) was 40 bytes ago --- */ struct page_pool * page_pool; /* 552 8 */ struct sk_buff * skb; /* 560 8 */ /* size: 568, cachelines: 9, members: 13 */ /* sum members: 560, holes: 2, sum holes: 8 */ /* member types with holes: 1, total: 1 */ /* forced alignments: 1, forced holes: 1, sum forced holes: 4 */ /* last cacheline: 56 bytes */ } __attribute__((__aligned__(8))); net-next + airoha_queue reorg: struct airoha_queue { struct airoha_qdma * qdma; /* 0 8 */ spinlock_t lock; /* 8 4 */ /* XXX 4 bytes hole, try to pack */ struct airoha_queue_entry * entry; /* 16 8 */ struct airoha_qdma_desc * desc; /* 24 8 */ int queued; /* 32 4 */ int ndesc; /* 36 4 */ struct napi_struct napi __attribute__((__aligned__(8))); /* 40 496 */ /* XXX last struct has 1 hole */ /* --- cacheline 8 boundary (512 bytes) was 24 bytes ago --- */ union { struct { u16 head; /* 536 2 */ u16 tail; /* 538 2 */ int buf_size; /* 540 4 */ struct page_pool * page_pool; /* 544 8 */ struct sk_buff * skb; /* 552 8 */ }; /* 536 24 */ struct { struct list_head tx_list; /* 536 16 */ int free_thr; /* 552 4 */ }; /* 536 24 */ }; /* 536 24 */ /* size: 560, cachelines: 9, members: 8 */ /* sum members: 556, holes: 1, sum holes: 4 */ /* member types with holes: 1, total: 1 */ /* forced alignments: 1 */ /* last cacheline: 48 bytes */ } __attribute__((__aligned__(8))); Regards, Lorenzo [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-05 7:53 ` Lorenzo Bianconi @ 2025-11-06 0:28 ` Jakub Kicinski 2025-11-06 8:27 ` Lorenzo Bianconi 0 siblings, 1 reply; 11+ messages in thread From: Jakub Kicinski @ 2025-11-06 0:28 UTC (permalink / raw) To: Lorenzo Bianconi Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev On Wed, 5 Nov 2025 08:53:06 +0100 Lorenzo Bianconi wrote: > > On Mon, 03 Nov 2025 11:27:56 +0100 Lorenzo Bianconi wrote: > > > Do not allocate memory for rx-only fields for hw tx queues and for tx-only > > > fields for hw rx queues. > > > > Could you share more details (pahole) > > Given that napi_struct is in the same struct, 20B is probably not going > > to make much difference? > > I agree the difference is not huge, I added this patch mainly for code > readability. If you prefer I can drop the patch, I do not have a strong > opinion about it. What do you think? I would not do it but your call.. Perhaps staring at data structures in crash dumps w/ drgn made me overly cautions of unnecessary overlap. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct 2025-11-06 0:28 ` Jakub Kicinski @ 2025-11-06 8:27 ` Lorenzo Bianconi 0 siblings, 0 replies; 11+ messages in thread From: Lorenzo Bianconi @ 2025-11-06 8:27 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev [-- Attachment #1: Type: text/plain, Size: 845 bytes --] > On Wed, 5 Nov 2025 08:53:06 +0100 Lorenzo Bianconi wrote: > > > On Mon, 03 Nov 2025 11:27:56 +0100 Lorenzo Bianconi wrote: > > > > Do not allocate memory for rx-only fields for hw tx queues and for tx-only > > > > fields for hw rx queues. > > > > > > Could you share more details (pahole) > > > Given that napi_struct is in the same struct, 20B is probably not going > > > to make much difference? > > > > I agree the difference is not huge, I added this patch mainly for code > > readability. If you prefer I can drop the patch, I do not have a strong > > opinion about it. What do you think? > > I would not do it but your call.. Perhaps staring at data structures > in crash dumps w/ drgn made me overly cautions of unnecessary overlap. ack, fine. I will drop the patch in the next revision. Regards, Lorenzo [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-11-06 8:28 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-03 10:27 [PATCH net-next 0/2] net: airoha: Allow mapping out-of-order DMA tx descriptors Lorenzo Bianconi 2025-11-03 10:27 ` [PATCH net-next 1/2] net: airoha: Add the capability to consume " Lorenzo Bianconi 2025-11-03 23:32 ` Jacob Keller 2025-11-05 2:30 ` Jakub Kicinski 2025-11-05 8:18 ` Lorenzo Bianconi 2025-11-03 10:27 ` [PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct Lorenzo Bianconi 2025-11-03 23:36 ` Jacob Keller 2025-11-05 2:32 ` Jakub Kicinski 2025-11-05 7:53 ` Lorenzo Bianconi 2025-11-06 0:28 ` Jakub Kicinski 2025-11-06 8:27 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).