xref: /linux/net/smc/smc_llc.h (revision 40e79150c1686263e6a031d7702aec63aff31332)
1 /* SPDX-License-Identifier: GPL-2.0 */
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)
21 #define SMC_LLC_WAIT_TIME		(2 * HZ)
22 
23 enum smc_llc_reqresp {
24 	SMC_LLC_REQ,
25 	SMC_LLC_RESP
26 };
27 
28 enum smc_llc_msg_type {
29 	SMC_LLC_CONFIRM_LINK		= 0x01,
30 	SMC_LLC_ADD_LINK		= 0x02,
31 	SMC_LLC_DELETE_LINK		= 0x04,
32 	SMC_LLC_CONFIRM_RKEY		= 0x06,
33 	SMC_LLC_TEST_LINK		= 0x07,
34 	SMC_LLC_CONFIRM_RKEY_CONT	= 0x08,
35 	SMC_LLC_DELETE_RKEY		= 0x09,
36 };
37 
38 /* returns a usable link of the link group, or NULL */
39 static inline struct smc_link *smc_llc_usable_link(struct smc_link_group *lgr)
40 {
41 	int i;
42 
43 	for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
44 		if (smc_link_usable(&lgr->lnk[i]))
45 			return &lgr->lnk[i];
46 	return NULL;
47 }
48 
49 /* transmit */
50 int smc_llc_send_confirm_link(struct smc_link *lnk,
51 			      enum smc_llc_reqresp reqresp);
52 int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[],
53 			  enum smc_llc_reqresp reqresp);
54 int smc_llc_send_delete_link(struct smc_link *link,
55 			     enum smc_llc_reqresp reqresp, bool orderly);
56 void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc);
57 void smc_llc_lgr_clear(struct smc_link_group *lgr);
58 int smc_llc_link_init(struct smc_link *link);
59 void smc_llc_link_active(struct smc_link *link);
60 void smc_llc_link_clear(struct smc_link *link);
61 int smc_llc_do_confirm_rkey(struct smc_link *send_link,
62 			    struct smc_buf_desc *rmb_desc);
63 int smc_llc_do_delete_rkey(struct smc_link_group *lgr,
64 			   struct smc_buf_desc *rmb_desc);
65 int smc_llc_flow_initiate(struct smc_link_group *lgr,
66 			  enum smc_llc_flowtype type);
67 void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow);
68 int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry,
69 			   enum smc_llc_reqresp type);
70 struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
71 				    struct smc_link *lnk,
72 				    int time_out, u8 exp_msg);
73 struct smc_llc_qentry *smc_llc_flow_qentry_clr(struct smc_llc_flow *flow);
74 void smc_llc_flow_qentry_del(struct smc_llc_flow *flow);
75 int smc_llc_init(void) __init;
76 
77 #endif /* SMC_LLC_H */
78