smc_llc.h 3.6 KB

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