snic_disc.h (3050B)
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 23enum snic_disc_state { 24 SNIC_DISC_NONE, 25 SNIC_DISC_INIT, 26 SNIC_DISC_PENDING, 27 SNIC_DISC_DONE 28}; 29 30struct snic; 31struct 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 46enum 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 54struct 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 70struct 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 84struct snic_fw_req; 85 86void snic_disc_init(struct snic_disc *); 87int snic_disc_start(struct snic *); 88void snic_disc_term(struct snic *); 89int snic_report_tgt_cmpl_handler(struct snic *, struct snic_fw_req *); 90int snic_tgtinfo_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq); 91void snic_process_report_tgts_rsp(struct work_struct *); 92void snic_handle_tgt_disc(struct work_struct *); 93void snic_handle_disc(struct work_struct *); 94void snic_tgt_dev_release(struct device *); 95void snic_tgt_del_all(struct snic *); 96 97#define dev_to_tgt(d) \ 98 container_of(d, struct snic_tgt, dev) 99 100static inline int 101is_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 113static inline int 114snic_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 122const char *snic_tgt_state_to_str(int); 123int snic_tgt_scsi_abort_io(struct snic_tgt *); 124#endif /* end of __SNIC_DISC_H */