Whamcloud - gitweb
LU-6142 lnet: convert kiblnd/ksocknal_thread_start to vararg
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd.h
index 60d1590..26956a3 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lnet/klnds/o2iblnd/o2iblnd.h
  *
 #undef NEED_KTIME_GET_REAL_NS
 #endif
 
+#define HAVE_NLA_PUT_U64_64BIT 1
+#define HAVE_NLA_PARSE_6_PARAMS 1
+#define HAVE_NETLINK_EXTACK 1
+
+
 /* MOFED has its own bitmap_alloc backport */
 #define HAVE_BITMAP_ALLOC 1
 
 
 #define DEBUG_SUBSYSTEM S_LND
 
-#include <libcfs/libcfs.h>
 #include <lnet/lib-lnet.h>
 #include "o2iblnd-idl.h"
 
-#define IBLND_PEER_HASH_SIZE           101     /* # peer_ni lists */
+#define IBLND_PEER_HASH_BITS           7       /* log2 of # peer_ni lists */
 
 #define IBLND_N_SCHED                  2
 #define IBLND_N_SCHED_HIGH             4
@@ -345,6 +348,7 @@ struct kib_fast_reg_descriptor { /* For fast registration */
 #endif
        struct ib_mr                    *frd_mr;
        bool                             frd_valid;
+       bool                             frd_posted;
 };
 
 struct kib_fmr_pool {
@@ -439,9 +443,7 @@ struct kib_data {
        /* stabilize net/dev/peer_ni/conn ops */
        rwlock_t                kib_global_lock;
        /* hash table of all my known peers */
-       struct list_head        *kib_peers;
-       /* size of kib_peers */
-       int                     kib_peer_hash_size;
+       DECLARE_HASHTABLE(kib_peers, IBLND_PEER_HASH_BITS);
        /* the connd task (serialisation assertions) */
        void                    *kib_connd;
        /* connections to setup/teardown */
@@ -642,8 +644,8 @@ struct kib_conn {
 #define IBLND_CONN_DISCONNECTED       5         /* disconnected */
 
 struct kib_peer_ni {
-       /* stash on global peer_ni list */
-       struct list_head        ibp_list;
+       /* on peer_ni hash chain */
+       struct hlist_node       ibp_list;
        /* who's on the other end(s) */
        lnet_nid_t              ibp_nid;
        /* LNet interface */
@@ -672,8 +674,6 @@ struct kib_peer_ni {
        unsigned char           ibp_races;
        /* # consecutive reconnection attempts to this peer */
        unsigned int            ibp_reconnected;
-       /* number of total active retries */
-       unsigned int            ibp_retries;
        /* errno on closing this peer_ni */
        int                     ibp_error;
        /* max map_on_demand */
@@ -814,20 +814,11 @@ kiblnd_peer_idle(struct kib_peer_ni *peer_ni)
        return !kiblnd_peer_connecting(peer_ni) && list_empty(&peer_ni->ibp_conns);
 }
 
-static inline struct list_head *
-kiblnd_nid2peerlist (lnet_nid_t nid)
-{
-       unsigned int hash =
-               ((unsigned int)nid) % kiblnd_data.kib_peer_hash_size;
-
-       return &kiblnd_data.kib_peers[hash];
-}
-
 static inline int
 kiblnd_peer_active(struct kib_peer_ni *peer_ni)
 {
        /* Am I in the peer_ni hash table? */
-       return !list_empty(&peer_ni->ibp_list);
+       return !hlist_unhashed(&peer_ni->ibp_list);
 }
 
 static inline struct kib_conn *
@@ -1075,6 +1066,10 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
         return ib_sg_dma_len(dev, sg);
 }
 
+#ifndef HAVE_RDMA_CONNECT_LOCKED
+#define rdma_connect_locked(cmid, cpp) rdma_connect(cmid, cpp)
+#endif
+
 /* XXX We use KIBLND_CONN_PARAM(e) as writable buffer, it's not strictly
  * right because OFED1.2 defines it as const, to use it we have to add
  * (void *) cast to overcome "const" */
@@ -1098,7 +1093,15 @@ int  kiblnd_tunables_init(void);
 
 int  kiblnd_connd (void *arg);
 int  kiblnd_scheduler(void *arg);
-int  kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name);
+#define kiblnd_thread_start(fn, data, namefmt, arg...)                 \
+       ({                                                              \
+               struct task_struct *__task = kthread_run(fn, data,      \
+                                                        namefmt, ##arg); \
+               if (!IS_ERR(__task))                                    \
+                       atomic_inc(&kiblnd_data.kib_nthreads);          \
+               PTR_ERR_OR_ZERO(__task);                                \
+       })
+
 int  kiblnd_failover_thread (void *arg);
 
 int kiblnd_alloc_pages(struct kib_pages **pp, int cpt, int npages);