snic_disc.h 2.3 KB

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