| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Shared Memory Communications over RDMA (SMC-R) and RoCE |
| 4 |
* |
| 5 |
* CLC (connection layer control) handshake over initial TCP socket to |
| 6 |
* prepare for RDMA traffic |
| 7 |
* |
| 8 |
* Copyright IBM Corp. 2016 |
| 9 |
* |
| 10 |
* Author(s): Ursula Braun <[email protected]> |
| 11 |
*/ |
| 12 |
|
| 13 |
#ifndef _SMC_CLC_H |
| 14 |
#define _SMC_CLC_H |
| 15 |
|
| 16 |
#include <rdma/ib_verbs.h> |
| 17 |
#include <linux/smc.h> |
| 18 |
|
| 19 |
#include "smc.h" |
| 20 |
#include "smc_netlink.h" |
| 21 |
|
| 22 |
#define SMC_CLC_PROPOSAL 0x01 |
| 23 |
#define SMC_CLC_ACCEPT 0x02 |
| 24 |
#define SMC_CLC_CONFIRM 0x03 |
| 25 |
#define SMC_CLC_DECLINE 0x04 |
| 26 |
|
| 27 |
#define SMC_TYPE_R 0 /* SMC-R only */ |
| 28 |
#define SMC_TYPE_D 1 /* SMC-D only */ |
| 29 |
#define SMC_TYPE_N 2 /* neither SMC-R nor SMC-D */ |
| 30 |
#define SMC_TYPE_B 3 /* SMC-R and SMC-D */ |
| 31 |
#define CLC_WAIT_TIME (6 * HZ) /* max. wait time on clcsock */ |
| 32 |
#define CLC_WAIT_TIME_SHORT HZ /* short wait time on clcsock */ |
| 33 |
#define SMC_CLC_DECL_MEM 0x01010000 /* insufficient memory resources */ |
| 34 |
#define SMC_CLC_DECL_TIMEOUT_CL 0x02010000 /* timeout w4 QP confirm link */ |
| 35 |
#define SMC_CLC_DECL_TIMEOUT_AL 0x02020000 /* timeout w4 QP add link */ |
| 36 |
#define SMC_CLC_DECL_CNFERR 0x03000000 /* configuration error */ |
| 37 |
#define SMC_CLC_DECL_PEERNOSMC 0x03010000 /* peer did not indicate SMC */ |
| 38 |
#define SMC_CLC_DECL_IPSEC 0x03020000 /* IPsec usage */ |
| 39 |
#define SMC_CLC_DECL_NOSMCDEV 0x03030000 /* no SMC device found (R or D) */ |
| 40 |
#define SMC_CLC_DECL_NOSMCDDEV 0x03030001 /* no SMC-D device found */ |
| 41 |
#define SMC_CLC_DECL_NOSMCRDEV 0x03030002 /* no SMC-R device found */ |
| 42 |
#define SMC_CLC_DECL_NOISM2SUPP 0x03030003 /* hardware has no ISMv2 support */ |
| 43 |
#define SMC_CLC_DECL_NOV2EXT 0x03030004 /* peer sent no clc v2 extension */ |
| 44 |
#define SMC_CLC_DECL_NOV2DEXT 0x03030005 /* peer sent no clc SMC-Dv2 ext. */ |
| 45 |
#define SMC_CLC_DECL_NOSEID 0x03030006 /* peer sent no SEID */ |
| 46 |
#define SMC_CLC_DECL_NOSMCD2DEV 0x03030007 /* no SMC-Dv2 device found */ |
| 47 |
#define SMC_CLC_DECL_NOUEID 0x03030008 /* peer sent no UEID */ |
| 48 |
#define SMC_CLC_DECL_RELEASEERR 0x03030009 /* release version negotiate failed */ |
| 49 |
#define SMC_CLC_DECL_MAXCONNERR 0x0303000a /* max connections negotiate failed */ |
| 50 |
#define SMC_CLC_DECL_MAXLINKERR 0x0303000b /* max links negotiate failed */ |
| 51 |
#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/ |
| 52 |
#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */ |
| 53 |
#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */ |
| 54 |
#define SMC_CLC_DECL_DIFFPREFIX 0x03070000 /* IP prefix / subnet mismatch */ |
| 55 |
#define SMC_CLC_DECL_GETVLANERR 0x03080000 /* err to get vlan id of ip device*/ |
| 56 |
#define SMC_CLC_DECL_ISMVLANERR 0x03090000 /* err to reg vlan id on ism dev */ |
| 57 |
#define SMC_CLC_DECL_NOACTLINK 0x030a0000 /* no active smc-r link in lgr */ |
| 58 |
#define SMC_CLC_DECL_NOSRVLINK 0x030b0000 /* SMC-R link from srv not found */ |
| 59 |
#define SMC_CLC_DECL_VERSMISMAT 0x030c0000 /* SMC version mismatch */ |
| 60 |
#define SMC_CLC_DECL_MAX_DMB 0x030d0000 /* SMC-D DMB limit exceeded */ |
| 61 |
#define SMC_CLC_DECL_NOROUTE 0x030e0000 /* SMC-Rv2 conn. no route to peer */ |
| 62 |
#define SMC_CLC_DECL_NOINDIRECT 0x030f0000 /* SMC-Rv2 conn. indirect mismatch*/ |
| 63 |
#define SMC_CLC_DECL_SYNCERR 0x04000000 /* synchronization error */ |
| 64 |
#define SMC_CLC_DECL_PEERDECL 0x05000000 /* peer declined during handshake */ |
| 65 |
#define SMC_CLC_DECL_INTERR 0x09990000 /* internal error */ |
| 66 |
#define SMC_CLC_DECL_ERR_RTOK 0x09990001 /* rtoken handling failed */ |
| 67 |
#define SMC_CLC_DECL_ERR_RDYLNK 0x09990002 /* ib ready link failed */ |
| 68 |
#define SMC_CLC_DECL_ERR_REGBUF 0x09990003 /* reg rdma bufs failed */ |
| 69 |
|
| 70 |
#define SMC_FIRST_CONTACT_MASK 0b10 /* first contact bit within typev2 */ |
| 71 |
|
| 72 |
struct smc_clc_msg_hdr { /* header1 of clc messages */ |
| 73 |
u8 eyecatcher[4]; /* eye catcher */ |
| 74 |
u8 type; /* proposal / accept / confirm / decline */ |
| 75 |
__be16 length; |
| 76 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 77 |
u8 version : 4, |
| 78 |
typev2 : 2, |
| 79 |
typev1 : 2; |
| 80 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 81 |
u8 typev1 : 2, |
| 82 |
typev2 : 2, |
| 83 |
version : 4; |
| 84 |
#endif |
| 85 |
} __packed; /* format defined in RFC7609 */ |
| 86 |
|
| 87 |
struct smc_clc_msg_trail { /* trailer of clc messages */ |
| 88 |
u8 eyecatcher[4]; |
| 89 |
}; |
| 90 |
|
| 91 |
struct smc_clc_msg_local { /* header2 of clc messages */ |
| 92 |
u8 id_for_peer[SMC_SYSTEMID_LEN]; /* unique system id */ |
| 93 |
u8 gid[16]; /* gid of ib_device port */ |
| 94 |
u8 mac[6]; /* mac of ib_device port */ |
| 95 |
}; |
| 96 |
|
| 97 |
/* Struct would be 4 byte aligned, but it is used in an array that is sent |
| 98 |
* to peers and must conform to RFC7609, hence we need to use packed here. |
| 99 |
*/ |
| 100 |
struct smc_clc_ipv6_prefix { |
| 101 |
struct in6_addr prefix; |
| 102 |
u8 prefix_len; |
| 103 |
} __packed; /* format defined in RFC7609 */ |
| 104 |
|
| 105 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 106 |
struct smc_clc_v2_flag { |
| 107 |
u8 release : 4, |
| 108 |
rsvd : 3, |
| 109 |
seid : 1; |
| 110 |
}; |
| 111 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 112 |
struct smc_clc_v2_flag { |
| 113 |
u8 seid : 1, |
| 114 |
rsvd : 3, |
| 115 |
release : 4; |
| 116 |
}; |
| 117 |
#endif |
| 118 |
|
| 119 |
struct smc_clnt_opts_area_hdr { |
| 120 |
u8 eid_cnt; /* number of user defined EIDs */ |
| 121 |
u8 ism_gid_cnt; /* number of ISMv2 GIDs */ |
| 122 |
u8 reserved1; |
| 123 |
struct smc_clc_v2_flag flag; |
| 124 |
u8 reserved2[2]; |
| 125 |
__be16 smcd_v2_ext_offset; /* SMC-Dv2 Extension Offset */ |
| 126 |
}; |
| 127 |
|
| 128 |
struct smc_clc_smcd_gid_chid { |
| 129 |
__be64 gid; /* ISM GID */ |
| 130 |
__be16 chid; /* ISMv2 CHID */ |
| 131 |
} __packed; /* format defined in |
| 132 |
* IBM Shared Memory Communications Version 2 |
| 133 |
* (https://www.ibm.com/support/pages/node/6326337) |
| 134 |
*/ |
| 135 |
|
| 136 |
struct smc_clc_v2_extension { |
| 137 |
/* New members must be added within the struct_group() macro below. */ |
| 138 |
struct_group_tagged(smc_clc_v2_extension_fixed, fixed, |
| 139 |
struct smc_clnt_opts_area_hdr hdr; |
| 140 |
u8 roce[16]; /* RoCEv2 GID */ |
| 141 |
u8 max_conns; |
| 142 |
u8 max_links; |
| 143 |
__be16 feature_mask; |
| 144 |
u8 reserved[12]; |
| 145 |
); |
| 146 |
u8 user_eids[][SMC_MAX_EID_LEN]; |
| 147 |
}; |
| 148 |
static_assert(offsetof(struct smc_clc_v2_extension, user_eids) == sizeof(struct smc_clc_v2_extension_fixed), |
| 149 |
"struct member likely outside of struct_group_tagged()"); |
| 150 |
|
| 151 |
struct smc_clc_msg_proposal_prefix { /* prefix part of clc proposal message*/ |
| 152 |
__be32 outgoing_subnet; /* subnet mask */ |
| 153 |
u8 prefix_len; /* number of significant bits in mask */ |
| 154 |
u8 reserved[2]; |
| 155 |
u8 ipv6_prefixes_cnt; /* number of IPv6 prefixes in prefix array */ |
| 156 |
} __aligned(4); |
| 157 |
|
| 158 |
struct smc_clc_msg_smcd { /* SMC-D GID information */ |
| 159 |
struct smc_clc_smcd_gid_chid ism; /* ISM native GID+CHID of requester */ |
| 160 |
__be16 v2_ext_offset; /* SMC Version 2 Extension Offset */ |
| 161 |
u8 vendor_oui[3]; /* vendor organizationally unique identifier */ |
| 162 |
u8 vendor_exp_options[5]; |
| 163 |
u8 reserved[20]; |
| 164 |
}; |
| 165 |
|
| 166 |
struct smc_clc_smcd_v2_extension { |
| 167 |
/* New members must be added within the struct_group() macro below. */ |
| 168 |
struct_group_tagged(smc_clc_smcd_v2_extension_fixed, fixed, |
| 169 |
u8 system_eid[SMC_MAX_EID_LEN]; |
| 170 |
u8 reserved[16]; |
| 171 |
); |
| 172 |
struct smc_clc_smcd_gid_chid gidchid[]; |
| 173 |
}; |
| 174 |
static_assert(offsetof(struct smc_clc_smcd_v2_extension, gidchid) == sizeof(struct smc_clc_smcd_v2_extension_fixed), |
| 175 |
"struct member likely outside of struct_group_tagged()"); |
| 176 |
|
| 177 |
struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */ |
| 178 |
struct smc_clc_msg_hdr hdr; |
| 179 |
struct smc_clc_msg_local lcl; |
| 180 |
__be16 iparea_offset; /* offset to IP address information area */ |
| 181 |
} __aligned(4); |
| 182 |
|
| 183 |
#define SMC_CLC_MAX_V6_PREFIX 8 |
| 184 |
#define SMC_CLC_MAX_UEID 8 |
| 185 |
#define SMCD_CLC_MAX_V2_GID_ENTRIES 8 /* max # of CHID-GID entries in CLC |
| 186 |
* proposal SMC-Dv2 extension. |
| 187 |
* each ISM device takes one entry and |
| 188 |
* each Emulated-ISM takes two entries |
| 189 |
*/ |
| 190 |
|
| 191 |
struct smc_clc_msg_proposal_area { |
| 192 |
struct smc_clc_msg_proposal pclc_base; |
| 193 |
struct smc_clc_msg_smcd pclc_smcd; |
| 194 |
struct smc_clc_msg_proposal_prefix pclc_prfx; |
| 195 |
struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX]; |
| 196 |
struct smc_clc_v2_extension_fixed pclc_v2_ext; |
| 197 |
u8 user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN]; |
| 198 |
struct smc_clc_smcd_v2_extension_fixed pclc_smcd_v2_ext; |
| 199 |
struct smc_clc_smcd_gid_chid |
| 200 |
pclc_gidchids[SMCD_CLC_MAX_V2_GID_ENTRIES]; |
| 201 |
struct smc_clc_msg_trail pclc_trl; |
| 202 |
}; |
| 203 |
|
| 204 |
struct smcr_clc_msg_accept_confirm { /* SMCR accept/confirm */ |
| 205 |
struct smc_clc_msg_local lcl; |
| 206 |
u8 qpn[3]; /* QP number */ |
| 207 |
__be32 rmb_rkey; /* RMB rkey */ |
| 208 |
u8 rmbe_idx; /* Index of RMBE in RMB */ |
| 209 |
__be32 rmbe_alert_token; /* unique connection id */ |
| 210 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 211 |
u8 rmbe_size : 4, /* buf size (compressed) */ |
| 212 |
qp_mtu : 4; /* QP mtu */ |
| 213 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 214 |
u8 qp_mtu : 4, |
| 215 |
rmbe_size : 4; |
| 216 |
#endif |
| 217 |
u8 reserved; |
| 218 |
__be64 rmb_dma_addr; /* RMB virtual address */ |
| 219 |
u8 reserved2; |
| 220 |
u8 psn[3]; /* packet sequence number */ |
| 221 |
} __packed; |
| 222 |
|
| 223 |
struct smcd_clc_msg_accept_confirm_common { /* SMCD accept/confirm */ |
| 224 |
__be64 gid; /* Sender GID */ |
| 225 |
__be64 token; /* DMB token */ |
| 226 |
u8 dmbe_idx; /* DMBE index */ |
| 227 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 228 |
u8 dmbe_size : 4, /* buf size (compressed) */ |
| 229 |
reserved3 : 4; |
| 230 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 231 |
u8 reserved3 : 4, |
| 232 |
dmbe_size : 4; |
| 233 |
#endif |
| 234 |
u16 reserved4; |
| 235 |
__be32 linkid; /* Link identifier */ |
| 236 |
} __packed; |
| 237 |
|
| 238 |
#define SMC_CLC_OS_ZOS 1 |
| 239 |
#define SMC_CLC_OS_LINUX 2 |
| 240 |
#define SMC_CLC_OS_AIX 3 |
| 241 |
|
| 242 |
struct smc_clc_first_contact_ext { |
| 243 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 244 |
u8 v2_direct : 1, |
| 245 |
reserved : 7; |
| 246 |
u8 os_type : 4, |
| 247 |
release : 4; |
| 248 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 249 |
u8 reserved : 7, |
| 250 |
v2_direct : 1; |
| 251 |
u8 release : 4, |
| 252 |
os_type : 4; |
| 253 |
#endif |
| 254 |
u8 reserved2[2]; |
| 255 |
u8 hostname[SMC_MAX_HOSTNAME_LEN]; |
| 256 |
}; |
| 257 |
|
| 258 |
struct smc_clc_first_contact_ext_v2x { |
| 259 |
struct smc_clc_first_contact_ext fce_v2_base; |
| 260 |
union { |
| 261 |
struct { |
| 262 |
u8 max_conns; /* for SMC-R only */ |
| 263 |
u8 max_links; /* for SMC-R only */ |
| 264 |
}; |
| 265 |
u8 reserved3[2]; /* for SMC-D only */ |
| 266 |
}; |
| 267 |
__be16 feature_mask; |
| 268 |
__be32 vendor_exp_options; |
| 269 |
u8 reserved4[8]; |
| 270 |
} __packed; /* format defined in |
| 271 |
* IBM Shared Memory Communications Version 2 (Third Edition) |
| 272 |
* (https://www.ibm.com/support/pages/node/7009315) |
| 273 |
*/ |
| 274 |
|
| 275 |
struct smc_clc_fce_gid_ext { |
| 276 |
u8 gid_cnt; |
| 277 |
u8 reserved2[3]; |
| 278 |
u8 gid[][SMC_GID_SIZE]; |
| 279 |
}; |
| 280 |
|
| 281 |
struct smc_clc_msg_accept_confirm { /* clc accept / confirm message */ |
| 282 |
struct smc_clc_msg_hdr hdr; |
| 283 |
union { |
| 284 |
struct { /* SMC-R */ |
| 285 |
struct smcr_clc_msg_accept_confirm r0; |
| 286 |
struct { /* v2 only */ |
| 287 |
u8 eid[SMC_MAX_EID_LEN]; |
| 288 |
u8 reserved6[8]; |
| 289 |
} __packed r1; |
| 290 |
}; |
| 291 |
struct { /* SMC-D */ |
| 292 |
struct smcd_clc_msg_accept_confirm_common d0; |
| 293 |
struct { /* v2 only, but 12 bytes reserved in v1 */ |
| 294 |
__be16 chid; |
| 295 |
u8 eid[SMC_MAX_EID_LEN]; |
| 296 |
__be64 gid_ext; |
| 297 |
} __packed d1; |
| 298 |
}; |
| 299 |
}; |
| 300 |
}; |
| 301 |
|
| 302 |
struct smc_clc_msg_decline { /* clc decline message */ |
| 303 |
struct smc_clc_msg_hdr hdr; |
| 304 |
u8 id_for_peer[SMC_SYSTEMID_LEN]; /* sender peer_id */ |
| 305 |
__be32 peer_diagnosis; /* diagnosis information */ |
| 306 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 307 |
u8 os_type : 4, |
| 308 |
reserved : 4; |
| 309 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 310 |
u8 reserved : 4, |
| 311 |
os_type : 4; |
| 312 |
#endif |
| 313 |
u8 reserved2[3]; |
| 314 |
struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */ |
| 315 |
} __aligned(4); |
| 316 |
|
| 317 |
#define SMC_DECL_DIAG_COUNT_V2 4 /* no. of additional peer diagnosis codes */ |
| 318 |
|
| 319 |
struct smc_clc_msg_decline_v2 { /* clc decline message */ |
| 320 |
struct smc_clc_msg_hdr hdr; |
| 321 |
u8 id_for_peer[SMC_SYSTEMID_LEN]; /* sender peer_id */ |
| 322 |
__be32 peer_diagnosis; /* diagnosis information */ |
| 323 |
#if defined(__BIG_ENDIAN_BITFIELD) |
| 324 |
u8 os_type : 4, |
| 325 |
reserved : 4; |
| 326 |
#elif defined(__LITTLE_ENDIAN_BITFIELD) |
| 327 |
u8 reserved : 4, |
| 328 |
os_type : 4; |
| 329 |
#endif |
| 330 |
u8 reserved2[3]; |
| 331 |
__be32 peer_diagnosis_v2[SMC_DECL_DIAG_COUNT_V2]; |
| 332 |
struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */ |
| 333 |
} __aligned(4); |
| 334 |
|
| 335 |
/* determine start of the prefix area within the proposal message */ |
| 336 |
static inline struct smc_clc_msg_proposal_prefix * |
| 337 |
smc_clc_proposal_get_prefix(struct smc_clc_msg_proposal *pclc) |
| 338 |
{ |
| 339 |
u16 offset = ntohs(pclc->iparea_offset); |
| 340 |
|
| 341 |
if (offset > sizeof(struct smc_clc_msg_smcd)) |
| 342 |
return NULL; |
| 343 |
return (struct smc_clc_msg_proposal_prefix *) |
| 344 |
((u8 *)pclc + sizeof(*pclc) + offset); |
| 345 |
} |
| 346 |
|
| 347 |
static inline bool smcr_indicated(int smc_type) |
| 348 |
{ |
| 349 |
return smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B; |
| 350 |
} |
| 351 |
|
| 352 |
static inline bool smcd_indicated(int smc_type) |
| 353 |
{ |
| 354 |
return smc_type == SMC_TYPE_D || smc_type == SMC_TYPE_B; |
| 355 |
} |
| 356 |
|
| 357 |
static inline u8 smc_indicated_type(int is_smcd, int is_smcr) |
| 358 |
{ |
| 359 |
if (is_smcd && is_smcr) |
| 360 |
return SMC_TYPE_B; |
| 361 |
if (is_smcd) |
| 362 |
return SMC_TYPE_D; |
| 363 |
if (is_smcr) |
| 364 |
return SMC_TYPE_R; |
| 365 |
return SMC_TYPE_N; |
| 366 |
} |
| 367 |
|
| 368 |
/* get SMC-D info from proposal message */ |
| 369 |
static inline struct smc_clc_msg_smcd * |
| 370 |
smc_get_clc_msg_smcd(struct smc_clc_msg_proposal *prop) |
| 371 |
{ |
| 372 |
if (smcd_indicated(prop->hdr.typev1) && |
| 373 |
ntohs(prop->iparea_offset) != sizeof(struct smc_clc_msg_smcd)) |
| 374 |
return NULL; |
| 375 |
|
| 376 |
return (struct smc_clc_msg_smcd *)(prop + 1); |
| 377 |
} |
| 378 |
|
| 379 |
static inline struct smc_clc_v2_extension * |
| 380 |
smc_get_clc_v2_ext(struct smc_clc_msg_proposal *prop) |
| 381 |
{ |
| 382 |
struct smc_clc_msg_smcd *prop_smcd = smc_get_clc_msg_smcd(prop); |
| 383 |
u16 max_offset; |
| 384 |
|
| 385 |
max_offset = offsetof(struct smc_clc_msg_proposal_area, pclc_v2_ext) - |
| 386 |
offsetof(struct smc_clc_msg_proposal_area, pclc_smcd) - |
| 387 |
offsetofend(struct smc_clc_msg_smcd, v2_ext_offset); |
| 388 |
|
| 389 |
if (!prop_smcd || !ntohs(prop_smcd->v2_ext_offset) || |
| 390 |
ntohs(prop_smcd->v2_ext_offset) > max_offset) |
| 391 |
return NULL; |
| 392 |
|
| 393 |
return (struct smc_clc_v2_extension *) |
| 394 |
((u8 *)prop_smcd + |
| 395 |
offsetof(struct smc_clc_msg_smcd, v2_ext_offset) + |
| 396 |
sizeof(prop_smcd->v2_ext_offset) + |
| 397 |
ntohs(prop_smcd->v2_ext_offset)); |
| 398 |
} |
| 399 |
|
| 400 |
static inline struct smc_clc_smcd_v2_extension * |
| 401 |
smc_get_clc_smcd_v2_ext(struct smc_clc_v2_extension *prop_v2ext) |
| 402 |
{ |
| 403 |
u16 max_offset = offsetof(struct smc_clc_msg_proposal_area, pclc_smcd_v2_ext) - |
| 404 |
offsetof(struct smc_clc_msg_proposal_area, pclc_v2_ext) - |
| 405 |
offsetof(struct smc_clc_v2_extension, hdr) - |
| 406 |
offsetofend(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset); |
| 407 |
|
| 408 |
if (!prop_v2ext) |
| 409 |
return NULL; |
| 410 |
if (!ntohs(prop_v2ext->hdr.smcd_v2_ext_offset) || |
| 411 |
ntohs(prop_v2ext->hdr.smcd_v2_ext_offset) > max_offset) |
| 412 |
return NULL; |
| 413 |
|
| 414 |
return (struct smc_clc_smcd_v2_extension *) |
| 415 |
((u8 *)prop_v2ext + |
| 416 |
offsetof(struct smc_clc_v2_extension, hdr) + |
| 417 |
offsetof(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset) + |
| 418 |
sizeof(prop_v2ext->hdr.smcd_v2_ext_offset) + |
| 419 |
ntohs(prop_v2ext->hdr.smcd_v2_ext_offset)); |
| 420 |
} |
| 421 |
|
| 422 |
static inline struct smc_clc_first_contact_ext * |
| 423 |
smc_get_clc_first_contact_ext(struct smc_clc_msg_accept_confirm *clc, |
| 424 |
bool is_smcd) |
| 425 |
{ |
| 426 |
int clc_v2_len; |
| 427 |
|
| 428 |
if (clc->hdr.version == SMC_V1 || |
| 429 |
!(clc->hdr.typev2 & SMC_FIRST_CONTACT_MASK)) |
| 430 |
return NULL; |
| 431 |
|
| 432 |
if (is_smcd) |
| 433 |
clc_v2_len = |
| 434 |
offsetofend(struct smc_clc_msg_accept_confirm, d1); |
| 435 |
else |
| 436 |
clc_v2_len = |
| 437 |
offsetofend(struct smc_clc_msg_accept_confirm, r1); |
| 438 |
|
| 439 |
return (struct smc_clc_first_contact_ext *)(((u8 *)clc) + clc_v2_len); |
| 440 |
} |
| 441 |
|
| 442 |
struct smcd_dev; |
| 443 |
struct smc_init_info; |
| 444 |
|
| 445 |
int smc_clc_prfx_match(struct socket *clcsock, |
| 446 |
struct smc_clc_msg_proposal_prefix *prop); |
| 447 |
int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, |
| 448 |
u8 expected_type, unsigned long timeout); |
| 449 |
int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, u8 version); |
| 450 |
int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini); |
| 451 |
int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact, |
| 452 |
u8 version, u8 *eid, struct smc_init_info *ini); |
| 453 |
int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact, |
| 454 |
u8 version, u8 *negotiated_eid, struct smc_init_info *ini); |
| 455 |
int smc_clc_srv_v2x_features_validate(struct smc_sock *smc, |
| 456 |
struct smc_clc_msg_proposal *pclc, |
| 457 |
struct smc_init_info *ini); |
| 458 |
int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce, |
| 459 |
struct smc_init_info *ini); |
| 460 |
int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc, |
| 461 |
struct smc_init_info *ini); |
| 462 |
void smc_clc_init(void) __init; |
| 463 |
void smc_clc_exit(void); |
| 464 |
void smc_clc_get_hostname(u8 **host); |
| 465 |
bool smc_clc_match_eid(u8 *negotiated_eid, |
| 466 |
struct smc_clc_v2_extension *smc_v2_ext, |
| 467 |
u8 *peer_eid, u8 *local_eid); |
| 468 |
int smc_clc_ueid_count(void); |
| 469 |
int smc_nl_dump_ueid(struct sk_buff *skb, struct netlink_callback *cb); |
| 470 |
int smc_nl_add_ueid(struct sk_buff *skb, struct genl_info *info); |
| 471 |
int smc_nl_remove_ueid(struct sk_buff *skb, struct genl_info *info); |
| 472 |
int smc_nl_flush_ueid(struct sk_buff *skb, struct genl_info *info); |
| 473 |
int smc_nl_dump_seid(struct sk_buff *skb, struct netlink_callback *cb); |
| 474 |
int smc_nl_enable_seid(struct sk_buff *skb, struct genl_info *info); |
| 475 |
int smc_nl_disable_seid(struct sk_buff *skb, struct genl_info *info); |
| 476 |
|
| 477 |
#endif |