Whamcloud - gitweb
LU-14093 lnet: annotate LNET_WIRE_HANDLE_COOKIE_NONE as u64
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnet-types.h
index a80cc73..69dc893 100644 (file)
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #ifndef __UAPI_LNET_TYPES_H__
@@ -36,7 +35,8 @@
 /** \addtogroup lnet
  * @{ */
 
-#include <linux/types.h>
+#include <linux/lnet/lnet-idl.h>
+
 /** \addtogroup lnet_addr
  * @{ */
 
  */
 #define LNET_RESERVED_PORTAL     0
 
-/**
- * Address of an end-point in an LNet network.
- *
- * A node can have multiple end-points and hence multiple addresses.
- * An LNet network can be a simple network (e.g. tcp0) or a network of
- * LNet networks connected by LNet routers. Therefore an end-point address
- * has two parts: network ID, and address within a network.
- *
- * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
- */
-typedef __u64 lnet_nid_t;
-
-/**
- * ID of a process in a node. Shortened as PID to distinguish from
- * lnet_process_id, the global process ID.
- */
-typedef __u32 lnet_pid_t;
-
 /** wildcard NID that matches any end-point address */
 #define LNET_NID_ANY     ((lnet_nid_t) -1)
 /** wildcard PID that matches any lnet_pid_t */
@@ -107,183 +89,31 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
        return (type << 16) | num;
 }
 
-#define WIRE_ATTR      __attribute__((packed))
-
-/* Packed version of struct lnet_process_id to transfer via network */
-typedef struct lnet_process_id_packed {
-       lnet_nid_t nid;
-       lnet_pid_t pid; /* node id / process id */
-} WIRE_ATTR lnet_process_id_packed;
-
-/* The wire handle's interface cookie only matches one network interface in
- * one epoch (i.e. new cookie when the interface restarts or the node
- * reboots).  The object cookie only matches one object on that interface
- * during that object's lifetime (i.e. no cookie re-use). */
-typedef struct lnet_handle_wire {
-       __u64 wh_interface_cookie;
-       __u64 wh_object_cookie;
-} WIRE_ATTR lnet_handle_wire_t;
-
-typedef enum lnet_msg_type {
-       LNET_MSG_ACK = 0,
-       LNET_MSG_PUT,
-       LNET_MSG_GET,
-       LNET_MSG_REPLY,
-       LNET_MSG_HELLO,
-} lnet_msg_type_t;
-
-/* The variant fields of the portals message header are aligned on an 8
- * byte boundary in the message header.  Note that all types used in these
- * wire structs MUST be fixed size and the smaller types are placed at the
- * end. */
-struct lnet_ack {
-       struct lnet_handle_wire dst_wmd;
-       __u64                   match_bits;
-       __u32                   mlength;
-} WIRE_ATTR;
-
-struct lnet_put {
-       struct lnet_handle_wire ack_wmd;
-       __u64                   match_bits;
-       __u64                   hdr_data;
-       __u32                   ptl_index;
-       __u32                   offset;
-} WIRE_ATTR;
-
-struct lnet_get {
-       struct lnet_handle_wire return_wmd;
-       __u64                   match_bits;
-       __u32                   ptl_index;
-       __u32                   src_offset;
-       __u32                   sink_length;
-} WIRE_ATTR;
-
-struct lnet_reply {
-       struct lnet_handle_wire dst_wmd;
-} WIRE_ATTR;
-
-struct lnet_hello {
-       __u64                   incarnation;
-       __u32                   type;
-} WIRE_ATTR;
-
-typedef struct lnet_hdr {
-       lnet_nid_t      dest_nid;
-       lnet_nid_t      src_nid;
-       lnet_pid_t      dest_pid;
-       lnet_pid_t      src_pid;
-       __u32           type;           /* enum lnet_msg_type */
-       __u32           payload_length; /* payload data to follow */
-       /*<------__u64 aligned------->*/
-       union {
-               struct lnet_ack         ack;
-               struct lnet_put         put;
-               struct lnet_get         get;
-               struct lnet_reply       reply;
-               struct lnet_hello       hello;
-       } msg;
-} WIRE_ATTR lnet_hdr_t;
-
-/* A HELLO message contains a magic number and protocol version
- * code in the header's dest_nid, the peer's NID in the src_nid, and
- * LNET_MSG_HELLO in the type field.  All other common fields are zero
- * (including payload_size; i.e. no payload).
- * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
- * running the same protocol and to find out its NID. These LNDs should
- * exchange HELLO messages when a connection is first established.  Individual
- * LNDs can put whatever else they fancy in lnet_hdr::msg.
- */
-typedef struct lnet_magicversion {
-       __u32   magic;          /* LNET_PROTO_TCP_MAGIC */
-       __u16   version_major;  /* increment on incompatible change */
-       __u16   version_minor;  /* increment on compatible change */
-} WIRE_ATTR lnet_magic_version_t;
-
-/* PROTO MAGIC for LNDs */
-#define LNET_PROTO_IB_MAGIC            0x0be91b91
-#define LNET_PROTO_GNI_MAGIC           0xb00fbabe /* ask Kim */
-#define LNET_PROTO_TCP_MAGIC           0xeebc0ded
-#define LNET_PROTO_ACCEPTOR_MAGIC      0xacce7100
-#define LNET_PROTO_PING_MAGIC          0x70696E67 /* 'ping' */
-
-/* Placeholder for a future "unified" protocol across all LNDs */
-/* Current LNDs that receive a request with this magic will respond
- * with a "stub" reply using their current protocol */
-#define LNET_PROTO_MAGIC               0x45726963 /* ! */
-
-#define LNET_PROTO_TCP_VERSION_MAJOR   1
-#define LNET_PROTO_TCP_VERSION_MINOR   0
-
-/* Acceptor connection request */
-typedef struct lnet_acceptor_connreq {
-       __u32   acr_magic;      /* PTL_ACCEPTOR_PROTO_MAGIC */
-       __u32   acr_version;    /* protocol version */
-       __u64   acr_nid;        /* target NID */
-} WIRE_ATTR lnet_acceptor_connreq_t;
-
-#define LNET_PROTO_ACCEPTOR_VERSION    1
-
-typedef struct lnet_counters {
-       __u32   msgs_alloc;
-       __u32   msgs_max;
-       __u32   errors;
-       __u32   send_count;
-       __u32   recv_count;
-       __u32   route_count;
-       __u32   drop_count;
-       __u64   send_length;
-       __u64   recv_length;
-       __u64   route_length;
-       __u64   drop_length;
-} WIRE_ATTR lnet_counters_t;
-
-#define LNET_NI_STATUS_UP      0x15aac0de
-#define LNET_NI_STATUS_DOWN    0xdeadface
-#define LNET_NI_STATUS_INVALID 0x00000000
-
-struct lnet_ni_status {
-       lnet_nid_t ns_nid;
-       __u32      ns_status;
-       __u32      ns_unused;
-} WIRE_ATTR;
-
-/*
- * NB: value of these features equal to LNET_PROTO_PING_VERSION_x
- * of old LNet, so there shouldn't be any compatibility issue
- */
-#define LNET_PING_FEAT_INVAL           (0)             /* no feature */
-#define LNET_PING_FEAT_BASE            (1 << 0)        /* just a ping */
-#define LNET_PING_FEAT_NI_STATUS       (1 << 1)        /* return NI status */
-#define LNET_PING_FEAT_RTE_DISABLED    (1 << 2)        /* Routing enabled */
-#define LNET_PING_FEAT_MULTI_RAIL      (1 << 3)        /* Multi-Rail aware */
-#define LNET_PING_FEAT_DISCOVERY       (1 << 4)        /* Supports Discovery */
-
-/*
- * All ping feature bits fit to hit the wire.
- * In lnet_assert_wire_constants() this is compared against its open-coded
- * value, and in lnet_ping_target_update() it is used to verify that no
- * unknown bits have been set.
- * New feature bits can be added, just be aware that this does change the
- * over-the-wire protocol.
- */
-#define LNET_PING_FEAT_BITS            (LNET_PING_FEAT_BASE | \
-                                        LNET_PING_FEAT_NI_STATUS | \
-                                        LNET_PING_FEAT_RTE_DISABLED | \
-                                        LNET_PING_FEAT_MULTI_RAIL | \
-                                        LNET_PING_FEAT_DISCOVERY)
-
-struct lnet_ping_info {
-       __u32                   pi_magic;
-       __u32                   pi_features;
-       lnet_pid_t              pi_pid;
-       __u32                   pi_nnis;
-       struct lnet_ni_status   pi_ni[0];
-} WIRE_ATTR;
-
-#define LNET_PING_INFO_SIZE(NNIDS) \
-       offsetof(struct lnet_ping_info, pi_ni[NNIDS])
-#define LNET_PING_INFO_LONI(PINFO)     ((PINFO)->pi_ni[0].ns_nid)
-#define LNET_PING_INFO_SEQNO(PINFO)    ((PINFO)->pi_ni[0].ns_status)
+/** 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)
+
+struct lnet_counters_health {
+       __u32   lch_rst_alloc;
+       __u32   lch_resend_count;
+       __u32   lch_response_timeout_count;
+       __u32   lch_local_interrupt_count;
+       __u32   lch_local_dropped_count;
+       __u32   lch_local_aborted_count;
+       __u32   lch_local_no_route_count;
+       __u32   lch_local_timeout_count;
+       __u32   lch_local_error_count;
+       __u32   lch_remote_dropped_count;
+       __u32   lch_remote_error_count;
+       __u32   lch_remote_timeout_count;
+       __u32   lch_network_timeout_count;
+};
+
+struct lnet_counters {
+       struct lnet_counters_common lct_common;
+       struct lnet_counters_health lct_health;
+};
 
 /*
  * This is a hard-coded limit on the number of interfaces supported by
@@ -301,37 +131,15 @@ struct lnet_ping_info {
 /**
  * Objects maintained by the LNet are accessed through handles. Handle types
  * have names of the form lnet_handle_xx, where xx is one of the two letter
- * object type codes ('eq' for event queue, 'md' for memory descriptor, and
+ * object type codes ('md' for memory descriptor, and
  * 'me' for match entry). Each type of object is given a unique handle type
  * to enhance type checking.
  */
-#define LNET_WIRE_HANDLE_COOKIE_NONE   (-1)
+#define LNET_WIRE_HANDLE_COOKIE_NONE   (~0ULL)
 
-typedef struct lnet_handle_eq {
+struct lnet_handle_md {
        __u64   cookie;
-} lnet_handle_eq_t;
-
-/**
- * Invalidate eq handle \a h.
- */
-static inline void LNetInvalidateEQHandle(struct lnet_handle_eq *h)
-{
-       h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
-}
-
-/**
- * Check whether eq handle \a h is invalid.
- *
- * \return 1 if handle is invalid, 0 if valid.
- */
-static inline int LNetEQHandleIsInvalid(struct lnet_handle_eq h)
-{
-       return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
-}
-
-typedef struct lnet_handle_md {
-       __u64   cookie;
-} lnet_handle_md_t;
+};
 
 /**
  * Invalidate md handle \a h.
@@ -342,7 +150,7 @@ static inline void LNetInvalidateMDHandle(struct lnet_handle_md *h)
 }
 
 /**
- * Check whether eq handle \a h is invalid.
+ * Check whether handler \a h is invalid.
  *
  * \return 1 if handle is invalid, 0 if valid.
  */
@@ -351,19 +159,15 @@ static inline int LNetMDHandleIsInvalid(struct lnet_handle_md h)
        return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
 }
 
-typedef struct lnet_handle_me {
-       __u64   cookie;
-} lnet_handle_me_t;
-
 /**
  * Global process ID.
  */
-typedef struct lnet_process_id {
+struct lnet_process_id {
        /** node id */
        lnet_nid_t nid;
        /** process id */
        lnet_pid_t pid;
-} lnet_process_id_t;
+};
 /** @} lnet_addr */
 
 /** \addtogroup lnet_me
@@ -373,10 +177,10 @@ typedef struct lnet_process_id {
  * Specifies whether the match entry or memory descriptor should be unlinked
  * automatically (LNET_UNLINK) or not (LNET_RETAIN).
  */
-typedef enum lnet_unlink {
+enum lnet_unlink {
        LNET_RETAIN = 0,
        LNET_UNLINK
-} lnet_unlink_t;
+};
 
 /**
  * Values of the type enum lnet_ins_pos are used to control where a new match
@@ -385,14 +189,14 @@ typedef enum lnet_unlink {
  * LNET_INS_AFTER is used to insert the new entry after the current entry
  * or after the last item in the list.
  */
-typedef enum lnet_ins_pos {
+enum lnet_ins_pos {
        /** insert ME before current position or head of the list */
        LNET_INS_BEFORE,
        /** insert ME after current position or tail of the list */
        LNET_INS_AFTER,
        /** attach ME at tail of local CPU partition ME list */
        LNET_INS_LOCAL
-} lnet_ins_pos;
+};
 
 /** @} lnet_me */
 
@@ -400,23 +204,31 @@ typedef enum lnet_ins_pos {
  * @{ */
 
 /**
+ * Event queue handler function type.
+ *
+ * The EQ handler runs for each event that is deposited into the EQ. The
+ * handler is supplied with a pointer to the event that triggered the
+ * handler invocation.
+ *
+ * The handler must not block, must be reentrant, and must not call any LNet
+ * API functions. It should return as quickly as possible.
+ */
+struct lnet_event;
+typedef void (*lnet_handler_t)(struct lnet_event *event);
+
+/**
  * Defines the visible parts of a memory descriptor. Values of this type
  * are used to initialize memory descriptors.
  */
-typedef struct lnet_md {
+struct lnet_md {
        /**
         * Specify the memory region associated with the memory descriptor.
         * If the options field has:
         * - LNET_MD_KIOV bit set: The start field points to the starting
-        * address of an array of lnet_kiov_t and the length field specifies
+        * address of an array of struct bio_vec and the length field specifies
         * the number of entries in the array. The length can't be bigger
-        * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
+        * than LNET_MAX_IOV. The struct bio_vec is used to describe page-based
         * fragments that are not necessarily mapped in virtal memory.
-        * - LNET_MD_IOVEC bit set: The start field points to the starting
-        * address of an array of struct kvec and the length field specifies
-        * the number of entries in the array. The length can't be bigger
-        * than LNET_MAX_IOV. The struct kvec is used to describe fragments
-        * that have virtual addresses.
         * - Otherwise: The memory region is contiguous. The start field
         * specifies the starting address for the memory region and the
         * length field specifies its length.
@@ -470,15 +282,17 @@ typedef struct lnet_md {
         *   acknowledgment. Acknowledgments are never sent for GET operations.
         *   The data sent in the REPLY serves as an implicit acknowledgment.
         * - LNET_MD_KIOV: The start and length fields specify an array of
-        *   lnet_kiov_t.
-        * - LNET_MD_IOVEC: The start and length fields specify an array of
-        *   struct iovec.
+        *   struct bio_vec.
         * - LNET_MD_MAX_SIZE: The max_size field is valid.
         * - LNET_MD_BULK_HANDLE: The bulk_handle field is valid.
+        * - LNET_MD_TRACK_RESPONSE: Enable response tracking on this MD
+        *   regardless of the value of the lnet_response_tracking param.
+        * - LNET_MD_NO_TRACK_RESPONSE: Disable response tracking on this MD
+        *   regardless of the value of the lnet_response_tracking param.
         *
         * Note:
-        * - LNET_MD_KIOV or LNET_MD_IOVEC allows for a scatter/gather
-        *   capability for memory descriptors. They can't be both set.
+        * - LNET_MD_KIOV allows for a scatter/gather capability for memory
+        *   descriptors.
         * - When LNET_MD_MAX_SIZE is set, the total length of the memory
         *   region (i.e. sum of all fragment lengths) must not be less than
         *   \a max_size.
@@ -492,12 +306,11 @@ typedef struct lnet_md {
         */
        void            *user_ptr;
        /**
-        * A handle for the event queue used to log the operations performed on
-        * the memory region. If this argument is a NULL handle (i.e. nullified
-        * by LNetInvalidateHandle()), operations performed on this memory
-        * descriptor are not logged.
+        * The event handler used to log the operations performed on
+        * the memory region. If this argument is NULL operations
+        * performed on this memory descriptor are not logged.
         */
-       struct lnet_handle_eq eq_handle;
+       lnet_handler_t  handler;
        /**
         * The bulk MD handle which was registered to describe the buffers
         * either to be used to transfer data to the peer or receive data
@@ -507,7 +320,7 @@ typedef struct lnet_md {
         * if the LNET_MD_BULK_HANDLE option is set.
         */
        struct lnet_handle_md bulk_handle;
-} lnet_md_t;
+};
 
 /* Max Transfer Unit (minimum supported everywhere).
  * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks)
@@ -515,9 +328,6 @@ typedef struct lnet_md {
 #define LNET_MTU_BITS  20
 #define LNET_MTU       (1 << LNET_MTU_BITS)
 
-/** limit on the number of fragments in discontiguous MDs */
-#define LNET_MAX_IOV   256
-
 /**
  * Options for the MD structure. See struct lnet_md::options.
  */
@@ -532,35 +342,21 @@ typedef struct lnet_md {
 /** See struct lnet_md::options. */
 #define LNET_MD_ACK_DISABLE         (1 << 5)
 /** See struct lnet_md::options. */
-#define LNET_MD_IOVEC               (1 << 6)
+/* deprecated #define LNET_MD_IOVEC  (1 << 6) */
 /** See struct lnet_md::options. */
 #define LNET_MD_MAX_SIZE            (1 << 7)
 /** See struct lnet_md::options. */
 #define LNET_MD_KIOV                (1 << 8)
 /** See struct lnet_md::options. */
 #define LNET_MD_BULK_HANDLE         (1 << 9)
-
-/* For compatibility with Cray Portals */
-#define LNET_MD_PHYS                        0
+/** See struct lnet_md::options. */
+#define LNET_MD_TRACK_RESPONSE      (1 << 10)
+/** See struct lnet_md::options. */
+#define LNET_MD_NO_TRACK_RESPONSE    (1 << 11)
 
 /** Infinite threshold on MD operations. See struct lnet_md::threshold */
 #define LNET_MD_THRESH_INF      (-1)
 
-/**
- * A page-based fragment of a MD.
- */
-typedef struct {
-       /** Pointer to the page where the fragment resides */
-       struct page      *kiov_page;
-       /** Length in bytes of the fragment */
-       unsigned int     kiov_len;
-       /**
-        * Starting offset of the fragment within the page. Note that the
-        * end of the fragment must not pass the end of the page; i.e.,
-        * kiov_len + kiov_offset <= PAGE_SIZE.
-        */
-       unsigned int     kiov_offset;
-} lnet_kiov_t;
 /** @} lnet_md */
 
 /** \addtogroup lnet_eq
@@ -569,7 +365,7 @@ typedef struct {
 /**
  * Six types of events can be logged in an event queue.
  */
-typedef enum lnet_event_kind {
+enum lnet_event_kind {
        /** An incoming GET operation has completed on the MD. */
        LNET_EVENT_GET          = 1,
        /**
@@ -605,14 +401,14 @@ typedef enum lnet_event_kind {
         * \see LNetMDUnlink
         */
        LNET_EVENT_UNLINK,
-} lnet_event_kind_t;
+};
 
 #define LNET_SEQ_GT(a, b)      (((signed long)((a) - (b))) > 0)
 
 /**
  * Information about an event on a MD.
  */
-typedef struct lnet_event {
+struct lnet_event {
        /** The identifier (nid, pid) of the target. */
        struct lnet_process_id   target;
        /** The identifier (nid, pid) of the initiator. */
@@ -647,17 +443,23 @@ typedef struct lnet_event {
         */
        struct lnet_handle_md   md_handle;
        /**
-        * A snapshot of the state of the MD immediately after the event has
-        * been processed. In particular, the threshold field in md will
-        * reflect the value of the threshold after the operation occurred.
+        * A snapshot of relevant state of the MD immediately after the event
+        * has been processed.
         */
-       struct lnet_md           md;
+       void                    *md_start;
+       void                    *md_user_ptr;
+       unsigned int            md_options;
        /**
         * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
         * \see LNetPut
         */
        __u64               hdr_data;
        /**
+        * The message type, to ensure a handler for LNET_EVENT_SEND can
+        * distinguish between LNET_MSG_GET and LNET_MSG_PUT.
+        */
+       __u32               msg_type;
+       /**
         * Indicates the completion status of the operation. It's 0 for
         * successful operations, otherwise it's an error code.
         */
@@ -681,21 +483,7 @@ typedef struct lnet_event {
         * to each event.
         */
        volatile unsigned long sequence;
-} lnet_event_t;
-
-/**
- * Event queue handler function type.
- *
- * The EQ handler runs for each event that is deposited into the EQ. The
- * handler is supplied with a pointer to the event that triggered the
- * handler invocation.
- *
- * The handler must not block, must be reentrant, and must not call any LNet
- * API functions. It should return as quickly as possible.
- */
-typedef void (*lnet_eq_handler_t)(struct lnet_event *event);
-#define LNET_EQ_HANDLER_NONE NULL
-/** @} lnet_eq */
+};
 
 /** \addtogroup lnet_data
  * @{ */
@@ -708,12 +496,26 @@ typedef void (*lnet_eq_handler_t)(struct lnet_event *event);
  * \see struct lnet_md::options for the discussion on LNET_MD_ACK_DISABLE
  * by which acknowledgments can be disabled for a MD.
  */
-typedef enum lnet_ack_req {
+enum lnet_ack_req {
        /** Request an acknowledgment */
        LNET_ACK_REQ,
        /** Request that no acknowledgment should be generated. */
        LNET_NOACK_REQ
-} lnet_ack_req_t;
+};
+
+/**
+ * UDSP action types. There are two available actions:
+ *     1. PRIORITY - set priority of matching LNet constructs
+ *     2. PREFERRED LIST - set preferred list of matching LNet constructs
+ */
+enum lnet_udsp_action_type {
+       EN_LNET_UDSP_ACTION_NONE = 0,
+       /** assign a priority to matching constructs */
+       EN_LNET_UDSP_ACTION_PRIORITY = 1,
+       /** assign a preferred list of NIDs to matching constructs */
+       EN_LNET_UDSP_ACTION_PREFERRED_LIST = 2,
+};
+
 /** @} lnet_data */
 
 /** @} lnet */