[ofa-general] OFED, the backported <linux/scatterlist.h> header and sg_init_table()

Jon Mason jon at opengridcomputing.com
Tue May 5 08:06:36 PDT 2009


On Tue, May 05, 2009 at 10:21:36AM +0300, Jack Morgenstein wrote:
> On Monday 04 May 2009 17:56, Jon Mason wrote:
> > What's even worse is that sg_init_table is already defined in the
> > RHEL5.3 headers.  When coding up a header cleanup patch for RHEL5.3, I
> > noticed it was already defined in linux/ncrypto.h.  Also, it's there for
> > RHEL5.2 (and a few older kernels).
> > 
> I do not see that as "worse". ncrypto is the cryptographic scatterlist API, which is not used anywhere in OFED.
> Do we include this only because of its base scatterlist additions? 

No, we currently duplicate all the scatterlist functionality.  Including
ncrypto.h would greatly simplify the backport headers, but it is a
RHEL5.2/5.3 only solution.  If this change is needed for all other
backports, then a better solution will be needed.

> ncrypto.h itself has a list of includes.
> 
> I guess, though, you could do the following for scatterlist.h in the RHEL5.3 backport:
> ==============================================================================
> #ifndef __BACKPORT_LINUX_SCATTERLIST_H_TO_RHEL5_3__
> #define __BACKPORT_LINUX_SCATTERLIST_H_TO_RHEL5_3__
> 
> /* crypto.h includes scatterlist.h */
> #include<linux/ncrypto.h>
> 
> static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
> {
>         sg->page = page;
> }
> 
> #define for_each_sg(sglist, sg, nr, __i)        \
>         for (__i = 0, sg = (sglist); __i < (nr); __i++, sg++)
> 
> static inline struct scatterlist *sg_next(struct scatterlist *sg)
> {
>         if (!sg) {
>                 BUG();
>                 return NULL;
>         }
>         return sg + 1;
> }
> 
> #endif
> ==============================================================================


It is more than just this.  By including ncrypto.h, crypto.h and
scatterlist.h in the RHEL backports are 99% smaller due to the removal
of duplicated functionality.  Obviously, this will need to be tested
heavily.

Thanks,
Jon

> 
> linux/ncrypto.h, though, is not part of, say, kernel 2.6.23.  Need to check if the above is RedHat-only solution.
> 
> - Jack



More information about the general mailing list