root/drivers/scsi/snic/snic_disc.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. is_snic_target
  2. snic_tgt_chkready

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

/* [<][>][^][v][top][bottom][index][help] */