Whamcloud - gitweb
LU-6261 gnilnd: kgnilnd_check_rdma_cq race in error path.
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd.h
index b75d850..785142c 100644 (file)
 
 /* 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 {
@@ -1982,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"
@@ -1991,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_ */