efct_io.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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(__EFCT_IO_H__)
  7. #define __EFCT_IO_H__
  8. #include "efct_lio.h"
  9. #define EFCT_LOG_ENABLE_IO_ERRORS(efct) \
  10. (((efct) != NULL) ? (((efct)->logmask & (1U << 6)) != 0) : 0)
  11. #define io_error_log(io, fmt, ...) \
  12. do { \
  13. if (EFCT_LOG_ENABLE_IO_ERRORS(io->efct)) \
  14. efc_log_warn(io->efct, fmt, ##__VA_ARGS__); \
  15. } while (0)
  16. #define SCSI_CMD_BUF_LENGTH 48
  17. #define SCSI_RSP_BUF_LENGTH (FCP_RESP_WITH_EXT + SCSI_SENSE_BUFFERSIZE)
  18. #define EFCT_NUM_SCSI_IOS 8192
  19. enum efct_io_type {
  20. EFCT_IO_TYPE_IO = 0,
  21. EFCT_IO_TYPE_ELS,
  22. EFCT_IO_TYPE_CT,
  23. EFCT_IO_TYPE_CT_RESP,
  24. EFCT_IO_TYPE_BLS_RESP,
  25. EFCT_IO_TYPE_ABORT,
  26. EFCT_IO_TYPE_MAX,
  27. };
  28. enum efct_els_state {
  29. EFCT_ELS_REQUEST = 0,
  30. EFCT_ELS_REQUEST_DELAYED,
  31. EFCT_ELS_REQUEST_DELAY_ABORT,
  32. EFCT_ELS_REQ_ABORT,
  33. EFCT_ELS_REQ_ABORTED,
  34. EFCT_ELS_ABORT_IO_COMPL,
  35. };
  36. /**
  37. * Scsi target IO object
  38. * @efct: pointer back to efct
  39. * @instance_index: unique instance index value
  40. * @io: IO display name
  41. * @node: pointer to node
  42. * @list_entry: io list entry
  43. * @io_pending_link: io pending list entry
  44. * @ref: reference counter
  45. * @release: release callback function
  46. * @init_task_tag: initiator task tag (OX_ID) for back-end and SCSI logging
  47. * @tgt_task_tag: target task tag (RX_ID) for back-end and SCSI logging
  48. * @hw_tag: HW layer unique IO id
  49. * @tag: unique IO identifier
  50. * @sgl: SGL
  51. * @sgl_allocated: Number of allocated SGEs
  52. * @sgl_count: Number of SGEs in this SGL
  53. * @tgt_io: backend target private IO data
  54. * @exp_xfer_len: expected data transfer length, based on FC header
  55. * @hw_priv: Declarations private to HW/SLI
  56. * @io_type: indicates what this struct efct_io structure is used for
  57. * @hio: hw io object
  58. * @transferred: Number of bytes transferred
  59. * @auto_resp: set if auto_trsp was set
  60. * @low_latency: set if low latency request
  61. * @wq_steering: selected WQ steering request
  62. * @wq_class: selected WQ class if steering is class
  63. * @xfer_req: transfer size for current request
  64. * @scsi_tgt_cb: target callback function
  65. * @scsi_tgt_cb_arg: target callback function argument
  66. * @abort_cb: abort callback function
  67. * @abort_cb_arg: abort callback function argument
  68. * @bls_cb: BLS callback function
  69. * @bls_cb_arg: BLS callback function argument
  70. * @tmf_cmd: TMF command being processed
  71. * @abort_rx_id: rx_id from the ABTS that initiated the command abort
  72. * @cmd_tgt: True if this is a Target command
  73. * @send_abts: when aborting, indicates ABTS is to be sent
  74. * @cmd_ini: True if this is an Initiator command
  75. * @seq_init: True if local node has sequence initiative
  76. * @iparam: iparams for hw io send call
  77. * @hio_type: HW IO type
  78. * @wire_len: wire length
  79. * @hw_cb: saved HW callback
  80. * @io_to_abort: for abort handling, pointer to IO to abort
  81. * @rspbuf: SCSI Response buffer
  82. * @timeout: Timeout value in seconds for this IO
  83. * @cs_ctl: CS_CTL priority for this IO
  84. * @io_free: Is io object in freelist
  85. * @app_id: application id
  86. */
  87. struct efct_io {
  88. struct efct *efct;
  89. u32 instance_index;
  90. const char *display_name;
  91. struct efct_node *node;
  92. struct list_head list_entry;
  93. struct list_head io_pending_link;
  94. struct kref ref;
  95. void (*release)(struct kref *arg);
  96. u32 init_task_tag;
  97. u32 tgt_task_tag;
  98. u32 hw_tag;
  99. u32 tag;
  100. struct efct_scsi_sgl *sgl;
  101. u32 sgl_allocated;
  102. u32 sgl_count;
  103. struct efct_scsi_tgt_io tgt_io;
  104. u32 exp_xfer_len;
  105. void *hw_priv;
  106. enum efct_io_type io_type;
  107. struct efct_hw_io *hio;
  108. size_t transferred;
  109. bool auto_resp;
  110. bool low_latency;
  111. u8 wq_steering;
  112. u8 wq_class;
  113. u64 xfer_req;
  114. efct_scsi_io_cb_t scsi_tgt_cb;
  115. void *scsi_tgt_cb_arg;
  116. efct_scsi_io_cb_t abort_cb;
  117. void *abort_cb_arg;
  118. efct_scsi_io_cb_t bls_cb;
  119. void *bls_cb_arg;
  120. enum efct_scsi_tmf_cmd tmf_cmd;
  121. u16 abort_rx_id;
  122. bool cmd_tgt;
  123. bool send_abts;
  124. bool cmd_ini;
  125. bool seq_init;
  126. union efct_hw_io_param_u iparam;
  127. enum efct_hw_io_type hio_type;
  128. u64 wire_len;
  129. void *hw_cb;
  130. struct efct_io *io_to_abort;
  131. struct efc_dma rspbuf;
  132. u32 timeout;
  133. u8 cs_ctl;
  134. u8 io_free;
  135. u32 app_id;
  136. };
  137. struct efct_io_cb_arg {
  138. int status;
  139. int ext_status;
  140. void *app;
  141. };
  142. struct efct_io_pool *
  143. efct_io_pool_create(struct efct *efct, u32 num_sgl);
  144. int
  145. efct_io_pool_free(struct efct_io_pool *io_pool);
  146. u32
  147. efct_io_pool_allocated(struct efct_io_pool *io_pool);
  148. struct efct_io *
  149. efct_io_pool_io_alloc(struct efct_io_pool *io_pool);
  150. void
  151. efct_io_pool_io_free(struct efct_io_pool *io_pool, struct efct_io *io);
  152. struct efct_io *
  153. efct_io_find_tgt_io(struct efct *efct, struct efct_node *node,
  154. u16 ox_id, u16 rx_id);
  155. #endif /* __EFCT_IO_H__ */