aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfa_port.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 20:34:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 20:34:15 -0400
commitc70b5296e775cde46cfcb2d860ba160108a5ec7a (patch)
tree30419cb982acca44499236adcca65f2f87698c74 /drivers/scsi/bfa/bfa_port.c
parent80c226fbef56576946c9655fcb2ab62e63404d12 (diff)
parent58ff4bd042adf8013c8f70fd03c2c0f8d022e387 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (84 commits) [SCSI] be2iscsi: SGE Len == 64K [SCSI] be2iscsi: Remove premature free of cid [SCSI] be2iscsi: More time for FW [SCSI] libsas: fix bug for vacant phy [SCSI] sd: Fix overflow with big physical blocks [SCSI] st: add MTWEOFI to write filemarks without flushing drive buffer [SCSI] libsas: Don't issue commands to devices that have been hot-removed [SCSI] megaraid_sas: Add Online Controller Reset to MegaRAID SAS drive [SCSI] lpfc 8.3.17: Update lpfc driver version to 8.3.17 [SCSI] lpfc 8.3.17: Replace function reset methodology [SCSI] lpfc 8.3.17: SCSI fixes [SCSI] lpfc 8.3.17: BSG fixes [SCSI] lpfc 8.3.17: SLI Additions and Fixes [SCSI] lpfc 8.3.17: Code Cleanup and Locking fixes [SCSI] zfcp: Remove scsi_cmnd->serial_number from debug traces [SCSI] ipr: fix array error logging [SCSI] aha152x: enable PCMCIA on 64bit [SCSI] scsi_dh_alua: Handle all states correctly [SCSI] cxgb4i: connection and ddp setting update [SCSI] cxgb3i: fixed connection over vlan ...
Diffstat (limited to 'drivers/scsi/bfa/bfa_port.c')
-rw-r--r--drivers/scsi/bfa/bfa_port.c134
1 files changed, 62 insertions, 72 deletions
diff --git a/drivers/scsi/bfa/bfa_port.c b/drivers/scsi/bfa/bfa_port.c
index c7e69f1e56e3..b6d170a13bea 100644
--- a/drivers/scsi/bfa/bfa_port.c
+++ b/drivers/scsi/bfa/bfa_port.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,30 +15,25 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <defs/bfa_defs_port.h> 18#include "bfa_defs_svc.h"
19#include <cs/bfa_trc.h> 19#include "bfa_port.h"
20#include <cs/bfa_log.h> 20#include "bfi.h"
21#include <cs/bfa_debug.h> 21#include "bfa_ioc.h"
22#include <port/bfa_port.h> 22
23#include <bfi/bfi.h>
24#include <bfi/bfi_port.h>
25#include <bfa_ioc.h>
26#include <cna/bfa_cna_trcmod.h>
27 23
28BFA_TRC_FILE(CNA, PORT); 24BFA_TRC_FILE(CNA, PORT);
29 25
30#define bfa_ioc_portid(__ioc) ((__ioc)->port_id) 26#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
31#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc)
32 27
33static void 28static void
34bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats) 29bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats)
35{ 30{
36 u32 *dip = (u32 *) stats; 31 u32 *dip = (u32 *) stats;
37 u32 t0, t1; 32 u32 t0, t1;
38 int i; 33 int i;
39 34
40 for (i = 0; i < sizeof(union bfa_pport_stats_u) / sizeof(u32); 35 for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32);
41 i += 2) { 36 i += 2) {
42 t0 = dip[i]; 37 t0 = dip[i];
43 t1 = dip[i + 1]; 38 t1 = dip[i + 1];
44#ifdef __BIGENDIAN 39#ifdef __BIGENDIAN
@@ -49,11 +44,6 @@ bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats)
49 dip[i + 1] = bfa_os_ntohl(t0); 44 dip[i + 1] = bfa_os_ntohl(t0);
50#endif 45#endif
51 } 46 }
52
53 /** todo
54 * QoS stats r also swapped as 64bit; that structure also
55 * has to use 64 bit counters
56 */
57} 47}
58 48
59/** 49/**
@@ -68,7 +58,9 @@ bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats)
68static void 58static void
69bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status) 59bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
70{ 60{
71 bfa_assert(0); 61 bfa_trc(port, status);
62 port->endis_pending = BFA_FALSE;
63 port->endis_cbfn(port->endis_cbarg, status);
72} 64}
73 65
74/** 66/**
@@ -83,7 +75,9 @@ bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
83static void 75static void
84bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status) 76bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status)
85{ 77{
86 bfa_assert(0); 78 bfa_trc(port, status);
79 port->endis_pending = BFA_FALSE;
80 port->endis_cbfn(port->endis_cbarg, status);
87} 81}
88 82
89/** 83/**
@@ -105,7 +99,7 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
105 struct bfa_timeval_s tv; 99 struct bfa_timeval_s tv;
106 100
107 memcpy(port->stats, port->stats_dma.kva, 101 memcpy(port->stats, port->stats_dma.kva,
108 sizeof(union bfa_pport_stats_u)); 102 sizeof(union bfa_port_stats_u));
109 bfa_port_stats_swap(port, port->stats); 103 bfa_port_stats_swap(port, port->stats);
110 104
111 bfa_os_gettimeofday(&tv); 105 bfa_os_gettimeofday(&tv);
@@ -133,11 +127,11 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
133 struct bfa_timeval_s tv; 127 struct bfa_timeval_s tv;
134 128
135 port->stats_status = status; 129 port->stats_status = status;
136 port->stats_busy = BFA_FALSE; 130 port->stats_busy = BFA_FALSE;
137 131
138 /** 132 /**
139 * re-initialize time stamp for stats reset 133 * re-initialize time stamp for stats reset
140 */ 134 */
141 bfa_os_gettimeofday(&tv); 135 bfa_os_gettimeofday(&tv);
142 port->stats_reset_time = tv.tv_sec; 136 port->stats_reset_time = tv.tv_sec;
143 137
@@ -158,10 +152,10 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
158static void 152static void
159bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m) 153bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
160{ 154{
161 struct bfa_port_s *port = (struct bfa_port_s *)cbarg; 155 struct bfa_port_s *port = (struct bfa_port_s *) cbarg;
162 union bfi_port_i2h_msg_u *i2hmsg; 156 union bfi_port_i2h_msg_u *i2hmsg;
163 157
164 i2hmsg = (union bfi_port_i2h_msg_u *)m; 158 i2hmsg = (union bfi_port_i2h_msg_u *) m;
165 bfa_trc(port, m->mh.msg_id); 159 bfa_trc(port, m->mh.msg_id);
166 160
167 switch (m->mh.msg_id) { 161 switch (m->mh.msg_id) {
@@ -178,9 +172,7 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
178 break; 172 break;
179 173
180 case BFI_PORT_I2H_GET_STATS_RSP: 174 case BFI_PORT_I2H_GET_STATS_RSP:
181 /* 175 /* Stats busy flag is still set? (may be cmd timed out) */
182 * Stats busy flag is still set? (may be cmd timed out)
183 */
184 if (port->stats_busy == BFA_FALSE) 176 if (port->stats_busy == BFA_FALSE)
185 break; 177 break;
186 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status); 178 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status);
@@ -208,7 +200,7 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
208u32 200u32
209bfa_port_meminfo(void) 201bfa_port_meminfo(void)
210{ 202{
211 return BFA_ROUNDUP(sizeof(union bfa_pport_stats_u), BFA_DMA_ALIGN_SZ); 203 return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ);
212} 204}
213 205
214/** 206/**
@@ -216,8 +208,8 @@ bfa_port_meminfo(void)
216 * 208 *
217 * 209 *
218 * @param[in] port Port module pointer 210 * @param[in] port Port module pointer
219 * dma_kva Kernel Virtual Address of Port DMA Memory 211 * dma_kva Kernel Virtual Address of Port DMA Memory
220 * dma_pa Physical Address of Port DMA Memory 212 * dma_pa Physical Address of Port DMA Memory
221 * 213 *
222 * @return void 214 * @return void
223 */ 215 */
@@ -225,7 +217,7 @@ void
225bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa) 217bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
226{ 218{
227 port->stats_dma.kva = dma_kva; 219 port->stats_dma.kva = dma_kva;
228 port->stats_dma.pa = dma_pa; 220 port->stats_dma.pa = dma_pa;
229} 221}
230 222
231/** 223/**
@@ -239,12 +231,14 @@ bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
239 */ 231 */
240bfa_status_t 232bfa_status_t
241bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, 233bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
242 void *cbarg) 234 void *cbarg)
243{ 235{
244 struct bfi_port_generic_req_s *m; 236 struct bfi_port_generic_req_s *m;
245 237
246 /** todo Not implemented */ 238 if (bfa_ioc_is_disabled(port->ioc)) {
247 bfa_assert(0); 239 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
240 return BFA_STATUS_IOC_DISABLED;
241 }
248 242
249 if (!bfa_ioc_is_operational(port->ioc)) { 243 if (!bfa_ioc_is_operational(port->ioc)) {
250 bfa_trc(port, BFA_STATUS_IOC_FAILURE); 244 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
@@ -256,11 +250,11 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
256 return BFA_STATUS_DEVBUSY; 250 return BFA_STATUS_DEVBUSY;
257 } 251 }
258 252
259 m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; 253 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
260 254
261 port->msgtag++; 255 port->msgtag++;
262 port->endis_cbfn = cbfn; 256 port->endis_cbfn = cbfn;
263 port->endis_cbarg = cbarg; 257 port->endis_cbarg = cbarg;
264 port->endis_pending = BFA_TRUE; 258 port->endis_pending = BFA_TRUE;
265 259
266 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ, 260 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
@@ -281,12 +275,14 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
281 */ 275 */
282bfa_status_t 276bfa_status_t
283bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, 277bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
284 void *cbarg) 278 void *cbarg)
285{ 279{
286 struct bfi_port_generic_req_s *m; 280 struct bfi_port_generic_req_s *m;
287 281
288 /** todo Not implemented */ 282 if (bfa_ioc_is_disabled(port->ioc)) {
289 bfa_assert(0); 283 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
284 return BFA_STATUS_IOC_DISABLED;
285 }
290 286
291 if (!bfa_ioc_is_operational(port->ioc)) { 287 if (!bfa_ioc_is_operational(port->ioc)) {
292 bfa_trc(port, BFA_STATUS_IOC_FAILURE); 288 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
@@ -298,11 +294,11 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
298 return BFA_STATUS_DEVBUSY; 294 return BFA_STATUS_DEVBUSY;
299 } 295 }
300 296
301 m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; 297 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
302 298
303 port->msgtag++; 299 port->msgtag++;
304 port->endis_cbfn = cbfn; 300 port->endis_cbfn = cbfn;
305 port->endis_cbarg = cbarg; 301 port->endis_cbarg = cbarg;
306 port->endis_pending = BFA_TRUE; 302 port->endis_pending = BFA_TRUE;
307 303
308 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ, 304 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
@@ -322,8 +318,8 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
322 * @return Status 318 * @return Status
323 */ 319 */
324bfa_status_t 320bfa_status_t
325bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats, 321bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
326 bfa_port_stats_cbfn_t cbfn, void *cbarg) 322 bfa_port_stats_cbfn_t cbfn, void *cbarg)
327{ 323{
328 struct bfi_port_get_stats_req_s *m; 324 struct bfi_port_get_stats_req_s *m;
329 325
@@ -337,12 +333,12 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats,
337 return BFA_STATUS_DEVBUSY; 333 return BFA_STATUS_DEVBUSY;
338 } 334 }
339 335
340 m = (struct bfi_port_get_stats_req_s *)port->stats_mb.msg; 336 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
341 337
342 port->stats = stats; 338 port->stats = stats;
343 port->stats_cbfn = cbfn; 339 port->stats_cbfn = cbfn;
344 port->stats_cbarg = cbarg; 340 port->stats_cbarg = cbarg;
345 port->stats_busy = BFA_TRUE; 341 port->stats_busy = BFA_TRUE;
346 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa); 342 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
347 343
348 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ, 344 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
@@ -362,7 +358,7 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats,
362 */ 358 */
363bfa_status_t 359bfa_status_t
364bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn, 360bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
365 void *cbarg) 361 void *cbarg)
366{ 362{
367 struct bfi_port_generic_req_s *m; 363 struct bfi_port_generic_req_s *m;
368 364
@@ -376,11 +372,11 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
376 return BFA_STATUS_DEVBUSY; 372 return BFA_STATUS_DEVBUSY;
377 } 373 }
378 374
379 m = (struct bfi_port_generic_req_s *)port->stats_mb.msg; 375 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
380 376
381 port->stats_cbfn = cbfn; 377 port->stats_cbfn = cbfn;
382 port->stats_cbarg = cbarg; 378 port->stats_cbarg = cbarg;
383 port->stats_busy = BFA_TRUE; 379 port->stats_busy = BFA_TRUE;
384 380
385 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ, 381 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
386 bfa_ioc_portid(port->ioc)); 382 bfa_ioc_portid(port->ioc));
@@ -400,11 +396,9 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
400void 396void
401bfa_port_hbfail(void *arg) 397bfa_port_hbfail(void *arg)
402{ 398{
403 struct bfa_port_s *port = (struct bfa_port_s *)arg; 399 struct bfa_port_s *port = (struct bfa_port_s *) arg;
404 400
405 /* 401 /* Fail any pending get_stats/clear_stats requests */
406 * Fail any pending get_stats/clear_stats requests
407 */
408 if (port->stats_busy) { 402 if (port->stats_busy) {
409 if (port->stats_cbfn) 403 if (port->stats_cbfn)
410 port->stats_cbfn(port->stats_cbarg, BFA_STATUS_FAILED); 404 port->stats_cbfn(port->stats_cbarg, BFA_STATUS_FAILED);
@@ -412,9 +406,7 @@ bfa_port_hbfail(void *arg)
412 port->stats_busy = BFA_FALSE; 406 port->stats_busy = BFA_FALSE;
413 } 407 }
414 408
415 /* 409 /* Clear any enable/disable is pending */
416 * Clear any enable/disable is pending
417 */
418 if (port->endis_pending) { 410 if (port->endis_pending) {
419 if (port->endis_cbfn) 411 if (port->endis_cbfn)
420 port->endis_cbfn(port->endis_cbarg, BFA_STATUS_FAILED); 412 port->endis_cbfn(port->endis_cbarg, BFA_STATUS_FAILED);
@@ -433,22 +425,20 @@ bfa_port_hbfail(void *arg)
433 * The device driver specific mbox ISR functions have 425 * The device driver specific mbox ISR functions have
434 * this pointer as one of the parameters. 426 * this pointer as one of the parameters.
435 * trcmod - 427 * trcmod -
436 * logmod -
437 * 428 *
438 * @return void 429 * @return void
439 */ 430 */
440void 431void
441bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, void *dev, 432bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
442 struct bfa_trc_mod_s *trcmod, struct bfa_log_mod_s *logmod) 433 void *dev, struct bfa_trc_mod_s *trcmod)
443{ 434{
444 struct bfa_timeval_s tv; 435 struct bfa_timeval_s tv;
445 436
446 bfa_assert(port); 437 bfa_assert(port);
447 438
448 port->dev = dev; 439 port->dev = dev;
449 port->ioc = ioc; 440 port->ioc = ioc;
450 port->trcmod = trcmod; 441 port->trcmod = trcmod;
451 port->logmod = logmod;
452 442
453 port->stats_busy = BFA_FALSE; 443 port->stats_busy = BFA_FALSE;
454 port->endis_pending = BFA_FALSE; 444 port->endis_pending = BFA_FALSE;