Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Shared Memory Communications over RDMA (SMC-R) and RoCE
0004  *
0005  *  Definitions for LLC (link layer control) message handling
0006  *
0007  *  Copyright IBM Corp. 2016
0008  *
0009  *  Author(s):  Klaus Wacker <Klaus.Wacker@de.ibm.com>
0010  *              Ursula Braun <ubraun@linux.vnet.ibm.com>
0011  */
0012 
0013 #ifndef SMC_LLC_H
0014 #define SMC_LLC_H
0015 
0016 #include "smc_wr.h"
0017 
0018 #define SMC_LLC_FLAG_RESP       0x80
0019 
0020 #define SMC_LLC_WAIT_FIRST_TIME     (5 * HZ)
0021 #define SMC_LLC_WAIT_TIME       (2 * HZ)
0022 
0023 enum smc_llc_reqresp {
0024     SMC_LLC_REQ,
0025     SMC_LLC_RESP
0026 };
0027 
0028 enum smc_llc_msg_type {
0029     SMC_LLC_CONFIRM_LINK        = 0x01,
0030     SMC_LLC_ADD_LINK        = 0x02,
0031     SMC_LLC_ADD_LINK_CONT       = 0x03,
0032     SMC_LLC_DELETE_LINK     = 0x04,
0033     SMC_LLC_REQ_ADD_LINK        = 0x05,
0034     SMC_LLC_CONFIRM_RKEY        = 0x06,
0035     SMC_LLC_TEST_LINK       = 0x07,
0036     SMC_LLC_CONFIRM_RKEY_CONT   = 0x08,
0037     SMC_LLC_DELETE_RKEY     = 0x09,
0038     /* V2 types */
0039     SMC_LLC_CONFIRM_LINK_V2     = 0x21,
0040     SMC_LLC_ADD_LINK_V2     = 0x22,
0041     SMC_LLC_DELETE_LINK_V2      = 0x24,
0042     SMC_LLC_REQ_ADD_LINK_V2     = 0x25,
0043     SMC_LLC_CONFIRM_RKEY_V2     = 0x26,
0044     SMC_LLC_TEST_LINK_V2        = 0x27,
0045     SMC_LLC_DELETE_RKEY_V2      = 0x29,
0046 };
0047 
0048 #define smc_link_downing(state) \
0049     (cmpxchg(state, SMC_LNK_ACTIVE, SMC_LNK_INACTIVE) == SMC_LNK_ACTIVE)
0050 
0051 /* LLC DELETE LINK Request Reason Codes */
0052 #define SMC_LLC_DEL_LOST_PATH       0x00010000
0053 #define SMC_LLC_DEL_OP_INIT_TERM    0x00020000
0054 #define SMC_LLC_DEL_PROG_INIT_TERM  0x00030000
0055 #define SMC_LLC_DEL_PROT_VIOL       0x00040000
0056 #define SMC_LLC_DEL_NO_ASYM_NEEDED  0x00050000
0057 /* LLC DELETE LINK Response Reason Codes */
0058 #define SMC_LLC_DEL_NOLNK   0x00100000  /* Unknown Link ID (no link) */
0059 #define SMC_LLC_DEL_NOLGR   0x00200000  /* Unknown Link Group */
0060 
0061 /* returns a usable link of the link group, or NULL */
0062 static inline struct smc_link *smc_llc_usable_link(struct smc_link_group *lgr)
0063 {
0064     int i;
0065 
0066     for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
0067         if (smc_link_usable(&lgr->lnk[i]))
0068             return &lgr->lnk[i];
0069     return NULL;
0070 }
0071 
0072 /* set the termination reason code for the link group */
0073 static inline void smc_llc_set_termination_rsn(struct smc_link_group *lgr,
0074                            u32 rsn)
0075 {
0076     if (!lgr->llc_termination_rsn)
0077         lgr->llc_termination_rsn = rsn;
0078 }
0079 
0080 /* transmit */
0081 int smc_llc_send_confirm_link(struct smc_link *lnk,
0082                   enum smc_llc_reqresp reqresp);
0083 int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[],
0084               struct smc_link *link_new,
0085               enum smc_llc_reqresp reqresp);
0086 int smc_llc_send_delete_link(struct smc_link *link, u8 link_del_id,
0087                  enum smc_llc_reqresp reqresp, bool orderly,
0088                  u32 reason);
0089 void smc_llc_srv_delete_link_local(struct smc_link *link, u8 del_link_id);
0090 void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc);
0091 void smc_llc_lgr_clear(struct smc_link_group *lgr);
0092 int smc_llc_link_init(struct smc_link *link);
0093 void smc_llc_link_active(struct smc_link *link);
0094 void smc_llc_link_clear(struct smc_link *link, bool log);
0095 int smc_llc_do_confirm_rkey(struct smc_link *send_link,
0096                 struct smc_buf_desc *rmb_desc);
0097 int smc_llc_do_delete_rkey(struct smc_link_group *lgr,
0098                struct smc_buf_desc *rmb_desc);
0099 int smc_llc_flow_initiate(struct smc_link_group *lgr,
0100               enum smc_llc_flowtype type);
0101 void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow);
0102 int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry,
0103                enum smc_llc_reqresp type);
0104 void smc_llc_link_set_uid(struct smc_link *link);
0105 void smc_llc_save_peer_uid(struct smc_llc_qentry *qentry);
0106 struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
0107                     struct smc_link *lnk,
0108                     int time_out, u8 exp_msg);
0109 struct smc_llc_qentry *smc_llc_flow_qentry_clr(struct smc_llc_flow *flow);
0110 void smc_llc_flow_qentry_del(struct smc_llc_flow *flow);
0111 void smc_llc_send_link_delete_all(struct smc_link_group *lgr, bool ord,
0112                   u32 rsn);
0113 int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry);
0114 int smc_llc_srv_add_link(struct smc_link *link,
0115              struct smc_llc_qentry *req_qentry);
0116 void smc_llc_add_link_local(struct smc_link *link);
0117 int smc_llc_init(void) __init;
0118 
0119 #endif /* SMC_LLC_H */