<div dir="ltr"><div><div><div>Hi,<br></div><div><br>I see you configure the device so I assume it has the capabilities to do the checksum offloading.<br><br></div>However, do you "tell" the device to calculate the checksums for every packet. I mean, point 2 from my previous email where certain flags are set in the `ol_flags` for every Tx packet.<br></div>I think this is needed in order to tell the device whether you want it to calculate the checksum for the given packet or you want it to skip the checksum calculation.<br></div>You need something like this for every packet before calling `rte_eth_tx_burst` for the packet(s).<br><div><br></div><div>pkt->ol_flags |= PKT_TX_IP_CKSUM | PKT_TX_IPV4 | PKT_TX_UDP_CKSUM;</div>pkt->l2_len = RTE_ETHER_HDR_LEN;                                        <br><div>pkt->l3_len = <ip header length>; // ((hdr.version_ihl & 0x0F) * 4U);</div><div><br></div><div><br> </div>These comments from lib/librte_mbuf/rte_mbuf_core.h explain the flags<br>/**                                                                             <br> * Bits 52+53 used for L4 packet type with checksum enabled: 00: Reserved,         <br> * 01: TCP checksum, 10: SCTP checksum, 11: UDP checksum. To use hardware          <br> * L4 checksum offload, the user needs to:                                      <br> *  - fill l2_len and l3_len in mbuf                                            <br> *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM        <br> *  - set the flag PKT_TX_IPV4 or PKT_TX_IPV6                                   <br> */<br>/**                                                                             <br> * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should         <br> * also be set by the application, although a PMD will only check               <br> * PKT_TX_IP_CKSUM.                                                             <br> *  - fill the mbuf offload information: l2_len, l3_len                         <br> */</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 8, 2022 at 10:57 AM Ruslan R. Laishev <<a href="mailto:zator@yandex.ru">zator@yandex.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hello, Paul!</div><div> </div><div>Thanks for the answer.</div><div> </div><div><div> </div></div><div><span style="font-family:"courier new",monospace">I set offloads as follows:</span></div><div>...</div><div><pre style="margin:0px;text-indent:0px"><span style="color:rgb(255,106,173)">#define</span><span style="color:rgb(190,192,194)"> </span><span style="color:rgb(255,106,173)">RTE_ETH_TX_OFFLOAD_IPV4_CKSUM</span><span style="color:rgb(190,192,194)">       </span><span style="color:rgb(255,106,173)">RTE_BIT64</span>(<span style="color:rgb(138,96,44)">1</span>)</pre><pre style="margin:0px;text-indent:0px"><span style="color:rgb(255,106,173)">#define</span><span style="color:rgb(190,192,194)"> </span><span style="color:rgb(255,106,173)">RTE_ETH_TX_OFFLOAD_UDP_CKSUM</span><span style="color:rgb(190,192,194)">        </span><span style="color:rgb(255,106,173)">RTE_BIT64</span>(<span style="color:rgb(138,96,44)">2</span>)</pre><pre style="margin:0px;text-indent:0px"><span style="color:rgb(255,106,173)">#define</span><span style="color:rgb(190,192,194)"> </span><span style="color:rgb(255,106,173)">RTE_ETH_TX_OFFLOAD_TCP_CKSUM</span><span style="color:rgb(190,192,194)">        </span><span style="color:rgb(255,106,173)">RTE_BIT64</span>(<span style="color:rgb(138,96,44)">3</span>)</pre></div><div>...</div><div><pre style="margin:0px;text-indent:0px"><span style="font-family:"courier new",monospace"><em style="color:rgb(69,198,214);font-style:italic">static</em></span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(255,128,128);font-family:"courier new",monospace">uint64_t</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="font-family:"courier new",monospace">s_offloads</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">=</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="font-family:"courier new",monospace">{</span></pre><pre style="margin:0px;text-indent:0px"><span style="color:rgb(190,192,194);font-family:"courier new",monospace">          </span><span style="color:rgb(255,106,173);font-family:"courier new",monospace">RTE_ETH_TX_OFFLOAD_IPV4_CKSUM</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">|</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(255,106,173);font-family:"courier new",monospace">RTE_ETH_TX_OFFLOAD_UDP_CKSUM</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">|</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(255,106,173);font-family:"courier new",monospace">RTE_ETH_TX_OFFLOAD_TCP_CKSUM</span><span style="font-family:"courier new",monospace">};</span></pre><div> </div></div><div><pre style="margin:0px;text-indent:0px"><span style="color:rgb(190,192,194);font-family:"courier new",monospace">              </span><span style="font-family:"courier new",monospace"><em style="color:rgb(69,198,214);font-style:italic">if</em></span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="font-family:"courier new",monospace">(</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">l_dev_info.</span><span style="font-family:"courier new",monospace">tx_offload_capa</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">&</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(255,106,173);font-family:"courier new",monospace">RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="font-family:"courier new",monospace">)</span></pre><pre style="margin:0px;text-indent:0px"><span style="color:rgb(190,192,194);font-family:"courier new",monospace">                        </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">l_port_conf.</span><span style="font-family:"courier new",monospace">txmode</span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">.</span><span style="font-family:"courier new",monospace">offloads</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">|=</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(255,106,173);font-family:"courier new",monospace">RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE</span><span style="font-family:"courier new",monospace">;</span></pre><pre style="margin:0px;text-indent:0px"> </pre><pre style="margin:0px;text-indent:0px"><span style="color:rgb(190,192,194);font-family:"courier new",monospace">          </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">l_port_conf.</span><span style="font-family:"courier new",monospace">txmode</span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">.</span><span style="font-family:"courier new",monospace">offloads</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="color:rgb(214,187,154);font-family:"courier new",monospace">|=</span><span style="color:rgb(190,192,194);font-family:"courier new",monospace"> </span><span style="font-family:"courier new",monospace">s_offloads;</span></pre><div> </div><div><div><span style="font-family:"courier new",monospace">l_dev_info.tx_offload_capa = 0x000080bf</span></div><div><span style="font-family:"courier new",monospace">l_port_conf.txmode.offloads = 0x0000000e - it's before </span>rte_eth_dev_configure( ( ... <span style="color:rgb(214,187,154)">&l_port_conf ...)</span></div><div><br></div></div><div> </div><div> </div><div>The receiver - is  DPDK application. Do I'm need set offloads at receiver site to eliminate "ierrors" ?</div><div> </div></div><div> </div><div> </div><div> </div><div> </div><div>08.12.2022, 10:54, "Pavel Vazharov" <<a href="mailto:freakpv@gmail.com" target="_blank">freakpv@gmail.com</a>>:</div><blockquote><div><div><div><div><div>Few questions:</div>1. Does the sending NIC support IP and TCP/UDP checksum offloading? I mean, if these flags set?<br>    struct rte_eth_dev_info dev_info;                                          <br>    rte_eth_dev_info_get(cfg.nic_port_id_, &dev_info);<br>    constexpr auto rxcsum = DEV_RX_OFFLOAD_CHECKSUM;                            <br>    constexpr auto l3csum = DEV_TX_OFFLOAD_IPV4_CKSUM;                          <br>    constexpr auto l4csum = DEV_TX_OFFLOAD_TCP_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM;                 <br>    dev_rx_csum_          = ((dev_info.tx_offload_capa & rxcsum) == rxcsum);    <br>    dev_tx_csum_l3_       = ((dev_info.tx_offload_capa & l3csum) == l3csum);    <br>    dev_tx_csum_l4_       = ((dev_info.tx_offload_capa & l4csum) == l4csum);<br> </div>2. Do you "tell" the sending NIC to do the checksum calculations before sending the packets? I mean, do you do something like this for outgoing packets?<br>    if (offl.ip_csum) {                                                        <br>        pkt->ol_flags |= PKT_TX_IP_CKSUM | PKT_TX_IPV4;                        <br>        pkt->l2_len = RTE_ETHER_HDR_LEN;                                        <br>        pkt->l3_len = ih_len;                                                  <br>    }                                                                          <br>    if (offl.tcp_csum) {                                                        <br>        pkt->ol_flags |= PKT_TX_TCP_CKSUM;                                      <br>        pkt->l2_len = RTE_ETHER_HDR_LEN;                                        <br>        pkt->l3_len = ih_len;                                                  <br>    }                                                                          <br>    if (offl.udp_csum) {                                                        <br>        pkt->ol_flags |= PKT_TX_UDP_CKSUM;                                      <br>        pkt->l2_len = RTE_ETHER_HDR_LEN;                                        <br>        pkt->l3_len = ih_len;                                                  <br>    }<br> </div>3. Is the receiving side also a DPDK application? If it is, and if the NIC there supports checksum offloading you can check the flags of the received packets to see if the receiving NIC has detected checksum errors.<br>pkt->ol_flags & (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD)<br> </div><div>Hope some of the above helps.</div></div> <div><div>On Thu, Dec 8, 2022 at 9:36 AM Ruslan R. Laishev <<a href="mailto:zator@yandex.ru" rel="noopener noreferrer" target="_blank">zator@yandex.ru</a>> wrote:</div><blockquote style="border-left:1px solid rgb(204,204,204);margin:0px 0px 0px 0.8ex;padding-left:1ex"><div>Hello !</div><div> </div><div>I wrote too small apps to send and receive  ethernet/ip/udp frame/packet/dg, so on received side I  see next situation:</div><div>number of in errors is equally a number of received packets. The test packet I made manually,  set offloads  IP/UDP checkusm.</div><div>Is there what I'm need to check additionally ?</div><div> </div></blockquote></div></blockquote><div> </div><div> </div><div><span style="font-family:"georgia","palatino"">--- </span></div><div><span style="font-family:"georgia","palatino"">С уважением,<br>Ruslan R. Laishev</span></div><div><span style="font-family:"georgia","palatino"">OpenVMS bigot, natural born system/network progger, C contractor.</span></div><div><span style="font-family:"georgia","palatino"">+79013163222</span></div><div><span style="font-family:"georgia","palatino"">+79910009922</span></div><div> </div></blockquote></div>