aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfa_fcpim.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bfa/bfa_fcpim.c')
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.c175
1 files changed, 175 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
new file mode 100644
index 000000000000..401babe3494e
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -0,0 +1,175 @@
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#include <bfa.h>
19#include <log/bfa_log_hal.h>
20
21BFA_TRC_FILE(HAL, FCPIM);
22BFA_MODULE(fcpim);
23
24/**
25 * hal_fcpim_mod BFA FCP Initiator Mode module
26 */
27
28/**
29 * Compute and return memory needed by FCP(im) module.
30 */
31static void
32bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
33 u32 *dm_len)
34{
35 bfa_itnim_meminfo(cfg, km_len, dm_len);
36
37 /**
38 * IO memory
39 */
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;
44
45 *km_len += cfg->fwcfg.num_ioim_reqs *
46 (sizeof(struct bfa_ioim_s) + sizeof(struct bfa_ioim_sp_s));
47
48 *dm_len += cfg->fwcfg.num_ioim_reqs * BFI_IOIM_SNSLEN;
49
50 /**
51 * task management command memory
52 */
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);
56}
57
58
59static void
60bfa_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)
62{
63 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
64
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);
69
70 fcpim->bfa = bfa;
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;
76
77 bfa_itnim_attach(fcpim, meminfo);
78 bfa_tskim_attach(fcpim, meminfo);
79 bfa_ioim_attach(fcpim, meminfo);
80}
81
82static void
83bfa_fcpim_initdone(struct bfa_s *bfa)
84{
85}
86
87static void
88bfa_fcpim_detach(struct bfa_s *bfa)
89{
90 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
91
92 bfa_ioim_detach(fcpim);
93 bfa_tskim_detach(fcpim);
94}
95
96static void
97bfa_fcpim_start(struct bfa_s *bfa)
98{
99}
100
101static void
102bfa_fcpim_stop(struct bfa_s *bfa)
103{
104}
105
106static void
107bfa_fcpim_iocdisable(struct bfa_s *bfa)
108{
109 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
110 struct bfa_itnim_s *itnim;
111 struct list_head *qe, *qen;
112
113 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
114 itnim = (struct bfa_itnim_s *) qe;
115 bfa_itnim_iocdisable(itnim);
116 }
117}
118
119void
120bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
121{
122 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
123
124 fcpim->path_tov = path_tov * 1000;
125 if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
126 fcpim->path_tov = BFA_FCPIM_PATHTOV_MAX;
127}
128
129u16
130bfa_fcpim_path_tov_get(struct bfa_s *bfa)
131{
132 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
133
134 return (fcpim->path_tov / 1000);
135}
136
137bfa_status_t
138bfa_fcpim_get_modstats(struct bfa_s *bfa, struct bfa_fcpim_stats_s *modstats)
139{
140 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
141
142 *modstats = fcpim->stats;
143
144 return BFA_STATUS_OK;
145}
146
147bfa_status_t
148bfa_fcpim_clr_modstats(struct bfa_s *bfa)
149{
150 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
151
152 memset(&fcpim->stats, 0, sizeof(struct bfa_fcpim_stats_s));
153
154 return BFA_STATUS_OK;
155}
156
157void
158bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth)
159{
160 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
161
162 bfa_assert(q_depth <= BFA_IOCFC_QDEPTH_MAX);
163
164 fcpim->q_depth = q_depth;
165}
166
167u16
168bfa_fcpim_qdepth_get(struct bfa_s *bfa)
169{
170 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
171
172 return (fcpim->q_depth);
173}
174
175