^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) * Definitions for LLC (link layer control) message handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2016
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author(s): Klaus Wacker <Klaus.Wacker@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * 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_LLC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define SMC_LLC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "smc_wr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define SMC_LLC_FLAG_RESP 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define SMC_LLC_WAIT_FIRST_TIME (5 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SMC_LLC_WAIT_TIME (2 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) enum smc_llc_reqresp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) SMC_LLC_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) SMC_LLC_RESP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) enum smc_llc_msg_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) SMC_LLC_CONFIRM_LINK = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) SMC_LLC_ADD_LINK = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) SMC_LLC_ADD_LINK_CONT = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) SMC_LLC_DELETE_LINK = 0x04,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) SMC_LLC_CONFIRM_RKEY = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) SMC_LLC_TEST_LINK = 0x07,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) SMC_LLC_CONFIRM_RKEY_CONT = 0x08,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) SMC_LLC_DELETE_RKEY = 0x09,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define smc_link_downing(state) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) (cmpxchg(state, SMC_LNK_ACTIVE, SMC_LNK_INACTIVE) == SMC_LNK_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* LLC DELETE LINK Request Reason Codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define SMC_LLC_DEL_LOST_PATH 0x00010000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define SMC_LLC_DEL_OP_INIT_TERM 0x00020000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define SMC_LLC_DEL_PROG_INIT_TERM 0x00030000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define SMC_LLC_DEL_PROT_VIOL 0x00040000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define SMC_LLC_DEL_NO_ASYM_NEEDED 0x00050000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* LLC DELETE LINK Response Reason Codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define SMC_LLC_DEL_NOLNK 0x00100000 /* Unknown Link ID (no link) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define SMC_LLC_DEL_NOLGR 0x00200000 /* Unknown Link Group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* returns a usable link of the link group, or NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static inline struct smc_link *smc_llc_usable_link(struct smc_link_group *lgr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (smc_link_usable(&lgr->lnk[i]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return &lgr->lnk[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* set the termination reason code for the link group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static inline void smc_llc_set_termination_rsn(struct smc_link_group *lgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u32 rsn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (!lgr->llc_termination_rsn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) lgr->llc_termination_rsn = rsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* transmit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int smc_llc_send_confirm_link(struct smc_link *lnk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) enum smc_llc_reqresp reqresp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct smc_link *link_new,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) enum smc_llc_reqresp reqresp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int smc_llc_send_delete_link(struct smc_link *link, u8 link_del_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) enum smc_llc_reqresp reqresp, bool orderly,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) u32 reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) void smc_llc_srv_delete_link_local(struct smc_link *link, u8 del_link_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void smc_llc_lgr_clear(struct smc_link_group *lgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int smc_llc_link_init(struct smc_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void smc_llc_link_active(struct smc_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) void smc_llc_link_clear(struct smc_link *link, bool log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int smc_llc_do_confirm_rkey(struct smc_link *send_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct smc_buf_desc *rmb_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int smc_llc_do_delete_rkey(struct smc_link_group *lgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct smc_buf_desc *rmb_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int smc_llc_flow_initiate(struct smc_link_group *lgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) enum smc_llc_flowtype type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) enum smc_llc_reqresp type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) void smc_llc_link_set_uid(struct smc_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) void smc_llc_save_peer_uid(struct smc_llc_qentry *qentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct smc_link *lnk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int time_out, u8 exp_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct smc_llc_qentry *smc_llc_flow_qentry_clr(struct smc_llc_flow *flow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void smc_llc_flow_qentry_del(struct smc_llc_flow *flow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) void smc_llc_send_link_delete_all(struct smc_link_group *lgr, bool ord,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) u32 rsn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int smc_llc_srv_add_link(struct smc_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) void smc_llc_add_link_local(struct smc_link *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int smc_llc_init(void) __init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #endif /* SMC_LLC_H */