[openib-general] [PATCH ] ofed_1_2 Backport Chelsio to RHEL4U4
Vladimir Sokolovsky
vlad at mellanox.co.il
Thu Jan 18 08:53:32 PST 2007
Applied.
Regards,
Vladimir
On Thu, 2007-01-18 at 10:31 -0600, Steve Wise wrote:
> Backport Chelsio to RHEL4U4
>
> Signed-off-by: Steve Wise <swise at opengridcomputing.com>
> ---
>
> .../backport/2.6.9_U4/include/linux/ethtool.h | 9 +
> .../backport/2.6.9_U4/include/linux/genalloc.h | 42 +++++
> .../backport/2.6.9_U4/include/linux/interrupt.h | 17 ++
> .../backport/2.6.9_U4/include/linux/kfifo.h | 157 ++++++++++++++++++
> kernel_addons/backport/2.6.9_U4/include/linux/mm.h | 20 ++
> .../backport/2.6.9_U4/include/linux/netdevice.h | 9 +
> .../backport/2.6.9_U4/include/linux/pci.h | 1
> .../backport/2.6.9_U4/include/linux/random.h | 15 ++
> .../backport/2.6.9_U4/include/linux/skbuff.h | 4
> .../backport/2.6.9_U4/include/linux/slab.h | 19 --
> .../backport/2.6.9_U4/include/linux/types.h | 8 +
> .../backport/2.6.9_U4/include/linux/workqueue.h | 8 +
> kernel_addons/backport/2.6.9_U4/include/net/dst.h | 16 ++
> .../backport/2.6.9_U4/include/net/netevent.h | 33 ++++
> .../backport/2.6.9_U4/include/src/genalloc.c | 198 +++++++++++++++++++++++
> .../backport/2.6.9_U4/include/src/kfifo.c | 196 +++++++++++++++++++++++
> .../backport/2.6.9_U4/include/src/netevent.c | 71 ++++++++
> .../backport/2.6.9_U4/cxgb3_main_to_2_6_13.patch | 12 +
> .../2.6.9_U4/cxgb3_makefile_to_2_6_19.patch | 12 +
> .../backport/2.6.9_U4/iwch_cm_to_2_6_9_U4.patch | 13 ++
> .../backport/2.6.9_U4/linux_stuff_to_2_6_17.patch | 31 ++++
> .../2.6.9_U4/mthca_provider_3465_to_2_6_9.patch | 15 --
> .../backport/2.6.9_U4/t3_hw_to_2_6_5-7_244.patch | 43 +++++
> 23 files changed, 917 insertions(+), 32 deletions(-)
>
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/ethtool.h b/kernel_addons/backport/2.6.9_U4/include/linux/ethtool.h
> new file mode 100644
> index 0000000..d03127c
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/ethtool.h
> @@ -0,0 +1,9 @@
> +#ifndef BACKPORT_LINUX_ETHTOOL_TO_2_6_13
> +#define BACKPORT_LINUX_ETHTOOL_TO_2_6_13
> +
> +#include_next <linux/ethtool.h>
> +
> +#define ADVERTISED_Pause (1 << 13)
> +#define ADVERTISED_Asym_Pause (1 << 14)
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/genalloc.h b/kernel_addons/backport/2.6.9_U4/include/linux/genalloc.h
> new file mode 100644
> index 0000000..3c23c68
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/genalloc.h
> @@ -0,0 +1,42 @@
> +/*
> + * Basic general purpose allocator for managing special purpose memory
> + * not managed by the regular kmalloc/kfree interface.
> + * Uses for this includes on-device special memory, uncached memory
> + * etc.
> + *
> + * This source code is licensed under the GNU General Public License,
> + * Version 2. See the file COPYING for more details.
> + */
> +
> +
> +/*
> + * General purpose special memory pool descriptor.
> + */
> +struct gen_pool {
> + rwlock_t lock;
> + struct list_head chunks; /* list of chunks in this pool */
> + int min_alloc_order; /* minimum allocation order */
> +};
> +
> +/*
> + * General purpose special memory pool chunk descriptor.
> + */
> +struct gen_pool_chunk {
> + spinlock_t lock;
> + struct list_head next_chunk; /* next chunk in pool */
> + unsigned long start_addr; /* starting address of memory chunk */
> + unsigned long end_addr; /* ending address of memory chunk */
> + unsigned long bits[0]; /* bitmap for allocating memory chunk */
> +};
> +
> +extern struct gen_pool *ib_gen_pool_create(int, int);
> +extern int ib_gen_pool_add(struct gen_pool *, unsigned long, size_t, int);
> +extern void ib_gen_pool_destroy(struct gen_pool *);
> +extern unsigned long ib_gen_pool_alloc(struct gen_pool *, size_t);
> +extern void ib_gen_pool_free(struct gen_pool *, unsigned long, size_t);
> +
> +#define gen_pool_create ib_gen_pool_create
> +#define gen_pool_add ib_gen_pool_add
> +#define gen_pool_destroy ib_gen_pool_destroy
> +#define gen_pool_alloc ib_gen_pool_alloc
> +#define gen_pool_free ib_gen_pool_free
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/interrupt.h b/kernel_addons/backport/2.6.9_U4/include/linux/interrupt.h
> new file mode 100644
> index 0000000..66e66a9
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/interrupt.h
> @@ -0,0 +1,17 @@
> +#ifndef BACKPORT_LINUX_INTERRUPT_TO_2_6_18
> +#define BACKPORT_LINUX_INTERRUPT_TO_2_6_18
> +#include_next <linux/interrupt.h>
> +
> +static inline int
> +backport_request_irq(unsigned int irq,
> + irqreturn_t (*handler)(int, void *),
> + unsigned long flags, const char *dev_name, void *dev_id)
> +{
> + return request_irq(irq,
> + (irqreturn_t (*)(int, void *, struct pt_regs *))handler,
> + flags, dev_name, dev_id);
> +}
> +
> +#define request_irq backport_request_irq
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/kfifo.h b/kernel_addons/backport/2.6.9_U4/include/linux/kfifo.h
> new file mode 100644
> index 0000000..48eccd8
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/kfifo.h
> @@ -0,0 +1,157 @@
> +/*
> + * A simple kernel FIFO implementation.
> + *
> + * Copyright (C) 2004 Stelian Pop <stelian at popies.net>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +#ifndef _LINUX_KFIFO_H
> +#define _LINUX_KFIFO_H
> +
> +#ifdef __KERNEL__
> +
> +#include <linux/kernel.h>
> +#include <linux/spinlock.h>
> +
> +struct kfifo {
> + unsigned char *buffer; /* the buffer holding the data */
> + unsigned int size; /* the size of the allocated buffer */
> + unsigned int in; /* data is added at offset (in % size) */
> + unsigned int out; /* data is extracted from off. (out % size) */
> + spinlock_t *lock; /* protects concurrent modifications */
> +};
> +
> +extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
> + gfp_t gfp_mask, spinlock_t *lock);
> +extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask,
> + spinlock_t *lock);
> +extern void kfifo_free(struct kfifo *fifo);
> +extern unsigned int __kfifo_put(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len);
> +extern unsigned int __kfifo_get(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len);
> +
> +/**
> + * __kfifo_reset - removes the entire FIFO contents, no locking version
> + * @fifo: the fifo to be emptied.
> + */
> +static inline void __kfifo_reset(struct kfifo *fifo)
> +{
> + fifo->in = fifo->out = 0;
> +}
> +
> +/**
> + * kfifo_reset - removes the entire FIFO contents
> + * @fifo: the fifo to be emptied.
> + */
> +static inline void kfifo_reset(struct kfifo *fifo)
> +{
> + unsigned long flags;
> +
> + spin_lock_irqsave(fifo->lock, flags);
> +
> + __kfifo_reset(fifo);
> +
> + spin_unlock_irqrestore(fifo->lock, flags);
> +}
> +
> +/**
> + * kfifo_put - puts some data into the FIFO
> + * @fifo: the fifo to be used.
> + * @buffer: the data to be added.
> + * @len: the length of the data to be added.
> + *
> + * This function copies at most 'len' bytes from the 'buffer' into
> + * the FIFO depending on the free space, and returns the number of
> + * bytes copied.
> + */
> +static inline unsigned int kfifo_put(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len)
> +{
> + unsigned long flags;
> + unsigned int ret;
> +
> + spin_lock_irqsave(fifo->lock, flags);
> +
> + ret = __kfifo_put(fifo, buffer, len);
> +
> + spin_unlock_irqrestore(fifo->lock, flags);
> +
> + return ret;
> +}
> +
> +/**
> + * kfifo_get - gets some data from the FIFO
> + * @fifo: the fifo to be used.
> + * @buffer: where the data must be copied.
> + * @len: the size of the destination buffer.
> + *
> + * This function copies at most 'len' bytes from the FIFO into the
> + * 'buffer' and returns the number of copied bytes.
> + */
> +static inline unsigned int kfifo_get(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len)
> +{
> + unsigned long flags;
> + unsigned int ret;
> +
> + spin_lock_irqsave(fifo->lock, flags);
> +
> + ret = __kfifo_get(fifo, buffer, len);
> +
> + /*
> + * optimization: if the FIFO is empty, set the indices to 0
> + * so we don't wrap the next time
> + */
> + if (fifo->in == fifo->out)
> + fifo->in = fifo->out = 0;
> +
> + spin_unlock_irqrestore(fifo->lock, flags);
> +
> + return ret;
> +}
> +
> +/**
> + * __kfifo_len - returns the number of bytes available in the FIFO, no locking version
> + * @fifo: the fifo to be used.
> + */
> +static inline unsigned int __kfifo_len(struct kfifo *fifo)
> +{
> + return fifo->in - fifo->out;
> +}
> +
> +/**
> + * kfifo_len - returns the number of bytes available in the FIFO
> + * @fifo: the fifo to be used.
> + */
> +static inline unsigned int kfifo_len(struct kfifo *fifo)
> +{
> + unsigned long flags;
> + unsigned int ret;
> +
> + spin_lock_irqsave(fifo->lock, flags);
> +
> + ret = __kfifo_len(fifo);
> +
> + spin_unlock_irqrestore(fifo->lock, flags);
> +
> + return ret;
> +}
> +
> +#else
> +#warning "don't include kernel headers in userspace"
> +#endif /* __KERNEL__ */
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/mm.h b/kernel_addons/backport/2.6.9_U4/include/linux/mm.h
> new file mode 100644
> index 0000000..77ee6fc
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/mm.h
> @@ -0,0 +1,20 @@
> +#ifndef BACKPORT_LINUX_MM_TO_SLES9SP3
> +#define BACKPORT_LINUX_MM_TO_SLES9SP3
> +
> +#include_next <linux/mm.h>
> +
> +static inline int
> +remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
> + unsigned long pfn, unsigned long size, pgprot_t prot)
> +{
> + return remap_page_range(vma, addr, pfn << PAGE_SHIFT, size, prot);
> +}
> +
> +static inline int
> +io_remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
> + unsigned long pfn, unsigned long size, pgprot_t prot)
> +{
> + return io_remap_page_range(vma, addr, pfn << PAGE_SHIFT, size, prot);
> +}
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/netdevice.h b/kernel_addons/backport/2.6.9_U4/include/linux/netdevice.h
> index 5641019..2f12781 100644
> --- a/kernel_addons/backport/2.6.9_U4/include/linux/netdevice.h
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/netdevice.h
> @@ -15,4 +15,13 @@ static inline void netif_tx_unlock(struc
> spin_unlock(&dev->xmit_lock);
> }
>
> +static inline int __netif_rx_schedule_prep(struct net_device *dev)
> +{
> + return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state);
> +}
> +
> +#undef SET_ETHTOOL_OPS
> +#define SET_ETHTOOL_OPS(netdev, ops) \
> + (netdev)->ethtool_ops = (struct ethtool_ops *)(ops)
> +
> #endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/pci.h b/kernel_addons/backport/2.6.9_U4/include/linux/pci.h
> index bd47cd4..6e0df62 100644
> --- a/kernel_addons/backport/2.6.9_U4/include/linux/pci.h
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/pci.h
> @@ -4,5 +4,6 @@ #define LINUX_PCI_BACKPORT_TO_2_6_9_H
> #include_next <linux/pci.h>
>
> #define PCI_EXP_LNKCTL 16 /* Link Control */
> +#define PCI_EXP_LNKSTA 18 /* Link Status */
>
> #endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/random.h b/kernel_addons/backport/2.6.9_U4/include/linux/random.h
> new file mode 100644
> index 0000000..2ea2e1f
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/random.h
> @@ -0,0 +1,15 @@
> +#ifndef BACKPORT_LINUX_RANDOM_TO_2_6_18
> +#define BACKPORT_LINUX_RANDOM_TO_2_6_18
> +#include_next <linux/random.h>
> +
> +static inline u32 backport_random32(void)
> +{
> + u32 v;
> +
> + get_random_bytes(&v, sizeof(u32));
> + return v;
> +}
> +
> +#define random32 backport_random32
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/skbuff.h b/kernel_addons/backport/2.6.9_U4/include/linux/skbuff.h
> index 94b968a..62bfb3b 100644
> --- a/kernel_addons/backport/2.6.9_U4/include/linux/skbuff.h
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/skbuff.h
> @@ -3,7 +3,8 @@ #define LINUX_SKBUFF_H_BACKPORT
>
> #include_next <linux/skbuff.h>
>
> -#define CHECKSUM_PARTIAL CHECKSUM_HW
> +#define CHECKSUM_PARTIAL CHECKSUM_HW
> +#define CHECKSUM_COMPLETE CHECKSUM_HW
>
> /**
> * skb_header_release - release reference to header
> @@ -17,5 +18,6 @@ static inline void skb_header_release(st
> {
> }
>
> +#define gso_size tso_size
>
> #endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/slab.h b/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
> index 46ac6e5..cbf6311 100644
> --- a/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
> @@ -1,10 +1,8 @@
> -#include_next <linux/slab.h>
> +#ifndef LINUX_SLAB_BACKPORT_H
> +#define LINUX_SLAB_BACKPORT_H
>
> #include_next <linux/slab.h>
>
> -#ifndef BACKPORT_LINUX_STRING_TO_2_6_18
> -#define BACKPORT_LINUX_STRING_TO_2_6_18
> -
> static inline
> void *kmemdup(const void *src, size_t len, gfp_t gfp)
> {
> @@ -16,19 +14,10 @@ void *kmemdup(const void *src, size_t le
> return p;
> }
>
> -#endif
> -#ifndef BACKPORT_LINUX_STRING_TO_2_6_18
> -#define BACKPORT_LINUX_STRING_TO_2_6_18
> -
> static inline
> -void *kmemdup(const void *src, size_t len, gfp_t gfp)
> +void *kmalloc_node(size_t size, gfp_t flags, int nid)
> {
> - void *p;
> -
> - p = kmalloc(len, gfp);
> - if (p)
> - memcpy(p, src, len);
> - return p;
> + return kmalloc(size, flags);
> }
>
> #endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/types.h b/kernel_addons/backport/2.6.9_U4/include/linux/types.h
> new file mode 100644
> index 0000000..0c19a43
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/types.h
> @@ -0,0 +1,8 @@
> +#ifndef LINUX_TYPES_BACKPORT_H
> +#define LINUX_TYPES_BACKPORT_H
> +
> +#include_next <linux/types.h>
> +
> +#define BITS_PER_BYTE 8
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/workqueue.h b/kernel_addons/backport/2.6.9_U4/include/linux/workqueue.h
> index 330f47f..c054ed2 100644
> --- a/kernel_addons/backport/2.6.9_U4/include/linux/workqueue.h
> +++ b/kernel_addons/backport/2.6.9_U4/include/linux/workqueue.h
> @@ -26,6 +26,12 @@ backport_cancel_delayed_work(struct dela
> return cancel_delayed_work(&work->work);
> }
>
> +static inline void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
> + struct delayed_work *dwork)
> +{
> + while (!cancel_delayed_work(&dwork->work))
> + flush_workqueue(wq);
> +}
>
> #undef INIT_WORK
> #define INIT_WORK(_work, _func) backport_INIT_WORK(_work, _func)
> @@ -33,7 +39,7 @@ #define INIT_DELAYED_WORK(_work, _func)
>
> #undef DECLARE_WORK
> #define DECLARE_WORK(n, f) \
> - struct work_struct n = __WORK_INITIALIZER(n, f, &(n))
> + struct work_struct n = __WORK_INITIALIZER(n, (void (*)(void *))f, &(n))
> #define DECLARE_DELAYED_WORK(n, f) \
> struct delayed_work n = { .work = __WORK_INITIALIZER(n.work, f, &(n.work)) }
>
> diff --git a/kernel_addons/backport/2.6.9_U4/include/net/dst.h b/kernel_addons/backport/2.6.9_U4/include/net/dst.h
> new file mode 100644
> index 0000000..ec5e7b4
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/net/dst.h
> @@ -0,0 +1,16 @@
> +#ifndef BACKPORT_NET_DST_2_6_11
> +#define BACKPORT_NET_DST_2_6_11
> +
> +#include_next <net/dst.h>
> +
> +static inline u32 dst_mtu(struct dst_entry *dst)
> +{
> + u32 mtu = dst_metric(dst, RTAX_MTU);
> + /*
> + * Alexey put it here, so ask him about it :)
> + */
> + barrier();
> + return mtu;
> +}
> +
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/net/netevent.h b/kernel_addons/backport/2.6.9_U4/include/net/netevent.h
> new file mode 100644
> index 0000000..e5d2162
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/net/netevent.h
> @@ -0,0 +1,33 @@
> +#ifndef _NET_EVENT_H
> +#define _NET_EVENT_H
> +
> +/*
> + * Generic netevent notifiers
> + *
> + * Authors:
> + * Tom Tucker <tom at opengridcomputing.com>
> + * Steve Wise <swise at opengridcomputing.com>
> + *
> + * Changes:
> + */
> +#ifdef __KERNEL__
> +
> +#include <net/dst.h>
> +
> +struct netevent_redirect {
> + struct dst_entry *old;
> + struct dst_entry *new;
> +};
> +
> +enum netevent_notif_type {
> + NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */
> + NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */
> + NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */
> +};
> +
> +extern int register_netevent_notifier(struct notifier_block *nb);
> +extern int unregister_netevent_notifier(struct notifier_block *nb);
> +extern int call_netevent_notifiers(unsigned long val, void *v);
> +
> +#endif
> +#endif
> diff --git a/kernel_addons/backport/2.6.9_U4/include/src/genalloc.c b/kernel_addons/backport/2.6.9_U4/include/src/genalloc.c
> new file mode 100644
> index 0000000..75ae68c
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/src/genalloc.c
> @@ -0,0 +1,198 @@
> +/*
> + * Basic general purpose allocator for managing special purpose memory
> + * not managed by the regular kmalloc/kfree interface.
> + * Uses for this includes on-device special memory, uncached memory
> + * etc.
> + *
> + * Copyright 2005 (C) Jes Sorensen <jes at trained-monkey.org>
> + *
> + * This source code is licensed under the GNU General Public License,
> + * Version 2. See the file COPYING for more details.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/genalloc.h>
> +
> +
> +/**
> + * gen_pool_create - create a new special memory pool
> + * @min_alloc_order: log base 2 of number of bytes each bitmap bit represents
> + * @nid: node id of the node the pool structure should be allocated on, or -1
> + *
> + * Create a new special memory pool that can be used to manage special purpose
> + * memory not managed by the regular kmalloc/kfree interface.
> + */
> +struct gen_pool *gen_pool_create(int min_alloc_order, int nid)
> +{
> + struct gen_pool *pool;
> +
> + pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid);
> + if (pool != NULL) {
> + rwlock_init(&pool->lock);
> + INIT_LIST_HEAD(&pool->chunks);
> + pool->min_alloc_order = min_alloc_order;
> + }
> + return pool;
> +}
> +EXPORT_SYMBOL(gen_pool_create);
> +
> +/**
> + * gen_pool_add - add a new chunk of special memory to the pool
> + * @pool: pool to add new memory chunk to
> + * @addr: starting address of memory chunk to add to pool
> + * @size: size in bytes of the memory chunk to add to pool
> + * @nid: node id of the node the chunk structure and bitmap should be
> + * allocated on, or -1
> + *
> + * Add a new chunk of special memory to the specified pool.
> + */
> +int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size,
> + int nid)
> +{
> + struct gen_pool_chunk *chunk;
> + int nbits = size >> pool->min_alloc_order;
> + int nbytes = sizeof(struct gen_pool_chunk) +
> + (nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
> +
> + chunk = kmalloc_node(nbytes, GFP_KERNEL, nid);
> + if (unlikely(chunk == NULL))
> + return -1;
> +
> + memset(chunk, 0, nbytes);
> + spin_lock_init(&chunk->lock);
> + chunk->start_addr = addr;
> + chunk->end_addr = addr + size;
> +
> + write_lock(&pool->lock);
> + list_add(&chunk->next_chunk, &pool->chunks);
> + write_unlock(&pool->lock);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(gen_pool_add);
> +
> +/**
> + * gen_pool_destroy - destroy a special memory pool
> + * @pool: pool to destroy
> + *
> + * Destroy the specified special memory pool. Verifies that there are no
> + * outstanding allocations.
> + */
> +void gen_pool_destroy(struct gen_pool *pool)
> +{
> + struct list_head *_chunk, *_next_chunk;
> + struct gen_pool_chunk *chunk;
> + int order = pool->min_alloc_order;
> + int bit, end_bit;
> +
> +
> + write_lock(&pool->lock);
> + list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
> + chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
> + list_del(&chunk->next_chunk);
> +
> + end_bit = (chunk->end_addr - chunk->start_addr) >> order;
> + bit = find_next_bit(chunk->bits, end_bit, 0);
> + BUG_ON(bit < end_bit);
> +
> + kfree(chunk);
> + }
> + kfree(pool);
> + return;
> +}
> +EXPORT_SYMBOL(gen_pool_destroy);
> +
> +/**
> + * gen_pool_alloc - allocate special memory from the pool
> + * @pool: pool to allocate from
> + * @size: number of bytes to allocate from the pool
> + *
> + * Allocate the requested number of bytes from the specified pool.
> + * Uses a first-fit algorithm.
> + */
> +unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
> +{
> + struct list_head *_chunk;
> + struct gen_pool_chunk *chunk;
> + unsigned long addr, flags;
> + int order = pool->min_alloc_order;
> + int nbits, bit, start_bit, end_bit;
> +
> + if (size == 0)
> + return 0;
> +
> + nbits = (size + (1UL << order) - 1) >> order;
> +
> + read_lock(&pool->lock);
> + list_for_each(_chunk, &pool->chunks) {
> + chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
> +
> + end_bit = (chunk->end_addr - chunk->start_addr) >> order;
> + end_bit -= nbits + 1;
> +
> + spin_lock_irqsave(&chunk->lock, flags);
> + bit = -1;
> + while (bit + 1 < end_bit) {
> + bit = find_next_zero_bit(chunk->bits, end_bit, bit + 1);
> + if (bit >= end_bit)
> + break;
> +
> + start_bit = bit;
> + if (nbits > 1) {
> + bit = find_next_bit(chunk->bits, bit + nbits,
> + bit + 1);
> + if (bit - start_bit < nbits)
> + continue;
> + }
> +
> + addr = chunk->start_addr +
> + ((unsigned long)start_bit << order);
> + while (nbits--)
> + __set_bit(start_bit++, &chunk->bits);
> + spin_unlock_irqrestore(&chunk->lock, flags);
> + read_unlock(&pool->lock);
> + return addr;
> + }
> + spin_unlock_irqrestore(&chunk->lock, flags);
> + }
> + read_unlock(&pool->lock);
> + return 0;
> +}
> +EXPORT_SYMBOL(gen_pool_alloc);
> +
> +/**
> + * gen_pool_free - free allocated special memory back to the pool
> + * @pool: pool to free to
> + * @addr: starting address of memory to free back to pool
> + * @size: size in bytes of memory to free
> + *
> + * Free previously allocated special memory back to the specified pool.
> + */
> +void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size)
> +{
> + struct list_head *_chunk;
> + struct gen_pool_chunk *chunk;
> + unsigned long flags;
> + int order = pool->min_alloc_order;
> + int bit, nbits;
> +
> + nbits = (size + (1UL << order) - 1) >> order;
> +
> + read_lock(&pool->lock);
> + list_for_each(_chunk, &pool->chunks) {
> + chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
> +
> + if (addr >= chunk->start_addr && addr < chunk->end_addr) {
> + BUG_ON(addr + size > chunk->end_addr);
> + spin_lock_irqsave(&chunk->lock, flags);
> + bit = (addr - chunk->start_addr) >> order;
> + while (nbits--)
> + __clear_bit(bit++, &chunk->bits);
> + spin_unlock_irqrestore(&chunk->lock, flags);
> + break;
> + }
> + }
> + BUG_ON(nbits > 0);
> + read_unlock(&pool->lock);
> +}
> +EXPORT_SYMBOL(gen_pool_free);
> diff --git a/kernel_addons/backport/2.6.9_U4/include/src/kfifo.c b/kernel_addons/backport/2.6.9_U4/include/src/kfifo.c
> new file mode 100644
> index 0000000..5d1d907
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/src/kfifo.c
> @@ -0,0 +1,196 @@
> +/*
> + * A simple kernel FIFO implementation.
> + *
> + * Copyright (C) 2004 Stelian Pop <stelian at popies.net>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +#include <linux/err.h>
> +#include <linux/kfifo.h>
> +
> +/**
> + * kfifo_init - allocates a new FIFO using a preallocated buffer
> + * @buffer: the preallocated buffer to be used.
> + * @size: the size of the internal buffer, this have to be a power of 2.
> + * @gfp_mask: get_free_pages mask, passed to kmalloc()
> + * @lock: the lock to be used to protect the fifo buffer
> + *
> + * Do NOT pass the kfifo to kfifo_free() after use ! Simply free the
> + * struct kfifo with kfree().
> + */
> +struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
> + gfp_t gfp_mask, spinlock_t *lock)
> +{
> + struct kfifo *fifo;
> +
> + /* size must be a power of 2 */
> + BUG_ON(size & (size - 1));
> +
> + fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
> + if (!fifo)
> + return ERR_PTR(-ENOMEM);
> +
> + fifo->buffer = buffer;
> + fifo->size = size;
> + fifo->in = fifo->out = 0;
> + fifo->lock = lock;
> +
> + return fifo;
> +}
> +EXPORT_SYMBOL(kfifo_init);
> +
> +/**
> + * kfifo_alloc - allocates a new FIFO and its internal buffer
> + * @size: the size of the internal buffer to be allocated.
> + * @gfp_mask: get_free_pages mask, passed to kmalloc()
> + * @lock: the lock to be used to protect the fifo buffer
> + *
> + * The size will be rounded-up to a power of 2.
> + */
> +struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
> +{
> + unsigned char *buffer;
> + struct kfifo *ret;
> +
> + /*
> + * round up to the next power of 2, since our 'let the indices
> + * wrap' tachnique works only in this case.
> + */
> + if (size & (size - 1)) {
> + BUG_ON(size > 0x80000000);
> + size = roundup_pow_of_two(size);
> + }
> +
> + buffer = kmalloc(size, gfp_mask);
> + if (!buffer)
> + return ERR_PTR(-ENOMEM);
> +
> + ret = kfifo_init(buffer, size, gfp_mask, lock);
> +
> + if (IS_ERR(ret))
> + kfree(buffer);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(kfifo_alloc);
> +
> +/**
> + * kfifo_free - frees the FIFO
> + * @fifo: the fifo to be freed.
> + */
> +void kfifo_free(struct kfifo *fifo)
> +{
> + kfree(fifo->buffer);
> + kfree(fifo);
> +}
> +EXPORT_SYMBOL(kfifo_free);
> +
> +/**
> + * __kfifo_put - puts some data into the FIFO, no locking version
> + * @fifo: the fifo to be used.
> + * @buffer: the data to be added.
> + * @len: the length of the data to be added.
> + *
> + * This function copies at most 'len' bytes from the 'buffer' into
> + * the FIFO depending on the free space, and returns the number of
> + * bytes copied.
> + *
> + * Note that with only one concurrent reader and one concurrent
> + * writer, you don't need extra locking to use these functions.
> + */
> +unsigned int __kfifo_put(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len)
> +{
> + unsigned int l;
> +
> + len = min(len, fifo->size - fifo->in + fifo->out);
> +
> + /*
> + * Ensure that we sample the fifo->out index -before- we
> + * start putting bytes into the kfifo.
> + */
> +
> + smp_mb();
> +
> + /* first put the data starting from fifo->in to buffer end */
> + l = min(len, fifo->size - (fifo->in & (fifo->size - 1)));
> + memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l);
> +
> + /* then put the rest (if any) at the beginning of the buffer */
> + memcpy(fifo->buffer, buffer + l, len - l);
> +
> + /*
> + * Ensure that we add the bytes to the kfifo -before-
> + * we update the fifo->in index.
> + */
> +
> + smp_wmb();
> +
> + fifo->in += len;
> +
> + return len;
> +}
> +EXPORT_SYMBOL(__kfifo_put);
> +
> +/**
> + * __kfifo_get - gets some data from the FIFO, no locking version
> + * @fifo: the fifo to be used.
> + * @buffer: where the data must be copied.
> + * @len: the size of the destination buffer.
> + *
> + * This function copies at most 'len' bytes from the FIFO into the
> + * 'buffer' and returns the number of copied bytes.
> + *
> + * Note that with only one concurrent reader and one concurrent
> + * writer, you don't need extra locking to use these functions.
> + */
> +unsigned int __kfifo_get(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len)
> +{
> + unsigned int l;
> +
> + len = min(len, fifo->in - fifo->out);
> +
> + /*
> + * Ensure that we sample the fifo->in index -before- we
> + * start removing bytes from the kfifo.
> + */
> +
> + smp_rmb();
> +
> + /* first get the data from fifo->out until the end of the buffer */
> + l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
> + memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l);
> +
> + /* then get the rest (if any) from the beginning of the buffer */
> + memcpy(buffer + l, fifo->buffer, len - l);
> +
> + /*
> + * Ensure that we remove the bytes from the kfifo -before-
> + * we update the fifo->out index.
> + */
> +
> + smp_mb();
> +
> + fifo->out += len;
> +
> + return len;
> +}
> +EXPORT_SYMBOL(__kfifo_get);
> diff --git a/kernel_addons/backport/2.6.9_U4/include/src/netevent.c b/kernel_addons/backport/2.6.9_U4/include/src/netevent.c
> new file mode 100644
> index 0000000..5ffadd1
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.9_U4/include/src/netevent.c
> @@ -0,0 +1,71 @@
> +/*
> + * Network event notifiers
> + *
> + * Authors:
> + * Tom Tucker <tom at opengridcomputing.com>
> + * Steve Wise <swise at opengridcomputing.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + *
> + * Fixes:
> + */
> +
> +#include <linux/module.h>
> +#include <linux/skbuff.h>
> +#include <linux/rtnetlink.h>
> +#include <linux/notifier.h>
> +
> +static struct notifier_block *netevent_notif_chain;
> +
> +/**
> + * register_netevent_notifier - register a netevent notifier block
> + * @nb: notifier
> + *
> + * Register a notifier to be called when a netevent occurs.
> + * The notifier passed is linked into the kernel structures and must
> + * not be reused until it has been unregistered. A negative errno code
> + * is returned on a failure.
> + */
> +int register_netevent_notifier(struct notifier_block *nb)
> +{
> + int err;
> +
> + err = notifier_chain_register(&netevent_notif_chain, nb);
> + return err;
> +}
> +
> +/**
> + * netevent_unregister_notifier - unregister a netevent notifier block
> + * @nb: notifier
> + *
> + * Unregister a notifier previously registered by
> + * register_neigh_notifier(). The notifier is unlinked into the
> + * kernel structures and may then be reused. A negative errno code
> + * is returned on a failure.
> + */
> +
> +int unregister_netevent_notifier(struct notifier_block *nb)
> +{
> + return notifier_chain_unregister(&netevent_notif_chain, nb);
> +}
> +
> +/**
> + * call_netevent_notifiers - call all netevent notifier blocks
> + * @val: value passed unmodified to notifier function
> + * @v: pointer passed unmodified to notifier function
> + *
> + * Call all neighbour notifier blocks. Parameters and return value
> + * are as for notifier_call_chain().
> + */
> +
> +int call_netevent_notifiers(unsigned long val, void *v)
> +{
> + return notifier_call_chain(&netevent_notif_chain, val, v);
> +}
> +
> +EXPORT_SYMBOL_GPL(register_netevent_notifier);
> +EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
> +EXPORT_SYMBOL_GPL(call_netevent_notifiers);
> diff --git a/kernel_patches/backport/2.6.9_U4/cxgb3_main_to_2_6_13.patch b/kernel_patches/backport/2.6.9_U4/cxgb3_main_to_2_6_13.patch
> new file mode 100644
> index 0000000..e6781f3
> --- /dev/null
> +++ b/kernel_patches/backport/2.6.9_U4/cxgb3_main_to_2_6_13.patch
> @@ -0,0 +1,12 @@
> +diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
> +index dfa035a..414ea84 100755
> +--- a/drivers/net/cxgb3/cxgb3_main.c
> ++++ b/drivers/net/cxgb3/cxgb3_main.c
> +@@ -1526,7 +1526,6 @@ static const struct ethtool_ops cxgb_eth
> + .get_wol = get_wol,
> + .get_tso = ethtool_op_get_tso,
> + .set_tso = ethtool_op_set_tso,
> +- .get_perm_addr = ethtool_op_get_perm_addr
> + };
> +
> + static int in_range(int val, int lo, int hi)
> diff --git a/kernel_patches/backport/2.6.9_U4/cxgb3_makefile_to_2_6_19.patch b/kernel_patches/backport/2.6.9_U4/cxgb3_makefile_to_2_6_19.patch
> new file mode 100644
> index 0000000..ad7e7f4
> --- /dev/null
> +++ b/kernel_patches/backport/2.6.9_U4/cxgb3_makefile_to_2_6_19.patch
> @@ -0,0 +1,12 @@
> +diff --git a/drivers/net/cxgb3/Makefile b/drivers/net/cxgb3/Makefile
> +index 3434679..bb008b6 100755
> +--- a/drivers/net/cxgb3/Makefile
> ++++ b/drivers/net/cxgb3/Makefile
> +@@ -1,6 +1,7 @@
> + #
> + # Chelsio T3 driver
> + #
> ++NOSTDINC_FLAGS:= $(NOSTDINC_FLAGS) $(LINUXINCLUDE)
> +
> + obj-$(CONFIG_CHELSIO_T3) += cxgb3.o
> +
> diff --git a/kernel_patches/backport/2.6.9_U4/iwch_cm_to_2_6_9_U4.patch b/kernel_patches/backport/2.6.9_U4/iwch_cm_to_2_6_9_U4.patch
> new file mode 100644
> index 0000000..f8f51d6
> --- /dev/null
> +++ b/kernel_patches/backport/2.6.9_U4/iwch_cm_to_2_6_9_U4.patch
> @@ -0,0 +1,13 @@
> +diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
> +index 3237fc8..2a38953 100644
> +--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
> ++++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
> +@@ -338,7 +338,7 @@ static struct rtable *find_route(struct
> + }
> + };
> +
> +- if (ip_route_output_flow(&rt, &fl, NULL, 0))
> ++ if (ip_route_output_key(&rt, &fl))
> + return NULL;
> + return rt;
> + }
> diff --git a/kernel_patches/backport/2.6.9_U4/linux_stuff_to_2_6_17.patch b/kernel_patches/backport/2.6.9_U4/linux_stuff_to_2_6_17.patch
> new file mode 100644
> index 0000000..e84b964
> --- /dev/null
> +++ b/kernel_patches/backport/2.6.9_U4/linux_stuff_to_2_6_17.patch
> @@ -0,0 +1,31 @@
> +diff --git a/drivers/infiniband/core/genalloc.c b/drivers/infiniband/core/genalloc.c
> +new file mode 100644
> +index 0000000..58cf933
> +--- /dev/null
> ++++ b/drivers/infiniband/core/genalloc.c
> +@@ -0,0 +1 @@
> ++#include "src/genalloc.c"
> +diff --git a/drivers/infiniband/core/netevent.c b/drivers/infiniband/core/netevent.c
> +new file mode 100644
> +index 0000000..58cf933
> +--- /dev/null
> ++++ b/drivers/infiniband/core/netevent.c
> +@@ -0,0 +1 @@
> ++#include "src/netevent.c"
> +diff --git a/drivers/infiniband/core/kfifo.c b/drivers/infiniband/core/kfifo.c
> +new file mode 100644
> +index 0000000..58cf933
> +--- /dev/null
> ++++ b/drivers/infiniband/core/kfifo.c
> +@@ -0,0 +1 @@
> ++#include "src/kfifo.c"
> +diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
> +index 50fb1cd..456bfd0 100644
> +--- a/drivers/infiniband/core/Makefile
> ++++ b/drivers/infiniband/core/Makefile
> +@@ -30,3 +30,5 @@ ib_ucm-y := ucm.o
> +
> + ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_mem.o \
> + uverbs_marshall.o
> ++
> ++ib_core-y += genalloc.o netevent.o kfifo.o
> diff --git a/kernel_patches/backport/2.6.9_U4/mthca_provider_3465_to_2_6_9.patch b/kernel_patches/backport/2.6.9_U4/mthca_provider_3465_to_2_6_9.patch
> deleted file mode 100644
> index a3febff..0000000
> --- a/kernel_patches/backport/2.6.9_U4/mthca_provider_3465_to_2_6_9.patch
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -Index: linux-kernel/drivers/infiniband/hw/mthca/mthca_provider.c
> -===================================================================
> ---- linux-kernel.orig/drivers/infiniband/hw/mthca/mthca_provider.c 2005-11-24 14:01:20.000000000 +0200
> -+++ linux-kernel/drivers/infiniband/hw/mthca/mthca_provider.c 2005-11-24 14:03:14.000000000 +0200
> -@@ -359,8 +359,8 @@ static int mthca_mmap_uar(struct ib_ucon
> -
> - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> -
> -- if (io_remap_pfn_range(vma, vma->vm_start,
> -- to_mucontext(context)->uar.pfn,
> -+ if (remap_page_range(vma, vma->vm_start,
> -+ (to_mucontext(context)->uar.pfn) << PAGE_SHIFT,
> - PAGE_SIZE, vma->vm_page_prot))
> - return -EAGAIN;
> -
> diff --git a/kernel_patches/backport/2.6.9_U4/t3_hw_to_2_6_5-7_244.patch b/kernel_patches/backport/2.6.9_U4/t3_hw_to_2_6_5-7_244.patch
> new file mode 100644
> index 0000000..a667be0
> --- /dev/null
> +++ b/kernel_patches/backport/2.6.9_U4/t3_hw_to_2_6_5-7_244.patch
> @@ -0,0 +1,43 @@
> +diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
> +index 463ca32..b931fd2 100755
> +--- a/drivers/net/cxgb3/adapter.h
> ++++ b/drivers/net/cxgb3/adapter.h
> +@@ -179,6 +179,7 @@ struct adapter {
> + struct list_head adapter_list;
> + void __iomem *regs;
> + struct pci_dev *pdev;
> ++ u32 saved_pci_state[16];
> + unsigned long registered_device_map;
> + unsigned long open_device_map;
> + unsigned long flags;
> +diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
> +index 14ea6b9..f13f581 100755
> +--- a/drivers/net/cxgb3/t3_hw.c
> ++++ b/drivers/net/cxgb3/t3_hw.c
> +@@ -3250,7 +3250,7 @@ int t3_reset_adapter(struct adapter *ada
> + uint16_t devid = 0;
> +
> + if (is_pcie(adapter))
> +- pci_save_state(adapter->pdev);
> ++ pci_save_state(adapter->pdev, adapter->saved_pci_state);
> + t3_write_reg(adapter, A_PL_RST, F_CRSTWRM | F_CRSTWRMMODE);
> +
> + /*
> +@@ -3268,7 +3268,7 @@ int t3_reset_adapter(struct adapter *ada
> + return -1;
> +
> + if (is_pcie(adapter))
> +- pci_restore_state(adapter->pdev);
> ++ pci_restore_state(adapter->pdev, adapter->saved_pci_state);
> + return 0;
> + }
> +
> +@@ -3357,8 +3357,6 @@ int __devinit t3_prep_adapter(struct ada
> +
> + memcpy(adapter->port[i]->dev_addr, hw_addr,
> + ETH_ALEN);
> +- memcpy(adapter->port[i]->perm_addr, hw_addr,
> +- ETH_ALEN);
> + init_link_config(&p->link_config, p->port_type->caps);
> + p->phy.ops->power_down(&p->phy, 1);
> + if (!(p->port_type->caps & SUPPORTED_IRQ))
>
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
>
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
More information about the general
mailing list