Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Shared Memory Communications over RDMA (SMC-R) and RoCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  CLC (connection layer control) handshake over initial TCP socket to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  prepare for RDMA traffic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Copyright IBM Corp. 2016
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  Author(s):  Ursula Braun <ubraun@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #ifndef _SMC_CLC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define _SMC_CLC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "smc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define SMC_CLC_PROPOSAL	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define SMC_CLC_ACCEPT		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define SMC_CLC_CONFIRM		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define SMC_CLC_DECLINE		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define SMC_TYPE_R		0		/* SMC-R only		      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define SMC_TYPE_D		1		/* SMC-D only		      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define SMC_TYPE_N		2		/* neither SMC-R nor SMC-D    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define SMC_TYPE_B		3		/* SMC-R and SMC-D	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define CLC_WAIT_TIME		(6 * HZ)	/* max. wait time on clcsock  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define CLC_WAIT_TIME_SHORT	HZ		/* short wait time on clcsock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define SMC_CLC_DECL_MEM	0x01010000  /* insufficient memory resources  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define SMC_CLC_DECL_TIMEOUT_CL	0x02010000  /* timeout w4 QP confirm link     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define SMC_CLC_DECL_TIMEOUT_AL	0x02020000  /* timeout w4 QP add link	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define SMC_CLC_DECL_CNFERR	0x03000000  /* configuration error            */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define SMC_CLC_DECL_PEERNOSMC	0x03010000  /* peer did not indicate SMC      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define SMC_CLC_DECL_IPSEC	0x03020000  /* IPsec usage		      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define SMC_CLC_DECL_NOSMCDEV	0x03030000  /* no SMC device found (R or D)   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define SMC_CLC_DECL_NOSMCDDEV	0x03030001  /* no SMC-D device found	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define SMC_CLC_DECL_NOSMCRDEV	0x03030002  /* no SMC-R device found	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define SMC_CLC_DECL_MODEUNSUPP	0x03040000  /* smc modes do not match (R or D)*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define SMC_CLC_DECL_RMBE_EC	0x03050000  /* peer has eyecatcher in RMBE    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define SMC_CLC_DECL_OPTUNSUPP	0x03060000  /* fastopen sockopt not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define SMC_CLC_DECL_DIFFPREFIX	0x03070000  /* IP prefix / subnet mismatch    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define SMC_CLC_DECL_GETVLANERR	0x03080000  /* err to get vlan id of ip device*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define SMC_CLC_DECL_ISMVLANERR	0x03090000  /* err to reg vlan id on ism dev  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define SMC_CLC_DECL_NOACTLINK	0x030a0000  /* no active smc-r link in lgr    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define SMC_CLC_DECL_NOSRVLINK	0x030b0000  /* SMC-R link from srv not found  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define SMC_CLC_DECL_VERSMISMAT	0x030c0000  /* SMC version mismatch	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define SMC_CLC_DECL_MAX_DMB	0x030d0000  /* SMC-D DMB limit exceeded       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define SMC_CLC_DECL_SYNCERR	0x04000000  /* synchronization error          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define SMC_CLC_DECL_PEERDECL	0x05000000  /* peer declined during handshake */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define SMC_CLC_DECL_INTERR	0x09990000  /* internal error		      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define SMC_CLC_DECL_ERR_RTOK	0x09990001  /*	 rtoken handling failed       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define SMC_CLC_DECL_ERR_RDYLNK	0x09990002  /*	 ib ready link failed	      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define SMC_CLC_DECL_ERR_REGRMB	0x09990003  /*	 reg rmb failed		      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define SMC_FIRST_CONTACT_MASK	0b10	/* first contact bit within typev2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) struct smc_clc_msg_hdr {	/* header1 of clc messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u8 eyecatcher[4];	/* eye catcher */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	u8 type;		/* proposal / accept / confirm / decline */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	__be16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u8 version : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	   typev2  : 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	   typev1  : 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u8 typev1  : 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	   typev2  : 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	   version : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) } __packed;			/* format defined in RFC7609 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) struct smc_clc_msg_trail {	/* trailer of clc messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	u8 eyecatcher[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) struct smc_clc_msg_local {	/* header2 of clc messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u8 id_for_peer[SMC_SYSTEMID_LEN]; /* unique system id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u8 gid[16];		/* gid of ib_device port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u8 mac[6];		/* mac of ib_device port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /* Struct would be 4 byte aligned, but it is used in an array that is sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * to peers and must conform to RFC7609, hence we need to use packed here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) struct smc_clc_ipv6_prefix {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct in6_addr prefix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	u8 prefix_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) } __packed;			/* format defined in RFC7609 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) struct smc_clc_v2_flag {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	u8 release : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	   rsvd    : 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	   seid    : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) struct smc_clc_v2_flag {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	u8 seid   : 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	rsvd      : 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	release   : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct smc_clnt_opts_area_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u8 eid_cnt;		/* number of user defined EIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	u8 ism_gid_cnt;		/* number of ISMv2 GIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u8 reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct smc_clc_v2_flag flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	u8 reserved2[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	__be16 smcd_v2_ext_offset; /* SMC-Dv2 Extension Offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct smc_clc_smcd_gid_chid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	__be64 gid;		/* ISM GID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	__be16 chid;		/* ISMv2 CHID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) } __packed;		/* format defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 * IBM Shared Memory Communications Version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			 * (https://www.ibm.com/support/pages/node/6326337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct smc_clc_v2_extension {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct smc_clnt_opts_area_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	u8 roce[16];		/* RoCEv2 GID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	u8 reserved[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	u8 user_eids[][SMC_MAX_EID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct smc_clc_msg_proposal_prefix {	/* prefix part of clc proposal message*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	__be32 outgoing_subnet;	/* subnet mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	u8 prefix_len;		/* number of significant bits in mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	u8 reserved[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	u8 ipv6_prefixes_cnt;	/* number of IPv6 prefixes in prefix array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) } __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct smc_clc_msg_smcd {	/* SMC-D GID information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct smc_clc_smcd_gid_chid ism; /* ISM native GID+CHID of requestor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	__be16 v2_ext_offset;	/* SMC Version 2 Extension Offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	u8 reserved[28];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct smc_clc_smcd_v2_extension {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	u8 system_eid[SMC_MAX_EID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	u8 reserved[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct smc_clc_smcd_gid_chid gidchid[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct smc_clc_msg_proposal {	/* clc proposal message sent by Linux */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct smc_clc_msg_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	struct smc_clc_msg_local lcl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	__be16 iparea_offset;	/* offset to IP address information area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define SMC_CLC_MAX_V6_PREFIX		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct smc_clc_msg_proposal_area {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct smc_clc_msg_proposal		pclc_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct smc_clc_msg_smcd			pclc_smcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	struct smc_clc_msg_proposal_prefix	pclc_prfx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct smc_clc_ipv6_prefix	pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct smc_clc_v2_extension		pclc_v2_ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct smc_clc_smcd_v2_extension	pclc_smcd_v2_ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct smc_clc_smcd_gid_chid		pclc_gidchids[SMC_MAX_ISM_DEVS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	struct smc_clc_msg_trail		pclc_trl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct smcr_clc_msg_accept_confirm {	/* SMCR accept/confirm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	struct smc_clc_msg_local lcl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	u8 qpn[3];			/* QP number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	__be32 rmb_rkey;		/* RMB rkey */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	u8 rmbe_idx;			/* Index of RMBE in RMB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	__be32 rmbe_alert_token;	/* unique connection id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u8 rmbe_size : 4,		/* buf size (compressed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	   qp_mtu   : 4;		/* QP mtu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	u8 qp_mtu   : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	   rmbe_size : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	__be64 rmb_dma_addr;	/* RMB virtual address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	u8 reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	u8 psn[3];		/* packet sequence number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct smcd_clc_msg_accept_confirm_common {	/* SMCD accept/confirm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	u64 gid;		/* Sender GID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	u64 token;		/* DMB token */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	u8 dmbe_idx;		/* DMBE index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	u8 dmbe_size : 4,	/* buf size (compressed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	   reserved3 : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	u8 reserved3 : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	   dmbe_size : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	u16 reserved4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	__be32 linkid;		/* Link identifier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define SMC_CLC_OS_ZOS		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define SMC_CLC_OS_LINUX	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define SMC_CLC_OS_AIX		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct smc_clc_first_contact_ext {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	u8 reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	u8 os_type : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	   release : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	u8 release : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	   os_type : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	u8 reserved2[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	u8 hostname[SMC_MAX_HOSTNAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct smc_clc_msg_accept_confirm {	/* clc accept / confirm message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct smc_clc_msg_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		struct smcr_clc_msg_accept_confirm r0; /* SMC-R */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		struct { /* SMC-D */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			struct smcd_clc_msg_accept_confirm_common d0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			u32 reserved5[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) } __packed;			/* format defined in RFC7609 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct smc_clc_msg_accept_confirm_v2 {	/* clc accept / confirm message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct smc_clc_msg_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		struct smcr_clc_msg_accept_confirm r0; /* SMC-R */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		struct { /* SMC-D */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			struct smcd_clc_msg_accept_confirm_common d0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			__be16 chid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			u8 eid[SMC_MAX_EID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			u8 reserved5[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct smc_clc_msg_decline {	/* clc decline message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	struct smc_clc_msg_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	u8 id_for_peer[SMC_SYSTEMID_LEN]; /* sender peer_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	__be32 peer_diagnosis;	/* diagnosis information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #if defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	u8 os_type  : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	   reserved : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #elif defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	u8 reserved : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	   os_type  : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	u8 reserved2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) } __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* determine start of the prefix area within the proposal message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static inline struct smc_clc_msg_proposal_prefix *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) smc_clc_proposal_get_prefix(struct smc_clc_msg_proposal *pclc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	return (struct smc_clc_msg_proposal_prefix *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	       ((u8 *)pclc + sizeof(*pclc) + ntohs(pclc->iparea_offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static inline bool smcr_indicated(int smc_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	return smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static inline bool smcd_indicated(int smc_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	return smc_type == SMC_TYPE_D || smc_type == SMC_TYPE_B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /* get SMC-D info from proposal message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static inline struct smc_clc_msg_smcd *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) smc_get_clc_msg_smcd(struct smc_clc_msg_proposal *prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (smcd_indicated(prop->hdr.typev1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	    ntohs(prop->iparea_offset) != sizeof(struct smc_clc_msg_smcd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	return (struct smc_clc_msg_smcd *)(prop + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static inline struct smc_clc_v2_extension *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) smc_get_clc_v2_ext(struct smc_clc_msg_proposal *prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	struct smc_clc_msg_smcd *prop_smcd = smc_get_clc_msg_smcd(prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	if (!prop_smcd || !ntohs(prop_smcd->v2_ext_offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return (struct smc_clc_v2_extension *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	       ((u8 *)prop_smcd +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	       offsetof(struct smc_clc_msg_smcd, v2_ext_offset) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	       sizeof(prop_smcd->v2_ext_offset) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	       ntohs(prop_smcd->v2_ext_offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static inline struct smc_clc_smcd_v2_extension *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) smc_get_clc_smcd_v2_ext(struct smc_clc_v2_extension *prop_v2ext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (!prop_v2ext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (!ntohs(prop_v2ext->hdr.smcd_v2_ext_offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	return (struct smc_clc_smcd_v2_extension *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		((u8 *)prop_v2ext +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		 offsetof(struct smc_clc_v2_extension, hdr) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		 offsetof(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		 sizeof(prop_v2ext->hdr.smcd_v2_ext_offset) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		 ntohs(prop_v2ext->hdr.smcd_v2_ext_offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct smcd_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) struct smc_init_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) int smc_clc_prfx_match(struct socket *clcsock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		       struct smc_clc_msg_proposal_prefix *prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		     u8 expected_type, unsigned long timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, u8 version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 			 u8 version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 			u8 version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) void smc_clc_init(void) __init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #endif