^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright 2014 Cisco Systems, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This program is free software; you may redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifndef __SNIC_DISC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define __SNIC_DISC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "snic_fwint.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) enum snic_disc_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) SNIC_DISC_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) SNIC_DISC_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) SNIC_DISC_PENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) SNIC_DISC_DONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct snic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct snic_disc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct list_head tgt_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) enum snic_disc_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u16 disc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u8 req_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u32 nxt_tgt_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u32 rtgt_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) u8 *rtgt_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct delayed_work disc_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void (*cb)(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define SNIC_TGT_NAM_LEN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) enum snic_tgt_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) SNIC_TGT_STAT_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) SNIC_TGT_STAT_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) SNIC_TGT_STAT_ONLINE, /* Target is Online */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) SNIC_TGT_STAT_OFFLINE, /* Target is Offline */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) SNIC_TGT_STAT_DEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct snic_tgt_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) enum snic_tgt_type typ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u16 disc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) char *name[SNIC_TGT_NAM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /*DAS Target specific info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*SAN Target specific info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u8 dummmy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* snic tgt flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define SNIC_TGT_SCAN_PENDING 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct snic_tgt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u16 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u16 channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u32 scsi_tgt_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) enum snic_tgt_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct work_struct scan_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct work_struct del_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct snic_tgt_priv tdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct snic_fw_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) void snic_disc_init(struct snic_disc *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int snic_disc_start(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) void snic_disc_term(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int snic_report_tgt_cmpl_handler(struct snic *, struct snic_fw_req *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int snic_tgtinfo_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) void snic_process_report_tgts_rsp(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) void snic_handle_tgt_disc(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) void snic_handle_disc(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) void snic_tgt_dev_release(struct device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) void snic_tgt_del_all(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define dev_to_tgt(d) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) container_of(d, struct snic_tgt, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) is_snic_target(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return dev->release == snic_tgt_dev_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define starget_to_tgt(st) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) (is_snic_target(((struct scsi_target *) st)->dev.parent) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dev_to_tgt(st->dev.parent) : NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define snic_tgt_to_shost(t) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) dev_to_shost(t->dev.parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) snic_tgt_chkready(struct snic_tgt *tgt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (tgt->state == SNIC_TGT_STAT_ONLINE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) const char *snic_tgt_state_to_str(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int snic_tgt_scsi_abort_io(struct snic_tgt *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #endif /* end of __SNIC_DISC_H */