Rajat Jain
|
Adding HW checksum in network driver
|
Rajat Jain
07/07/2008 11:26 AM
post10119
|
Adding HW checksum in network driver
Hi,
I'm trying to add TCP / IP checksum support in my network driver and am a little confused about its interaction with the
higher layers. Can some one please clarify my doubts:
1) Firstly, should a driver be ready for a situation where the user first enables the HW checksum support and then
disables it? Looking at the help for ifconfig, this surely looks possible:
# ifconfig en0 inet ip4csum-rx
# ifconfig en0 inet -ip4csum-rx
But when I try this experimentally, I find that my driver's SIOCSIFCAP devctl dutifully called with correct
ifcr_capenable_rx set for the first command. But my devctl() is never called again for the second command. What am I
missing here?
2) I understand that the driver should enable HW checksum offloading as per the flags set in ifcr_capenable_rx in
SIOCSIFCAP devctl:
IFCAP_CSUM_IPv4
IFCAP_CSUM_TCPv4
IFCAP_CSUM_UDPv4
IFCAP_CSUM_TCPv6
IFCAP_CSUM_UDPv6
Hence if a flag is set, then the corresponding capability needs to be enabled in HW. But what is the expected behavior
from driver in case a flag is NOT set (and the corresponding ability is already enabled in HW). Should the corresponding
ability be DISABLED in HW or should it be left untouched?
3) Just to make sure I understand it correctly, can somebody please confirm my understanding:
Taking IPv4 as example, in Rx side checksum offloading, the driver should set the flags in npkt->csum_flags like this:
- If no checksum done, do not set any flags
- If checksum verification done, and it was Correct - Just set M_CSUM_IPv4
- If checksum verification done, and it was bad -set M_CSUM_IPv4 and M_CSUM_IPv4_BAD
Is this right?
Thanks,
Rajat
|
|
|