Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 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 | */ |
| 29 | struct bfa_itnim_s; |
| 30 | struct bfa_ioim_s; |
| 31 | struct bfa_tskim_s; |
| 32 | struct bfad_ioim_s; |
| 33 | struct bfad_tskim_s; |
| 34 | |
| 35 | /* |
| 36 | * bfa fcpim module API functions |
| 37 | */ |
| 38 | void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov); |
| 39 | u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa); |
| 40 | void bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth); |
| 41 | u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa); |
| 42 | bfa_status_t bfa_fcpim_get_modstats(struct bfa_s *bfa, |
| 43 | struct bfa_fcpim_stats_s *modstats); |
| 44 | bfa_status_t bfa_fcpim_clr_modstats(struct bfa_s *bfa); |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 45 | void bfa_fcpim_set_ioredirect(struct bfa_s *bfa, bfa_boolean_t state); |
| 46 | void bfa_fcpim_update_ioredirect(struct bfa_s *bfa); |
| 47 | void 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 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * bfa itnim API functions |
| 66 | */ |
| 67 | struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa, |
| 68 | struct bfa_rport_s *rport, void *itnim); |
| 69 | void bfa_itnim_delete(struct bfa_itnim_s *itnim); |
| 70 | void bfa_itnim_online(struct bfa_itnim_s *itnim, |
| 71 | bfa_boolean_t seq_rec); |
| 72 | void bfa_itnim_offline(struct bfa_itnim_s *itnim); |
| 73 | void bfa_itnim_get_stats(struct bfa_itnim_s *itnim, |
| 74 | struct bfa_itnim_hal_stats_s *stats); |
| 75 | void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim); |
| 76 | |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 77 | #define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 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 | */ |
| 86 | void 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 | */ |
| 95 | void bfa_cb_itnim_offline(void *itnim); |
| 96 | void bfa_cb_itnim_tov_begin(void *itnim); |
| 97 | void 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 | */ |
| 110 | void bfa_cb_itnim_sler(void *itnim); |
| 111 | |
| 112 | /* |
| 113 | * bfa ioim API functions |
| 114 | */ |
| 115 | struct 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 | |
| 120 | void bfa_ioim_free(struct bfa_ioim_s *ioim); |
| 121 | void bfa_ioim_start(struct bfa_ioim_s *ioim); |
| 122 | void bfa_ioim_abort(struct bfa_ioim_s *ioim); |
| 123 | void 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 | */ |
| 139 | void 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 | */ |
| 151 | void 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 | */ |
| 160 | void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio); |
| 161 | void bfa_cb_ioim_resfree(void *hcb_bfad); |
| 162 | |
| 163 | void bfa_cb_ioim_resfree(void *hcb_bfad); |
| 164 | |
| 165 | /* |
| 166 | * bfa tskim API functions |
| 167 | */ |
| 168 | struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa, |
| 169 | struct bfad_tskim_s *dtsk); |
| 170 | void bfa_tskim_free(struct bfa_tskim_s *tskim); |
| 171 | void 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); |
| 174 | void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, |
| 175 | enum bfi_tskim_status tsk_status); |
| 176 | |
| 177 | #endif /* __BFA_FCPIM_H__ */ |