1/* 2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 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 __BFA_FCPIM_H__ 19#define __BFA_FCPIM_H__ 20 21#include <bfa.h> 22#include <bfa_svc.h> 23#include <bfi/bfi_fcpim.h> 24#include <defs/bfa_defs_fcpim.h> 25 26/* 27 * forward declarations 28 */ 29struct bfa_itnim_s; 30struct bfa_ioim_s; 31struct bfa_tskim_s; 32struct bfad_ioim_s; 33struct bfad_tskim_s; 34 35/* 36 * bfa fcpim module API functions 37 */ 38void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov); 39u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa); 40void bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth); 41u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa); 42bfa_status_t bfa_fcpim_get_modstats(struct bfa_s *bfa, 43 struct bfa_fcpim_stats_s *modstats); 44bfa_status_t bfa_fcpim_clr_modstats(struct bfa_s *bfa); 45void bfa_fcpim_set_ioredirect(struct bfa_s *bfa, bfa_boolean_t state); 46void bfa_fcpim_update_ioredirect(struct bfa_s *bfa); 47void bfa_cb_ioredirect_state_change(void *hcb_bfad, bfa_boolean_t ioredirect); 48 49#define bfa_fcpim_ioredirect_enabled(__bfa) \ 50 (((struct bfa_fcpim_mod_s *)(BFA_FCPIM_MOD(__bfa)))->ioredirect) 51 52#define bfa_fcpim_get_next_reqq(__bfa, __qid) \ 53{ \ 54 struct bfa_fcpim_mod_s *__fcpim = BFA_FCPIM_MOD(__bfa); \ 55 __fcpim->reqq++; \ 56 __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \ 57 *(__qid) = __fcpim->reqq; \ 58} 59 60#define bfa_iocfc_map_msg_to_qid(__msg, __qid) \ 61 *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1)); 62 63 64/* 65 * bfa itnim API functions 66 */ 67struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa, 68 struct bfa_rport_s *rport, void *itnim); 69void bfa_itnim_delete(struct bfa_itnim_s *itnim); 70void bfa_itnim_online(struct bfa_itnim_s *itnim, 71 bfa_boolean_t seq_rec); 72void bfa_itnim_offline(struct bfa_itnim_s *itnim); 73void bfa_itnim_get_stats(struct bfa_itnim_s *itnim, 74 struct bfa_itnim_hal_stats_s *stats); 75void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim); 76 77#define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq) 78 79/** 80 * BFA completion callback for bfa_itnim_online(). 81 * 82 * @param[in] itnim FCS or driver itnim instance 83 * 84 * return None 85 */ 86void bfa_cb_itnim_online(void *itnim); 87 88/** 89 * BFA completion callback for bfa_itnim_offline(). 90 * 91 * @param[in] itnim FCS or driver itnim instance 92 * 93 * return None 94 */ 95void bfa_cb_itnim_offline(void *itnim); 96void bfa_cb_itnim_tov_begin(void *itnim); 97void bfa_cb_itnim_tov(void *itnim); 98 99/** 100 * BFA notification to FCS/driver for second level error recovery. 101 * 102 * Atleast one I/O request has timedout and target is unresponsive to 103 * repeated abort requests. Second level error recovery should be initiated 104 * by starting implicit logout and recovery procedures. 105 * 106 * @param[in] itnim FCS or driver itnim instance 107 * 108 * return None 109 */ 110void bfa_cb_itnim_sler(void *itnim); 111 112/* 113 * bfa ioim API functions 114 */ 115struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa, 116 struct bfad_ioim_s *dio, 117 struct bfa_itnim_s *itnim, 118 u16 nsgles); 119 120void bfa_ioim_free(struct bfa_ioim_s *ioim); 121void bfa_ioim_start(struct bfa_ioim_s *ioim); 122void bfa_ioim_abort(struct bfa_ioim_s *ioim); 123void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, 124 bfa_boolean_t iotov); 125 126 127/** 128 * I/O completion notification. 129 * 130 * @param[in] dio driver IO structure 131 * @param[in] io_status IO completion status 132 * @param[in] scsi_status SCSI status returned by target 133 * @param[in] sns_len SCSI sense length, 0 if none 134 * @param[in] sns_info SCSI sense data, if any 135 * @param[in] residue Residual length 136 * 137 * @return None 138 */ 139void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio, 140 enum bfi_ioim_status io_status, 141 u8 scsi_status, int sns_len, 142 u8 *sns_info, s32 residue); 143 144/** 145 * I/O good completion notification. 146 * 147 * @param[in] dio driver IO structure 148 * 149 * @return None 150 */ 151void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio); 152 153/** 154 * I/O abort completion notification 155 * 156 * @param[in] dio driver IO that was aborted 157 * 158 * @return None 159 */ 160void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio); 161void bfa_cb_ioim_resfree(void *hcb_bfad); 162 163void bfa_cb_ioim_resfree(void *hcb_bfad); 164 165/* 166 * bfa tskim API functions 167 */ 168struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa, 169 struct bfad_tskim_s *dtsk); 170void bfa_tskim_free(struct bfa_tskim_s *tskim); 171void bfa_tskim_start(struct bfa_tskim_s *tskim, 172 struct bfa_itnim_s *itnim, lun_t lun, 173 enum fcp_tm_cmnd tm, u8 t_secs); 174void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, 175 enum bfi_tskim_status tsk_status); 176 177#endif /* __BFA_FCPIM_H__ */ 178