Whamcloud - gitweb
LU-16118 build: Workaround __write_overflow_field errors
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnet-types.h
index 5a2a2a0..f515173 100644 (file)
 #ifndef __UAPI_LNET_TYPES_H__
 #define __UAPI_LNET_TYPES_H__
 
+#include <linux/types.h>
 #include <linux/string.h>
 #include <asm/byteorder.h>
+#ifndef __KERNEL__
+#include <stdbool.h>
+#endif
 
 /** \addtogroup lnet
  * @{ */
@@ -81,11 +85,6 @@ 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;
@@ -101,16 +100,33 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
        return (type << 16) | num;
 }
 
+static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr)
+{
+       return (((__u64)net) << 32) | addr;
+}
+
 /** The lolnd NID (i.e. myself) */
 #define LNET_NID_LO_0 LNET_MKNID(LNET_MKNET(LOLND, 0), 0)
 
 #define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY)
 
-static inline int nid_is_nid4(const struct lnet_nid *nid)
+static inline bool nid_is_nid4(const struct lnet_nid *nid)
 {
        return NID_ADDR_BYTES(nid) == 4;
 }
 
+/* check for address set */
+static inline bool nid_addr_is_set(const struct lnet_nid *nid)
+{
+       int i;
+
+       for (i = 0; i < NID_ADDR_BYTES(nid); i++)
+               if (nid->nid_addr[i])
+                       return true;
+
+       return false;
+}
+
 /* LOLND may not be defined yet, so we cannot use an inline */
 #define nid_is_lo0(__nid)                                              \
        ((__nid)->nid_type == LOLND &&                                  \
@@ -129,8 +145,7 @@ static inline __u32 LNET_NID_NET(const struct lnet_nid *nid)
 static inline void lnet_nid4_to_nid(lnet_nid_t nid4, struct lnet_nid *nid)
 {
        if (nid4 == LNET_NID_ANY) {
-               /* equal to setting to LNET_ANY_NID */
-               memset(nid, 0xff, sizeof(*nid));
+               *nid = LNET_ANY_NID;
                return;
        }