Whamcloud - gitweb
LU-2675 lnet: add lnet/nidstr.h
[fs/lustre-release.git] / lnet / include / lnet / types.h
index 2982801..997fbc1 100644 (file)
@@ -40,7 +40,7 @@
 /** \addtogroup lnet
  * @{ */
 
-#include <libcfs/libcfs.h>
+#include <libcfs/types.h>
 
 /** \addtogroup lnet_addr
  * @{ */
@@ -77,6 +77,39 @@ typedef __u32 lnet_pid_t;
 
 #define LNET_TIME_FOREVER    (-1)
 
+/* how an LNET NID encodes net:address */
+/** extract the address part of an lnet_nid_t */
+
+static inline __u32 LNET_NIDADDR(lnet_nid_t nid)
+{
+       return nid & 0xffffffff;
+}
+
+static inline __u32 LNET_NIDNET(lnet_nid_t nid)
+{
+       return (nid >> 32) & 0xffffffff;
+}
+
+static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr)
+{
+       return (((__u64)net) << 32) | addr;
+}
+
+static inline __u32 LNET_NETNUM(__u32 net)
+{
+       return net & 0xffff;
+}
+
+static inline __u32 LNET_NETTYP(__u32 net)
+{
+       return (net >> 16) & 0xffff;
+}
+
+static inline __u32 LNET_MKNET(__u32 type, __u32 num)
+{
+       return (type << 16) | num;
+}
+
 /**
  * Objects maintained by the LNet are accessed through handles. Handle types
  * have names of the form lnet_handle_xx_t, where xx is one of the two letter