[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [task #16111] Set checksum to zero optimized-out in case of
From: |
Zakaria Abu Al-Ailah |
Subject: |
[lwip-devel] [task #16111] Set checksum to zero optimized-out in case of using a HW Checksum Block |
Date: |
Sat, 22 Jan 2022 15:43:35 -0500 (EST) |
Follow-up Comment #2, task #16111 (project lwip):
Hi Simon,
I hope you are doing well.
Thank you for your prompt reply.
We have been using LwIP for a long time ago, and didn't face a single issue
with it.
Actually, we started having this problem after starting to use our own
HARDWARE CHECKSUM BLOCK, so the checksum is computed in Hardware in order to
speed up the process and get higher throughput.
To do so, we defined 'LWIP_CHKSUM' in 'lwipopts.h' as follows:
#define LWIP_CHKSUM hw_cks
The function 'hw_cks' sets the input parameters ('dataptr' and 'len') in some
registers and then starts the HW BLOCK, and when the output gets ready, it
reads the checksum from some register and returns it.
In unit testing, the HW BLOCK works 100% properly, but in integration with
LwIP, we figured out that ping-replies are sent out with wrong header
checksum!
In this case, we checked the disassembly code, and found out that the compiler
has completely removed the code of the instruction 'IPH_CHKSUM_SET(iphdr, 0)'
(line 236).
That said, the problem is never related to delay storing or something related
to the cache.
The compiler is doing so, since the same field '_chksum' is sets twice (line
236 and 239), and this field is not used in software between the two sets, but
actually the HW BLOCK will pass on it (in memory) in order to compute the new
checksum (for the ping-reply).
We added a dummy instruction inside the function 'hw_cks(const void *dataptr,
int len)', e.g.
uint8_t val = *((uint8_t *)dataptr + 10); /* read the first byte of '_chksum'
*/
We then checked the disassembly code, and found that the compiler didn't
remove the code of 'IPH_CHKSUM_SET(iphdr, 0)' (in this case, it is aware that
this field is used).
We also did a test (receive ping-requests from the host and send ping-replies
out) and verified that everything is working fine.
*I guess you should add 'volatile' to the field '_chksum', in order to
explicitly tell the compiler that this field might be used in hardware.*
Note: We are using FTO optimization. It is required in our case.
Regards,
Zakaria
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/task/?16111>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/