diff mbox

[ovs-dev,2/5] lib/dp-packet: copy additional packet info when do packet copy

Message ID 1493705445-5774-3-git-send-email-qdy220091330@gmail.com
State Changes Requested
Headers show

Commit Message

Michael Qiu May 2, 2017, 6:10 a.m. UTC
From: Michael Qiu <qiudayu@chinac.com>

Currently, when doing packet copy, lots of DPDK mbuf's info
will be missed, like packet type, ol_flags, etc.
Those information is very important for DPDK to do
packets processing.

Signed-off-by: Michael Qiu <qiudayu@chinac.com>
---
 lib/dp-packet.c   | 3 +++
 lib/netdev-dpdk.c | 4 ++++
 2 files changed, 7 insertions(+)

Comments

Mark Kavanagh May 3, 2017, 3:32 p.m. UTC | #1
>
>From: Michael Qiu <qiudayu@chinac.com>
>
>Currently, when doing packet copy, lots of DPDK mbuf's info
>will be missed, like packet type, ol_flags, etc.
>Those information is very important for DPDK to do
>packets processing.
>
>Signed-off-by: Michael Qiu <qiudayu@chinac.com>
>---
> lib/dp-packet.c   | 3 +++
> lib/netdev-dpdk.c | 4 ++++
> 2 files changed, 7 insertions(+)
>
>diff --git a/lib/dp-packet.c b/lib/dp-packet.c
>index 109947c..79f6e7e 100644
>--- a/lib/dp-packet.c
>+++ b/lib/dp-packet.c
>@@ -176,6 +176,9 @@ dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t
>headroom)

If I'm, not mistaken, this function is invoked as part of the execute_controller_action - I'm not too familiar with this action, could you provide an example of how it is used in this context?

>     new_buffer->cutlen = buffer->cutlen;
> #ifdef DPDK_NETDEV
>     new_buffer->mbuf.ol_flags = buffer->mbuf.ol_flags;
>+    new_buffer->mbuf.tx_offload = buffer->mbuf.tx_offload;
>+    new_buffer->mbuf.packet_type = buffer->mbuf.packet_type;
>+    new_buffer->mbuf.nb_segs = buffer->mbuf.nb_segs;
> #else
>     new_buffer->rss_hash_valid = buffer->rss_hash_valid;
> #endif
>diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>index ddc651b..ba044a3 100644
>--- a/lib/netdev-dpdk.c
>+++ b/lib/netdev-dpdk.c
>@@ -1764,6 +1764,10 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch
>*batch)
>         memcpy(rte_pktmbuf_mtod(pkts[newcnt], void *),
>                dp_packet_data(batch->packets[i]), size);
>
>+        pkts[newcnt]->nb_segs = batch->packets[i]->mbuf.nb_segs;
>+        pkts[newcnt]->ol_flags = batch->packets[i]->mbuf.ol_flags;
>+        pkts[newcnt]->packet_type = batch->packets[i]->mbuf.packet_type;
>+        pkts[newcnt]->tx_offload = batch->packets[i]->mbuf.tx_offload;

If packet comes from a non-DPDK source, are these fields of any value?

>         rte_pktmbuf_data_len(pkts[newcnt]) = size;
>         rte_pktmbuf_pkt_len(pkts[newcnt]) = size;
>
>--
>1.8.3.1
Michael Qiu May 3, 2017, 4:08 p.m. UTC | #2
在 2017年5月3日,下午11:32,Kavanagh, Mark B <mark.b.kavanagh@intel.com> 写道:

>> 
>> From: Michael Qiu <qiudayu@chinac.com>
>> 
>> Currently, when doing packet copy, lots of DPDK mbuf's info
>> will be missed, like packet type, ol_flags, etc.
>> Those information is very important for DPDK to do
>> packets processing.
>> 
>> Signed-off-by: Michael Qiu <qiudayu@chinac.com>
>> ---
>> lib/dp-packet.c   | 3 +++
>> lib/netdev-dpdk.c | 4 ++++
>> 2 files changed, 7 insertions(+)
>> 
>> diff --git a/lib/dp-packet.c b/lib/dp-packet.c
>> index 109947c..79f6e7e 100644
>> --- a/lib/dp-packet.c
>> +++ b/lib/dp-packet.c
>> @@ -176,6 +176,9 @@ dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t
>> headroom)
> 
> If I'm, not mistaken, this function is invoked as part of the execute_controller_action - I'm not too familiar with this action, could you provide an example of how it is used in this context?

Here I will check it tomorrow. It's a long time since I make this change, but without this change, it will not work correctly in some situation after vxlan hw offloading enabled.

> 
>>    new_buffer->cutlen = buffer->cutlen;
>> #ifdef DPDK_NETDEV
>>    new_buffer->mbuf.ol_flags = buffer->mbuf.ol_flags;
>> +    new_buffer->mbuf.tx_offload = buffer->mbuf.tx_offload;
>> +    new_buffer->mbuf.packet_type = buffer->mbuf.packet_type;
>> +    new_buffer->mbuf.nb_segs = buffer->mbuf.nb_segs;
>> #else
>>    new_buffer->rss_hash_valid = buffer->rss_hash_valid;
>> #endif
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index ddc651b..ba044a3 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -1764,6 +1764,10 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch
>> *batch)
>>        memcpy(rte_pktmbuf_mtod(pkts[newcnt], void *),
>>               dp_packet_data(batch->packets[i]), size);
>> 
>> +        pkts[newcnt]->nb_segs = batch->packets[i]->mbuf.nb_segs;
>> +        pkts[newcnt]->ol_flags = batch->packets[i]->mbuf.ol_flags;
>> +        pkts[newcnt]->packet_type = batch->packets[i]->mbuf.packet_type;
>> +        pkts[newcnt]->tx_offload = batch->packets[i]->mbuf.tx_offload;
> 
> If packet comes from a non-DPDK source, are these fields of any value?

That's why we need the first patch, set them to zero.

> 
>>        rte_pktmbuf_data_len(pkts[newcnt]) = size;
>>        rte_pktmbuf_pkt_len(pkts[newcnt]) = size;
>> 
>> --
>> 1.8.3.1
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox

Patch

diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index 109947c..79f6e7e 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -176,6 +176,9 @@  dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t headroom)
     new_buffer->cutlen = buffer->cutlen;
 #ifdef DPDK_NETDEV
     new_buffer->mbuf.ol_flags = buffer->mbuf.ol_flags;
+    new_buffer->mbuf.tx_offload = buffer->mbuf.tx_offload;
+    new_buffer->mbuf.packet_type = buffer->mbuf.packet_type;
+    new_buffer->mbuf.nb_segs = buffer->mbuf.nb_segs;
 #else
     new_buffer->rss_hash_valid = buffer->rss_hash_valid;
 #endif
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index ddc651b..ba044a3 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1764,6 +1764,10 @@  dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
         memcpy(rte_pktmbuf_mtod(pkts[newcnt], void *),
                dp_packet_data(batch->packets[i]), size);
 
+        pkts[newcnt]->nb_segs = batch->packets[i]->mbuf.nb_segs;
+        pkts[newcnt]->ol_flags = batch->packets[i]->mbuf.ol_flags;
+        pkts[newcnt]->packet_type = batch->packets[i]->mbuf.packet_type;
+        pkts[newcnt]->tx_offload = batch->packets[i]->mbuf.tx_offload;
         rte_pktmbuf_data_len(pkts[newcnt]) = size;
         rte_pktmbuf_pkt_len(pkts[newcnt]) = size;