Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Adding HW checksum in network driver: (5 Items)
   
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

Re: Adding HW checksum in network driver  
Hi,

I found out answer to my question 2, but my other two queries persist:

Thanks,

Rajat


> 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?
> 
> 
> 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
> 


Re: Adding HW checksum in network driver  
On Tue, Jul 08, 2008 at 05:40:32AM -0400, Rajat Jain wrote:
> 
> Hi,
> 
> I found out answer to my question 2, but my other two queries persist:
> 
> Thanks,
> 
> Rajat
> 
> 
> > 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?


This is a bug in ifconfig. -ip4csum-[rt]x was trying to enable,
not disable.  Since it was already enabled the stack didn't bother
calling your devctl. -ip4csum was doing the right thing. New x86
io-net version of ifconfig attached.

> > 
> > 
> > 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 it's not enabled, the stack ignores your flags on rx so do whatever's
easiest / most efficient.

> > - 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?

Yes.

Attachment: Text ifconfig 48.4 KB
RE: Adding HW checksum in network driver  
Hi Sean,

> 
> This is a bug in ifconfig. -ip4csum-[rt]x was trying to
> enable, not disable.  Since it was already enabled the stack
> didn't bother calling your devctl. -ip4csum was doing the
> right thing. New x86 io-net version of ifconfig attached.
> 

Thanks for the info. Can you please send me the latest io-net ifconfig
for ppcbe?

Thanks a lot,

Rajat
Re: Adding HW checksum in network driver  
On Tue, Jul 08, 2008 at 11:49:49PM -0400, Rajat Jain wrote:
> 
> Hi Sean,
> 
> > 
> > This is a bug in ifconfig. -ip4csum-[rt]x was trying to
> > enable, not disable.  Since it was already enabled the stack
> > didn't bother calling your devctl. -ip4csum was doing the
> > right thing. New x86 io-net version of ifconfig attached.
> > 
> 
> Thanks for the info. Can you please send me the latest io-net ifconfig
> for ppcbe?

Attached.

-seanb
Attachment: Text ifconfig 55.21 KB