kni: add chained mbufs support
PATCH 1/1 kni: add chained mbufs support
rx_q fifo may have chained mbufs, merge them into single skb before handing to the network stack.
--- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 4 +- lib/librte_eal/linuxapp/kni/kni_net.c | 83 ++++++++++++++++------ 2 files changed, 64 insertions(+), 23 deletions(-)
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +3 -1
@@ -113,7 +113,9 @@ struct rte_kni_mbuf { void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));char pad0[10 ];uint16_t data_off;/**< Start address of data in segment buffer. */ -char pad1[4 ]; +char pad1[2 ]; +uint8_t nb_segs;/**< Number of segments. */ +char pad4[1 ];uint64_t ol_flags;/**< Offload features. */ char pad2[4 ];uint32_t pkt_len;/**< Total pkt len: sum of all segment data_len. */
lib/librte_eal/linuxapp/kni/kni_net.c +61 -22
117 lines not on this page · raw message
Signature · 1 line
2.5.5
Have you tested with it?
I think we need to test it in a longer time, e.g. 1 hour My commetns inlined.
Thanks,
Helin
Quoted 53 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, April 26, 2016 12:11 AM
To: [email protected]
Cc: Zhang, Helin; Yigit, Ferruh
Subject: [PATCH] kni: add chained mbufs support
rx_qfifo may have chained mbufs, merge them into single skb before handing to the network stack.Signed-off-by Ferruh Yigit <[email protected]>--- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 4 +- lib/librte_eal/linuxapp/kni/kni_net.c | 83 ++++++++++++++++------ 2 files changed, 64 insertions(+), 23 deletions(-)lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +3
-1@@ -113,7 +113,9 @@ struct rte_kni_mbuf { void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));char pad0[10 ];uint16_t data_off;/**< Start address of data in segment buffer. */ -char pad1[4 ]; +char pad1[2 ]; +uint8_t nb_segs;/**< Number of segments. */ +char pad4[1 ];uint64_t ol_flags;/**< Offload features. */ char pad2[4 ];
uint32_tpkt_len; /**< Total pkt len: sum of all segmentdata_len.
*/lib/librte_eal/linuxapp/kni/kni_net.c +2
-1@@ -156,7 +156,8 @@ kni_net_rx_normal(struct kni_dev *kni)/* Transfer received packets to netif */ for (i =0 ; i < num_rx; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; - len = kva->data_len; + len = kva->pkt_len; + data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + kni->mbuf_kva;@@ -165,22 +166,41 @@ kni_net_rx_normal(struct kni_dev *kni)KNI_ERR ("Out of mem, dropping pkts\n" );/* Update statistics */ kni->stats.rx_dropped++;
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 175
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +6
-3+continue ; } -else { -/* Align IP on 16B boundary */ -skb_reserve (skb,2 ); + +/* Align IP on 16B boundary */ +skb_reserve (skb,2 ); + +if (kva->nb_segs ==0 ) {
I guess it should compare nb_segs with 1, but not 0. Am I wrong?
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni)
Quoted 11 lines
lib/librte_eal/linuxapp/kni/kni_net.c +4
-5memcpy (skb_put (skb, len), data_kva, len); - skb->dev = dev; - skb->protocol =eth_type_trans (skb, dev); - skb->ip_summed =CHECKSUM_UNNECESSARY ; + }else { +int nb_segs; +int kva_nb_segs = kva->nb_segs; -/* Call netif interface */ -netif_rx_ni (skb); +for (nb_segs =0 ; nb_segs < kva_nb_segs; nb_segs++)
Kva_nb_segs might not needed at all, use kva->nb_segs directly?
Quoted 43 lines
lib/librte_eal/linuxapp/kni/kni_net.c +20
-3{ +memcpy (skb_put (skb, kva->data_len), + data_kva, kva->data_len); -/* Update statistics */ - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; +if (!kva->next) +break ; + + kva = kva->next - kni->mbuf_va + kni- >mbuf_kva; + data_kva = kva->buf_addr + kva->data_off + - kni->mbuf_va + kni->mbuf_kva; + } } + + skb->dev = dev; + skb->protocol =eth_type_trans (skb, dev); + skb->ip_summed =CHECKSUM_UNNECESSARY ; + +/* Call netif interface */ +netif_rx_ni (skb); + +/* Update statistics */ + kni->stats.rx_bytes += len; + kni->stats.rx_packets++; }lib/librte_eal/linuxapp/kni/kni_net.c +1
-1/* Burst enqueue mbufs into free_q */ @@ -317,7 +337,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)/* Copy mbufs to sk buffer and then call tx interface */ for (i =0 ; i < num; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; - len = kva->data_len; + len = kva->pkt_len; data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + kni->mbuf_kva;@@ -338,20 +358,39 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)if (skb ==NULL ) {KNI_ERR ("Out of mem, dropping pkts\n" ); kni->stats.rx_dropped++;
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_lo_fifo_skb(struct kni_dev *kni) · line 367
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +6
-3+continue ; } -else { -/* Align IP on 16B boundary */ -skb_reserve (skb,2 ); + +/* Align IP on 16B boundary */ +skb_reserve (skb,2 ); + +if (kva->nb_segs ==0 ) {
The same commnets as above.
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni)
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +4
-4memcpy (skb_put (skb, len), data_kva, len); - skb->dev = dev; - skb->ip_summed =CHECKSUM_UNNECESSARY ; + }else { +int nb_segs; +int kva_nb_segs = kva->nb_segs; - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; +for (nb_segs =0 ; nb_segs < kva_nb_segs; nb_segs++)
The same comments as above.
Quoted 29 lines
lib/librte_eal/linuxapp/kni/kni_net.c +18
-2{ +memcpy (skb_put (skb, kva->data_len), + data_kva, kva->data_len); + +if (!kva->next) +break ; -/* call tx interface */ -kni_net_tx (skb, dev); + kva = kva->next - kni->mbuf_va + kni- >mbuf_kva; + data_kva = kva->buf_addr + kva->data_off + - kni->mbuf_va + kni->mbuf_kva; + } } + + skb->dev = dev; + skb->ip_summed =CHECKSUM_UNNECESSARY ; + + kni->stats.rx_bytes += len; + kni->stats.rx_packets++; + +/* call tx interface */ +kni_net_tx (skb, dev); }/* enqueue all the mbufs from
rx_qintofree_q*/
--
2.5.5
Quoted 1 line · Helin
Have you tested with it?
Yes, has been tested.
Quoted 1 line
I think we need to test it in a longer time, e.g. 1 hour
I will make a longevity test before sending next patch.
Quoted 54 lines
My commetns inlined.
Thanks,
HelinQuoted 49 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, April 26, 2016 12:11 AM
To: [email protected]
Cc: Zhang, Helin; Yigit, Ferruh
Subject: [PATCH] kni: add chained mbufs support
rx_qfifo may have chained mbufs, merge them into single skb before handing to the network stack.Signed-off-by Ferruh Yigit <[email protected]>--- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 4 +- lib/librte_eal/linuxapp/kni/kni_net.c | 83 ++++++++++++++++------ 2 files changed, 64 insertions(+), 23 deletions(-)lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +3
-1@@ -113,7 +113,9 @@ struct rte_kni_mbuf { void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));char pad0[10 ];uint16_t data_off;/**< Start address of data in segment buffer. */ -char pad1[4 ]; +char pad1[2 ]; +uint8_t nb_segs;/**< Number of segments. */ +char pad4[1 ];uint64_t ol_flags;/**< Offload features. */ char pad2[4 ];
uint32_tpkt_len; /**< Total pkt len: sum of all segmentdata_len.
*/lib/librte_eal/linuxapp/kni/kni_net.c +2
-1@@ -156,7 +156,8 @@ kni_net_rx_normal(struct kni_dev *kni)/* Transfer received packets to netif */ for (i =0 ; i < num_rx; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; - len = kva->data_len; + len = kva->pkt_len; + data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + kni->mbuf_kva;
Quoted 16 lines
Quoted 4 lines
lib/librte_eal/linuxapp/kni/kni_net.c +0
-0@@ -165,22 +166,41 @@ kni_net_rx_normal(struct kni_dev *kni)KNI_ERR ("Out of mem, dropping pkts\n" );/* Update statistics */ kni->stats.rx_dropped++;lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 175
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +6
-3+continue ; } -else { -/* Align IP on 16B boundary */ -skb_reserve (skb,2 ); + +/* Align IP on 16B boundary */ +skb_reserve (skb,2 ); + +if (kva->nb_segs ==0 ) {I guess it should compare
nb_segswith 1, but not 0. Am I wrong?
Right, this needs to be 1, I will send a new patch.
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/linuxapp/kni/kni_net.c +3
-3memcpy (skb_put (skb, len), data_kva, len); - skb->dev = dev; - skb->protocol =eth_type_trans (skb, dev); - skb->ip_summed =CHECKSUM_UNNECESSARY ; + }else { +int nb_segs; +int kva_nb_segs = kva->nb_segs;
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni)
Quoted 3 lines
lib/librte_eal/linuxapp/kni/kni_net.c +1
-2-/* Call netif interface */ -netif_rx_ni (skb); +for (nb_segs =0 ; nb_segs < kva_nb_segs; nb_segs++)
Kva_nb_segsmight not needed at all, usekva->nb_segsdirectly?
It is needed, kva keeps updated, so need to save number of segment for first mbuf.
Quoted 96 lines
Quoted 43 lines
lib/librte_eal/linuxapp/kni/kni_net.c +20
-3{ +memcpy (skb_put (skb, kva->data_len), + data_kva, kva->data_len); -/* Update statistics */ - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; +if (!kva->next) +break ; + + kva = kva->next - kni->mbuf_va + kni- > mbuf_kva; + data_kva = kva->buf_addr + kva->data_off + - kni->mbuf_va + kni->mbuf_kva; + } } + + skb->dev = dev; + skb->protocol =eth_type_trans (skb, dev); + skb->ip_summed =CHECKSUM_UNNECESSARY ; + +/* Call netif interface */ +netif_rx_ni (skb); + +/* Update statistics */ + kni->stats.rx_bytes += len; + kni->stats.rx_packets++; }lib/librte_eal/linuxapp/kni/kni_net.c +1
-1/* Burst enqueue mbufs into free_q */ @@ -317,7 +337,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)/* Copy mbufs to sk buffer and then call tx interface */ for (i =0 ; i < num; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; - len = kva->data_len; + len = kva->pkt_len; data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + kni->mbuf_kva;@@ -338,20 +358,39 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)if (skb ==NULL ) {KNI_ERR ("Out of mem, dropping pkts\n" ); kni->stats.rx_dropped++;lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_lo_fifo_skb(struct kni_dev *kni) · line 367
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +6
-3+continue ; } -else { -/* Align IP on 16B boundary */ -skb_reserve (skb,2 ); + +/* Align IP on 16B boundary */ +skb_reserve (skb,2 ); + +if (kva->nb_segs ==0 ) {The same commnets as above.
lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni)
Quoted 10 lines
lib/librte_eal/linuxapp/kni/kni_net.c +4
-4memcpy (skb_put (skb, len), data_kva, len); - skb->dev = dev; - skb->ip_summed =CHECKSUM_UNNECESSARY ; + }else { +int nb_segs; +int kva_nb_segs = kva->nb_segs; - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; +for (nb_segs =0 ; nb_segs < kva_nb_segs; nb_segs++)The same comments as above.
Quoted 29 lines
lib/librte_eal/linuxapp/kni/kni_net.c +18
-2{ +memcpy (skb_put (skb, kva->data_len), + data_kva, kva->data_len); + +if (!kva->next) +break ; -/* call tx interface */ -kni_net_tx (skb, dev); + kva = kva->next - kni->mbuf_va + kni- > mbuf_kva; + data_kva = kva->buf_addr + kva->data_off + - kni->mbuf_va + kni->mbuf_kva; + } } + + skb->dev = dev; + skb->ip_summed =CHECKSUM_UNNECESSARY ; + + kni->stats.rx_bytes += len; + kni->stats.rx_packets++; + +/* call tx interface */ +kni_net_tx (skb, dev); }/* enqueue all the mbufs from
rx_qintofree_q*/
--
2.5.5
PATCH v2 1/1 kni: add chained mbufs support
rx_q fifo may have chained mbufs, merge them into single skb before handing to the network stack.
--- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 4 +- lib/librte_eal/linuxapp/kni/kni_net.c | 83 ++++++++++++++++------ 2 files changed, 64 insertions(+), 23 deletions(-)
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +3 -1
@@ -113,7 +113,9 @@ struct rte_kni_mbuf { void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));char pad0[10 ];uint16_t data_off;/**< Start address of data in segment buffer. */ -char pad1[4 ]; +char pad1[2 ]; +uint8_t nb_segs;/**< Number of segments. */ +char pad4[1 ];uint64_t ol_flags;/**< Offload features. */ char pad2[4 ];uint32_t pkt_len;/**< Total pkt len: sum of all segment data_len. */
lib/librte_eal/linuxapp/kni/kni_net.c +61 -22
117 lines not on this page · raw message
Signature · 1 line
2.5.5
Quoted 9 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, April 26, 2016 8:38 PM
To: [email protected]
Cc: Zhang, Helin <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: [PATCH v2] kni: add chained mbufs support
Quoted 4 lines
rx_qfifo may have chained mbufs, merge them into single skb before handing to the network stack.Signed-off-by Ferruh Yigit <[email protected]>
Thomas Monjalon
AppliedQuoted 5 lines
Quoted 4 lines
rx_qfifo may have chained mbufs, merge them into single skb before handing to the network stack.Signed-off-by Ferruh Yigit <[email protected]>Acked-by Helin Zhang <[email protected]>
Applied, thanks