Whamcloud - gitweb
LU-6034 lnet: add default case for check summing
[fs/lustre-release.git] / lnet / include / lnet / types.h
index 2982801..ac9799b 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,7 +40,7 @@
 /** \addtogroup lnet
  * @{ */
 
-#include <libcfs/libcfs.h>
+#include <libcfs/types.h>
 
 /** \addtogroup lnet_addr
  * @{ */
@@ -74,9 +74,43 @@ typedef __u32 lnet_pid_t;
 
 #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
 #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
+#define LNET_PID_LUSTRE 12345
 
 #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