libceph, rbd: ignore addr->type while comparing in some cases
[linux-2.6-microblaze.git] / include / linux / ceph / msgr.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef CEPH_MSGR_H
3 #define CEPH_MSGR_H
4
5 /*
6  * Data types for message passing layer used by Ceph.
7  */
8
9 #define CEPH_MON_PORT    6789  /* default monitor port */
10
11 /*
12  * tcp connection banner.  include a protocol version. and adjust
13  * whenever the wire protocol changes.  try to keep this string length
14  * constant.
15  */
16 #define CEPH_BANNER "ceph v027"
17 #define CEPH_BANNER_MAX_LEN 30
18
19
20 /*
21  * Rollover-safe type and comparator for 32-bit sequence numbers.
22  * Comparator returns -1, 0, or 1.
23  */
24 typedef __u32 ceph_seq_t;
25
26 static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
27 {
28        return (__s32)a - (__s32)b;
29 }
30
31
32 /*
33  * entity_name -- logical name for a process participating in the
34  * network, e.g. 'mds0' or 'osd3'.
35  */
36 struct ceph_entity_name {
37         __u8 type;      /* CEPH_ENTITY_TYPE_* */
38         __le64 num;
39 } __attribute__ ((packed));
40
41 #define CEPH_ENTITY_TYPE_MON    0x01
42 #define CEPH_ENTITY_TYPE_MDS    0x02
43 #define CEPH_ENTITY_TYPE_OSD    0x04
44 #define CEPH_ENTITY_TYPE_CLIENT 0x08
45 #define CEPH_ENTITY_TYPE_AUTH   0x20
46
47 #define CEPH_ENTITY_TYPE_ANY    0xFF
48
49 extern const char *ceph_entity_type_name(int type);
50
51 /*
52  * entity_addr -- network address
53  */
54 struct ceph_entity_addr {
55         __le32 type;  /* CEPH_ENTITY_ADDR_TYPE_* */
56         __le32 nonce;  /* unique id for process (e.g. pid) */
57         struct sockaddr_storage in_addr;
58 } __attribute__ ((packed));
59
60 static inline bool ceph_addr_equal_no_type(const struct ceph_entity_addr *lhs,
61                                            const struct ceph_entity_addr *rhs)
62 {
63         return !memcmp(&lhs->in_addr, &rhs->in_addr, sizeof(lhs->in_addr)) &&
64                lhs->nonce == rhs->nonce;
65 }
66
67 struct ceph_entity_inst {
68         struct ceph_entity_name name;
69         struct ceph_entity_addr addr;
70 } __attribute__ ((packed));
71
72
73 /* used by message exchange protocol */
74 #define CEPH_MSGR_TAG_READY         1  /* server->client: ready for messages */
75 #define CEPH_MSGR_TAG_RESETSESSION  2  /* server->client: reset, try again */
76 #define CEPH_MSGR_TAG_WAIT          3  /* server->client: wait for racing
77                                           incoming connection */
78 #define CEPH_MSGR_TAG_RETRY_SESSION 4  /* server->client + cseq: try again
79                                           with higher cseq */
80 #define CEPH_MSGR_TAG_RETRY_GLOBAL  5  /* server->client + gseq: try again
81                                           with higher gseq */
82 #define CEPH_MSGR_TAG_CLOSE         6  /* closing pipe */
83 #define CEPH_MSGR_TAG_MSG           7  /* message */
84 #define CEPH_MSGR_TAG_ACK           8  /* message ack */
85 #define CEPH_MSGR_TAG_KEEPALIVE     9  /* just a keepalive byte! */
86 #define CEPH_MSGR_TAG_BADPROTOVER   10 /* bad protocol version */
87 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
88 #define CEPH_MSGR_TAG_FEATURES      12 /* insufficient features */
89 #define CEPH_MSGR_TAG_SEQ           13 /* 64-bit int follows with seen seq number */
90 #define CEPH_MSGR_TAG_KEEPALIVE2    14 /* keepalive2 byte + ceph_timespec */
91 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive2 reply */
92 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16  /* cephx v2 doing server challenge */
93
94 /*
95  * connection negotiation
96  */
97 struct ceph_msg_connect {
98         __le64 features;     /* supported feature bits */
99         __le32 host_type;    /* CEPH_ENTITY_TYPE_* */
100         __le32 global_seq;   /* count connections initiated by this host */
101         __le32 connect_seq;  /* count connections initiated in this session */
102         __le32 protocol_version;
103         __le32 authorizer_protocol;
104         __le32 authorizer_len;
105         __u8  flags;         /* CEPH_MSG_CONNECT_* */
106 } __attribute__ ((packed));
107
108 struct ceph_msg_connect_reply {
109         __u8 tag;
110         __le64 features;     /* feature bits for this session */
111         __le32 global_seq;
112         __le32 connect_seq;
113         __le32 protocol_version;
114         __le32 authorizer_len;
115         __u8 flags;
116 } __attribute__ ((packed));
117
118 #define CEPH_MSG_CONNECT_LOSSY  1  /* messages i send may be safely dropped */
119
120
121 /*
122  * message header
123  */
124 struct ceph_msg_header_old {
125         __le64 seq;       /* message seq# for this session */
126         __le64 tid;       /* transaction id */
127         __le16 type;      /* message type */
128         __le16 priority;  /* priority.  higher value == higher priority */
129         __le16 version;   /* version of message encoding */
130
131         __le32 front_len; /* bytes in main payload */
132         __le32 middle_len;/* bytes in middle payload */
133         __le32 data_len;  /* bytes of data payload */
134         __le16 data_off;  /* sender: include full offset;
135                              receiver: mask against ~PAGE_MASK */
136
137         struct ceph_entity_inst src, orig_src;
138         __le32 reserved;
139         __le32 crc;       /* header crc32c */
140 } __attribute__ ((packed));
141
142 struct ceph_msg_header {
143         __le64 seq;       /* message seq# for this session */
144         __le64 tid;       /* transaction id */
145         __le16 type;      /* message type */
146         __le16 priority;  /* priority.  higher value == higher priority */
147         __le16 version;   /* version of message encoding */
148
149         __le32 front_len; /* bytes in main payload */
150         __le32 middle_len;/* bytes in middle payload */
151         __le32 data_len;  /* bytes of data payload */
152         __le16 data_off;  /* sender: include full offset;
153                              receiver: mask against ~PAGE_MASK */
154
155         struct ceph_entity_name src;
156         __le16 compat_version;
157         __le16 reserved;
158         __le32 crc;       /* header crc32c */
159 } __attribute__ ((packed));
160
161 #define CEPH_MSG_PRIO_LOW     64
162 #define CEPH_MSG_PRIO_DEFAULT 127
163 #define CEPH_MSG_PRIO_HIGH    196
164 #define CEPH_MSG_PRIO_HIGHEST 255
165
166 /*
167  * follows data payload
168  */
169 struct ceph_msg_footer_old {
170         __le32 front_crc, middle_crc, data_crc;
171         __u8 flags;
172 } __attribute__ ((packed));
173
174 struct ceph_msg_footer {
175         __le32 front_crc, middle_crc, data_crc;
176         // sig holds the 64 bits of the digital signature for the message PLR
177         __le64  sig;
178         __u8 flags;
179 } __attribute__ ((packed));
180
181 #define CEPH_MSG_FOOTER_COMPLETE  (1<<0)   /* msg wasn't aborted */
182 #define CEPH_MSG_FOOTER_NOCRC     (1<<1)   /* no data crc */
183 #define CEPH_MSG_FOOTER_SIGNED    (1<<2)   /* msg was signed */
184
185
186 #endif