Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
9bf9abea UB |
2 | /* |
3 | * Shared Memory Communications over RDMA (SMC-R) and RoCE | |
4 | * | |
5 | * Definitions for LLC (link layer control) message handling | |
6 | * | |
7 | * Copyright IBM Corp. 2016 | |
8 | * | |
9 | * Author(s): Klaus Wacker <Klaus.Wacker@de.ibm.com> | |
10 | * Ursula Braun <ubraun@linux.vnet.ibm.com> | |
11 | */ | |
12 | ||
13 | #ifndef SMC_LLC_H | |
14 | #define SMC_LLC_H | |
15 | ||
16 | #include "smc_wr.h" | |
17 | ||
18 | #define SMC_LLC_FLAG_RESP 0x80 | |
19 | ||
20 | #define SMC_LLC_WAIT_FIRST_TIME (5 * HZ) | |
52bedf37 | 21 | #define SMC_LLC_WAIT_TIME (2 * HZ) |
77eee325 | 22 | #define SMC_LLC_TESTLINK_DEFAULT_TIME (30 * HZ) |
9bf9abea UB |
23 | |
24 | enum smc_llc_reqresp { | |
25 | SMC_LLC_REQ, | |
26 | SMC_LLC_RESP | |
27 | }; | |
28 | ||
29 | enum smc_llc_msg_type { | |
30 | SMC_LLC_CONFIRM_LINK = 0x01, | |
52bedf37 | 31 | SMC_LLC_ADD_LINK = 0x02, |
87f88cda | 32 | SMC_LLC_ADD_LINK_CONT = 0x03, |
52bedf37 | 33 | SMC_LLC_DELETE_LINK = 0x04, |
b4ba4652 | 34 | SMC_LLC_REQ_ADD_LINK = 0x05, |
4ed75de5 | 35 | SMC_LLC_CONFIRM_RKEY = 0x06, |
313164da | 36 | SMC_LLC_TEST_LINK = 0x07, |
4ed75de5 KG |
37 | SMC_LLC_CONFIRM_RKEY_CONT = 0x08, |
38 | SMC_LLC_DELETE_RKEY = 0x09, | |
b4ba4652 KG |
39 | /* V2 types */ |
40 | SMC_LLC_CONFIRM_LINK_V2 = 0x21, | |
41 | SMC_LLC_ADD_LINK_V2 = 0x22, | |
42 | SMC_LLC_DELETE_LINK_V2 = 0x24, | |
43 | SMC_LLC_REQ_ADD_LINK_V2 = 0x25, | |
44 | SMC_LLC_CONFIRM_RKEY_V2 = 0x26, | |
45 | SMC_LLC_TEST_LINK_V2 = 0x27, | |
46 | SMC_LLC_DELETE_RKEY_V2 = 0x29, | |
9bf9abea UB |
47 | }; |
48 | ||
541afa10 KG |
49 | #define smc_link_downing(state) \ |
50 | (cmpxchg(state, SMC_LNK_ACTIVE, SMC_LNK_INACTIVE) == SMC_LNK_ACTIVE) | |
51 | ||
fbed3b37 KG |
52 | /* LLC DELETE LINK Request Reason Codes */ |
53 | #define SMC_LLC_DEL_LOST_PATH 0x00010000 | |
54 | #define SMC_LLC_DEL_OP_INIT_TERM 0x00020000 | |
55 | #define SMC_LLC_DEL_PROG_INIT_TERM 0x00030000 | |
56 | #define SMC_LLC_DEL_PROT_VIOL 0x00040000 | |
57 | #define SMC_LLC_DEL_NO_ASYM_NEEDED 0x00050000 | |
58 | /* LLC DELETE LINK Response Reason Codes */ | |
59 | #define SMC_LLC_DEL_NOLNK 0x00100000 /* Unknown Link ID (no link) */ | |
60 | #define SMC_LLC_DEL_NOLGR 0x00200000 /* Unknown Link Group */ | |
61 | ||
d854fcbf KG |
62 | /* returns a usable link of the link group, or NULL */ |
63 | static inline struct smc_link *smc_llc_usable_link(struct smc_link_group *lgr) | |
64 | { | |
65 | int i; | |
66 | ||
67 | for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) | |
68 | if (smc_link_usable(&lgr->lnk[i])) | |
69 | return &lgr->lnk[i]; | |
70 | return NULL; | |
71 | } | |
72 | ||
3e0c40af KG |
73 | /* set the termination reason code for the link group */ |
74 | static inline void smc_llc_set_termination_rsn(struct smc_link_group *lgr, | |
75 | u32 rsn) | |
76 | { | |
77 | if (!lgr->llc_termination_rsn) | |
78 | lgr->llc_termination_rsn = rsn; | |
79 | } | |
80 | ||
9bf9abea | 81 | /* transmit */ |
947541f3 | 82 | int smc_llc_send_confirm_link(struct smc_link *lnk, |
9bf9abea | 83 | enum smc_llc_reqresp reqresp); |
7005ada6 | 84 | int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[], |
fbed3b37 | 85 | struct smc_link *link_new, |
52bedf37 | 86 | enum smc_llc_reqresp reqresp); |
fbed3b37 KG |
87 | int smc_llc_send_delete_link(struct smc_link *link, u8 link_del_id, |
88 | enum smc_llc_reqresp reqresp, bool orderly, | |
89 | u32 reason); | |
4dadd151 | 90 | void smc_llc_srv_delete_link_local(struct smc_link *link, u8 del_link_id); |
00a049cf KG |
91 | void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc); |
92 | void smc_llc_lgr_clear(struct smc_link_group *lgr); | |
2a4c57a9 | 93 | int smc_llc_link_init(struct smc_link *link); |
00a049cf | 94 | void smc_llc_link_active(struct smc_link *link); |
0a99be43 | 95 | void smc_llc_link_clear(struct smc_link *link, bool log); |
3d88a21b | 96 | int smc_llc_do_confirm_rkey(struct smc_link *send_link, |
44aa81ce | 97 | struct smc_buf_desc *rmb_desc); |
6d74c3a8 | 98 | int smc_llc_do_delete_rkey(struct smc_link_group *lgr, |
60e03c62 | 99 | struct smc_buf_desc *rmb_desc); |
555da9af KG |
100 | int smc_llc_flow_initiate(struct smc_link_group *lgr, |
101 | enum smc_llc_flowtype type); | |
102 | void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow); | |
92334cfc KG |
103 | int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry, |
104 | enum smc_llc_reqresp type); | |
45fa8da0 | 105 | void smc_llc_link_set_uid(struct smc_link *link); |
649758ff | 106 | void smc_llc_save_peer_uid(struct smc_llc_qentry *qentry); |
555da9af KG |
107 | struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr, |
108 | struct smc_link *lnk, | |
109 | int time_out, u8 exp_msg); | |
110 | struct smc_llc_qentry *smc_llc_flow_qentry_clr(struct smc_llc_flow *flow); | |
111 | void smc_llc_flow_qentry_del(struct smc_llc_flow *flow); | |
f3811fd7 KG |
112 | void smc_llc_send_link_delete_all(struct smc_link_group *lgr, bool ord, |
113 | u32 rsn); | |
b1570a87 | 114 | int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry); |
b4ba4652 KG |
115 | int smc_llc_srv_add_link(struct smc_link *link, |
116 | struct smc_llc_qentry *req_qentry); | |
c48254fa | 117 | void smc_llc_add_link_local(struct smc_link *link); |
9bf9abea UB |
118 | int smc_llc_init(void) __init; |
119 | ||
120 | #endif /* SMC_LLC_H */ |