snic_io.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
  3. #ifndef _SNIC_IO_H
  4. #define _SNIC_IO_H
  5. #define SNIC_DFLT_SG_DESC_CNT 32 /* Default descriptors for sgl */
  6. #define SNIC_MAX_SG_DESC_CNT 60 /* Max descriptor for sgl */
  7. #define SNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */
  8. /* SG descriptor for snic */
  9. struct snic_sg_desc {
  10. __le64 addr;
  11. __le32 len;
  12. u32 _resvd;
  13. };
  14. struct snic_dflt_sgl {
  15. struct snic_sg_desc sg_desc[SNIC_DFLT_SG_DESC_CNT];
  16. };
  17. struct snic_max_sgl {
  18. struct snic_sg_desc sg_desc[SNIC_MAX_SG_DESC_CNT];
  19. };
  20. enum snic_req_cache_type {
  21. SNIC_REQ_CACHE_DFLT_SGL = 0, /* cache with default size sgl */
  22. SNIC_REQ_CACHE_MAX_SGL, /* cache with max size sgl */
  23. SNIC_REQ_TM_CACHE, /* cache for task mgmt reqs contains
  24. snic_host_req objects only*/
  25. SNIC_REQ_MAX_CACHES /* number of sgl caches */
  26. };
  27. /* Per IO internal state */
  28. struct snic_internal_io_state {
  29. char *rqi;
  30. u64 flags;
  31. u32 state;
  32. u32 abts_status; /* Abort completion status */
  33. u32 lr_status; /* device reset completion status */
  34. };
  35. /* IO state machine */
  36. enum snic_ioreq_state {
  37. SNIC_IOREQ_NOT_INITED = 0,
  38. SNIC_IOREQ_PENDING,
  39. SNIC_IOREQ_ABTS_PENDING,
  40. SNIC_IOREQ_ABTS_COMPLETE,
  41. SNIC_IOREQ_LR_PENDING,
  42. SNIC_IOREQ_LR_COMPLETE,
  43. SNIC_IOREQ_COMPLETE,
  44. };
  45. struct snic;
  46. struct snic_host_req;
  47. /*
  48. * snic_req_info : Contains info about IO, one per scsi command.
  49. * Notes: Make sure that the structure is aligned to 16 B
  50. * this helps in easy access to snic_req_info from snic_host_req
  51. */
  52. struct snic_req_info {
  53. struct list_head list;
  54. struct snic_host_req *req;
  55. u64 start_time; /* start time in jiffies */
  56. u16 rq_pool_type; /* noticion of request pool type */
  57. u16 req_len; /* buf len passing to fw (req + sgl)*/
  58. u32 tgt_id;
  59. u32 tm_tag;
  60. u8 io_cmpl:1; /* sets to 1 when fw completes IO */
  61. u8 resvd[3];
  62. struct scsi_cmnd *sc; /* Associated scsi cmd */
  63. struct snic *snic; /* Associated snic */
  64. ulong sge_va; /* Pointer to Resp Buffer */
  65. u64 snsbuf_va;
  66. struct snic_host_req *abort_req;
  67. struct completion *abts_done;
  68. struct snic_host_req *dr_req;
  69. struct completion *dr_done;
  70. };
  71. #define rqi_to_req(rqi) \
  72. ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
  73. #define req_to_rqi(req) \
  74. ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
  75. #define req_to_sgl(req) \
  76. ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
  77. struct snic_req_info *
  78. snic_req_init(struct snic *, int sg_cnt);
  79. void snic_req_free(struct snic *, struct snic_req_info *);
  80. void snic_calc_io_process_time(struct snic *, struct snic_req_info *);
  81. void snic_pci_unmap_rsp_buf(struct snic *, struct snic_req_info *);
  82. struct snic_host_req *
  83. snic_abort_req_init(struct snic *, struct snic_req_info *);
  84. struct snic_host_req *
  85. snic_dr_req_init(struct snic *, struct snic_req_info *);
  86. #endif /* _SNIC_IO_H */