snic_io.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright 2014 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #ifndef _SNIC_IO_H
  18. #define _SNIC_IO_H
  19. #define SNIC_DFLT_SG_DESC_CNT 32 /* Default descriptors for sgl */
  20. #define SNIC_MAX_SG_DESC_CNT 60 /* Max descriptor for sgl */
  21. #define SNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */
  22. /* SG descriptor for snic */
  23. struct snic_sg_desc {
  24. __le64 addr;
  25. __le32 len;
  26. u32 _resvd;
  27. };
  28. struct snic_dflt_sgl {
  29. struct snic_sg_desc sg_desc[SNIC_DFLT_SG_DESC_CNT];
  30. };
  31. struct snic_max_sgl {
  32. struct snic_sg_desc sg_desc[SNIC_MAX_SG_DESC_CNT];
  33. };
  34. enum snic_req_cache_type {
  35. SNIC_REQ_CACHE_DFLT_SGL = 0, /* cache with default size sgl */
  36. SNIC_REQ_CACHE_MAX_SGL, /* cache with max size sgl */
  37. SNIC_REQ_TM_CACHE, /* cache for task mgmt reqs contains
  38. snic_host_req objects only*/
  39. SNIC_REQ_MAX_CACHES /* number of sgl caches */
  40. };
  41. /* Per IO internal state */
  42. struct snic_internal_io_state {
  43. char *rqi;
  44. u64 flags;
  45. u32 state;
  46. u32 abts_status; /* Abort completion status */
  47. u32 lr_status; /* device reset completion status */
  48. };
  49. /* IO state machine */
  50. enum snic_ioreq_state {
  51. SNIC_IOREQ_NOT_INITED = 0,
  52. SNIC_IOREQ_PENDING,
  53. SNIC_IOREQ_ABTS_PENDING,
  54. SNIC_IOREQ_ABTS_COMPLETE,
  55. SNIC_IOREQ_LR_PENDING,
  56. SNIC_IOREQ_LR_COMPLETE,
  57. SNIC_IOREQ_COMPLETE,
  58. };
  59. struct snic;
  60. struct snic_host_req;
  61. /*
  62. * snic_req_info : Contains info about IO, one per scsi command.
  63. * Notes: Make sure that the structure is aligned to 16 B
  64. * this helps in easy access to snic_req_info from snic_host_req
  65. */
  66. struct snic_req_info {
  67. struct list_head list;
  68. struct snic_host_req *req;
  69. u64 start_time; /* start time in jiffies */
  70. u16 rq_pool_type; /* noticion of request pool type */
  71. u16 req_len; /* buf len passing to fw (req + sgl)*/
  72. u32 tgt_id;
  73. u32 tm_tag;
  74. u8 io_cmpl:1; /* sets to 1 when fw completes IO */
  75. u8 resvd[3];
  76. struct scsi_cmnd *sc; /* Associated scsi cmd */
  77. struct snic *snic; /* Associated snic */
  78. ulong sge_va; /* Pointer to Resp Buffer */
  79. u64 snsbuf_va;
  80. struct snic_host_req *abort_req;
  81. struct completion *abts_done;
  82. struct snic_host_req *dr_req;
  83. struct completion *dr_done;
  84. };
  85. #define rqi_to_req(rqi) \
  86. ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
  87. #define req_to_rqi(req) \
  88. ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
  89. #define req_to_sgl(req) \
  90. ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
  91. struct snic_req_info *
  92. snic_req_init(struct snic *, int sg_cnt);
  93. void snic_req_free(struct snic *, struct snic_req_info *);
  94. void snic_calc_io_process_time(struct snic *, struct snic_req_info *);
  95. void snic_pci_unmap_rsp_buf(struct snic *, struct snic_req_info *);
  96. struct snic_host_req *
  97. snic_abort_req_init(struct snic *, struct snic_req_info *);
  98. struct snic_host_req *
  99. snic_dr_req_init(struct snic *, struct snic_req_info *);
  100. #endif /* _SNIC_IO_H */