Whamcloud - gitweb
LU-3963 libcfs: convert LNET layer to linux list api 69/9369/9
authorJames Simmons <uja.ornl@gmail.com>
Thu, 24 Apr 2014 16:43:58 +0000 (12:43 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 7 May 2014 02:11:05 +0000 (02:11 +0000)
This patch converts all cfs_list primitives to the linux api
for the LNET layer.

Change-Id: Id790b87d253db759edb921f4828f04b11bbe6fe9
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Reviewed-on: http://review.whamcloud.com/9369
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Amir Shehata <amir.shehata@intel.com>
40 files changed:
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/include/lnet/lnetst.h
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_lib-linux.c
lnet/klnds/socklnd/socklnd_lib-winnt.c
lnet/klnds/socklnd/socklnd_proto.c
lnet/lnet/api-ni.c
lnet/lnet/config.c
lnet/lnet/lib-eq.c
lnet/lnet/lib-md.c
lnet/lnet/lib-me.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/lib-ptl.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/lnet/router_proc.c
lnet/selftest/brw_test.c
lnet/selftest/conrpc.c
lnet/selftest/conrpc.h
lnet/selftest/console.c
lnet/selftest/console.h
lnet/selftest/framework.c
lnet/selftest/rpc.c
lnet/selftest/selftest.h
lnet/selftest/timer.c
lnet/selftest/timer.h
lnet/ulnds/socklnd/conn.c
lnet/ulnds/socklnd/handlers.c
lnet/ulnds/socklnd/poll.c
lnet/ulnds/socklnd/usocklnd.c
lnet/ulnds/socklnd/usocklnd.h
lnet/ulnds/socklnd/usocklnd_cb.c
lnet/utils/lst.c

index f7d9ae0..13aa91b 100644 (file)
@@ -264,24 +264,24 @@ void lnet_freelist_fini(lnet_freelist_t *fl);
 static inline void *
 lnet_freelist_alloc (lnet_freelist_t *fl)
 {
-        /* ALWAYS called with liblock held */
-        lnet_freeobj_t *o;
+       /* ALWAYS called with liblock held */
+       lnet_freeobj_t *o;
 
-        if (cfs_list_empty (&fl->fl_list))
-                return (NULL);
+       if (list_empty(&fl->fl_list))
+               return NULL;
 
-        o = cfs_list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
-        cfs_list_del (&o->fo_list);
-        return ((void *)&o->fo_contents);
+       o = list_entry(fl->fl_list.next, lnet_freeobj_t, fo_list);
+       list_del(&o->fo_list);
+       return (void *)&o->fo_contents;
 }
 
 static inline void
 lnet_freelist_free (lnet_freelist_t *fl, void *obj)
 {
-        /* ALWAYS called with liblock held */
-        lnet_freeobj_t *o = cfs_list_entry (obj, lnet_freeobj_t, fo_contents);
+       /* ALWAYS called with liblock held */
+       lnet_freeobj_t *o = list_entry(obj, lnet_freeobj_t, fo_contents);
 
-        cfs_list_add (&o->fo_list, &fl->fl_list);
+       list_add(&o->fo_list, &fl->fl_list);
 }
 
 
@@ -333,7 +333,7 @@ lnet_md_alloc (lnet_md_t *umd)
        lnet_res_unlock(0);
 
        if (md != NULL)
-               CFS_INIT_LIST_HEAD(&md->md_list);
+               INIT_LIST_HEAD(&md->md_list);
 
        return md;
 }
@@ -467,14 +467,14 @@ lnet_md_alloc (lnet_md_t *umd)
 
         LIBCFS_ALLOC(md, size);
 
-        if (md != NULL) {
-                /* Set here in case of early free */
-                md->md_options = umd->options;
-                md->md_niov = niov;
-                CFS_INIT_LIST_HEAD(&md->md_list);
-        }
+       if (md != NULL) {
+               /* Set here in case of early free */
+               md->md_options = umd->options;
+               md->md_niov = niov;
+               INIT_LIST_HEAD(&md->md_list);
+       }
 
-        return (md);
+       return md;
 }
 
 static inline void
@@ -544,7 +544,7 @@ lnet_res_lh_invalidate(lnet_libhandle_t *lh)
 {
        /* ALWAYS called with resource lock held */
        /* NB: cookie is still useful, don't reset it */
-       cfs_list_del(&lh->lh_hash_chain);
+       list_del(&lh->lh_hash_chain);
 }
 
 static inline void
@@ -700,7 +700,7 @@ lnet_nid2peerhash(lnet_nid_t nid)
        return hash_long(nid, LNET_PEER_HASH_BITS);
 }
 
-static inline cfs_list_t *
+static inline struct list_head *
 lnet_net2rnethash(__u32 net)
 {
        return &the_lnet.ln_remote_nets_hash[(LNET_NETNUM(net) +
@@ -801,7 +801,7 @@ lnet_ptl_unsetopt(lnet_portal_t *ptl, int opt)
 }
 
 /* match-table functions */
-cfs_list_t *lnet_mt_match_head(struct lnet_match_table *mtable,
+struct list_head *lnet_mt_match_head(struct lnet_match_table *mtable,
                               lnet_process_id_t id, __u64 mbits);
 struct lnet_match_table *lnet_mt_of_attach(unsigned int index,
                                           lnet_process_id_t id, __u64 mbits,
@@ -812,7 +812,7 @@ int lnet_mt_match_md(struct lnet_match_table *mtable,
 
 /* portals match/attach functions */
 void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
-                       cfs_list_t *matches, cfs_list_t *drops);
+                       struct list_head *matches, struct list_head *drops);
 void lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md);
 int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg);
 
@@ -828,8 +828,8 @@ void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
 lnet_msg_t *lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *get_msg);
 void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
 void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
-void lnet_drop_delayed_msg_list(cfs_list_t *head, char *reason);
-void lnet_recv_delayed_msg_list(cfs_list_t *head);
+void lnet_drop_delayed_msg_list(struct list_head *head, char *reason);
+void lnet_recv_delayed_msg_list(struct list_head *head);
 
 int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt);
 void lnet_msg_container_cleanup(struct lnet_msg_container *container);
@@ -952,9 +952,9 @@ void lnet_ping_target_fini(void);
 int lnet_ping(lnet_process_id_t id, int timeout_ms,
               lnet_process_id_t *ids, int n_ids);
 
-int lnet_parse_ip2nets (char **networksp, char *ip2nets);
-int lnet_parse_routes (char *route_str, int *im_a_router);
-int lnet_parse_networks (cfs_list_t *nilist, char *networks);
+int lnet_parse_ip2nets(char **networksp, char *ip2nets);
+int lnet_parse_routes(char *route_str, int *im_a_router);
+int lnet_parse_networks(struct list_head *nilist, char *networks);
 
 int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt);
 lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable,
index 30b1f85..b9b9f45 100644 (file)
@@ -183,10 +183,10 @@ typedef struct {
 struct lnet_libmd;
 
 typedef struct lnet_msg {
-        cfs_list_t            msg_activelist;
-        cfs_list_t            msg_list;           /* Q for credits/MD */
+       struct list_head        msg_activelist;
+       struct list_head        msg_list;       /* Q for credits/MD */
 
-        lnet_process_id_t     msg_target;
+       lnet_process_id_t       msg_target;
        /* where is it from, it's only for building event */
        lnet_nid_t              msg_from;
        __u32                   msg_type;
@@ -237,15 +237,15 @@ typedef struct lnet_msg {
 
 
 typedef struct lnet_libhandle {
-        cfs_list_t            lh_hash_chain;
-        __u64                 lh_cookie;
+       struct list_head        lh_hash_chain;
+       __u64                   lh_cookie;
 } lnet_libhandle_t;
 
 #define lh_entry(ptr, type, member) \
         ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
 
 typedef struct lnet_eq {
-       cfs_list_t              eq_list;
+       struct list_head        eq_list;
        lnet_libhandle_t        eq_lh;
        lnet_seq_t              eq_enq_seq;
        lnet_seq_t              eq_deq_seq;
@@ -256,36 +256,36 @@ typedef struct lnet_eq {
 } lnet_eq_t;
 
 typedef struct lnet_me {
-        cfs_list_t             me_list;
-        lnet_libhandle_t       me_lh;
-        lnet_process_id_t      me_match_id;
-        unsigned int           me_portal;
-       unsigned int           me_pos;          /* hash offset in mt_hash */
-        __u64                  me_match_bits;
-        __u64                  me_ignore_bits;
-        lnet_unlink_t          me_unlink;
-        struct lnet_libmd     *me_md;
+       struct list_head        me_list;
+       lnet_libhandle_t        me_lh;
+       lnet_process_id_t       me_match_id;
+       unsigned int            me_portal;
+       unsigned int            me_pos;         /* hash offset in mt_hash */
+       __u64                   me_match_bits;
+       __u64                   me_ignore_bits;
+       lnet_unlink_t           me_unlink;
+       struct lnet_libmd      *me_md;
 } lnet_me_t;
 
 typedef struct lnet_libmd {
-        cfs_list_t            md_list;
-        lnet_libhandle_t      md_lh;
-        lnet_me_t            *md_me;
-        char                 *md_start;
-        unsigned int          md_offset;
-        unsigned int          md_length;
-        unsigned int          md_max_size;
-        int                   md_threshold;
-        int                   md_refcount;
-        unsigned int          md_options;
-        unsigned int          md_flags;
-        void                 *md_user_ptr;
-        lnet_eq_t            *md_eq;
-        unsigned int          md_niov;                /* # frags */
-        union {
-                struct iovec  iov[LNET_MAX_IOV];
-                lnet_kiov_t   kiov[LNET_MAX_IOV];
-        } md_iov;
+       struct list_head        md_list;
+       lnet_libhandle_t        md_lh;
+       lnet_me_t              *md_me;
+       char                   *md_start;
+       unsigned int            md_offset;
+       unsigned int            md_length;
+       unsigned int            md_max_size;
+       int                     md_threshold;
+       int                     md_refcount;
+       unsigned int            md_options;
+       unsigned int            md_flags;
+       void                   *md_user_ptr;
+       lnet_eq_t              *md_eq;
+       unsigned int            md_niov;        /* # frags */
+       union {
+               struct iovec    iov[LNET_MAX_IOV];
+               lnet_kiov_t     kiov[LNET_MAX_IOV];
+       } md_iov;
 } lnet_libmd_t;
 
 #define LNET_MD_FLAG_ZOMBIE     (1 << 0)
@@ -295,24 +295,28 @@ typedef struct lnet_libmd {
 #ifdef LNET_USE_LIB_FREELIST
 typedef struct
 {
-        void                  *fl_objs;          /* single contiguous array of objects */
-        int                    fl_nobjs;         /* the number of them */
-        int                    fl_objsize;       /* the size (including overhead) of each of them */
-        cfs_list_t             fl_list;          /* where they are enqueued */
+       /* single contiguous array of objects */
+       void                   *fl_objs;
+       /* the number of them */
+       int                     fl_nobjs;
+       /* the size (including overhead) of each of them */
+       int                     fl_objsize;
+       /* where they are enqueued */
+       struct list_head        fl_list;
 } lnet_freelist_t;
 
 typedef struct
 {
-        cfs_list_t             fo_list;             /* enqueue on fl_list */
-        void                  *fo_contents;         /* aligned contents */
+       struct list_head        fo_list;        /* enqueue on fl_list */
+       void                   *fo_contents;    /* aligned contents */
 } lnet_freeobj_t;
 #endif
 
 typedef struct {
-        /* info about peers we are trying to fail */
-        cfs_list_t             tp_list;             /* ln_test_peers */
-        lnet_nid_t             tp_nid;              /* matching nid */
-        unsigned int           tp_threshold;        /* # failures to simulate */
+       /* info about peers we are trying to fail */
+       struct list_head        tp_list;        /* ln_test_peers */
+       lnet_nid_t              tp_nid;         /* matching nid */
+       unsigned int            tp_threshold;   /* # failures to simulate */
 } lnet_test_peer_t;
 
 #define LNET_COOKIE_TYPE_MD    1
@@ -325,9 +329,9 @@ struct lnet_ni;                                  /* forward ref */
 
 typedef struct lnet_lnd
 {
-        /* fields managed by portals */
-        cfs_list_t            lnd_list;             /* stash in the LND table */
-        int                   lnd_refcount;         /* # active instances */
+       /* fields managed by portals */
+       struct list_head        lnd_list;       /* stash in the LND table */
+       int                     lnd_refcount;   /* # active instances */
 
         /* fields initialised by the LND */
         unsigned int          lnd_type;
@@ -406,7 +410,7 @@ struct lnet_tx_queue {
        int                     tq_credits;     /* # tx credits free */
        int                     tq_credits_min; /* lowest it's been */
        int                     tq_credits_max; /* total # tx credits */
-       cfs_list_t              tq_delayed;     /* delayed TXs */
+       struct list_head        tq_delayed;     /* delayed TXs */
 };
 
 #define LNET_MAX_INTERFACES   16
@@ -421,8 +425,8 @@ typedef struct lnet_ni {
        pthread_mutex_t         ni_lock;
 # endif
 #endif
-       cfs_list_t              ni_list;        /* chain on ln_nis */
-       cfs_list_t              ni_cptlist;     /* chain on ln_nis_cpt */
+       struct list_head        ni_list;        /* chain on ln_nis */
+       struct list_head        ni_cptlist;     /* chain on ln_nis_cpt */
        int                     ni_maxtxcredits; /* # tx credits  */
        /* # per-peer send credits */
        int                     ni_peertxcredits;
@@ -467,42 +471,63 @@ typedef struct {
 #define LNET_PINGINFO_SIZE offsetof(lnet_ping_info_t, pi_ni[LNET_MAX_RTR_NIS])
 typedef struct {
        /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */
-       cfs_list_t              rcd_list;
+       struct list_head        rcd_list;
        lnet_handle_md_t        rcd_mdh;        /* ping buffer MD */
        struct lnet_peer        *rcd_gateway;   /* reference to gateway */
        lnet_ping_info_t        *rcd_pinginfo;  /* ping buffer */
 } lnet_rc_data_t;
 
 typedef struct lnet_peer {
-        cfs_list_t        lp_hashlist;          /* chain on peer hash */
-        cfs_list_t        lp_txq;               /* messages blocking for tx credits */
-        cfs_list_t        lp_rtrq;              /* messages blocking for router credits */
-        cfs_list_t        lp_rtr_list;          /* chain on router list */
-        int               lp_txcredits;         /* # tx credits available */
-        int               lp_mintxcredits;      /* low water mark */
-        int               lp_rtrcredits;        /* # router credits */
-        int               lp_minrtrcredits;     /* low water mark */
-        unsigned int      lp_alive:1;           /* alive/dead? */
-        unsigned int      lp_notify:1;          /* notification outstanding? */
-        unsigned int      lp_notifylnd:1;       /* outstanding notification for LND? */
-        unsigned int      lp_notifying:1;       /* some thread is handling notification */
-        unsigned int      lp_ping_notsent;      /* SEND event outstanding from ping */
-        int               lp_alive_count;       /* # times router went dead<->alive */
-        long              lp_txqnob;            /* bytes queued for sending */
-        cfs_time_t        lp_timestamp;         /* time of last aliveness news */
-        cfs_time_t        lp_ping_timestamp;    /* time of last ping attempt */
-        cfs_time_t        lp_ping_deadline;     /* != 0 if ping reply expected */
-        cfs_time_t        lp_last_alive;        /* when I was last alive */
-        cfs_time_t        lp_last_query;        /* when lp_ni was queried last time */
-        lnet_ni_t        *lp_ni;                /* interface peer is on */
-        lnet_nid_t        lp_nid;               /* peer's NID */
-        int               lp_refcount;          /* # refs */
+       /* chain on peer hash */
+       struct list_head        lp_hashlist;
+       /* messages blocking for tx credits */
+       struct list_head        lp_txq;
+       /* messages blocking for router credits */
+       struct list_head        lp_rtrq;
+       /* chain on router list */
+       struct list_head        lp_rtr_list;
+       /* # tx credits available */
+       int                     lp_txcredits;
+       /* low water mark */
+       int                     lp_mintxcredits;
+       /* # router credits */
+       int                     lp_rtrcredits;
+       /* low water mark */
+       int                     lp_minrtrcredits;
+       /* alive/dead? */
+       unsigned int            lp_alive:1;
+       /* notification outstanding? */
+       unsigned int            lp_notify:1;
+       /* outstanding notification for LND? */
+       unsigned int            lp_notifylnd:1;
+       /* some thread is handling notification */
+       unsigned int            lp_notifying:1;
+       /* SEND event outstanding from ping */
+       unsigned int            lp_ping_notsent;
+       /* # times router went dead<->alive */
+       int                     lp_alive_count;
+       /* bytes queued for sending */
+       long                    lp_txqnob;
+       /* time of last aliveness news */
+       cfs_time_t              lp_timestamp;
+       /* time of last ping attempt */
+       cfs_time_t              lp_ping_timestamp;
+       /* != 0 if ping reply expected */
+       cfs_time_t              lp_ping_deadline;
+       /* when I was last alive */
+       cfs_time_t              lp_last_alive;
+       /* when lp_ni was queried last time */
+       cfs_time_t              lp_last_query;
+       /* interface peer is on */
+       lnet_ni_t               *lp_ni;
+       lnet_nid_t              lp_nid;         /* peer's NID */
+       int                     lp_refcount;    /* # refs */
        int                     lp_cpt;         /* CPT this peer attached on */
        /* # refs from lnet_route_t::lr_gateway */
        int                     lp_rtr_refcount;
        /* returned RC ping features */
        unsigned int            lp_ping_feats;
-       cfs_list_t              lp_routes;      /* routers on this peer */
+       struct list_head        lp_routes;      /* routers on this peer */
        lnet_rc_data_t          *lp_rcd;        /* router checker state */
 } lnet_peer_t;
 
@@ -514,8 +539,8 @@ typedef struct lnet_peer {
 struct lnet_peer_table {
        int                     pt_version;     /* /proc validity stamp */
        int                     pt_number;      /* # peers extant */
-       cfs_list_t              pt_deathrow;    /* zombie peers */
-       cfs_list_t              *pt_hash;       /* NID->peer hash */
+       struct list_head        pt_deathrow;    /* zombie peers */
+       struct list_head        *pt_hash;       /* NID->peer hash */
 };
 
 /* peer aliveness is enabled only on routers for peers in a network where the
@@ -524,8 +549,8 @@ struct lnet_peer_table {
                                         (lp)->lp_ni->ni_peertimeout > 0)
 
 typedef struct {
-       cfs_list_t              lr_list;        /* chain on net */
-       cfs_list_t              lr_gwlist;      /* chain on gateway */
+       struct list_head        lr_list;        /* chain on net */
+       struct list_head        lr_gwlist;      /* chain on gateway */
        lnet_peer_t             *lr_gateway;    /* router node */
        __u32                   lr_net;         /* remote network number */
        int                     lr_seq;         /* sequence for round-robin */
@@ -539,24 +564,33 @@ typedef struct {
 #define LNET_REMOTE_NETS_HASH_SIZE     (1 << the_lnet.ln_remote_nets_hbits)
 
 typedef struct {
-        cfs_list_t              lrn_list;       /* chain on ln_remote_nets_hash */
-        cfs_list_t              lrn_routes;     /* routes to me */
-        __u32                   lrn_net;        /* my net number */
+       /* chain on ln_remote_nets_hash */
+       struct list_head        lrn_list;
+       /* routes to me */
+       struct list_head        lrn_routes;
+       /* my net number */
+       __u32                   lrn_net;
 } lnet_remotenet_t;
 
 typedef struct {
-        cfs_list_t rbp_bufs;             /* my free buffer pool */
-        cfs_list_t rbp_msgs;             /* messages blocking for a buffer */
-        int        rbp_npages;           /* # pages in each buffer */
-        int        rbp_nbuffers;         /* # buffers */
-        int        rbp_credits;          /* # free buffers / blocked messages */
-        int        rbp_mincredits;       /* low water mark */
+       /* my free buffer pool */
+       struct list_head        rbp_bufs;
+       /* messages blocking for a buffer */
+       struct list_head        rbp_msgs;
+       /* # pages in each buffer */
+       int                     rbp_npages;
+       /* # buffers */
+       int                     rbp_nbuffers;
+       /* # free buffers / blocked messages */
+       int                     rbp_credits;
+       /* low water mark */
+       int                     rbp_mincredits;
 } lnet_rtrbufpool_t;
 
 typedef struct {
-        cfs_list_t             rb_list;             /* chain on rbp_bufs */
-        lnet_rtrbufpool_t     *rb_pool;             /* owning pool */
-        lnet_kiov_t            rb_kiov[0];          /* the buffer space */
+       struct list_head         rb_list;       /* chain on rbp_bufs */
+       lnet_rtrbufpool_t       *rb_pool;       /* owning pool */
+       lnet_kiov_t              rb_kiov[0];    /* the buffer space */
 } lnet_rtrbuf_t;
 
 typedef struct {
@@ -629,7 +663,7 @@ struct lnet_match_table {
        unsigned int            mt_enabled;
        /* bitmap to flag whether MEs on mt_hash are exhausted or not */
        __u64                   mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
-       cfs_list_t              *mt_mhash;      /* matching hash */
+       struct list_head        *mt_mhash;      /* matching hash */
 };
 
 /* these are only useful for wildcard portal */
@@ -656,9 +690,9 @@ typedef struct lnet_portal {
        /* flags on this portal: lazy, unique... */
        unsigned int            ptl_options;
        /* list of messags which are stealing buffer */
-       cfs_list_t              ptl_msg_stealing;
+       struct list_head        ptl_msg_stealing;
        /* messages blocking for MD */
-       cfs_list_t              ptl_msg_delayed;
+       struct list_head        ptl_msg_delayed;
        /* Match table for each CPT */
        struct lnet_match_table **ptl_mtables;
        /* spread rotor of incoming "PUT" */
@@ -677,8 +711,8 @@ typedef struct lnet_portal {
 struct lnet_res_container {
        unsigned int            rec_type;       /* container type */
        __u64                   rec_lh_cookie;  /* cookie generator */
-       cfs_list_t              rec_active;     /* active resource list */
-       cfs_list_t              *rec_lh_hash;   /* handle hash */
+       struct list_head        rec_active;     /* active resource list */
+       struct list_head        *rec_lh_hash;   /* handle hash */
 #ifdef LNET_USE_LIB_FREELIST
        lnet_freelist_t         rec_freelist;   /* freelist for resources */
 #endif
@@ -690,8 +724,8 @@ struct lnet_msg_container {
        /* max # threads finalizing */
        int                     msc_nfinalizers;
        /* msgs waiting to complete finalizing */
-       cfs_list_t              msc_finalizing;
-       cfs_list_t              msc_active;     /* active message list */
+       struct list_head        msc_finalizing;
+       struct list_head        msc_active;     /* active message list */
        /* threads doing finalization */
        void                    **msc_finalizers;
 #ifdef LNET_USE_LIB_FREELIST
@@ -726,7 +760,7 @@ typedef struct
        /* Event Queue container */
        struct lnet_res_container       ln_eq_container;
 #ifdef __KERNEL__
-       wait_queue_head_t                       ln_eq_waitq;
+       wait_queue_head_t               ln_eq_waitq;
        spinlock_t                      ln_eq_wait_lock;
 #else
 # ifndef HAVE_LIBPTHREAD
@@ -745,23 +779,23 @@ typedef struct
        lnet_counters_t                 **ln_counters;
        struct lnet_peer_table          **ln_peer_tables;
        /* failure simulation */
-       cfs_list_t                      ln_test_peers;
+       struct list_head                ln_test_peers;
 
-       cfs_list_t                      ln_nis;         /* LND instances */
+       struct list_head                ln_nis;         /* LND instances */
        /* NIs bond on specific CPT(s) */
-       cfs_list_t                      ln_nis_cpt;
+       struct list_head                ln_nis_cpt;
        /* dying LND instances */
-       cfs_list_t                      ln_nis_zombie;
+       struct list_head                ln_nis_zombie;
        lnet_ni_t                       *ln_loni;       /* the loopback NI */
        /* NI to wait for events in */
        lnet_ni_t                       *ln_eq_waitni;
 
        /* remote networks with routes to them */
-       cfs_list_t                      *ln_remote_nets_hash;
+       struct list_head                *ln_remote_nets_hash;
        /* validity stamp */
        __u64                           ln_remote_nets_version;
        /* list of all known routers */
-       cfs_list_t                      ln_routers;
+       struct list_head                ln_routers;
        /* validity stamp */
        __u64                           ln_routers_version;
        /* percpt router buffer pools */
@@ -776,9 +810,9 @@ typedef struct
        /* router checker's event queue */
        lnet_handle_eq_t                ln_rc_eqh;
        /* rcd still pending on net */
-       cfs_list_t                      ln_rcd_deathrow;
+       struct list_head                ln_rcd_deathrow;
        /* rcd ready for free */
-       cfs_list_t                      ln_rcd_zombie;
+       struct list_head                ln_rcd_zombie;
 #ifdef __KERNEL__
        /* serialise startup/shutdown */
        struct semaphore                ln_rc_signal;
@@ -807,7 +841,7 @@ typedef struct
        /* uniquely identifies this ni in this epoch */
        __u64                           ln_interface_cookie;
        /* registered LNDs */
-       cfs_list_t                      ln_lnds;
+       struct list_head                ln_lnds;
 
        /* space for network names */
        char                            *ln_network_tokens;
index 0e54a2b..6e43427 100644 (file)
@@ -126,11 +126,11 @@ typedef struct {
                                                          *** for list_batch command */
 
 typedef struct {
-        cfs_list_t              rpe_link;               /* link chain */
-        lnet_process_id_t       rpe_peer;               /* peer's id */
-        struct timeval          rpe_stamp;              /* time stamp of RPC */
-        int                     rpe_state;              /* peer's state */
-        int                     rpe_rpc_errno;          /* RPC errno */
+       struct list_head        rpe_link;               /* link chain */
+       lnet_process_id_t       rpe_peer;               /* peer's id */
+       struct timeval          rpe_stamp;              /* time stamp of RPC */
+       int                     rpe_state;              /* peer's state */
+       int                     rpe_rpc_errno;          /* RPC errno */
 
         lst_sid_t               rpe_sid;                /* peer's session id */
         int                     rpe_fwk_errno;          /* framework errno */
@@ -280,7 +280,8 @@ typedef struct {
         char                   *lstio_dbg_namep;        /* IN: name of group|batch */
         int                     lstio_dbg_count;        /* IN: # of test nodes to debug */
         lnet_process_id_t      *lstio_dbg_idsp;         /* IN: id of test nodes */
-        cfs_list_t             *lstio_dbg_resultp;      /* OUT: list head of result buffer */
+       /* OUT: list head of result buffer */
+       struct list_head       *lstio_dbg_resultp;
 } lstio_debug_args_t;
 
 typedef struct {
@@ -300,25 +301,27 @@ typedef struct {
 #define LST_GROUP_RMND          3                       /* delete nodes from the group */
 
 typedef struct {
-        int                     lstio_grp_key;          /* IN: session key */
-        int                     lstio_grp_opc;          /* IN: OPC */
-        int                     lstio_grp_args;         /* IN: arguments */
-        int                     lstio_grp_nmlen;        /* IN: name length */
-        char                   *lstio_grp_namep;        /* IN: group name */
-        int                     lstio_grp_count;        /* IN: # of nodes id */
-        lnet_process_id_t      *lstio_grp_idsp;         /* IN: array of nodes */
-        cfs_list_t             *lstio_grp_resultp;      /* OUT: list head of result buffer */
+       int                     lstio_grp_key;          /* IN: session key */
+       int                     lstio_grp_opc;          /* IN: OPC */
+       int                     lstio_grp_args;         /* IN: arguments */
+       int                     lstio_grp_nmlen;        /* IN: name length */
+       char                    *lstio_grp_namep;       /* IN: group name */
+       int                     lstio_grp_count;        /* IN: # of nodes id */
+       lnet_process_id_t       *lstio_grp_idsp;        /* IN: array of nodes */
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_grp_resultp;
 } lstio_group_update_args_t;
 
 typedef struct {
-        int                     lstio_grp_key;          /* IN: session key */
-        int                     lstio_grp_nmlen;        /* IN: name length */
-        char                   *lstio_grp_namep;        /* IN: group name */
-        int                     lstio_grp_count;        /* IN: # of nodes */
+       int                      lstio_grp_key;         /* IN: session key */
+       int                      lstio_grp_nmlen;       /* IN: name length */
+       char                    *lstio_grp_namep;       /* IN: group name */
+       int                      lstio_grp_count;       /* IN: # of nodes */
        /** OUT: session features */
-       unsigned               *lstio_grp_featp;
-        lnet_process_id_t      *lstio_grp_idsp;         /* IN: nodes */
-        cfs_list_t             *lstio_grp_resultp;      /* OUT: list head of result buffer */
+       unsigned                *lstio_grp_featp;
+       lnet_process_id_t       *lstio_grp_idsp;        /* IN: nodes */
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_grp_resultp;
 } lstio_group_nodes_args_t;
 
 typedef struct {
@@ -354,29 +357,46 @@ typedef struct {
 } lstio_batch_del_args_t;
 
 typedef struct {
-        int                     lstio_bat_key;          /* IN: session key */
-        int                     lstio_bat_timeout;      /* IN: timeout for the batch */
-        int                     lstio_bat_nmlen;        /* IN: name length */
-        char                   *lstio_bat_namep;        /* IN: batch name */
-        cfs_list_t             *lstio_bat_resultp;      /* OUT: list head of result buffer */
+       /* IN: session key */
+       int                      lstio_bat_key;
+       /* IN: timeout for the batch */
+       int                      lstio_bat_timeout;
+       /* IN: name length */
+       int                      lstio_bat_nmlen;
+       /* IN: batch name */
+       char                    *lstio_bat_namep;
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_bat_resultp;
 } lstio_batch_run_args_t;
 
 typedef struct {
-        int                     lstio_bat_key;          /* IN: session key */
-        int                     lstio_bat_force;        /* IN: abort unfinished test RPC */
-        int                     lstio_bat_nmlen;        /* IN: name length */
-        char                   *lstio_bat_namep;        /* IN: batch name */
-        cfs_list_t             *lstio_bat_resultp;      /* OUT: list head of result buffer */
+       /* IN: session key */
+       int                      lstio_bat_key;
+       /* IN: abort unfinished test RPC */
+       int                      lstio_bat_force;
+       /* IN: name length */
+       int                      lstio_bat_nmlen;
+       /* IN: batch name */
+       char                    *lstio_bat_namep;
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_bat_resultp;
 } lstio_batch_stop_args_t;
 
 typedef struct {
-        int                     lstio_bat_key;          /* IN: session key */
-        int                     lstio_bat_testidx;      /* IN: test index */
-        int                     lstio_bat_client;       /* IN: is test client? */
-        int                     lstio_bat_timeout;      /* IN: timeout for waiting */
-        int                     lstio_bat_nmlen;        /* IN: name length */
-        char                   *lstio_bat_namep;        /* IN: batch name */
-        cfs_list_t             *lstio_bat_resultp;      /* OUT: list head of result buffer */
+       /* IN: session key */
+       int                     lstio_bat_key;
+       /* IN: test index */
+       int                     lstio_bat_testidx;
+       /* IN: is test client? */
+       int                     lstio_bat_client;
+       /* IN: timeout for waiting */
+       int                     lstio_bat_timeout;
+       /* IN: name length */
+       int                     lstio_bat_nmlen;
+       /* IN: batch name */
+       char                    *lstio_bat_namep;
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_bat_resultp;
 } lstio_batch_query_args_t;
 
 typedef struct {
@@ -401,13 +421,20 @@ typedef struct {
 
 /* add stat in session */
 typedef struct {
-        int                     lstio_sta_key;          /* IN: session key */
-        int                     lstio_sta_timeout;      /* IN: timeout for stat requst */
-        int                     lstio_sta_nmlen;        /* IN: group name length */
-        char                   *lstio_sta_namep;        /* IN: group name */
-        int                     lstio_sta_count;        /* IN: # of pid */
-        lnet_process_id_t      *lstio_sta_idsp;         /* IN: pid */
-        cfs_list_t             *lstio_sta_resultp;      /* OUT: list head of result buffer */
+       /* IN: session key */
+       int                     lstio_sta_key;
+       /* IN: timeout for stat requst */
+       int                     lstio_sta_timeout;
+       /* IN: group name length */
+       int                     lstio_sta_nmlen;
+       /* IN: group name */
+       char                    *lstio_sta_namep;
+       /* IN: # of pid */
+       int                     lstio_sta_count;
+       /* IN: pid */
+       lnet_process_id_t       *lstio_sta_idsp;
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_sta_resultp;
 } lstio_stat_args_t;
 
 typedef enum {
@@ -434,13 +461,17 @@ typedef struct {
         int                     lstio_tes_dgrp_nmlen;   /* IN: destination group name length */
         char                   *lstio_tes_dgrp_name;    /* IN: group name */
 
-        int                     lstio_tes_param_len;    /* IN: param buffer len */
-        void                   *lstio_tes_param;        /* IN: parameter for specified test:
-                                                               lstio_bulk_param_t,
-                                                               lstio_ping_param_t,
-                                                               ... more */
-        int                    *lstio_tes_retp;         /* OUT: private returned value */
-        cfs_list_t             *lstio_tes_resultp;      /* OUT: list head of result buffer */
+       /* IN: param buffer len */
+       int                      lstio_tes_param_len;
+       /* IN: parameter for specified test:
+              lstio_bulk_param_t,
+              lstio_ping_param_t,
+              ... more */
+       void                    *lstio_tes_param;
+       /* OUT: private returned value */
+       int                     *lstio_tes_retp;
+       /* OUT: list head of result buffer */
+       struct list_head        *lstio_tes_resultp;
 } lstio_test_args_t;
 
 typedef enum {
index 7a5944f..c0b4408 100644 (file)
@@ -340,90 +340,90 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
                 return -ENOMEM;
         }
 
-        memset(peer, 0, sizeof(*peer));         /* zero flags etc */
+       memset(peer, 0, sizeof(*peer));         /* zero flags etc */
 
-        peer->ibp_ni = ni;
-        peer->ibp_nid = nid;
-        peer->ibp_error = 0;
-        peer->ibp_last_alive = 0;
-       atomic_set(&peer->ibp_refcount, 1);  /* 1 ref for caller */
+       peer->ibp_ni = ni;
+       peer->ibp_nid = nid;
+       peer->ibp_error = 0;
+       peer->ibp_last_alive = 0;
+       atomic_set(&peer->ibp_refcount, 1);     /* 1 ref for caller */
 
-        CFS_INIT_LIST_HEAD(&peer->ibp_list);     /* not in the peer table yet */
-        CFS_INIT_LIST_HEAD(&peer->ibp_conns);
-        CFS_INIT_LIST_HEAD(&peer->ibp_tx_queue);
+       INIT_LIST_HEAD(&peer->ibp_list);        /* not in the peer table yet */
+       INIT_LIST_HEAD(&peer->ibp_conns);
+       INIT_LIST_HEAD(&peer->ibp_tx_queue);
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        /* always called with a ref on ni, which prevents ni being shutdown */
-        LASSERT (net->ibn_shutdown == 0);
+       /* always called with a ref on ni, which prevents ni being shutdown */
+       LASSERT(net->ibn_shutdown == 0);
 
-        /* npeers only grows with the global lock held */
+       /* npeers only grows with the global lock held */
        atomic_inc(&net->ibn_npeers);
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        *peerp = peer;
-        return 0;
+       *peerp = peer;
+       return 0;
 }
 
 void
 kiblnd_destroy_peer (kib_peer_t *peer)
 {
-        kib_net_t *net = peer->ibp_ni->ni_data;
+       kib_net_t *net = peer->ibp_ni->ni_data;
 
-        LASSERT (net != NULL);
+       LASSERT(net != NULL);
        LASSERT (atomic_read(&peer->ibp_refcount) == 0);
-        LASSERT (!kiblnd_peer_active(peer));
-        LASSERT (peer->ibp_connecting == 0);
-        LASSERT (peer->ibp_accepting == 0);
-        LASSERT (cfs_list_empty(&peer->ibp_conns));
-        LASSERT (cfs_list_empty(&peer->ibp_tx_queue));
-
-        LIBCFS_FREE(peer, sizeof(*peer));
-
-        /* NB a peer's connections keep a reference on their peer until
-         * they are destroyed, so we can be assured that _all_ state to do
-         * with this peer has been cleaned up when its refcount drops to
-         * zero. */
+       LASSERT(!kiblnd_peer_active(peer));
+       LASSERT(peer->ibp_connecting == 0);
+       LASSERT(peer->ibp_accepting == 0);
+       LASSERT(list_empty(&peer->ibp_conns));
+       LASSERT(list_empty(&peer->ibp_tx_queue));
+
+       LIBCFS_FREE(peer, sizeof(*peer));
+
+       /* NB a peer's connections keep a reference on their peer until
+        * they are destroyed, so we can be assured that _all_ state to do
+        * with this peer has been cleaned up when its refcount drops to
+        * zero. */
        atomic_dec(&net->ibn_npeers);
 }
 
 kib_peer_t *
 kiblnd_find_peer_locked (lnet_nid_t nid)
 {
-        /* the caller is responsible for accounting the additional reference
-         * that this creates */
-        cfs_list_t       *peer_list = kiblnd_nid2peerlist(nid);
-        cfs_list_t       *tmp;
-        kib_peer_t       *peer;
+       /* the caller is responsible for accounting the additional reference
+        * that this creates */
+       struct list_head        *peer_list = kiblnd_nid2peerlist(nid);
+       struct list_head        *tmp;
+       kib_peer_t              *peer;
 
-        cfs_list_for_each (tmp, peer_list) {
+       list_for_each(tmp, peer_list) {
 
-                peer = cfs_list_entry(tmp, kib_peer_t, ibp_list);
+               peer = list_entry(tmp, kib_peer_t, ibp_list);
 
-                LASSERT (peer->ibp_connecting > 0 || /* creating conns */
-                         peer->ibp_accepting > 0 ||
-                         !cfs_list_empty(&peer->ibp_conns));  /* active conn */
+               LASSERT(peer->ibp_connecting > 0 ||     /* creating conns */
+                       peer->ibp_accepting > 0 ||
+                       !list_empty(&peer->ibp_conns)); /* active conn */
 
-                if (peer->ibp_nid != nid)
-                        continue;
+               if (peer->ibp_nid != nid)
+                       continue;
 
-                CDEBUG(D_NET, "got peer [%p] -> %s (%d) version: %x\n",
-                       peer, libcfs_nid2str(nid),
+               CDEBUG(D_NET, "got peer [%p] -> %s (%d) version: %x\n",
+                      peer, libcfs_nid2str(nid),
                       atomic_read(&peer->ibp_refcount),
-                       peer->ibp_version);
-                return peer;
-        }
-        return NULL;
+                      peer->ibp_version);
+               return peer;
+       }
+       return NULL;
 }
 
 void
 kiblnd_unlink_peer_locked (kib_peer_t *peer)
 {
-        LASSERT (cfs_list_empty(&peer->ibp_conns));
+       LASSERT(list_empty(&peer->ibp_conns));
 
         LASSERT (kiblnd_peer_active(peer));
-        cfs_list_del_init(&peer->ibp_list);
+       list_del_init(&peer->ibp_list);
         /* lose peerlist's ref */
         kiblnd_peer_decref(peer);
 }
@@ -432,29 +432,29 @@ int
 kiblnd_get_peer_info (lnet_ni_t *ni, int index, 
                       lnet_nid_t *nidp, int *count)
 {
-        kib_peer_t            *peer;
-        cfs_list_t            *ptmp;
-        int                    i;
-        unsigned long          flags;
+       kib_peer_t              *peer;
+       struct list_head        *ptmp;
+       int                      i;
+       unsigned long            flags;
 
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
         for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
 
-                cfs_list_for_each (ptmp, &kiblnd_data.kib_peers[i]) {
+               list_for_each(ptmp, &kiblnd_data.kib_peers[i]) {
 
-                        peer = cfs_list_entry(ptmp, kib_peer_t, ibp_list);
-                        LASSERT (peer->ibp_connecting > 0 ||
-                                 peer->ibp_accepting > 0 ||
-                                 !cfs_list_empty(&peer->ibp_conns));
+                       peer = list_entry(ptmp, kib_peer_t, ibp_list);
+                       LASSERT(peer->ibp_connecting > 0 ||
+                               peer->ibp_accepting > 0 ||
+                               !list_empty(&peer->ibp_conns));
 
-                        if (peer->ibp_ni != ni)
-                                continue;
+                       if (peer->ibp_ni != ni)
+                               continue;
 
-                        if (index-- > 0)
-                                continue;
+                       if (index-- > 0)
+                               continue;
 
-                        *nidp = peer->ibp_nid;
+                       *nidp = peer->ibp_nid;
                        *count = atomic_read(&peer->ibp_refcount);
 
                        read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
@@ -464,42 +464,42 @@ kiblnd_get_peer_info (lnet_ni_t *ni, int index,
        }
 
        read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
-        return -ENOENT;
+       return -ENOENT;
 }
 
 void
 kiblnd_del_peer_locked (kib_peer_t *peer)
 {
-        cfs_list_t           *ctmp;
-        cfs_list_t           *cnxt;
-        kib_conn_t           *conn;
+       struct list_head        *ctmp;
+       struct list_head        *cnxt;
+       kib_conn_t              *conn;
 
-        if (cfs_list_empty(&peer->ibp_conns)) {
-                kiblnd_unlink_peer_locked(peer);
-        } else {
-                cfs_list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
-                        conn = cfs_list_entry(ctmp, kib_conn_t, ibc_list);
+       if (list_empty(&peer->ibp_conns)) {
+               kiblnd_unlink_peer_locked(peer);
+       } else {
+               list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
+                       conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                        kiblnd_close_conn_locked(conn, 0);
-                }
-                /* NB closing peer's last conn unlinked it. */
-        }
-        /* NB peer now unlinked; might even be freed if the peer table had the
-         * last ref on it. */
+                       kiblnd_close_conn_locked(conn, 0);
+               }
+               /* NB closing peer's last conn unlinked it. */
+       }
+       /* NB peer now unlinked; might even be freed if the peer table had the
+        * last ref on it. */
 }
 
 int
 kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
 {
-        CFS_LIST_HEAD         (zombies);
-        cfs_list_t            *ptmp;
-        cfs_list_t            *pnxt;
-        kib_peer_t            *peer;
-        int                    lo;
-        int                    hi;
-        int                    i;
-        unsigned long          flags;
-        int                    rc = -ENOENT;
+       struct list_head        zombies = LIST_HEAD_INIT(zombies);
+       struct list_head        *ptmp;
+       struct list_head        *pnxt;
+       kib_peer_t              *peer;
+       int                     lo;
+       int                     hi;
+       int                     i;
+       unsigned long           flags;
+       int                     rc = -ENOENT;
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
@@ -510,68 +510,67 @@ kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
                 hi = kiblnd_data.kib_peer_hash_size - 1;
         }
 
-        for (i = lo; i <= hi; i++) {
-                cfs_list_for_each_safe (ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
-                        peer = cfs_list_entry(ptmp, kib_peer_t, ibp_list);
-                        LASSERT (peer->ibp_connecting > 0 ||
-                                 peer->ibp_accepting > 0 ||
-                                 !cfs_list_empty(&peer->ibp_conns));
+       for (i = lo; i <= hi; i++) {
+               list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
+                       peer = list_entry(ptmp, kib_peer_t, ibp_list);
+                       LASSERT(peer->ibp_connecting > 0 ||
+                               peer->ibp_accepting > 0 ||
+                               !list_empty(&peer->ibp_conns));
 
-                        if (peer->ibp_ni != ni)
-                                continue;
+                       if (peer->ibp_ni != ni)
+                               continue;
 
-                        if (!(nid == LNET_NID_ANY || peer->ibp_nid == nid))
-                                continue;
+                       if (!(nid == LNET_NID_ANY || peer->ibp_nid == nid))
+                               continue;
 
-                        if (!cfs_list_empty(&peer->ibp_tx_queue)) {
-                                LASSERT (cfs_list_empty(&peer->ibp_conns));
+                       if (!list_empty(&peer->ibp_tx_queue)) {
+                               LASSERT(list_empty(&peer->ibp_conns));
 
-                                cfs_list_splice_init(&peer->ibp_tx_queue,
-                                                     &zombies);
-                        }
+                               list_splice_init(&peer->ibp_tx_queue,
+                                                &zombies);
+                       }
 
-                        kiblnd_del_peer_locked(peer);
-                        rc = 0;         /* matched something */
-                }
-        }
+                       kiblnd_del_peer_locked(peer);
+                       rc = 0;         /* matched something */
+               }
+       }
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        kiblnd_txlist_done(ni, &zombies, -EIO);
+       kiblnd_txlist_done(ni, &zombies, -EIO);
 
-        return rc;
+       return rc;
 }
 
 kib_conn_t *
-kiblnd_get_conn_by_idx (lnet_ni_t *ni, int index)
+kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
 {
-        kib_peer_t            *peer;
-        cfs_list_t            *ptmp;
-        kib_conn_t            *conn;
-        cfs_list_t            *ctmp;
-        int                    i;
-        unsigned long          flags;
+       kib_peer_t              *peer;
+       struct list_head        *ptmp;
+       kib_conn_t              *conn;
+       struct list_head        *ctmp;
+       int                     i;
+       unsigned long           flags;
 
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
-                cfs_list_for_each (ptmp, &kiblnd_data.kib_peers[i]) {
+       for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
+               list_for_each(ptmp, &kiblnd_data.kib_peers[i]) {
 
-                        peer = cfs_list_entry(ptmp, kib_peer_t, ibp_list);
-                        LASSERT (peer->ibp_connecting > 0 ||
-                                 peer->ibp_accepting > 0 ||
-                                 !cfs_list_empty(&peer->ibp_conns));
+                       peer = list_entry(ptmp, kib_peer_t, ibp_list);
+                       LASSERT(peer->ibp_connecting > 0 ||
+                               peer->ibp_accepting > 0 ||
+                               !list_empty(&peer->ibp_conns));
 
-                        if (peer->ibp_ni != ni)
-                                continue;
+                       if (peer->ibp_ni != ni)
+                               continue;
 
-                        cfs_list_for_each (ctmp, &peer->ibp_conns) {
-                                if (index-- > 0)
-                                        continue;
+                       list_for_each(ctmp, &peer->ibp_conns) {
+                               if (index-- > 0)
+                                       continue;
 
-                                conn = cfs_list_entry(ctmp, kib_conn_t,
-                                                      ibc_list);
-                                kiblnd_conn_addref(conn);
+                               conn = list_entry(ctmp, kib_conn_t, ibc_list);
+                               kiblnd_conn_addref(conn);
                                read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
                                                       flags);
                                return conn;
@@ -606,47 +605,47 @@ kiblnd_debug_tx (kib_tx_t *tx)
 void
 kiblnd_debug_conn (kib_conn_t *conn)
 {
-       cfs_list_t      *tmp;
-       int             i;
+       struct list_head        *tmp;
+       int                     i;
 
        spin_lock(&conn->ibc_lock);
 
-        CDEBUG(D_CONSOLE, "conn[%d] %p [version %x] -> %s: \n",
+       CDEBUG(D_CONSOLE, "conn[%d] %p [version %x] -> %s:\n",
               atomic_read(&conn->ibc_refcount), conn,
-               conn->ibc_version, libcfs_nid2str(conn->ibc_peer->ibp_nid));
-        CDEBUG(D_CONSOLE, "   state %d nposted %d/%d cred %d o_cred %d r_cred %d\n",
-               conn->ibc_state, conn->ibc_noops_posted,
-               conn->ibc_nsends_posted, conn->ibc_credits,
-               conn->ibc_outstanding_credits, conn->ibc_reserved_credits);
-        CDEBUG(D_CONSOLE, "   comms_err %d\n", conn->ibc_comms_error);
+              conn->ibc_version, libcfs_nid2str(conn->ibc_peer->ibp_nid));
+       CDEBUG(D_CONSOLE, "   state %d nposted %d/%d cred %d o_cred %d "
+              " r_cred %d\n", conn->ibc_state, conn->ibc_noops_posted,
+              conn->ibc_nsends_posted, conn->ibc_credits,
+              conn->ibc_outstanding_credits, conn->ibc_reserved_credits);
+       CDEBUG(D_CONSOLE, "   comms_err %d\n", conn->ibc_comms_error);
 
-        CDEBUG(D_CONSOLE, "   early_rxs:\n");
-        cfs_list_for_each(tmp, &conn->ibc_early_rxs)
-                kiblnd_debug_rx(cfs_list_entry(tmp, kib_rx_t, rx_list));
+       CDEBUG(D_CONSOLE, "   early_rxs:\n");
+       list_for_each(tmp, &conn->ibc_early_rxs)
+               kiblnd_debug_rx(list_entry(tmp, kib_rx_t, rx_list));
 
-        CDEBUG(D_CONSOLE, "   tx_noops:\n");
-        cfs_list_for_each(tmp, &conn->ibc_tx_noops)
-                kiblnd_debug_tx(cfs_list_entry(tmp, kib_tx_t, tx_list));
+       CDEBUG(D_CONSOLE, "   tx_noops:\n");
+       list_for_each(tmp, &conn->ibc_tx_noops)
+               kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
-        CDEBUG(D_CONSOLE, "   tx_queue_nocred:\n");
-        cfs_list_for_each(tmp, &conn->ibc_tx_queue_nocred)
-                kiblnd_debug_tx(cfs_list_entry(tmp, kib_tx_t, tx_list));
+       CDEBUG(D_CONSOLE, "   tx_queue_nocred:\n");
+       list_for_each(tmp, &conn->ibc_tx_queue_nocred)
+               kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
-        CDEBUG(D_CONSOLE, "   tx_queue_rsrvd:\n");
-        cfs_list_for_each(tmp, &conn->ibc_tx_queue_rsrvd)
-                kiblnd_debug_tx(cfs_list_entry(tmp, kib_tx_t, tx_list));
+       CDEBUG(D_CONSOLE, "   tx_queue_rsrvd:\n");
+       list_for_each(tmp, &conn->ibc_tx_queue_rsrvd)
+               kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
-        CDEBUG(D_CONSOLE, "   tx_queue:\n");
-        cfs_list_for_each(tmp, &conn->ibc_tx_queue)
-                kiblnd_debug_tx(cfs_list_entry(tmp, kib_tx_t, tx_list));
+       CDEBUG(D_CONSOLE, "   tx_queue:\n");
+       list_for_each(tmp, &conn->ibc_tx_queue)
+               kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
-        CDEBUG(D_CONSOLE, "   active_txs:\n");
-        cfs_list_for_each(tmp, &conn->ibc_active_txs)
-                kiblnd_debug_tx(cfs_list_entry(tmp, kib_tx_t, tx_list));
+       CDEBUG(D_CONSOLE, "   active_txs:\n");
+       list_for_each(tmp, &conn->ibc_active_txs)
+               kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
-        CDEBUG(D_CONSOLE, "   rxs:\n");
-        for (i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++)
-                kiblnd_debug_rx(&conn->ibc_rxs[i]);
+       CDEBUG(D_CONSOLE, "   rxs:\n");
+       for (i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++)
+               kiblnd_debug_rx(&conn->ibc_rxs[i]);
 
        spin_unlock(&conn->ibc_lock);
 }
@@ -718,17 +717,17 @@ kib_conn_t *
 kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
                    int state, int version)
 {
-        /* CAVEAT EMPTOR:
-         * If the new conn is created successfully it takes over the caller's
-         * ref on 'peer'.  It also "owns" 'cmid' and destroys it when it itself
-         * is destroyed.  On failure, the caller's ref on 'peer' remains and
-         * she must dispose of 'cmid'.  (Actually I'd block forever if I tried
-         * to destroy 'cmid' here since I'm called from the CM which still has
-         * its ref on 'cmid'). */
-       rwlock_t                *glock = &kiblnd_data.kib_global_lock;
-        kib_net_t              *net = peer->ibp_ni->ni_data;
+       /* CAVEAT EMPTOR:
+        * If the new conn is created successfully it takes over the caller's
+        * ref on 'peer'.  It also "owns" 'cmid' and destroys it when it itself
+        * is destroyed.  On failure, the caller's ref on 'peer' remains and
+        * she must dispose of 'cmid'.  (Actually I'd block forever if I tried
+        * to destroy 'cmid' here since I'm called from the CM which still has
+        * its ref on 'cmid'). */
+       rwlock_t               *glock = &kiblnd_data.kib_global_lock;
+       kib_net_t              *net = peer->ibp_ni->ni_data;
        kib_dev_t              *dev;
-        struct ib_qp_init_attr *init_qp_attr;
+       struct ib_qp_init_attr *init_qp_attr;
        struct kib_sched_info   *sched;
        kib_conn_t              *conn;
        struct ib_cq            *cq;
@@ -756,24 +755,24 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
        }
 
        LIBCFS_CPT_ALLOC(conn, lnet_cpt_table(), cpt, sizeof(*conn));
-        if (conn == NULL) {
-                CERROR("Can't allocate connection for %s\n",
-                       libcfs_nid2str(peer->ibp_nid));
-                goto failed_1;
-        }
-
-        conn->ibc_state = IBLND_CONN_INIT;
-        conn->ibc_version = version;
-        conn->ibc_peer = peer;                  /* I take the caller's ref */
-        cmid->context = conn;                   /* for future CM callbacks */
-        conn->ibc_cmid = cmid;
-
-        CFS_INIT_LIST_HEAD(&conn->ibc_early_rxs);
-        CFS_INIT_LIST_HEAD(&conn->ibc_tx_noops);
-        CFS_INIT_LIST_HEAD(&conn->ibc_tx_queue);
-        CFS_INIT_LIST_HEAD(&conn->ibc_tx_queue_rsrvd);
-        CFS_INIT_LIST_HEAD(&conn->ibc_tx_queue_nocred);
-        CFS_INIT_LIST_HEAD(&conn->ibc_active_txs);
+       if (conn == NULL) {
+               CERROR("Can't allocate connection for %s\n",
+                      libcfs_nid2str(peer->ibp_nid));
+               goto failed_1;
+       }
+
+       conn->ibc_state = IBLND_CONN_INIT;
+       conn->ibc_version = version;
+       conn->ibc_peer = peer;                  /* I take the caller's ref */
+       cmid->context = conn;                   /* for future CM callbacks */
+       conn->ibc_cmid = cmid;
+
+       INIT_LIST_HEAD(&conn->ibc_early_rxs);
+       INIT_LIST_HEAD(&conn->ibc_tx_noops);
+       INIT_LIST_HEAD(&conn->ibc_tx_queue);
+       INIT_LIST_HEAD(&conn->ibc_tx_queue_rsrvd);
+       INIT_LIST_HEAD(&conn->ibc_tx_queue_nocred);
+       INIT_LIST_HEAD(&conn->ibc_active_txs);
        spin_lock_init(&conn->ibc_lock);
 
        LIBCFS_CPT_ALLOC(conn->ibc_connvars, lnet_cpt_table(), cpt,
@@ -793,7 +792,7 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
        if (dev->ibd_hdev->ibh_ibdev != cmid->device) {
                /* wakeup failover thread and teardown connection */
                if (kiblnd_dev_can_failover(dev)) {
-                       cfs_list_add_tail(&dev->ibd_fail_list,
+                       list_add_tail(&dev->ibd_fail_list,
                                      &kiblnd_data.kib_failed_devs);
                        wake_up(&kiblnd_data.kib_failover_waitq);
                }
@@ -932,12 +931,12 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 
        LASSERT (!in_interrupt());
        LASSERT (atomic_read(&conn->ibc_refcount) == 0);
-       LASSERT (cfs_list_empty(&conn->ibc_early_rxs));
-       LASSERT (cfs_list_empty(&conn->ibc_tx_noops));
-       LASSERT (cfs_list_empty(&conn->ibc_tx_queue));
-       LASSERT (cfs_list_empty(&conn->ibc_tx_queue_rsrvd));
-       LASSERT (cfs_list_empty(&conn->ibc_tx_queue_nocred));
-       LASSERT (cfs_list_empty(&conn->ibc_active_txs));
+       LASSERT(list_empty(&conn->ibc_early_rxs));
+       LASSERT(list_empty(&conn->ibc_tx_noops));
+       LASSERT(list_empty(&conn->ibc_tx_queue));
+       LASSERT(list_empty(&conn->ibc_tx_queue_rsrvd));
+       LASSERT(list_empty(&conn->ibc_tx_queue_nocred));
+       LASSERT(list_empty(&conn->ibc_active_txs));
        LASSERT (conn->ibc_noops_posted == 0);
        LASSERT (conn->ibc_nsends_posted == 0);
 
@@ -992,103 +991,103 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 }
 
 int
-kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
+kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
 {
-        kib_conn_t             *conn;
-        cfs_list_t             *ctmp;
-        cfs_list_t             *cnxt;
-        int                     count = 0;
+       kib_conn_t              *conn;
+       struct list_head        *ctmp;
+       struct list_head        *cnxt;
+       int                     count = 0;
 
-        cfs_list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
-                conn = cfs_list_entry(ctmp, kib_conn_t, ibc_list);
+       list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
+               conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                CDEBUG(D_NET, "Closing conn -> %s, "
-                              "version: %x, reason: %d\n",
-                       libcfs_nid2str(peer->ibp_nid),
-                       conn->ibc_version, why);
+               CDEBUG(D_NET, "Closing conn -> %s, "
+                             "version: %x, reason: %d\n",
+                      libcfs_nid2str(peer->ibp_nid),
+                      conn->ibc_version, why);
 
-                kiblnd_close_conn_locked(conn, why);
-                count++;
-        }
+               kiblnd_close_conn_locked(conn, why);
+               count++;
+       }
 
-        return count;
+       return count;
 }
 
 int
-kiblnd_close_stale_conns_locked (kib_peer_t *peer,
-                                 int version, __u64 incarnation)
+kiblnd_close_stale_conns_locked(kib_peer_t *peer,
+                               int version, __u64 incarnation)
 {
-        kib_conn_t             *conn;
-        cfs_list_t             *ctmp;
-        cfs_list_t             *cnxt;
-        int                     count = 0;
+       kib_conn_t              *conn;
+       struct list_head        *ctmp;
+       struct list_head        *cnxt;
+       int                     count = 0;
 
-        cfs_list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
-                conn = cfs_list_entry(ctmp, kib_conn_t, ibc_list);
+       list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
+               conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                if (conn->ibc_version     == version &&
-                    conn->ibc_incarnation == incarnation)
-                        continue;
+               if (conn->ibc_version     == version &&
+                   conn->ibc_incarnation == incarnation)
+                       continue;
 
-                CDEBUG(D_NET, "Closing stale conn -> %s version: %x, "
-                              "incarnation:"LPX64"(%x, "LPX64")\n",
-                       libcfs_nid2str(peer->ibp_nid),
-                       conn->ibc_version, conn->ibc_incarnation,
-                       version, incarnation);
+               CDEBUG(D_NET, "Closing stale conn -> %s version: %x, "
+                             "incarnation:"LPX64"(%x, "LPX64")\n",
+                      libcfs_nid2str(peer->ibp_nid),
+                      conn->ibc_version, conn->ibc_incarnation,
+                      version, incarnation);
 
-                kiblnd_close_conn_locked(conn, -ESTALE);
-                count++;
-        }
+               kiblnd_close_conn_locked(conn, -ESTALE);
+               count++;
+       }
 
-        return count;
+       return count;
 }
 
 int
-kiblnd_close_matching_conns (lnet_ni_t *ni, lnet_nid_t nid)
+kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
 {
-        kib_peer_t             *peer;
-        cfs_list_t             *ptmp;
-        cfs_list_t             *pnxt;
-        int                     lo;
-        int                     hi;
-        int                     i;
-        unsigned long           flags;
-        int                     count = 0;
+       kib_peer_t              *peer;
+       struct list_head        *ptmp;
+       struct list_head        *pnxt;
+       int                     lo;
+       int                     hi;
+       int                     i;
+       unsigned long           flags;
+       int                     count = 0;
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        if (nid != LNET_NID_ANY)
-                lo = hi = kiblnd_nid2peerlist(nid) - kiblnd_data.kib_peers;
-        else {
-                lo = 0;
-                hi = kiblnd_data.kib_peer_hash_size - 1;
-        }
+       if (nid != LNET_NID_ANY)
+               lo = hi = kiblnd_nid2peerlist(nid) - kiblnd_data.kib_peers;
+       else {
+               lo = 0;
+               hi = kiblnd_data.kib_peer_hash_size - 1;
+       }
 
-        for (i = lo; i <= hi; i++) {
-                cfs_list_for_each_safe (ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
+       for (i = lo; i <= hi; i++) {
+               list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
 
-                        peer = cfs_list_entry(ptmp, kib_peer_t, ibp_list);
-                        LASSERT (peer->ibp_connecting > 0 ||
-                                 peer->ibp_accepting > 0 ||
-                                 !cfs_list_empty(&peer->ibp_conns));
+                       peer = list_entry(ptmp, kib_peer_t, ibp_list);
+                       LASSERT(peer->ibp_connecting > 0 ||
+                               peer->ibp_accepting > 0 ||
+                               !list_empty(&peer->ibp_conns));
 
-                        if (peer->ibp_ni != ni)
-                                continue;
+                       if (peer->ibp_ni != ni)
+                               continue;
 
-                        if (!(nid == LNET_NID_ANY || nid == peer->ibp_nid))
-                                continue;
+                       if (!(nid == LNET_NID_ANY || nid == peer->ibp_nid))
+                               continue;
 
-                        count += kiblnd_close_peer_conns_locked(peer, 0);
-                }
-        }
+                       count += kiblnd_close_peer_conns_locked(peer, 0);
+               }
+       }
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        /* wildcards always succeed */
-        if (nid == LNET_NID_ANY)
-                return 0;
+       /* wildcards always succeed */
+       if (nid == LNET_NID_ANY)
+               return 0;
 
-        return (count == 0) ? -ENOENT : 0;
+       return (count == 0) ? -ENOENT : 0;
 }
 
 int
@@ -1146,7 +1145,7 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
 }
 
 void
-kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
+kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
 {
        cfs_time_t      last_alive = 0;
        cfs_time_t      now = cfs_time_current();
@@ -1156,28 +1155,28 @@ kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
 
        read_lock_irqsave(glock, flags);
 
-        peer = kiblnd_find_peer_locked(nid);
-        if (peer != NULL) {
-                LASSERT (peer->ibp_connecting > 0 || /* creating conns */
-                         peer->ibp_accepting > 0 ||
-                         !cfs_list_empty(&peer->ibp_conns));  /* active conn */
-                last_alive = peer->ibp_last_alive;
-        }
+       peer = kiblnd_find_peer_locked(nid);
+       if (peer != NULL) {
+               LASSERT(peer->ibp_connecting > 0 || /* creating conns */
+                       peer->ibp_accepting > 0 ||
+                       !list_empty(&peer->ibp_conns));  /* active conn */
+               last_alive = peer->ibp_last_alive;
+       }
 
        read_unlock_irqrestore(glock, flags);
 
-        if (last_alive != 0)
-                *when = last_alive;
+       if (last_alive != 0)
+               *when = last_alive;
 
-        /* peer is not persistent in hash, trigger peer creation
-         * and connection establishment with a NULL tx */
-        if (peer == NULL)
-                kiblnd_launch_tx(ni, NULL, nid);
+       /* peer is not persistent in hash, trigger peer creation
+        * and connection establishment with a NULL tx */
+       if (peer == NULL)
+               kiblnd_launch_tx(ni, NULL, nid);
 
-        CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
-               libcfs_nid2str(nid), peer,
-               last_alive ? cfs_duration_sec(now - last_alive) : -1);
-        return;
+       CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
+              libcfs_nid2str(nid), peer,
+              last_alive ? cfs_duration_sec(now - last_alive) : -1);
+       return;
 }
 
 void
@@ -1363,31 +1362,32 @@ kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
 
         tpo->tpo_hdev = kiblnd_current_hdev(dev);
 
-        for (ipage = page_offset = i = 0; i < pool->po_size; i++) {
-                page = txpgs->ibp_pages[ipage];
-                tx = &tpo->tpo_tx_descs[i];
+       for (ipage = page_offset = i = 0; i < pool->po_size; i++) {
+               page = txpgs->ibp_pages[ipage];
+               tx = &tpo->tpo_tx_descs[i];
 
-                tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) +
-                                           page_offset);
+               tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) +
+                                          page_offset);
 
-                tx->tx_msgaddr = kiblnd_dma_map_single(
-                        tpo->tpo_hdev->ibh_ibdev, tx->tx_msg,
-                        IBLND_MSG_SIZE, DMA_TO_DEVICE);
-                LASSERT (!kiblnd_dma_mapping_error(tpo->tpo_hdev->ibh_ibdev,
-                                                   tx->tx_msgaddr));
-                KIBLND_UNMAP_ADDR_SET(tx, tx_msgunmap, tx->tx_msgaddr);
+               tx->tx_msgaddr = kiblnd_dma_map_single(tpo->tpo_hdev->ibh_ibdev,
+                                                      tx->tx_msg,
+                                                      IBLND_MSG_SIZE,
+                                                      DMA_TO_DEVICE);
+               LASSERT(!kiblnd_dma_mapping_error(tpo->tpo_hdev->ibh_ibdev,
+                                                 tx->tx_msgaddr));
+               KIBLND_UNMAP_ADDR_SET(tx, tx_msgunmap, tx->tx_msgaddr);
 
-                cfs_list_add(&tx->tx_list, &pool->po_free_list);
+               list_add(&tx->tx_list, &pool->po_free_list);
 
-                page_offset += IBLND_MSG_SIZE;
-                LASSERT (page_offset <= PAGE_SIZE);
+               page_offset += IBLND_MSG_SIZE;
+               LASSERT(page_offset <= PAGE_SIZE);
 
-                if (page_offset == PAGE_SIZE) {
-                        page_offset = 0;
-                        ipage++;
-                        LASSERT (ipage <= txpgs->ibp_npages);
-                }
-        }
+               if (page_offset == PAGE_SIZE) {
+                       page_offset = 0;
+                       ipage++;
+                       LASSERT(ipage <= txpgs->ibp_npages);
+               }
+       }
 }
 
 struct ib_mr *
@@ -1458,15 +1458,15 @@ kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
 }
 
 void
-kiblnd_destroy_fmr_pool_list(cfs_list_t *head)
+kiblnd_destroy_fmr_pool_list(struct list_head *head)
 {
-        kib_fmr_pool_t *pool;
+       kib_fmr_pool_t *pool;
 
-        while (!cfs_list_empty(head)) {
-                pool = cfs_list_entry(head->next, kib_fmr_pool_t, fpo_list);
-                cfs_list_del(&pool->fpo_list);
-                kiblnd_destroy_fmr_pool(pool);
-        }
+       while (!list_empty(head)) {
+               pool = list_entry(head->next, kib_fmr_pool_t, fpo_list);
+               list_del(&pool->fpo_list);
+               kiblnd_destroy_fmr_pool(pool);
+       }
 }
 
 static int kiblnd_fmr_pool_size(int ncpts)
@@ -1525,23 +1525,23 @@ kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo)
 }
 
 static void
-kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, cfs_list_t *zombies)
+kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, struct list_head *zombies)
 {
        if (fps->fps_net == NULL) /* intialized? */
                return;
 
        spin_lock(&fps->fps_lock);
 
-        while (!cfs_list_empty(&fps->fps_pool_list)) {
-                kib_fmr_pool_t *fpo = cfs_list_entry(fps->fps_pool_list.next,
+       while (!list_empty(&fps->fps_pool_list)) {
+               kib_fmr_pool_t *fpo = list_entry(fps->fps_pool_list.next,
                                                  kib_fmr_pool_t, fpo_list);
-                fpo->fpo_failed = 1;
-                cfs_list_del(&fpo->fpo_list);
-                if (fpo->fpo_map_count == 0)
-                        cfs_list_add(&fpo->fpo_list, zombies);
-                else
-                        cfs_list_add(&fpo->fpo_list, &fps->fps_failed_pool_list);
-        }
+               fpo->fpo_failed = 1;
+               list_del(&fpo->fpo_list);
+               if (fpo->fpo_map_count == 0)
+                       list_add(&fpo->fpo_list, zombies);
+               else
+                       list_add(&fpo->fpo_list, &fps->fps_failed_pool_list);
+       }
 
        spin_unlock(&fps->fps_lock);
 }
@@ -1559,24 +1559,24 @@ static int
 kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, kib_net_t *net,
                        int pool_size, int flush_trigger)
 {
-        kib_fmr_pool_t *fpo;
-        int             rc;
+       kib_fmr_pool_t *fpo;
+       int             rc;
 
-        memset(fps, 0, sizeof(kib_fmr_poolset_t));
+       memset(fps, 0, sizeof(kib_fmr_poolset_t));
 
-        fps->fps_net = net;
+       fps->fps_net = net;
        fps->fps_cpt = cpt;
        fps->fps_pool_size = pool_size;
        fps->fps_flush_trigger = flush_trigger;
        spin_lock_init(&fps->fps_lock);
-       CFS_INIT_LIST_HEAD(&fps->fps_pool_list);
-       CFS_INIT_LIST_HEAD(&fps->fps_failed_pool_list);
+       INIT_LIST_HEAD(&fps->fps_pool_list);
+       INIT_LIST_HEAD(&fps->fps_failed_pool_list);
 
-        rc = kiblnd_create_fmr_pool(fps, &fpo);
-        if (rc == 0)
-                cfs_list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
+       rc = kiblnd_create_fmr_pool(fps, &fpo);
+       if (rc == 0)
+               list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
 
-        return rc;
+       return rc;
 }
 
 static int
@@ -1592,41 +1592,41 @@ kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, cfs_time_t now)
 void
 kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
 {
-        CFS_LIST_HEAD     (zombies);
-        kib_fmr_pool_t    *fpo = fmr->fmr_pool;
-        kib_fmr_poolset_t *fps = fpo->fpo_owner;
-        cfs_time_t         now = cfs_time_current();
-        kib_fmr_pool_t    *tmp;
-        int                rc;
+       struct list_head   zombies = LIST_HEAD_INIT(zombies);
+       kib_fmr_pool_t    *fpo = fmr->fmr_pool;
+       kib_fmr_poolset_t *fps = fpo->fpo_owner;
+       cfs_time_t         now = cfs_time_current();
+       kib_fmr_pool_t    *tmp;
+       int                rc;
 
-        rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
-        LASSERT (rc == 0);
+       rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
+       LASSERT(rc == 0);
 
-        if (status != 0) {
-                rc = ib_flush_fmr_pool(fpo->fpo_fmr_pool);
-                LASSERT (rc == 0);
-        }
+       if (status != 0) {
+               rc = ib_flush_fmr_pool(fpo->fpo_fmr_pool);
+               LASSERT(rc == 0);
+       }
 
-        fmr->fmr_pool = NULL;
-        fmr->fmr_pfmr = NULL;
+       fmr->fmr_pool = NULL;
+       fmr->fmr_pfmr = NULL;
 
        spin_lock(&fps->fps_lock);
-        fpo->fpo_map_count --;  /* decref the pool */
+       fpo->fpo_map_count--;   /* decref the pool */
 
-        cfs_list_for_each_entry_safe(fpo, tmp, &fps->fps_pool_list, fpo_list) {
-                /* the first pool is persistent */
-                if (fps->fps_pool_list.next == &fpo->fpo_list)
-                        continue;
+       list_for_each_entry_safe(fpo, tmp, &fps->fps_pool_list, fpo_list) {
+               /* the first pool is persistent */
+               if (fps->fps_pool_list.next == &fpo->fpo_list)
+                       continue;
 
-                if (kiblnd_fmr_pool_is_idle(fpo, now)) {
-                        cfs_list_move(&fpo->fpo_list, &zombies);
-                        fps->fps_version ++;
-                }
-        }
+               if (kiblnd_fmr_pool_is_idle(fpo, now)) {
+                       list_move(&fpo->fpo_list, &zombies);
+                       fps->fps_version++;
+               }
+       }
        spin_unlock(&fps->fps_lock);
 
-        if (!cfs_list_empty(&zombies))
-                kiblnd_destroy_fmr_pool_list(&zombies);
+       if (!list_empty(&zombies))
+               kiblnd_destroy_fmr_pool_list(&zombies);
 }
 
 int
@@ -1638,10 +1638,10 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
         __u64               version;
         int                 rc;
 
- again:
+again:
        spin_lock(&fps->fps_lock);
        version = fps->fps_version;
-       cfs_list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
+       list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
                fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
                fpo->fpo_map_count++;
                spin_unlock(&fps->fps_lock);
@@ -1692,7 +1692,7 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
        fps->fps_increasing = 0;
        if (rc == 0) {
                fps->fps_version++;
-               cfs_list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
+               list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
        } else {
                fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
        }
@@ -1704,55 +1704,55 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
 static void
 kiblnd_fini_pool(kib_pool_t *pool)
 {
-        LASSERT (cfs_list_empty(&pool->po_free_list));
-        LASSERT (pool->po_allocated == 0);
+       LASSERT(list_empty(&pool->po_free_list));
+       LASSERT(pool->po_allocated == 0);
 
-        CDEBUG(D_NET, "Finalize %s pool\n", pool->po_owner->ps_name);
+       CDEBUG(D_NET, "Finalize %s pool\n", pool->po_owner->ps_name);
 }
 
 static void
 kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size)
 {
-        CDEBUG(D_NET, "Initialize %s pool\n", ps->ps_name);
+       CDEBUG(D_NET, "Initialize %s pool\n", ps->ps_name);
 
-        memset(pool, 0, sizeof(kib_pool_t));
-        CFS_INIT_LIST_HEAD(&pool->po_free_list);
-        pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
-        pool->po_owner    = ps;
-        pool->po_size     = size;
+       memset(pool, 0, sizeof(kib_pool_t));
+       INIT_LIST_HEAD(&pool->po_free_list);
+       pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+       pool->po_owner    = ps;
+       pool->po_size     = size;
 }
 
 void
-kiblnd_destroy_pool_list(cfs_list_t *head)
+kiblnd_destroy_pool_list(struct list_head *head)
 {
-        kib_pool_t *pool;
+       kib_pool_t *pool;
 
-        while (!cfs_list_empty(head)) {
-                pool = cfs_list_entry(head->next, kib_pool_t, po_list);
-                cfs_list_del(&pool->po_list);
+       while (!list_empty(head)) {
+               pool = list_entry(head->next, kib_pool_t, po_list);
+               list_del(&pool->po_list);
 
-                LASSERT (pool->po_owner != NULL);
-                pool->po_owner->ps_pool_destroy(pool);
-        }
+               LASSERT(pool->po_owner != NULL);
+               pool->po_owner->ps_pool_destroy(pool);
+       }
 }
 
 static void
-kiblnd_fail_poolset(kib_poolset_t *ps, cfs_list_t *zombies)
+kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies)
 {
        if (ps->ps_net == NULL) /* intialized? */
                return;
 
        spin_lock(&ps->ps_lock);
-        while (!cfs_list_empty(&ps->ps_pool_list)) {
-                kib_pool_t *po = cfs_list_entry(ps->ps_pool_list.next,
+       while (!list_empty(&ps->ps_pool_list)) {
+               kib_pool_t *po = list_entry(ps->ps_pool_list.next,
                                             kib_pool_t, po_list);
-                po->po_failed = 1;
-                cfs_list_del(&po->po_list);
-                if (po->po_allocated == 0)
-                        cfs_list_add(&po->po_list, zombies);
-                else
-                        cfs_list_add(&po->po_list, &ps->ps_failed_pool_list);
-        }
+               po->po_failed = 1;
+               list_del(&po->po_list);
+               if (po->po_allocated == 0)
+                       list_add(&po->po_list, zombies);
+               else
+                       list_add(&po->po_list, &ps->ps_failed_pool_list);
+       }
        spin_unlock(&ps->ps_lock);
 }
 
@@ -1789,16 +1789,16 @@ kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
            >= sizeof(ps->ps_name))
                return -E2BIG;
        spin_lock_init(&ps->ps_lock);
-        CFS_INIT_LIST_HEAD(&ps->ps_pool_list);
-        CFS_INIT_LIST_HEAD(&ps->ps_failed_pool_list);
+       INIT_LIST_HEAD(&ps->ps_pool_list);
+       INIT_LIST_HEAD(&ps->ps_failed_pool_list);
 
-        rc = ps->ps_pool_create(ps, size, &pool);
-        if (rc == 0)
-                cfs_list_add(&pool->po_list, &ps->ps_pool_list);
-        else
-                CERROR("Failed to create the first pool for %s\n", ps->ps_name);
+       rc = ps->ps_pool_create(ps, size, &pool);
+       if (rc == 0)
+               list_add(&pool->po_list, &ps->ps_pool_list);
+       else
+               CERROR("Failed to create the first pool for %s\n", ps->ps_name);
 
-        return rc;
+       return rc;
 }
 
 static int
@@ -1812,58 +1812,58 @@ kiblnd_pool_is_idle(kib_pool_t *pool, cfs_time_t now)
 }
 
 void
-kiblnd_pool_free_node(kib_pool_t *pool, cfs_list_t *node)
+kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
 {
-        CFS_LIST_HEAD  (zombies);
-        kib_poolset_t  *ps = pool->po_owner;
-        kib_pool_t     *tmp;
-        cfs_time_t      now = cfs_time_current();
+       struct list_head zombies = LIST_HEAD_INIT(zombies);
+       kib_poolset_t   *ps = pool->po_owner;
+       kib_pool_t      *tmp;
+       cfs_time_t       now = cfs_time_current();
 
        spin_lock(&ps->ps_lock);
 
-        if (ps->ps_node_fini != NULL)
-                ps->ps_node_fini(pool, node);
+       if (ps->ps_node_fini != NULL)
+               ps->ps_node_fini(pool, node);
 
-        LASSERT (pool->po_allocated > 0);
-        cfs_list_add(node, &pool->po_free_list);
-        pool->po_allocated --;
+       LASSERT(pool->po_allocated > 0);
+       list_add(node, &pool->po_free_list);
+       pool->po_allocated--;
 
-        cfs_list_for_each_entry_safe(pool, tmp, &ps->ps_pool_list, po_list) {
-                /* the first pool is persistent */
-                if (ps->ps_pool_list.next == &pool->po_list)
-                        continue;
+       list_for_each_entry_safe(pool, tmp, &ps->ps_pool_list, po_list) {
+               /* the first pool is persistent */
+               if (ps->ps_pool_list.next == &pool->po_list)
+                       continue;
 
-                if (kiblnd_pool_is_idle(pool, now))
-                        cfs_list_move(&pool->po_list, &zombies);
-        }
+               if (kiblnd_pool_is_idle(pool, now))
+                       list_move(&pool->po_list, &zombies);
+       }
        spin_unlock(&ps->ps_lock);
 
-       if (!cfs_list_empty(&zombies))
+       if (!list_empty(&zombies))
                kiblnd_destroy_pool_list(&zombies);
 }
 
-cfs_list_t *
+struct list_head *
 kiblnd_pool_alloc_node(kib_poolset_t *ps)
 {
-        cfs_list_t            *node;
-        kib_pool_t            *pool;
-        int                    rc;
+       struct list_head        *node;
+       kib_pool_t              *pool;
+       int                     rc;
 
- again:
+again:
        spin_lock(&ps->ps_lock);
-        cfs_list_for_each_entry(pool, &ps->ps_pool_list, po_list) {
-                if (cfs_list_empty(&pool->po_free_list))
-                        continue;
-
-                pool->po_allocated ++;
-                pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
-                node = pool->po_free_list.next;
-                cfs_list_del(node);
-
-                if (ps->ps_node_init != NULL) {
-                        /* still hold the lock */
-                        ps->ps_node_init(pool, node);
-                }
+       list_for_each_entry(pool, &ps->ps_pool_list, po_list) {
+               if (list_empty(&pool->po_free_list))
+                       continue;
+
+               pool->po_allocated++;
+               pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+               node = pool->po_free_list.next;
+               list_del(node);
+
+               if (ps->ps_node_init != NULL) {
+                       /* still hold the lock */
+                       ps->ps_node_init(pool, node);
+               }
                spin_unlock(&ps->ps_lock);
                return node;
        }
@@ -1893,14 +1893,14 @@ kiblnd_pool_alloc_node(kib_poolset_t *ps)
        rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
 
        spin_lock(&ps->ps_lock);
-        ps->ps_increasing = 0;
-        if (rc == 0) {
-                cfs_list_add_tail(&pool->po_list, &ps->ps_pool_list);
-        } else {
-                ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
-                CERROR("Can't allocate new %s pool because out of memory\n",
-                       ps->ps_name);
-        }
+       ps->ps_increasing = 0;
+       if (rc == 0) {
+               list_add_tail(&pool->po_list, &ps->ps_pool_list);
+       } else {
+               ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+               CERROR("Can't allocate new %s pool because out of memory\n",
+                      ps->ps_name);
+       }
        spin_unlock(&ps->ps_lock);
 
        goto again;
@@ -1922,22 +1922,22 @@ int
 kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
                     kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr)
 {
-        kib_phys_mr_t *pmr;
-        cfs_list_t    *node;
-        int            rc;
-        int            i;
+       kib_phys_mr_t    *pmr;
+       struct list_head *node;
+       int               rc;
+       int               i;
 
-        node = kiblnd_pool_alloc_node(&pps->pps_poolset);
-        if (node == NULL) {
-                CERROR("Failed to allocate PMR descriptor\n");
-                return -ENOMEM;
-        }
+       node = kiblnd_pool_alloc_node(&pps->pps_poolset);
+       if (node == NULL) {
+               CERROR("Failed to allocate PMR descriptor\n");
+               return -ENOMEM;
+       }
 
-        pmr = container_of(node, kib_phys_mr_t, pmr_list);
-        if (pmr->pmr_pool->ppo_hdev != hdev) {
-                kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
-                return -EAGAIN;
-        }
+       pmr = container_of(node, kib_phys_mr_t, pmr_list);
+       if (pmr->pmr_pool->ppo_hdev != hdev) {
+               kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
+               return -EAGAIN;
+       }
 
         for (i = 0; i < rd->rd_nfrags; i ++) {
                 pmr->pmr_ipb[i].addr = rd->rd_frags[i].rf_addr;
@@ -1955,13 +1955,13 @@ kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
                 return 0;
         }
 
-        rc = PTR_ERR(pmr->pmr_mr);
-        CERROR("Failed ib_reg_phys_mr: %d\n", rc);
+       rc = PTR_ERR(pmr->pmr_mr);
+       CERROR("Failed ib_reg_phys_mr: %d\n", rc);
 
-        pmr->pmr_mr = NULL;
-        kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
+       pmr->pmr_mr = NULL;
+       kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
 
-        return rc;
+       return rc;
 }
 
 static void
@@ -1972,12 +1972,12 @@ kiblnd_destroy_pmr_pool(kib_pool_t *pool)
 
         LASSERT (pool->po_allocated == 0);
 
-        while (!cfs_list_empty(&pool->po_free_list)) {
-                pmr = cfs_list_entry(pool->po_free_list.next,
+       while (!list_empty(&pool->po_free_list)) {
+               pmr = list_entry(pool->po_free_list.next,
                                      kib_phys_mr_t, pmr_list);
 
                 LASSERT (pmr->pmr_mr == NULL);
-                cfs_list_del(&pmr->pmr_list);
+               list_del(&pmr->pmr_list);
 
                 if (pmr->pmr_ipb != NULL) {
                         LIBCFS_FREE(pmr->pmr_ipb,
@@ -2032,7 +2032,7 @@ kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
                 if (pmr->pmr_ipb == NULL)
                         break;
 
-                cfs_list_add(&pmr->pmr_list, &pool->po_free_list);
+               list_add(&pmr->pmr_list, &pool->po_free_list);
         }
 
         if (i < size) {
@@ -2064,7 +2064,7 @@ kiblnd_destroy_tx_pool(kib_pool_t *pool)
         for (i = 0; i < pool->po_size; i++) {
                 kib_tx_t *tx = &tpo->tpo_tx_descs[i];
 
-                cfs_list_del(&tx->tx_list);
+               list_del(&tx->tx_list);
                 if (tx->tx_pages != NULL)
                         LIBCFS_FREE(tx->tx_pages,
                                     LNET_MAX_IOV *
@@ -2186,13 +2186,13 @@ kiblnd_create_tx_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
 }
 
 static void
-kiblnd_tx_init(kib_pool_t *pool, cfs_list_t *node)
+kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
 {
-        kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t,
-                                             tps_poolset);
-        kib_tx_t         *tx  = cfs_list_entry(node, kib_tx_t, tx_list);
+       kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t,
+                                            tps_poolset);
+       kib_tx_t         *tx  = list_entry(node, kib_tx_t, tx_list);
 
-        tx->tx_cookie = tps->tps_next_tx_cookie ++;
+       tx->tx_cookie = tps->tps_next_tx_cookie++;
 }
 
 void
@@ -2598,9 +2598,9 @@ kiblnd_dev_need_failover(kib_dev_t *dev)
 int
 kiblnd_dev_failover(kib_dev_t *dev)
 {
-        CFS_LIST_HEAD      (zombie_tpo);
-        CFS_LIST_HEAD      (zombie_ppo);
-        CFS_LIST_HEAD      (zombie_fpo);
+       struct list_head    zombie_tpo = LIST_HEAD_INIT(zombie_tpo);
+       struct list_head    zombie_ppo = LIST_HEAD_INIT(zombie_ppo);
+       struct list_head    zombie_fpo = LIST_HEAD_INIT(zombie_fpo);
         struct rdma_cm_id  *cmid  = NULL;
         kib_hca_dev_t      *hdev  = NULL;
         kib_hca_dev_t      *old;
@@ -2695,11 +2695,11 @@ kiblnd_dev_failover(kib_dev_t *dev)
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        old = dev->ibd_hdev;
-        dev->ibd_hdev = hdev; /* take over the refcount */
-        hdev = old;
+       old = dev->ibd_hdev;
+       dev->ibd_hdev = hdev;   /* take over the refcount */
+       hdev = old;
 
-        cfs_list_for_each_entry(net, &dev->ibd_nets, ibn_list) {
+       list_for_each_entry(net, &dev->ibd_nets, ibn_list) {
                cfs_cpt_for_each(i, lnet_cpt_table()) {
                        kiblnd_fail_poolset(&net->ibn_tx_ps[i]->tps_poolset,
                                            &zombie_tpo);
@@ -2717,31 +2717,31 @@ kiblnd_dev_failover(kib_dev_t *dev)
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
  out:
-        if (!cfs_list_empty(&zombie_tpo))
-                kiblnd_destroy_pool_list(&zombie_tpo);
-        if (!cfs_list_empty(&zombie_ppo))
-                kiblnd_destroy_pool_list(&zombie_ppo);
-        if (!cfs_list_empty(&zombie_fpo))
-                kiblnd_destroy_fmr_pool_list(&zombie_fpo);
-        if (hdev != NULL)
-                kiblnd_hdev_decref(hdev);
+       if (!list_empty(&zombie_tpo))
+               kiblnd_destroy_pool_list(&zombie_tpo);
+       if (!list_empty(&zombie_ppo))
+               kiblnd_destroy_pool_list(&zombie_ppo);
+       if (!list_empty(&zombie_fpo))
+               kiblnd_destroy_fmr_pool_list(&zombie_fpo);
+       if (hdev != NULL)
+               kiblnd_hdev_decref(hdev);
 
-        if (rc != 0)
-                dev->ibd_failed_failover++;
-        else
-                dev->ibd_failed_failover = 0;
+       if (rc != 0)
+               dev->ibd_failed_failover++;
+       else
+               dev->ibd_failed_failover = 0;
 
-        return rc;
+       return rc;
 }
 
 void
 kiblnd_destroy_dev (kib_dev_t *dev)
 {
         LASSERT (dev->ibd_nnets == 0);
-        LASSERT (cfs_list_empty(&dev->ibd_nets));
+       LASSERT(list_empty(&dev->ibd_nets));
 
-        cfs_list_del(&dev->ibd_fail_list);
-        cfs_list_del(&dev->ibd_list);
+       list_del(&dev->ibd_fail_list);
+       list_del(&dev->ibd_list);
 
         if (dev->ibd_hdev != NULL)
                 kiblnd_hdev_decref(dev->ibd_hdev);
@@ -2788,9 +2788,9 @@ kiblnd_create_dev(char *ifname)
                 dev_put(netdev);
         }
 
-        CFS_INIT_LIST_HEAD(&dev->ibd_nets);
-        CFS_INIT_LIST_HEAD(&dev->ibd_list); /* not yet in kib_devs */
-        CFS_INIT_LIST_HEAD(&dev->ibd_fail_list);
+       INIT_LIST_HEAD(&dev->ibd_nets);
+       INIT_LIST_HEAD(&dev->ibd_list); /* not yet in kib_devs */
+       INIT_LIST_HEAD(&dev->ibd_fail_list);
         dev->ibd_ifip = ip;
         strcpy(&dev->ibd_ifname[0], ifname);
 
@@ -2802,7 +2802,7 @@ kiblnd_create_dev(char *ifname)
                 return NULL;
         }
 
-        cfs_list_add_tail(&dev->ibd_list,
+       list_add_tail(&dev->ibd_list,
                           &kiblnd_data.kib_devs);
         return dev;
 }
@@ -2813,7 +2813,7 @@ kiblnd_base_shutdown(void)
        struct kib_sched_info   *sched;
        int                     i;
 
-        LASSERT (cfs_list_empty(&kiblnd_data.kib_devs));
+       LASSERT(list_empty(&kiblnd_data.kib_devs));
 
         CDEBUG(D_MALLOC, "before LND base cleanup: kmem %d\n",
               atomic_read(&libcfs_kmemory));
@@ -2826,10 +2826,10 @@ kiblnd_base_shutdown(void)
         case IBLND_INIT_DATA:
                 LASSERT (kiblnd_data.kib_peers != NULL);
                 for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
-                        LASSERT (cfs_list_empty(&kiblnd_data.kib_peers[i]));
+                       LASSERT(list_empty(&kiblnd_data.kib_peers[i]));
                 }
-                LASSERT (cfs_list_empty(&kiblnd_data.kib_connd_zombies));
-                LASSERT (cfs_list_empty(&kiblnd_data.kib_connd_conns));
+               LASSERT(list_empty(&kiblnd_data.kib_connd_zombies));
+               LASSERT(list_empty(&kiblnd_data.kib_connd_conns));
 
                /* flag threads to terminate; wake and wait for them to die */
                kiblnd_data.kib_shutdown = 1;
@@ -2860,7 +2860,7 @@ kiblnd_base_shutdown(void)
 
        if (kiblnd_data.kib_peers != NULL) {
                LIBCFS_FREE(kiblnd_data.kib_peers,
-                           sizeof(cfs_list_t) *
+                           sizeof(struct list_head) *
                            kiblnd_data.kib_peer_hash_size);
        }
 
@@ -2918,7 +2918,7 @@ kiblnd_shutdown (lnet_ni_t *ni)
                write_lock_irqsave(g_lock, flags);
                LASSERT(net->ibn_dev->ibd_nnets > 0);
                net->ibn_dev->ibd_nnets--;
-               cfs_list_del(&net->ibn_list);
+               list_del(&net->ibn_list);
                write_unlock_irqrestore(g_lock, flags);
 
                 /* fall through */
@@ -2942,7 +2942,7 @@ kiblnd_shutdown (lnet_ni_t *ni)
         LIBCFS_FREE(net, sizeof(*net));
 
 out:
-        if (cfs_list_empty(&kiblnd_data.kib_devs))
+       if (list_empty(&kiblnd_data.kib_devs))
                 kiblnd_base_shutdown();
         return;
 }
@@ -2954,29 +2954,29 @@ kiblnd_base_startup(void)
        int                     rc;
        int                     i;
 
-        LASSERT (kiblnd_data.kib_init == IBLND_INIT_NOTHING);
+       LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING);
 
        try_module_get(THIS_MODULE);
        memset(&kiblnd_data, 0, sizeof(kiblnd_data)); /* zero pointers, flags etc */
 
        rwlock_init(&kiblnd_data.kib_global_lock);
 
-        CFS_INIT_LIST_HEAD(&kiblnd_data.kib_devs);
-        CFS_INIT_LIST_HEAD(&kiblnd_data.kib_failed_devs);
+       INIT_LIST_HEAD(&kiblnd_data.kib_devs);
+       INIT_LIST_HEAD(&kiblnd_data.kib_failed_devs);
 
-        kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE;
-        LIBCFS_ALLOC(kiblnd_data.kib_peers,
-                     sizeof(cfs_list_t) *
-                            kiblnd_data.kib_peer_hash_size);
-        if (kiblnd_data.kib_peers == NULL) {
-                goto failed;
-        }
-        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
-                CFS_INIT_LIST_HEAD(&kiblnd_data.kib_peers[i]);
+       kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE;
+       LIBCFS_ALLOC(kiblnd_data.kib_peers,
+                    sizeof(struct list_head) *
+                    kiblnd_data.kib_peer_hash_size);
+       if (kiblnd_data.kib_peers == NULL)
+               goto failed;
+
+       for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
+               INIT_LIST_HEAD(&kiblnd_data.kib_peers[i]);
 
        spin_lock_init(&kiblnd_data.kib_connd_lock);
-       CFS_INIT_LIST_HEAD(&kiblnd_data.kib_connd_conns);
-       CFS_INIT_LIST_HEAD(&kiblnd_data.kib_connd_zombies);
+       INIT_LIST_HEAD(&kiblnd_data.kib_connd_conns);
+       INIT_LIST_HEAD(&kiblnd_data.kib_connd_zombies);
        init_waitqueue_head(&kiblnd_data.kib_connd_waitq);
        init_waitqueue_head(&kiblnd_data.kib_failover_waitq);
 
@@ -2989,7 +2989,7 @@ kiblnd_base_startup(void)
                int     nthrs;
 
                spin_lock_init(&sched->ibs_lock);
-               CFS_INIT_LIST_HEAD(&sched->ibs_conns);
+               INIT_LIST_HEAD(&sched->ibs_conns);
                init_waitqueue_head(&sched->ibs_waitq);
 
                nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
@@ -3113,7 +3113,7 @@ kiblnd_dev_search(char *ifname)
        char            *colon2;
 
        colon = strchr(ifname, ':');
-       cfs_list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
+       list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
                if (strcmp(&dev->ibd_ifname[0], ifname) == 0)
                        return dev;
 
@@ -3216,7 +3216,7 @@ kiblnd_startup (lnet_ni_t *ni)
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
        ibdev->ibd_nnets++;
-       cfs_list_add_tail(&net->ibn_list, &ibdev->ibd_nets);
+       list_add_tail(&net->ibn_list, &ibdev->ibd_nets);
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
         net->ibn_init = IBLND_INIT_ALL;
index 0bd5d94..f5edc51 100644 (file)
@@ -203,19 +203,22 @@ struct kib_hca_dev;
 
 typedef struct
 {
-        cfs_list_t           ibd_list;          /* chain on kib_devs */
-        cfs_list_t           ibd_fail_list;     /* chain on kib_failed_devs */
-        __u32                ibd_ifip;          /* IPoIB interface IP */
-        /** IPoIB interface name */
-        char                 ibd_ifname[KIB_IFNAME_SIZE];
-        int                  ibd_nnets;         /* # nets extant */
-
-        cfs_time_t           ibd_next_failover;
-        int                  ibd_failed_failover; /* # failover failures */
-        unsigned int         ibd_failover;      /* failover in progress */
-        unsigned int         ibd_can_failover;  /* IPoIB interface is a bonding master */
-        cfs_list_t           ibd_nets;
-        struct kib_hca_dev  *ibd_hdev;
+       struct list_head        ibd_list;       /* chain on kib_devs */
+       struct list_head        ibd_fail_list;  /* chain on kib_failed_devs */
+       __u32                   ibd_ifip;       /* IPoIB interface IP */
+       /** IPoIB interface name */
+       char                    ibd_ifname[KIB_IFNAME_SIZE];
+       int                     ibd_nnets;      /* # nets extant */
+
+       cfs_time_t              ibd_next_failover;
+       /* # failover failures */
+       int                     ibd_failed_failover;
+       /* failover in progress */
+       unsigned int            ibd_failover;
+       /* IPoIB interface is a bonding master */
+       unsigned int            ibd_can_failover;
+       struct list_head        ibd_nets;
+       struct kib_hca_dev      *ibd_hdev;
 } kib_dev_t;
 
 typedef struct kib_hca_dev
@@ -248,12 +251,12 @@ typedef struct
 struct kib_pmr_pool;
 
 typedef struct {
-        cfs_list_t              pmr_list;               /* chain node */
-        struct ib_phys_buf     *pmr_ipb;                /* physical buffer */
-        struct ib_mr           *pmr_mr;                 /* IB MR */
-        struct kib_pmr_pool    *pmr_pool;               /* owner of this MR */
-        __u64                   pmr_iova;               /* Virtual I/O address */
-        int                     pmr_refcount;           /* reference count */
+       struct list_head        pmr_list;       /* chain node */
+       struct ib_phys_buf     *pmr_ipb;        /* physical buffer */
+       struct ib_mr           *pmr_mr;         /* IB MR */
+       struct kib_pmr_pool    *pmr_pool;       /* owner of this MR */
+       __u64                   pmr_iova;       /* Virtual I/O address */
+       int                     pmr_refcount;   /* reference count */
 } kib_phys_mr_t;
 
 struct kib_pool;
@@ -262,8 +265,8 @@ struct kib_poolset;
 typedef int  (*kib_ps_pool_create_t)(struct kib_poolset *ps,
                                     int inc, struct kib_pool **pp_po);
 typedef void (*kib_ps_pool_destroy_t)(struct kib_pool *po);
-typedef void (*kib_ps_node_init_t)(struct kib_pool *po, cfs_list_t *node);
-typedef void (*kib_ps_node_fini_t)(struct kib_pool *po, cfs_list_t *node);
+typedef void (*kib_ps_node_init_t)(struct kib_pool *po, struct list_head *node);
+typedef void (*kib_ps_node_fini_t)(struct kib_pool *po, struct list_head *node);
 
 struct kib_net;
 
@@ -271,31 +274,51 @@ struct kib_net;
 
 typedef struct kib_poolset
 {
-       spinlock_t              ps_lock;                /* serialize */
-        struct kib_net         *ps_net;                 /* network it belongs to */
-        char                    ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
-        cfs_list_t              ps_pool_list;           /* list of pools */
-        cfs_list_t              ps_failed_pool_list;    /* failed pool list */
-        cfs_time_t              ps_next_retry;          /* time stamp for retry if failed to allocate */
-        int                     ps_increasing;          /* is allocating new pool */
-        int                     ps_pool_size;           /* new pool size */
-       int                     ps_cpt;                 /* CPT id */
-
-        kib_ps_pool_create_t    ps_pool_create;         /* create a new pool */
-        kib_ps_pool_destroy_t   ps_pool_destroy;        /* destroy a pool */
-        kib_ps_node_init_t      ps_node_init;           /* initialize new allocated node */
-        kib_ps_node_fini_t      ps_node_fini;           /* finalize node */
+       /* serialize */
+       spinlock_t              ps_lock;
+       /* network it belongs to */
+       struct kib_net          *ps_net;
+       /* pool set name */
+       char                    ps_name[IBLND_POOL_NAME_LEN];
+       /* list of pools */
+       struct list_head        ps_pool_list;
+       /* failed pool list */
+       struct list_head        ps_failed_pool_list;
+       /* time stamp for retry if failed to allocate */
+       cfs_time_t              ps_next_retry;
+       /* is allocating new pool */
+       int                     ps_increasing;
+       /* new pool size */
+       int                     ps_pool_size;
+       /* CPT id */
+       int                     ps_cpt;
+
+       /* create a new pool */
+       kib_ps_pool_create_t    ps_pool_create;
+       /* destroy a pool */
+       kib_ps_pool_destroy_t   ps_pool_destroy;
+       /* initialize new allocated node */
+       kib_ps_node_init_t      ps_node_init;
+       /* finalize node */
+       kib_ps_node_fini_t      ps_node_fini;
 } kib_poolset_t;
 
 typedef struct kib_pool
 {
-        cfs_list_t              po_list;                /* chain on pool list */
-        cfs_list_t              po_free_list;           /* pre-allocated node */
-        kib_poolset_t          *po_owner;               /* pool_set of this pool */
-        cfs_time_t              po_deadline;            /* deadline of this pool */
-        int                     po_allocated;           /* # of elements in use */
-        int                     po_failed;              /* pool is created on failed HCA */
-        int                     po_size;                /* # of pre-allocated elements */
+       /* chain on pool list */
+       struct list_head        po_list;
+       /* pre-allocated node */
+       struct list_head        po_free_list;
+       /* pool_set of this pool */
+       kib_poolset_t          *po_owner;
+       /* deadline of this pool */
+       cfs_time_t              po_deadline;
+       /* # of elements in use */
+       int                     po_allocated;
+       /* pool is created on failed HCA */
+       int                     po_failed;
+       /* # of pre-allocated elements */
+       int                     po_size;
 } kib_pool_t;
 
 typedef struct {
@@ -322,10 +345,10 @@ typedef struct kib_pmr_pool {
 typedef struct
 {
        spinlock_t              fps_lock;               /* serialize */
-        struct kib_net         *fps_net;                /* IB network */
-        cfs_list_t              fps_pool_list;          /* FMR pool list */
-        cfs_list_t              fps_failed_pool_list;   /* FMR pool list */
-        __u64                   fps_version;            /* validity stamp */
+       struct kib_net         *fps_net;                /* IB network */
+       struct list_head        fps_pool_list;          /* FMR pool list */
+       struct list_head        fps_failed_pool_list;   /* FMR pool list */
+       __u64                   fps_version;            /* validity stamp */
        int                     fps_cpt;                /* CPT id */
        int                     fps_pool_size;
        int                     fps_flush_trigger;
@@ -337,13 +360,13 @@ typedef struct
 
 typedef struct
 {
-        cfs_list_t              fpo_list;               /* chain on pool list */
-        struct kib_hca_dev     *fpo_hdev;               /* device for this pool */
-        kib_fmr_poolset_t      *fpo_owner;              /* owner of this pool */
-        struct ib_fmr_pool     *fpo_fmr_pool;           /* IB FMR pool */
-        cfs_time_t              fpo_deadline;           /* deadline of this pool */
-        int                     fpo_failed;             /* fmr pool is failed */
-        int                     fpo_map_count;          /* # of mapped FMR */
+       struct list_head        fpo_list;       /* chain on pool list */
+       struct kib_hca_dev     *fpo_hdev;       /* device for this pool */
+       kib_fmr_poolset_t      *fpo_owner;      /* owner of this pool */
+       struct ib_fmr_pool     *fpo_fmr_pool;   /* IB FMR pool */
+       cfs_time_t              fpo_deadline;   /* deadline of this pool */
+       int                     fpo_failed;     /* fmr pool is failed */
+       int                     fpo_map_count;  /* # of mapped FMR */
 } kib_fmr_pool_t;
 
 typedef struct {
@@ -353,10 +376,11 @@ typedef struct {
 
 typedef struct kib_net
 {
-       cfs_list_t           ibn_list;          /* chain on kib_dev_t::ibd_nets */
-       __u64                ibn_incarnation;   /* my epoch */
-       int                  ibn_init;          /* initialisation state */
-       int                  ibn_shutdown;      /* shutting down? */
+       /* chain on kib_dev_t::ibd_nets */
+       struct list_head        ibn_list;
+       __u64                   ibn_incarnation;/* my epoch */
+       int                     ibn_init;       /* initialisation state */
+       int                     ibn_shutdown;   /* shutting down? */
 
        atomic_t                ibn_npeers;     /* # peers extant */
        atomic_t                ibn_nconns;     /* # connections extant */
@@ -377,9 +401,9 @@ struct kib_sched_info {
        /* serialise */
        spinlock_t              ibs_lock;
        /* schedulers sleep here */
-       wait_queue_head_t               ibs_waitq;
+       wait_queue_head_t       ibs_waitq;
        /* conns to check for rx completions */
-       cfs_list_t              ibs_conns;
+       struct list_head        ibs_conns;
        /* number of scheduler threads */
        int                     ibs_nthreads;
        /* max allowed scheduler threads */
@@ -391,26 +415,26 @@ typedef struct
 {
        int                     kib_init;       /* initialisation state */
        int                     kib_shutdown;   /* shut down? */
-       cfs_list_t              kib_devs;       /* IB devices extant */
+       struct list_head        kib_devs;       /* IB devices extant */
        /* list head of failed devices */
-       cfs_list_t              kib_failed_devs;
+       struct list_head        kib_failed_devs;
        /* schedulers sleep here */
-       wait_queue_head_t               kib_failover_waitq;
+       wait_queue_head_t       kib_failover_waitq;
        atomic_t                kib_nthreads;   /* # live threads */
        /* stabilize net/dev/peer/conn ops */
        rwlock_t                kib_global_lock;
        /* hash table of all my known peers */
-       cfs_list_t              *kib_peers;
+       struct list_head        *kib_peers;
        /* size of kib_peers */
        int                     kib_peer_hash_size;
        /* the connd task (serialisation assertions) */
        void                    *kib_connd;
        /* connections to setup/teardown */
-       cfs_list_t              kib_connd_conns;
+       struct list_head        kib_connd_conns;
        /* connections with zero refcount */
-       cfs_list_t              kib_connd_zombies;
+       struct list_head        kib_connd_zombies;
        /* connection daemon sleeps here */
-       wait_queue_head_t               kib_connd_waitq;
+       wait_queue_head_t       kib_connd_waitq;
        spinlock_t              kib_connd_lock; /* serialise */
        struct ib_qp_attr       kib_error_qpa;  /* QP->ERROR */
        /* percpt data for schedulers */
@@ -544,15 +568,24 @@ typedef struct {
 
 typedef struct kib_rx                           /* receive message */
 {
-        cfs_list_t                rx_list;      /* queue for attention */
-        struct kib_conn          *rx_conn;      /* owning conn */
-        int                       rx_nob;       /* # bytes received (-1 while posted) */
-        enum ib_wc_status         rx_status;    /* completion status */
-        kib_msg_t                *rx_msg;       /* message buffer (host vaddr) */
-        __u64                     rx_msgaddr;   /* message buffer (I/O addr) */
-        DECLARE_PCI_UNMAP_ADDR   (rx_msgunmap); /* for dma_unmap_single() */
-        struct ib_recv_wr         rx_wrq;       /* receive work item... */
-        struct ib_sge             rx_sge;       /* ...and its memory */
+       /* queue for attention */
+       struct list_head        rx_list;
+       /* owning conn */
+       struct kib_conn        *rx_conn;
+       /* # bytes received (-1 while posted) */
+       int                     rx_nob;
+       /* completion status */
+       enum ib_wc_status       rx_status;
+       /* message buffer (host vaddr) */
+       kib_msg_t              *rx_msg;
+       /* message buffer (I/O addr) */
+       __u64                   rx_msgaddr;
+       /* for dma_unmap_single() */
+       DECLARE_PCI_UNMAP_ADDR(rx_msgunmap);
+       /* receive work item... */
+       struct ib_recv_wr       rx_wrq;
+       /* ...and its memory */
+       struct ib_sge           rx_sge;
 } kib_rx_t;
 
 #define IBLND_POSTRX_DONT_POST    0             /* don't post */
@@ -562,31 +595,54 @@ typedef struct kib_rx                           /* receive message */
 
 typedef struct kib_tx                           /* transmit message */
 {
-        cfs_list_t                tx_list;      /* queue on idle_txs ibc_tx_queue etc. */
-        kib_tx_pool_t            *tx_pool;      /* pool I'm from */
-        struct kib_conn          *tx_conn;      /* owning conn */
-        short                     tx_sending;   /* # tx callbacks outstanding */
-        short                     tx_queued;    /* queued for sending */
-        short                     tx_waiting;   /* waiting for peer */
-        int                       tx_status;    /* LNET completion status */
-        unsigned long             tx_deadline;  /* completion deadline */
-        __u64                     tx_cookie;    /* completion cookie */
-        lnet_msg_t               *tx_lntmsg[2]; /* lnet msgs to finalize on completion */
-        kib_msg_t                *tx_msg;       /* message buffer (host vaddr) */
-        __u64                     tx_msgaddr;   /* message buffer (I/O addr) */
-        DECLARE_PCI_UNMAP_ADDR   (tx_msgunmap); /* for dma_unmap_single() */
-        int                       tx_nwrq;      /* # send work items */
-        struct ib_send_wr        *tx_wrq;       /* send work items... */
-        struct ib_sge            *tx_sge;       /* ...and their memory */
-        kib_rdma_desc_t          *tx_rd;        /* rdma descriptor */
-        int                       tx_nfrags;    /* # entries in... */
-        struct scatterlist       *tx_frags;     /* dma_map_sg descriptor */
-        __u64                    *tx_pages;     /* rdma phys page addrs */
-        union {
-                kib_phys_mr_t      *pmr;        /* MR for physical buffer */
-                kib_fmr_t           fmr;        /* FMR */
-        }                         tx_u;
-        int                       tx_dmadir;    /* dma direction */
+       /* queue on idle_txs ibc_tx_queue etc. */
+       struct list_head        tx_list;
+       /* pool I'm from */
+       kib_tx_pool_t           *tx_pool;
+       /* owning conn */
+       struct kib_conn         *tx_conn;
+       /* # tx callbacks outstanding */
+       short                   tx_sending;
+       /* queued for sending */
+       short                   tx_queued;
+       /* waiting for peer */
+       short                   tx_waiting;
+       /* LNET completion status */
+       int                     tx_status;
+       /* completion deadline */
+       unsigned long           tx_deadline;
+       /* completion cookie */
+       __u64                   tx_cookie;
+       /* lnet msgs to finalize on completion */
+       lnet_msg_t              *tx_lntmsg[2];
+       /* message buffer (host vaddr) */
+       kib_msg_t               *tx_msg;
+       /* message buffer (I/O addr) */
+       __u64                   tx_msgaddr;
+       /* for dma_unmap_single() */
+       DECLARE_PCI_UNMAP_ADDR(tx_msgunmap);
+       /* # send work items */
+       int                     tx_nwrq;
+       /* send work items... */
+       struct ib_send_wr       *tx_wrq;
+       /* ...and their memory */
+       struct ib_sge           *tx_sge;
+       /* rdma descriptor */
+       kib_rdma_desc_t         *tx_rd;
+       /* # entries in... */
+       int                     tx_nfrags;
+       /* dma_map_sg descriptor */
+       struct scatterlist      *tx_frags;
+       /* rdma phys page addrs */
+       __u64                   *tx_pages;
+       union {
+               /* MR for physical buffer */
+               kib_phys_mr_t  *pmr;
+               /* FMR */
+               kib_fmr_t       fmr;
+       }                       tx_u;
+                               /* dma direction */
+       int                     tx_dmadir;
 } kib_tx_t;
 
 typedef struct kib_connvars
@@ -597,44 +653,72 @@ typedef struct kib_connvars
 
 typedef struct kib_conn
 {
-       struct kib_sched_info *ibc_sched;       /* scheduler information */
-        struct kib_peer     *ibc_peer;          /* owning peer */
-        kib_hca_dev_t       *ibc_hdev;          /* HCA bound on */
-        cfs_list_t           ibc_list;          /* stash on peer's conn list */
-        cfs_list_t           ibc_sched_list;    /* schedule for attention */
-        __u16                ibc_version;       /* version of connection */
-        __u64                ibc_incarnation;   /* which instance of the peer */
-       atomic_t             ibc_refcount;      /* # users */
-        int                  ibc_state;         /* what's happening */
-        int                  ibc_nsends_posted; /* # uncompleted sends */
-        int                  ibc_noops_posted;  /* # uncompleted NOOPs */
-        int                  ibc_credits;       /* # credits I have */
-        int                  ibc_outstanding_credits; /* # credits to return */
-        int                  ibc_reserved_credits;/* # ACK/DONE msg credits */
-        int                  ibc_comms_error;   /* set on comms error */
-       unsigned int         ibc_nrx:16;        /* receive buffers owned */
-       unsigned int         ibc_scheduled:1;   /* scheduled for attention */
-       unsigned int         ibc_ready:1;       /* CQ callback fired */
-        /* time of last send */
-        unsigned long        ibc_last_send;
-        /** link chain for kiblnd_check_conns only */
-        cfs_list_t           ibc_connd_list;
-        /** rxs completed before ESTABLISHED */
-        cfs_list_t           ibc_early_rxs;
-        /** IBLND_MSG_NOOPs for IBLND_MSG_VERSION_1 */
-        cfs_list_t           ibc_tx_noops;
-        cfs_list_t           ibc_tx_queue;       /* sends that need a credit */
-        cfs_list_t           ibc_tx_queue_nocred;/* sends that don't need a credit */
-        cfs_list_t           ibc_tx_queue_rsrvd; /* sends that need to reserve an ACK/DONE msg */
-        cfs_list_t           ibc_active_txs;     /* active tx awaiting completion */
-       spinlock_t           ibc_lock;           /* serialise */
-        kib_rx_t            *ibc_rxs;            /* the rx descs */
-        kib_pages_t         *ibc_rx_pages;       /* premapped rx msg pages */
-
-        struct rdma_cm_id   *ibc_cmid;           /* CM id */
-        struct ib_cq        *ibc_cq;             /* completion queue */
-
-        kib_connvars_t      *ibc_connvars;       /* in-progress connection state */
+       /* scheduler information */
+       struct kib_sched_info   *ibc_sched;
+       /* owning peer */
+       struct kib_peer         *ibc_peer;
+       /* HCA bound on */
+       kib_hca_dev_t           *ibc_hdev;
+       /* stash on peer's conn list */
+       struct list_head        ibc_list;
+       /* schedule for attention */
+       struct list_head        ibc_sched_list;
+       /* version of connection */
+       __u16                   ibc_version;
+       /* which instance of the peer */
+       __u64                   ibc_incarnation;
+       /* # users */
+       atomic_t                ibc_refcount;
+       /* what's happening */
+       int                     ibc_state;
+       /* # uncompleted sends */
+       int                     ibc_nsends_posted;
+       /* # uncompleted NOOPs */
+       int                     ibc_noops_posted;
+       /* # credits I have */
+       int                     ibc_credits;
+       /* # credits to return */
+       int                     ibc_outstanding_credits;
+       /* # ACK/DONE msg credits */
+       int                     ibc_reserved_credits;
+       /* set on comms error */
+       int                     ibc_comms_error;
+       /* receive buffers owned */
+       unsigned int            ibc_nrx:16;
+       /* scheduled for attention */
+       unsigned int            ibc_scheduled:1;
+       /* CQ callback fired */
+       unsigned int            ibc_ready:1;
+       /* time of last send */
+       unsigned long           ibc_last_send;
+       /** link chain for kiblnd_check_conns only */
+       struct list_head        ibc_connd_list;
+       /** rxs completed before ESTABLISHED */
+       struct list_head        ibc_early_rxs;
+       /** IBLND_MSG_NOOPs for IBLND_MSG_VERSION_1 */
+       struct list_head        ibc_tx_noops;
+       /* sends that need a credit */
+       struct list_head        ibc_tx_queue;
+       /* sends that don't need a credit */
+       struct list_head        ibc_tx_queue_nocred;
+       /* sends that need to reserve an ACK/DONE msg */
+       struct list_head        ibc_tx_queue_rsrvd;
+       /* active tx awaiting completion */
+       struct list_head        ibc_active_txs;
+       /* serialise */
+       spinlock_t              ibc_lock;
+       /* the rx descs */
+       kib_rx_t                *ibc_rxs;
+       /* premapped rx msg pages */
+       kib_pages_t             *ibc_rx_pages;
+
+       /* CM id */
+       struct rdma_cm_id       *ibc_cmid;
+       /* completion queue */
+       struct ib_cq            *ibc_cq;
+
+       /* in-progress connection state */
+       kib_connvars_t          *ibc_connvars;
 } kib_conn_t;
 
 #define IBLND_CONN_INIT               0         /* being initialised */
@@ -646,18 +730,30 @@ typedef struct kib_conn
 
 typedef struct kib_peer
 {
-        cfs_list_t           ibp_list;           /* stash on global peer list */
-        lnet_nid_t           ibp_nid;            /* who's on the other end(s) */
-        lnet_ni_t           *ibp_ni;             /* LNet interface */
-       atomic_t         ibp_refcount;       /* # users */
-        cfs_list_t           ibp_conns;          /* all active connections */
-        cfs_list_t           ibp_tx_queue;       /* msgs waiting for a conn */
-        __u16                ibp_version;        /* version of peer */
-        __u64                ibp_incarnation;    /* incarnation of peer */
-        int                  ibp_connecting;     /* current active connection attempts */
-        int                  ibp_accepting;      /* current passive connection attempts */
-        int                  ibp_error;          /* errno on closing this peer */
-        cfs_time_t           ibp_last_alive;     /* when (in jiffies) I was last alive */
+       /* stash on global peer list */
+       struct list_head        ibp_list;
+       /* who's on the other end(s) */
+       lnet_nid_t              ibp_nid;
+       /* LNet interface */
+       lnet_ni_t               *ibp_ni;
+       /* # users */
+       atomic_t                ibp_refcount;
+       /* all active connections */
+       struct list_head        ibp_conns;
+       /* msgs waiting for a conn */
+       struct list_head        ibp_tx_queue;
+       /* version of peer */
+       __u16                   ibp_version;
+       /* incarnation of peer */
+       __u64                   ibp_incarnation;
+       /* current active connection attempts */
+       int                     ibp_connecting;
+       /* current passive connection attempts */
+       int                     ibp_accepting;
+       /* errno on closing this peer */
+       int                     ibp_error;
+       /* when (in jiffies) I was last alive */
+       cfs_time_t              ibp_last_alive;
 } kib_peer_t;
 
 extern kib_data_t      kiblnd_data;
@@ -667,14 +763,14 @@ extern void kiblnd_hdev_destroy(kib_hca_dev_t *hdev);
 static inline void
 kiblnd_hdev_addref_locked(kib_hca_dev_t *hdev)
 {
-       LASSERT (atomic_read(&hdev->ibh_ref) > 0);
+       LASSERT(atomic_read(&hdev->ibh_ref) > 0);
        atomic_inc(&hdev->ibh_ref);
 }
 
 static inline void
 kiblnd_hdev_decref(kib_hca_dev_t *hdev)
 {
-       LASSERT (atomic_read(&hdev->ibh_ref) > 0);
+       LASSERT(atomic_read(&hdev->ibh_ref) > 0);
        if (atomic_dec_and_test(&hdev->ibh_ref))
                kiblnd_hdev_destroy(hdev);
 }
@@ -682,7 +778,7 @@ kiblnd_hdev_decref(kib_hca_dev_t *hdev)
 static inline int
 kiblnd_dev_can_failover(kib_dev_t *dev)
 {
-        if (!cfs_list_empty(&dev->ibd_fail_list)) /* already scheduled */
+       if (!list_empty(&dev->ibd_fail_list)) /* already scheduled */
                 return 0;
 
         if (*kiblnd_tunables.kib_dev_failover == 0) /* disabled */
@@ -710,7 +806,7 @@ do {                                                                        \
        LASSERT_ATOMIC_POS(&(conn)->ibc_refcount);                      \
        if (atomic_dec_and_test(&(conn)->ibc_refcount)) {               \
                spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);  \
-               cfs_list_add_tail(&(conn)->ibc_list,                    \
+               list_add_tail(&(conn)->ibc_list,                        \
                                  &kiblnd_data.kib_connd_zombies);      \
                wake_up(&kiblnd_data.kib_connd_waitq);          \
                spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);\
@@ -735,29 +831,29 @@ do {                                                            \
                kiblnd_destroy_peer(peer);                      \
 } while (0)
 
-static inline cfs_list_t *
+static inline struct list_head *
 kiblnd_nid2peerlist (lnet_nid_t nid)
 {
-        unsigned int hash =
-                ((unsigned int)nid) % kiblnd_data.kib_peer_hash_size;
+       unsigned int hash =
+               ((unsigned int)nid) % kiblnd_data.kib_peer_hash_size;
 
-        return (&kiblnd_data.kib_peers [hash]);
+       return &kiblnd_data.kib_peers[hash];
 }
 
 static inline int
 kiblnd_peer_active (kib_peer_t *peer)
 {
-        /* Am I in the peer hash table? */
-        return (!cfs_list_empty(&peer->ibp_list));
+       /* Am I in the peer hash table? */
+       return !list_empty(&peer->ibp_list);
 }
 
 static inline kib_conn_t *
 kiblnd_get_conn_locked (kib_peer_t *peer)
 {
-        LASSERT (!cfs_list_empty(&peer->ibp_conns));
+       LASSERT(!list_empty(&peer->ibp_conns));
 
         /* just return the first connection */
-        return cfs_list_entry(peer->ibp_conns.next, kib_conn_t, ibc_list);
+       return list_entry(peer->ibp_conns.next, kib_conn_t, ibc_list);
 }
 
 static inline int
@@ -779,16 +875,16 @@ kiblnd_need_noop(kib_conn_t *conn)
                 return 0; /* No need to send NOOP */
 
         if (IBLND_OOB_CAPABLE(conn->ibc_version)) {
-                if (!cfs_list_empty(&conn->ibc_tx_queue_nocred))
+               if (!list_empty(&conn->ibc_tx_queue_nocred))
                         return 0; /* NOOP can be piggybacked */
 
                 /* No tx to piggyback NOOP onto or no credit to send a tx */
-                return (cfs_list_empty(&conn->ibc_tx_queue) ||
+               return (list_empty(&conn->ibc_tx_queue) ||
                         conn->ibc_credits == 0);
         }
 
-        if (!cfs_list_empty(&conn->ibc_tx_noops) || /* NOOP already queued */
-            !cfs_list_empty(&conn->ibc_tx_queue_nocred) || /* piggyback NOOP */
+       if (!list_empty(&conn->ibc_tx_noops) || /* NOOP already queued */
+           !list_empty(&conn->ibc_tx_queue_nocred) || /* piggyback NOOP */
             conn->ibc_credits == 0)                    /* no credit */
                 return 0;
 
@@ -797,7 +893,7 @@ kiblnd_need_noop(kib_conn_t *conn)
                 return 0;
 
         /* No tx to piggyback NOOP onto or no credit to send a tx */
-        return (cfs_list_empty(&conn->ibc_tx_queue) || conn->ibc_credits == 1);
+       return (list_empty(&conn->ibc_tx_queue) || conn->ibc_credits == 1);
 }
 
 static inline void
@@ -808,22 +904,22 @@ kiblnd_abort_receives(kib_conn_t *conn)
 }
 
 static inline const char *
-kiblnd_queue2str (kib_conn_t *conn, cfs_list_t *q)
+kiblnd_queue2str(kib_conn_t *conn, struct list_head *q)
 {
-        if (q == &conn->ibc_tx_queue)
-                return "tx_queue";
+       if (q == &conn->ibc_tx_queue)
+               return "tx_queue";
 
-        if (q == &conn->ibc_tx_queue_rsrvd)
-                return "tx_queue_rsrvd";
+       if (q == &conn->ibc_tx_queue_rsrvd)
+               return "tx_queue_rsrvd";
 
-        if (q == &conn->ibc_tx_queue_nocred)
-                return "tx_queue_nocred";
+       if (q == &conn->ibc_tx_queue_nocred)
+               return "tx_queue_nocred";
 
-        if (q == &conn->ibc_active_txs)
-                return "active_txs";
+       if (q == &conn->ibc_active_txs)
+               return "active_txs";
 
-        LBUG();
-        return NULL;
+       LBUG();
+       return NULL;
 }
 
 /* CAVEAT EMPTOR: We rely on descriptor alignment to allow us to use the
@@ -1049,8 +1145,8 @@ void kiblnd_unmap_rx_descs(kib_conn_t *conn);
 int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
                   kib_rdma_desc_t *rd, int nfrags);
 void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
-void kiblnd_pool_free_node(kib_pool_t *pool, cfs_list_t *node);
-cfs_list_t *kiblnd_pool_alloc_node(kib_poolset_t *ps);
+void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node);
+struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps);
 
 int  kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages,
                          int npages, __u64 iov, kib_fmr_t *fmr);
@@ -1106,8 +1202,7 @@ void kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid);
 void kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn);
 void kiblnd_queue_tx (kib_tx_t *tx, kib_conn_t *conn);
 void kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob);
-void kiblnd_txlist_done (lnet_ni_t *ni, cfs_list_t *txlist,
-                         int status);
+void kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status);
 void kiblnd_check_sends (kib_conn_t *conn);
 
 void kiblnd_qp_event(struct ib_event *event, void *arg);
index 0905627..484fe8c 100644 (file)
@@ -84,26 +84,26 @@ kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
 }
 
 void
-kiblnd_txlist_done (lnet_ni_t *ni, cfs_list_t *txlist, int status)
+kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status)
 {
-        kib_tx_t *tx;
+       kib_tx_t *tx;
 
-        while (!cfs_list_empty (txlist)) {
-                tx = cfs_list_entry (txlist->next, kib_tx_t, tx_list);
+       while (!list_empty(txlist)) {
+               tx = list_entry(txlist->next, kib_tx_t, tx_list);
 
-                cfs_list_del(&tx->tx_list);
-                /* complete now */
-                tx->tx_waiting = 0;
-                tx->tx_status = status;
-                kiblnd_tx_done(ni, tx);
-        }
+               list_del(&tx->tx_list);
+               /* complete now */
+               tx->tx_waiting = 0;
+               tx->tx_status = status;
+               kiblnd_tx_done(ni, tx);
+       }
 }
 
 kib_tx_t *
 kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
 {
        kib_net_t               *net = (kib_net_t *)ni->ni_data;
-       cfs_list_t              *node;
+       struct list_head        *node;
        kib_tx_t                *tx;
        kib_tx_poolset_t        *tps;
 
@@ -212,26 +212,26 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
 kib_tx_t *
 kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
 {
-        cfs_list_t   *tmp;
+       struct list_head *tmp;
 
-        cfs_list_for_each(tmp, &conn->ibc_active_txs) {
-                kib_tx_t *tx = cfs_list_entry(tmp, kib_tx_t, tx_list);
+       list_for_each(tmp, &conn->ibc_active_txs) {
+               kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list);
 
-                LASSERT (!tx->tx_queued);
-                LASSERT (tx->tx_sending != 0 || tx->tx_waiting);
+               LASSERT(!tx->tx_queued);
+               LASSERT(tx->tx_sending != 0 || tx->tx_waiting);
 
-                if (tx->tx_cookie != cookie)
-                        continue;
+               if (tx->tx_cookie != cookie)
+                       continue;
 
-                if (tx->tx_waiting &&
-                    tx->tx_msg->ibm_type == txtype)
-                        return tx;
+               if (tx->tx_waiting &&
+                   tx->tx_msg->ibm_type == txtype)
+                       return tx;
 
-                CWARN("Bad completion: %swaiting, type %x (wanted %x)\n",
-                      tx->tx_waiting ? "" : "NOT ",
-                      tx->tx_msg->ibm_type, txtype);
-        }
-        return NULL;
+               CWARN("Bad completion: %swaiting, type %x (wanted %x)\n",
+                     tx->tx_waiting ? "" : "NOT ",
+                     tx->tx_msg->ibm_type, txtype);
+       }
+       return NULL;
 }
 
 void
@@ -265,7 +265,7 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
 
         idle = !tx->tx_queued && (tx->tx_sending == 0);
         if (idle)
-                cfs_list_del(&tx->tx_list);
+               list_del(&tx->tx_list);
 
        spin_unlock(&conn->ibc_lock);
 
@@ -392,7 +392,7 @@ kiblnd_handle_rx (kib_rx_t *rx)
                tx = kiblnd_find_waiting_tx_locked(conn, IBLND_MSG_PUT_REQ,
                                        msg->ibm_u.putack.ibpam_src_cookie);
                if (tx != NULL)
-                       cfs_list_del(&tx->tx_list);
+                       list_del(&tx->tx_list);
                spin_unlock(&conn->ibc_lock);
 
                 if (tx == NULL) {
@@ -508,7 +508,7 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
                write_lock_irqsave(g_lock, flags);
                /* must check holding global lock to eliminate race */
                if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
-                       cfs_list_add_tail(&rx->rx_list, &conn->ibc_early_rxs);
+                       list_add_tail(&rx->rx_list, &conn->ibc_early_rxs);
                        write_unlock_irqrestore(g_lock, flags);
                        return;
                }
@@ -831,7 +831,7 @@ kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
         }
 
         /* NB don't drop ibc_lock before bumping tx_sending */
-        cfs_list_del(&tx->tx_list);
+       list_del(&tx->tx_list);
         tx->tx_queued = 0;
 
         if (msg->ibm_type == IBLND_MSG_NOOP &&
@@ -866,7 +866,7 @@ kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
          * tx_sending is non-zero if we've not done the tx_complete()
          * from the first send; hence the ++ rather than = below. */
         tx->tx_sending++;
-        cfs_list_add(&tx->tx_list, &conn->ibc_active_txs);
+       list_add(&tx->tx_list, &conn->ibc_active_txs);
 
         /* I'm still holding ibc_lock! */
         if (conn->ibc_state != IBLND_CONN_ESTABLISHED) {
@@ -899,7 +899,7 @@ kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
 
         done = (tx->tx_sending == 0);
         if (done)
-                cfs_list_del(&tx->tx_list);
+               list_del(&tx->tx_list);
 
        spin_unlock(&conn->ibc_lock);
 
@@ -942,11 +942,11 @@ kiblnd_check_sends (kib_conn_t *conn)
         LASSERT (conn->ibc_reserved_credits >= 0);
 
         while (conn->ibc_reserved_credits > 0 &&
-               !cfs_list_empty(&conn->ibc_tx_queue_rsrvd)) {
-                tx = cfs_list_entry(conn->ibc_tx_queue_rsrvd.next,
+              !list_empty(&conn->ibc_tx_queue_rsrvd)) {
+               tx = list_entry(conn->ibc_tx_queue_rsrvd.next,
                                     kib_tx_t, tx_list);
-                cfs_list_del(&tx->tx_list);
-                cfs_list_add_tail(&tx->tx_list, &conn->ibc_tx_queue);
+               list_del(&tx->tx_list);
+               list_add_tail(&tx->tx_list, &conn->ibc_tx_queue);
                 conn->ibc_reserved_credits--;
         }
 
@@ -967,18 +967,18 @@ kiblnd_check_sends (kib_conn_t *conn)
         for (;;) {
                 int credit;
 
-                if (!cfs_list_empty(&conn->ibc_tx_queue_nocred)) {
+               if (!list_empty(&conn->ibc_tx_queue_nocred)) {
                         credit = 0;
-                        tx = cfs_list_entry(conn->ibc_tx_queue_nocred.next,
+                       tx = list_entry(conn->ibc_tx_queue_nocred.next,
                                             kib_tx_t, tx_list);
-                } else if (!cfs_list_empty(&conn->ibc_tx_noops)) {
+               } else if (!list_empty(&conn->ibc_tx_noops)) {
                         LASSERT (!IBLND_OOB_CAPABLE(ver));
                         credit = 1;
-                        tx = cfs_list_entry(conn->ibc_tx_noops.next,
+                       tx = list_entry(conn->ibc_tx_noops.next,
                                         kib_tx_t, tx_list);
-                } else if (!cfs_list_empty(&conn->ibc_tx_queue)) {
+               } else if (!list_empty(&conn->ibc_tx_queue)) {
                         credit = 1;
-                        tx = cfs_list_entry(conn->ibc_tx_queue.next,
+                       tx = list_entry(conn->ibc_tx_queue.next,
                                             kib_tx_t, tx_list);
                 } else
                         break;
@@ -1033,7 +1033,7 @@ kiblnd_tx_complete (kib_tx_t *tx, int status)
                !tx->tx_waiting &&               /* Not waiting for peer */
                !tx->tx_queued;                  /* Not re-queued (PUT_DONE) */
         if (idle)
-                cfs_list_del(&tx->tx_list);
+               list_del(&tx->tx_list);
 
         kiblnd_conn_addref(conn);               /* 1 ref for me.... */
 
@@ -1169,11 +1169,11 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
 void
 kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
 {
-        cfs_list_t   *q;
+       struct list_head *q;
 
-        LASSERT (tx->tx_nwrq > 0);              /* work items set up */
-        LASSERT (!tx->tx_queued);               /* not queued for sending already */
-        LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
+       LASSERT(tx->tx_nwrq > 0);       /* work items set up */
+       LASSERT(!tx->tx_queued);        /* not queued for sending already */
+       LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        tx->tx_queued = 1;
        tx->tx_deadline = jiffies + (*kiblnd_tunables.kib_timeout * HZ);
@@ -1216,7 +1216,7 @@ kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
                 break;
         }
 
-        cfs_list_add_tail(&tx->tx_list, q);
+       list_add_tail(&tx->tx_list, q);
 }
 
 void
@@ -1357,7 +1357,7 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
        read_lock_irqsave(g_lock, flags);
 
         peer = kiblnd_find_peer_locked(nid);
-        if (peer != NULL && !cfs_list_empty(&peer->ibp_conns)) {
+       if (peer != NULL && !list_empty(&peer->ibp_conns)) {
                 /* Found a peer with an established connection */
                 conn = kiblnd_get_conn_locked(peer);
                 kiblnd_conn_addref(conn); /* 1 ref for me... */
@@ -1376,12 +1376,12 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 
         peer = kiblnd_find_peer_locked(nid);
         if (peer != NULL) {
-                if (cfs_list_empty(&peer->ibp_conns)) {
+               if (list_empty(&peer->ibp_conns)) {
                         /* found a peer, but it's still connecting... */
                         LASSERT (peer->ibp_connecting != 0 ||
                                  peer->ibp_accepting != 0);
                         if (tx != NULL)
-                                cfs_list_add_tail(&tx->tx_list,
+                               list_add_tail(&tx->tx_list,
                                                   &peer->ibp_tx_queue);
                        write_unlock_irqrestore(g_lock, flags);
                } else {
@@ -1415,12 +1415,12 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 
         peer2 = kiblnd_find_peer_locked(nid);
         if (peer2 != NULL) {
-                if (cfs_list_empty(&peer2->ibp_conns)) {
+               if (list_empty(&peer2->ibp_conns)) {
                         /* found a peer, but it's still connecting... */
                         LASSERT (peer2->ibp_connecting != 0 ||
                                  peer2->ibp_accepting != 0);
                         if (tx != NULL)
-                                cfs_list_add_tail(&tx->tx_list,
+                               list_add_tail(&tx->tx_list,
                                                   &peer2->ibp_tx_queue);
                        write_unlock_irqrestore(g_lock, flags);
                } else {
@@ -1446,10 +1446,10 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
         LASSERT (((kib_net_t *)ni->ni_data)->ibn_shutdown == 0);
 
         if (tx != NULL)
-                cfs_list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
+               list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
 
         kiblnd_peer_addref(peer);
-        cfs_list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
+       list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
 
        write_unlock_irqrestore(g_lock, flags);
 
@@ -1838,7 +1838,7 @@ kiblnd_peer_notify (kib_peer_t *peer)
 
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        if (cfs_list_empty(&peer->ibp_conns) &&
+       if (list_empty(&peer->ibp_conns) &&
             peer->ibp_accepting == 0 &&
             peer->ibp_connecting == 0 &&
             peer->ibp_error != 0) {
@@ -1877,28 +1877,30 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
                 return; /* already being handled  */
 
         if (error == 0 &&
-            cfs_list_empty(&conn->ibc_tx_noops) &&
-            cfs_list_empty(&conn->ibc_tx_queue) &&
-            cfs_list_empty(&conn->ibc_tx_queue_rsrvd) &&
-            cfs_list_empty(&conn->ibc_tx_queue_nocred) &&
-            cfs_list_empty(&conn->ibc_active_txs)) {
+           list_empty(&conn->ibc_tx_noops) &&
+           list_empty(&conn->ibc_tx_queue) &&
+           list_empty(&conn->ibc_tx_queue_rsrvd) &&
+           list_empty(&conn->ibc_tx_queue_nocred) &&
+           list_empty(&conn->ibc_active_txs)) {
                 CDEBUG(D_NET, "closing conn to %s\n", 
                        libcfs_nid2str(peer->ibp_nid));
         } else {
                 CNETERR("Closing conn to %s: error %d%s%s%s%s%s\n",
                        libcfs_nid2str(peer->ibp_nid), error,
-                       cfs_list_empty(&conn->ibc_tx_queue) ? "" : "(sending)",
-                       cfs_list_empty(&conn->ibc_tx_noops) ? "" : "(sending_noops)",
-                       cfs_list_empty(&conn->ibc_tx_queue_rsrvd) ? "" : "(sending_rsrvd)",
-                       cfs_list_empty(&conn->ibc_tx_queue_nocred) ? "" : "(sending_nocred)",
-                       cfs_list_empty(&conn->ibc_active_txs) ? "" : "(waiting)");
+                      list_empty(&conn->ibc_tx_queue) ? "" : "(sending)",
+                      list_empty(&conn->ibc_tx_noops) ? "" : "(sending_noops)",
+                      list_empty(&conn->ibc_tx_queue_rsrvd) ?
+                                               "" : "(sending_rsrvd)",
+                      list_empty(&conn->ibc_tx_queue_nocred) ?
+                                                "" : "(sending_nocred)",
+                      list_empty(&conn->ibc_active_txs) ? "" : "(waiting)");
         }
 
         dev = ((kib_net_t *)peer->ibp_ni->ni_data)->ibn_dev;
-        cfs_list_del(&conn->ibc_list);
+       list_del(&conn->ibc_list);
         /* connd (see below) takes over ibc_list's ref */
 
-        if (cfs_list_empty (&peer->ibp_conns) &&    /* no more conns */
+       if (list_empty(&peer->ibp_conns) &&    /* no more conns */
             kiblnd_peer_active(peer)) {         /* still in peer table */
                 kiblnd_unlink_peer_locked(peer);
 
@@ -1910,14 +1912,14 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
 
        if (error != 0 &&
            kiblnd_dev_can_failover(dev)) {
-               cfs_list_add_tail(&dev->ibd_fail_list,
+               list_add_tail(&dev->ibd_fail_list,
                              &kiblnd_data.kib_failed_devs);
                wake_up(&kiblnd_data.kib_failover_waitq);
        }
 
        spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);
 
-       cfs_list_add_tail(&conn->ibc_list, &kiblnd_data.kib_connd_conns);
+       list_add_tail(&conn->ibc_list, &kiblnd_data.kib_connd_conns);
        wake_up(&kiblnd_data.kib_connd_waitq);
 
        spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);
@@ -1945,10 +1947,10 @@ kiblnd_handle_early_rxs(kib_conn_t *conn)
        LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
-       while (!cfs_list_empty(&conn->ibc_early_rxs)) {
-               rx = cfs_list_entry(conn->ibc_early_rxs.next,
+       while (!list_empty(&conn->ibc_early_rxs)) {
+               rx = list_entry(conn->ibc_early_rxs.next,
                                    kib_rx_t, rx_list);
-               cfs_list_del(&rx->rx_list);
+               list_del(&rx->rx_list);
                write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
                kiblnd_handle_rx(rx);
@@ -1959,35 +1961,35 @@ kiblnd_handle_early_rxs(kib_conn_t *conn)
 }
 
 void
-kiblnd_abort_txs(kib_conn_t *conn, cfs_list_t *txs)
+kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
 {
-        CFS_LIST_HEAD       (zombies);
-        cfs_list_t          *tmp;
-        cfs_list_t          *nxt;
-        kib_tx_t            *tx;
+       struct list_head         zombies = LIST_HEAD_INIT(zombies);
+       struct list_head        *tmp;
+       struct list_head        *nxt;
+       kib_tx_t                *tx;
 
        spin_lock(&conn->ibc_lock);
 
-        cfs_list_for_each_safe (tmp, nxt, txs) {
-                tx = cfs_list_entry (tmp, kib_tx_t, tx_list);
+       list_for_each_safe(tmp, nxt, txs) {
+               tx = list_entry(tmp, kib_tx_t, tx_list);
 
-                if (txs == &conn->ibc_active_txs) {
-                        LASSERT (!tx->tx_queued);
-                        LASSERT (tx->tx_waiting ||
-                                 tx->tx_sending != 0);
-                } else {
-                        LASSERT (tx->tx_queued);
-                }
+               if (txs == &conn->ibc_active_txs) {
+                       LASSERT(!tx->tx_queued);
+                       LASSERT(tx->tx_waiting ||
+                               tx->tx_sending != 0);
+               } else {
+                       LASSERT(tx->tx_queued);
+               }
 
-                tx->tx_status = -ECONNABORTED;
-                tx->tx_waiting = 0;
+               tx->tx_status = -ECONNABORTED;
+               tx->tx_waiting = 0;
 
-                if (tx->tx_sending == 0) {
-                        tx->tx_queued = 0;
-                        cfs_list_del (&tx->tx_list);
-                        cfs_list_add (&tx->tx_list, &zombies);
-                }
-        }
+               if (tx->tx_sending == 0) {
+                       tx->tx_queued = 0;
+                       list_del(&tx->tx_list);
+                       list_add(&tx->tx_list, &zombies);
+               }
+       }
 
        spin_unlock(&conn->ibc_lock);
 
@@ -2022,8 +2024,8 @@ kiblnd_finalise_conn (kib_conn_t *conn)
 void
 kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error)
 {
-       CFS_LIST_HEAD    (zombies);
-       unsigned long     flags;
+       struct list_head zombies = LIST_HEAD_INIT(zombies);
+       unsigned long   flags;
 
        LASSERT (error != 0);
        LASSERT (!in_interrupt());
@@ -2039,48 +2041,48 @@ kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error)
        }
 
        if (peer->ibp_connecting != 0 ||
-            peer->ibp_accepting != 0) {
-                /* another connection attempt under way... */
+           peer->ibp_accepting != 0) {
+               /* another connection attempt under way... */
                write_unlock_irqrestore(&kiblnd_data.kib_global_lock,
-                                            flags);
-                return;
-        }
+                                       flags);
+               return;
+       }
 
-        if (cfs_list_empty(&peer->ibp_conns)) {
-                /* Take peer's blocked transmits to complete with error */
-                cfs_list_add(&zombies, &peer->ibp_tx_queue);
-                cfs_list_del_init(&peer->ibp_tx_queue);
+       if (list_empty(&peer->ibp_conns)) {
+               /* Take peer's blocked transmits to complete with error */
+               list_add(&zombies, &peer->ibp_tx_queue);
+               list_del_init(&peer->ibp_tx_queue);
 
-                if (kiblnd_peer_active(peer))
-                        kiblnd_unlink_peer_locked(peer);
+               if (kiblnd_peer_active(peer))
+                       kiblnd_unlink_peer_locked(peer);
 
-                peer->ibp_error = error;
-        } else {
-                /* Can't have blocked transmits if there are connections */
-                LASSERT (cfs_list_empty(&peer->ibp_tx_queue));
-        }
+               peer->ibp_error = error;
+       } else {
+               /* Can't have blocked transmits if there are connections */
+               LASSERT(list_empty(&peer->ibp_tx_queue));
+       }
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        kiblnd_peer_notify(peer);
+       kiblnd_peer_notify(peer);
 
-        if (cfs_list_empty (&zombies))
-                return;
+       if (list_empty(&zombies))
+               return;
 
-        CNETERR("Deleting messages for %s: connection failed\n",
-                libcfs_nid2str(peer->ibp_nid));
+       CNETERR("Deleting messages for %s: connection failed\n",
+               libcfs_nid2str(peer->ibp_nid));
 
-        kiblnd_txlist_done(peer->ibp_ni, &zombies, -EHOSTUNREACH);
+       kiblnd_txlist_done(peer->ibp_ni, &zombies, -EHOSTUNREACH);
 }
 
 void
 kiblnd_connreq_done(kib_conn_t *conn, int status)
 {
-        kib_peer_t        *peer = conn->ibc_peer;
-        kib_tx_t          *tx;
-        cfs_list_t         txs;
-        unsigned long      flags;
-        int                active;
+       kib_peer_t       *peer = conn->ibc_peer;
+       kib_tx_t         *tx;
+       struct list_head txs;
+       unsigned long    flags;
+       int              active;
 
         active = (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
 
@@ -2111,14 +2113,14 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
         kiblnd_set_conn_state(conn, IBLND_CONN_ESTABLISHED);
         kiblnd_peer_alive(peer);
 
-        /* Add conn to peer's list and nuke any dangling conns from a different
-         * peer instance... */
-        kiblnd_conn_addref(conn);               /* +1 ref for ibc_list */
-        cfs_list_add(&conn->ibc_list, &peer->ibp_conns);
-        if (active)
-                peer->ibp_connecting--;
-        else
-                peer->ibp_accepting--;
+       /* Add conn to peer's list and nuke any dangling conns from a different
+        * peer instance... */
+       kiblnd_conn_addref(conn);       /* +1 ref for ibc_list */
+       list_add(&conn->ibc_list, &peer->ibp_conns);
+       if (active)
+               peer->ibp_connecting--;
+       else
+               peer->ibp_accepting--;
 
         if (peer->ibp_version == 0) {
                 peer->ibp_version     = conn->ibc_version;
@@ -2133,9 +2135,9 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
                 peer->ibp_incarnation = conn->ibc_incarnation;
         }
 
-        /* grab pending txs while I have the lock */
-        cfs_list_add(&txs, &peer->ibp_tx_queue);
-        cfs_list_del_init(&peer->ibp_tx_queue);
+       /* grab pending txs while I have the lock */
+       list_add(&txs, &peer->ibp_tx_queue);
+       list_del_init(&peer->ibp_tx_queue);
 
         if (!kiblnd_peer_active(peer) ||        /* peer has been deleted */
             conn->ibc_comms_error != 0) {       /* error has happened already */
@@ -2154,9 +2156,9 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
 
        /* Schedule blocked txs */
        spin_lock(&conn->ibc_lock);
-       while (!cfs_list_empty(&txs)) {
-               tx = cfs_list_entry(txs.next, kib_tx_t, tx_list);
-               cfs_list_del(&tx->tx_list);
+       while (!list_empty(&txs)) {
+               tx = list_entry(txs.next, kib_tx_t, tx_list);
+               list_del(&tx->tx_list);
 
                kiblnd_queue_tx_locked(tx, conn);
        }
@@ -2383,7 +2385,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                 LASSERT (net->ibn_shutdown == 0);
 
                 kiblnd_peer_addref(peer);
-                cfs_list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
+               list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
 
                write_unlock_irqrestore(g_lock, flags);
         }
@@ -2472,7 +2474,7 @@ kiblnd_reconnect (kib_conn_t *conn, int version,
          * NB: reconnect is still needed even when ibp_tx_queue is
          * empty if ibp_version != version because reconnect may be
          * initiated by kiblnd_query() */
-        if ((!cfs_list_empty(&peer->ibp_tx_queue) ||
+       if ((!list_empty(&peer->ibp_tx_queue) ||
              peer->ibp_version != version) &&
             peer->ibp_connecting == 1 &&
             peer->ibp_accepting == 0) {
@@ -2994,30 +2996,30 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
 }
 
 static int
-kiblnd_check_txs_locked(kib_conn_t *conn, cfs_list_t *txs)
+kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs)
 {
-        kib_tx_t          *tx;
-        cfs_list_t        *ttmp;
+       kib_tx_t         *tx;
+       struct list_head *ttmp;
 
-        cfs_list_for_each (ttmp, txs) {
-                tx = cfs_list_entry (ttmp, kib_tx_t, tx_list);
+       list_for_each(ttmp, txs) {
+               tx = list_entry(ttmp, kib_tx_t, tx_list);
 
-                if (txs != &conn->ibc_active_txs) {
-                        LASSERT (tx->tx_queued);
-                } else {
-                        LASSERT (!tx->tx_queued);
-                        LASSERT (tx->tx_waiting || tx->tx_sending != 0);
-                }
+               if (txs != &conn->ibc_active_txs) {
+                       LASSERT(tx->tx_queued);
+               } else {
+                       LASSERT(!tx->tx_queued);
+                       LASSERT(tx->tx_waiting || tx->tx_sending != 0);
+               }
 
-                if (cfs_time_aftereq (jiffies, tx->tx_deadline)) {
-                        CERROR("Timed out tx: %s, %lu seconds\n",
-                               kiblnd_queue2str(conn, txs),
-                               cfs_duration_sec(jiffies - tx->tx_deadline));
-                        return 1;
-                }
-        }
+               if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+                       CERROR("Timed out tx: %s, %lu seconds\n",
+                              kiblnd_queue2str(conn, txs),
+                              cfs_duration_sec(jiffies - tx->tx_deadline));
+                       return 1;
+               }
+       }
 
-        return 0;
+       return 0;
 }
 
 static int
@@ -3033,30 +3035,30 @@ kiblnd_conn_timed_out_locked(kib_conn_t *conn)
 void
 kiblnd_check_conns (int idx)
 {
-        CFS_LIST_HEAD (closes);
-        CFS_LIST_HEAD (checksends);
-        cfs_list_t    *peers = &kiblnd_data.kib_peers[idx];
-        cfs_list_t    *ptmp;
-        kib_peer_t    *peer;
-        kib_conn_t    *conn;
-        cfs_list_t    *ctmp;
-        unsigned long  flags;
+       struct list_head  closes = LIST_HEAD_INIT(closes);
+       struct list_head  checksends = LIST_HEAD_INIT(checksends);
+       struct list_head *peers = &kiblnd_data.kib_peers[idx];
+       struct list_head *ptmp;
+       kib_peer_t       *peer;
+       kib_conn_t       *conn;
+       struct list_head *ctmp;
+       unsigned long     flags;
 
         /* NB. We expect to have a look at all the peers and not find any
          * RDMAs to time out, so we just use a shared lock while we
          * take a look... */
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-        cfs_list_for_each (ptmp, peers) {
-                peer = cfs_list_entry (ptmp, kib_peer_t, ibp_list);
+       list_for_each(ptmp, peers) {
+               peer = list_entry(ptmp, kib_peer_t, ibp_list);
 
-                cfs_list_for_each (ctmp, &peer->ibp_conns) {
-                        int timedout;
-                        int sendnoop;
+               list_for_each(ctmp, &peer->ibp_conns) {
+                       int timedout;
+                       int sendnoop;
 
-                        conn = cfs_list_entry(ctmp, kib_conn_t, ibc_list);
+                       conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                        LASSERT (conn->ibc_state == IBLND_CONN_ESTABLISHED);
+                       LASSERT(conn->ibc_state == IBLND_CONN_ESTABLISHED);
 
                        spin_lock(&conn->ibc_lock);
 
@@ -3064,25 +3066,24 @@ kiblnd_check_conns (int idx)
                        timedout = kiblnd_conn_timed_out_locked(conn);
                        if (!sendnoop && !timedout) {
                                spin_unlock(&conn->ibc_lock);
-                                continue;
-                        }
+                               continue;
+                       }
 
-                        if (timedout) {
-                                CERROR("Timed out RDMA with %s (%lu): "
-                                       "c: %u, oc: %u, rc: %u\n",
-                                       libcfs_nid2str(peer->ibp_nid),
-                                       cfs_duration_sec(cfs_time_current() -
-                                                        peer->ibp_last_alive),
-                                       conn->ibc_credits,
-                                       conn->ibc_outstanding_credits,
-                                       conn->ibc_reserved_credits);
-                                cfs_list_add(&conn->ibc_connd_list, &closes);
-                        } else {
-                                cfs_list_add(&conn->ibc_connd_list,
-                                             &checksends);
-                        }
-                        /* +ref for 'closes' or 'checksends' */
-                        kiblnd_conn_addref(conn);
+                       if (timedout) {
+                               CERROR("Timed out RDMA with %s (%lu): "
+                                      "c: %u, oc: %u, rc: %u\n",
+                                      libcfs_nid2str(peer->ibp_nid),
+                                      cfs_duration_sec(cfs_time_current() -
+                                                       peer->ibp_last_alive),
+                                      conn->ibc_credits,
+                                      conn->ibc_outstanding_credits,
+                                      conn->ibc_reserved_credits);
+                               list_add(&conn->ibc_connd_list, &closes);
+                       } else {
+                               list_add(&conn->ibc_connd_list, &checksends);
+                       }
+                       /* +ref for 'closes' or 'checksends' */
+                       kiblnd_conn_addref(conn);
 
                        spin_unlock(&conn->ibc_lock);
                }
@@ -3090,27 +3091,27 @@ kiblnd_check_conns (int idx)
 
        read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        /* Handle timeout by closing the whole
-         * connection. We can only be sure RDMA activity
-         * has ceased once the QP has been modified. */
-        while (!cfs_list_empty(&closes)) {
-                conn = cfs_list_entry(closes.next,
-                                      kib_conn_t, ibc_connd_list);
-                cfs_list_del(&conn->ibc_connd_list);
-                kiblnd_close_conn(conn, -ETIMEDOUT);
-                kiblnd_conn_decref(conn);
-        }
+       /* Handle timeout by closing the whole
+        * connection. We can only be sure RDMA activity
+        * has ceased once the QP has been modified. */
+       while (!list_empty(&closes)) {
+               conn = list_entry(closes.next,
+                                 kib_conn_t, ibc_connd_list);
+               list_del(&conn->ibc_connd_list);
+               kiblnd_close_conn(conn, -ETIMEDOUT);
+               kiblnd_conn_decref(conn);
+       }
 
-        /* In case we have enough credits to return via a
-         * NOOP, but there were no non-blocking tx descs
-         * free to do it last time... */
-        while (!cfs_list_empty(&checksends)) {
-                conn = cfs_list_entry(checksends.next,
-                                      kib_conn_t, ibc_connd_list);
-                cfs_list_del(&conn->ibc_connd_list);
-                kiblnd_check_sends(conn);
-                kiblnd_conn_decref(conn);
-        }
+       /* In case we have enough credits to return via a
+        * NOOP, but there were no non-blocking tx descs
+        * free to do it last time... */
+       while (!list_empty(&checksends)) {
+               conn = list_entry(checksends.next,
+                                 kib_conn_t, ibc_connd_list);
+               list_del(&conn->ibc_connd_list);
+               kiblnd_check_sends(conn);
+               kiblnd_conn_decref(conn);
+       }
 }
 
 void
@@ -3149,11 +3150,11 @@ kiblnd_connd (void *arg)
 
                 dropped_lock = 0;
 
-                if (!cfs_list_empty (&kiblnd_data.kib_connd_zombies)) {
-                        conn = cfs_list_entry(kiblnd_data. \
+               if (!list_empty(&kiblnd_data.kib_connd_zombies)) {
+                       conn = list_entry(kiblnd_data. \
                                               kib_connd_zombies.next,
                                               kib_conn_t, ibc_list);
-                        cfs_list_del(&conn->ibc_list);
+                       list_del(&conn->ibc_list);
 
                        spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock,
                                               flags);
@@ -3164,10 +3165,10 @@ kiblnd_connd (void *arg)
                        spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);
                }
 
-               if (!cfs_list_empty(&kiblnd_data.kib_connd_conns)) {
-                       conn = cfs_list_entry(kiblnd_data.kib_connd_conns.next,
+               if (!list_empty(&kiblnd_data.kib_connd_conns)) {
+                       conn = list_entry(kiblnd_data.kib_connd_conns.next,
                                              kib_conn_t, ibc_list);
-                       cfs_list_del(&conn->ibc_list);
+                       list_del(&conn->ibc_list);
 
                        spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock,
                                               flags);
@@ -3304,7 +3305,7 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg)
             conn->ibc_nsends_posted > 0)) {
                kiblnd_conn_addref(conn); /* +1 ref for sched_conns */
                conn->ibc_scheduled = 1;
-               cfs_list_add_tail(&conn->ibc_sched_list, &sched->ibs_conns);
+               list_add_tail(&conn->ibc_sched_list, &sched->ibs_conns);
 
                if (waitqueue_active(&sched->ibs_waitq))
                        wake_up(&sched->ibs_waitq);
@@ -3363,12 +3364,12 @@ kiblnd_scheduler(void *arg)
 
                did_something = 0;
 
-               if (!cfs_list_empty(&sched->ibs_conns)) {
-                       conn = cfs_list_entry(sched->ibs_conns.next,
+               if (!list_empty(&sched->ibs_conns)) {
+                       conn = list_entry(sched->ibs_conns.next,
                                              kib_conn_t, ibc_sched_list);
                        /* take over kib_sched_conns' ref on conn... */
                        LASSERT(conn->ibc_scheduled);
-                       cfs_list_del(&conn->ibc_sched_list);
+                       list_del(&conn->ibc_sched_list);
                        conn->ibc_ready = 0;
 
                        spin_unlock_irqrestore(&sched->ibs_lock, flags);
@@ -3410,7 +3411,7 @@ kiblnd_scheduler(void *arg)
                                 * this one... */
                                /* +1 ref for sched_conns */
                                kiblnd_conn_addref(conn);
-                               cfs_list_add_tail(&conn->ibc_sched_list,
+                               list_add_tail(&conn->ibc_sched_list,
                                                  &sched->ibs_conns);
                                if (waitqueue_active(&sched->ibs_waitq))
                                        wake_up(&sched->ibs_waitq);
@@ -3470,7 +3471,7 @@ kiblnd_failover_thread(void *arg)
                 int     do_failover = 0;
                 int     long_sleep;
 
-                cfs_list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
+               list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
                                     ibd_fail_list) {
                         if (cfs_time_before(cfs_time_current(),
                                             dev->ibd_next_failover))
@@ -3480,7 +3481,7 @@ kiblnd_failover_thread(void *arg)
                 }
 
                 if (do_failover) {
-                        cfs_list_del_init(&dev->ibd_fail_list);
+                       list_del_init(&dev->ibd_fail_list);
                         dev->ibd_failover = 1;
                        write_unlock_irqrestore(glock, flags);
 
@@ -3499,7 +3500,7 @@ kiblnd_failover_thread(void *arg)
                         dev->ibd_next_failover =
                                 cfs_time_shift(min(dev->ibd_failed_failover, 10));
                         if (kiblnd_dev_can_failover(dev)) {
-                                cfs_list_add_tail(&dev->ibd_fail_list,
+                               list_add_tail(&dev->ibd_fail_list,
                                               &kiblnd_data.kib_failed_devs);
                         }
 
@@ -3507,7 +3508,7 @@ kiblnd_failover_thread(void *arg)
                 }
 
                 /* long sleep if no more pending failover */
-                long_sleep = cfs_list_empty(&kiblnd_data.kib_failed_devs);
+               long_sleep = list_empty(&kiblnd_data.kib_failed_devs);
 
                set_current_state(TASK_INTERRUPTIBLE);
                add_wait_queue(&kiblnd_data.kib_failover_waitq, &wait);
@@ -3526,9 +3527,9 @@ kiblnd_failover_thread(void *arg)
                  * we need checking like this because if there is not active
                  * connection on the dev and no SEND from local, we may listen
                  * on wrong HCA for ever while there is a bonding failover */
-                cfs_list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
+               list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
                         if (kiblnd_dev_can_failover(dev)) {
-                                cfs_list_add_tail(&dev->ibd_fail_list,
+                               list_add_tail(&dev->ibd_fail_list,
                                               &kiblnd_data.kib_failed_devs);
                         }
                 }
index 9d65d38..e798cf8 100644 (file)
@@ -124,10 +124,10 @@ ksocknal_create_peer (ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
        peer->ksnp_last_alive = 0;
        peer->ksnp_zc_next_cookie = SOCKNAL_KEEPALIVE_PING + 1;
 
-        CFS_INIT_LIST_HEAD (&peer->ksnp_conns);
-        CFS_INIT_LIST_HEAD (&peer->ksnp_routes);
-        CFS_INIT_LIST_HEAD (&peer->ksnp_tx_queue);
-        CFS_INIT_LIST_HEAD (&peer->ksnp_zc_req_list);
+       INIT_LIST_HEAD(&peer->ksnp_conns);
+       INIT_LIST_HEAD(&peer->ksnp_routes);
+       INIT_LIST_HEAD(&peer->ksnp_tx_queue);
+       INIT_LIST_HEAD(&peer->ksnp_zc_req_list);
        spin_lock_init(&peer->ksnp_lock);
 
        spin_lock_bh(&net->ksnn_lock);
@@ -156,14 +156,14 @@ ksocknal_destroy_peer (ksock_peer_t *peer)
        CDEBUG (D_NET, "peer %s %p deleted\n",
                libcfs_id2str(peer->ksnp_id), peer);
 
-       LASSERT (atomic_read (&peer->ksnp_refcount) == 0);
-       LASSERT (peer->ksnp_accepting == 0);
-       LASSERT (cfs_list_empty (&peer->ksnp_conns));
-       LASSERT (cfs_list_empty (&peer->ksnp_routes));
-       LASSERT (cfs_list_empty (&peer->ksnp_tx_queue));
-       LASSERT (cfs_list_empty (&peer->ksnp_zc_req_list));
+       LASSERT(atomic_read(&peer->ksnp_refcount) == 0);
+       LASSERT(peer->ksnp_accepting == 0);
+       LASSERT(list_empty(&peer->ksnp_conns));
+       LASSERT(list_empty(&peer->ksnp_routes));
+       LASSERT(list_empty(&peer->ksnp_tx_queue));
+       LASSERT(list_empty(&peer->ksnp_zc_req_list));
 
-        LIBCFS_FREE (peer, sizeof (*peer));
+       LIBCFS_FREE(peer, sizeof(*peer));
 
         /* NB a peer's connections and routes keep a reference on their peer
          * until they are destroyed, so we can be assured that _all_ state to
@@ -177,29 +177,29 @@ ksocknal_destroy_peer (ksock_peer_t *peer)
 ksock_peer_t *
 ksocknal_find_peer_locked (lnet_ni_t *ni, lnet_process_id_t id)
 {
-        cfs_list_t       *peer_list = ksocknal_nid2peerlist(id.nid);
-        cfs_list_t       *tmp;
-        ksock_peer_t     *peer;
+       struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
+       struct list_head *tmp;
+       ksock_peer_t     *peer;
 
-        cfs_list_for_each (tmp, peer_list) {
+       list_for_each(tmp, peer_list) {
 
-                peer = cfs_list_entry (tmp, ksock_peer_t, ksnp_list);
+               peer = list_entry(tmp, ksock_peer_t, ksnp_list);
 
-                LASSERT (!peer->ksnp_closing);
+               LASSERT(!peer->ksnp_closing);
 
-                if (peer->ksnp_ni != ni)
-                        continue;
+               if (peer->ksnp_ni != ni)
+                       continue;
 
-                if (peer->ksnp_id.nid != id.nid ||
-                    peer->ksnp_id.pid != id.pid)
-                        continue;
+               if (peer->ksnp_id.nid != id.nid ||
+                   peer->ksnp_id.pid != id.pid)
+                       continue;
 
                CDEBUG(D_NET, "got peer [%p] -> %s (%d)\n",
                       peer, libcfs_id2str(id),
                       atomic_read(&peer->ksnp_refcount));
-               return (peer);
+               return peer;
        }
-       return (NULL);
+       return NULL;
 }
 
 ksock_peer_t *
@@ -237,13 +237,13 @@ ksocknal_unlink_peer_locked (ksock_peer_t *peer)
                 iface->ksni_npeers--;
         }
 
-        LASSERT (cfs_list_empty(&peer->ksnp_conns));
-        LASSERT (cfs_list_empty(&peer->ksnp_routes));
-        LASSERT (!peer->ksnp_closing);
-        peer->ksnp_closing = 1;
-        cfs_list_del (&peer->ksnp_list);
-        /* lose peerlist's ref */
-        ksocknal_peer_decref(peer);
+       LASSERT(list_empty(&peer->ksnp_conns));
+       LASSERT(list_empty(&peer->ksnp_routes));
+       LASSERT(!peer->ksnp_closing);
+       peer->ksnp_closing = 1;
+       list_del(&peer->ksnp_list);
+       /* lose peerlist's ref */
+       ksocknal_peer_decref(peer);
 }
 
 int
@@ -251,28 +251,27 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index,
                         lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip,
                         int *port, int *conn_count, int *share_count)
 {
-        ksock_peer_t      *peer;
-        cfs_list_t        *ptmp;
-        ksock_route_t     *route;
-        cfs_list_t        *rtmp;
-        int                i;
+       ksock_peer_t      *peer;
+       struct list_head  *ptmp;
+       ksock_route_t     *route;
+       struct list_head  *rtmp;
+       int                i;
         int                j;
-        int                rc = -ENOENT;
+       int                rc = -ENOENT;
 
        read_lock(&ksocknal_data.ksnd_global_lock);
 
-        for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
+       for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
+               list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
-                cfs_list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) {
-                        peer = cfs_list_entry (ptmp, ksock_peer_t, ksnp_list);
+                       if (peer->ksnp_ni != ni)
+                               continue;
 
-                        if (peer->ksnp_ni != ni)
-                                continue;
-
-                        if (peer->ksnp_n_passive_ips == 0 &&
-                            cfs_list_empty(&peer->ksnp_routes)) {
-                                if (index-- > 0)
-                                        continue;
+                       if (peer->ksnp_n_passive_ips == 0 &&
+                           list_empty(&peer->ksnp_routes)) {
+                               if (index-- > 0)
+                                       continue;
 
                                 *id = peer->ksnp_id;
                                 *myip = 0;
@@ -284,9 +283,9 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index,
                                 goto out;
                         }
 
-                        for (j = 0; j < peer->ksnp_n_passive_ips; j++) {
-                                if (index-- > 0)
-                                        continue;
+                       for (j = 0; j < peer->ksnp_n_passive_ips; j++) {
+                               if (index-- > 0)
+                                       continue;
 
                                 *id = peer->ksnp_id;
                                 *myip = peer->ksnp_passive_ips[j];
@@ -298,27 +297,27 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index,
                                 goto out;
                         }
 
-                        cfs_list_for_each (rtmp, &peer->ksnp_routes) {
-                                if (index-- > 0)
-                                        continue;
-
-                                route = cfs_list_entry(rtmp, ksock_route_t,
-                                                       ksnr_list);
+                       list_for_each(rtmp, &peer->ksnp_routes) {
+                               if (index-- > 0)
+                                       continue;
 
-                                *id = peer->ksnp_id;
-                                *myip = route->ksnr_myipaddr;
-                                *peer_ip = route->ksnr_ipaddr;
-                                *port = route->ksnr_port;
-                                *conn_count = route->ksnr_conn_count;
-                                *share_count = route->ksnr_share_count;
-                                rc = 0;
-                                goto out;
-                        }
-                }
-        }
- out:
+                               route = list_entry(rtmp, ksock_route_t,
+                                                  ksnr_list);
+
+                               *id = peer->ksnp_id;
+                               *myip = route->ksnr_myipaddr;
+                               *peer_ip = route->ksnr_ipaddr;
+                               *port = route->ksnr_port;
+                               *conn_count = route->ksnr_conn_count;
+                               *share_count = route->ksnr_share_count;
+                               rc = 0;
+                               goto out;
+                       }
+               }
+       }
+out:
        read_unlock(&ksocknal_data.ksnd_global_lock);
-        return (rc);
+       return rc;
 }
 
 void
@@ -369,93 +368,93 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
 void
 ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route)
 {
-        cfs_list_t        *tmp;
-        ksock_conn_t      *conn;
-        ksock_route_t     *route2;
-
-        LASSERT (!peer->ksnp_closing);
-        LASSERT (route->ksnr_peer == NULL);
-        LASSERT (!route->ksnr_scheduled);
-        LASSERT (!route->ksnr_connecting);
-        LASSERT (route->ksnr_connected == 0);
-
-        /* LASSERT(unique) */
-        cfs_list_for_each(tmp, &peer->ksnp_routes) {
-                route2 = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
-
-                if (route2->ksnr_ipaddr == route->ksnr_ipaddr) {
-                        CERROR ("Duplicate route %s %u.%u.%u.%u\n",
-                                libcfs_id2str(peer->ksnp_id),
-                                HIPQUAD(route->ksnr_ipaddr));
-                        LBUG();
-                }
-        }
+       struct list_head *tmp;
+       ksock_conn_t     *conn;
+       ksock_route_t    *route2;
+
+       LASSERT(!peer->ksnp_closing);
+       LASSERT(route->ksnr_peer == NULL);
+       LASSERT(!route->ksnr_scheduled);
+       LASSERT(!route->ksnr_connecting);
+       LASSERT(route->ksnr_connected == 0);
+
+       /* LASSERT(unique) */
+       list_for_each(tmp, &peer->ksnp_routes) {
+               route2 = list_entry(tmp, ksock_route_t, ksnr_list);
+
+               if (route2->ksnr_ipaddr == route->ksnr_ipaddr) {
+                       CERROR("Duplicate route %s %u.%u.%u.%u\n",
+                              libcfs_id2str(peer->ksnp_id),
+                              HIPQUAD(route->ksnr_ipaddr));
+                       LBUG();
+               }
+       }
 
-        route->ksnr_peer = peer;
-        ksocknal_peer_addref(peer);
-        /* peer's routelist takes over my ref on 'route' */
-        cfs_list_add_tail(&route->ksnr_list, &peer->ksnp_routes);
+       route->ksnr_peer = peer;
+       ksocknal_peer_addref(peer);
+       /* peer's routelist takes over my ref on 'route' */
+       list_add_tail(&route->ksnr_list, &peer->ksnp_routes);
 
-        cfs_list_for_each(tmp, &peer->ksnp_conns) {
-                conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+       list_for_each(tmp, &peer->ksnp_conns) {
+               conn = list_entry(tmp, ksock_conn_t, ksnc_list);
 
-                if (conn->ksnc_ipaddr != route->ksnr_ipaddr)
-                        continue;
+               if (conn->ksnc_ipaddr != route->ksnr_ipaddr)
+                       continue;
 
-                ksocknal_associate_route_conn_locked(route, conn);
-                /* keep going (typed routes) */
-        }
+               ksocknal_associate_route_conn_locked(route, conn);
+               /* keep going (typed routes) */
+       }
 }
 
 void
 ksocknal_del_route_locked (ksock_route_t *route)
 {
-        ksock_peer_t      *peer = route->ksnr_peer;
-        ksock_interface_t *iface;
-        ksock_conn_t      *conn;
-        cfs_list_t        *ctmp;
-        cfs_list_t        *cnxt;
+       ksock_peer_t      *peer = route->ksnr_peer;
+       ksock_interface_t *iface;
+       ksock_conn_t      *conn;
+       struct list_head  *ctmp;
+       struct list_head  *cnxt;
 
-        LASSERT (!route->ksnr_deleted);
+       LASSERT(!route->ksnr_deleted);
 
-        /* Close associated conns */
-        cfs_list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) {
-                conn = cfs_list_entry(ctmp, ksock_conn_t, ksnc_list);
+       /* Close associated conns */
+       list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
+               conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
 
-                if (conn->ksnc_route != route)
-                        continue;
+               if (conn->ksnc_route != route)
+                       continue;
 
-                ksocknal_close_conn_locked (conn, 0);
-        }
+               ksocknal_close_conn_locked(conn, 0);
+       }
 
-        if (route->ksnr_myipaddr != 0) {
-                iface = ksocknal_ip2iface(route->ksnr_peer->ksnp_ni,
-                                          route->ksnr_myipaddr);
-                if (iface != NULL)
-                        iface->ksni_nroutes--;
-        }
+       if (route->ksnr_myipaddr != 0) {
+               iface = ksocknal_ip2iface(route->ksnr_peer->ksnp_ni,
+                                         route->ksnr_myipaddr);
+               if (iface != NULL)
+                       iface->ksni_nroutes--;
+       }
 
-        route->ksnr_deleted = 1;
-        cfs_list_del (&route->ksnr_list);
-        ksocknal_route_decref(route);             /* drop peer's ref */
+       route->ksnr_deleted = 1;
+       list_del(&route->ksnr_list);
+       ksocknal_route_decref(route);           /* drop peer's ref */
 
-        if (cfs_list_empty (&peer->ksnp_routes) &&
-            cfs_list_empty (&peer->ksnp_conns)) {
-                /* I've just removed the last route to a peer with no active
-                 * connections */
-                ksocknal_unlink_peer_locked (peer);
-        }
+       if (list_empty(&peer->ksnp_routes) &&
+           list_empty(&peer->ksnp_conns)) {
+               /* I've just removed the last route to a peer with no active
+                * connections */
+               ksocknal_unlink_peer_locked(peer);
+       }
 }
 
 int
-ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
+ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
 {
-        cfs_list_t        *tmp;
-        ksock_peer_t      *peer;
-        ksock_peer_t      *peer2;
-        ksock_route_t     *route;
-        ksock_route_t     *route2;
-        int                rc;
+       struct list_head *tmp;
+       ksock_peer_t     *peer;
+       ksock_peer_t     *peer2;
+       ksock_route_t    *route;
+       ksock_route_t    *route2;
+       int               rc;
 
         if (id.nid == LNET_NID_ANY ||
             id.pid == LNET_PID_ANY)
@@ -477,188 +476,192 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
         /* always called with a ref on ni, so shutdown can't have started */
         LASSERT (((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
 
-        peer2 = ksocknal_find_peer_locked (ni, id);
-        if (peer2 != NULL) {
-                ksocknal_peer_decref(peer);
-                peer = peer2;
-        } else {
-                /* peer table takes my ref on peer */
-                cfs_list_add_tail (&peer->ksnp_list,
-                                   ksocknal_nid2peerlist (id.nid));
-        }
+       peer2 = ksocknal_find_peer_locked(ni, id);
+       if (peer2 != NULL) {
+               ksocknal_peer_decref(peer);
+               peer = peer2;
+       } else {
+               /* peer table takes my ref on peer */
+               list_add_tail(&peer->ksnp_list,
+                             ksocknal_nid2peerlist(id.nid));
+       }
 
-        route2 = NULL;
-        cfs_list_for_each (tmp, &peer->ksnp_routes) {
-                route2 = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
+       route2 = NULL;
+       list_for_each(tmp, &peer->ksnp_routes) {
+               route2 = list_entry(tmp, ksock_route_t, ksnr_list);
 
-                if (route2->ksnr_ipaddr == ipaddr)
-                        break;
+               if (route2->ksnr_ipaddr == ipaddr)
+                       break;
 
-                route2 = NULL;
-        }
-        if (route2 == NULL) {
-                ksocknal_add_route_locked(peer, route);
-                route->ksnr_share_count++;
-        } else {
-                ksocknal_route_decref(route);
-                route2->ksnr_share_count++;
-        }
+               route2 = NULL;
+       }
+       if (route2 == NULL) {
+               ksocknal_add_route_locked(peer, route);
+               route->ksnr_share_count++;
+       } else {
+               ksocknal_route_decref(route);
+               route2->ksnr_share_count++;
+       }
 
        write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-        return (0);
+       return 0;
 }
 
 void
 ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
 {
-        ksock_conn_t     *conn;
-        ksock_route_t    *route;
-        cfs_list_t       *tmp;
-        cfs_list_t       *nxt;
-        int               nshared;
+       ksock_conn_t     *conn;
+       ksock_route_t    *route;
+       struct list_head *tmp;
+       struct list_head *nxt;
+       int               nshared;
 
-        LASSERT (!peer->ksnp_closing);
+       LASSERT(!peer->ksnp_closing);
 
-        /* Extra ref prevents peer disappearing until I'm done with it */
-        ksocknal_peer_addref(peer);
+       /* Extra ref prevents peer disappearing until I'm done with it */
+       ksocknal_peer_addref(peer);
 
-        cfs_list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
-                route = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
+       list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
+               route = list_entry(tmp, ksock_route_t, ksnr_list);
 
-                /* no match */
-                if (!(ip == 0 || route->ksnr_ipaddr == ip))
-                        continue;
+               /* no match */
+               if (!(ip == 0 || route->ksnr_ipaddr == ip))
+                       continue;
 
-                route->ksnr_share_count = 0;
-                /* This deletes associated conns too */
-                ksocknal_del_route_locked (route);
-        }
+               route->ksnr_share_count = 0;
+               /* This deletes associated conns too */
+               ksocknal_del_route_locked(route);
+       }
 
-        nshared = 0;
-        cfs_list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
-                route = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
-                nshared += route->ksnr_share_count;
-        }
+       nshared = 0;
+       list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
+               route = list_entry(tmp, ksock_route_t, ksnr_list);
+               nshared += route->ksnr_share_count;
+       }
 
-        if (nshared == 0) {
-                /* remove everything else if there are no explicit entries
-                 * left */
+       if (nshared == 0) {
+               /* remove everything else if there are no explicit entries
+                * left */
 
-                cfs_list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
-                        route = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
+               list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
+                       route = list_entry(tmp, ksock_route_t, ksnr_list);
 
-                        /* we should only be removing auto-entries */
-                        LASSERT(route->ksnr_share_count == 0);
-                        ksocknal_del_route_locked (route);
-                }
+                       /* we should only be removing auto-entries */
+                       LASSERT(route->ksnr_share_count == 0);
+                       ksocknal_del_route_locked(route);
+               }
 
-                cfs_list_for_each_safe (tmp, nxt, &peer->ksnp_conns) {
-                        conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+               list_for_each_safe(tmp, nxt, &peer->ksnp_conns) {
+                       conn = list_entry(tmp, ksock_conn_t, ksnc_list);
 
-                        ksocknal_close_conn_locked(conn, 0);
-                }
-        }
+                       ksocknal_close_conn_locked(conn, 0);
+               }
+       }
 
-        ksocknal_peer_decref(peer);
-        /* NB peer unlinks itself when last conn/route is removed */
+       ksocknal_peer_decref(peer);
+               /* NB peer unlinks itself when last conn/route is removed */
 }
 
 int
 ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
 {
-        CFS_LIST_HEAD     (zombies);
-        cfs_list_t        *ptmp;
-        cfs_list_t        *pnxt;
-        ksock_peer_t      *peer;
-        int                lo;
-        int                hi;
-        int                i;
-        int                rc = -ENOENT;
+       struct list_head  zombies = LIST_HEAD_INIT(zombies);
+       struct list_head *ptmp;
+       struct list_head *pnxt;
+       ksock_peer_t     *peer;
+       int               lo;
+       int               hi;
+       int               i;
+       int               rc = -ENOENT;
 
        write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
-        if (id.nid != LNET_NID_ANY)
-                lo = hi = (int)(ksocknal_nid2peerlist(id.nid) - ksocknal_data.ksnd_peers);
-        else {
-                lo = 0;
-                hi = ksocknal_data.ksnd_peer_hash_size - 1;
-        }
+       if (id.nid != LNET_NID_ANY) {
+               hi = (int)(ksocknal_nid2peerlist(id.nid) -
+                          ksocknal_data.ksnd_peers);
+               lo = hi;
+       } else {
+               lo = 0;
+               hi = ksocknal_data.ksnd_peer_hash_size - 1;
+       }
 
-        for (i = lo; i <= hi; i++) {
-                cfs_list_for_each_safe (ptmp, pnxt,
-                                        &ksocknal_data.ksnd_peers[i]) {
-                        peer = cfs_list_entry (ptmp, ksock_peer_t, ksnp_list);
+       for (i = lo; i <= hi; i++) {
+               list_for_each_safe(ptmp, pnxt,
+                                  &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
-                        if (peer->ksnp_ni != ni)
-                                continue;
+                       if (peer->ksnp_ni != ni)
+                               continue;
 
-                        if (!((id.nid == LNET_NID_ANY || peer->ksnp_id.nid == id.nid) &&
-                              (id.pid == LNET_PID_ANY || peer->ksnp_id.pid == id.pid)))
-                                continue;
+                       if (!((id.nid == LNET_NID_ANY ||
+                              peer->ksnp_id.nid == id.nid) &&
+                             (id.pid == LNET_PID_ANY ||
+                              peer->ksnp_id.pid == id.pid)))
+                               continue;
 
-                        ksocknal_peer_addref(peer);     /* a ref for me... */
+                       ksocknal_peer_addref(peer);     /* a ref for me... */
 
-                        ksocknal_del_peer_locked (peer, ip);
+                       ksocknal_del_peer_locked(peer, ip);
 
-                        if (peer->ksnp_closing &&
-                            !cfs_list_empty(&peer->ksnp_tx_queue)) {
-                                LASSERT (cfs_list_empty(&peer->ksnp_conns));
-                                LASSERT (cfs_list_empty(&peer->ksnp_routes));
+                       if (peer->ksnp_closing &&
+                           !list_empty(&peer->ksnp_tx_queue)) {
+                               LASSERT(list_empty(&peer->ksnp_conns));
+                               LASSERT(list_empty(&peer->ksnp_routes));
 
-                                cfs_list_splice_init(&peer->ksnp_tx_queue,
-                                                     &zombies);
-                        }
+                               list_splice_init(&peer->ksnp_tx_queue,
+                                                &zombies);
+                       }
 
-                        ksocknal_peer_decref(peer);     /* ...till here */
+                       ksocknal_peer_decref(peer);     /* ...till here */
 
-                        rc = 0;                 /* matched! */
-                }
-        }
+                       rc = 0;                         /* matched! */
+               }
+       }
 
        write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-        ksocknal_txlist_done(ni, &zombies, 1);
+       ksocknal_txlist_done(ni, &zombies, 1);
 
-        return (rc);
+       return rc;
 }
 
 ksock_conn_t *
 ksocknal_get_conn_by_idx (lnet_ni_t *ni, int index)
 {
-        ksock_peer_t      *peer;
-        cfs_list_t        *ptmp;
-        ksock_conn_t      *conn;
-        cfs_list_t        *ctmp;
-        int                i;
+       ksock_peer_t     *peer;
+       struct list_head *ptmp;
+       ksock_conn_t     *conn;
+       struct list_head *ctmp;
+       int               i;
 
        read_lock(&ksocknal_data.ksnd_global_lock);
 
-        for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-                cfs_list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) {
-                        peer = cfs_list_entry (ptmp, ksock_peer_t, ksnp_list);
+       for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
+               list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
-                        LASSERT (!peer->ksnp_closing);
+                       LASSERT(!peer->ksnp_closing);
 
-                        if (peer->ksnp_ni != ni)
-                                continue;
+                       if (peer->ksnp_ni != ni)
+                               continue;
 
-                        cfs_list_for_each (ctmp, &peer->ksnp_conns) {
-                                if (index-- > 0)
-                                        continue;
+                       list_for_each(ctmp, &peer->ksnp_conns) {
+                               if (index-- > 0)
+                                       continue;
 
-                                conn = cfs_list_entry (ctmp, ksock_conn_t,
-                                                       ksnc_list);
-                                ksocknal_conn_addref(conn);
+                               conn = list_entry(ctmp, ksock_conn_t,
+                                                 ksnc_list);
+                               ksocknal_conn_addref(conn);
                                read_unlock(&ksocknal_data. \
-                                                 ksnd_global_lock);
-                                return (conn);
-                        }
-                }
-        }
+                                           ksnd_global_lock);
+                               return conn;
+                       }
+               }
+       }
 
        read_unlock(&ksocknal_data.ksnd_global_lock);
-        return (NULL);
+       return NULL;
 }
 
 ksock_sched_t *
@@ -854,19 +857,19 @@ void
 ksocknal_create_routes(ksock_peer_t *peer, int port,
                        __u32 *peer_ipaddrs, int npeer_ipaddrs)
 {
-        ksock_route_t       *newroute = NULL;
+       ksock_route_t           *newroute = NULL;
        rwlock_t                *global_lock = &ksocknal_data.ksnd_global_lock;
-        lnet_ni_t           *ni = peer->ksnp_ni;
-        ksock_net_t         *net = ni->ni_data;
-        cfs_list_t          *rtmp;
-        ksock_route_t       *route;
-        ksock_interface_t   *iface;
-        ksock_interface_t   *best_iface;
-        int                  best_netmatch;
-        int                  this_netmatch;
-        int                  best_nroutes;
-        int                  i;
-        int                  j;
+       lnet_ni_t               *ni = peer->ksnp_ni;
+       ksock_net_t             *net = ni->ni_data;
+       struct list_head        *rtmp;
+       ksock_route_t           *route;
+       ksock_interface_t       *iface;
+       ksock_interface_t       *best_iface;
+       int                     best_netmatch;
+       int                     this_netmatch;
+       int                     best_nroutes;
+       int                     i;
+       int                     j;
 
         /* CAVEAT EMPTOR: We do all our interface matching with an
          * exclusive hold of global lock at IRQ priority.  We're only
@@ -902,41 +905,41 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
                         break;
                 }
 
-                /* Already got a route? */
-                route = NULL;
-                cfs_list_for_each(rtmp, &peer->ksnp_routes) {
-                        route = cfs_list_entry(rtmp, ksock_route_t, ksnr_list);
+               /* Already got a route? */
+               route = NULL;
+               list_for_each(rtmp, &peer->ksnp_routes) {
+                       route = list_entry(rtmp, ksock_route_t, ksnr_list);
 
-                        if (route->ksnr_ipaddr == newroute->ksnr_ipaddr)
-                                break;
+                       if (route->ksnr_ipaddr == newroute->ksnr_ipaddr)
+                               break;
 
-                        route = NULL;
-                }
-                if (route != NULL)
-                        continue;
+                       route = NULL;
+               }
+               if (route != NULL)
+                       continue;
 
-                best_iface = NULL;
-                best_nroutes = 0;
-                best_netmatch = 0;
+               best_iface = NULL;
+               best_nroutes = 0;
+               best_netmatch = 0;
 
-                LASSERT (net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
+               LASSERT(net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
 
-                /* Select interface to connect from */
-                for (j = 0; j < net->ksnn_ninterfaces; j++) {
-                        iface = &net->ksnn_interfaces[j];
+               /* Select interface to connect from */
+               for (j = 0; j < net->ksnn_ninterfaces; j++) {
+                       iface = &net->ksnn_interfaces[j];
 
-                        /* Using this interface already? */
-                        cfs_list_for_each(rtmp, &peer->ksnp_routes) {
-                                route = cfs_list_entry(rtmp, ksock_route_t,
-                                                       ksnr_list);
+                       /* Using this interface already? */
+                       list_for_each(rtmp, &peer->ksnp_routes) {
+                               route = list_entry(rtmp, ksock_route_t,
+                                                  ksnr_list);
 
-                                if (route->ksnr_myipaddr == iface->ksni_ipaddr)
-                                        break;
+                               if (route->ksnr_myipaddr == iface->ksni_ipaddr)
+                                       break;
 
-                                route = NULL;
-                        }
-                        if (route != NULL)
-                                continue;
+                               route = NULL;
+                       }
+                       if (route != NULL)
+                               continue;
 
                         this_netmatch = (((iface->ksni_ipaddr ^
                                            newroute->ksnr_ipaddr) &
@@ -987,31 +990,29 @@ ksocknal_accept (lnet_ni_t *ni, cfs_socket_t *sock)
                 return -ENOMEM;
         }
 
-        lnet_ni_addref(ni);
-        cr->ksncr_ni   = ni;
-        cr->ksncr_sock = sock;
+       lnet_ni_addref(ni);
+       cr->ksncr_ni   = ni;
+       cr->ksncr_sock = sock;
 
        spin_lock_bh(&ksocknal_data.ksnd_connd_lock);
 
-       cfs_list_add_tail(&cr->ksncr_list, &ksocknal_data.ksnd_connd_connreqs);
+       list_add_tail(&cr->ksncr_list, &ksocknal_data.ksnd_connd_connreqs);
        wake_up(&ksocknal_data.ksnd_connd_waitq);
 
        spin_unlock_bh(&ksocknal_data.ksnd_connd_lock);
-        return 0;
+       return 0;
 }
 
 int
 ksocknal_connecting (ksock_peer_t *peer, __u32 ipaddr)
 {
-        ksock_route_t   *route;
-
-        cfs_list_for_each_entry_typed (route, &peer->ksnp_routes,
-                                       ksock_route_t, ksnr_list) {
+       ksock_route_t *route;
 
-                if (route->ksnr_ipaddr == ipaddr)
-                        return route->ksnr_connecting;
-        }
-        return 0;
+       list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) {
+               if (route->ksnr_ipaddr == ipaddr)
+                       return route->ksnr_connecting;
+       }
+       return 0;
 }
 
 int
@@ -1019,9 +1020,9 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                       cfs_socket_t *sock, int type)
 {
        rwlock_t                *global_lock = &ksocknal_data.ksnd_global_lock;
-        CFS_LIST_HEAD     (zombies);
-        lnet_process_id_t  peerid;
-        cfs_list_t        *tmp;
+       struct list_head        zombies = LIST_HEAD_INIT(zombies);
+       lnet_process_id_t       peerid;
+       struct list_head        *tmp;
         __u64              incarnation;
         ksock_conn_t      *conn;
         ksock_conn_t      *conn2;
@@ -1061,7 +1062,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
        conn->ksnc_rx_ready = 0;
        conn->ksnc_rx_scheduled = 0;
 
-       CFS_INIT_LIST_HEAD (&conn->ksnc_tx_queue);
+       INIT_LIST_HEAD(&conn->ksnc_tx_queue);
        conn->ksnc_tx_ready = 0;
        conn->ksnc_tx_scheduled = 0;
        conn->ksnc_tx_carrier = NULL;
@@ -1140,16 +1141,16 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                 /* called with a ref on ni, so shutdown can't have started */
                 LASSERT (((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
 
-                peer2 = ksocknal_find_peer_locked(ni, peerid);
-                if (peer2 == NULL) {
-                        /* NB this puts an "empty" peer in the peer
-                         * table (which takes my ref) */
-                        cfs_list_add_tail(&peer->ksnp_list,
-                                          ksocknal_nid2peerlist(peerid.nid));
-                } else {
-                        ksocknal_peer_decref(peer);
-                        peer = peer2;
-                }
+               peer2 = ksocknal_find_peer_locked(ni, peerid);
+               if (peer2 == NULL) {
+                       /* NB this puts an "empty" peer in the peer
+                        * table (which takes my ref) */
+                       list_add_tail(&peer->ksnp_list,
+                                     ksocknal_nid2peerlist(peerid.nid));
+               } else {
+                       ksocknal_peer_decref(peer);
+                       peer = peer2;
+               }
 
                 /* +1 ref for me */
                 ksocknal_peer_addref(peer);
@@ -1173,16 +1174,16 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                 goto failed_2;
         }
 
-        if (peer->ksnp_proto == NULL) {
-                /* Never connected before.
-                 * NB recv_hello may have returned EPROTO to signal my peer
-                 * wants a different protocol than the one I asked for.
-                 */
-                LASSERT (cfs_list_empty(&peer->ksnp_conns));
+       if (peer->ksnp_proto == NULL) {
+               /* Never connected before.
+                * NB recv_hello may have returned EPROTO to signal my peer
+                * wants a different protocol than the one I asked for.
+                */
+               LASSERT(list_empty(&peer->ksnp_conns));
 
-                peer->ksnp_proto = conn->ksnc_proto;
-                peer->ksnp_incarnation = incarnation;
-        }
+               peer->ksnp_proto = conn->ksnc_proto;
+               peer->ksnp_incarnation = incarnation;
+       }
 
         if (peer->ksnp_proto != conn->ksnc_proto ||
             peer->ksnp_incarnation != incarnation) {
@@ -1210,11 +1211,11 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                 goto failed_2;
         }
 
-        /* Refuse to duplicate an existing connection, unless this is a
-         * loopback connection */
-        if (conn->ksnc_ipaddr != conn->ksnc_myipaddr) {
-                cfs_list_for_each(tmp, &peer->ksnp_conns) {
-                        conn2 = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+       /* Refuse to duplicate an existing connection, unless this is a
+        * loopback connection */
+       if (conn->ksnc_ipaddr != conn->ksnc_myipaddr) {
+               list_for_each(tmp, &peer->ksnp_conns) {
+                       conn2 = list_entry(tmp, ksock_conn_t, ksnc_list);
 
                         if (conn2->ksnc_ipaddr != conn->ksnc_ipaddr ||
                             conn2->ksnc_myipaddr != conn->ksnc_myipaddr ||
@@ -1243,19 +1244,19 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                        HIPQUAD(conn->ksnc_ipaddr));
         }
 
-        /* Search for a route corresponding to the new connection and
-         * create an association.  This allows incoming connections created
-         * by routes in my peer to match my own route entries so I don't
-         * continually create duplicate routes. */
-        cfs_list_for_each (tmp, &peer->ksnp_routes) {
-                route = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
+       /* Search for a route corresponding to the new connection and
+        * create an association.  This allows incoming connections created
+        * by routes in my peer to match my own route entries so I don't
+        * continually create duplicate routes. */
+       list_for_each(tmp, &peer->ksnp_routes) {
+               route = list_entry(tmp, ksock_route_t, ksnr_list);
 
-                if (route->ksnr_ipaddr != conn->ksnc_ipaddr)
-                        continue;
+               if (route->ksnr_ipaddr != conn->ksnc_ipaddr)
+                       continue;
 
-                ksocknal_associate_route_conn_locked(route, conn);
-                break;
-        }
+               ksocknal_associate_route_conn_locked(route, conn);
+               break;
+       }
 
         conn->ksnc_peer = peer;                 /* conn takes my ref on peer */
         peer->ksnp_last_alive = cfs_time_current();
@@ -1272,21 +1273,22 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
        conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
        smp_mb();   /* order with adding to peer's conn list */
 
-       cfs_list_add (&conn->ksnc_list, &peer->ksnp_conns);
+       list_add(&conn->ksnc_list, &peer->ksnp_conns);
        ksocknal_conn_addref(conn);
 
        ksocknal_new_packet(conn, 0);
 
         conn->ksnc_zc_capable = ksocknal_lib_zc_capable(conn);
 
-        /* Take packets blocking for this connection. */
-        cfs_list_for_each_entry_safe(tx, txtmp, &peer->ksnp_tx_queue, tx_list) {
-                if (conn->ksnc_proto->pro_match_tx(conn, tx, tx->tx_nonblk) == SOCKNAL_MATCH_NO)
-                                continue;
+       /* Take packets blocking for this connection. */
+       list_for_each_entry_safe(tx, txtmp, &peer->ksnp_tx_queue, tx_list) {
+               if (conn->ksnc_proto->pro_match_tx(conn, tx, tx->tx_nonblk) ==
+                   SOCKNAL_MATCH_NO)
+                       continue;
 
-                cfs_list_del (&tx->tx_list);
-                ksocknal_queue_tx_locked (tx, conn);
-        }
+               list_del(&tx->tx_list);
+               ksocknal_queue_tx_locked(tx, conn);
+       }
 
        write_unlock_bh(global_lock);
 
@@ -1354,14 +1356,14 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
         ksocknal_conn_decref(conn);
         return rc;
 
- failed_2:
-        if (!peer->ksnp_closing &&
-            cfs_list_empty (&peer->ksnp_conns) &&
-            cfs_list_empty (&peer->ksnp_routes)) {
-                cfs_list_add(&zombies, &peer->ksnp_tx_queue);
-                cfs_list_del_init(&peer->ksnp_tx_queue);
-                ksocknal_unlink_peer_locked(peer);
-        }
+failed_2:
+       if (!peer->ksnp_closing &&
+           list_empty(&peer->ksnp_conns) &&
+           list_empty(&peer->ksnp_routes)) {
+               list_add(&zombies, &peer->ksnp_tx_queue);
+               list_del_init(&peer->ksnp_tx_queue);
+               ksocknal_unlink_peer_locked(peer);
+       }
 
        write_unlock_bh(global_lock);
 
@@ -1412,78 +1414,80 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
         ksock_peer_t      *peer = conn->ksnc_peer;
         ksock_route_t     *route;
         ksock_conn_t      *conn2;
-        cfs_list_t        *tmp;
+       struct list_head  *tmp;
 
-        LASSERT (peer->ksnp_error == 0);
-        LASSERT (!conn->ksnc_closing);
-        conn->ksnc_closing = 1;
+       LASSERT(peer->ksnp_error == 0);
+       LASSERT(!conn->ksnc_closing);
+       conn->ksnc_closing = 1;
 
-        /* ksnd_deathrow_conns takes over peer's ref */
-        cfs_list_del (&conn->ksnc_list);
+       /* ksnd_deathrow_conns takes over peer's ref */
+       list_del(&conn->ksnc_list);
 
-        route = conn->ksnc_route;
-        if (route != NULL) {
-                /* dissociate conn from route... */
-                LASSERT (!route->ksnr_deleted);
-                LASSERT ((route->ksnr_connected & (1 << conn->ksnc_type)) != 0);
+       route = conn->ksnc_route;
+       if (route != NULL) {
+               /* dissociate conn from route... */
+               LASSERT(!route->ksnr_deleted);
+               LASSERT((route->ksnr_connected & (1 << conn->ksnc_type)) != 0);
 
-                conn2 = NULL;
-                cfs_list_for_each(tmp, &peer->ksnp_conns) {
-                        conn2 = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+               conn2 = NULL;
+               list_for_each(tmp, &peer->ksnp_conns) {
+                       conn2 = list_entry(tmp, ksock_conn_t, ksnc_list);
 
-                        if (conn2->ksnc_route == route &&
-                            conn2->ksnc_type == conn->ksnc_type)
-                                break;
+                       if (conn2->ksnc_route == route &&
+                           conn2->ksnc_type == conn->ksnc_type)
+                               break;
 
-                        conn2 = NULL;
-                }
-                if (conn2 == NULL)
-                        route->ksnr_connected &= ~(1 << conn->ksnc_type);
+                       conn2 = NULL;
+               }
+               if (conn2 == NULL)
+                       route->ksnr_connected &= ~(1 << conn->ksnc_type);
 
-                conn->ksnc_route = NULL;
+               conn->ksnc_route = NULL;
 
-#if 0           /* irrelevent with only eager routes */
-                /* make route least favourite */
-                cfs_list_del (&route->ksnr_list);
-                cfs_list_add_tail (&route->ksnr_list, &peer->ksnp_routes);
+#if 0          /* irrelevent with only eager routes */
+               /* make route least favourite */
+               list_del(&route->ksnr_list);
+               list_add_tail(&route->ksnr_list, &peer->ksnp_routes);
 #endif
-                ksocknal_route_decref(route);     /* drop conn's ref on route */
-        }
+               ksocknal_route_decref(route);   /* drop conn's ref on route */
+       }
 
-        if (cfs_list_empty (&peer->ksnp_conns)) {
-                /* No more connections to this peer */
+       if (list_empty(&peer->ksnp_conns)) {
+               /* No more connections to this peer */
 
-                if (!cfs_list_empty(&peer->ksnp_tx_queue)) {
-                        ksock_tx_t *tx;
+               if (!list_empty(&peer->ksnp_tx_queue)) {
+                               ksock_tx_t *tx;
 
-                        LASSERT (conn->ksnc_proto == &ksocknal_protocol_v3x);
+                       LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x);
 
-                        /* throw them to the last connection...,
-                         * these TXs will be send to /dev/null by scheduler */
-                        cfs_list_for_each_entry(tx, &peer->ksnp_tx_queue,
-                                                tx_list)
-                                ksocknal_tx_prep(conn, tx);
+                       /* throw them to the last connection...,
+                        * these TXs will be send to /dev/null by scheduler */
+                       list_for_each_entry(tx, &peer->ksnp_tx_queue,
+                                           tx_list)
+                               ksocknal_tx_prep(conn, tx);
 
                        spin_lock_bh(&conn->ksnc_scheduler->kss_lock);
-                       cfs_list_splice_init(&peer->ksnp_tx_queue,
-                                            &conn->ksnc_tx_queue);
+                       list_splice_init(&peer->ksnp_tx_queue,
+                                        &conn->ksnc_tx_queue);
                        spin_unlock_bh(&conn->ksnc_scheduler->kss_lock);
-                }
+               }
 
-                peer->ksnp_proto = NULL;        /* renegotiate protocol version */
-                peer->ksnp_error = error;       /* stash last conn close reason */
+               /* renegotiate protocol version */
+               peer->ksnp_proto = NULL;
+               /* stash last conn close reason */
+               peer->ksnp_error = error;
 
-                if (cfs_list_empty (&peer->ksnp_routes)) {
-                        /* I've just closed last conn belonging to a
-                         * peer with no routes to it */
-                        ksocknal_unlink_peer_locked (peer);
-                }
-        }
+               if (list_empty(&peer->ksnp_routes)) {
+                       /* I've just closed last conn belonging to a
+                        * peer with no routes to it */
+                       ksocknal_unlink_peer_locked(peer);
+               }
+       }
 
        spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
 
-       cfs_list_add_tail(&conn->ksnc_list,
-                         &ksocknal_data.ksnd_deathrow_conns);
+       list_add_tail(&conn->ksnc_list,
+                     &ksocknal_data.ksnd_deathrow_conns);
        wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
        spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock);
@@ -1501,60 +1505,59 @@ ksocknal_peer_failed (ksock_peer_t *peer)
 
        read_lock(&ksocknal_data.ksnd_global_lock);
 
-        if ((peer->ksnp_id.pid & LNET_PID_USERFLAG) == 0 &&
-            cfs_list_empty(&peer->ksnp_conns) &&
-            peer->ksnp_accepting == 0 &&
-            ksocknal_find_connecting_route_locked(peer) == NULL) {
-                notify = 1;
-                last_alive = peer->ksnp_last_alive;
-        }
+       if ((peer->ksnp_id.pid & LNET_PID_USERFLAG) == 0 &&
+            list_empty(&peer->ksnp_conns) &&
+            peer->ksnp_accepting == 0 &&
+            ksocknal_find_connecting_route_locked(peer) == NULL) {
+               notify = 1;
+               last_alive = peer->ksnp_last_alive;
+       }
 
        read_unlock(&ksocknal_data.ksnd_global_lock);
 
-        if (notify)
-                lnet_notify (peer->ksnp_ni, peer->ksnp_id.nid, 0,
-                             last_alive);
+       if (notify)
+               lnet_notify(peer->ksnp_ni, peer->ksnp_id.nid, 0,
+                           last_alive);
 }
 
 void
 ksocknal_finalize_zcreq(ksock_conn_t *conn)
 {
-        ksock_peer_t     *peer = conn->ksnc_peer;
-        ksock_tx_t       *tx;
-        ksock_tx_t       *tmp;
-        CFS_LIST_HEAD    (zlist);
+       ksock_peer_t     *peer = conn->ksnc_peer;
+       ksock_tx_t       *tx;
+       ksock_tx_t       *tmp;
+       struct list_head  zlist = LIST_HEAD_INIT(zlist);
 
-        /* NB safe to finalize TXs because closing of socket will
-         * abort all buffered data */
-        LASSERT (conn->ksnc_sock == NULL);
+       /* NB safe to finalize TXs because closing of socket will
+        * abort all buffered data */
+       LASSERT(conn->ksnc_sock == NULL);
 
        spin_lock(&peer->ksnp_lock);
 
-        cfs_list_for_each_entry_safe_typed(tx, tmp, &peer->ksnp_zc_req_list,
-                                           ksock_tx_t, tx_zc_list) {
-                if (tx->tx_conn != conn)
-                        continue;
+       list_for_each_entry_safe(tx, tmp, &peer->ksnp_zc_req_list, tx_zc_list) {
+               if (tx->tx_conn != conn)
+                       continue;
 
-                LASSERT (tx->tx_msg.ksm_zc_cookies[0] != 0);
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] != 0);
 
-                tx->tx_msg.ksm_zc_cookies[0] = 0;
-                tx->tx_zc_aborted = 1; /* mark it as not-acked */
-                cfs_list_del(&tx->tx_zc_list);
-                cfs_list_add(&tx->tx_zc_list, &zlist);
-        }
+               tx->tx_msg.ksm_zc_cookies[0] = 0;
+               tx->tx_zc_aborted = 1;  /* mark it as not-acked */
+               list_del(&tx->tx_zc_list);
+               list_add(&tx->tx_zc_list, &zlist);
+       }
 
        spin_unlock(&peer->ksnp_lock);
 
-        while (!cfs_list_empty(&zlist)) {
-                tx = cfs_list_entry(zlist.next, ksock_tx_t, tx_zc_list);
+       while (!list_empty(&zlist)) {
+               tx = list_entry(zlist.next, ksock_tx_t, tx_zc_list);
 
-                cfs_list_del(&tx->tx_zc_list);
-                ksocknal_tx_decref(tx);
-        }
+               list_del(&tx->tx_zc_list);
+               ksocknal_tx_decref(tx);
+       }
 }
 
 void
-ksocknal_terminate_conn (ksock_conn_t *conn)
+ksocknal_terminate_conn(ksock_conn_t *conn)
 {
         /* This gets called by the reaper (guaranteed thread context) to
          * disengage the socket from its callbacks and close it.
@@ -1573,8 +1576,8 @@ ksocknal_terminate_conn (ksock_conn_t *conn)
         conn->ksnc_tx_ready = 1;
 
         if (!conn->ksnc_tx_scheduled &&
-            !cfs_list_empty(&conn->ksnc_tx_queue)){
-                cfs_list_add_tail (&conn->ksnc_tx_list,
+           !list_empty(&conn->ksnc_tx_queue)) {
+               list_add_tail(&conn->ksnc_tx_list,
                                &sched->kss_tx_conns);
                 conn->ksnc_tx_scheduled = 1;
                 /* extra ref for scheduler */
@@ -1596,7 +1599,7 @@ ksocknal_terminate_conn (ksock_conn_t *conn)
 
         if (peer->ksnp_error != 0) {
                 /* peer's last conn closed in error */
-                LASSERT (cfs_list_empty (&peer->ksnp_conns));
+               LASSERT(list_empty(&peer->ksnp_conns));
                 failed = 1;
                 peer->ksnp_error = 0;     /* avoid multiple notifications */
         }
@@ -1622,7 +1625,7 @@ ksocknal_queue_zombie_conn (ksock_conn_t *conn)
        LASSERT(atomic_read(&conn->ksnc_conn_refcount) == 0);
        spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
 
-       cfs_list_add_tail(&conn->ksnc_list, &ksocknal_data.ksnd_zombie_conns);
+       list_add_tail(&conn->ksnc_list, &ksocknal_data.ksnd_zombie_conns);
        wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
        spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock);
@@ -1642,7 +1645,7 @@ ksocknal_destroy_conn (ksock_conn_t *conn)
        LASSERT (conn->ksnc_route == NULL);
        LASSERT (!conn->ksnc_tx_scheduled);
        LASSERT (!conn->ksnc_rx_scheduled);
-       LASSERT (cfs_list_empty(&conn->ksnc_tx_queue));
+       LASSERT(list_empty(&conn->ksnc_tx_queue));
 
         /* complete current receive if any */
         switch (conn->ksnc_rx_state) {
@@ -1697,12 +1700,12 @@ int
 ksocknal_close_peer_conns_locked (ksock_peer_t *peer, __u32 ipaddr, int why)
 {
         ksock_conn_t       *conn;
-        cfs_list_t         *ctmp;
-        cfs_list_t         *cnxt;
+       struct list_head         *ctmp;
+       struct list_head         *cnxt;
         int                 count = 0;
 
-        cfs_list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) {
-                conn = cfs_list_entry (ctmp, ksock_conn_t, ksnc_list);
+       list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
+               conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
 
                 if (ipaddr == 0 ||
                     conn->ksnc_ipaddr == ipaddr) {
@@ -1734,8 +1737,8 @@ int
 ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr)
 {
         ksock_peer_t       *peer;
-        cfs_list_t         *ptmp;
-        cfs_list_t         *pnxt;
+       struct list_head         *ptmp;
+       struct list_head         *pnxt;
         int                 lo;
         int                 hi;
         int                 i;
@@ -1751,10 +1754,9 @@ ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr)
         }
 
         for (i = lo; i <= hi; i++) {
-                cfs_list_for_each_safe (ptmp, pnxt,
-                                        &ksocknal_data.ksnd_peers[i]) {
+               list_for_each_safe(ptmp, pnxt, &ksocknal_data.ksnd_peers[i]) {
 
-                        peer = cfs_list_entry (ptmp, ksock_peer_t, ksnp_list);
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
                         if (!((id.nid == LNET_NID_ANY || id.nid == peer->ksnp_id.nid) &&
                               (id.pid == LNET_PID_ANY || id.pid == peer->ksnp_id.pid)))
@@ -1810,12 +1812,12 @@ ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
 
         peer = ksocknal_find_peer_locked(ni, id);
         if (peer != NULL) {
-                cfs_list_t       *tmp;
+               struct list_head       *tmp;
                 ksock_conn_t     *conn;
                 int               bufnob;
 
-                cfs_list_for_each (tmp, &peer->ksnp_conns) {
-                        conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+               list_for_each(tmp, &peer->ksnp_conns) {
+                       conn = list_entry(tmp, ksock_conn_t, ksnc_list);
                         bufnob = libcfs_sock_wmem_queued(conn->ksnc_sock);
 
                         if (bufnob < conn->ksnc_tx_bufnob) {
@@ -1862,7 +1864,7 @@ ksocknal_push_peer (ksock_peer_t *peer)
 {
         int               index;
         int               i;
-        cfs_list_t       *tmp;
+       struct list_head       *tmp;
         ksock_conn_t     *conn;
 
         for (index = 0; ; index++) {
@@ -1871,9 +1873,9 @@ ksocknal_push_peer (ksock_peer_t *peer)
                 i = 0;
                 conn = NULL;
 
-                cfs_list_for_each (tmp, &peer->ksnp_conns) {
+               list_for_each(tmp, &peer->ksnp_conns) {
                         if (i++ == index) {
-                                conn = cfs_list_entry (tmp, ksock_conn_t,
+                               conn = list_entry(tmp, ksock_conn_t,
                                                        ksnc_list);
                                 ksocknal_conn_addref(conn);
                                 break;
@@ -1894,7 +1896,7 @@ int
 ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
 {
         ksock_peer_t      *peer;
-        cfs_list_t        *tmp;
+       struct list_head        *tmp;
         int                index;
         int                i;
         int                j;
@@ -1907,8 +1909,8 @@ ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
                         index = 0;
                         peer = NULL;
 
-                        cfs_list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) {
-                                peer = cfs_list_entry(tmp, ksock_peer_t,
+                       list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
+                               peer = list_entry(tmp, ksock_peer_t,
                                                       ksnp_list);
 
                                 if (!((id.nid == LNET_NID_ANY ||
@@ -1947,9 +1949,9 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
         int                rc;
         int                i;
         int                j;
-        cfs_list_t        *ptmp;
+       struct list_head        *ptmp;
         ksock_peer_t      *peer;
-        cfs_list_t        *rtmp;
+       struct list_head        *rtmp;
         ksock_route_t     *route;
 
         if (ipaddress == 0 ||
@@ -1973,16 +1975,16 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
                 iface->ksni_npeers = 0;
 
                 for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-                        cfs_list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
-                                peer = cfs_list_entry(ptmp, ksock_peer_t,
+                       list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
+                               peer = list_entry(ptmp, ksock_peer_t,
                                                       ksnp_list);
 
                                 for (j = 0; j < peer->ksnp_n_passive_ips; j++)
                                         if (peer->ksnp_passive_ips[j] == ipaddress)
                                                 iface->ksni_npeers++;
 
-                                cfs_list_for_each(rtmp, &peer->ksnp_routes) {
-                                        route = cfs_list_entry(rtmp,
+                               list_for_each(rtmp, &peer->ksnp_routes) {
+                                       route = list_entry(rtmp,
                                                                ksock_route_t,
                                                                ksnr_list);
 
@@ -2004,8 +2006,8 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
 void
 ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
 {
-        cfs_list_t         *tmp;
-        cfs_list_t         *nxt;
+       struct list_head         *tmp;
+       struct list_head         *nxt;
         ksock_route_t      *route;
         ksock_conn_t       *conn;
         int                 i;
@@ -2020,8 +2022,8 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
                         break;
                 }
 
-        cfs_list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
-                route = cfs_list_entry (tmp, ksock_route_t, ksnr_list);
+       list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
+               route = list_entry(tmp, ksock_route_t, ksnr_list);
 
                 if (route->ksnr_myipaddr != ipaddr)
                         continue;
@@ -2034,8 +2036,8 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
                 }
         }
 
-        cfs_list_for_each_safe(tmp, nxt, &peer->ksnp_conns) {
-                conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+       list_for_each_safe(tmp, nxt, &peer->ksnp_conns) {
+               conn = list_entry(tmp, ksock_conn_t, ksnc_list);
 
                 if (conn->ksnc_myipaddr == ipaddr)
                         ksocknal_close_conn_locked (conn, 0);
@@ -2047,8 +2049,8 @@ ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress)
 {
         ksock_net_t       *net = ni->ni_data;
         int                rc = -ENOENT;
-        cfs_list_t        *tmp;
-        cfs_list_t        *nxt;
+       struct list_head        *tmp;
+       struct list_head        *nxt;
         ksock_peer_t      *peer;
         __u32              this_ip;
         int                i;
@@ -2072,9 +2074,9 @@ ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress)
                 net->ksnn_ninterfaces--;
 
                 for (j = 0; j < ksocknal_data.ksnd_peer_hash_size; j++) {
-                        cfs_list_for_each_safe(tmp, nxt,
+                       list_for_each_safe(tmp, nxt,
                                                &ksocknal_data.ksnd_peers[j]) {
-                                peer = cfs_list_entry(tmp, ksock_peer_t,
+                               peer = list_entry(tmp, ksock_peer_t,
                                                       ksnp_list);
 
                                 if (peer->ksnp_ni != ni)
@@ -2237,22 +2239,22 @@ ksocknal_free_buffers (void)
        }
 
         LIBCFS_FREE (ksocknal_data.ksnd_peers,
-                     sizeof (cfs_list_t) *
+                    sizeof(struct list_head) *
                      ksocknal_data.ksnd_peer_hash_size);
 
        spin_lock(&ksocknal_data.ksnd_tx_lock);
 
-       if (!cfs_list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
-               cfs_list_t      zlist;
+       if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
+               struct list_head        zlist;
                ksock_tx_t      *tx;
 
-               cfs_list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs);
-               cfs_list_del_init(&ksocknal_data.ksnd_idle_noop_txs);
+               list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs);
+               list_del_init(&ksocknal_data.ksnd_idle_noop_txs);
                spin_unlock(&ksocknal_data.ksnd_tx_lock);
 
-               while (!cfs_list_empty(&zlist)) {
-                       tx = cfs_list_entry(zlist.next, ksock_tx_t, tx_list);
-                       cfs_list_del(&tx->tx_list);
+               while (!list_empty(&zlist)) {
+                       tx = list_entry(zlist.next, ksock_tx_t, tx_list);
+                       list_del(&tx->tx_list);
                        LIBCFS_FREE(tx, tx->tx_desc_size);
                }
        } else {
@@ -2280,14 +2282,14 @@ ksocknal_base_shutdown(void)
         case SOCKNAL_INIT_DATA:
                 LASSERT (ksocknal_data.ksnd_peers != NULL);
                 for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-                        LASSERT (cfs_list_empty (&ksocknal_data.ksnd_peers[i]));
+                       LASSERT(list_empty(&ksocknal_data.ksnd_peers[i]));
                 }
 
-               LASSERT(cfs_list_empty(&ksocknal_data.ksnd_nets));
-                LASSERT (cfs_list_empty (&ksocknal_data.ksnd_enomem_conns));
-                LASSERT (cfs_list_empty (&ksocknal_data.ksnd_zombie_conns));
-                LASSERT (cfs_list_empty (&ksocknal_data.ksnd_connd_connreqs));
-                LASSERT (cfs_list_empty (&ksocknal_data.ksnd_connd_routes));
+               LASSERT(list_empty(&ksocknal_data.ksnd_nets));
+               LASSERT(list_empty(&ksocknal_data.ksnd_enomem_conns));
+               LASSERT(list_empty(&ksocknal_data.ksnd_zombie_conns));
+               LASSERT(list_empty(&ksocknal_data.ksnd_connd_connreqs));
+               LASSERT(list_empty(&ksocknal_data.ksnd_connd_routes));
 
                if (ksocknal_data.ksnd_sched_info != NULL) {
                        cfs_percpt_for_each(info, i,
@@ -2298,11 +2300,11 @@ ksocknal_base_shutdown(void)
                                for (j = 0; j < info->ksi_nthreads_max; j++) {
 
                                        sched = &info->ksi_scheds[j];
-                                       LASSERT(cfs_list_empty(&sched->\
+                                       LASSERT(list_empty(&sched->\
                                                               kss_tx_conns));
-                                       LASSERT(cfs_list_empty(&sched->\
+                                       LASSERT(list_empty(&sched->\
                                                               kss_rx_conns));
-                                       LASSERT(cfs_list_empty(&sched-> \
+                                       LASSERT(list_empty(&sched-> \
                                                  kss_zombie_noop_txs));
                                        LASSERT(sched->kss_nconns == 0);
                                }
@@ -2379,31 +2381,31 @@ ksocknal_base_startup(void)
         memset (&ksocknal_data, 0, sizeof (ksocknal_data)); /* zero pointers */
 
         ksocknal_data.ksnd_peer_hash_size = SOCKNAL_PEER_HASH_SIZE;
-        LIBCFS_ALLOC (ksocknal_data.ksnd_peers,
-                      sizeof (cfs_list_t) *
-                      ksocknal_data.ksnd_peer_hash_size);
+       LIBCFS_ALLOC(ksocknal_data.ksnd_peers,
+                    sizeof(struct list_head) *
+                    ksocknal_data.ksnd_peer_hash_size);
         if (ksocknal_data.ksnd_peers == NULL)
                 return -ENOMEM;
 
         for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++)
-                CFS_INIT_LIST_HEAD(&ksocknal_data.ksnd_peers[i]);
+               INIT_LIST_HEAD(&ksocknal_data.ksnd_peers[i]);
 
        rwlock_init(&ksocknal_data.ksnd_global_lock);
-       CFS_INIT_LIST_HEAD(&ksocknal_data.ksnd_nets);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_nets);
 
        spin_lock_init(&ksocknal_data.ksnd_reaper_lock);
-       CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_enomem_conns);
-       CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_zombie_conns);
-       CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_deathrow_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_enomem_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_zombie_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_deathrow_conns);
        init_waitqueue_head(&ksocknal_data.ksnd_reaper_waitq);
 
        spin_lock_init(&ksocknal_data.ksnd_connd_lock);
-       CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_connd_connreqs);
-       CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_connd_routes);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_connd_connreqs);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_connd_routes);
        init_waitqueue_head(&ksocknal_data.ksnd_connd_waitq);
 
        spin_lock_init(&ksocknal_data.ksnd_tx_lock);
-        CFS_INIT_LIST_HEAD (&ksocknal_data.ksnd_idle_noop_txs);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_idle_noop_txs);
 
        /* NB memset above zeros whole of ksocknal_data */
 
@@ -2442,9 +2444,9 @@ ksocknal_base_startup(void)
 
                        sched->kss_info = info;
                        spin_lock_init(&sched->kss_lock);
-                       CFS_INIT_LIST_HEAD(&sched->kss_rx_conns);
-                       CFS_INIT_LIST_HEAD(&sched->kss_tx_conns);
-                       CFS_INIT_LIST_HEAD(&sched->kss_zombie_noop_txs);
+                       INIT_LIST_HEAD(&sched->kss_rx_conns);
+                       INIT_LIST_HEAD(&sched->kss_tx_conns);
+                       INIT_LIST_HEAD(&sched->kss_zombie_noop_txs);
                        init_waitqueue_head(&sched->kss_waitq);
                }
         }
@@ -2502,14 +2504,14 @@ void
 ksocknal_debug_peerhash (lnet_ni_t *ni)
 {
        ksock_peer_t    *peer = NULL;
-       cfs_list_t      *tmp;
+       struct list_head        *tmp;
        int             i;
 
        read_lock(&ksocknal_data.ksnd_global_lock);
 
         for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-                cfs_list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) {
-                        peer = cfs_list_entry (tmp, ksock_peer_t, ksnp_list);
+               list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(tmp, ksock_peer_t, ksnp_list);
 
                         if (peer->ksnp_ni == ni) break;
 
@@ -2528,19 +2530,19 @@ ksocknal_debug_peerhash (lnet_ni_t *ni)
                       peer->ksnp_sharecount, peer->ksnp_closing,
                       peer->ksnp_accepting, peer->ksnp_error,
                       peer->ksnp_zc_next_cookie,
-                      !cfs_list_empty(&peer->ksnp_tx_queue),
-                      !cfs_list_empty(&peer->ksnp_zc_req_list));
+                      !list_empty(&peer->ksnp_tx_queue),
+                      !list_empty(&peer->ksnp_zc_req_list));
 
-               cfs_list_for_each (tmp, &peer->ksnp_routes) {
-                       route = cfs_list_entry(tmp, ksock_route_t, ksnr_list);
+               list_for_each(tmp, &peer->ksnp_routes) {
+                       route = list_entry(tmp, ksock_route_t, ksnr_list);
                        CWARN ("Route: ref %d, schd %d, conn %d, cnted %d, "
                               "del %d\n", atomic_read(&route->ksnr_refcount),
                               route->ksnr_scheduled, route->ksnr_connecting,
                               route->ksnr_connected, route->ksnr_deleted);
                }
 
-               cfs_list_for_each (tmp, &peer->ksnp_conns) {
-                       conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
+               list_for_each(tmp, &peer->ksnp_conns) {
+                       conn = list_entry(tmp, ksock_conn_t, ksnc_list);
                        CWARN ("Conn: ref %d, sref %d, t %d, c %d\n",
                               atomic_read(&conn->ksnc_conn_refcount),
                               atomic_read(&conn->ksnc_sock_refcount),
@@ -2595,7 +2597,7 @@ ksocknal_shutdown (lnet_ni_t *ni)
                 LASSERT (net->ksnn_interfaces[i].ksni_nroutes == 0);
         }
 
-       cfs_list_del(&net->ksnn_list);
+       list_del(&net->ksnn_list);
        LIBCFS_FREE(net, sizeof(*net));
 
         ksocknal_data.ksnd_nnets--;
@@ -2676,7 +2678,7 @@ ksocknal_search_new_ipif(ksock_net_t *net)
                if (colon != NULL) /* ignore alias device */
                        *colon = 0;
 
-               cfs_list_for_each_entry(tmp, &ksocknal_data.ksnd_nets,
+               list_for_each_entry(tmp, &ksocknal_data.ksnd_nets,
                                        ksnn_list) {
                        for (j = 0; !found && j < tmp->ksnn_ninterfaces; j++) {
                                char *ifnam2 = &tmp->ksnn_interfaces[j].\
@@ -2844,7 +2846,7 @@ ksocknal_startup (lnet_ni_t *ni)
 
        ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid),
                                net->ksnn_interfaces[0].ksni_ipaddr);
-       cfs_list_add(&net->ksnn_list, &ksocknal_data.ksnd_nets);
+       list_add(&net->ksnn_list, &ksocknal_data.ksnd_nets);
 
         ksocknal_data.ksnd_nnets++;
 
index b16767c..c988017 100644 (file)
@@ -66,11 +66,11 @@ struct ksock_sched_info;
 typedef struct                                  /* per scheduler state */
 {
        spinlock_t              kss_lock;       /* serialise */
-       cfs_list_t              kss_rx_conns;   /* conn waiting to be read */
+       struct list_head        kss_rx_conns;   /* conn waiting to be read */
        /* conn waiting to be written */
-       cfs_list_t              kss_tx_conns;
+       struct list_head        kss_tx_conns;
        /* zombie noop tx list */
-       cfs_list_t              kss_zombie_noop_txs;
+       struct list_head        kss_zombie_noop_txs;
        wait_queue_head_t       kss_waitq;      /* where scheduler sleeps */
        /* # connections assigned to this scheduler */
        int                     kss_nconns;
@@ -154,7 +154,7 @@ typedef struct
 {
        __u64             ksnn_incarnation;     /* my epoch */
        spinlock_t        ksnn_lock;            /* serialise */
-       cfs_list_t        ksnn_list;            /* chain on global list */
+       struct list_head  ksnn_list;            /* chain on global list */
        int               ksnn_npeers;          /* # peers */
        int               ksnn_shutdown;        /* shutting down? */
        int               ksnn_ninterfaces;     /* IP interfaces */
@@ -170,11 +170,11 @@ typedef struct
 {
        int                     ksnd_init;      /* initialisation state */
        int                     ksnd_nnets;     /* # networks set up */
-       cfs_list_t              ksnd_nets;      /* list of nets */
+       struct list_head        ksnd_nets;      /* list of nets */
        /* stabilize peer/conn ops */
        rwlock_t                ksnd_global_lock;
        /* hash table of all my known peers */
-       cfs_list_t              *ksnd_peers;
+       struct list_head        *ksnd_peers;
        int                     ksnd_peer_hash_size; /* size of ksnd_peers */
 
        int                     ksnd_nthreads;  /* # live threads */
@@ -184,33 +184,46 @@ typedef struct
 
        atomic_t      ksnd_nactive_txs;    /* #active txs */
 
-       cfs_list_t        ksnd_deathrow_conns; /* conns to close: reaper_lock*/
-       cfs_list_t        ksnd_zombie_conns;   /* conns to free: reaper_lock */
-       cfs_list_t        ksnd_enomem_conns;   /* conns to retry: reaper_lock*/
-       wait_queue_head_t       ksnd_reaper_waitq;   /* reaper sleeps here */
-       cfs_time_t        ksnd_reaper_waketime;/* when reaper will wake */
-       spinlock_t        ksnd_reaper_lock;     /* serialise */
+       /* conns to close: reaper_lock*/
+       struct list_head        ksnd_deathrow_conns;
+       /* conns to free: reaper_lock */
+       struct list_head        ksnd_zombie_conns;
+       /* conns to retry: reaper_lock*/
+       struct list_head        ksnd_enomem_conns;
+       /* reaper sleeps here */
+       wait_queue_head_t       ksnd_reaper_waitq;
+       /* when reaper will wake */
+       cfs_time_t        ksnd_reaper_waketime;
+       /* serialise */
+       spinlock_t        ksnd_reaper_lock;
 
        int               ksnd_enomem_tx;      /* test ENOMEM sender */
        int               ksnd_stall_tx;       /* test sluggish sender */
        int               ksnd_stall_rx;       /* test sluggish receiver */
 
-       cfs_list_t        ksnd_connd_connreqs; /* incoming connection requests */
-       cfs_list_t        ksnd_connd_routes;   /* routes waiting to be connected */
-       wait_queue_head_t       ksnd_connd_waitq;    /* connds sleep here */
-       int               ksnd_connd_connecting;/* # connds connecting */
+       /* incoming connection requests */
+       struct list_head        ksnd_connd_connreqs;
+       /* routes waiting to be connected */
+       struct list_head        ksnd_connd_routes;
+       /* connds sleep here */
+       wait_queue_head_t       ksnd_connd_waitq;
+       /* # connds connecting */
+       int                     ksnd_connd_connecting;
        /** time stamp of the last failed connecting attempt */
-       long              ksnd_connd_failed_stamp;
+       long                    ksnd_connd_failed_stamp;
        /** # starting connd */
-       unsigned          ksnd_connd_starting;
+       unsigned                ksnd_connd_starting;
        /** time stamp of the last starting connd */
-       long              ksnd_connd_starting_stamp;
+       long                    ksnd_connd_starting_stamp;
        /** # running connd */
-       unsigned          ksnd_connd_running;
-       spinlock_t        ksnd_connd_lock;      /* serialise */
+       unsigned                ksnd_connd_running;
+       /* serialise */
+       spinlock_t              ksnd_connd_lock;
 
-       cfs_list_t        ksnd_idle_noop_txs;   /* list head for freed noop tx */
-       spinlock_t        ksnd_tx_lock;         /* serialise, g_lock unsafe */
+       /* list head for freed noop tx */
+       struct list_head        ksnd_idle_noop_txs;
+       /* serialise, g_lock unsafe */
+       spinlock_t              ksnd_tx_lock;
 
 } ksock_nal_data_t;
 
@@ -234,8 +247,8 @@ struct ksock_proto;                             /* forward ref */
 
 typedef struct                                  /* transmit packet */
 {
-       cfs_list_t     tx_list;        /* queue on conn for transmission etc */
-       cfs_list_t     tx_zc_list;     /* queue on peer for ZC request */
+       struct list_head   tx_list;     /* queue on conn for transmission etc */
+       struct list_head   tx_zc_list;  /* queue on peer for ZC request */
        atomic_t       tx_refcount;    /* tx reference count */
        int            tx_nob;         /* # packet bytes */
        int            tx_resid;       /* residual bytes */
@@ -247,7 +260,7 @@ typedef struct                                  /* transmit packet */
         unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
         unsigned short tx_nonblk:1;    /* it's a non-blocking ACK */
         lnet_kiov_t   *tx_kiov;        /* packet page frags */
-        struct ksock_conn  *tx_conn;        /* owning conn */
+       struct ksock_conn *tx_conn;        /* owning conn */
         lnet_msg_t    *tx_lnetmsg;     /* lnet message for lnet_finalize() */
         cfs_time_t     tx_deadline;    /* when (in jiffies) tx times out */
         ksock_msg_t    tx_msg;         /* socklnd message buffer */
@@ -283,10 +296,10 @@ typedef union {
 
 typedef struct ksock_conn
 {
-        struct ksock_peer  *ksnc_peer;         /* owning peer */
-        struct ksock_route *ksnc_route;        /* owning route */
-        cfs_list_t          ksnc_list;         /* stash on peer's conn list */
-       cfs_socket_t        *ksnc_sock;         /* actual socket */
+       struct ksock_peer  *ksnc_peer;          /* owning peer */
+       struct ksock_route *ksnc_route;         /* owning route */
+       struct list_head    ksnc_list;          /* stash on peer's conn list */
+       cfs_socket_t       *ksnc_sock;          /* actual socket */
        void                *ksnc_saved_data_ready; /* socket's original data_ready() callback */
        void                *ksnc_saved_write_space; /* socket's original write_space() callback */
        atomic_t            ksnc_conn_refcount; /* conn refcount */
@@ -302,8 +315,10 @@ typedef struct ksock_conn
        unsigned int        ksnc_zc_capable:1; /* enable to ZC */
         struct ksock_proto *ksnc_proto;      /* protocol for the connection */
 
-        /* reader */
-        cfs_list_t  ksnc_rx_list;     /* where I enq waiting input or a forwarding descriptor */
+       /* READER */
+
+       /* where I enq waiting input or a forwarding descriptor */
+       struct list_head   ksnc_rx_list;
         cfs_time_t            ksnc_rx_deadline; /* when (in jiffies) receive times out */
         __u8                  ksnc_rx_started;  /* started receiving a message */
         __u8                  ksnc_rx_ready;    /* data ready to read */
@@ -325,24 +340,33 @@ typedef struct ksock_conn
                                                  * lnet_hdr_t, it's stored in
                                                  * ksnc_msg.ksm_u.lnetmsg */
 
-        /* WRITER */
-        cfs_list_t            ksnc_tx_list;     /* where I enq waiting for output space */
-        cfs_list_t            ksnc_tx_queue;    /* packets waiting to be sent */
-        ksock_tx_t           *ksnc_tx_carrier;  /* next TX that can carry a LNet message or ZC-ACK */
-       cfs_time_t            ksnc_tx_deadline; /* when (in jiffies) tx times out */
-       int                   ksnc_tx_bufnob;     /* send buffer marker */
-       atomic_t              ksnc_tx_nob;        /* # bytes queued */
-       int                   ksnc_tx_ready;      /* write space */
-       int                   ksnc_tx_scheduled;  /* being progressed */
-       cfs_time_t            ksnc_tx_last_post;  /* time stamp of the last posted TX */
+       /* -- WRITER -- */
+       /* where I enq waiting for output space */
+       struct list_head        ksnc_tx_list;
+       /* packets waiting to be sent */
+       struct list_head        ksnc_tx_queue;
+       /* next TX that can carry a LNet message or ZC-ACK */
+       ksock_tx_t              *ksnc_tx_carrier;
+       /* when (in jiffies) tx times out */
+       cfs_time_t              ksnc_tx_deadline;
+       /* send buffer marker */
+       int                     ksnc_tx_bufnob;
+       /* # bytes queued */
+       atomic_t                ksnc_tx_nob;
+       /* write space */
+       int                     ksnc_tx_ready;
+       /* being progressed */
+       int                     ksnc_tx_scheduled;
+       /* time stamp of the last posted TX */
+       cfs_time_t              ksnc_tx_last_post;
 } ksock_conn_t;
 
 typedef struct ksock_route
 {
-       cfs_list_t            ksnr_list;        /* chain on peer route list */
-       cfs_list_t            ksnr_connd_list;  /* chain on ksnr_connd_routes */
-       struct ksock_peer    *ksnr_peer;        /* owning peer */
-       atomic_t          ksnr_refcount;    /* # users */
+       struct list_head   ksnr_list;           /* chain on peer route list */
+       struct list_head   ksnr_connd_list;     /* chain on ksnr_connd_routes */
+       struct ksock_peer *ksnr_peer;           /* owning peer */
+       atomic_t           ksnr_refcount;       /* # users */
        cfs_time_t            ksnr_timeout;     /* when (in jiffies) reconnection can happen next */
        cfs_duration_t        ksnr_retry_interval; /* how long between retries */
         __u32                 ksnr_myipaddr;    /* my IP */
@@ -360,7 +384,7 @@ typedef struct ksock_route
 
 typedef struct ksock_peer
 {
-       cfs_list_t            ksnp_list;        /* stash on global peer list */
+       struct list_head        ksnp_list;      /* stash on global peer list */
        cfs_time_t            ksnp_last_alive;  /* when (in jiffies) I was last alive */
        lnet_process_id_t     ksnp_id;       /* who's on the other end(s) */
        atomic_t              ksnp_refcount; /* # users */
@@ -371,11 +395,12 @@ typedef struct ksock_peer
         __u64                 ksnp_zc_next_cookie;/* ZC completion cookie */
         __u64                 ksnp_incarnation;   /* latest known peer incarnation */
         struct ksock_proto   *ksnp_proto;    /* latest known peer protocol */
-        cfs_list_t            ksnp_conns;    /* all active connections */
-        cfs_list_t            ksnp_routes;   /* routes */
-        cfs_list_t            ksnp_tx_queue; /* waiting packets */
+       struct list_head        ksnp_conns;     /* all active connections */
+       struct list_head        ksnp_routes;    /* routes */
+       struct list_head        ksnp_tx_queue;  /* waiting packets */
        spinlock_t            ksnp_lock;        /* serialize, g_lock unsafe */
-        cfs_list_t            ksnp_zc_req_list;   /* zero copy requests wait for ACK  */
+       /* zero copy requests wait for ACK  */
+       struct list_head        ksnp_zc_req_list;
         cfs_time_t            ksnp_send_keepalive; /* time to send keepalive */
         lnet_ni_t            *ksnp_ni;       /* which network */
         int                   ksnp_n_passive_ips; /* # of... */
@@ -384,9 +409,12 @@ typedef struct ksock_peer
 
 typedef struct ksock_connreq
 {
-        cfs_list_t            ksncr_list;     /* stash on ksnd_connd_connreqs */
-        lnet_ni_t            *ksncr_ni;       /* chosen NI */
-        cfs_socket_t         *ksncr_sock;     /* accepted socket */
+       /* stash on ksnd_connd_connreqs */
+       struct list_head        ksncr_list;
+       /* chosen NI */
+       lnet_ni_t               *ksncr_ni;
+       /* accepted socket */
+       cfs_socket_t            *ksncr_sock;
 } ksock_connreq_t;
 
 extern ksock_nal_data_t ksocknal_data;
@@ -437,7 +465,7 @@ ksocknal_route_mask(void)
                 (1 << SOCKLND_CONN_BULK_OUT));
 }
 
-static inline cfs_list_t *
+static inline struct list_head *
 ksocknal_nid2peerlist (lnet_nid_t nid)
 {
         unsigned int hash = ((unsigned int)nid) % ksocknal_data.ksnd_peer_hash_size;
@@ -565,7 +593,7 @@ extern void ksocknal_destroy_conn (ksock_conn_t *conn);
 extern int  ksocknal_close_peer_conns_locked (ksock_peer_t *peer,
                                               __u32 ipaddr, int why);
 extern int ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why);
-extern int ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr);
+extern int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr);
 extern ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer,
                                                ksock_tx_t *tx, int nonblk);
 
@@ -576,8 +604,8 @@ extern void ksocknal_free_tx (ksock_tx_t *tx);
 extern ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
 extern void ksocknal_next_tx_carrier(ksock_conn_t *conn);
 extern void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn);
-extern void ksocknal_txlist_done (lnet_ni_t *ni, cfs_list_t *txlist,
-                                  int error);
+extern void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist,
+                                int error);
 extern void ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
 extern void ksocknal_query (struct lnet_ni *ni, lnet_nid_t nid, cfs_time_t *when);
 extern int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
index 9db13f8..515b22f 100644 (file)
@@ -37,11 +37,11 @@ ksocknal_alloc_tx(int type, int size)
                /* searching for a noop tx in free list */
                spin_lock(&ksocknal_data.ksnd_tx_lock);
 
-               if (!cfs_list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
-                       tx = cfs_list_entry(ksocknal_data.ksnd_idle_noop_txs. \
+               if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
+                       tx = list_entry(ksocknal_data.ksnd_idle_noop_txs. \
                                            next, ksock_tx_t, tx_list);
                        LASSERT(tx->tx_desc_size == size);
-                       cfs_list_del(&tx->tx_list);
+                       list_del(&tx->tx_list);
                }
 
                spin_unlock(&ksocknal_data.ksnd_tx_lock);
@@ -99,7 +99,7 @@ ksocknal_free_tx (ksock_tx_t *tx)
         &nbs