2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
19 #include <log/bfa_log_hal.h>
21 BFA_TRC_FILE(HAL
, FCPIM
);
25 * hal_fcpim_mod BFA FCP Initiator Mode module
29 * Compute and return memory needed by FCP(im) module.
32 bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s
*cfg
, u32
*km_len
,
35 bfa_itnim_meminfo(cfg
, km_len
, dm_len
);
40 if (cfg
->fwcfg
.num_ioim_reqs
< BFA_IOIM_MIN
)
41 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MIN
;
42 else if (cfg
->fwcfg
.num_ioim_reqs
> BFA_IOIM_MAX
)
43 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MAX
;
45 *km_len
+= cfg
->fwcfg
.num_ioim_reqs
*
46 (sizeof(struct bfa_ioim_s
) + sizeof(struct bfa_ioim_sp_s
));
48 *dm_len
+= cfg
->fwcfg
.num_ioim_reqs
* BFI_IOIM_SNSLEN
;
51 * task management command memory
53 if (cfg
->fwcfg
.num_tskim_reqs
< BFA_TSKIM_MIN
)
54 cfg
->fwcfg
.num_tskim_reqs
= BFA_TSKIM_MIN
;
55 *km_len
+= cfg
->fwcfg
.num_tskim_reqs
* sizeof(struct bfa_tskim_s
);
60 bfa_fcpim_attach(struct bfa_s
*bfa
, void *bfad
, struct bfa_iocfc_cfg_s
*cfg
,
61 struct bfa_meminfo_s
*meminfo
, struct bfa_pcidev_s
*pcidev
)
63 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
65 bfa_trc(bfa
, cfg
->drvcfg
.path_tov
);
66 bfa_trc(bfa
, cfg
->fwcfg
.num_rports
);
67 bfa_trc(bfa
, cfg
->fwcfg
.num_ioim_reqs
);
68 bfa_trc(bfa
, cfg
->fwcfg
.num_tskim_reqs
);
71 fcpim
->num_itnims
= cfg
->fwcfg
.num_rports
;
72 fcpim
->num_ioim_reqs
= cfg
->fwcfg
.num_ioim_reqs
;
73 fcpim
->num_tskim_reqs
= cfg
->fwcfg
.num_tskim_reqs
;
74 fcpim
->path_tov
= cfg
->drvcfg
.path_tov
;
75 fcpim
->delay_comp
= cfg
->drvcfg
.delay_comp
;
77 bfa_itnim_attach(fcpim
, meminfo
);
78 bfa_tskim_attach(fcpim
, meminfo
);
79 bfa_ioim_attach(fcpim
, meminfo
);
83 bfa_fcpim_detach(struct bfa_s
*bfa
)
85 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
87 bfa_ioim_detach(fcpim
);
88 bfa_tskim_detach(fcpim
);
92 bfa_fcpim_start(struct bfa_s
*bfa
)
97 bfa_fcpim_stop(struct bfa_s
*bfa
)
102 bfa_fcpim_iocdisable(struct bfa_s
*bfa
)
104 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
105 struct bfa_itnim_s
*itnim
;
106 struct list_head
*qe
, *qen
;
108 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
109 itnim
= (struct bfa_itnim_s
*) qe
;
110 bfa_itnim_iocdisable(itnim
);
115 bfa_fcpim_path_tov_set(struct bfa_s
*bfa
, u16 path_tov
)
117 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
119 fcpim
->path_tov
= path_tov
* 1000;
120 if (fcpim
->path_tov
> BFA_FCPIM_PATHTOV_MAX
)
121 fcpim
->path_tov
= BFA_FCPIM_PATHTOV_MAX
;
125 bfa_fcpim_path_tov_get(struct bfa_s
*bfa
)
127 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
129 return fcpim
->path_tov
/ 1000;
133 bfa_fcpim_get_modstats(struct bfa_s
*bfa
, struct bfa_fcpim_stats_s
*modstats
)
135 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
137 *modstats
= fcpim
->stats
;
139 return BFA_STATUS_OK
;
143 bfa_fcpim_clr_modstats(struct bfa_s
*bfa
)
145 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
147 memset(&fcpim
->stats
, 0, sizeof(struct bfa_fcpim_stats_s
));
149 return BFA_STATUS_OK
;
153 bfa_fcpim_qdepth_set(struct bfa_s
*bfa
, u16 q_depth
)
155 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
157 bfa_assert(q_depth
<= BFA_IOCFC_QDEPTH_MAX
);
159 fcpim
->q_depth
= q_depth
;
163 bfa_fcpim_qdepth_get(struct bfa_s
*bfa
)
165 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
167 return fcpim
->q_depth
;
171 bfa_fcpim_update_ioredirect(struct bfa_s
*bfa
)
173 bfa_boolean_t ioredirect
;
176 * IO redirection is turned off when QoS is enabled and vice versa
178 ioredirect
= bfa_fcport_is_qos_enabled(bfa
) ? BFA_FALSE
: BFA_TRUE
;
181 * Notify the bfad module of a possible state change in
182 * IO redirection capability, due to a QoS state change. bfad will
183 * check on the support for io redirection and update the
184 * fcpim's ioredirect state accordingly.
186 bfa_cb_ioredirect_state_change((void *)(bfa
->bfad
), ioredirect
);
190 bfa_fcpim_set_ioredirect(struct bfa_s
*bfa
, bfa_boolean_t state
)
192 struct bfa_fcpim_mod_s
*fcpim
= BFA_FCPIM_MOD(bfa
);
193 fcpim
->ioredirect
= state
;