Message ID | 1469459664-3438-1-git-send-email-u9012063@gmail.com |
---|---|
State | Accepted |
Delegated to: | Daniele Di Proietto |
Headers | show |
Applied to master, thanks 2016-07-25 8:14 GMT-07:00 William Tu <u9012063@gmail.com>: > Instead of looping into each packet and check whether to truncate, the > patch moves it out of the loop and uses batch API. If truncation is > not set, checking 'trunc' in 'struct dp_packet_batch' at per-batch basis > can skip the per-packet checking overhead. > > Signed-off-by: William Tu <u9012063@gmail.com> > --- > lib/netdev-dpdk.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > index 7fb6457..22d547f 100644 > --- a/lib/netdev-dpdk.c > +++ b/lib/netdev-dpdk.c > @@ -1411,6 +1411,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, > struct dp_packet_batch *batch) > ovs_mutex_lock(&nonpmd_mempool_mutex); > } > > + dp_packet_batch_apply_cutlen(batch); > + > for (i = 0; i < batch->count; i++) { > int size = dp_packet_size(batch->packets[i]); > > @@ -1429,10 +1431,6 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, > struct dp_packet_batch *batch) > break; > } > > - /* Cut the size so only the truncated size is copied. */ > - size -= dp_packet_get_cutlen(batch->packets[i]); > - dp_packet_reset_cutlen(batch->packets[i]); > - > /* We have to do a copy for now */ > memcpy(rte_pktmbuf_mtod(mbufs[newcnt], void *), > dp_packet_data(batch->packets[i]), size); > @@ -1506,12 +1504,11 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int > qid, > unsigned int temp_cnt = 0; > int cnt = batch->count; > > + dp_packet_batch_apply_cutlen(batch); > + > for (int i = 0; i < cnt; i++) { > int size = dp_packet_size(batch->packets[i]); > > - size -= dp_packet_get_cutlen(batch->packets[i]); > - dp_packet_set_size(batch->packets[i], size); > - > if (OVS_UNLIKELY(size > dev->max_packet_len)) { > if (next_tx_idx != i) { > temp_cnt = i - next_tx_idx; > -- > 2.5.0 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 7fb6457..22d547f 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1411,6 +1411,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch) ovs_mutex_lock(&nonpmd_mempool_mutex); } + dp_packet_batch_apply_cutlen(batch); + for (i = 0; i < batch->count; i++) { int size = dp_packet_size(batch->packets[i]); @@ -1429,10 +1431,6 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch) break; } - /* Cut the size so only the truncated size is copied. */ - size -= dp_packet_get_cutlen(batch->packets[i]); - dp_packet_reset_cutlen(batch->packets[i]); - /* We have to do a copy for now */ memcpy(rte_pktmbuf_mtod(mbufs[newcnt], void *), dp_packet_data(batch->packets[i]), size); @@ -1506,12 +1504,11 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid, unsigned int temp_cnt = 0; int cnt = batch->count; + dp_packet_batch_apply_cutlen(batch); + for (int i = 0; i < cnt; i++) { int size = dp_packet_size(batch->packets[i]); - size -= dp_packet_get_cutlen(batch->packets[i]); - dp_packet_set_size(batch->packets[i], size); - if (OVS_UNLIKELY(size > dev->max_packet_len)) { if (next_tx_idx != i) { temp_cnt = i - next_tx_idx;
Instead of looping into each packet and check whether to truncate, the patch moves it out of the loop and uses batch API. If truncation is not set, checking 'trunc' in 'struct dp_packet_batch' at per-batch basis can skip the per-packet checking overhead. Signed-off-by: William Tu <u9012063@gmail.com> --- lib/netdev-dpdk.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)