X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Finclude%2Fuapi%2Flinux%2Flnet%2Flnet-types.h;h=5a2a2a0aa7450e9ed9741f2f51e777ed612a1b12;hb=959304eac7;hp=be0c51002363c1325ad61e276ec5e72e8b09101f;hpb=0cf2b328fe1a417e3c4d5ff6216e0b86738d28bf;p=fs%2Flustre-release.git diff --git a/lnet/include/uapi/linux/lnet/lnet-types.h b/lnet/include/uapi/linux/lnet/lnet-types.h index be0c510..5a2a2a0 100644 --- a/lnet/include/uapi/linux/lnet/lnet-types.h +++ b/lnet/include/uapi/linux/lnet/lnet-types.h @@ -27,16 +27,19 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. */ #ifndef __UAPI_LNET_TYPES_H__ #define __UAPI_LNET_TYPES_H__ +#include +#include + /** \addtogroup lnet * @{ */ -#include +#include + /** \addtogroup lnet_addr * @{ */ @@ -47,29 +50,20 @@ */ #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 */ #define LNET_PID_ANY ((lnet_pid_t) -1) +static inline int LNET_NID_IS_ANY(const struct lnet_nid *nid) +{ + /* A NULL pointer can be used to mean "ANY" */ + return !nid || nid->nid_type == 0xFF; +} + +#define LNET_ANY_NID ((struct lnet_nid) \ + {0xFF, 0xFF, ~0, {~0, ~0, ~0, ~0} }) + #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */ #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */ #define LNET_PID_LUSTRE 12345 @@ -99,7 +93,7 @@ static inline __u32 LNET_NETNUM(__u32 net) static inline __u32 LNET_NETTYP(__u32 net) { - return (net >> 16) & 0xffff; + return (net >> 16) & 0xff; } static inline __u32 LNET_MKNET(__u32 type, __u32 num) @@ -107,135 +101,77 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num) return (type << 16) | num; } -#define WIRE_ATTR __attribute__((packed)) +/** The lolnd NID (i.e. myself) */ +#define LNET_NID_LO_0 LNET_MKNID(LNET_MKNET(LOLND, 0), 0) -/* Packed version of struct lnet_process_id to transfer via network */ -struct lnet_process_id_packed { - lnet_nid_t nid; - lnet_pid_t pid; /* node id / process id */ -} WIRE_ATTR; - -/* 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). */ -struct lnet_handle_wire { - __u64 wh_interface_cookie; - __u64 wh_object_cookie; -} WIRE_ATTR; - -enum lnet_msg_type { - LNET_MSG_ACK = 0, - LNET_MSG_PUT, - LNET_MSG_GET, - LNET_MSG_REPLY, - LNET_MSG_HELLO, -}; +#define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY) -/* 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; +static inline int nid_is_nid4(const struct lnet_nid *nid) +{ + return NID_ADDR_BYTES(nid) == 4; +} -struct lnet_put { - struct lnet_handle_wire ack_wmd; - __u64 match_bits; - __u64 hdr_data; - __u32 ptl_index; - __u32 offset; -} WIRE_ATTR; +/* LOLND may not be defined yet, so we cannot use an inline */ +#define nid_is_lo0(__nid) \ + ((__nid)->nid_type == LOLND && \ + nid_is_nid4(__nid) && \ + (__nid)->nid_num == 0 && \ + (__nid)->nid_addr[0] == 0) -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; - -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; - -/* 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. - */ -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; - -/* 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 */ -struct lnet_acceptor_connreq { - __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */ - __u32 acr_version; /* protocol version */ - __u64 acr_nid; /* target NID */ -} WIRE_ATTR; - -#define LNET_PROTO_ACCEPTOR_VERSION 1 - -struct lnet_counters_common { - __u32 lcc_msgs_alloc; - __u32 lcc_msgs_max; - __u32 lcc_errors; - __u32 lcc_send_count; - __u32 lcc_recv_count; - __u32 lcc_route_count; - __u32 lcc_drop_count; - __u64 lcc_send_length; - __u64 lcc_recv_length; - __u64 lcc_route_length; - __u64 lcc_drop_length; -} WIRE_ATTR; +static inline __u32 LNET_NID_NET(const struct lnet_nid *nid) +{ + if (LNET_NID_IS_ANY(nid)) + return LNET_NET_ANY; + else + return LNET_MKNET(nid->nid_type, __be16_to_cpu(nid->nid_num)); +} + +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)); + return; + } + + nid->nid_size = 0; + nid->nid_type = LNET_NETTYP(LNET_NIDNET(nid4)); + nid->nid_num = __cpu_to_be16(LNET_NETNUM(LNET_NIDNET(nid4))); + nid->nid_addr[0] = __cpu_to_be32(LNET_NIDADDR(nid4)); + nid->nid_addr[1] = nid->nid_addr[2] = nid->nid_addr[3] = 0; +} + +static inline lnet_nid_t lnet_nid_to_nid4(const struct lnet_nid *nid) +{ + if (LNET_NID_IS_ANY(nid)) + return LNET_NID_ANY; + + return LNET_MKNID(LNET_NID_NET(nid), __be32_to_cpu(nid->nid_addr[0])); +} + +static inline int nid_same(const struct lnet_nid *n1, + const struct lnet_nid *n2) +{ + return n1->nid_size == n2->nid_size && + n1->nid_type == n2->nid_type && + n1->nid_num == n2->nid_num && + n1->nid_addr[0] == n2->nid_addr[0] && + n1->nid_addr[1] == n2->nid_addr[1] && + n1->nid_addr[2] == n2->nid_addr[2] && + n1->nid_addr[3] == n2->nid_addr[3]; +} + +/* This can be used when we need to hash a nid */ +static inline unsigned long nidhash(const struct lnet_nid *nid) +{ + int i; + unsigned long hash = 0; + + hash ^= LNET_NID_NET(nid); + for (i = 0; i < 4; i++) + hash ^= nid->nid_addr[i]; + return hash; +} struct lnet_counters_health { __u32 lch_rst_alloc; @@ -258,54 +194,6 @@ struct lnet_counters { struct lnet_counters_health lct_health; }; -#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) - /* * This is a hard-coded limit on the number of interfaces supported by * the interface bonding implemented by the ksocknal LND. It must be @@ -322,11 +210,11 @@ 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) struct lnet_handle_md { __u64 cookie; @@ -341,7 +229,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. */ @@ -359,6 +247,34 @@ struct lnet_process_id { /** process id */ lnet_pid_t pid; }; + +/** + * Global process ID - with large addresses + */ +struct lnet_processid { + /** node id */ + struct lnet_nid nid; + /** process id */ + lnet_pid_t pid; +}; + +static inline void +lnet_pid4_to_pid(struct lnet_process_id pid4, struct lnet_processid *pid) +{ + pid->pid = pid4.pid; + lnet_nid4_to_nid(pid4.nid, &pid->nid); +} + +static inline struct lnet_process_id +lnet_pid_to_pid4(struct lnet_processid *pid) +{ + struct lnet_process_id ret; + + ret.pid = pid->pid; + ret.nid = lnet_nid_to_nid4(&pid->nid); + return ret; +} + /** @} lnet_addr */ /** \addtogroup lnet_me @@ -394,6 +310,10 @@ enum lnet_ins_pos { /** \addtogroup lnet_md * @{ */ +struct lnet_hdr_nid16 { + char _bytes[sizeof(struct lnet_hdr)]; +} __attribute__((packed)); + /** * Event queue handler function type. * @@ -405,8 +325,7 @@ enum lnet_ins_pos { * API functions. It should return as quickly as possible. */ struct lnet_event; -typedef void (*lnet_eq_handler_t)(struct lnet_event *event); -#define LNET_EQ_HANDLER_NONE NULL +typedef void (*lnet_handler_t)(struct lnet_event *event); /** * Defines the visible parts of a memory descriptor. Values of this type @@ -477,6 +396,11 @@ struct lnet_md { * 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. + * - LNET_MD_GNILND: Disable warning about exceeding LNET_MAX_IOV. * * Note: * - LNET_MD_KIOV allows for a scatter/gather capability for memory @@ -498,7 +422,7 @@ struct lnet_md { * the memory region. If this argument is NULL operations * performed on this memory descriptor are not logged. */ - lnet_eq_handler_t 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 @@ -537,9 +461,14 @@ struct lnet_md { #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) +/** See struct lnet_md::options. */ +#define LNET_MD_GNILND (1 << 12) +/** Special page mapping handling */ +#define LNET_MD_GPU_ADDR (1 << 13) /** Infinite threshold on MD operations. See struct lnet_md::threshold */ #define LNET_MD_THRESH_INF (-1) @@ -597,25 +526,25 @@ enum lnet_event_kind { */ struct lnet_event { /** The identifier (nid, pid) of the target. */ - struct lnet_process_id target; + struct lnet_processid target; /** The identifier (nid, pid) of the initiator. */ - struct lnet_process_id initiator; + struct lnet_processid initiator; /** The source NID on the initiator. */ - struct lnet_process_id source; + struct lnet_processid source; /** * The NID of the immediate sender. If the request has been forwarded * by routers, this is the NID of the last hop; otherwise it's the * same as the source. */ - lnet_nid_t sender; + struct lnet_nid sender; /** Indicates the type of the event. */ enum lnet_event_kind type; /** The portal table index specified in the request */ - unsigned int pt_index; + unsigned int pt_index; /** A copy of the match bits specified in the request. */ - __u64 match_bits; + __u64 match_bits; /** The length (in bytes) specified in the request. */ - unsigned int rlength; + unsigned int rlength; /** * The length (in bytes) of the data that was manipulated by the * operation. For truncated operations, the manipulated length will be @@ -623,52 +552,53 @@ struct lnet_event { * see struct lnet_md). For all other operations, the manipulated length * will be the length of the requested operation, i.e. rlength. */ - unsigned int mlength; + unsigned int mlength; /** * The handle to the MD associated with the event. The handle may be * invalid if the MD has been unlinked. */ 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; + __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; + __u32 msg_type; /** * Indicates the completion status of the operation. It's 0 for * successful operations, otherwise it's an error code. */ - int status; + int status; /** * Indicates whether the MD has been unlinked. Note that: * - An event with unlinked set is the last event on the MD. * - This field is also set for an explicit LNET_EVENT_UNLINK event. * \see LNetMDUnlink */ - int unlinked; + int unlinked; /** * The displacement (in bytes) into the memory region that the * operation used. The offset can be determined by the operation for * a remote managed MD or by the local MD. * \see struct lnet_md::options */ - unsigned int offset; + unsigned int offset; /** * The sequence number for this event. Sequence numbers are unique * to each event. */ - volatile unsigned long sequence; + volatile unsigned long sequence; }; /** \addtogroup lnet_data @@ -688,6 +618,20 @@ enum lnet_ack_req { /** Request that no acknowledgment should be generated. */ LNET_NOACK_REQ }; + +/** + * 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 */