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

Jack Morgenstein jackm at dev.mellanox.co.il
Tue May 5 00:21:36 PDT 2009


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

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