Whamcloud - gitweb
LU-56 lnet: abstract container for EQ/ME/MD
[fs/lustre-release.git] / lnet / include / lnet / lib-types.h
index ad3440c..0dd289e 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -26,7 +24,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -153,14 +151,11 @@ typedef struct {
 
 /* PROTO MAGIC for LNDs */
 #define LNET_PROTO_IB_MAGIC                 0x0be91b91
-#define LNET_PROTO_OPENIB_MAGIC             LNET_PROTO_IB_MAGIC
-#define LNET_PROTO_IIB_MAGIC                LNET_PROTO_IB_MAGIC
-#define LNET_PROTO_VIB_MAGIC                LNET_PROTO_IB_MAGIC
 #define LNET_PROTO_RA_MAGIC                 0x0be91b92
 #define LNET_PROTO_QSW_MAGIC                0x0be91b93
+#define LNET_PROTO_GNI_MAGIC                0xb00fbabe /* ask Kim */
 #define LNET_PROTO_TCP_MAGIC                0xeebc0ded
 #define LNET_PROTO_PTL_MAGIC                0x50746C4E /* 'PtlN' unique magic */
-#define LNET_PROTO_GM_MAGIC                 0x6d797269 /* 'myri'! */
 #define LNET_PROTO_MX_MAGIC                 0x4d583130 /* 'MX10'! */
 #define LNET_PROTO_ACCEPTOR_MAGIC           0xacce7100
 #define LNET_PROTO_PING_MAGIC               0x70696E67 /* 'ping' */
@@ -194,6 +189,7 @@ typedef struct lnet_msg {
         lnet_process_id_t     msg_target;
         __u32                 msg_type;
 
+        unsigned int          msg_vmflush:1;      /* VM trying to free memory */
         unsigned int          msg_target_is_router:1; /* sending to a router */
         unsigned int          msg_routing:1;      /* being forwarded */
         unsigned int          msg_ack:1;          /* ack on finalize (PUT) */
@@ -304,7 +300,8 @@ typedef struct {
 #define LNET_COOKIE_TYPE_MD    1
 #define LNET_COOKIE_TYPE_ME    2
 #define LNET_COOKIE_TYPE_EQ    3
-#define LNET_COOKIE_TYPES      4
+#define LNET_COOKIE_TYPE_BITS  2
+#define LNET_COOKIE_TYPES      (1 << LNET_COOKIE_TYPE_BITS)
 /* LNET_COOKIE_TYPES must be a power of 2, so the cookie type can be
  * extracted by masking with (LNET_COOKIE_TYPES - 1) */
 
@@ -508,14 +505,37 @@ typedef struct {
 
 /* Options for lnet_portal_t::ptl_options */
 #define LNET_PTL_LAZY               (1 << 0)
+#define LNET_PTL_MATCH_UNIQUE       (1 << 1)    /* unique match, for RDMA */
+#define LNET_PTL_MATCH_WILDCARD     (1 << 2)    /* wildcard match, request portal */
+
+/* ME hash of RDMA portal */
+#define LNET_PORTAL_HASH_BITS        8
+#define LNET_PORTAL_HASH_SIZE       (1 << LNET_PORTAL_HASH_BITS)
+
 typedef struct {
-        cfs_list_t           ptl_ml;   /* match list */
-        cfs_list_t           ptl_msgq; /* messages blocking for MD */
-        __u64                ptl_ml_version;    /* validity stamp, only changed for new attached MD */
-        __u64                ptl_msgq_version;  /* validity stamp */
-        unsigned int         ptl_options;
+        cfs_list_t       *ptl_mhash;            /* match hash */
+        cfs_list_t        ptl_mlist;            /* match list */
+        cfs_list_t        ptl_msgq;             /* messages blocking for MD */
+        __u64             ptl_ml_version;       /* validity stamp, only changed for new attached MD */
+        __u64             ptl_msgq_version;     /* validity stamp */
+        unsigned int      ptl_options;
 } lnet_portal_t;
 
+#define LNET_LH_HASH_BITS      12
+#define LNET_LH_HASH_SIZE      (1ULL << LNET_LH_HASH_BITS)
+#define LNET_LH_HASH_MASK      (LNET_LH_HASH_SIZE - 1)
+
+/* resource container (ME, MD, EQ) */
+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 */
+#ifdef LNET_USE_LIB_FREELIST
+       lnet_freelist_t         rec_freelist;   /* freelist for resources */
+#endif
+};
+
 /* Router Checker states */
 #define LNET_RC_STATE_SHUTDOWN     0            /* not started */
 #define LNET_RC_STATE_RUNNING      1            /* started up OK */
@@ -535,8 +555,8 @@ typedef struct
 #ifdef __KERNEL__
         cfs_spinlock_t         ln_lock;
         cfs_waitq_t            ln_waitq;
-        cfs_semaphore_t   ln_api_mutex;
-        cfs_semaphore_t   ln_lnd_mutex;
+        cfs_mutex_t            ln_api_mutex;
+        cfs_mutex_t            ln_lnd_mutex;
 #else
 # ifndef HAVE_LIBPTHREAD
         int                    ln_lock;
@@ -549,6 +569,12 @@ typedef struct
         pthread_mutex_t        ln_lnd_mutex;
 # endif
 #endif
+       /* ME container  */
+       struct lnet_res_container       ln_me_container;
+       /* MD container  */
+       struct lnet_res_container       ln_md_container;
+       /* Event Queue container */
+       struct lnet_res_container       ln_eq_container;
 
         /* Stuff initialised at LNetNIInit() */
 
@@ -577,9 +603,6 @@ typedef struct
         int                    ln_routing;          /* am I a router? */
         lnet_rtrbufpool_t      ln_rtrpools[LNET_NRBPOOLS]; /* router buffer pools */
 
-        int                    ln_lh_hash_size;     /* size of lib handle hash table */
-        cfs_list_t            *ln_lh_hash_table;    /* all extant lib handles, this interface */
-        __u64                  ln_next_object_cookie; /* cookie generator */
         __u64                  ln_interface_cookie; /* uniquely identifies this ni in this epoch */
 
         char                  *ln_network_tokens;   /* space for network names */
@@ -601,22 +624,16 @@ typedef struct
         lnet_ping_info_t      *ln_ping_info;
 
 #ifdef __KERNEL__
-        cfs_semaphore_t   ln_rc_signal;        /* serialise startup/shutdown */
+        cfs_semaphore_t        ln_rc_signal;        /* serialise startup/shutdown */
 #endif
-        int                ln_rc_state;         /* router checker startup/shutdown state */
-        lnet_handle_eq_t   ln_rc_eqh;           /* router checker's event queue */
-        lnet_handle_md_t   ln_rc_mdh;
-        cfs_list_t         ln_zombie_rcd;
-
+        int                    ln_rc_state;         /* router checker startup/shutdown state */
+        lnet_handle_eq_t       ln_rc_eqh;           /* router checker's event queue */
+        lnet_handle_md_t       ln_rc_mdh;
+        cfs_list_t             ln_zombie_rcd;
 #ifdef LNET_USE_LIB_FREELIST
-        lnet_freelist_t        ln_free_mes;
         lnet_freelist_t        ln_free_msgs;
-        lnet_freelist_t        ln_free_mds;
-        lnet_freelist_t        ln_free_eqs;
 #endif
         cfs_list_t             ln_active_msgs;
-        cfs_list_t             ln_active_mds;
-        cfs_list_t             ln_active_eqs;
 
         lnet_counters_t        ln_counters;