static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,

                                           const void *pkt_data,

                                           size_t pkt_len)

{

    struct virtio_net_hdr *vhdr;

    bool isip4, isip6, istcp, isudp;

    uint8_t *data;

    int len;



    if (!net_rx_pkt_has_virt_hdr(pkt)) {

        return;

    }



    vhdr = net_rx_pkt_get_vhdr(pkt);

    if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {

        return;

    }



    net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp);

    if (!(isip4 || isip6) || !(istcp || isudp)) {

        return;

    }



    vmxnet3_dump_virt_hdr(vhdr);



    /* Validate packet len: csum_start + scum_offset + length of csum field */

    if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {

        VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, "

                  "cannot calculate checksum",

                  pkt_len, vhdr->csum_start, vhdr->csum_offset);

        return;

    }



    data = (uint8_t *)pkt_data + vhdr->csum_start;

    len = pkt_len - vhdr->csum_start;

    /* Put the checksum obtained into the packet */

    stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));



    vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;

    vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;

}

static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,

                                           const void *pkt_data,

                                           size_t pkt_len)

{

    struct virtio_net_hdr *vhdr;

    bool isip4, isip6, istcp, isudp;

    uint8_t *data;

    int len;



    if (!net_rx_pkt_has_virt_hdr(pkt)) {

        return;

    }



    vhdr = net_rx_pkt_get_vhdr(pkt);

    if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {

        return;

    }



    net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp);

    if (!(isip4 || isip6) || !(istcp || isudp)) {

        return;

    }



    vmxnet3_dump_virt_hdr(vhdr);



    

    if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {

        VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, "

                  "cannot calculate checksum",

                  pkt_len, vhdr->csum_start, vhdr->csum_offset);

        return;

    }



    data = (uint8_t *)pkt_data + vhdr->csum_start;

    len = pkt_len - vhdr->csum_start;

    

    stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));



    vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;

    vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;

}

    stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));
static void FUNC_0(struct NetRxPkt *VAR_0,

                                           const void *VAR_1,

                                           size_t VAR_2)

{

    struct virtio_net_hdr *VAR_3;

    bool isip4, isip6, istcp, isudp;

    uint8_t *data;

    int VAR_4;



    if (!net_rx_pkt_has_virt_hdr(VAR_0)) {

        return;

    }



    VAR_3 = net_rx_pkt_get_vhdr(VAR_0);

    if (!VMXNET_FLAG_IS_SET(VAR_3->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {

        return;

    }



    net_rx_pkt_get_protocols(VAR_0, &isip4, &isip6, &isudp, &istcp);

    if (!(isip4 || isip6) || !(istcp || isudp)) {

        return;

    }



    vmxnet3_dump_virt_hdr(VAR_3);



    

    if (VAR_2 < (VAR_3->csum_start + VAR_3->csum_offset + 2)) {

        VMW_PKPRN("packet VAR_4:%zu < csum_start(%d) + csum_offset(%d) + 2, "

                  "cannot calculate checksum",

                  VAR_2, VAR_3->csum_start, VAR_3->csum_offset);

        return;

    }



    data = (uint8_t *)VAR_1 + VAR_3->csum_start;

    VAR_4 = VAR_2 - VAR_3->csum_start;

    

    stw_be_p(data + VAR_3->csum_offset, net_raw_checksum(data, VAR_4));



    VAR_3->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;

    VAR_3->flags |= VIRTIO_NET_HDR_F_DATA_VALID;

}

static void FUNC_0(struct NetRxPkt *VAR_0,
const void *VAR_1,
size_t VAR_2)
{ struct virtio_net_hdr *VAR_3; bool isip4, isip6, istcp, isudp; uint8_t *data; int VAR_4; if (!net_rx_pkt_has_virt_hdr(VAR_0)) { return; } VAR_3 = net_rx_pkt_get_vhdr(VAR_0); if (!VMXNET_FLAG_IS_SET(VAR_3->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) { return; } net_rx_pkt_get_protocols(VAR_0, &isip4, &isip6, &isudp, &istcp); if (!(isip4 || isip6) || !(istcp || isudp)) { return; } vmxnet3_dump_virt_hdr(VAR_3); if (VAR_2 < (VAR_3->csum_start + VAR_3->csum_offset + 2)) { VMW_PKPRN("packet VAR_4:%zu < csum_start(%d) + csum_offset(%d) + 2, "
"cannot calculate checksum",
VAR_2, VAR_3->csum_start, VAR_3->csum_offset); return; } data = (uint8_t *)VAR_1 + VAR_3->csum_start; VAR_4 = VAR_2 - VAR_3->csum_start; stw_be_p(data + VAR_3->csum_offset, net_raw_checksum(data, VAR_4)); VAR_3->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM; VAR_3->flags |= VIRTIO_NET_HDR_F_DATA_VALID; }