app/testpmd: fix random number of Tx segments
PATCH 1/1 app/testpmd: fix random number of Tx segments
When random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14 + 20 + 8 + 16 bytes. Otherwise the Tx engine may cause the application to crash.
Bugzilla ID: 797
--- app/test-pmd/config.c | 16 +++++++++++----- app/test-pmd/testpmd.c | 5 +++++ app/test-pmd/testpmd.h | 5 +++++ app/test-pmd/txonly.c | 7 +++++-- 4 files changed, 26 insertions(+), 7 deletions(-)
app/test-pmd/config.c +11 -5
@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16). */ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) { fprintf(stderr,
@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof (struct rte_ether_hdr ) +20 +8 +16 )) + tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }
app/test-pmd/testpmd.c +5 -0
@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { };uint8_t tx_pkt_nb_segs =1 ;/**< Number of segments in TXONLY packets */ +/**< Minimum number of segments in TXONLY packets to accommodate all packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h +5 -0
@@ -464,6 +464,11 @@ enum dcb_mode_enableextern uint16_t tx_pkt_length;/**< Length of TXONLY packet */ extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT ];/**< Seg. lengths */ extern uint8_t tx_pkt_nb_segs;/**< Number of segments in TX packets */ + +/**< Minimum number of segments in TXONLY packets to accommodate all packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs;extern uint32_t tx_pkt_times_intra;extern uint32_t tx_pkt_times_inter;
app/test-pmd/txonly.c +5 -2
@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs;
Signature · 1 line
1.8.3.1
Hi
Quoted 28 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Thursday, September 2, 2021 16:20
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH] app/testpmd: fix random number of Tx segmentsWhen random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14 + 20 + 8 + 16 bytes. Otherwise the Tx engine may cause the application to crash.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoing packets")Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/config.c | 16 +++++++++++----- app/test-pmd/testpmd.c | 5 +++++ app/test-pmd/testpmd.h | 5 +++++ app/test-pmd/txonly.c | 7 +++++-- 4 files changed, 26 insertions(+), 7 deletions(-)app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-031d8ba1..5105b3b 100644
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3841
Quoted 7 lines
app/test-pmd/config.c +2
-2@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16).
I don't really agree on this. Most of the time, txonly generate packets with Eth/IP/UDP. It's not fair to limit the hdr length to include timestamp in all cases.
And to be honest, I don't see why you need to add "tx_pkt_nb_min_segs". It's only used in txonly when "TX_PKT_SPLIT_RND". So this issue is because when "TX_PKT_SPLIT_RND", the random nb_segs is not enough for the hdr.
But if you read txonly carefully, if "TX_PKT_SPLIT_RND", the first segment length should be equal or greater than 42 (14+20+8). Because when "TX_PKT_SPLIT_RND", update_pkt_header() should be called. And that function doesn't deal with header in multi-segments. I think there's bug here.
So I think you should only add a check in pkt_burst_prepare() in txonly().
if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) || txonly_multi_flow)
+ if (tx_pkt_seg_lengths[0] < 42) {
+ err_log;
+ return false;
+ }
update_pkt_header(pkt, pkt_len);
As for timestamp, maybe refer to "pkt_copy_split" in csumonly.c is better? Copy the extra to the last segment if it's not enough. Not sure how to deal with this issue better.
Quoted 79 lines
app/test-pmd/config.c +9
-3*/ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) { fprintf(stderr,@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof (struct rte_ether_hdr ) +20 +8 +16 )) + tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-06cbe9ba..c496e59 100644
app/test-pmd/testpmd.c +0
-0@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { }; uint8_t
tx_pkt_nb_segs= 1; /**< Number of segments in TXONLY packets */app/test-pmd/testpmd.c +6
-0+/**< Minimum number of segments in TXONLY packets to accommodate all +packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-016a3598..f5bc427 100644
app/test-pmd/testpmd.h +0
-0@@ -464,6 +464,11 @@ enum dcb_mode_enable extern uint16_t
tx_pkt_length; /**< Length of TXONLY packet */ externuint16_ttx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ externuint8_ttx_pkt_nb_segs; /**< Number of segments in TX packets */app/test-pmd/testpmd.h +6
-0+ +/**< Minimum number of segments in TXONLY packets to accommodate all +packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs;extern uint32_t tx_pkt_times_intra;extern uint32_t tx_pkt_times_inter;app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..27e4458 100644
app/test-pmd/txonly.c +5
-3@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs; --1.8.3.1
Quoted 68 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 4:59 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsHi
Quoted 32 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Thursday, September 2, 2021 16:20
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH] app/testpmd: fix random number of Tx segmentsWhen random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14 + 20 + 8 + 16 bytes. Otherwise the Tx engine may cause the application to crash.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoingpackets")
Cc: [email protected]Signed-off-by Alvin Zhang <[email protected]>---
app/test-pmd/config.c| 16 +++++++++++-----app/test-pmd/testpmd.c
| 5
+++++app/test-pmd/testpmd.h| 5 +++++app/test-pmd/txonly.c| 7 +++++ +++++--4 files changed, 26 insertions(+), 7 deletions(-)app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-031d8ba1..5105b3b 100644
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3841
Quoted 7 lines
app/test-pmd/config.c +2
-2@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16). I don't really agree on this. Most of the time, txonly generate packets with Eth/IP/UDP. It's not fair to limit the hdr length to include timestamp in all cases. And to be honest, I don't see why you need to add "
tx_pkt_nb_min_segs". It's only used in txonly when "TX_PKT_SPLIT_RND". So this issue is because when "TX_PKT_SPLIT_RND", the randomnb_segsis not enough for the hdr.But if you read txonly carefully, if "
TX_PKT_SPLIT_RND", the first segment length should be equal or greater than 42 (14+20+8). Because when "TX_PKT_SPLIT_RND",update_pkt_header()should be called. And that function doesn't deal with header in multi-segments.
I think there's bug here.So I think you should only add a check in
pkt_burst_prepare()intxonly().if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) || txonly_multi_flow)(quoted diff) +4
-0+ if (tx_pkt_seg_lengths[0] < 42) { + err_log; + return false; + }
Quoted 1 line
update_pkt_header(pkt, pkt_len);
Yes, I didn't notice the updating for the UDP header, but the bug first occurs in this function copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));
not in update_pkt_header.
Here we expecting users should set minimum 42 byte for first segment seems ok,
But I think we putting the check in configuring the data space length of first segment is more graceful.
Quoted 85 lines
As for timestamp, maybe refer to "
pkt_copy_split" incsumonly.cis better? Copy the extra to the last segment if it's not enough. Not sure how to deal with this issue better.Quoted 80 lines
app/test-pmd/config.c +9
-3*/ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) { fprintf(stderr,@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof (struct rte_ether_hdr ) +20 +8 +16 )) + tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-06cbe9ba..c496e59 100644
app/test-pmd/testpmd.c +0
-0@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { };
uint8_ttx_pkt_nb_segs= 1; /**< Number of segments in TXONLY packets */app/test-pmd/testpmd.c +6
-0+/**< Minimum number of segments in TXONLY packets to accommodate all +packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-016a3598..f5bc427 100644
app/test-pmd/testpmd.h +0
-0@@ -464,6 +464,11 @@ enum dcb_mode_enable extern uint16_t
tx_pkt_length; /**< Length of TXONLY packet */ externuint16_ttx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ externuint8_ttx_pkt_nb_segs; /**< Number of segments in TX packets */app/test-pmd/testpmd.h +6
-0+ +/**< Minimum number of segments in TXONLY packets to accommodate all +packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs;extern uint32_t tx_pkt_times_intra;extern uint32_t tx_pkt_times_inter;app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..27e4458 100644
app/test-pmd/txonly.c +5
-3@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs; --1.8.3.1
Quoted 86 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Monday, September 6, 2021 18:04
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 39 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 4:59 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsHi
Quoted 29 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Thursday, September 2, 2021 16:20
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH] app/testpmd: fix random number of Tx segmentsWhen random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14 + 20 + 8 + 16 bytes. Otherwise the Tx engine may cause the application to crash.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoingpackets")
Cc: [email protected]Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/config.c | 16 +++++++++++-----
app/test-pmd/testpmd.c
| 5
+++++app/test-pmd/testpmd.h| 5 +++++app/test-pmd/txonly.c| +++++ 7
+++++ +++++--4 files changed, 26 insertions(+), 7 deletions(-)Quoted 15 lines
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3841
Quoted 12 lines
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-031d8ba1..5105b3b 100644
app/test-pmd/config.c +2
-2@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16). I don't really agree on this. Most of the time, txonly generate packets with Eth/IP/UDP. It's not fair to limit the hdr length to include
timestamp in all cases.
Quoted 3 lines
And to be honest, I don't see why you need to add "
tx_pkt_nb_min_segs". It's only used in txonly when "TX_PKT_SPLIT_RND". So this issue is because when "TX_PKT_SPLIT_RND", therandom
nb_segsis not enough for the hdr.Quoted 13 lines
But if you read txonly carefully, if "
TX_PKT_SPLIT_RND", the first segment length should be equal or greater than 42 (14+20+8). Because when "TX_PKT_SPLIT_RND",update_pkt_header()should be called. And that function doesn't deal with header in multi-segments. I think there's bug here.So I think you should only add a check in
pkt_burst_prepare()intxonly().if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) || txonly_multi_flow)(quoted diff) +4
-0+ if (tx_pkt_seg_lengths[0] < 42) { + err_log; + return false; + }Quoted 1 line
update_pkt_header(pkt, pkt_len);Yes, I didn't notice the updating for the UDP header, but the bug first occurs in this function copy_buf_to_pkt(&pkt_udp_hdr,
sizeof(pkt_udp_hdr), pkt,
Quoted 7 lines
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));not in
update_pkt_header.Here we expecting users should set minimum 42 byte for first segment seems ok, But I think we putting the check in configuring the data space length of first segment is more graceful.
No. You didn't get my point. It's not graceful at all.
The segment fault will only happen when "TX_PKT_SPLIT_RND". Because the hdr may take 2 segs while random nb_segs is only 1. But if it's not "TX_PKT_SPLIT_RND", the current set_tx_pkt_segments() already make sure pkt_len is enough for 42.
So the only case you need to deal with is "TX_PKT_SPLIT_RND". And since "TX_PKT_SPLIT_RND" actually needs the first segment to be enough to contain 42 bytes. And in cmd_set_txpkts_parsed, you may not get the configuration to know if it will be configured as "TX_PKT_SPLIT_RND". That's why you should check before update_pkt_header().
In this way, when it's NOT "TX_PKT_SPLIT_RND", it will maintain the old behavior that hdrs may cross several segs which makes more sense.
Quoted 87 lines
Quoted 87 lines
As for timestamp, maybe refer to "
pkt_copy_split" incsumonly.cis better? Copy the extra to the last segment if it's not enough. Not sure how to deal with this issue better.Quoted 81 lines
app/test-pmd/config.c +9
-3*/ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) { fprintf(stderr,@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof (struct rte_ether_hdr ) +20 +8 +16 )) + tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-06cbe9ba..c496e59 100644
app/test-pmd/testpmd.c +0
-0@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { };
uint8_ttx_pkt_nb_segs= 1; /**< Number of segments in TXONLY packets */app/test-pmd/testpmd.c +6
-0+/**< Minimum number of segments in TXONLY packets to accommodate +all packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-016a3598..f5bc427 100644
app/test-pmd/testpmd.h +0
-0@@ -464,6 +464,11 @@ enum dcb_mode_enable extern uint16_t
tx_pkt_length; /**< Length of TXONLY packet */ externuint16_ttx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ externuint8_ttx_pkt_nb_segs; /**< Number of segments in TX packets */app/test-pmd/testpmd.h +6
-0+ +/**< Minimum number of segments in TXONLY packets to accommodate +all packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs; extern uint32_t tx_pkt_times_intra; extern uint32_t
tx_pkt_times_inter;app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..27e4458 100644
app/test-pmd/txonly.c +5
-3@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs; --1.8.3.1
Quoted 87 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 6:55 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 77 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Monday, September 6, 2021 18:04
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 40 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 4:59 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsHi
Quoted 30 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Thursday, September 2, 2021 16:20
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH] app/testpmd: fix random number of Tx segmentsWhen random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14 + 20 + 8 +
16 bytes. Otherwise the Tx engine may cause the application to crash.Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoingpackets")
Cc: [email protected]Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/config.c | 16 +++++++++++-----
app/test-pmd/testpmd.c
| 5
+++++app/test-pmd/testpmd.h| 5 +++++app/test-pmd/txonly.c| +++++ 7
+++++ +++++--4 files changed, 26 insertions(+), 7 deletions(-)Quoted 16 lines
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3841
Quoted 12 lines
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-031d8ba1..5105b3b 100644
app/test-pmd/config.c +2
-2@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16). I don't really agree on this. Most of the time, txonly generate packets with Eth/IP/UDP. It's not fair to limit the hdr length to include
timestamp in all cases.
Quoted 4 lines
And to be honest, I don't see why you need to add "
tx_pkt_nb_min_segs". It's only used in txonly when "TX_PKT_SPLIT_RND". So this issue is because when "TX_PKT_SPLIT_RND", therandom
nb_segsis not enough for the hdr.Quoted 7 lines
But if you read txonly carefully, if "
TX_PKT_SPLIT_RND", the first segment length should be equal or greater than 42 (14+20+8). Because when "TX_PKT_SPLIT_RND",update_pkt_header()should be called. And that function doesn't deal with header in multi-segments. I think there's bug here.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
So I think you should only add a check in
pkt_burst_prepare()intxonly().if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) ||
txonly_multi_flow)(quoted diff) +4
-0+ if (tx_pkt_seg_lengths[0] < 42) { + err_log; + return false; + }update_pkt_header(pkt, pkt_len);
As above, If user have below configuration, there will no one packet be sent out and have lots and lots of repeated annoying logs. testpmd> set fwd txonly
Set txonly packet forwarding mode
testpmd> set txpkts 40,64
testpmd> set txsplit rand
testpmd> start
txonly packet forwarding - ports=1 - cores=1 - streams=4 - NUMA support enabled, MP allocation mode: native Logical Core 2 (socket 0) forwards packets on 4 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
RX P=0/Q=1 (socket 0) -> TX P=0/Q=1 (socket 0) peer=02:00:00:00:00:00
RX P=0/Q=2 (socket 0) -> TX P=0/Q=2 (socket 0) peer=02:00:00:00:00:00
RX P=0/Q=3 (socket 0) -> TX P=0/Q=3 (socket 0) peer=02:00:00:00:00:00
txonly packet forwarding packets/burst=32 packet len=104 - nb packet segments=2 nb forwarding cores=1 - nb forwarding ports=1 port 0: RX queue number: 4 Tx queue number: 4
Rx offloads=0x0 Tx offloads=0x10000
RX queue: 0
RX desc=1024 - RX free threshold=32
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
RX Offloads=0x0
TX queue: 0
TX desc=1024 - TX free threshold=32
TX threshold registers: pthresh=32 hthresh=0 wthresh=0
TX offloads=0x10000 - TX RS bit threshold=32tx_pkt_seg_lengths[0] must bigger than 41 bytes tetx_pkt_seg_lengths[0] must bigger than 41 bytes stpmd> tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes
...
...
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 0 TX-dropped: 0 TX-total: 0
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 0 TX-dropped: 0 TX-total: 0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
By the way, if multi flow was enabled, the ip header also will be updated, so we should put the check before below codes.
if (txonly_multi_flow) {
uint8_t ip_var = RTE_PER_LCORE(_ip_var);
struct rte_ipv4_hdr *ip_hdr;
uint32_t addr;
ip_hdr = rte_pktmbuf_mtod_offset(pkt,
struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
/*
* Generate multiple flows by varying IP src addr. This
* enables packets are well distributed by RSS in
* receiver side if any and txonly mode can be a decent
* packet generator for developer's quick performance
* regression test.
*/
addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id();
ip_hdr->src_addr = rte_cpu_to_be_32(addr);
RTE_PER_LCORE(_ip_var) = ip_var;
}Quoted 115 lines
Quoted 3 lines
Yes, I didn't notice the updating for the UDP header, but the bug first occurs in this function copy_buf_to_pkt(&pkt_udp_hdr,
sizeof(pkt_udp_hdr), pkt,Quoted 7 lines
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));not in
update_pkt_header.Here we expecting users should set minimum 42 byte for first segment seems ok, But I think we putting the check in configuring the data space length of first segment is more graceful.
No. You didn't get my point. It's not graceful at all.
The segment fault will only happen when "TX_PKT_SPLIT_RND". Because the hdr may take 2 segs while randomnb_segsis only 1.
But if it's not "TX_PKT_SPLIT_RND", the currentset_tx_pkt_segments()already make surepkt_lenis enough for 42.So the only case you need to deal with is "
TX_PKT_SPLIT_RND". And since "TX_PKT_SPLIT_RND" actually needs the first segment to be enough to contain 42 bytes.
And incmd_set_txpkts_parsed, you may not get the configuration to know if it will be configured as "TX_PKT_SPLIT_RND". That's why you should check beforeupdate_pkt_header().In this way, when it's NOT "
TX_PKT_SPLIT_RND", it will maintain the old behavior that hdrs may cross several segs which makes more sense.Quoted 87 lines
Quoted 87 lines
As for timestamp, maybe refer to "
pkt_copy_split" incsumonly.cis better? Copy the extra to the last segment if it's not enough. Not sure how to deal with this issue better.Quoted 81 lines
app/test-pmd/config.c +9
-3*/ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) { fprintf(stderr,@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof (struct rte_ether_hdr ) +20 +8 +16 )) + tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-06cbe9ba..c496e59 100644
app/test-pmd/testpmd.c +0
-0@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { };
uint8_ttx_pkt_nb_segs= 1; /**< Number of segments in TXONLY packets */app/test-pmd/testpmd.c +6
-0+/**< Minimum number of segments in TXONLY packets to accommodate +all packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-016a3598..f5bc427 100644
app/test-pmd/testpmd.h +0
-0@@ -464,6 +464,11 @@ enum dcb_mode_enable extern uint16_t
tx_pkt_length; /**< Length of TXONLY packet */ externuint16_ttx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ externuint8_ttx_pkt_nb_segs; /**< Number of segments in TX packets */app/test-pmd/testpmd.h +6
-0+ +/**< Minimum number of segments in TXONLY packets to accommodate +all packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs; extern uint32_t tx_pkt_times_intra; extern uint32_t
tx_pkt_times_inter;app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..27e4458 100644
app/test-pmd/txonly.c +5
-3@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs; --1.8.3.1
Quoted 186 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Tuesday, September 7, 2021 10:25
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 89 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 6:55 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 79 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Monday, September 6, 2021 18:04
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsQuoted 42 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Monday, September 6, 2021 4:59 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] app/testpmd: fix random number of Tx segmentsHi
Quoted 32 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Thursday, September 2, 2021 16:20
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH] app/testpmd: fix random number of Tx segmentsWhen random number of segments in Tx packets is enabled, the total data space length of all segments must be greater or equal than the size of an Eth/IP/UDP/timestamp packet, that's total 14
+ 20 +
8 +
16 bytes. Otherwise the Tx engine may cause the application to crash.Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoingpackets")
Cc: [email protected]Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/config.c | 16 +++++++++++-----
app/test-pmd/testpmd.c
| 5
+++++app/test-pmd/testpmd.h| 5 +++++app/test-pmd/txonly.c+++++ |
+++++ 7
+++++ +++++--4 files changed, 26 insertions(+), 7 deletions(-)Quoted 16 lines
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3841
Quoted 12 lines
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-031d8ba1..5105b3b 100644
app/test-pmd/config.c +2
-2@@ -3837,10 +3837,11 @@ struct igb_ring_desc_16_bytes {* Check that each segment length is greater or equal than * the mbuf data size. * Check also that the total packet length is greater or equal than the -* size of an empty UDP/IP packet (sizeof(struct rte_ether_hdr) + -* 20 + 8). +* size of an Eth/IP/UDP + timestamp packet +* (sizeof(struct rte_ether_hdr) + 20 + 8 + 16). I don't really agree on this. Most of the time, txonly generate packets with Eth/IP/UDP. It's not fair to limit the hdr length to include
timestamp in all cases.
Quoted 4 lines
And to be honest, I don't see why you need to add "
tx_pkt_nb_min_segs". It's only used in txonly when "TX_PKT_SPLIT_RND". So this issue is because when "TX_PKT_SPLIT_RND", therandom
nb_segsis not enough for the hdr.Quoted 7 lines
But if you read txonly carefully, if "
TX_PKT_SPLIT_RND", the first segment length should be equal or greater than 42 (14+20+8). Because when "TX_PKT_SPLIT_RND",update_pkt_header()should be called. And that function doesn't deal with header in multi-segments. I think there's bug here.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
So I think you should only add a check in
pkt_burst_prepare()intxonly().if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) ||
txonly_multi_flow)(quoted diff) +4
-0+ if (tx_pkt_seg_lengths[0] < 42) { + err_log; + return false; + }update_pkt_header(pkt, pkt_len);As above, If user have below configuration, there will no one packet be sent out and have lots and lots of repeated annoying logs.
testpmd> set fwd txonly
Set txonly packet forwarding mode
testpmd> set txpkts 40,64
testpmd> set txsplit rand
testpmd> start
txonly packet forwarding - ports=1 - cores=1 - streams=4 - NUMA support enabled, MP allocation mode: native Logical Core 2 (socket 0) forwards packets on 4 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00 RX P=0/Q=1 (socket 0) -> TX P=0/Q=1 (socket 0) peer=02:00:00:00:00:00 RX P=0/Q=2 (socket 0) -> TX P=0/Q=2 (socket 0) peer=02:00:00:00:00:00 RX P=0/Q=3 (socket 0) -> TX P=0/Q=3 (socket 0) peer=02:00:00:00:00:00txonly packet forwarding packets/burst=32
packet len=104 - nb packet segments=2
nb forwarding cores=1 - nb forwarding ports=1
port 0: RX queue number: 4 Tx queue number: 4Rx offloads=0x0 Tx offloads=0x10000 RX queue: 0 RX desc=1024 - RX free threshold=32 RX threshold registers: pthresh=0 hthresh=0 wthresh=0 RX Offloads=0x0 TX queue: 0 TX desc=1024 - TX free threshold=32 TX threshold registers: pthresh=32 hthresh=0 wthresh=0 TX offloads=0x10000 - TX RS bit threshold=32 tx_pkt_seg_lengths[0] mustbigger than 41 bytes tetx_pkt_seg_lengths[0] must bigger than 41 bytes stpmd> tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes tx_pkt_seg_lengths[0] must bigger than 41 bytes ...
...
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...---------------------- Forward statistics for port 0 ----------------------
RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 0 TX-dropped: 0 TX-total: 0----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all
ports+++++++++++++++RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 0 TX-dropped: 0 TX-total: 0+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++By the way, if multi flow was enabled, the ip header also will be updated, so we should put the check before below codes.
if (txonly_multi_flow) { uint8_t ip_var = RTE_PER_LCORE(_ip_var); struct rte_ipv4_hdr *ip_hdr; uint32_t addr; ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); /* * Generate multiple flows by varying IP src addr. This * enables packets are well distributed by RSS in
Quoted 9 lines
* receiver side if any and txonly mode can be a decent * packet generator for developer's quick performance * regression test. */ addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id(); ip_hdr->src_addr = rte_cpu_to_be_32(addr); RTE_PER_LCORE(_ip_var) = ip_var; }
Yes. No matter where you put the check in txonly, there'll be annoying print.
Tricky.
I can only think of 2 solutions:
1. If needs to update hdr (ip or udp) and first seg len < 42, copy pkt_ip_hdr and pkt_udp_hdr to a temp value, update the temp value and use copy_buf_to_pkt() to copy the tmp hdr to segs. And other cases keep the original code in case perf drop. Also, This one needs to keep your min_segs design.
The shortcoming is it's quite complicated change.
2. Force the first segment length is over 42 bytes in set_tx_pkt_segments()
This way is very simple but the shortcoming is the limit usage and you probably need to add a notice in doc to tell users this change.
Quoted 119 lines
Quoted 35 lines
Quoted 3 lines
Yes, I didn't notice the updating for the UDP header, but the bug first occurs in this function copy_buf_to_pkt(&pkt_udp_hdr,
sizeof(pkt_udp_hdr), pkt,Quoted 7 lines
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));not in
update_pkt_header.Here we expecting users should set minimum 42 byte for first segment seems ok, But I think we putting the check in configuring the data space length of first segment is more graceful.
No. You didn't get my point. It's not graceful at all.
The segment fault will only happen when "TX_PKT_SPLIT_RND". Because the hdr may take 2 segs while randomnb_segsis only 1. But if it's not "TX_PKT_SPLIT_RND", the currentset_tx_pkt_segments()already make surepkt_lenis enough for 42.So the only case you need to deal with is "
TX_PKT_SPLIT_RND". And since "TX_PKT_SPLIT_RND" actually needs the first segment to be enough to contain
42 bytes.
And incmd_set_txpkts_parsed, you may not get the configuration to know if it will be configured as "TX_PKT_SPLIT_RND". That's why you should check beforeupdate_pkt_header().In this way, when it's NOT "
TX_PKT_SPLIT_RND", it will maintain the old behavior that hdrs may cross several segs which makes more sense.Quoted 6 lines
Quoted 6 lines
As for timestamp, maybe refer to "
pkt_copy_split" incsumonly.cis better? Copy the extra to the last segment if it's not enough. Not sure how to deal with this issue better.Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
app/test-pmd/config.c +1
-0*/ tx_pkt_len =0 ; + tx_pkt_nb_min_segs =0 ;for (i =0 ; i < nb_segs; i++) {if (seg_lengths[i] > mbuf_data_size[0 ]) {Quoted 8 lines
Quoted 8 lines
app/test-pmd/config.c struct igb_ring_desc_16_bytes { · line 3855
Quoted 8 lines
app/test-pmd/config.c +3
-0fprintf(stderr,@@ -3849,11 +3850,16 @@ struct igb_ring_desc_16_bytes {return ; } tx_pkt_len = (uint16_t )(tx_pkt_len + seg_lengths[i]); + +if (!tx_pkt_nb_min_segs && + tx_pkt_len >= (sizeof(struct rte_ether_hdr) + 20 + 8 +16))
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
app/test-pmd/config.c +5
-3+ tx_pkt_nb_min_segs = i +1 ; } -if (tx_pkt_len < (sizeof (struct rte_ether_hdr ) +20 +8 )) { + +if (!tx_pkt_nb_min_segs) {fprintf (stderr,"total packet length=%u < %d - give up\n" , - (unsigned ) tx_pkt_len, - (int )(sizeof (struct rte_ether_hdr ) +20 +8 )); + (unsigned int ) tx_pkt_len, + (int )(sizeof (struct rte_ether_hdr ) +20 +8 +16 ));return ; }app/test-pmd/testpmd.c +0
-0index
6cbe9ba..c496e59 100644app/test-pmd/testpmd.c +0
-0@@ -232,6 +232,11 @@ struct fwd_engine * fwd_engines[] = { };
uint8_ttx_pkt_nb_segs= 1; /**< Number of segments in TXONLY packets */app/test-pmd/testpmd.c +6
-0+/**< Minimum number of segments in TXONLY packets to +accommodate all packet +* headers. +*/ +uint8_t tx_pkt_nb_min_segs =1 ; +enum tx_pkt_split tx_pkt_split =TX_PKT_SPLIT_OFF ;/**< Split policy for packets to TX. */
app/test-pmd/testpmd.h +0
-0index
16a3598..f5bc427 100644app/test-pmd/testpmd.h +0
-0@@ -464,6 +464,11 @@ enum dcb_mode_enable extern uint16_t
tx_pkt_length; /**< Length of TXONLY packet */ externuint16_ttx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ externuint8_ttx_pkt_nb_segs; /**< Number of segments in TX packets */app/test-pmd/testpmd.h +6
-0+ +/**< Minimum number of segments in TXONLY packets to +accommodate all packet +* headers. +*/ +extern uint8_t tx_pkt_nb_min_segs; extern uint32_t tx_pkt_times_intra; extern uint32_t
tx_pkt_times_inter;app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..27e4458 100644
app/test-pmd/txonly.c +5
-3@@ -195,8 +195,11 @@uint32_t nb_segs, pkt_len;uint8_t i; -if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND )) - nb_segs =rte_rand () % tx_pkt_nb_segs +1 ; +if (unlikely (tx_pkt_split ==TX_PKT_SPLIT_RND ) && + tx_pkt_nb_segs > tx_pkt_nb_min_segs) + nb_segs =rte_rand () % + (tx_pkt_nb_segs - tx_pkt_nb_min_segs +1 ) + + tx_pkt_nb_min_segs;else nb_segs = tx_pkt_nb_segs; --1.8.3.1
PATCH v2 1/2 app/testpmd: update forward engine beginning
In reply to Alvin ZhangFor each forward engine, there may be some special conditions must be meet before the forwarding run.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are meet, and the testpmd then call the callback to determine whether the forwarding can be started.
There was a void callback 'port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates it's return type, then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch puts the calling part of the callback up to before some forwarding related status being set.
--- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 5 files changed, 34 insertions(+), 16 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -1
@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static void
app/test-pmd/noisy_vnf.c +3 -1
@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;
@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {
app/test-pmd/testpmd.c +26 -12
@@ -2172,16 +2172,10 @@ struct extmem_param {static void launch_packet_forwarding (lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i];if ((interactive ==0 ) || (lc_id !=rte_lcore_id ())) {
@@ -2227,10 +2221,35 @@ struct extmem_param {fprintf (stderr,"Packet forwarding already started\n" );return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();
@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);
app/test-pmd/testpmd.h +1 -1
@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);
app/test-pmd/txonly.c +2 -1
@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;
@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = {
Signature · 1 line
1.8.3.1
PATCH v2 2/2 app/testpmd: fix txonly forwording
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding need more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are meet.
Bugzilla ID: 797
--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)
app/test-pmd/txonly.c +55 -12
@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;
@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {
@@ -438,13 +440,23 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr ))); + pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Random segment number or multiple flow enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;
@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Time stamp and random segment number enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; + +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"No enough Tx segment space for time stamp info." +" total %u < %u (needed)\n" , + total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
1.8.3.1
PATCH v3 1/2 app/testpmd: update forward engine beginning
In reply to Alvin ZhangFor each forward engine, there may be some special conditions must be meet before the forwarding run.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are meet, and then testpmd can call the callback to determine whether the forwarding can be started.
There was a void callback 'port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates it's return type, then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch puts the calling part of the callback up to before some forwarding related status being set.
--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)
app/test-pmd/flowgen.c +2 -1
@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; }struct fwd_engine flow_gen_engine = {
app/test-pmd/ieee1588fwd.c +2 -1
@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static void
app/test-pmd/noisy_vnf.c +3 -1
@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;
@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {
app/test-pmd/testpmd.c +26 -12
@@ -2172,16 +2172,10 @@ struct extmem_param {static void launch_packet_forwarding (lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i];if ((interactive ==0 ) || (lc_id !=rte_lcore_id ())) {
@@ -2227,10 +2221,35 @@ struct extmem_param {fprintf (stderr,"Packet forwarding already started\n" );return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();
@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);
app/test-pmd/testpmd.h +1 -1
@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);
app/test-pmd/txonly.c +2 -1
@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;
@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = {
Signature · 1 line
1.8.3.1
PATCH v3 2/2 app/testpmd: fix txonly forwording
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding need more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are meet.
Bugzilla ID: 797
--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)
app/test-pmd/txonly.c +55 -12
@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;
@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {
@@ -438,13 +440,23 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr ))); + pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Random segment number or multiple flow enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;
@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Time stamp and random segment number enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; + +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"No enough Tx segment space for time stamp info." +" total %u < %u (needed)\n" , + total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3 2/2] app/testpmd: fix txonly forwording
Hi
Quoted 12 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Saturday, September 18, 2021 11:07
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v3 2/2] app/testpmd: fix txonly forwordingWhen random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Quoted 6 lines
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments.
This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.In addition, if time stamp is enabled, the forwarding need more Tx segment
needs
Quoted 4 lines
space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are meet.
are met
Quoted 4 lines
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoing packets")
This patch is based on the 1st patch of this patch-set. So if you only send this patch to stable, there'll be incompatible issues. Either you send both patches to stable or you just fix this for the future (don't cc to stable).
But the patch looks good to me.
Quoted 7 lines
Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)
Re: [dpdk-dev] [PATCH v3 1/2] app/testpmd: update forward engine beginning
In reply to Alvin ZhangHi
Quoted 9 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Saturday, September 18, 2021 11:07
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>
Subject: [PATCH v3 1/2] app/testpmd: update forward engine beginningFor each forward engine, there may be some special conditions must be meet
met
Quoted 1 line
before the forwarding run.
is running / runs
Quoted 7 lines
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are meet, and then testpmd can call the callback to determine
met
Quoted 4 lines
whether the forwarding can be started.
There was a void callback '
port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates it's return type, then we can add
its return value then we can
Quoted 3 lines
some checks in it to confirm whether the forwarding can be started. In addition, this patch puts the calling part of the callback up to before some forwarding related status being set.
this patch calls this callback before the forwarding stats is reset and then launches the forwarding engine.
Also the cc stable issue I state in the 2nd patch. But overall the patch looks good to me.
BRs
Xiaoyun
Quoted 172 lines
Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)app/test-pmd/flowgen.c index renamed from app/test-pmd/flowgen.c +0
-00d3664a..83234fc 100644
app/test-pmd/flowgen.c +2
-1@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; }struct fwd_engine flow_gen_engine = {app/test-pmd/ieee1588fwd.c index renamed from app/test-pmd/ieee1588fwd.c +0
-0034f238..81624a7 100644
app/test-pmd/ieee1588fwd.c +2
-1@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static voidapp/test-pmd/noisy_vnf.c index renamed from app/test-pmd/noisy_vnf.c +0
-0382a4c2..e4434be 100644
app/test-pmd/noisy_vnf.c +3
-1@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-097ae52e..0345b2e 100644
app/test-pmd/testpmd.c +19
-7@@ -2172,16 +2172,10 @@ struct extmem_param { static void launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i]; if ((interactive == 0) || (lc_id != rte_lcore_id())) { @@ -2227,10 +2221,35 @@ struct extmem_param { fprintf(stderr, "Packet forwarding already started\n");return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { + fprintf(stderr, + "Packet forwarding notready\n");
app/test-pmd/testpmd.c +8
-5+return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-05863b2f..e9d9db0 100644
app/test-pmd/testpmd.h +1
-1@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..386a4ff 100644
app/test-pmd/txonly.c +2
-2@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = { --1.8.3.1
Re: [dpdk-dev] [PATCH v3 1/2] app/testpmd: update forward engine beginning
Quoted 18 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Saturday, September 18, 2021 4:31 PM
To: Zhang, AlvinX <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v3 1/2] app/testpmd: update forward engine beginningHi
Quoted 8 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Saturday, September 18, 2021 11:07
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>
Subject: [PATCH v3 1/2] app/testpmd: update forward engine beginning
Quoted 4 lines
Quoted 2 lines
For each forward engine, there may be some special conditions must be meet
met
Hi Xiaoyun,
Thanks for your attentively reviewing. I will update them in V4.
Quoted 208 lines
Quoted 2 lines
before the forwarding run.
is running / runs
Quoted 8 lines
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are meet, and then testpmd can call the callback to determine
met
Quoted 5 lines
whether the forwarding can be started.
There was a void callback '
port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates it's return type, then we can addits return value then we can
Quoted 3 lines
some checks in it to confirm whether the forwarding can be started. In addition, this patch puts the calling part of the callback up to before some forwarding related status being set.
this patch calls this callback before the forwarding stats is reset and then launches the forwarding engine.
Also the cc stable issue I state in the 2nd patch. But overall the patch looks good to me.
BRs
XiaoyunQuoted 7 lines
Signed-off-by Alvin Zhang <[email protected]>--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38++++++++++++++++++++++++++------------
Quoted 134 lines
app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)app/test-pmd/flowgen.c index renamed from app/test-pmd/flowgen.c +0
-00d3664a..83234fc 100644
app/test-pmd/flowgen.c +2
-1@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; } struct fwd_engine flow_gen_engine = { diff --git
a/app/test-pmd/ieee1588fwd.cb/app/test-pmd/ieee1588fwd.cindex 034f238..81624a7 100644app/test-pmd/ieee1588fwd.c +2
-1@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static voidapp/test-pmd/noisy_vnf.c index renamed from app/test-pmd/noisy_vnf.c +0
-0382a4c2..e4434be 100644
app/test-pmd/noisy_vnf.c +3
-1@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; } struct fwd_engine noisy_vnf_engine = { diff --git
a/app/test-pmd/testpmd.cb/app/test-pmd/testpmd.cindex 97ae52e..0345b2e 100644app/test-pmd/testpmd.c +19
-7@@ -2172,16 +2172,10 @@ struct extmem_param { static void launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i]; if ((interactive == 0) || (lc_id != rte_lcore_id())) { @@ -2227,10 +2221,35 @@ struct extmem_param { fprintf(stderr, "Packet forwarding already started\n");return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { + fprintf(stderr, + "Packet forwarding notready\n");
app/test-pmd/testpmd.c +8
-5+return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-05863b2f..e9d9db0 100644
app/test-pmd/testpmd.h struct fwd_lcore { · line 269
Quoted 2 lines
app/test-pmd/testpmd.h +0
-0@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware.
Quoted 26 lines
app/test-pmd/testpmd.h +1
-1*/ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0aed820f..386a4ff 100644
app/test-pmd/txonly.c +2
-1@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }
Quoted 3 lines
Quoted 3 lines
app/test-pmd/txonly.c +0
-1struct fwd_engine tx_only_engine = { --1.8.3.1
BRs
Alvin
PATCH v4 1/2 app/testpmd: update forward engine beginning
In reply to Alvin ZhangFor each forward engine, there may be some special conditions must be met before the forwarding runs.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are met, and then testpmd can call the callback to determine whether the forwarding can be started.
There was a void callback 'port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates its return value then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch calls the callback before the forwarding stats is reset and then launches the forwarding engine.
Bugzilla ID: 797
Cc: [email protected]
--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)
app/test-pmd/flowgen.c +2 -1
@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; }struct fwd_engine flow_gen_engine = {
app/test-pmd/ieee1588fwd.c +2 -1
@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static void
app/test-pmd/noisy_vnf.c +3 -1
@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;
@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {
app/test-pmd/testpmd.c +26 -12
@@ -2172,16 +2172,10 @@ struct extmem_param {static void launch_packet_forwarding (lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i];if ((interactive ==0 ) || (lc_id !=rte_lcore_id ())) {
@@ -2227,10 +2221,35 @@ struct extmem_param {fprintf (stderr,"Packet forwarding already started\n" );return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();
@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);
app/test-pmd/testpmd.h +1 -1
@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);
app/test-pmd/txonly.c +2 -1
@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;
@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = {
Signature · 1 line
1.8.3.1
PATCH v4 2/2 app/testpmd: fix txonly forwording
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)
app/test-pmd/txonly.c +55 -12
@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;
@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {
@@ -438,13 +440,23 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr ))); + pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Random segment number or multiple flow enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;
@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Time stamp and random segment number enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; + +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"No enough Tx segment space for time stamp info." +" total %u < %u (needed)\n" , + total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: fix txonly forwording
Quoted 21 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Wednesday, September 22, 2021 10:50
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v4 2/2] app/testpmd: fix txonly forwordingWhen random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments.
This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
Quoted 8 lines
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoing packets")Signed-off-by Alvin Zhang <[email protected]>
Re: [dpdk-dev] [PATCH v4 1/2] app/testpmd: update forward engine beginning
In reply to Alvin ZhangQuoted 19 lines
-----Original Message-----
From: Zhang, AlvinX <[email protected]>
Sent: Wednesday, September 22, 2021 10:50
To: Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v4 1/2] app/testpmd: update forward engine beginningFor each forward engine, there may be some special conditions must be met before the forwarding runs.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are met, and then testpmd can call the callback to determine whether the forwarding can be started.
Quoted 8 lines
There was a void callback '
port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates its return value then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch calls the callback before the forwarding stats is reset and then launches the forwarding engine.Bugzilla ID: 797
Cc: [email protected]
Not sure if you should add the same fixline as patch 2
Quoted 2 lines
Signed-off-by Alvin Zhang <[email protected]>
Except that, Acked-by: Xiaoyun Li <[email protected]>
PATCH v5 1/2 app/testpmd: update forward engine beginning
In reply to Alvin ZhangFor each forward engine, there may be some special conditions must be met before the forwarding runs.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are met, and then testpmd can call the callback to determine whether the forwarding can be started.
There was a void callback 'port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates its return value then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch calls the callback before the forwarding stats is reset and then launches the forwarding engine.
Bugzilla ID: 797
Cc: [email protected]
--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)
app/test-pmd/flowgen.c +2 -1
@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; }struct fwd_engine flow_gen_engine = {
app/test-pmd/ieee1588fwd.c +2 -1
@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static void
app/test-pmd/noisy_vnf.c +3 -1
@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;
@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {
app/test-pmd/testpmd.c +26 -12
@@ -2172,16 +2172,10 @@ struct extmem_param {static void launch_packet_forwarding (lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i];if ((interactive ==0 ) || (lc_id !=rte_lcore_id ())) {
@@ -2227,10 +2221,35 @@ struct extmem_param {fprintf (stderr,"Packet forwarding already started\n" );return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();
@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);
app/test-pmd/testpmd.h +1 -1
@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);
app/test-pmd/txonly.c +2 -1
@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;
@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = {
Signature · 1 line
1.8.3.1
PATCH v5 2/2 app/testpmd: fix txonly forwording
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
---
v5: fixes a compilation issue
--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)
app/test-pmd/txonly.c +55 -12
@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;
@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {
@@ -438,13 +440,23 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr ))); + pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Random segment number or multiple flow enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;
@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct tx_timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Time stamp and random segment number enabled," +" but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; + +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"No enough Tx segment space for time stamp info." +" total %u < %u (needed)\n" , + total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v5 2/2] app/testpmd: fix txonly forwording
Hi Alvin,
There's a typo in the commit summary: forwording -> forwarding.
Quoted 72 lines · Alvin Zhang
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoing packets")Signed-off-by Alvin Zhang <[email protected]>Acked-by Xiaoyun Li <[email protected]>---
v5: fixes a compilation issue
--- app/test-pmd/txonly.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-)app/test-pmd/txonly.c +9
-11@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {@@ -438,13 +440,23 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr )));
app/test-pmd/txonly.c line 455
Quoted 10 lines
app/test-pmd/txonly.c +10
-0+ pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "Random segment number or multiple flow enabled," + " but tx_pkt_seg_lengths[0] %u < %u (needed)\n",
This should probably be on a single line:
TESTPMD_LOG(ERR, "Random segment number or multiple flow enabled, but tx_pkt_seg_lengths[0] %u < %u (needed)\n",
because this way it's more search-friendly. Style checks should be OK with that.
Quoted 11 lines
app/test-pmd/txonly.c +4
-0+ tx_pkt_seg_lengths[0], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]);
app/test-pmd/txonly.c line 486
Quoted 10 lines
app/test-pmd/txonly.c +9
-1-if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct tx_timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "Time stamp and random segment number enabled," + " but tx_pkt_seg_lengths[0] %u < %u (needed)\n",
Likewise.
Quoted 7 lines
app/test-pmd/txonly.c +7
-0+ tx_pkt_seg_lengths[0], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; +
app/test-pmd/txonly.c line 503
Quoted 10 lines
app/test-pmd/txonly.c +10
-0+for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "No enough Tx segment space for time stamp info." + " total %u < %u (needed)\n",
Likewise.
Quoted 11 lines
app/test-pmd/txonly.c +6
-0+ total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
Ivan M
Re: [dpdk-dev] [PATCH v5 2/2] app/testpmd: fix txonly forwording
Quoted 11 lines
-----Original Message-----
From: Ivan Malov <[email protected]>
Sent: Thursday, September 23, 2021 12:26 PM
To: Zhang, AlvinX <[email protected]>; Li, Xiaoyun <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v5 2/2] app/testpmd: fix txonly forwordingHi Alvin,
There's a typo in the commit summary: forwording -> forwarding.
I'll update it in V6.
Quoted 89 lines · Alvin Zhang
Quoted 20 lines
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
Fixes 79bec05b32b7 ("app/testpmd: add ability to split outgoingpackets")
Cc: [email protected]Quoted 7 lines
Signed-off-by Alvin Zhang <[email protected]>Acked-by Xiaoyun Li <[email protected]>---
v5: fixes a compilation issue
--- app/test-pmd/txonly.c | 67++++++++++++++++++++++++++++++++++++++++++---------
Quoted 24 lines
1 file changed, 55 insertions(+), 12 deletions(-)app/test-pmd/txonly.c index renamed from app/test-pmd/txonly.c +0
-0386a4ff..e7b1b42 100644
app/test-pmd/txonly.c +7
-0@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew);app/test-pmd/txonly.c line 270
Quoted 10 lines
app/test-pmd/txonly.c +1
-6-struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req != RTE_PER_LCORE(timestamp_idone))) { @@ -438,13+440,23 @@
Quoted 11 lines
static int tx_only_begin(portid_t pi) {app/test-pmd/txonly.c +1
-5-uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr )));app/test-pmd/txonly.c line 455
Quoted 10 lines
app/test-pmd/txonly.c +10
-0+ pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "Random segment number or multiple flow enabled," + " but tx_pkt_seg_lengths[0] %u < %u (needed)\n",This should probably be on a single line:
Quoted 4 lines
TESTPMD_LOG(ERR, "Random segment number or multiple flow enabled, but tx_pkt_seg_lengths[0] %u < %u (needed)\n",
because this way it's more search-friendly. Style checks should be OK with that.
I'll update them in V6.
Quoted 62 lines
app/test-pmd/txonly.c
Quoted 6 lines
app/test-pmd/txonly.c +4
-0+ tx_pkt_seg_lengths[0], pkt_hdr_len); +return -EINVAL ; + } + setup_pkt_udp_ip_headers(&pkt_ip_hdr, &pkt_udp_hdr,
pkt_data_len);Quoted 5 lines
timestamp_enable = false;app/test-pmd/txonly.c +0
-0@@ -463,8 +475,39 @@ timestamp_mask && timestamp_off >= 0 &&app/test-pmd/txonly.c line 485
Quoted 10 lines
app/test-pmd/txonly.c +8
-1!rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct tx_timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "Time stamp and random segment numberenabled,"
app/test-pmd/txonly.c line 486
Quoted 1 line
app/test-pmd/txonly.c +1
-0+ " but tx_pkt_seg_lengths[0] %u < %u (needed)\n",Likewise.
Quoted 6 lines
app/test-pmd/txonly.c +6
-0+ tx_pkt_seg_lengths[0], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i;app/test-pmd/txonly.c
Quoted 10 lines
app/test-pmd/txonly.c +10
-0+ +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { + TESTPMD_LOG(ERR, + "No enough Tx segment space for time stampinfo."
app/test-pmd/txonly.c line 503
Quoted 1 line
app/test-pmd/txonly.c +1
-0+ " total %u < %u (needed)\n",Likewise.
app/test-pmd/txonly.c line 513
Quoted 11 lines
app/test-pmd/txonly.c +6
-0+ total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;--
Ivan M
PATCH v6 1/2 app/testpmd: update forward engine beginning
In reply to Alvin ZhangFor each forward engine, there may be some special conditions must be met before the forwarding runs.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are met, and then testpmd can call the callback to determine whether the forwarding can be started.
There was a void callback 'port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates its return value then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch calls the callback before the forwarding stats is reset and then launches the forwarding engine.
Bugzilla ID: 797
Cc: [email protected]
--- app/test-pmd/flowgen.c | 3 ++- app/test-pmd/ieee1588fwd.c | 3 ++- app/test-pmd/noisy_vnf.c | 4 +++- app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 3 ++- 6 files changed, 36 insertions(+), 17 deletions(-)
app/test-pmd/flowgen.c +2 -1
@@ -201,10 +201,11 @@get_end_cycles (fs, start_tsc); } -static void +static int flowgen_begin (portid_t pi) {printf (" number of flows for port %u: %d\n" , pi, nb_flows_flowgen); +return 0 ; }struct fwd_engine flow_gen_engine = {
app/test-pmd/ieee1588fwd.c +2 -1
@@ -198,10 +198,11 @@ struct ptpv2_msg {port_ieee1588_tx_timestamp_check (fs->rx_port); } -static void +static int port_ieee1588_fwd_begin (portid_t pi) {rte_eth_timesync_enable (pi); +return 0 ; } static void
app/test-pmd/noisy_vnf.c +3 -1
@@ -231,7 +231,7 @@ struct noisy_config {rte_free (noisy_cfg[pi]); } -static void +static int noisy_fwd_begin (portid_t pi) {struct noisy_config *n;
@@ -273,6 +273,8 @@ struct noisy_config {rte_exit (EXIT_FAILURE ,"--noisy-lkup-memory-size must be > 0\n" ); } + +return 0 ; }struct fwd_engine noisy_vnf_engine = {
app/test-pmd/testpmd.c +26 -12
@@ -2172,16 +2172,10 @@ struct extmem_param {static void launch_packet_forwarding (lcore_function_t *pkt_fwd_on_lcore) { -port_fwd_begin_t port_fwd_begin;unsigned int i;unsigned int lc_id;int diag; - port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }for (i =0 ; i < cur_fwd_config.nb_fwd_lcores; i++) { lc_id = fwd_lcores_cpuids[i];if ((interactive ==0 ) || (lc_id !=rte_lcore_id ())) {
@@ -2227,10 +2221,35 @@ struct extmem_param {fprintf (stderr,"Packet forwarding already started\n" );return ; } - test_done =0 ;fwd_config_setup (); + port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + +if (with_tx_first) { + port_fwd_begin = tx_only_engine.port_fwd_begin; +if (port_fwd_begin !=NULL ) { +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) { +if (port_fwd_begin (fwd_ports_ids[i])) { +fprintf (stderr, +"Packet forwarding not ready\n" ); +return ; + } + } + } + } + + test_done =0 ; +if (!no_flush_rx)flush_fwd_rx_queues ();
@@ -2239,11 +2258,6 @@ struct extmem_param {fwd_stats_reset ();if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; -if (port_fwd_begin !=NULL ) { -for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) - (*port_fwd_begin)(fwd_ports_ids[i]); - }while (with_tx_first--) {launch_packet_forwarding ( run_one_txonly_burst_on_core);
app/test-pmd/testpmd.h +1 -1
@@ -268,7 +268,7 @@ struct fwd_lcore {* Forwards packets unchanged on the same port. * Check that sent IEEE1588 PTP packets are timestamped by the hardware. */ -typedef void (*port_fwd_begin_t )(portid_t pi); +typedef int (*port_fwd_begin_t )(portid_t pi);typedef void (*port_fwd_end_t )(portid_t pi);typedef void (*packet_fwd_t )(struct fwd_stream *fs);
app/test-pmd/txonly.c +2 -1
@@ -435,7 +435,7 @@get_end_cycles (fs, start_tsc); } -static void +static int tx_only_begin (portid_t pi) {uint16_t pkt_data_len;
@@ -467,6 +467,7 @@ timestamp_init_req++;/* Make sure all settings are visible on forwarding cores.*/ rte_wmb (); +return 0 ; }struct fwd_engine tx_only_engine = {
Signature · 1 line
1.8.3.1
PATCH v6 2/2 app/testpmd: fix txonly forwarding
When random number of Tx segments is enabled, because the actual number of segments may be only one, the first segment of the Tx packets must accommodate a complete being sending Eth/IP/UDP packet.
Besides, if multiple flow is enabled, the forwarding will update the IP and UDP header, these headers shouldn't cross segments. This also requires the first Tx segment can accommodate a complete Eth/IP/UDP packet.
In addition, if time stamp is enabled, the forwarding needs more Tx segment space for time stamp information.
This patch adds checks in beginning of forward engine to make sure all above conditions are met.
Bugzilla ID: 797
---
v5: fixes a compilation issue
v6: update the commit summary and some logs
--- app/test-pmd/txonly.c | 64 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-)
app/test-pmd/txonly.c +52 -12
@@ -40,6 +40,13 @@#include "testpmd.h" +struct tx_timestamp { +rte_be32_t signature; +rte_be16_t pkt_idx; +rte_be16_t queue_idx; +rte_be64_t ts; +}; +/* use RFC863 Discard Protocol */ uint16_t tx_udp_src_port =9 ;uint16_t tx_udp_dst_port =9 ;
@@ -257,12 +264,7 @@if (unlikely (timestamp_enable)) {uint64_t skew =RTE_PER_LCORE (timestamp_qskew); -struct { -rte_be32_t signature; -rte_be16_t pkt_idx; -rte_be16_t queue_idx; -rte_be64_t ts; - } timestamp_mark; +struct tx_timestamp timestamp_mark;if (unlikely (timestamp_init_req !=RTE_PER_LCORE (timestamp_idone))) {
@@ -438,13 +440,22 @@static int tx_only_begin (portid_t pi) { -uint16_t pkt_data_len; +uint16_t pkt_hdr_len, pkt_data_len;int dynf; - pkt_data_len = (uint16_t ) (tx_pkt_length - ( -sizeof (struct rte_ether_hdr ) + -sizeof (struct rte_ipv4_hdr ) + -sizeof (struct rte_udp_hdr ))); + pkt_hdr_len = (uint16_t )(sizeof (struct rte_ether_hdr ) + +sizeof (struct rte_ipv4_hdr ) + +sizeof (struct rte_udp_hdr )); + pkt_data_len = tx_pkt_length - pkt_hdr_len; + +if ((tx_pkt_split ==TX_PKT_SPLIT_RND || txonly_multi_flow) && + tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Random segment number or multiple flow enabled, but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } +setup_pkt_udp_ip_headers (&pkt_ip_hdr, &pkt_udp_hdr, pkt_data_len); timestamp_enable = false;
@@ -463,8 +474,37 @@ timestamp_mask && timestamp_off >=0 && !rte_eth_read_clock (pi, ×tamp_initial[pi]); -if (timestamp_enable) + +if (timestamp_enable) { + pkt_hdr_len +=sizeof (struct tx_timestamp ); + +if (tx_pkt_split ==TX_PKT_SPLIT_RND ) { +if (tx_pkt_seg_lengths[0 ] < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"Time stamp and random segment number enabled, but tx_pkt_seg_lengths[0] %u < %u (needed)\n" , + tx_pkt_seg_lengths[0 ], pkt_hdr_len); +return -EINVAL ; + } + }else { +uint16_t total =0 ; +uint8_t i; + +for (i =0 ; i < tx_pkt_nb_segs; i++) { + total += tx_pkt_seg_lengths[i]; +if (total >= pkt_hdr_len) +break ; + } + +if (total < pkt_hdr_len) { +TESTPMD_LOG (ERR , +"No enough Tx segment space for time stamp info, total %u < %u (needed)\n" , + total, pkt_hdr_len); +return -EINVAL ; + } + } timestamp_init_req++; + } +/* Make sure all settings are visible on forwarding cores.*/ rte_wmb ();return 0 ;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [dpdk-stable] [PATCH v6 1/2] app/testpmd: update forward engine beginning
In reply to Alvin ZhangQuoted 18 lines · Alvin Zhang
For each forward engine, there may be some special conditions must be met before the forwarding runs.
Adding checks for these conditions in configuring is not suitable, because one condition may rely on multiple configurations, and the conditions required by each forward engine is not general.
The best solution is each forward engine has a callback to check whether these conditions are met, and then testpmd can call the callback to determine whether the forwarding can be started.
There was a void callback '
port_fwd_begin' in forward engine, it did some initialization for forwarding, this patch updates its return value then we can add some checks in it to confirm whether the forwarding can be started. In addition, this patch calls the callback before the forwarding stats is reset and then launches the forwarding engine.
Quoted 5 lines
Bugzilla ID: 797
Cc: [email protected]Signed-off-by Alvin Zhang <[email protected]>Acked-by Xiaoyun Li <[email protected]>
Series applied to dpdk-next-net/main, thanks.
Updated log messages slightly while merging.