smc_core.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Shared Memory Communications over RDMA (SMC-R) and RoCE
  4. *
  5. * Definitions for SMC Connections, Link Groups and Links
  6. *
  7. * Copyright IBM Corp. 2016
  8. *
  9. * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
  10. */
  11. #ifndef _SMC_CORE_H
  12. #define _SMC_CORE_H
  13. #include <linux/atomic.h>
  14. #include <linux/smc.h>
  15. #include <linux/pci.h>
  16. #include <rdma/ib_verbs.h>
  17. #include <net/genetlink.h>
  18. #include <net/smc.h>
  19. #include "smc.h"
  20. #include "smc_ib.h"
  21. #include "smc_clc.h"
  22. #define SMC_RMBS_PER_LGR_MAX 255 /* max. # of RMBs per link group */
  23. #define SMC_CONN_PER_LGR_MIN 16 /* min. # of connections per link group */
  24. #define SMC_CONN_PER_LGR_MAX 255 /* max. # of connections per link group,
  25. * also is the default value for SMC-R v1 and v2.0
  26. */
  27. #define SMC_CONN_PER_LGR_PREFER 255 /* Preferred connections per link group used for
  28. * SMC-R v2.1 and later negotiation, vendors or
  29. * distrubutions may modify it to a value between
  30. * 16-255 as needed.
  31. */
  32. struct smc_lgr_list { /* list of link group definition */
  33. struct list_head list;
  34. spinlock_t lock; /* protects list of link groups */
  35. u32 num; /* unique link group number */
  36. };
  37. enum smc_lgr_role { /* possible roles of a link group */
  38. SMC_CLNT, /* client */
  39. SMC_SERV /* server */
  40. };
  41. enum smc_link_state { /* possible states of a link */
  42. SMC_LNK_UNUSED, /* link is unused */
  43. SMC_LNK_INACTIVE, /* link is inactive */
  44. SMC_LNK_ACTIVATING, /* link is being activated */
  45. SMC_LNK_ACTIVE, /* link is active */
  46. };
  47. #define SMC_WR_BUF_SIZE 48 /* size of work request buffer */
  48. #define SMC_WR_BUF_V2_SIZE 8192 /* size of v2 work request buffer */
  49. struct smc_wr_buf {
  50. u8 raw[SMC_WR_BUF_SIZE];
  51. };
  52. struct smc_wr_v2_buf {
  53. u8 raw[SMC_WR_BUF_V2_SIZE];
  54. };
  55. #define SMC_WR_REG_MR_WAIT_TIME (5 * HZ)/* wait time for ib_wr_reg_mr result */
  56. enum smc_wr_reg_state {
  57. POSTED, /* ib_wr_reg_mr request posted */
  58. CONFIRMED, /* ib_wr_reg_mr response: successful */
  59. FAILED /* ib_wr_reg_mr response: failure */
  60. };
  61. struct smc_rdma_sge { /* sges for RDMA writes */
  62. struct ib_sge wr_tx_rdma_sge[SMC_IB_MAX_SEND_SGE];
  63. };
  64. #define SMC_MAX_RDMA_WRITES 2 /* max. # of RDMA writes per
  65. * message send
  66. */
  67. struct smc_rdma_sges { /* sges per message send */
  68. struct smc_rdma_sge tx_rdma_sge[SMC_MAX_RDMA_WRITES];
  69. };
  70. struct smc_rdma_wr { /* work requests per message
  71. * send
  72. */
  73. struct ib_rdma_wr wr_tx_rdma[SMC_MAX_RDMA_WRITES];
  74. };
  75. #define SMC_LGR_ID_SIZE 4
  76. struct smc_link {
  77. struct smc_ib_device *smcibdev; /* ib-device */
  78. u8 ibport; /* port - values 1 | 2 */
  79. struct ib_pd *roce_pd; /* IB protection domain,
  80. * unique for every RoCE QP
  81. */
  82. struct ib_qp *roce_qp; /* IB queue pair */
  83. struct ib_qp_attr qp_attr; /* IB queue pair attributes */
  84. struct smc_wr_buf *wr_tx_bufs; /* WR send payload buffers */
  85. struct ib_send_wr *wr_tx_ibs; /* WR send meta data */
  86. struct ib_sge *wr_tx_sges; /* WR send gather meta data */
  87. struct smc_rdma_sges *wr_tx_rdma_sges;/*RDMA WRITE gather meta data*/
  88. struct smc_rdma_wr *wr_tx_rdmas; /* WR RDMA WRITE */
  89. struct smc_wr_tx_pend *wr_tx_pends; /* WR send waiting for CQE */
  90. struct completion *wr_tx_compl; /* WR send CQE completion */
  91. /* above four vectors have wr_tx_cnt elements and use the same index */
  92. struct ib_send_wr *wr_tx_v2_ib; /* WR send v2 meta data */
  93. struct ib_sge *wr_tx_v2_sge; /* WR send v2 gather meta data*/
  94. struct smc_wr_tx_pend *wr_tx_v2_pend; /* WR send v2 waiting for CQE */
  95. dma_addr_t wr_tx_dma_addr; /* DMA address of wr_tx_bufs */
  96. dma_addr_t wr_tx_v2_dma_addr; /* DMA address of v2 tx buf*/
  97. atomic_long_t wr_tx_id; /* seq # of last sent WR */
  98. unsigned long *wr_tx_mask; /* bit mask of used indexes */
  99. u32 wr_tx_cnt; /* number of WR send buffers */
  100. wait_queue_head_t wr_tx_wait; /* wait for free WR send buf */
  101. struct {
  102. struct percpu_ref wr_tx_refs;
  103. } ____cacheline_aligned_in_smp;
  104. struct completion tx_ref_comp;
  105. struct smc_wr_buf *wr_rx_bufs; /* WR recv payload buffers */
  106. struct ib_recv_wr *wr_rx_ibs; /* WR recv meta data */
  107. struct ib_sge *wr_rx_sges; /* WR recv scatter meta data */
  108. /* above three vectors have wr_rx_cnt elements and use the same index */
  109. dma_addr_t wr_rx_dma_addr; /* DMA address of wr_rx_bufs */
  110. dma_addr_t wr_rx_v2_dma_addr; /* DMA address of v2 rx buf*/
  111. u64 wr_rx_id; /* seq # of last recv WR */
  112. u64 wr_rx_id_compl; /* seq # of last completed WR */
  113. u32 wr_rx_cnt; /* number of WR recv buffers */
  114. unsigned long wr_rx_tstamp; /* jiffies when last buf rx */
  115. wait_queue_head_t wr_rx_empty_wait; /* wait for RQ empty */
  116. struct ib_reg_wr wr_reg; /* WR register memory region */
  117. wait_queue_head_t wr_reg_wait; /* wait for wr_reg result */
  118. struct {
  119. struct percpu_ref wr_reg_refs;
  120. } ____cacheline_aligned_in_smp;
  121. struct completion reg_ref_comp;
  122. enum smc_wr_reg_state wr_reg_state; /* state of wr_reg request */
  123. u8 gid[SMC_GID_SIZE];/* gid matching used vlan id*/
  124. u8 sgid_index; /* gid index for vlan id */
  125. u32 peer_qpn; /* QP number of peer */
  126. enum ib_mtu path_mtu; /* used mtu */
  127. enum ib_mtu peer_mtu; /* mtu size of peer */
  128. u32 psn_initial; /* QP tx initial packet seqno */
  129. u32 peer_psn; /* QP rx initial packet seqno */
  130. u8 peer_mac[ETH_ALEN]; /* = gid[8:10||13:15] */
  131. u8 peer_gid[SMC_GID_SIZE]; /* gid of peer*/
  132. u8 link_id; /* unique # within link group */
  133. u8 link_uid[SMC_LGR_ID_SIZE]; /* unique lnk id */
  134. u8 peer_link_uid[SMC_LGR_ID_SIZE]; /* peer uid */
  135. u8 link_idx; /* index in lgr link array */
  136. u8 link_is_asym; /* is link asymmetric? */
  137. u8 clearing : 1; /* link is being cleared */
  138. refcount_t refcnt; /* link reference count */
  139. struct smc_link_group *lgr; /* parent link group */
  140. struct work_struct link_down_wrk; /* wrk to bring link down */
  141. char ibname[IB_DEVICE_NAME_MAX]; /* ib device name */
  142. int ndev_ifidx; /* network device ifindex */
  143. enum smc_link_state state; /* state of link */
  144. struct delayed_work llc_testlink_wrk; /* testlink worker */
  145. struct completion llc_testlink_resp; /* wait for rx of testlink */
  146. int llc_testlink_time; /* testlink interval */
  147. atomic_t conn_cnt; /* connections on this link */
  148. };
  149. /* For now we just allow one parallel link per link group. The SMC protocol
  150. * allows more (up to 8).
  151. */
  152. #define SMC_LINKS_PER_LGR_MAX 3
  153. #define SMC_SINGLE_LINK 0
  154. #define SMC_LINKS_ADD_LNK_MIN 1 /* min. # of links per link group */
  155. #define SMC_LINKS_ADD_LNK_MAX 2 /* max. # of links per link group, also is the
  156. * default value for smc-r v1.0 and v2.0
  157. */
  158. #define SMC_LINKS_PER_LGR_MAX_PREFER 2 /* Preferred max links per link group used for
  159. * SMC-R v2.1 and later negotiation, vendors or
  160. * distrubutions may modify it to a value between
  161. * 1-2 as needed.
  162. */
  163. /* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */
  164. struct smc_buf_desc {
  165. struct list_head list;
  166. void *cpu_addr; /* virtual address of buffer */
  167. struct page *pages;
  168. int len; /* length of buffer */
  169. u32 used; /* currently used / unused */
  170. union {
  171. struct { /* SMC-R */
  172. struct sg_table sgt[SMC_LINKS_PER_LGR_MAX];
  173. /* virtual buffer */
  174. struct ib_mr *mr[SMC_LINKS_PER_LGR_MAX];
  175. /* memory region: for rmb and
  176. * vzalloced sndbuf
  177. * incl. rkey provided to peer
  178. * and lkey provided to local
  179. */
  180. u32 order; /* allocation order */
  181. u8 is_conf_rkey;
  182. /* confirm_rkey done */
  183. u8 is_reg_mr[SMC_LINKS_PER_LGR_MAX];
  184. /* mem region registered */
  185. u8 is_map_ib[SMC_LINKS_PER_LGR_MAX];
  186. /* mem region mapped to lnk */
  187. u8 is_dma_need_sync;
  188. u8 is_reg_err;
  189. /* buffer registration err */
  190. u8 is_vm;
  191. /* virtually contiguous */
  192. };
  193. struct { /* SMC-D */
  194. unsigned short sba_idx;
  195. /* SBA index number */
  196. u64 token;
  197. /* DMB token number */
  198. dma_addr_t dma_addr;
  199. /* DMA address */
  200. };
  201. };
  202. };
  203. struct smc_rtoken { /* address/key of remote RMB */
  204. u64 dma_addr;
  205. u32 rkey;
  206. };
  207. #define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */
  208. #define SMC_RMBE_SIZES 16 /* number of distinct RMBE sizes */
  209. /* theoretically, the RFC states that largest size would be 512K,
  210. * i.e. compressed 5 and thus 6 sizes (0..5), despite
  211. * struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15)
  212. */
  213. struct smcd_dev;
  214. enum smc_lgr_type { /* redundancy state of lgr */
  215. SMC_LGR_NONE, /* no active links, lgr to be deleted */
  216. SMC_LGR_SINGLE, /* 1 active RNIC on each peer */
  217. SMC_LGR_SYMMETRIC, /* 2 active RNICs on each peer */
  218. SMC_LGR_ASYMMETRIC_PEER, /* local has 2, peer 1 active RNICs */
  219. SMC_LGR_ASYMMETRIC_LOCAL, /* local has 1, peer 2 active RNICs */
  220. };
  221. enum smcr_buf_type { /* types of SMC-R sndbufs and RMBs */
  222. SMCR_PHYS_CONT_BUFS = 0,
  223. SMCR_VIRT_CONT_BUFS = 1,
  224. SMCR_MIXED_BUFS = 2,
  225. };
  226. enum smc_llc_flowtype {
  227. SMC_LLC_FLOW_NONE = 0,
  228. SMC_LLC_FLOW_ADD_LINK = 2,
  229. SMC_LLC_FLOW_DEL_LINK = 4,
  230. SMC_LLC_FLOW_REQ_ADD_LINK = 5,
  231. SMC_LLC_FLOW_RKEY = 6,
  232. };
  233. struct smc_llc_qentry;
  234. struct smc_llc_flow {
  235. enum smc_llc_flowtype type;
  236. struct smc_llc_qentry *qentry;
  237. };
  238. struct smc_link_group {
  239. struct list_head list;
  240. struct rb_root conns_all; /* connection tree */
  241. rwlock_t conns_lock; /* protects conns_all */
  242. unsigned int conns_num; /* current # of connections */
  243. unsigned short vlan_id; /* vlan id of link group */
  244. struct list_head sndbufs[SMC_RMBE_SIZES];/* tx buffers */
  245. struct rw_semaphore sndbufs_lock; /* protects tx buffers */
  246. struct list_head rmbs[SMC_RMBE_SIZES]; /* rx buffers */
  247. struct rw_semaphore rmbs_lock; /* protects rx buffers */
  248. u64 alloc_sndbufs; /* stats of tx buffers */
  249. u64 alloc_rmbs; /* stats of rx buffers */
  250. u8 id[SMC_LGR_ID_SIZE]; /* unique lgr id */
  251. struct delayed_work free_work; /* delayed freeing of an lgr */
  252. struct work_struct terminate_work; /* abnormal lgr termination */
  253. struct workqueue_struct *tx_wq; /* wq for conn. tx workers */
  254. u8 sync_err : 1; /* lgr no longer fits to peer */
  255. u8 terminating : 1;/* lgr is terminating */
  256. u8 freeing : 1; /* lgr is being freed */
  257. refcount_t refcnt; /* lgr reference count */
  258. bool is_smcd; /* SMC-R or SMC-D */
  259. u8 smc_version;
  260. u8 negotiated_eid[SMC_MAX_EID_LEN];
  261. u8 peer_os; /* peer operating system */
  262. u8 peer_smc_release;
  263. u8 peer_hostname[SMC_MAX_HOSTNAME_LEN];
  264. union {
  265. struct { /* SMC-R */
  266. enum smc_lgr_role role;
  267. /* client or server */
  268. struct smc_link lnk[SMC_LINKS_PER_LGR_MAX];
  269. /* smc link */
  270. struct smc_wr_v2_buf *wr_rx_buf_v2;
  271. /* WR v2 recv payload buffer */
  272. struct smc_wr_v2_buf *wr_tx_buf_v2;
  273. /* WR v2 send payload buffer */
  274. char peer_systemid[SMC_SYSTEMID_LEN];
  275. /* unique system_id of peer */
  276. struct smc_rtoken rtokens[SMC_RMBS_PER_LGR_MAX]
  277. [SMC_LINKS_PER_LGR_MAX];
  278. /* remote addr/key pairs */
  279. DECLARE_BITMAP(rtokens_used_mask, SMC_RMBS_PER_LGR_MAX);
  280. /* used rtoken elements */
  281. u8 next_link_id;
  282. enum smc_lgr_type type;
  283. enum smcr_buf_type buf_type;
  284. /* redundancy state */
  285. u8 pnet_id[SMC_MAX_PNETID_LEN + 1];
  286. /* pnet id of this lgr */
  287. struct list_head llc_event_q;
  288. /* queue for llc events */
  289. spinlock_t llc_event_q_lock;
  290. /* protects llc_event_q */
  291. struct rw_semaphore llc_conf_mutex;
  292. /* protects lgr reconfig. */
  293. struct work_struct llc_add_link_work;
  294. struct work_struct llc_del_link_work;
  295. struct work_struct llc_event_work;
  296. /* llc event worker */
  297. wait_queue_head_t llc_flow_waiter;
  298. /* w4 next llc event */
  299. wait_queue_head_t llc_msg_waiter;
  300. /* w4 next llc msg */
  301. struct smc_llc_flow llc_flow_lcl;
  302. /* llc local control field */
  303. struct smc_llc_flow llc_flow_rmt;
  304. /* llc remote control field */
  305. struct smc_llc_qentry *delayed_event;
  306. /* arrived when flow active */
  307. spinlock_t llc_flow_lock;
  308. /* protects llc flow */
  309. int llc_testlink_time;
  310. /* link keep alive time */
  311. u32 llc_termination_rsn;
  312. /* rsn code for termination */
  313. u8 nexthop_mac[ETH_ALEN];
  314. u8 uses_gateway;
  315. __be32 saddr;
  316. /* net namespace */
  317. struct net *net;
  318. u8 max_conns;
  319. /* max conn can be assigned to lgr */
  320. u8 max_links;
  321. /* max links can be added in lgr */
  322. };
  323. struct { /* SMC-D */
  324. struct smcd_gid peer_gid;
  325. /* Peer GID (remote) */
  326. struct smcd_dev *smcd;
  327. /* ISM device for VLAN reg. */
  328. u8 peer_shutdown : 1;
  329. /* peer triggered shutdownn */
  330. };
  331. };
  332. };
  333. struct smc_clc_msg_local;
  334. #define GID_LIST_SIZE 2
  335. struct smc_gidlist {
  336. u8 len;
  337. u8 list[GID_LIST_SIZE][SMC_GID_SIZE];
  338. };
  339. struct smc_init_info_smcrv2 {
  340. /* Input fields */
  341. __be32 saddr;
  342. struct sock *clc_sk;
  343. __be32 daddr;
  344. /* Output fields when saddr is set */
  345. struct smc_ib_device *ib_dev_v2;
  346. u8 ib_port_v2;
  347. u8 ib_gid_v2[SMC_GID_SIZE];
  348. /* Additional output fields when clc_sk and daddr is set as well */
  349. u8 uses_gateway;
  350. u8 nexthop_mac[ETH_ALEN];
  351. struct smc_gidlist gidlist;
  352. };
  353. #define SMC_MAX_V2_ISM_DEVS SMCD_CLC_MAX_V2_GID_ENTRIES
  354. /* max # of proposed non-native ISM devices,
  355. * which can't exceed the max # of CHID-GID
  356. * entries in CLC proposal SMC-Dv2 extension.
  357. */
  358. struct smc_init_info {
  359. u8 is_smcd;
  360. u8 smc_type_v1;
  361. u8 smc_type_v2;
  362. u8 release_nr;
  363. u8 max_conns;
  364. u8 max_links;
  365. u8 first_contact_peer;
  366. u8 first_contact_local;
  367. u16 feature_mask;
  368. unsigned short vlan_id;
  369. u32 rc;
  370. u8 negotiated_eid[SMC_MAX_EID_LEN];
  371. /* SMC-R */
  372. u8 smcr_version;
  373. u8 check_smcrv2;
  374. u8 peer_gid[SMC_GID_SIZE];
  375. u8 peer_mac[ETH_ALEN];
  376. u8 peer_systemid[SMC_SYSTEMID_LEN];
  377. struct smc_ib_device *ib_dev;
  378. u8 ib_gid[SMC_GID_SIZE];
  379. u8 ib_port;
  380. u32 ib_clcqpn;
  381. struct smc_init_info_smcrv2 smcrv2;
  382. /* SMC-D */
  383. struct smcd_gid ism_peer_gid[SMC_MAX_V2_ISM_DEVS + 1];
  384. struct smcd_dev *ism_dev[SMC_MAX_V2_ISM_DEVS + 1];
  385. u16 ism_chid[SMC_MAX_V2_ISM_DEVS + 1];
  386. u8 ism_offered_cnt; /* # of ISM devices offered */
  387. u8 ism_selected; /* index of selected ISM dev*/
  388. u8 smcd_version;
  389. };
  390. /* Find the connection associated with the given alert token in the link group.
  391. * To use rbtrees we have to implement our own search core.
  392. * Requires @conns_lock
  393. * @token alert token to search for
  394. * @lgr link group to search in
  395. * Returns connection associated with token if found, NULL otherwise.
  396. */
  397. static inline struct smc_connection *smc_lgr_find_conn(
  398. u32 token, struct smc_link_group *lgr)
  399. {
  400. struct smc_connection *res = NULL;
  401. struct rb_node *node;
  402. node = lgr->conns_all.rb_node;
  403. while (node) {
  404. struct smc_connection *cur = rb_entry(node,
  405. struct smc_connection, alert_node);
  406. if (cur->alert_token_local > token) {
  407. node = node->rb_left;
  408. } else {
  409. if (cur->alert_token_local < token) {
  410. node = node->rb_right;
  411. } else {
  412. res = cur;
  413. break;
  414. }
  415. }
  416. }
  417. return res;
  418. }
  419. static inline bool smc_conn_lgr_valid(struct smc_connection *conn)
  420. {
  421. return conn->lgr && conn->alert_token_local;
  422. }
  423. /*
  424. * Returns true if the specified link is usable.
  425. *
  426. * usable means the link is ready to receive RDMA messages, map memory
  427. * on the link, etc. This doesn't ensure we are able to send RDMA messages
  428. * on this link, if sending RDMA messages is needed, use smc_link_sendable()
  429. */
  430. static inline bool smc_link_usable(struct smc_link *lnk)
  431. {
  432. if (lnk->state == SMC_LNK_UNUSED || lnk->state == SMC_LNK_INACTIVE)
  433. return false;
  434. return true;
  435. }
  436. /*
  437. * Returns true if the specified link is ready to receive AND send RDMA
  438. * messages.
  439. *
  440. * For the client side in first contact, the underlying QP may still in
  441. * RESET or RTR when the link state is ACTIVATING, checks in smc_link_usable()
  442. * is not strong enough. For those places that need to send any CDC or LLC
  443. * messages, use smc_link_sendable(), otherwise, use smc_link_usable() instead
  444. */
  445. static inline bool smc_link_sendable(struct smc_link *lnk)
  446. {
  447. return smc_link_usable(lnk) &&
  448. lnk->qp_attr.cur_qp_state == IB_QPS_RTS;
  449. }
  450. static inline bool smc_link_active(struct smc_link *lnk)
  451. {
  452. return lnk->state == SMC_LNK_ACTIVE;
  453. }
  454. static inline void smc_gid_be16_convert(__u8 *buf, u8 *gid_raw)
  455. {
  456. sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
  457. be16_to_cpu(((__be16 *)gid_raw)[0]),
  458. be16_to_cpu(((__be16 *)gid_raw)[1]),
  459. be16_to_cpu(((__be16 *)gid_raw)[2]),
  460. be16_to_cpu(((__be16 *)gid_raw)[3]),
  461. be16_to_cpu(((__be16 *)gid_raw)[4]),
  462. be16_to_cpu(((__be16 *)gid_raw)[5]),
  463. be16_to_cpu(((__be16 *)gid_raw)[6]),
  464. be16_to_cpu(((__be16 *)gid_raw)[7]));
  465. }
  466. struct smc_pci_dev {
  467. __u32 pci_fid;
  468. __u16 pci_pchid;
  469. __u16 pci_vendor;
  470. __u16 pci_device;
  471. __u8 pci_id[SMC_PCI_ID_STR_LEN];
  472. };
  473. static inline void smc_set_pci_values(struct pci_dev *pci_dev,
  474. struct smc_pci_dev *smc_dev)
  475. {
  476. smc_dev->pci_vendor = pci_dev->vendor;
  477. smc_dev->pci_device = pci_dev->device;
  478. snprintf(smc_dev->pci_id, sizeof(smc_dev->pci_id), "%s",
  479. pci_name(pci_dev));
  480. #if IS_ENABLED(CONFIG_S390)
  481. { /* Set s390 specific PCI information */
  482. struct zpci_dev *zdev;
  483. zdev = to_zpci(pci_dev);
  484. smc_dev->pci_fid = zdev->fid;
  485. smc_dev->pci_pchid = zdev->pchid;
  486. }
  487. #endif
  488. }
  489. struct smc_sock;
  490. struct smc_clc_msg_accept_confirm;
  491. void smc_lgr_cleanup_early(struct smc_link_group *lgr);
  492. void smc_lgr_terminate_sched(struct smc_link_group *lgr);
  493. void smc_lgr_hold(struct smc_link_group *lgr);
  494. void smc_lgr_put(struct smc_link_group *lgr);
  495. void smcr_port_add(struct smc_ib_device *smcibdev, u8 ibport);
  496. void smcr_port_err(struct smc_ib_device *smcibdev, u8 ibport);
  497. void smc_smcd_terminate(struct smcd_dev *dev, struct smcd_gid *peer_gid,
  498. unsigned short vlan);
  499. void smc_smcd_terminate_all(struct smcd_dev *dev);
  500. void smc_smcr_terminate_all(struct smc_ib_device *smcibdev);
  501. int smc_buf_create(struct smc_sock *smc, bool is_smcd);
  502. int smcd_buf_attach(struct smc_sock *smc);
  503. int smc_uncompress_bufsize(u8 compressed);
  504. int smc_rmb_rtoken_handling(struct smc_connection *conn, struct smc_link *link,
  505. struct smc_clc_msg_accept_confirm *clc);
  506. int smc_rtoken_add(struct smc_link *lnk, __be64 nw_vaddr, __be32 nw_rkey);
  507. int smc_rtoken_delete(struct smc_link *lnk, __be32 nw_rkey);
  508. void smc_rtoken_set(struct smc_link_group *lgr, int link_idx, int link_idx_new,
  509. __be32 nw_rkey_known, __be64 nw_vaddr, __be32 nw_rkey);
  510. void smc_rtoken_set2(struct smc_link_group *lgr, int rtok_idx, int link_id,
  511. __be64 nw_vaddr, __be32 nw_rkey);
  512. void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn);
  513. void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn);
  514. int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini);
  515. void smc_conn_free(struct smc_connection *conn);
  516. int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini);
  517. int smc_core_init(void);
  518. void smc_core_exit(void);
  519. int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
  520. u8 link_idx, struct smc_init_info *ini);
  521. void smcr_link_clear(struct smc_link *lnk, bool log);
  522. void smcr_link_hold(struct smc_link *lnk);
  523. void smcr_link_put(struct smc_link *lnk);
  524. void smc_switch_link_and_count(struct smc_connection *conn,
  525. struct smc_link *to_lnk);
  526. int smcr_buf_map_lgr(struct smc_link *lnk);
  527. int smcr_buf_reg_lgr(struct smc_link *lnk);
  528. void smcr_lgr_set_type(struct smc_link_group *lgr, enum smc_lgr_type new_type);
  529. void smcr_lgr_set_type_asym(struct smc_link_group *lgr,
  530. enum smc_lgr_type new_type, int asym_lnk_idx);
  531. int smcr_link_reg_buf(struct smc_link *link, struct smc_buf_desc *rmb_desc);
  532. struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
  533. struct smc_link *from_lnk, bool is_dev_err);
  534. void smcr_link_down_cond(struct smc_link *lnk);
  535. void smcr_link_down_cond_sched(struct smc_link *lnk);
  536. int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb);
  537. int smcr_nl_get_lgr(struct sk_buff *skb, struct netlink_callback *cb);
  538. int smcr_nl_get_link(struct sk_buff *skb, struct netlink_callback *cb);
  539. int smcd_nl_get_lgr(struct sk_buff *skb, struct netlink_callback *cb);
  540. static inline struct smc_link_group *smc_get_lgr(struct smc_link *link)
  541. {
  542. return link->lgr;
  543. }
  544. #endif