Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright 2014 Cisco Systems, Inc.  All rights reserved. */
0003 
0004 #ifndef __SNIC_DISC_H
0005 #define __SNIC_DISC_H
0006 
0007 #include "snic_fwint.h"
0008 
0009 enum snic_disc_state {
0010     SNIC_DISC_NONE,
0011     SNIC_DISC_INIT,
0012     SNIC_DISC_PENDING,
0013     SNIC_DISC_DONE
0014 };
0015 
0016 struct snic;
0017 struct snic_disc {
0018     struct list_head tgt_list;
0019     enum snic_disc_state state;
0020     struct mutex mutex;
0021     u16 disc_id;
0022     u8  req_cnt;
0023     u32 nxt_tgt_id;
0024     u32 rtgt_cnt;
0025     u8  *rtgt_info;
0026     struct delayed_work disc_timeout;
0027     void (*cb)(struct snic *);
0028 };
0029 
0030 #define SNIC_TGT_NAM_LEN    16
0031 
0032 enum snic_tgt_state {
0033     SNIC_TGT_STAT_NONE,
0034     SNIC_TGT_STAT_INIT,
0035     SNIC_TGT_STAT_ONLINE,   /* Target is Online */
0036     SNIC_TGT_STAT_OFFLINE,  /* Target is Offline */
0037     SNIC_TGT_STAT_DEL,
0038 };
0039 
0040 struct snic_tgt_priv {
0041     struct list_head list;
0042     enum snic_tgt_type typ;
0043     u16 disc_id;
0044     char *name[SNIC_TGT_NAM_LEN];
0045 
0046     union {
0047         /*DAS Target specific info */
0048         /*SAN Target specific info */
0049         u8 dummmy;
0050     } u;
0051 };
0052 
0053 /* snic tgt flags */
0054 #define SNIC_TGT_SCAN_PENDING   0x01
0055 
0056 struct snic_tgt {
0057     struct list_head list;
0058     u16 id;
0059     u16 channel;
0060     u32 flags;
0061     u32 scsi_tgt_id;
0062     enum snic_tgt_state state;
0063     struct device dev;
0064     struct work_struct scan_work;
0065     struct work_struct del_work;
0066     struct snic_tgt_priv tdata;
0067 };
0068 
0069 
0070 struct snic_fw_req;
0071 
0072 void snic_disc_init(struct snic_disc *);
0073 int snic_disc_start(struct snic *);
0074 void snic_disc_term(struct snic *);
0075 int snic_report_tgt_cmpl_handler(struct snic *, struct snic_fw_req *);
0076 int snic_tgtinfo_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq);
0077 void snic_process_report_tgts_rsp(struct work_struct *);
0078 void snic_handle_tgt_disc(struct work_struct *);
0079 void snic_handle_disc(struct work_struct *);
0080 void snic_tgt_dev_release(struct device *);
0081 void snic_tgt_del_all(struct snic *);
0082 
0083 #define dev_to_tgt(d) \
0084     container_of(d, struct snic_tgt, dev)
0085 
0086 static inline int
0087 is_snic_target(struct device *dev)
0088 {
0089     return dev->release == snic_tgt_dev_release;
0090 }
0091 
0092 #define starget_to_tgt(st)  \
0093     (is_snic_target(((struct scsi_target *) st)->dev.parent) ? \
0094         dev_to_tgt(st->dev.parent) : NULL)
0095 
0096 #define snic_tgt_to_shost(t)    \
0097     dev_to_shost(t->dev.parent)
0098 
0099 static inline int
0100 snic_tgt_chkready(struct snic_tgt *tgt)
0101 {
0102     if (tgt->state == SNIC_TGT_STAT_ONLINE)
0103         return 0;
0104     else
0105         return DID_NO_CONNECT << 16;
0106 }
0107 
0108 const char *snic_tgt_state_to_str(int);
0109 int snic_tgt_scsi_abort_io(struct snic_tgt *);
0110 #endif /* end of  __SNIC_DISC_H */