From 6ae187404a8d7f8a41a06c797cdd2dde90f93bd7 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sat, 26 Dec 2020 12:19:19 -0500 Subject: [PATCH] LU-12678 lnet: discard WIRE_ATTR This macro adds nothing of value, and make the code harder to read for new readers so it was remove for the Linux client. We still want to keep track of what data structures are transmitted over the wire and ensure the protocol does not get broken. Move the wire protocol structures to their own header files and add wire checking. Linux-commit: 3e60455d1953fcee6042c107a8d5657886aa9c58 Test-Parameters: trivial Change-Id: I4867e80bf8e8f0598d1920865d6f1b9ba920ce5b Signed-off-by: Mr NeilBrown Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/37914 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lnet/include/lnet/socklnd.h | 8 +- lnet/include/uapi/linux/lnet/Makefile.am | 2 + lnet/include/uapi/linux/lnet/lnet-idl.h | 240 ++++++++++++++++++++++++++++++ lnet/include/uapi/linux/lnet/lnet-types.h | 199 +------------------------ lnet/include/uapi/linux/lnet/lnetst.h | 5 +- lnet/klnds/gnilnd/gnilnd.h | 22 +-- lnet/klnds/o2iblnd/autoMakefile.am | 2 +- lnet/klnds/o2iblnd/o2iblnd-idl.h | 156 +++++++++++++++++++ lnet/klnds/o2iblnd/o2iblnd.c | 166 ++++++++++++++++++++- lnet/klnds/o2iblnd/o2iblnd.h | 116 +-------------- lnet/lnet/api-ni.c | 50 ++++++- lnet/selftest/rpc.h | 48 +++--- 12 files changed, 652 insertions(+), 362 deletions(-) create mode 100644 lnet/include/uapi/linux/lnet/lnet-idl.h create mode 100644 lnet/klnds/o2iblnd/o2iblnd-idl.h diff --git a/lnet/include/lnet/socklnd.h b/lnet/include/lnet/socklnd.h index e2c19f2..ffc2b1d 100644 --- a/lnet/include/lnet/socklnd.h +++ b/lnet/include/lnet/socklnd.h @@ -47,7 +47,7 @@ struct ksock_hello_msg { __u32 kshm_ctype; /* connection type */ __u32 kshm_nips; /* # IP addrs */ __u32 kshm_ips[0]; /* IP addrs */ -} WIRE_ATTR; +} __packed; struct ksock_lnet_msg { struct lnet_hdr ksnm_hdr; /* lnet hdr */ @@ -58,7 +58,7 @@ struct ksock_lnet_msg { * structure definitions. lnet payload will be stored just after * the body of structure struct ksock_lnet_msg */ -} WIRE_ATTR; +} __packed; struct ksock_msg { __u32 ksm_type; /* type of socklnd message */ @@ -66,8 +66,8 @@ struct ksock_msg { __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */ union { struct ksock_lnet_msg lnetmsg; /* lnet message, it's empty if it's NOOP */ - } WIRE_ATTR ksm_u; -} WIRE_ATTR; + } __packed ksm_u; +} __packed; #define KSOCK_MSG_NOOP 0xc0 /* ksm_u empty */ #define KSOCK_MSG_LNET 0xc1 /* lnet msg */ diff --git a/lnet/include/uapi/linux/lnet/Makefile.am b/lnet/include/uapi/linux/lnet/Makefile.am index bb70adf..5d9847c 100644 --- a/lnet/include/uapi/linux/lnet/Makefile.am +++ b/lnet/include/uapi/linux/lnet/Makefile.am @@ -36,6 +36,7 @@ lnetinclude_HEADERS = \ lnetctl.h \ lnet-dlc.h \ lnetst.h \ + lnet-idl.h \ lnet-types.h \ nidstr.h \ socklnd.h @@ -46,6 +47,7 @@ EXTRA_DIST = \ lnetctl.h \ lnet-dlc.h \ lnetst.h \ + lnet-idl.h \ lnet-types.h \ nidstr.h \ socklnd.h diff --git a/lnet/include/uapi/linux/lnet/lnet-idl.h b/lnet/include/uapi/linux/lnet/lnet-idl.h new file mode 100644 index 0000000..8589a90 --- /dev/null +++ b/lnet/include/uapi/linux/lnet/lnet-idl.h @@ -0,0 +1,240 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * 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_IDL_H__ +#define __UAPI_LNET_IDL_H__ + +#include + +/************************************************************************ + * Core LNet wire message format. + * These are sent in sender's byte order (i.e. receiver flips). + */ + +/** + * 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; + +/* 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 */ +} __attribute__((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). + */ +struct lnet_handle_wire { + __u64 wh_interface_cookie; + __u64 wh_object_cookie; +} __attribute__((packed)); + +enum lnet_msg_type { + LNET_MSG_ACK = 0, + LNET_MSG_PUT, + LNET_MSG_GET, + LNET_MSG_REPLY, + LNET_MSG_HELLO, +}; + +/* 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; +} __attribute__((packed)); + +struct lnet_put { + struct lnet_handle_wire ack_wmd; + __u64 match_bits; + __u64 hdr_data; + __u32 ptl_index; + __u32 offset; +} __attribute__((packed)); + +struct lnet_get { + struct lnet_handle_wire return_wmd; + __u64 match_bits; + __u32 ptl_index; + __u32 src_offset; + __u32 sink_length; +} __attribute__((packed)); + +struct lnet_reply { + struct lnet_handle_wire dst_wmd; +} __attribute__((packed)); + +struct lnet_hello { + __u64 incarnation; + __u32 type; +} __attribute__((packed)); + +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; +} __attribute__((packed)); + +/* 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 */ +} __attribute__((packed)); + +/* 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 */ +} __attribute__((packed)); + +#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; +} __attribute__((packed)); + + +#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; +} __attribute__((packed)); + +/* + * 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]; +} __attribute__((packed)); + +#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) + +#endif diff --git a/lnet/include/uapi/linux/lnet/lnet-types.h b/lnet/include/uapi/linux/lnet/lnet-types.h index cc9ec76..f8be3e2 100644 --- a/lnet/include/uapi/linux/lnet/lnet-types.h +++ b/lnet/include/uapi/linux/lnet/lnet-types.h @@ -36,7 +36,8 @@ /** \addtogroup lnet * @{ */ -#include +#include + /** \addtogroup lnet_addr * @{ */ @@ -47,24 +48,6 @@ */ #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 */ @@ -112,136 +95,6 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num) #define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY) -#define WIRE_ATTR __attribute__((packed)) - -/* 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, -}; - -/* 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; - -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; - struct lnet_counters_health { __u32 lch_rst_alloc; __u32 lch_resend_count; @@ -263,54 +116,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 diff --git a/lnet/include/uapi/linux/lnet/lnetst.h b/lnet/include/uapi/linux/lnet/lnetst.h index 3c512b0..7346609 100644 --- a/lnet/include/uapi/linux/lnet/lnetst.h +++ b/lnet/include/uapi/linux/lnet/lnetst.h @@ -515,6 +515,7 @@ struct lst_test_ping_param { int png_flags; /* reserved flags */ }; +/* Both struct srpc_counters and struct sfw_counters are sent over the wire */ struct srpc_counters { __u32 errors; __u32 rpcs_sent; @@ -523,7 +524,7 @@ struct srpc_counters { __u32 rpcs_expired; __u64 bulk_get; __u64 bulk_put; -} WIRE_ATTR; +} __attribute__((packed)); struct sfw_counters { /** milliseconds since current session started */ @@ -532,6 +533,6 @@ struct sfw_counters { __u32 zombie_sessions; __u32 brw_errors; __u32 ping_errors; -} WIRE_ATTR; +} __attribute__((packed)); #endif diff --git a/lnet/klnds/gnilnd/gnilnd.h b/lnet/klnds/gnilnd/gnilnd.h index 571f9b9..03cdd07 100644 --- a/lnet/klnds/gnilnd/gnilnd.h +++ b/lnet/klnds/gnilnd/gnilnd.h @@ -346,7 +346,7 @@ typedef enum kgn_dgram_type { v2: * - added checksum to FMA * moved seq before paylod - * WIRE_ATTR added for alignment + * __packed added for alignment v3: * added gnm_payload_len for FMA payload size v4: @@ -373,12 +373,12 @@ typedef struct kgn_gniparams { __u32 gnpr_host_id; /* ph. host ID of the NIC */ __u32 gnpr_cqid; /* cqid I want peer to use when sending events to me */ gni_smsg_attr_t gnpr_smsg_attr; /* my short msg. attributes */ -} WIRE_ATTR kgn_gniparams_t; +} __packed kgn_gniparams_t; typedef struct kgn_nak_data { __s32 gnnd_errno; /* errno reason for NAK */ -} WIRE_ATTR kgn_nak_data_t; +} __packed kgn_nak_data_t; /* the first bits of the connreq struct CANNOT CHANGE FORM EVER * without breaking the ability for us to properly NAK someone */ @@ -400,42 +400,42 @@ typedef struct kgn_connreq { /* connection request/response * kgn_gniparams_t gncr_gnparams; /* sender's endpoint info */ kgn_nak_data_t gncr_nakdata; /* data (rc, etc) for NAK */ }; -} WIRE_ATTR kgn_connreq_t; +} __packed kgn_connreq_t; typedef struct { gni_mem_handle_t gnrd_key; __u64 gnrd_addr; __u32 gnrd_nob; -} WIRE_ATTR kgn_rdma_desc_t; +} __packed kgn_rdma_desc_t; typedef struct { struct lnet_hdr gnim_hdr; /* LNet header */ /* LNet payload is in FMA "Message Data" */ -} WIRE_ATTR kgn_immediate_msg_t; +} __packed kgn_immediate_msg_t; typedef struct { struct lnet_hdr gnprm_hdr; /* LNet header */ __u64 gnprm_cookie; /* opaque completion cookie */ -} WIRE_ATTR kgn_putreq_msg_t; +} __packed kgn_putreq_msg_t; typedef struct { __u64 gnpam_src_cookie; /* reflected completion cookie */ __u64 gnpam_dst_cookie; /* opaque completion cookie */ __u16 gnpam_payload_cksum; /* checksum for get msg */ kgn_rdma_desc_t gnpam_desc; /* sender's sink buffer */ -} WIRE_ATTR kgn_putack_msg_t; +} __packed kgn_putack_msg_t; typedef struct { struct lnet_hdr gngm_hdr; /* LNet header */ __u64 gngm_cookie; /* opaque completion cookie */ __u16 gngm_payload_cksum; /* checksum for put msg */ kgn_rdma_desc_t gngm_desc; /* sender's sink buffer */ -} WIRE_ATTR kgn_get_msg_t; +} __packed kgn_get_msg_t; typedef struct { int gncm_retval; /* error on NAK, size on REQ */ __u64 gncm_cookie; /* reflected completion cookie */ -} WIRE_ATTR kgn_completion_msg_t; +} __packed kgn_completion_msg_t; typedef struct { /* NB must fit in FMA "Prefix" */ __u32 gnm_magic; /* I'm an gni message */ @@ -454,7 +454,7 @@ typedef struct { /* NB must fit in FMA "Prefix" * kgn_get_msg_t get; kgn_completion_msg_t completion; } gnm_u; -} WIRE_ATTR kgn_msg_t; +} __packed kgn_msg_t; /************************************************************************ * runtime tunable data diff --git a/lnet/klnds/o2iblnd/autoMakefile.am b/lnet/klnds/o2iblnd/autoMakefile.am index 304a4b7..839926d 100644 --- a/lnet/klnds/o2iblnd/autoMakefile.am +++ b/lnet/klnds/o2iblnd/autoMakefile.am @@ -37,4 +37,4 @@ endif endif MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ -EXTRA_DIST = $(ko2iblnd-objs:%.o=%.c) o2iblnd.h +EXTRA_DIST = $(ko2iblnd-objs:%.o=%.c) o2iblnd-idl.h o2iblnd.h diff --git a/lnet/klnds/o2iblnd/o2iblnd-idl.h b/lnet/klnds/o2iblnd/o2iblnd-idl.h new file mode 100644 index 0000000..7d47e46 --- /dev/null +++ b/lnet/klnds/o2iblnd/o2iblnd-idl.h @@ -0,0 +1,156 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2017, Intel Corporation. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lnet/klnds/o2iblnd/o2iblnd-idl.h + * + * Author: Eric Barton + */ +#ifndef __LNET_O2IBLND_IDL_H__ +#define __LNET_O2IBLND_IDL_H__ + +#include + +/************************************************************************ + * IB Wire message format. + * These are sent in sender's byte order (i.e. receiver flips). + */ + +struct kib_connparams { + u16 ibcp_queue_depth; + u16 ibcp_max_frags; + u32 ibcp_max_msg_size; +} __packed; + +struct kib_immediate_msg { + struct lnet_hdr ibim_hdr; /* portals header */ + char ibim_payload[0];/* piggy-backed payload */ +} __packed; + +struct kib_rdma_frag { + u32 rf_nob; /* # bytes this frag */ + u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */ +} __packed; + +struct kib_rdma_desc { + u32 rd_key; /* local/remote key */ + u32 rd_nfrags; /* # fragments */ + struct kib_rdma_frag rd_frags[0]; /* buffer frags */ +} __packed; + +struct kib_putreq_msg { + struct lnet_hdr ibprm_hdr; /* portals header */ + u64 ibprm_cookie; /* opaque completion cookie */ +} __packed; + +struct kib_putack_msg { + u64 ibpam_src_cookie;/* reflected completion cookie */ + u64 ibpam_dst_cookie;/* opaque completion cookie */ + struct kib_rdma_desc ibpam_rd; /* sender's sink buffer */ +} __packed; + +struct kib_get_msg { + struct lnet_hdr ibgm_hdr; /* portals header */ + u64 ibgm_cookie; /* opaque completion cookie */ + struct kib_rdma_desc ibgm_rd; /* rdma descriptor */ +} __packed; + +struct kib_completion_msg { + u64 ibcm_cookie; /* opaque completion cookie */ + s32 ibcm_status; /* < 0 failure: >= 0 length */ +} __packed; + +struct kib_msg { + /* First 2 fields fixed FOR ALL TIME */ + u32 ibm_magic; /* I'm an ibnal message */ + u16 ibm_version; /* this is my version number */ + + u8 ibm_type; /* msg type */ + u8 ibm_credits; /* returned credits */ + u32 ibm_nob; /* # bytes in whole message */ + u32 ibm_cksum; /* checksum (0 == no checksum) */ + u64 ibm_srcnid; /* sender's NID */ + u64 ibm_srcstamp; /* sender's incarnation */ + u64 ibm_dstnid; /* destination's NID */ + u64 ibm_dststamp; /* destination's incarnation */ + + union { + struct kib_connparams connparams; + struct kib_immediate_msg immediate; + struct kib_putreq_msg putreq; + struct kib_putack_msg putack; + struct kib_get_msg get; + struct kib_completion_msg completion; + } __packed ibm_u; +} __packed; + +#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */ + +#define IBLND_MSG_VERSION_1 0x11 +#define IBLND_MSG_VERSION_2 0x12 +#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2 + +#define IBLND_MSG_CONNREQ 0xc0 /* connection request */ +#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */ +#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */ +#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */ +#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */ +#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */ +#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */ +#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */ +#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */ +#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */ + +struct kib_rej { + u32 ibr_magic; /* sender's magic */ + u16 ibr_version; /* sender's version */ + u8 ibr_why; /* reject reason */ + u8 ibr_padding; /* padding */ + u64 ibr_incarnation;/* incarnation of peer_ni */ + struct kib_connparams ibr_cp; /* connection parameters */ +} __packed; + +/* connection rejection reasons */ +#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */ +#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */ +#define IBLND_REJECT_FATAL 3 /* Anything else */ + +#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer_ni */ +#define IBLND_REJECT_CONN_STALE 5 /* stale peer_ni */ + +/* peer_ni's rdma frags doesn't match mine */ +#define IBLND_REJECT_RDMA_FRAGS 6 +/* peer_ni's msg queue size doesn't match mine */ +#define IBLND_REJECT_MSG_QUEUE_SIZE 7 +#define IBLND_REJECT_INVALID_SRV_ID 8 + +/***********************************************************************/ + +#endif /* __LNET_O2IBLND_IDL_H__ */ diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index 18ac5fa..b2dbb44 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -3407,6 +3407,164 @@ static const struct lnet_lnd the_o2iblnd = { .lnd_recv = kiblnd_recv, }; +static void ko2inlnd_assert_wire_constants(void) +{ + BUILD_BUG_ON(IBLND_MSG_MAGIC != 0x0be91b91); + BUILD_BUG_ON(IBLND_MSG_VERSION_1 != 0x11); + BUILD_BUG_ON(IBLND_MSG_VERSION_2 != 0x12); + BUILD_BUG_ON(IBLND_MSG_VERSION != IBLND_MSG_VERSION_2); + + BUILD_BUG_ON(IBLND_MSG_CONNREQ != 0xc0); + BUILD_BUG_ON(IBLND_MSG_CONNACK != 0xc1); + BUILD_BUG_ON(IBLND_MSG_NOOP != 0xd0); + BUILD_BUG_ON(IBLND_MSG_IMMEDIATE != 0xd1); + BUILD_BUG_ON(IBLND_MSG_PUT_REQ != 0xd2); + BUILD_BUG_ON(IBLND_MSG_PUT_NAK != 0xd3); + BUILD_BUG_ON(IBLND_MSG_PUT_ACK != 0xd4); + BUILD_BUG_ON(IBLND_MSG_PUT_DONE != 0xd5); + BUILD_BUG_ON(IBLND_MSG_GET_REQ != 0xd6); + BUILD_BUG_ON(IBLND_MSG_GET_DONE != 0xd7); + + BUILD_BUG_ON(IBLND_REJECT_CONN_RACE != 1); + BUILD_BUG_ON(IBLND_REJECT_NO_RESOURCES != 2); + BUILD_BUG_ON(IBLND_REJECT_FATAL != 3); + BUILD_BUG_ON(IBLND_REJECT_CONN_UNCOMPAT != 4); + BUILD_BUG_ON(IBLND_REJECT_CONN_STALE != 5); + BUILD_BUG_ON(IBLND_REJECT_RDMA_FRAGS != 6); + BUILD_BUG_ON(IBLND_REJECT_MSG_QUEUE_SIZE != 7); + BUILD_BUG_ON(IBLND_REJECT_INVALID_SRV_ID != 8); + + BUILD_BUG_ON((int)sizeof(struct kib_connparams) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_connparams, ibcp_queue_depth) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_connparams *)0)->ibcp_queue_depth) != 2); + BUILD_BUG_ON((int)offsetof(struct kib_connparams, ibcp_max_frags) != 2); + BUILD_BUG_ON((int)sizeof(((struct kib_connparams *)0)->ibcp_max_frags) != 2); + BUILD_BUG_ON((int)offsetof(struct kib_connparams, ibcp_max_msg_size) != 4); + BUILD_BUG_ON((int)sizeof(((struct kib_connparams *)0)->ibcp_max_msg_size) != 4); + + BUILD_BUG_ON((int)sizeof(struct kib_immediate_msg) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_immediate_msg, ibim_hdr) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_immediate_msg *)0)->ibim_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_immediate_msg, ibim_payload) != 72); + BUILD_BUG_ON((int)sizeof(((struct kib_immediate_msg *)0)->ibim_payload) != 0); + + BUILD_BUG_ON((int)sizeof(struct kib_rdma_frag) != 12); + BUILD_BUG_ON((int)offsetof(struct kib_rdma_frag, rf_nob) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_rdma_frag *)0)->rf_nob) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_rdma_frag, rf_addr) != 4); + BUILD_BUG_ON((int)sizeof(((struct kib_rdma_frag *)0)->rf_addr) != 8); + + BUILD_BUG_ON((int)sizeof(struct kib_rdma_desc) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_rdma_desc, rd_key) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_rdma_desc *)0)->rd_key) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_rdma_desc, rd_nfrags) != 4); + BUILD_BUG_ON((int)sizeof(((struct kib_rdma_desc *)0)->rd_nfrags) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_rdma_desc, rd_frags) != 8); + BUILD_BUG_ON((int)sizeof(((struct kib_rdma_desc *)0)->rd_frags) != 0); + + BUILD_BUG_ON((int)sizeof(struct kib_putreq_msg) != 80); + BUILD_BUG_ON((int)offsetof(struct kib_putreq_msg, ibprm_hdr) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_putreq_msg *)0)->ibprm_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_putreq_msg, ibprm_cookie) != 72); + BUILD_BUG_ON((int)sizeof(((struct kib_putreq_msg *)0)->ibprm_cookie) != 8); + + BUILD_BUG_ON((int)sizeof(struct kib_putack_msg) != 24); + BUILD_BUG_ON((int)offsetof(struct kib_putack_msg, ibpam_src_cookie) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_putack_msg *)0)->ibpam_src_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_putack_msg, ibpam_dst_cookie) != 8); + BUILD_BUG_ON((int)sizeof(((struct kib_putack_msg *)0)->ibpam_dst_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_putack_msg, ibpam_rd) != 16); + BUILD_BUG_ON((int)sizeof(((struct kib_putack_msg *)0)->ibpam_rd) != 8); + + BUILD_BUG_ON((int)sizeof(struct kib_get_msg) != 88); + BUILD_BUG_ON((int)offsetof(struct kib_get_msg, ibgm_hdr) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_get_msg *)0)->ibgm_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_get_msg, ibgm_cookie) != 72); + BUILD_BUG_ON((int)sizeof(((struct kib_get_msg *)0)->ibgm_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_get_msg, ibgm_rd) != 80); + BUILD_BUG_ON((int)sizeof(((struct kib_get_msg *)0)->ibgm_rd) != 8); + + BUILD_BUG_ON((int)sizeof(struct kib_completion_msg) != 12); + BUILD_BUG_ON((int)offsetof(struct kib_completion_msg, ibcm_cookie) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_completion_msg *)0)->ibcm_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_completion_msg, ibcm_status) != 8); + BUILD_BUG_ON((int)sizeof(((struct kib_completion_msg *)0)->ibcm_status) != 4); + + /* Checks for struct kib_msg */ + //BUILD_BUG_ON((int)sizeof(struct kib_msg) != 12); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_magic) != 0); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_magic) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_version) != 4); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_version) != 2); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_type) != 6); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_type) != 1); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_credits) != 7); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_credits) != 1); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_nob) != 8); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_nob) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_cksum) != 12); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_cksum) != 4); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_srcnid) != 16); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_srcnid) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_srcstamp) != 24); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_srcstamp) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_dstnid) != 32); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_dstnid) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_dststamp) != 40); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_dststamp) != 8); + + /* Connparams */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.connparams.ibcp_queue_depth) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.connparams.ibcp_queue_depth) != 2); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.connparams.ibcp_max_frags) != 50); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.connparams.ibcp_max_frags) != 2); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.connparams.ibcp_max_msg_size) != 52); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.connparams.ibcp_max_msg_size) != 4); + + /* Immediate message */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.immediate.ibim_hdr) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.immediate.ibim_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.immediate.ibim_payload) != 120); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.immediate.ibim_payload) != 0); + + /* PUT req message */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.putreq.ibprm_hdr) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.putreq.ibprm_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.putreq.ibprm_cookie) != 120); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.putreq.ibprm_cookie) != 8); + + /* Put ACK */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.putack.ibpam_src_cookie) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.putack.ibpam_src_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.putack.ibpam_dst_cookie) != 56); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.putack.ibpam_dst_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.putack.ibpam_rd) != 64); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.putack.ibpam_rd) != 8); + + /* GET message */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.get.ibgm_hdr) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.get.ibgm_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.get.ibgm_cookie) != 120); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.get.ibgm_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.get.ibgm_rd) != 128); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.get.ibgm_rd) != 8); + + /* Completion message */ + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.completion.ibcm_cookie) != 48); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.completion.ibcm_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct kib_msg, ibm_u.completion.ibcm_status) != 56); + BUILD_BUG_ON((int)sizeof(((struct kib_msg *)0)->ibm_u.completion.ibcm_status) != 4); + + /* Sanity checks */ + BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); + BUILD_BUG_ON(offsetof(struct kib_msg, + ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > + IBLND_MSG_SIZE); + BUILD_BUG_ON(offsetof(struct kib_msg, + ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > + IBLND_MSG_SIZE); +} + static void __exit ko2iblnd_exit(void) { lnet_unregister_lnd(&the_o2iblnd); @@ -3416,13 +3574,7 @@ static int __init ko2iblnd_init(void) { int rc; - BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); - BUILD_BUG_ON(offsetof(struct kib_msg, - ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > - IBLND_MSG_SIZE); - BUILD_BUG_ON(offsetof(struct kib_msg, - ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > - IBLND_MSG_SIZE); + ko2inlnd_assert_wire_constants(); rc = kiblnd_tunables_init(); if (rc != 0) diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index b8061f2..60d1590 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -91,6 +91,7 @@ #include #include +#include "o2iblnd-idl.h" #define IBLND_PEER_HASH_SIZE 101 /* # peer_ni lists */ @@ -470,121 +471,6 @@ struct kib_data { #define IBLND_INIT_DATA 1 #define IBLND_INIT_ALL 2 -/************************************************************************ - * IB Wire message format. - * These are sent in sender's byte order (i.e. receiver flips). - */ - -struct kib_connparams { - __u16 ibcp_queue_depth; - __u16 ibcp_max_frags; - __u32 ibcp_max_msg_size; -} WIRE_ATTR; - -struct kib_immediate_msg { - struct lnet_hdr ibim_hdr; /* portals header */ - char ibim_payload[0];/* piggy-backed payload */ -} WIRE_ATTR; - -struct kib_rdma_frag { - __u32 rf_nob; /* # bytes this frag */ - __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */ -} WIRE_ATTR; - -struct kib_rdma_desc { - __u32 rd_key; /* local/remote key */ - __u32 rd_nfrags; /* # fragments */ - struct kib_rdma_frag rd_frags[0]; /* buffer frags */ -} WIRE_ATTR; - -struct kib_putreq_msg { - struct lnet_hdr ibprm_hdr; /* portals header */ - __u64 ibprm_cookie; /* opaque completion cookie */ -} WIRE_ATTR; - -struct kib_putack_msg { - __u64 ibpam_src_cookie; /* reflected completion cookie */ - __u64 ibpam_dst_cookie; /* opaque completion cookie */ - struct kib_rdma_desc ibpam_rd; /* sender's sink buffer */ -} WIRE_ATTR; - -struct kib_get_msg { - struct lnet_hdr ibgm_hdr; /* portals header */ - __u64 ibgm_cookie; /* opaque completion cookie */ - struct kib_rdma_desc ibgm_rd; /* rdma descriptor */ -} WIRE_ATTR; - -struct kib_completion_msg { - __u64 ibcm_cookie; /* opaque completion cookie */ - __s32 ibcm_status; /* < 0 failure: >= 0 length */ -} WIRE_ATTR; - -struct kib_msg { - /* First 2 fields fixed FOR ALL TIME */ - __u32 ibm_magic; /* I'm an ibnal message */ - __u16 ibm_version; /* this is my version number */ - - __u8 ibm_type; /* msg type */ - __u8 ibm_credits; /* returned credits */ - __u32 ibm_nob; /* # bytes in whole message */ - __u32 ibm_cksum; /* checksum (0 == no checksum) */ - __u64 ibm_srcnid; /* sender's NID */ - __u64 ibm_srcstamp; /* sender's incarnation */ - __u64 ibm_dstnid; /* destination's NID */ - __u64 ibm_dststamp; /* destination's incarnation */ - - union { - struct kib_connparams connparams; - struct kib_immediate_msg immediate; - struct kib_putreq_msg putreq; - struct kib_putack_msg putack; - struct kib_get_msg get; - struct kib_completion_msg completion; - } WIRE_ATTR ibm_u; -} WIRE_ATTR; - -#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */ - -#define IBLND_MSG_VERSION_1 0x11 -#define IBLND_MSG_VERSION_2 0x12 -#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2 - -#define IBLND_MSG_CONNREQ 0xc0 /* connection request */ -#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */ -#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */ -#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */ -#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */ -#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */ -#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */ -#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */ -#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */ -#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */ - -struct kib_rej { - __u32 ibr_magic; /* sender's magic */ - __u16 ibr_version; /* sender's version */ - __u8 ibr_why; /* reject reason */ - __u8 ibr_padding; /* padding */ - __u64 ibr_incarnation; /* incarnation of peer_ni */ - struct kib_connparams ibr_cp; /* connection parameters */ -} WIRE_ATTR; - -/* connection rejection reasons */ -#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */ -#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */ -#define IBLND_REJECT_FATAL 3 /* Anything else */ - -#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer_ni */ -#define IBLND_REJECT_CONN_STALE 5 /* stale peer_ni */ - -/* peer_ni's rdma frags doesn't match mine */ -#define IBLND_REJECT_RDMA_FRAGS 6 -/* peer_ni's msg queue size doesn't match mine */ -#define IBLND_REJECT_MSG_QUEUE_SIZE 7 -#define IBLND_REJECT_INVALID_SRV_ID 8 - -/***********************************************************************/ - struct kib_rx { /* receive message */ /* queue for attention */ struct list_head rx_list; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index a75e2f1..4c3f6a4 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -749,7 +749,8 @@ static void lnet_assert_wire_constants(void) /* Wire protocol assertions generated by 'wirecheck' * running on Linux robert.bartonsoftware.com 2.6.8-1.521 * #1 Mon Aug 16 09:01:18 EDT 2004 i686 athlon i386 GNU/Linux - * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) */ + * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) + */ /* Constants... */ BUILD_BUG_ON(LNET_PROTO_TCP_MAGIC != 0xeebc0ded); @@ -761,6 +762,16 @@ static void lnet_assert_wire_constants(void) BUILD_BUG_ON(LNET_MSG_REPLY != 3); BUILD_BUG_ON(LNET_MSG_HELLO != 4); + BUILD_BUG_ON((int)sizeof(lnet_nid_t) != 8); + BUILD_BUG_ON((int)sizeof(lnet_pid_t) != 4); + + /* Checks for struct lnet_process_id_packed */ + BUILD_BUG_ON((int)sizeof(struct lnet_process_id_packed) != 12); + BUILD_BUG_ON((int)offsetof(struct lnet_process_id_packed, nid) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_process_id_packed *)0)->nid) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_process_id_packed, pid) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_process_id_packed *)0)->pid) != 4); + /* Checks for struct lnet_handle_wire */ BUILD_BUG_ON((int)sizeof(struct lnet_handle_wire) != 16); BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, @@ -875,6 +886,43 @@ static void lnet_assert_wire_constants(void) BUILD_BUG_ON((int)sizeof(((struct lnet_ping_info *)0)->pi_nnis) != 4); BUILD_BUG_ON((int)offsetof(struct lnet_ping_info, pi_ni) != 16); BUILD_BUG_ON((int)sizeof(((struct lnet_ping_info *)0)->pi_ni) != 0); + + /* Acceptor connection request */ + BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1); + + /* Checks for struct lnet_acceptor_connreq */ + BUILD_BUG_ON((int)sizeof(struct lnet_acceptor_connreq) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_magic) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_magic) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_version) != 4); + BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_version) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_nid) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_nid) != 8); + + /* Checks for struct lnet_counters_common */ + BUILD_BUG_ON((int)sizeof(struct lnet_counters_common) != 60); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_msgs_alloc) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_msgs_alloc) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_msgs_max) != 4); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_msgs_max) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_errors) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_errors) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_send_count) != 12); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_send_count) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_recv_count) != 16); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_recv_count) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_route_count) != 20); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_route_count) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_drop_count) != 24); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_drop_count) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_send_length) != 28); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_send_length) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_recv_length) != 36); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_recv_length) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_route_length) != 44); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_route_length) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_drop_length) != 52); + BUILD_BUG_ON((int)sizeof(((struct lnet_counters_common *)0)->lcc_drop_length) != 8); } static const struct lnet_lnd *lnet_find_lnd_by_type(__u32 type) diff --git a/lnet/selftest/rpc.h b/lnet/selftest/rpc.h index 8cc8c43..bcd7483 100644 --- a/lnet/selftest/rpc.h +++ b/lnet/selftest/rpc.h @@ -71,12 +71,12 @@ enum srpc_msg_type { struct srpc_generic_reqst { __u64 rpyid; /* reply buffer matchbits */ __u64 bulkid; /* bulk buffer matchbits */ -} WIRE_ATTR; +} __packed; struct srpc_generic_reply { __u32 status; struct lst_sid sid; -} WIRE_ATTR; +} __packed; /* FRAMEWORK RPCs */ struct srpc_mksn_reqst { @@ -84,43 +84,43 @@ struct srpc_mksn_reqst { struct lst_sid mksn_sid; /* session id */ __u32 mksn_force; /* use brute force */ char mksn_name[LST_NAME_SIZE]; -} WIRE_ATTR; /* make session request */ +} __packed; /* make session request */ struct srpc_mksn_reply { __u32 mksn_status; /* session status */ struct lst_sid mksn_sid; /* session id */ __u32 mksn_timeout; /* session timeout */ char mksn_name[LST_NAME_SIZE]; -} WIRE_ATTR; /* make session reply */ +} __packed; /* make session reply */ struct srpc_rmsn_reqst { __u64 rmsn_rpyid; /* reply buffer matchbits */ struct lst_sid rmsn_sid; /* session id */ -} WIRE_ATTR; /* remove session request */ +} __packed; /* remove session request */ struct srpc_rmsn_reply { __u32 rmsn_status; struct lst_sid rmsn_sid; /* session id */ -} WIRE_ATTR; /* remove session reply */ +} __packed; /* remove session reply */ struct srpc_join_reqst { __u64 join_rpyid; /* reply buffer matchbits */ struct lst_sid join_sid; /* session id to join */ char join_group[LST_NAME_SIZE]; /* group name */ -} WIRE_ATTR; +} __packed; struct srpc_join_reply { __u32 join_status; /* returned status */ struct lst_sid join_sid; /* session id */ __u32 join_timeout; /* # seconds' inactivity to expire */ char join_session[LST_NAME_SIZE]; /* session name */ -} WIRE_ATTR; +} __packed; struct srpc_debug_reqst { __u64 dbg_rpyid; /* reply buffer matchbits */ struct lst_sid dbg_sid; /* session id */ __u32 dbg_flags; /* bitmap of debug */ -} WIRE_ATTR; +} __packed; struct srpc_debug_reply { __u32 dbg_status; /* returned code */ @@ -128,7 +128,7 @@ struct srpc_debug_reply { __u32 dbg_timeout; /* session timeout */ __u32 dbg_nbatch; /* # of batches in the node */ char dbg_name[LST_NAME_SIZE]; /* session name */ -} WIRE_ATTR; +} __packed; #define SRPC_BATCH_OPC_RUN 1 #define SRPC_BATCH_OPC_STOP 2 @@ -141,20 +141,20 @@ struct srpc_batch_reqst { __u32 bar_opc; /* create/start/stop batch */ __u32 bar_testidx; /* index of test */ __u32 bar_arg; /* parameters */ -} WIRE_ATTR; +} __packed; struct srpc_batch_reply { __u32 bar_status; /* status of request */ struct lst_sid bar_sid; /* session id */ __u32 bar_active; /* # of active tests in batch/test */ __u32 bar_time; /* remained time */ -} WIRE_ATTR; +} __packed; struct srpc_stat_reqst { __u64 str_rpyid; /* reply buffer matchbits */ struct lst_sid str_sid; /* session id */ __u32 str_type; /* type of stat */ -} WIRE_ATTR; +} __packed; struct srpc_stat_reply { __u32 str_status; @@ -162,13 +162,13 @@ struct srpc_stat_reply { struct sfw_counters str_fw; struct srpc_counters str_rpc; struct lnet_counters_common str_lnet; -} WIRE_ATTR; +} __packed; struct test_bulk_req { __u32 blk_opc; /* bulk operation code */ __u32 blk_npg; /* # of pages */ __u32 blk_flags; /* reserved flags */ -} WIRE_ATTR; +} __packed; struct test_bulk_req_v1 { /** bulk operation code */ @@ -179,12 +179,12 @@ struct test_bulk_req_v1 { __u32 blk_len; /** bulk offset */ __u32 blk_offset; -} WIRE_ATTR; +} __packed; struct test_ping_req { __u32 png_size; /* size of ping message */ __u32 png_flags; /* reserved flags */ -} WIRE_ATTR; +} __packed; struct srpc_test_reqst { __u64 tsr_rpyid; /* reply buffer matchbits */ @@ -204,12 +204,12 @@ struct srpc_test_reqst { struct test_bulk_req bulk_v0; struct test_bulk_req_v1 bulk_v1; } tsr_u; -} WIRE_ATTR; +} __packed; struct srpc_test_reply { __u32 tsr_status; /* returned code */ struct lst_sid tsr_sid; -} WIRE_ATTR; +} __packed; /* TEST RPCs */ struct srpc_ping_reqst { @@ -218,13 +218,13 @@ struct srpc_ping_reqst { __u32 pnr_seq; __u64 pnr_time_sec; __u64 pnr_time_nsec; -} WIRE_ATTR; +} __packed; struct srpc_ping_reply { __u32 pnr_status; __u32 pnr_magic; __u32 pnr_seq; -} WIRE_ATTR; +} __packed; struct srpc_brw_reqst { __u64 brw_rpyid; /* reply buffer matchbits */ @@ -232,11 +232,11 @@ struct srpc_brw_reqst { __u32 brw_rw; /* read or write */ __u32 brw_len; /* bulk data len */ __u32 brw_flags; /* bulk data patterns */ -} WIRE_ATTR; /* bulk r/w request */ +} __packed; /* bulk r/w request */ struct srpc_brw_reply { __u32 brw_status; -} WIRE_ATTR; /* bulk r/w reply */ +} __packed; /* bulk r/w reply */ #define SRPC_MSG_MAGIC 0xeeb0f00d #define SRPC_MSG_VERSION 1 @@ -276,7 +276,7 @@ struct srpc_msg { struct srpc_brw_reqst brw_reqst; struct srpc_brw_reply brw_reply; } msg_body; -} WIRE_ATTR; +} __packed; static inline void srpc_unpack_msg_hdr(struct srpc_msg *msg) -- 1.8.3.1