Whamcloud - gitweb
LU-4423 lnet: don't use iovec instead of kvec
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd.h
index 2b9c039..9f6b36b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2009-2012 Cray, Inc.
  *
- * Copyright (c) 2013, 2014, Intel Corporation.
+ * Copyright (c) 2014, Intel Corporation.
  *
  *   Derived from work by: Eric Barton <eric@bartonsoftware.com>
  *   Author: Nic Henke <nic@cray.com>
 
 /* Max number of connections to keep in purgatory per peer */
 #define GNILND_PURGATORY_MAX     5
+/* Closing, don't put in purgatory */
+#define GNILND_NOPURG             222
 
 /* payload size to add to the base mailbox size
  * This is subtracting 2 from the concurrent_sends as 4 messages are included in the size
@@ -486,7 +488,7 @@ typedef struct kgn_tunables {
        int     *kgn_thread_affinity;  /* bind scheduler threads to cpus */
        int     *kgn_thread_safe;      /* use thread safe kgni API */
 #if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
-       cfs_sysctl_table_header_t *kgn_sysctl;  /* sysctl interface */
+       struct ctl_table_header *kgn_sysctl;  /* sysctl interface */
 #endif
 } kgn_tunables_t;
 
@@ -589,6 +591,8 @@ typedef struct kgn_device {
        atomic_t                gnd_n_schedule;
        atomic_t                gnd_canceled_dgrams; /* # of outstanding cancels */
        struct rw_semaphore     gnd_conn_sem;       /* serialize connection changes/data movement */
+       void                   *gnd_smdd_hold_buf;  /* buffer to keep smdd */
+       gni_mem_handle_t        gnd_smdd_hold_hndl; /* buffer mem handle */
 } kgn_device_t;
 
 typedef struct kgn_net {
@@ -964,9 +968,10 @@ static inline int kgnilnd_trylock(struct mutex *cq_lock,
                return __kgnilnd_mutex_trylock(c_lock);
 }
 
-static inline void *kgnilnd_vmalloc(int size)
+static inline void *kgnilnd_vzalloc(int size)
 {
-       void *ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOFS, PAGE_KERNEL);
+       void *ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOFS | __GFP_ZERO,
+                             PAGE_KERNEL);
        LIBCFS_ALLOC_POST(ret, size);
        return ret;
 }
@@ -1736,7 +1741,7 @@ int kgnilnd_eager_recv(lnet_ni_t *ni, void *private,
                        lnet_msg_t *lntmsg, void **new_private);
 int kgnilnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
                int delayed, unsigned int niov,
-               struct iovec *iov, lnet_kiov_t *kiov,
+               struct kvec *iov, lnet_kiov_t *kiov,
                unsigned int offset, unsigned int mlen, unsigned int rlen);
 
 __u16 kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, unsigned int offset, unsigned int nob, int dump_blob);
@@ -1981,6 +1986,8 @@ kgnilnd_conn_dgram_type2str(kgn_dgram_type_t type)
 /* pulls in tunables per platform and adds in nid/nic conversion
  * if RCA wasn't available at build time */
 #include "gnilnd_hss_ops.h"
+/* API wrapper functions - include late to pick up all of the other defines */
+#include "gnilnd_api_wrap.h"
 
 #if defined(CONFIG_CRAY_GEMINI)
  #include "gnilnd_gemini.h"
@@ -1990,7 +1997,38 @@ kgnilnd_conn_dgram_type2str(kgn_dgram_type_t type)
  #error "Undefined Network Hardware Type"
 #endif
 
-/* API wrapper functions - include late to pick up all of the other defines */
-#include "gnilnd_api_wrap.h"
+extern uint32_t kgni_driver_version;
+
+static inline void
+kgnilnd_check_kgni_version(void)
+{
+       uint32_t *kdv;
+
+       kgnilnd_data.kgn_enable_gl_mutex = 1;
+       kdv = symbol_get(kgni_driver_version);
+       if (!kdv) {
+               LCONSOLE_INFO("Not using thread safe locking -"
+                       " no symbol kgni_driver_version\n");
+               return;
+       }
+
+       /* Thread-safe kgni implemented in minor ver 0x44/45, code rev 0xb9 */
+       if (*kdv < GNI_VERSION_CHECK(0, GNILND_KGNI_TS_MINOR_VER, 0xb9)) {
+               symbol_put(kgni_driver_version);
+               LCONSOLE_INFO("Not using thread safe locking, gni version 0x%x,"
+                       " need >= 0x%x\n", *kdv,
+                       GNI_VERSION_CHECK(0, GNILND_KGNI_TS_MINOR_VER, 0xb9));
+               return;
+       }
+
+       symbol_put(kgni_driver_version);
+
+       if (!*kgnilnd_tunables.kgn_thread_safe) {
+               return;
+       }
+
+       /* Use thread-safe locking */
+       kgnilnd_data.kgn_enable_gl_mutex = 0;
+}
 
 #endif /* _GNILND_GNILND_H_ */