snic_disc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_DISC_H
  18. #define __SNIC_DISC_H
  19. #include "snic_fwint.h"
  20. enum snic_disc_state {
  21. SNIC_DISC_NONE,
  22. SNIC_DISC_INIT,
  23. SNIC_DISC_PENDING,
  24. SNIC_DISC_DONE
  25. };
  26. struct snic;
  27. struct snic_disc {
  28. struct list_head tgt_list;
  29. enum snic_disc_state state;
  30. struct mutex mutex;
  31. u16 disc_id;
  32. u8 req_cnt;
  33. u32 nxt_tgt_id;
  34. u32 rtgt_cnt;
  35. u8 *rtgt_info;
  36. struct delayed_work disc_timeout;
  37. void (*cb)(struct snic *);
  38. };
  39. #define SNIC_TGT_NAM_LEN 16
  40. enum snic_tgt_state {
  41. SNIC_TGT_STAT_NONE,
  42. SNIC_TGT_STAT_INIT,
  43. SNIC_TGT_STAT_ONLINE, /* Target is Online */
  44. SNIC_TGT_STAT_OFFLINE, /* Target is Offline */
  45. SNIC_TGT_STAT_DEL,
  46. };
  47. struct snic_tgt_priv {
  48. struct list_head list;
  49. enum snic_tgt_type typ;
  50. u16 disc_id;
  51. char *name[SNIC_TGT_NAM_LEN];
  52. union {
  53. /*DAS Target specific info */
  54. /*SAN Target specific info */
  55. u8 dummmy;
  56. } u;
  57. };
  58. /* snic tgt flags */
  59. #define SNIC_TGT_SCAN_PENDING 0x01
  60. struct snic_tgt {
  61. struct list_head list;
  62. u16 id;
  63. u16 channel;
  64. u32 flags;
  65. u32 scsi_tgt_id;
  66. enum snic_tgt_state state;
  67. struct device dev;
  68. struct work_struct scan_work;
  69. struct work_struct del_work;
  70. struct snic_tgt_priv tdata;
  71. };
  72. struct snic_fw_req;
  73. void snic_disc_init(struct snic_disc *);
  74. int snic_disc_start(struct snic *);
  75. void snic_disc_term(struct snic *);
  76. int snic_report_tgt_cmpl_handler(struct snic *, struct snic_fw_req *);
  77. int snic_tgtinfo_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq);
  78. void snic_process_report_tgts_rsp(struct work_struct *);
  79. void snic_handle_tgt_disc(struct work_struct *);
  80. void snic_handle_disc(struct work_struct *);
  81. void snic_tgt_dev_release(struct device *);
  82. void snic_tgt_del_all(struct snic *);
  83. #define dev_to_tgt(d) \
  84. container_of(d, struct snic_tgt, dev)
  85. static inline int
  86. is_snic_target(struct device *dev)
  87. {
  88. return dev->release == snic_tgt_dev_release;
  89. }
  90. #define starget_to_tgt(st) \
  91. (is_snic_target(((struct scsi_target *) st)->dev.parent) ? \
  92. dev_to_tgt(st->dev.parent) : NULL)
  93. #define snic_tgt_to_shost(t) \
  94. dev_to_shost(t->dev.parent)
  95. static inline int
  96. snic_tgt_chkready(struct snic_tgt *tgt)
  97. {
  98. if (tgt->state == SNIC_TGT_STAT_ONLINE)
  99. return 0;
  100. else
  101. return DID_NO_CONNECT << 16;
  102. }
  103. const char *snic_tgt_state_to_str(int);
  104. int snic_tgt_scsi_abort_io(struct snic_tgt *);
  105. #endif /* end of __SNIC_DISC_H */