<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:微软雅黑;
        panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
        {font-family:"\@微软雅黑";
        panose-1:2 11 5 3 2 2 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:宋体;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US"><a href="https://github.com/rodgarrison/reinvent/blob/main/integration_tests/reinvent_dpdk_udp/reinvent_dpdk_udp_integration_test.cpp#L345">https://github.com/rodgarrison/reinvent/blob/main/integration_tests/reinvent_dpdk_udp/reinvent_dpdk_udp_integration_test.cpp#L345</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">this is for tx checksum, Tx checksum works good, Rx checksum failed.</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"微软雅黑",sans-serif">发件人<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"微软雅黑",sans-serif"> fwefew 4t4tg [mailto:7532yahoo@gmail.com]
<br>
</span><b><span style="font-size:11.0pt;font-family:"微软雅黑",sans-serif">发送时间<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"微软雅黑",sans-serif"> 2022</span><span style="font-size:11.0pt;font-family:"微软雅黑",sans-serif">年<span lang="EN-US">3</span>月<span lang="EN-US">28</span>日<span lang="EN-US">
 11:12<br>
</span><b>收件人<span lang="EN-US">:</span></b><span lang="EN-US"> Stephen Hemminger <stephen@networkplumber.org><br>
</span><b>抄送<span lang="EN-US">:</span></b><span lang="EN-US"> jiangheng (H) <jiangheng12@huawei.com>; users@dpdk.org<br>
</span><b>主题<span lang="EN-US">:</span></b><span lang="EN-US"> Re: [dpdk-users] DPDK RX TCP checksum failed<o:p></o:p></span></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><a href="https://github.com/rodgarrison/reinvent">https://github.com/rodgarrison/reinvent</a><br>
demonstrates ether/UDP chec-kum offload running on AWS which uses virtio. I don't think TCP offload<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">is substantially different. Look here:<br>
<br>
<a href="https://github.com/rodgarrison/reinvent/blob/main/integration_tests/reinvent_dpdk_udp/reinvent_dpdk_udp_integration_test.cpp#L345">https://github.com/rodgarrison/reinvent/blob/main/integration_tests/reinvent_dpdk_udp/reinvent_dpdk_udp_integration_test.cpp#L345</a><br>
<br>
for where the mbuf needs to be setup.<br>
<br>
But I kind of agree with Stephan, although I haven't tested it, avoiding more sets into mbuf which might involve cache misses it might be faster to do by hand since the data is already in cache.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">On Sat, Mar 26, 2022 at 2:59 PM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</a>> wrote:<o:p></o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US">On Sat, 26 Mar 2022 08:13:21 +0000<br>
"jiangheng (H)" <<a href="mailto:jiangheng12@huawei.com" target="_blank">jiangheng12@huawei.com</a>> wrote:<br>
<br>
> Hi all,<br>
> <br>
> I tried using the checksum offloads feature in DPDK and it did not see working under virtual machine.<br>
> <br>
> Port only support TCP checksum and do not support IP checksum:<br>
> rx_offload_capa = DEV_RX_OFFLOAD_TCP_CKSUM<br>
> tx_offload_capa = DEV_TX_OFFLOAD_TCP_CKSUM<br>
> <br>
> so I config rxmode.offload txmode.offloads as below:<br>
> rxmode.offloads = DEV_RX_OFFLOAD_TCP_CKSUM<br>
> txmode.offloads = DEV_TX_OFFLOAD_TCP_CKSUM<br>
> <br>
> For TX, I set the following parameters, it works good.<br>
> mbuf->l2_len = sizeof(*ethhdr)<br>
> mbuf->l3_len = ip header len<br>
> mbuf-ol_flags = RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_TCP_CKSUM<br>
<br>
<br>
Virtio does not support IP checksum offload.  Because Virtio passes<br>
packets to Linux kernel, and Linux kernel does not do IP checksum offload.<br>
The IP checksum is so trivial it is faster for most things to just<br>
do it in software; the header is only 20 bytes and it will be in cache.<br>
<br>
You should always check device capability before enabling an offload.<br>
<br>
<br>
> For RX, It will execute the following code:<br>
> In drivers/net/virtio/virtio_rxtx.c  virtio_rx_offload function :<br>
>     if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {<br>
>         hdrlen = hdr_lens.l2_len + hdr_lens.l3_len + hdr_lens.l4_len;<br>
>         if (hdr->csum_start <= hdrlen && l4_supported) {<br>
>             m->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_NONE;<br>
>         } else {<br>
> <br>
> m->ol_flags set to RTE_MBUF_F_RX_L4_CKSUM_NONE, causing the TCP RX checksum failed.<br>
> How do I avoid the above code going into this branch?<br>
> <br>
<br>
If you want TCP checksum offload you have to set RTE_ETH_RX_OFFLOAD_TCP_CKSUM<br>
in the rxmode when port is configured.  This will tell virtio to ask the<br>
host to do rx offload. Again, virtio does not do IP checksum offload and<br>
you should always query device capability first.<o:p></o:p></span></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>