Commit | Line | Data |
---|---|---|
7725ccfd | 1 | /* |
a36c61f9 | 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
7725ccfd JH |
3 | * All rights reserved |
4 | * www.brocade.com | |
5 | * | |
6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License (GPL) Version 2 as | |
10 | * published by the Free Software Foundation | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | */ | |
17 | ||
18 | #ifndef __BFAD_IM_H__ | |
19 | #define __BFAD_IM_H__ | |
20 | ||
a36c61f9 | 21 | #include "bfa_fcs.h" |
7725ccfd JH |
22 | |
23 | #define FCPI_NAME " fcpim" | |
24 | ||
a36c61f9 KG |
25 | #ifndef KOBJ_NAME_LEN |
26 | #define KOBJ_NAME_LEN 20 | |
27 | #endif | |
28 | ||
7725ccfd JH |
29 | bfa_status_t bfad_im_module_init(void); |
30 | void bfad_im_module_exit(void); | |
31 | bfa_status_t bfad_im_probe(struct bfad_s *bfad); | |
32 | void bfad_im_probe_undo(struct bfad_s *bfad); | |
7725ccfd JH |
33 | bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port); |
34 | void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port); | |
7725ccfd JH |
35 | void bfad_im_port_clean(struct bfad_im_port_s *im_port); |
36 | int bfad_im_scsi_host_alloc(struct bfad_s *bfad, | |
b504293f | 37 | struct bfad_im_port_s *im_port, struct device *dev); |
7725ccfd JH |
38 | void bfad_im_scsi_host_free(struct bfad_s *bfad, |
39 | struct bfad_im_port_s *im_port); | |
40 | ||
41 | #define MAX_FCP_TARGET 1024 | |
42 | #define MAX_FCP_LUN 16384 | |
43 | #define BFAD_TARGET_RESET_TMO 60 | |
44 | #define BFAD_LUN_RESET_TMO 60 | |
45 | #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code) | |
46 | #define BFA_QUEUE_FULL_RAMP_UP_TIME 120 | |
7725ccfd JH |
47 | |
48 | /* | |
49 | * itnim flags | |
50 | */ | |
7725ccfd JH |
51 | #define IO_DONE_BIT 0 |
52 | ||
53 | struct bfad_itnim_data_s { | |
54 | struct bfad_itnim_s *itnim; | |
55 | }; | |
56 | ||
57 | struct bfad_im_port_s { | |
58 | struct bfad_s *bfad; | |
59 | struct bfad_port_s *port; | |
60 | struct work_struct port_delete_work; | |
61 | int idr_id; | |
62 | u16 cur_scsi_id; | |
a36c61f9 | 63 | u16 flags; |
7725ccfd JH |
64 | struct list_head binding_list; |
65 | struct Scsi_Host *shost; | |
66 | struct list_head itnim_mapped_list; | |
b504293f | 67 | struct fc_vport *fc_vport; |
7725ccfd JH |
68 | }; |
69 | ||
70 | enum bfad_itnim_state { | |
71 | ITNIM_STATE_NONE, | |
72 | ITNIM_STATE_ONLINE, | |
73 | ITNIM_STATE_OFFLINE_PENDING, | |
74 | ITNIM_STATE_OFFLINE, | |
75 | ITNIM_STATE_TIMEOUT, | |
76 | ITNIM_STATE_FREE, | |
77 | }; | |
78 | ||
79 | /* | |
80 | * Per itnim data structure | |
81 | */ | |
82 | struct bfad_itnim_s { | |
83 | struct list_head list_entry; | |
84 | struct bfa_fcs_itnim_s fcs_itnim; | |
85 | struct work_struct itnim_work; | |
86 | u32 flags; | |
87 | enum bfad_itnim_state state; | |
88 | struct bfad_im_s *im; | |
89 | struct bfad_im_port_s *im_port; | |
90 | struct bfad_rport_s *drv_rport; | |
91 | struct fc_rport *fc_rport; | |
92 | struct bfa_itnim_s *bfa_itnim; | |
93 | u16 scsi_tgt_id; | |
5b7db7af | 94 | u16 channel; |
7725ccfd JH |
95 | u16 queue_work; |
96 | unsigned long last_ramp_up_time; | |
97 | unsigned long last_queue_full_time; | |
98 | }; | |
99 | ||
100 | enum bfad_binding_type { | |
101 | FCP_PWWN_BINDING = 0x1, | |
102 | FCP_NWWN_BINDING = 0x2, | |
103 | FCP_FCID_BINDING = 0x3, | |
104 | }; | |
105 | ||
106 | struct bfad_fcp_binding { | |
107 | struct list_head list_entry; | |
108 | enum bfad_binding_type binding_type; | |
109 | u16 scsi_target_id; | |
110 | u32 fc_id; | |
111 | wwn_t nwwn; | |
112 | wwn_t pwwn; | |
113 | }; | |
114 | ||
115 | struct bfad_im_s { | |
116 | struct bfad_s *bfad; | |
117 | struct workqueue_struct *drv_workq; | |
a36c61f9 | 118 | char drv_workq_name[KOBJ_NAME_LEN]; |
7826f304 | 119 | struct work_struct aen_im_notify_work; |
7725ccfd JH |
120 | }; |
121 | ||
7826f304 KG |
122 | #define bfad_get_aen_entry(_drv, _entry) do { \ |
123 | unsigned long _flags; \ | |
124 | spin_lock_irqsave(&(_drv)->bfad_aen_spinlock, _flags); \ | |
125 | bfa_q_deq(&(_drv)->free_aen_q, &(_entry)); \ | |
126 | if (_entry) \ | |
127 | list_add_tail(&(_entry)->qe, &(_drv)->active_aen_q); \ | |
128 | spin_unlock_irqrestore(&(_drv)->bfad_aen_spinlock, _flags); \ | |
129 | } while (0) | |
130 | ||
131 | /* post fc_host vendor event */ | |
132 | #define bfad_im_post_vendor_event(_entry, _drv, _cnt, _cat, _evt) do { \ | |
133 | do_gettimeofday(&(_entry)->aen_tv); \ | |
134 | (_entry)->bfad_num = (_drv)->inst_no; \ | |
135 | (_entry)->seq_num = (_cnt); \ | |
136 | (_entry)->aen_category = (_cat); \ | |
137 | (_entry)->aen_type = (_evt); \ | |
138 | if ((_drv)->bfad_flags & BFAD_FC4_PROBE_DONE) \ | |
139 | queue_work((_drv)->im->drv_workq, \ | |
140 | &(_drv)->im->aen_im_notify_work); \ | |
141 | } while (0) | |
142 | ||
f16a1750 | 143 | struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, |
7725ccfd | 144 | struct bfad_s *); |
f16a1750 MZ |
145 | bfa_status_t bfad_thread_workq(struct bfad_s *bfad); |
146 | void bfad_destroy_workq(struct bfad_im_s *im); | |
147 | void bfad_fc_host_init(struct bfad_im_port_s *im_port); | |
148 | void bfad_scsi_host_free(struct bfad_s *bfad, | |
7725ccfd | 149 | struct bfad_im_port_s *im_port); |
f16a1750 | 150 | void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim, |
7725ccfd | 151 | struct scsi_device *sdev); |
f16a1750 MZ |
152 | void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev); |
153 | struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id); | |
7725ccfd JH |
154 | |
155 | extern struct scsi_host_template bfad_im_scsi_host_template; | |
156 | extern struct scsi_host_template bfad_im_vport_template; | |
157 | extern struct fc_function_template bfad_im_fc_function_template; | |
b504293f | 158 | extern struct fc_function_template bfad_im_vport_fc_function_template; |
7725ccfd | 159 | extern struct scsi_transport_template *bfad_im_scsi_transport_template; |
b504293f | 160 | extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template; |
7725ccfd | 161 | |
a36c61f9 KG |
162 | extern struct device_attribute *bfad_im_host_attrs[]; |
163 | extern struct device_attribute *bfad_im_vport_attrs[]; | |
164 | ||
165 | irqreturn_t bfad_intx(int irq, void *dev_id); | |
166 | ||
b85daafe KG |
167 | int bfad_im_bsg_request(struct fc_bsg_job *job); |
168 | int bfad_im_bsg_timeout(struct fc_bsg_job *job); | |
169 | ||
5b7db7af KG |
170 | /* |
171 | * Macro to set the SCSI device sdev_bflags - sdev_bflags are used by the | |
172 | * SCSI mid-layer to choose LUN Scanning mode REPORT_LUNS vs. Sequential Scan | |
173 | * | |
174 | * Internally iterate's over all the ITNIM's part of the im_port & set's the | |
175 | * sdev_bflags for the scsi_device associated with LUN #0. | |
176 | */ | |
177 | #define bfad_reset_sdev_bflags(__im_port, __lunmask_cfg) do { \ | |
178 | struct scsi_device *__sdev = NULL; \ | |
179 | struct bfad_itnim_s *__itnim = NULL; \ | |
180 | u32 scan_flags = BLIST_NOREPORTLUN | BLIST_SPARSELUN; \ | |
181 | list_for_each_entry(__itnim, &((__im_port)->itnim_mapped_list), \ | |
182 | list_entry) { \ | |
183 | __sdev = scsi_device_lookup((__im_port)->shost, \ | |
184 | __itnim->channel, \ | |
185 | __itnim->scsi_tgt_id, 0); \ | |
186 | if (__sdev) { \ | |
187 | if ((__lunmask_cfg) == BFA_TRUE) \ | |
188 | __sdev->sdev_bflags |= scan_flags; \ | |
189 | else \ | |
190 | __sdev->sdev_bflags &= ~scan_flags; \ | |
191 | scsi_device_put(__sdev); \ | |
192 | } \ | |
193 | } \ | |
194 | } while (0) | |
195 | ||
7725ccfd | 196 | #endif |