添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
文雅的炒饭  ·  As a reader --> ...·  7 月前    · 
胆小的单杠  ·  Spark source ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am using the checksum offloads feature in DPDK and it did not working under virtual macine. virtual port only support TCP checksum and do not support IP checksum.

so I config rxmode.offload txmode.offloads as below:

rxmode.offloads = DEV_RX_OFFLOAD_TCP_CKSUM 
txmode.offloads = DEV_TX_OFFLOAD_TCP_CKSUM
... ...
rte_eth_dev_configure()

For TX, I set the following parameters, it works good.

mbuf->l2_len = sizeof(*ethhdr)
mbuf->l3_len = ip header len
mbuf-ol_flags = RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_TCP_CKSUM

For RX, It will execute the following code:

 In drivers/net/virtio/virtio_rxtx.c  virtio_rx_offload function :
 929     if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
 930         hdrlen = hdr_lens.l2_len + hdr_lens.l3_len + hdr_lens.l4_len;
 931         if (hdr->csum_start <= hdrlen && l4_supported) {
 932             m->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_NONE;
 933         } else {
                ...  ...
 952         }
 953     } else if (hdr->flags & VIRTIO_NET_HDR_F_DATA_VALID && l4_supported) {
 954         m->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
 955     }

hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM is true(line 929)

hdrlen = 54

hdr->csum_start = 34

so m->ol_flags = RTE_MBUF_F_RX_L4_CKSUM_NONE(line 932)

This cause rx checksum failed.

I think the code should enter line 953 not line 929, but I don’t know where hdr->flags be set to VIRTIO_NET_HDR_F_NEEDS_CSUM.

dpdk version is 21.11

can you please clarify your question as RX TCP checksum is not working, or TX TCP checksum is not working, or both RX and TX checksum is not working. Also please share the example that is run in guest to validate the same.. Note: as per your question title you are stating dpdk Rx TCP checksum failed – Vipin Varghese Apr 12, 2022 at 3:23 I request you to check both patchwork.kernel.org/project/kvm/patch/… and doc.dpdk.org/guides/nics/overview.html. As per the patch if the host has validated the checksum the guest can skip checksum in RX direction saving CPU cycles. Is your host validating the checksum and injecting to guest via virtio? Can you please clarify – Vipin Varghese Apr 12, 2022 at 3:28 can you please clarify your question as RX TCP checksum is not working, or TX TCP checksum is not working, or both RX and TX checksum is not working. --> "RX TCP checksum is not working" – J.Heng Apr 12, 2022 at 9:45 looks like you accepted an answer, happy to see your issue is resolved rte_ipv4_udptcp_cksum_verify. were you able to nail down what caused RX_L4_CKSUM_NONE. as mentioned in my earlier comment is it host os which validates L4 hence bypassed in guest with patchwork.kernel.org/project/kvm/patch/…? – Vipin Varghese Apr 13, 2022 at 3:22 I have another confusion, what is the meaning of "the checksum in packet may be wrong, but data integrity is valid". is checksum a calculated value that is used to determine the integrity of data? In fact, I can observe some mbuf->ol_flags is RX_L4_CKSUM_GOOD, another is RX_L4_CKSUM_NONE,why these mbufs ol_flags can be different? – J.Heng Apr 13, 2022 at 14:57

According to the original commit, RX_L4_CKSUM_NONE helps to cover the virtio / vhost use case and indicates that "the checksum in packet may be wrong, but data integrity is valid".

My takeaway from this explanation is that confirming the "data integrity" might be possible because of the very nature of this specific use case, but, since no checksum validation is done (the value is not recalculated), one cannot set RX_L4_CKSUM_GOOD or RX_L4_CKSUM_BAD. Hence RX_L4_CKSUM_NONE.

Perhaps it pays to add a printout of rte_ipv4_udptcp_cksum_verify() invocation (temporarily) to the application. If it reports that the checksum is valid, then above explanation should prove correct (no checksum failure).

My app is : if ((p->ol_flags & (RTE_MBUF_F_RX_IP_CKSUM_BAD)) != 0) {return error}; so according to the above; I should modify my app to if ((p->ol_flags PKT_RX_L4_CKSUM_MASK) == PKT_RX_L4_CKSUM_BAD) {return error} – J.Heng Apr 12, 2022 at 10:00 The NONE flag is a combination of the corresponding GOOD and BAD ones. In this particular case, the driver sets NONE, that's why both GOOD and BAD bits are seen in ol_flags. The checksum status (as a whole) is a 2-bit enum value here. And the right way to check it is to apply the mask (L4_CKSUM_MASK) and compare (==) the resulting value with, say, BAD or GOOD, depending on what the app needs to check. – user10304260 Apr 13, 2022 at 17:02

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.