x86/amd-iommu: Add per IOMMU reference counting
[linux/fpc-iii.git] / drivers / scsi / bfa / bfa_fcpim.c
blob401babe3494ef37ef2eef54249c58cd837e09546
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
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.
18 #include <bfa.h>
19 #include <log/bfa_log_hal.h>
21 BFA_TRC_FILE(HAL, FCPIM);
22 BFA_MODULE(fcpim);
24 /**
25 * hal_fcpim_mod BFA FCP Initiator Mode module
28 /**
29 * Compute and return memory needed by FCP(im) module.
31 static void
32 bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
33 u32 *dm_len)
35 bfa_itnim_meminfo(cfg, km_len, dm_len);
37 /**
38 * IO memory
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;
50 /**
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);
59 static void
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);
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;
77 bfa_itnim_attach(fcpim, meminfo);
78 bfa_tskim_attach(fcpim, meminfo);
79 bfa_ioim_attach(fcpim, meminfo);
82 static void
83 bfa_fcpim_initdone(struct bfa_s *bfa)
87 static void
88 bfa_fcpim_detach(struct bfa_s *bfa)
90 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
92 bfa_ioim_detach(fcpim);
93 bfa_tskim_detach(fcpim);
96 static void
97 bfa_fcpim_start(struct bfa_s *bfa)
101 static void
102 bfa_fcpim_stop(struct bfa_s *bfa)
106 static void
107 bfa_fcpim_iocdisable(struct bfa_s *bfa)
109 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
110 struct bfa_itnim_s *itnim;
111 struct list_head *qe, *qen;
113 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
114 itnim = (struct bfa_itnim_s *) qe;
115 bfa_itnim_iocdisable(itnim);
119 void
120 bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
122 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
124 fcpim->path_tov = path_tov * 1000;
125 if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
126 fcpim->path_tov = BFA_FCPIM_PATHTOV_MAX;
130 bfa_fcpim_path_tov_get(struct bfa_s *bfa)
132 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
134 return (fcpim->path_tov / 1000);
137 bfa_status_t
138 bfa_fcpim_get_modstats(struct bfa_s *bfa, struct bfa_fcpim_stats_s *modstats)
140 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
142 *modstats = fcpim->stats;
144 return BFA_STATUS_OK;
147 bfa_status_t
148 bfa_fcpim_clr_modstats(struct bfa_s *bfa)
150 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
152 memset(&fcpim->stats, 0, sizeof(struct bfa_fcpim_stats_s));
154 return BFA_STATUS_OK;
157 void
158 bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth)
160 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
162 bfa_assert(q_depth <= BFA_IOCFC_QDEPTH_MAX);
164 fcpim->q_depth = q_depth;
168 bfa_fcpim_qdepth_get(struct bfa_s *bfa)
170 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
172 return (fcpim->q_depth);