efc_node.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
  4. * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
  5. */
  6. #if !defined(__EFC_NODE_H__)
  7. #define __EFC_NODE_H__
  8. #include "scsi/fc/fc_ns.h"
  9. #define EFC_NODEDB_PAUSE_FABRIC_LOGIN (1 << 0)
  10. #define EFC_NODEDB_PAUSE_NAMESERVER (1 << 1)
  11. #define EFC_NODEDB_PAUSE_NEW_NODES (1 << 2)
  12. #define MAX_ACC_REJECT_PAYLOAD sizeof(struct fc_els_ls_rjt)
  13. #define scsi_io_printf(io, fmt, ...) \
  14. efc_log_debug(io->efc, "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt, \
  15. io->node->display_name, io->instance_index, io->init_task_tag, \
  16. io->tgt_task_tag, io->hw_tag, ##__VA_ARGS__)
  17. static inline void
  18. efc_node_evt_set(struct efc_sm_ctx *ctx, enum efc_sm_event evt,
  19. const char *handler)
  20. {
  21. struct efc_node *node = ctx->app;
  22. if (evt == EFC_EVT_ENTER) {
  23. strncpy(node->current_state_name, handler,
  24. sizeof(node->current_state_name));
  25. } else if (evt == EFC_EVT_EXIT) {
  26. strncpy(node->prev_state_name, node->current_state_name,
  27. sizeof(node->prev_state_name));
  28. strncpy(node->current_state_name, "invalid",
  29. sizeof(node->current_state_name));
  30. }
  31. node->prev_evt = node->current_evt;
  32. node->current_evt = evt;
  33. }
  34. /**
  35. * hold frames in pending frame list
  36. *
  37. * Unsolicited receive frames are held on the node pending frame list,
  38. * rather than being processed.
  39. */
  40. static inline void
  41. efc_node_hold_frames(struct efc_node *node)
  42. {
  43. node->hold_frames = true;
  44. }
  45. /**
  46. * accept frames
  47. *
  48. * Unsolicited receive frames processed rather than being held on the node
  49. * pending frame list.
  50. */
  51. static inline void
  52. efc_node_accept_frames(struct efc_node *node)
  53. {
  54. node->hold_frames = false;
  55. }
  56. /*
  57. * Node initiator/target enable defines
  58. * All combinations of the SLI port (nport) initiator/target enable,
  59. * and remote node initiator/target enable are enumerated.
  60. * ex: EFC_NODE_ENABLE_T_TO_IT decodes to target mode is enabled on SLI port
  61. * and I+T is enabled on remote node.
  62. */
  63. enum efc_node_enable {
  64. EFC_NODE_ENABLE_x_TO_x,
  65. EFC_NODE_ENABLE_x_TO_T,
  66. EFC_NODE_ENABLE_x_TO_I,
  67. EFC_NODE_ENABLE_x_TO_IT,
  68. EFC_NODE_ENABLE_T_TO_x,
  69. EFC_NODE_ENABLE_T_TO_T,
  70. EFC_NODE_ENABLE_T_TO_I,
  71. EFC_NODE_ENABLE_T_TO_IT,
  72. EFC_NODE_ENABLE_I_TO_x,
  73. EFC_NODE_ENABLE_I_TO_T,
  74. EFC_NODE_ENABLE_I_TO_I,
  75. EFC_NODE_ENABLE_I_TO_IT,
  76. EFC_NODE_ENABLE_IT_TO_x,
  77. EFC_NODE_ENABLE_IT_TO_T,
  78. EFC_NODE_ENABLE_IT_TO_I,
  79. EFC_NODE_ENABLE_IT_TO_IT,
  80. };
  81. static inline enum efc_node_enable
  82. efc_node_get_enable(struct efc_node *node)
  83. {
  84. u32 retval = 0;
  85. if (node->nport->enable_ini)
  86. retval |= (1U << 3);
  87. if (node->nport->enable_tgt)
  88. retval |= (1U << 2);
  89. if (node->init)
  90. retval |= (1U << 1);
  91. if (node->targ)
  92. retval |= (1U << 0);
  93. return (enum efc_node_enable)retval;
  94. }
  95. int
  96. efc_node_check_els_req(struct efc_sm_ctx *ctx,
  97. enum efc_sm_event evt, void *arg,
  98. u8 cmd, void (*efc_node_common_func)(const char *,
  99. struct efc_sm_ctx *, enum efc_sm_event, void *),
  100. const char *funcname);
  101. int
  102. efc_node_check_ns_req(struct efc_sm_ctx *ctx,
  103. enum efc_sm_event evt, void *arg,
  104. u16 cmd, void (*efc_node_common_func)(const char *,
  105. struct efc_sm_ctx *, enum efc_sm_event, void *),
  106. const char *funcname);
  107. int
  108. efc_node_attach(struct efc_node *node);
  109. struct efc_node *
  110. efc_node_alloc(struct efc_nport *nport, u32 port_id,
  111. bool init, bool targ);
  112. void
  113. efc_node_free(struct efc_node *efc);
  114. void
  115. efc_node_update_display_name(struct efc_node *node);
  116. void efc_node_post_event(struct efc_node *node, enum efc_sm_event evt,
  117. void *arg);
  118. void
  119. __efc_node_shutdown(struct efc_sm_ctx *ctx,
  120. enum efc_sm_event evt, void *arg);
  121. void
  122. __efc_node_wait_node_free(struct efc_sm_ctx *ctx,
  123. enum efc_sm_event evt, void *arg);
  124. void
  125. __efc_node_wait_els_shutdown(struct efc_sm_ctx *ctx,
  126. enum efc_sm_event evt, void *arg);
  127. void
  128. __efc_node_wait_ios_shutdown(struct efc_sm_ctx *ctx,
  129. enum efc_sm_event evt, void *arg);
  130. void
  131. efc_node_save_sparms(struct efc_node *node, void *payload);
  132. void
  133. efc_node_transition(struct efc_node *node,
  134. void (*state)(struct efc_sm_ctx *, enum efc_sm_event,
  135. void *), void *data);
  136. void
  137. __efc_node_common(const char *funcname, struct efc_sm_ctx *ctx,
  138. enum efc_sm_event evt, void *arg);
  139. void
  140. efc_node_initiate_cleanup(struct efc_node *node);
  141. void
  142. efc_node_build_eui_name(char *buf, u32 buf_len, uint64_t eui_name);
  143. void
  144. efc_node_pause(struct efc_node *node,
  145. void (*state)(struct efc_sm_ctx *ctx,
  146. enum efc_sm_event evt, void *arg));
  147. void
  148. __efc_node_paused(struct efc_sm_ctx *ctx,
  149. enum efc_sm_event evt, void *arg);
  150. int
  151. efc_node_active_ios_empty(struct efc_node *node);
  152. void
  153. efc_node_send_ls_io_cleanup(struct efc_node *node);
  154. int
  155. efc_els_io_list_empty(struct efc_node *node, struct list_head *list);
  156. void
  157. efc_process_node_pending(struct efc_node *domain);
  158. u64 efc_node_get_wwnn(struct efc_node *node);
  159. struct efc_node *
  160. efc_node_find(struct efc_nport *nport, u32 id);
  161. void
  162. efc_node_post_els_resp(struct efc_node *node, u32 evt, void *arg);
  163. void
  164. efc_node_recv_els_frame(struct efc_node *node, struct efc_hw_sequence *s);
  165. void
  166. efc_node_recv_ct_frame(struct efc_node *node, struct efc_hw_sequence *seq);
  167. void
  168. efc_node_recv_fcp_cmd(struct efc_node *node, struct efc_hw_sequence *seq);
  169. #endif /* __EFC_NODE_H__ */