]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[HW] replace GPL-protected Linux implementation of lists by Windows one
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 10 Jun 2008 16:09:13 +0000 (16:09 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 10 Jun 2008 16:09:13 +0000 (16:09 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@1257 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/hw/mlx4/kernel/bus/net/catas.c
trunk/hw/mlx4/kernel/bus/net/icm.h
trunk/hw/mlx4/kernel/hca/mr.c
trunk/hw/mlx4/kernel/inc/l2w_list.h
trunk/hw/mthca/kernel/mt_list.h
trunk/hw/mthca/kernel/mt_verbs.c
trunk/hw/mthca/kernel/mthca_memfree.h

index 68e4ef435b7fdbc72482d01704057cc64124df8b..9658bdd9cdefbfde7af8c790dd4d250d5a1eadfd 100644 (file)
@@ -62,7 +62,7 @@ static void catas_reset()
        struct list_head tlist;
        int ret;
 
-       tlist.next = tlist.prev = &tlist;
+       INIT_LIST_HEAD(&tlist);
        spin_lock_irq(&catas_lock);
        list_splice_init(&catas_list, &tlist);
        spin_unlock_irq(&catas_lock);
index dc15df967d4853fae7d2a1dc85c87494e62fa067..008138fbc2512525a43e4e9c888d85f5da76c922 100644 (file)
@@ -90,7 +90,7 @@ static inline void mlx4_icm_first(struct mlx4_icm *icm,
 {
        iter->icm      = icm;
        iter->chunk    = list_empty(&icm->chunk_list) ?
-               NULL : list_entry(icm->chunk_list.next,
+               NULL : list_entry(icm->chunk_list.Flink,
                                  struct mlx4_icm_chunk, list);
        iter->page_idx = 0;
 }
@@ -103,12 +103,12 @@ static inline int mlx4_icm_last(struct mlx4_icm_iter *iter)
 static inline void mlx4_icm_next(struct mlx4_icm_iter *iter)
 {
        if (++iter->page_idx >= iter->chunk->nsg) {
-               if (iter->chunk->list.next == &iter->icm->chunk_list) {
+               if (iter->chunk->list.Flink == &iter->icm->chunk_list) {
                        iter->chunk = NULL;
                        return;
                }
 
-               iter->chunk = list_entry(iter->chunk->list.next,
+               iter->chunk = list_entry(iter->chunk->list.Flink,
                                         struct mlx4_icm_chunk, list);
                iter->page_idx = 0;
        }
index b4ecaa264de1d30df50deb28a2b78bbef36f0180..28afbbe26d55adacebaaf0cd2466cb61f1bcdada 100644 (file)
@@ -457,7 +457,7 @@ mlnx_unmap_fmr (
        if (list_empty(&fmr_list))\r
                goto done;\r
 \r
-       p_ib_fmr = list_entry(fmr_list.next, struct ib_fmr, list);\r
+       p_ib_fmr = list_entry(fmr_list.Flink, struct ib_fmr, list);\r
        err = p_ib_fmr->device->unmap_fmr(&fmr_list);\r
        status = errno_to_iberr(err);\r
 \r
index a9ffcc57ac2a58d44b49f56f8e937f995d3064a3..1779a191204c283a6c2ed93a5666fcd6ad973acc 100644 (file)
+#pragma once
 
-// taken from list.h
+////////////////////////////////////////////////////////
+//
+// TYPES
+//
+////////////////////////////////////////////////////////
 
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1  ((void *) 0x00100100)
-#define LIST_POISON2  ((void *) 0x00200200)
+// Use the type, defined in wdm.h
+#define list_head      _LIST_ENTRY
 
-/*
-* Simple doubly linked list implementation.
-*
-* Some of the internal functions ("__xxx") are useful when
-* manipulating whole lists rather than single entries, as
-* sometimes we already know the next/prev entries and we can
-* generate better code by using them directly rather than
-* using the generic single-entry routines.
-*/
 
-struct list_head {
-        struct list_head *next, *prev;
-};
+////////////////////////////////////////////////////////
+//
+// MACROS
+//
+////////////////////////////////////////////////////////
 
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
 
+// Define and initialize a list header
 #define LIST_HEAD(name) \
-       struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) \
-        (ptr)->next = (ptr); (ptr)->prev = (ptr)
-
-
-/*
-* Insert a new entry between two known consecutive entries.
-*
-* This is only for internal list manipulation where we know
-* the prev/next entries already!
-*/
-static inline void __list_add(struct list_head *new,
-                             struct list_head *prev,
-                             struct list_head *next)
-{
-       next->prev = new;
-       new->next = next;
-       new->prev = prev;
-       prev->next = new;
-}
-
-/**
-* list_add - add a new entry
-* @new: new entry to be added
-* @head: list head to add it after
-*
-* Insert a new entry after the specified head.
-* This is good for implementing stacks.
-*/
-static inline void list_add(struct list_head *new, struct list_head *head)
+       struct list_head name = { &(name), &(name) }
+
+// Initialize a list header
+#define INIT_LIST_HEAD(ptr)            InitializeListHead(ptr)
+
+// Get to the beginning of the struct for this list entry
+#define list_entry(ptr, type, member)  CONTAINING_RECORD(ptr, type, member)
+
+// Iterate over list of 'list_els' of given 'type'
+#define list_for_each_entry(list_el, head, member, type)                       \
+       for ( list_el = list_entry((head)->Flink, type, member);                \
+               &list_el->member != (head);                                                                     \
+               list_el = list_entry(list_el->member.Flink, type, member))
+
+// Iterate backwards over list of 'list_els' of given 'type'
+#define list_for_each_entry_reverse(list_el, head, member, type)       \
+       for (list_el = list_entry((head)->Blink, type, member);                 \
+               &list_el->member != (head);                                                                     \
+               list_el = list_entry(list_el->member.Blink, type, member))
+
+// Iterate over list of given type safe against removal of list entry
+#define list_for_each_entry_safe(list_el, tmp_list_el, head, member,type, tmp_type)    \
+       for (list_el = list_entry((head)->Flink, type, member),                                                 \
+               tmp_list_el = list_entry(list_el->member.Flink, type, member);                          \
+               &list_el->member != (head);                                                                                                     \
+               list_el = tmp_list_el,                                                                                                          \
+               tmp_list_el = list_entry(tmp_list_el->member.Flink, tmp_type, member))
+
+
+////////////////////////////////////////////////////////
+//
+// FUNCTIONS
+//
+////////////////////////////////////////////////////////
+
+// Insert a new entry after the specified head.
+static inline void list_add(struct list_head *new_entry, struct list_head *head)
 {
-       __list_add(new, head, head->next);
+       InsertHeadList( head, new_entry );
 }
 
-/**
-* list_add_tail - add a new entry
-* @new: new entry to be added
-* @head: list head to add it before
-*
-* Insert a new entry before the specified head.
-* This is useful for implementing queues.
-*/
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+// Insert a new entry before the specified head.
+static inline void list_add_tail(struct list_head *new_entry, struct list_head *head)
 {
-       __list_add(new, head->prev, head);
+       InsertTailList( head, new_entry );
 }
 
- /*
-  * Delete a list entry by making the prev/next entries
-  * point to each other.
-  *
-  * This is only for internal list manipulation where we know
-  * the prev/next entries already!
-  */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
-        next->prev = prev;
-        prev->next = next;
-}
-
- /**
-  * list_del - deletes entry from list.
-  * @entry: the element to delete from the list.
-  * Note: list_empty on entry does not return true after this, the entry is
-  * in an undefined state.
-  */
+// Deletes entry from list.
 static inline void list_del(struct list_head *entry)
 {
-        __list_del(entry->prev, entry->next);
-        entry->next = LIST_POISON1;
-        entry->prev = LIST_POISON2;
+       RemoveEntryList( entry );
 }
 
-/**
-* list_empty - tests whether a list is empty
-* @head: the list to test.
-*/
+// Tests whether a list is empty
 static inline int list_empty(const struct list_head *head)
 {
-                        return head->next == head;
+       return IsListEmpty( head );
 }
 
- static inline void __list_splice(struct list_head *list,
- struct list_head *head)
- {
-        struct list_head *first = list->next;
-        struct list_head *last = list->prev;
-        struct list_head *at = head->next;
-        first->prev = head;
-        head->next = first;
-        last->next = at;
-        at->prev = last;
- }
- /**
- * list_splice_init - join two lists and reinitialise the emptied list.
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * The list at @list is reinitialised
- */
- static inline void list_splice_init(struct list_head *list,
- struct list_head *head)
- {
-        if (!list_empty(list)) {
-                __list_splice(list, head);
-                INIT_LIST_HEAD(list);
-        }
- }
-
- /**
- * list_entry - get the struct for this entry
- * @ptr:        the &struct list_head pointer.
- * @type:       the type of the struct this is embedded in.
- * @member:     the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
-        container_of(ptr, type, member)
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry  -       iterate over list of given type
-* @pos:        the type * to use as a loop counter.
-* @head:       the head for your list.
-* @member:     the name of the list_struct within the struct.
-* @type:                       typeof(*pos)
-*/
-#define list_for_each_entry(pos, head, member,type)          \
-        for (pos = list_entry((head)->next, type, member);      \
-             &pos->member != (head);        \
-             pos = list_entry(pos->member.next, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_reverse - iterate backwards over list of given type.
-* @pos:                                the type * to use as a loop counter.
-* @head:                       the head for your list.
-* @member:             the name of the list_struct within the struct.
-* @type:                               typeof(*pos)
-*/
-#define list_for_each_entry_reverse(pos, head, member,type)                                                                    \
-                       for (pos = list_entry((head)->prev, type, member);                      \
-                                        &pos->member != (head);                                \
-                                        pos = list_entry(pos->member.prev, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
-* @pos:                                the type * to use as a loop counter.
-* @n:                                  another type * to use as temporary storage
-* @head:                       the head for your list.
-* @member:             the name of the list_struct within the struct.
-* @type:                               typeof(*pos)
-* @type_n:                     typeof(*n)
-*/
-#define list_for_each_entry_safe(pos, n, head, member,type,type_n)                                                                     \
-                               for (pos = list_entry((head)->next, type, member),                      \
-                                                       n = list_entry(pos->member.next, type, member); \
-                                                &pos->member != (head);                                                                                                                                                \
-                                                pos = n, n = list_entry(n->member.next, type_n, member))
+// Insert src_list into dst_list and reinitialise the emptied src_list.
+static inline void list_splice_init(struct list_head *src_list,
+       struct list_head *dst_list)
+{
+       if (!list_empty(src_list)) {
+               struct list_head *first = src_list->Flink;
+               struct list_head *last = src_list->Blink;
+               struct list_head *at = dst_list->Flink;
+
+               first->Blink = dst_list;
+               dst_list->Flink = first;
+               
+               last->Flink = at;
+               at->Blink = last;
+
+               INIT_LIST_HEAD(src_list);
+       }
+}
 
index 9fa96d8b99a58596489f745d59b0360f1eb339c3..092057eee8afbf4ea7d977a566e42d72497f749d 100644 (file)
 #ifndef MT_LIST_H
 #define MT_LIST_H
 
-// taken from list.h
+/* Use the type, defined in wdm.h */
+#define list_head      _LIST_ENTRY
 
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1  ((void *) 0x00100100)
-#define LIST_POISON2  ((void *) 0x00200200)
+/* Define and initialize a list header */
+#define LIST_HEAD(name) \
+       struct list_head name = { &(name), &(name) }
 
-/*
-* Simple doubly linked list implementation.
-*
-* Some of the internal functions ("__xxx") are useful when
-* manipulating whole lists rather than single entries, as
-* sometimes we already know the next/prev entries and we can
-* generate better code by using them directly rather than
-* using the generic single-entry routines.
-*/
+/* Initialize a list header */
+#define INIT_LIST_HEAD(ptr)            InitializeListHead(ptr)
 
-struct list_head {
-        struct list_head *next, *prev;
-};
+/* Get to the beginning of the struct for this list entry */
+#define list_entry(ptr, type, member)  CONTAINING_RECORD(ptr, type, member)
 
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
+/* Iterate over list of 'list_els' of given 'type' */
+#define list_for_each_entry(list_el, head, member, type)                       \
+       for ( list_el = list_entry((head)->Flink, type, member);                \
+               &list_el->member != (head);                                                                     \
+               list_el = list_entry(list_el->member.Flink, type, member))
 
-#define LIST_HEAD(name) \
-       struct list_head name = LIST_HEAD_INIT(name)
+/* Iterate backwards over list of 'list_els' of given 'type' */
+#define list_for_each_entry_reverse(list_el, head, member, type)       \
+       for (list_el = list_entry((head)->Blink, type, member);                 \
+               &list_el->member != (head);                                                                     \
+               list_el = list_entry(list_el->member.Blink, type, member))
 
-#define INIT_LIST_HEAD(ptr) \
-        (ptr)->next = (ptr); (ptr)->prev = (ptr)
+/* Iterate over list of given type safe against removal of list entry */
+#define list_for_each_entry_safe(list_el, tmp_list_el, head, member,type, tmp_type)    \
+       for (list_el = list_entry((head)->Flink, type, member),                                                 \
+               tmp_list_el = list_entry(list_el->member.Flink, type, member);                          \
+               &list_el->member != (head);                                                                                                     \
+               list_el = tmp_list_el,                                                                                                          \
+               tmp_list_el = list_entry(tmp_list_el->member.Flink, tmp_type, member))
 
 
-/*
-* Insert a new entry between two known consecutive entries.
-*
-* This is only for internal list manipulation where we know
-* the prev/next entries already!
-*/
-static inline void __list_add(struct list_head *new,
-                             struct list_head *prev,
-                             struct list_head *next)
+/* Insert a new entry after the specified head. */
+static inline void list_add(struct list_head *new_entry, struct list_head *head)
 {
-       next->prev = new;
-       new->next = next;
-       new->prev = prev;
-       prev->next = new;
+       InsertHeadList( head, new_entry );
 }
 
-/**
-* list_add - add a new entry
-* @new: new entry to be added
-* @head: list head to add it after
-*
-* Insert a new entry after the specified head.
-* This is good for implementing stacks.
-*/
-static inline void list_add(struct list_head *new, struct list_head *head)
+/* Insert a new entry before the specified head. */
+static inline void list_add_tail(struct list_head *new_entry, struct list_head *head)
 {
-       __list_add(new, head, head->next);
+       InsertTailList( head, new_entry );
 }
 
-/**
-* list_add_tail - add a new entry
-* @new: new entry to be added
-* @head: list head to add it before
-*
-* Insert a new entry before the specified head.
-* This is useful for implementing queues.
-*/
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+/* Deletes entry from list. */
+static inline void list_del(struct list_head *entry)
 {
-       __list_add(new, head->prev, head);
+       RemoveEntryList( entry );
 }
 
- /*
-  * Delete a list entry by making the prev/next entries
-  * point to each other.
-  *
-  * This is only for internal list manipulation where we know
-  * the prev/next entries already!
-  */
- static inline void __list_del(struct list_head * prev, struct list_head * next)
- {
-         next->prev = prev;
-         prev->next = next;
- }
- /**
-  * list_del - deletes entry from list.
-  * @entry: the element to delete from the list.
-  * Note: list_empty on entry does not return true after this, the entry is
-  * in an undefined state.
-  */
- static inline void list_del(struct list_head *entry)
- {
-         __list_del(entry->prev, entry->next);
-         entry->next = LIST_POISON1;
-         entry->prev = LIST_POISON2;
- }
-
-/**
-* list_empty - tests whether a list is empty
-* @head: the list to test.
-*/
+/* Tests whether a list is empty */
 static inline int list_empty(const struct list_head *head)
 {
-                        return head->next == head;
+       return IsListEmpty( head );
 }
 
- /**
- * list_entry - get the struct for this entry
- * @ptr:        the &struct list_head pointer.
- * @type:       the type of the struct this is embedded in.
- * @member:     the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
-        container_of(ptr, type, member)
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry  -       iterate over list of given type
-* @pos:        the type * to use as a loop counter.
-* @head:       the head for your list.
-* @member:     the name of the list_struct within the struct.
-* @type:                       typeof(*pos)
-*/
-#define list_for_each_entry(pos, head, member,type)          \
-        for (pos = list_entry((head)->next, type, member);      \
-             &pos->member != (head);        \
-             pos = list_entry(pos->member.next, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_reverse - iterate backwards over list of given type.
-* @pos:                                the type * to use as a loop counter.
-* @head:                       the head for your list.
-* @member:             the name of the list_struct within the struct.
-* @type:                               typeof(*pos)
-*/
-#define list_for_each_entry_reverse(pos, head, member,type)                                                                    \
-                       for (pos = list_entry((head)->prev, type, member);                      \
-                                        &pos->member != (head);                                \
-                                        pos = list_entry(pos->member.prev, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
-* @pos:                                the type * to use as a loop counter.
-* @n:                                  another type * to use as temporary storage
-* @head:                       the head for your list.
-* @member:             the name of the list_struct within the struct.
-* @type:                               typeof(*pos)
-* @type_n:                     typeof(*n)
-*/
-#define list_for_each_entry_safe(pos, n, head, member,type,type_n)                                                                     \
-                               for (pos = list_entry((head)->next, type, member),                      \
-                                                       n = list_entry(pos->member.next, type, member); \
-                                                &pos->member != (head);                                                                                                                                                \
-                                                pos = n, n = list_entry(n->member.next, type_n, member))
-
 
 #endif
index 3caa2fe91b4cb50001df1c8c860014be5bd9e2ba..43c6cfa8fff56b52fd672da531ec1b5a855b877f 100644 (file)
@@ -891,7 +891,7 @@ int ibv_unmap_fmr(struct list_head *fmr_list)
        if (list_empty(fmr_list))
                return 0;
 
-       fmr = list_entry(fmr_list->next, struct ib_fmr, list);
+       fmr = list_entry(fmr_list->Flink, struct ib_fmr, list);
        return fmr->device->unmap_fmr(fmr_list);
 }
 
index 184a35771b95e05271489a6e413ac0879af7f092..97367ce73b5da8d1b040b40be253e921d8e751c3 100644 (file)
@@ -96,7 +96,7 @@ static inline void mthca_icm_first(struct mthca_icm *icm,
 {
        iter->icm      = icm;
        iter->chunk    = list_empty(&icm->chunk_list) ?
-               NULL : list_entry(icm->chunk_list.next,
+               NULL : list_entry(icm->chunk_list.Flink,
                                  struct mthca_icm_chunk, list);
        iter->page_idx = 0;
 }
@@ -109,12 +109,12 @@ static inline int mthca_icm_last(struct mthca_icm_iter *iter)
 static inline void mthca_icm_next(struct mthca_icm_iter *iter)
 {
        if (++iter->page_idx >= iter->chunk->nsg) {
-               if (iter->chunk->list.next == &iter->icm->chunk_list) {
+               if (iter->chunk->list.Flink == &iter->icm->chunk_list) {
                        iter->chunk = NULL;
                        return;
                }
 
-               iter->chunk = list_entry(iter->chunk->list.next,
+               iter->chunk = list_entry(iter->chunk->list.Flink,
                                         struct mthca_icm_chunk, list);
                iter->page_idx = 0;
        }