blob: e93921dec3478a3b5d68e30943b34cc55f41d3cc [file] [log] [blame]
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001/*
Anil Gurumurthy889d0d42015-11-26 03:54:45 -05002 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
3 * Copyright (c) 2014- QLogic Corporation.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07004 * All rights reserved
Anil Gurumurthy889d0d42015-11-26 03:54:45 -05005 * www.qlogic.com
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07006 *
Anil Gurumurthy31e1d562015-11-26 03:54:46 -05007 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07008 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License (GPL) Version 2 as
11 * published by the Free Software Foundation
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
19#ifndef __BFA_FCPIM_H__
20#define __BFA_FCPIM_H__
21
22#include "bfa.h"
23#include "bfa_svc.h"
24#include "bfi_ms.h"
25#include "bfa_defs_svc.h"
26#include "bfa_cs.h"
27
Krishna Gudipatie2187d72011-06-13 15:53:58 -070028/* FCP module related definitions */
Krishna Gudipati45070252011-06-24 20:24:29 -070029#define BFA_IO_MAX BFI_IO_MAX
30#define BFA_FWTIO_MAX 2000
Krishna Gudipatie2187d72011-06-13 15:53:58 -070031
32struct bfa_fcp_mod_s;
33struct bfa_iotag_s {
34 struct list_head qe; /* queue element */
35 u16 tag; /* FW IO tag */
36};
37
38struct bfa_itn_s {
39 bfa_isr_func_t isr;
40};
41
42void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
43 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
44void bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m);
Krishna Gudipati45070252011-06-24 20:24:29 -070045void bfa_iotag_attach(struct bfa_fcp_mod_s *fcp);
Krishna Gudipati7ace27a2012-09-21 17:26:41 -070046void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw, u16 max_ioim_fw);
Krishna Gudipatie2187d72011-06-13 15:53:58 -070047
48#define BFA_FCP_MOD(_hal) (&(_hal)->modules.fcp_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -070049#define BFA_MEM_FCP_KVA(__bfa) (&(BFA_FCP_MOD(__bfa)->kva_seg))
Krishna Gudipatie2187d72011-06-13 15:53:58 -070050#define BFA_IOTAG_FROM_TAG(_fcp, _tag) \
51 (&(_fcp)->iotag_arr[(_tag & BFA_IOIM_IOTAG_MASK)])
52#define BFA_ITN_FROM_TAG(_fcp, _tag) \
53 ((_fcp)->itn_arr + ((_tag) & ((_fcp)->num_itns - 1)))
54#define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \
Krishna Gudipati1306e312012-09-21 17:25:30 -070055 bfa_mem_get_dmabuf_kva(_fcp, (_tag & BFA_IOIM_IOTAG_MASK), \
56 BFI_IOIM_SNSLEN)
57
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070058
59#define BFA_ITNIM_MIN 32
60#define BFA_ITNIM_MAX 1024
61
62#define BFA_IOIM_MIN 8
63#define BFA_IOIM_MAX 2000
64
65#define BFA_TSKIM_MIN 4
66#define BFA_TSKIM_MAX 512
67#define BFA_FCPIM_PATHTOV_DEF (30 * 1000) /* in millisecs */
68#define BFA_FCPIM_PATHTOV_MAX (90 * 1000) /* in millisecs */
69
70
71#define bfa_itnim_ioprofile_update(__itnim, __index) \
72 (__itnim->ioprofile.iocomps[__index]++)
73
74#define BFA_IOIM_RETRY_TAG_OFFSET 11
Krishna Gudipati15821f02010-12-13 16:23:27 -080075#define BFA_IOIM_IOTAG_MASK 0x07ff /* 2K IOs */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070076#define BFA_IOIM_RETRY_MAX 7
77
78/* Buckets are are 512 bytes to 2MB */
79static inline u32
80bfa_ioim_get_index(u32 n) {
81 int pos = 0;
82 if (n >= (1UL)<<22)
83 return BFA_IOBUCKET_MAX - 1;
84 n >>= 8;
Krishna Gudipati42a8e6e2011-07-20 17:01:52 -070085 if (n >= (1UL)<<16) {
86 n >>= 16;
87 pos += 16;
88 }
89 if (n >= 1 << 8) {
90 n >>= 8;
91 pos += 8;
92 }
93 if (n >= 1 << 4) {
94 n >>= 4;
95 pos += 4;
96 }
97 if (n >= 1 << 2) {
98 n >>= 2;
99 pos += 2;
100 }
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700101 if (n >= 1 << 1)
102 pos += 1;
103
104 return (n == 0) ? (0) : pos;
105}
106
107/*
108 * forward declarations
109 */
110struct bfa_ioim_s;
111struct bfa_tskim_s;
112struct bfad_ioim_s;
113struct bfad_tskim_s;
114
115typedef void (*bfa_fcpim_profile_t) (struct bfa_ioim_s *ioim);
116
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700117struct bfa_fcpim_s {
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700118 struct bfa_s *bfa;
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700119 struct bfa_fcp_mod_s *fcp;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700120 struct bfa_itnim_s *itnim_arr;
121 struct bfa_ioim_s *ioim_arr;
122 struct bfa_ioim_sp_s *ioim_sp_arr;
123 struct bfa_tskim_s *tskim_arr;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700124 int num_itnims;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700125 int num_tskim_reqs;
126 u32 path_tov;
127 u16 q_depth;
128 u8 reqq; /* Request queue to be used */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700129 struct list_head itnim_q; /* queue of active itnim */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700130 struct list_head ioim_resfree_q; /* IOs waiting for f/w */
131 struct list_head ioim_comp_q; /* IO global comp Q */
132 struct list_head tskim_free_q;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700133 struct list_head tskim_unused_q; /* Unused tskim Q */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800134 u32 ios_active; /* current active IOs */
135 u32 delay_comp;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700136 struct bfa_fcpim_del_itn_stats_s del_itn_stats;
137 bfa_boolean_t ioredirect;
138 bfa_boolean_t io_profile;
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800139 u32 io_profile_start_time;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700140 bfa_fcpim_profile_t profile_comp;
141 bfa_fcpim_profile_t profile_start;
142};
143
Krishna Gudipati45070252011-06-24 20:24:29 -0700144/* Max FCP dma segs required */
145#define BFA_FCP_DMA_SEGS BFI_IOIM_SNSBUF_SEGS
146
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700147struct bfa_fcp_mod_s {
148 struct bfa_s *bfa;
149 struct list_head iotag_ioim_free_q; /* free IO resources */
150 struct list_head iotag_tio_free_q; /* free IO resources */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700151 struct list_head iotag_unused_q; /* unused IO resources*/
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700152 struct bfa_iotag_s *iotag_arr;
153 struct bfa_itn_s *itn_arr;
Krishna Gudipati7ace27a2012-09-21 17:26:41 -0700154 int max_ioim_reqs;
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700155 int num_ioim_reqs;
156 int num_fwtio_reqs;
157 int num_itns;
Krishna Gudipati45070252011-06-24 20:24:29 -0700158 struct bfa_dma_s snsbase[BFA_FCP_DMA_SEGS];
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700159 struct bfa_fcpim_s fcpim;
Krishna Gudipati45070252011-06-24 20:24:29 -0700160 struct bfa_mem_dma_s dma_seg[BFA_FCP_DMA_SEGS];
161 struct bfa_mem_kva_s kva_seg;
Krishna Gudipati7ace27a2012-09-21 17:26:41 -0700162 int throttle_update_required;
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700163};
164
Jing Huangacdc79a2010-10-18 17:15:55 -0700165/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700166 * BFA IO (initiator mode)
167 */
168struct bfa_ioim_s {
169 struct list_head qe; /* queue elememt */
170 bfa_sm_t sm; /* BFA ioim state machine */
171 struct bfa_s *bfa; /* BFA module */
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700172 struct bfa_fcpim_s *fcpim; /* parent fcpim module */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700173 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
174 struct bfad_ioim_s *dio; /* driver IO handle */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800175 u16 iotag; /* FWI IO tag */
176 u16 abort_tag; /* unqiue abort request tag */
177 u16 nsges; /* number of SG elements */
178 u16 nsgpgs; /* number of SG pages */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700179 struct bfa_sgpg_s *sgpg; /* first SG page */
180 struct list_head sgpg_q; /* allocated SG pages */
181 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
182 bfa_cb_cbfn_t io_cbfn; /* IO completion handler */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800183 struct bfa_ioim_sp_s *iosp; /* slow-path IO handling */
184 u8 reqq; /* Request queue for I/O */
Krishna Gudipati83763d52011-07-20 17:04:03 -0700185 u8 mode; /* IO is passthrough or not */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800186 u64 start_time; /* IO's Profile start val */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700187};
188
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700189struct bfa_ioim_sp_s {
190 struct bfi_msg_s comp_rspmsg; /* IO comp f/w response */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800191 struct bfa_sgpg_wqe_s sgpg_wqe; /* waitq elem for sgpg */
192 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700193 bfa_boolean_t abort_explicit; /* aborted by OS */
194 struct bfa_tskim_s *tskim; /* Relevant TM cmd */
195};
196
Jing Huangacdc79a2010-10-18 17:15:55 -0700197/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700198 * BFA Task management command (initiator mode)
199 */
200struct bfa_tskim_s {
201 struct list_head qe;
202 bfa_sm_t sm;
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800203 struct bfa_s *bfa; /* BFA module */
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700204 struct bfa_fcpim_s *fcpim; /* parent fcpim module */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700205 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
Maggie Zhangf3148782010-12-09 19:11:39 -0800206 struct bfad_tskim_s *dtsk; /* driver task mgmt cmnd */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800207 bfa_boolean_t notify; /* notify itnim on TM comp */
Maggie Zhangf3148782010-12-09 19:11:39 -0800208 struct scsi_lun lun; /* lun if applicable */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800209 enum fcp_tm_cmnd tm_cmnd; /* task management command */
210 u16 tsk_tag; /* FWI IO tag */
211 u8 tsecs; /* timeout in seconds */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700212 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
213 struct list_head io_q; /* queue of affected IOs */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800214 struct bfa_wc_s wc; /* waiting counter */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700215 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
216 enum bfi_tskim_status tsk_status; /* TM status */
217};
218
Jing Huangacdc79a2010-10-18 17:15:55 -0700219/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700220 * BFA i-t-n (initiator mode)
221 */
222struct bfa_itnim_s {
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800223 struct list_head qe; /* queue element */
224 bfa_sm_t sm; /* i-t-n im BFA state machine */
225 struct bfa_s *bfa; /* bfa instance */
226 struct bfa_rport_s *rport; /* bfa rport */
227 void *ditn; /* driver i-t-n structure */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700228 struct bfi_mhdr_s mhdr; /* pre-built mhdr */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800229 u8 msg_no; /* itnim/rport firmware handle */
230 u8 reqq; /* CQ for requests */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700231 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
232 struct list_head pending_q; /* queue of pending IO requests */
233 struct list_head io_q; /* queue of active IO requests */
234 struct list_head io_cleanup_q; /* IO being cleaned up */
235 struct list_head tsk_q; /* queue of active TM commands */
236 struct list_head delay_comp_q; /* queue of failed inflight cmds */
237 bfa_boolean_t seq_rec; /* SQER supported */
238 bfa_boolean_t is_online; /* itnim is ONLINE for IO */
239 bfa_boolean_t iotov_active; /* IO TOV timer is active */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800240 struct bfa_wc_s wc; /* waiting counter */
241 struct bfa_timer_s timer; /* pending IO TOV */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700242 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700243 struct bfa_fcpim_s *fcpim; /* fcpim module */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700244 struct bfa_itnim_iostats_s stats;
245 struct bfa_itnim_ioprofile_s ioprofile;
246};
247
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700248#define bfa_itnim_is_online(_itnim) ((_itnim)->is_online)
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700249#define BFA_FCPIM(_hal) (&(_hal)->modules.fcp_mod.fcpim)
Krishna Gudipati15821f02010-12-13 16:23:27 -0800250#define BFA_IOIM_TAG_2_ID(_iotag) ((_iotag) & BFA_IOIM_IOTAG_MASK)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700251#define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \
Krishna Gudipati15821f02010-12-13 16:23:27 -0800252 (&fcpim->ioim_arr[(_iotag & BFA_IOIM_IOTAG_MASK)])
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700253#define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \
254 (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)])
255
256#define bfa_io_profile_start_time(_bfa) \
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700257 ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700258#define bfa_fcpim_get_io_profile(_bfa) \
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700259 ((_bfa)->modules.fcp_mod.fcpim.io_profile)
Krishna Gudipati15821f02010-12-13 16:23:27 -0800260#define bfa_ioim_update_iotag(__ioim) do { \
261 uint16_t k = (__ioim)->iotag >> BFA_IOIM_RETRY_TAG_OFFSET; \
262 k++; (__ioim)->iotag &= BFA_IOIM_IOTAG_MASK; \
263 (__ioim)->iotag |= k << BFA_IOIM_RETRY_TAG_OFFSET; \
264} while (0)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700265
266static inline bfa_boolean_t
Krishna Gudipati15821f02010-12-13 16:23:27 -0800267bfa_ioim_maxretry_reached(struct bfa_ioim_s *ioim)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700268{
Krishna Gudipati15821f02010-12-13 16:23:27 -0800269 uint16_t k = ioim->iotag >> BFA_IOIM_RETRY_TAG_OFFSET;
270 if (k < BFA_IOIM_RETRY_MAX)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700271 return BFA_FALSE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700272 return BFA_TRUE;
273}
Krishna Gudipati15821f02010-12-13 16:23:27 -0800274
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700275/*
276 * function prototypes
277 */
Krishna Gudipati45070252011-06-24 20:24:29 -0700278void bfa_ioim_attach(struct bfa_fcpim_s *fcpim);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700279void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
280void bfa_ioim_good_comp_isr(struct bfa_s *bfa,
281 struct bfi_msg_s *msg);
282void bfa_ioim_cleanup(struct bfa_ioim_s *ioim);
283void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim,
284 struct bfa_tskim_s *tskim);
285void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim);
286void bfa_ioim_tov(struct bfa_ioim_s *ioim);
287
Krishna Gudipati45070252011-06-24 20:24:29 -0700288void bfa_tskim_attach(struct bfa_fcpim_s *fcpim);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700289void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
290void bfa_tskim_iodone(struct bfa_tskim_s *tskim);
291void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim);
292void bfa_tskim_cleanup(struct bfa_tskim_s *tskim);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700293void bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700294
Krishna Gudipati45070252011-06-24 20:24:29 -0700295void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len);
296void bfa_itnim_attach(struct bfa_fcpim_s *fcpim);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700297void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim);
298void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
299void bfa_itnim_iodone(struct bfa_itnim_s *itnim);
300void bfa_itnim_tskdone(struct bfa_itnim_s *itnim);
301bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700302
303/*
304 * bfa fcpim module API functions
305 */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800306void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700307u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700308u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa);
Krishna Gudipati60138062011-06-24 20:25:15 -0700309bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa,
310 struct bfa_itnim_iostats_s *stats, u8 lp_tag);
311void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats,
312 struct bfa_itnim_iostats_s *itnim_stats);
Krishna Gudipati42a8e6e2011-07-20 17:01:52 -0700313bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time);
314bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa);
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800315
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700316#define bfa_fcpim_ioredirect_enabled(__bfa) \
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700317 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700318
319#define bfa_fcpim_get_next_reqq(__bfa, __qid) \
320{ \
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700321 struct bfa_fcpim_s *__fcpim = BFA_FCPIM(__bfa); \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700322 __fcpim->reqq++; \
323 __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \
324 *(__qid) = __fcpim->reqq; \
325}
326
327#define bfa_iocfc_map_msg_to_qid(__msg, __qid) \
328 *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1));
329/*
330 * bfa itnim API functions
331 */
332struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa,
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800333 struct bfa_rport_s *rport, void *itnim);
334void bfa_itnim_delete(struct bfa_itnim_s *itnim);
335void bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec);
336void bfa_itnim_offline(struct bfa_itnim_s *itnim);
337void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim);
338bfa_status_t bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
339 struct bfa_itnim_ioprofile_s *ioprofile);
340
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700341#define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq)
342
Jing Huangacdc79a2010-10-18 17:15:55 -0700343/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800344 * BFA completion callback for bfa_itnim_online().
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700345 */
346void bfa_cb_itnim_online(void *itnim);
347
Jing Huangacdc79a2010-10-18 17:15:55 -0700348/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800349 * BFA completion callback for bfa_itnim_offline().
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700350 */
351void bfa_cb_itnim_offline(void *itnim);
352void bfa_cb_itnim_tov_begin(void *itnim);
353void bfa_cb_itnim_tov(void *itnim);
354
Jing Huangacdc79a2010-10-18 17:15:55 -0700355/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800356 * BFA notification to FCS/driver for second level error recovery.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700357 * Atleast one I/O request has timedout and target is unresponsive to
358 * repeated abort requests. Second level error recovery should be initiated
359 * by starting implicit logout and recovery procedures.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700360 */
361void bfa_cb_itnim_sler(void *itnim);
362
363/*
364 * bfa ioim API functions
365 */
366struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa,
367 struct bfad_ioim_s *dio,
368 struct bfa_itnim_s *itnim,
369 u16 nsgles);
370
371void bfa_ioim_free(struct bfa_ioim_s *ioim);
372void bfa_ioim_start(struct bfa_ioim_s *ioim);
373bfa_status_t bfa_ioim_abort(struct bfa_ioim_s *ioim);
374void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim,
375 bfa_boolean_t iotov);
Jing Huangacdc79a2010-10-18 17:15:55 -0700376/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800377 * I/O completion notification.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700378 *
379 * @param[in] dio driver IO structure
380 * @param[in] io_status IO completion status
381 * @param[in] scsi_status SCSI status returned by target
382 * @param[in] sns_len SCSI sense length, 0 if none
383 * @param[in] sns_info SCSI sense data, if any
384 * @param[in] residue Residual length
385 *
386 * @return None
387 */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800388void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio,
389 enum bfi_ioim_status io_status,
390 u8 scsi_status, int sns_len,
391 u8 *sns_info, s32 residue);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700392
Jing Huangacdc79a2010-10-18 17:15:55 -0700393/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800394 * I/O good completion notification.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700395 */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800396void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700397
Jing Huangacdc79a2010-10-18 17:15:55 -0700398/*
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800399 * I/O abort completion notification
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700400 */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800401void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700402
403/*
404 * bfa tskim API functions
405 */
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800406struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa,
407 struct bfad_tskim_s *dtsk);
408void bfa_tskim_free(struct bfa_tskim_s *tskim);
409void bfa_tskim_start(struct bfa_tskim_s *tskim,
410 struct bfa_itnim_s *itnim, struct scsi_lun lun,
411 enum fcp_tm_cmnd tm, u8 t_secs);
412void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
413 enum bfi_tskim_status tsk_status);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700414
Krishna Gudipati83763d52011-07-20 17:04:03 -0700415void bfa_fcpim_lunmask_rp_update(struct bfa_s *bfa, wwn_t lp_wwn,
416 wwn_t rp_wwn, u16 rp_tag, u8 lp_tag);
Krishna Gudipati4c5d22b2011-07-20 17:04:24 -0700417bfa_status_t bfa_fcpim_lunmask_update(struct bfa_s *bfa, u32 on_off);
418bfa_status_t bfa_fcpim_lunmask_query(struct bfa_s *bfa, void *buf);
419bfa_status_t bfa_fcpim_lunmask_delete(struct bfa_s *bfa, u16 vf_id,
420 wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun);
421bfa_status_t bfa_fcpim_lunmask_add(struct bfa_s *bfa, u16 vf_id,
422 wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun);
423bfa_status_t bfa_fcpim_lunmask_clear(struct bfa_s *bfa);
Krishna Gudipati7ace27a2012-09-21 17:26:41 -0700424u16 bfa_fcpim_read_throttle(struct bfa_s *bfa);
425bfa_status_t bfa_fcpim_write_throttle(struct bfa_s *bfa, u16 value);
426bfa_status_t bfa_fcpim_throttle_set(struct bfa_s *bfa, u16 value);
427bfa_status_t bfa_fcpim_throttle_get(struct bfa_s *bfa, void *buf);
428u16 bfa_fcpim_get_throttle_cfg(struct bfa_s *bfa, u16 drv_cfg_param);
Krishna Gudipati83763d52011-07-20 17:04:03 -0700429
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700430#endif /* __BFA_FCPIM_H__ */