aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfa_fcpim.c
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-06-13 18:53:58 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-06-29 16:54:23 -0400
commite2187d7f38967aeaf4148cdbe3498f76f4f71bca (patch)
tree9d04ce87a63d934853cdd61ddc23dcc0c57c8acd /drivers/scsi/bfa/bfa_fcpim.c
parentbe540a991e2097c313d7304e0daaf89d68011bb9 (diff)
[SCSI] bfa: Enhancement for fcpim and IO tag handling.
- Enhancements to FCPIM module. - Introduced IO tag management to allocate/release IOs to FCPIM module from a free IOtag pool. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfa_fcpim.c')
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.c267
1 files changed, 197 insertions, 70 deletions
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 874cd79855ea..76d9a00ffb6a 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -19,7 +19,6 @@
19#include "bfa_modules.h" 19#include "bfa_modules.h"
20 20
21BFA_TRC_FILE(HAL, FCPIM); 21BFA_TRC_FILE(HAL, FCPIM);
22BFA_MODULE(fcpim);
23 22
24/* 23/*
25 * BFA ITNIM Related definitions 24 * BFA ITNIM Related definitions
@@ -295,16 +294,9 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
295 /* 294 /*
296 * IO memory 295 * IO memory
297 */ 296 */
298 if (cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN)
299 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
300 else if (cfg->fwcfg.num_ioim_reqs > BFA_IOIM_MAX)
301 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
302
303 *km_len += cfg->fwcfg.num_ioim_reqs * 297 *km_len += cfg->fwcfg.num_ioim_reqs *
304 (sizeof(struct bfa_ioim_s) + sizeof(struct bfa_ioim_sp_s)); 298 (sizeof(struct bfa_ioim_s) + sizeof(struct bfa_ioim_sp_s));
305 299
306 *dm_len += cfg->fwcfg.num_ioim_reqs * BFI_IOIM_SNSLEN;
307
308 /* 300 /*
309 * task management command memory 301 * task management command memory
310 */ 302 */
@@ -315,19 +307,21 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
315 307
316 308
317static void 309static void
318bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, 310bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad,
319 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) 311 struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
312 struct bfa_pcidev_s *pcidev)
320{ 313{
321 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 314 struct bfa_fcpim_s *fcpim = &fcp->fcpim;
315 struct bfa_s *bfa = fcp->bfa;
322 316
323 bfa_trc(bfa, cfg->drvcfg.path_tov); 317 bfa_trc(bfa, cfg->drvcfg.path_tov);
324 bfa_trc(bfa, cfg->fwcfg.num_rports); 318 bfa_trc(bfa, cfg->fwcfg.num_rports);
325 bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs); 319 bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs);
326 bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs); 320 bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs);
327 321
322 fcpim->fcp = fcp;
328 fcpim->bfa = bfa; 323 fcpim->bfa = bfa;
329 fcpim->num_itnims = cfg->fwcfg.num_rports; 324 fcpim->num_itnims = cfg->fwcfg.num_rports;
330 fcpim->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
331 fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs; 325 fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs;
332 fcpim->path_tov = cfg->drvcfg.path_tov; 326 fcpim->path_tov = cfg->drvcfg.path_tov;
333 fcpim->delay_comp = cfg->drvcfg.delay_comp; 327 fcpim->delay_comp = cfg->drvcfg.delay_comp;
@@ -340,24 +334,9 @@ bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
340} 334}
341 335
342static void 336static void
343bfa_fcpim_detach(struct bfa_s *bfa) 337bfa_fcpim_iocdisable(struct bfa_fcp_mod_s *fcp)
344{
345}
346
347static void
348bfa_fcpim_start(struct bfa_s *bfa)
349{
350}
351
352static void
353bfa_fcpim_stop(struct bfa_s *bfa)
354{ 338{
355} 339 struct bfa_fcpim_s *fcpim = &fcp->fcpim;
356
357static void
358bfa_fcpim_iocdisable(struct bfa_s *bfa)
359{
360 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
361 struct bfa_itnim_s *itnim; 340 struct bfa_itnim_s *itnim;
362 struct list_head *qe, *qen; 341 struct list_head *qe, *qen;
363 342
@@ -370,7 +349,7 @@ bfa_fcpim_iocdisable(struct bfa_s *bfa)
370void 349void
371bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov) 350bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
372{ 351{
373 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 352 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
374 353
375 fcpim->path_tov = path_tov * 1000; 354 fcpim->path_tov = path_tov * 1000;
376 if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX) 355 if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
@@ -380,7 +359,7 @@ bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
380u16 359u16
381bfa_fcpim_path_tov_get(struct bfa_s *bfa) 360bfa_fcpim_path_tov_get(struct bfa_s *bfa)
382{ 361{
383 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 362 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
384 363
385 return fcpim->path_tov / 1000; 364 return fcpim->path_tov / 1000;
386} 365}
@@ -388,7 +367,7 @@ bfa_fcpim_path_tov_get(struct bfa_s *bfa)
388u16 367u16
389bfa_fcpim_qdepth_get(struct bfa_s *bfa) 368bfa_fcpim_qdepth_get(struct bfa_s *bfa)
390{ 369{
391 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 370 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
392 371
393 return fcpim->q_depth; 372 return fcpim->q_depth;
394} 373}
@@ -1000,7 +979,7 @@ bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
1000} 979}
1001 980
1002void 981void
1003bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo) 982bfa_itnim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo)
1004{ 983{
1005 struct bfa_s *bfa = fcpim->bfa; 984 struct bfa_s *bfa = fcpim->bfa;
1006 struct bfa_itnim_s *itnim; 985 struct bfa_itnim_s *itnim;
@@ -1224,7 +1203,7 @@ bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim)
1224static void 1203static void
1225bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim) 1204bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim)
1226{ 1205{
1227 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(itnim->bfa); 1206 struct bfa_fcpim_s *fcpim = BFA_FCPIM(itnim->bfa);
1228 fcpim->del_itn_stats.del_itn_iocomp_aborted += 1207 fcpim->del_itn_stats.del_itn_iocomp_aborted +=
1229 itnim->stats.iocomp_aborted; 1208 itnim->stats.iocomp_aborted;
1230 fcpim->del_itn_stats.del_itn_iocomp_timedout += 1209 fcpim->del_itn_stats.del_itn_iocomp_timedout +=
@@ -1250,7 +1229,7 @@ bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim)
1250void 1229void
1251bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m) 1230bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
1252{ 1231{
1253 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 1232 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
1254 union bfi_itn_i2h_msg_u msg; 1233 union bfi_itn_i2h_msg_u msg;
1255 struct bfa_itnim_s *itnim; 1234 struct bfa_itnim_s *itnim;
1256 1235
@@ -1295,9 +1274,11 @@ bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
1295struct bfa_itnim_s * 1274struct bfa_itnim_s *
1296bfa_itnim_create(struct bfa_s *bfa, struct bfa_rport_s *rport, void *ditn) 1275bfa_itnim_create(struct bfa_s *bfa, struct bfa_rport_s *rport, void *ditn)
1297{ 1276{
1298 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 1277 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
1299 struct bfa_itnim_s *itnim; 1278 struct bfa_itnim_s *itnim;
1300 1279
1280 bfa_itn_create(bfa, rport, bfa_itnim_isr);
1281
1301 itnim = BFA_ITNIM_FROM_TAG(fcpim, rport->rport_tag); 1282 itnim = BFA_ITNIM_FROM_TAG(fcpim, rport->rport_tag);
1302 WARN_ON(itnim->rport != rport); 1283 WARN_ON(itnim->rport != rport);
1303 1284
@@ -1991,7 +1972,8 @@ __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)
1991 if ((m->scsi_status == SCSI_STATUS_CHECK_CONDITION) && 1972 if ((m->scsi_status == SCSI_STATUS_CHECK_CONDITION) &&
1992 m->sns_len) { 1973 m->sns_len) {
1993 sns_len = m->sns_len; 1974 sns_len = m->sns_len;
1994 snsinfo = ioim->iosp->snsinfo; 1975 snsinfo = BFA_SNSINFO_FROM_TAG(ioim->fcpim->fcp,
1976 ioim->iotag);
1995 } 1977 }
1996 1978
1997 /* 1979 /*
@@ -2360,46 +2342,31 @@ bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov)
2360 * Memory allocation and initialization. 2342 * Memory allocation and initialization.
2361 */ 2343 */
2362void 2344void
2363bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo) 2345bfa_ioim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo)
2364{ 2346{
2365 struct bfa_ioim_s *ioim; 2347 struct bfa_ioim_s *ioim;
2366 struct bfa_ioim_sp_s *iosp; 2348 struct bfa_ioim_sp_s *iosp;
2367 u16 i; 2349 u16 i;
2368 u8 *snsinfo;
2369 u32 snsbufsz;
2370 2350
2371 /* 2351 /*
2372 * claim memory first 2352 * claim memory first
2373 */ 2353 */
2374 ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo); 2354 ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo);
2375 fcpim->ioim_arr = ioim; 2355 fcpim->ioim_arr = ioim;
2376 bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->num_ioim_reqs); 2356 bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs);
2377 2357
2378 iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo); 2358 iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo);
2379 fcpim->ioim_sp_arr = iosp; 2359 fcpim->ioim_sp_arr = iosp;
2380 bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->num_ioim_reqs); 2360 bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs);
2381
2382 /*
2383 * Claim DMA memory for per IO sense data.
2384 */
2385 snsbufsz = fcpim->num_ioim_reqs * BFI_IOIM_SNSLEN;
2386 fcpim->snsbase.pa = bfa_meminfo_dma_phys(minfo);
2387 bfa_meminfo_dma_phys(minfo) += snsbufsz;
2388
2389 fcpim->snsbase.kva = bfa_meminfo_dma_virt(minfo);
2390 bfa_meminfo_dma_virt(minfo) += snsbufsz;
2391 snsinfo = fcpim->snsbase.kva;
2392 bfa_iocfc_set_snsbase(fcpim->bfa, fcpim->snsbase.pa);
2393 2361
2394 /* 2362 /*
2395 * Initialize ioim free queues 2363 * Initialize ioim free queues
2396 */ 2364 */
2397 INIT_LIST_HEAD(&fcpim->ioim_free_q);
2398 INIT_LIST_HEAD(&fcpim->ioim_resfree_q); 2365 INIT_LIST_HEAD(&fcpim->ioim_resfree_q);
2399 INIT_LIST_HEAD(&fcpim->ioim_comp_q); 2366 INIT_LIST_HEAD(&fcpim->ioim_comp_q);
2400 2367
2401 for (i = 0; i < fcpim->num_ioim_reqs; 2368 for (i = 0; i < fcpim->fcp->num_ioim_reqs;
2402 i++, ioim++, iosp++, snsinfo += BFI_IOIM_SNSLEN) { 2369 i++, ioim++, iosp++) {
2403 /* 2370 /*
2404 * initialize IOIM 2371 * initialize IOIM
2405 */ 2372 */
@@ -2408,22 +2375,19 @@ bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
2408 ioim->bfa = fcpim->bfa; 2375 ioim->bfa = fcpim->bfa;
2409 ioim->fcpim = fcpim; 2376 ioim->fcpim = fcpim;
2410 ioim->iosp = iosp; 2377 ioim->iosp = iosp;
2411 iosp->snsinfo = snsinfo;
2412 INIT_LIST_HEAD(&ioim->sgpg_q); 2378 INIT_LIST_HEAD(&ioim->sgpg_q);
2413 bfa_reqq_winit(&ioim->iosp->reqq_wait, 2379 bfa_reqq_winit(&ioim->iosp->reqq_wait,
2414 bfa_ioim_qresume, ioim); 2380 bfa_ioim_qresume, ioim);
2415 bfa_sgpg_winit(&ioim->iosp->sgpg_wqe, 2381 bfa_sgpg_winit(&ioim->iosp->sgpg_wqe,
2416 bfa_ioim_sgpg_alloced, ioim); 2382 bfa_ioim_sgpg_alloced, ioim);
2417 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit); 2383 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
2418
2419 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
2420 } 2384 }
2421} 2385}
2422 2386
2423void 2387void
2424bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m) 2388bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
2425{ 2389{
2426 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 2390 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
2427 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m; 2391 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
2428 struct bfa_ioim_s *ioim; 2392 struct bfa_ioim_s *ioim;
2429 u16 iotag; 2393 u16 iotag;
@@ -2507,7 +2471,7 @@ bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
2507void 2471void
2508bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct bfi_msg_s *m) 2472bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
2509{ 2473{
2510 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 2474 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
2511 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m; 2475 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
2512 struct bfa_ioim_s *ioim; 2476 struct bfa_ioim_s *ioim;
2513 u16 iotag; 2477 u16 iotag;
@@ -2573,18 +2537,21 @@ struct bfa_ioim_s *
2573bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio, 2537bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio,
2574 struct bfa_itnim_s *itnim, u16 nsges) 2538 struct bfa_itnim_s *itnim, u16 nsges)
2575{ 2539{
2576 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 2540 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
2577 struct bfa_ioim_s *ioim; 2541 struct bfa_ioim_s *ioim;
2542 struct bfa_iotag_s *iotag = NULL;
2578 2543
2579 /* 2544 /*
2580 * alocate IOIM resource 2545 * alocate IOIM resource
2581 */ 2546 */
2582 bfa_q_deq(&fcpim->ioim_free_q, &ioim); 2547 bfa_q_deq(&fcpim->fcp->iotag_ioim_free_q, &iotag);
2583 if (!ioim) { 2548 if (!iotag) {
2584 bfa_stats(itnim, no_iotags); 2549 bfa_stats(itnim, no_iotags);
2585 return NULL; 2550 return NULL;
2586 } 2551 }
2587 2552
2553 ioim = BFA_IOIM_FROM_TAG(fcpim, iotag->tag);
2554
2588 ioim->dio = dio; 2555 ioim->dio = dio;
2589 ioim->itnim = itnim; 2556 ioim->itnim = itnim;
2590 ioim->nsges = nsges; 2557 ioim->nsges = nsges;
@@ -2601,7 +2568,8 @@ bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio,
2601void 2568void
2602bfa_ioim_free(struct bfa_ioim_s *ioim) 2569bfa_ioim_free(struct bfa_ioim_s *ioim)
2603{ 2570{
2604 struct bfa_fcpim_mod_s *fcpim = ioim->fcpim; 2571 struct bfa_fcpim_s *fcpim = ioim->fcpim;
2572 struct bfa_iotag_s *iotag;
2605 2573
2606 if (ioim->nsgpgs > 0) 2574 if (ioim->nsgpgs > 0)
2607 bfa_sgpg_mfree(ioim->bfa, &ioim->sgpg_q, ioim->nsgpgs); 2575 bfa_sgpg_mfree(ioim->bfa, &ioim->sgpg_q, ioim->nsgpgs);
@@ -2610,8 +2578,17 @@ bfa_ioim_free(struct bfa_ioim_s *ioim)
2610 fcpim->ios_active--; 2578 fcpim->ios_active--;
2611 2579
2612 ioim->iotag &= BFA_IOIM_IOTAG_MASK; 2580 ioim->iotag &= BFA_IOIM_IOTAG_MASK;
2581
2582 WARN_ON(!(ioim->iotag <
2583 (fcpim->fcp->num_ioim_reqs + fcpim->fcp->num_fwtio_reqs)));
2584 iotag = BFA_IOTAG_FROM_TAG(fcpim->fcp, ioim->iotag);
2585
2586 if (ioim->iotag < fcpim->fcp->num_ioim_reqs)
2587 list_add_tail(&iotag->qe, &fcpim->fcp->iotag_ioim_free_q);
2588 else
2589 list_add_tail(&iotag->qe, &fcpim->fcp->iotag_tio_free_q);
2590
2613 list_del(&ioim->qe); 2591 list_del(&ioim->qe);
2614 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
2615} 2592}
2616 2593
2617void 2594void
@@ -3129,7 +3106,7 @@ bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
3129 * Memory allocation and initialization. 3106 * Memory allocation and initialization.
3130 */ 3107 */
3131void 3108void
3132bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo) 3109bfa_tskim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo)
3133{ 3110{
3134 struct bfa_tskim_s *tskim; 3111 struct bfa_tskim_s *tskim;
3135 u16 i; 3112 u16 i;
@@ -3161,7 +3138,7 @@ bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
3161void 3138void
3162bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m) 3139bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
3163{ 3140{
3164 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 3141 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
3165 struct bfi_tskim_rsp_s *rsp = (struct bfi_tskim_rsp_s *) m; 3142 struct bfi_tskim_rsp_s *rsp = (struct bfi_tskim_rsp_s *) m;
3166 struct bfa_tskim_s *tskim; 3143 struct bfa_tskim_s *tskim;
3167 u16 tsk_tag = be16_to_cpu(rsp->tsk_tag); 3144 u16 tsk_tag = be16_to_cpu(rsp->tsk_tag);
@@ -3188,7 +3165,7 @@ bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
3188struct bfa_tskim_s * 3165struct bfa_tskim_s *
3189bfa_tskim_alloc(struct bfa_s *bfa, struct bfad_tskim_s *dtsk) 3166bfa_tskim_alloc(struct bfa_s *bfa, struct bfad_tskim_s *dtsk)
3190{ 3167{
3191 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 3168 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
3192 struct bfa_tskim_s *tskim; 3169 struct bfa_tskim_s *tskim;
3193 3170
3194 bfa_q_deq(&fcpim->tskim_free_q, &tskim); 3171 bfa_q_deq(&fcpim->tskim_free_q, &tskim);
@@ -3233,3 +3210,153 @@ bfa_tskim_start(struct bfa_tskim_s *tskim, struct bfa_itnim_s *itnim,
3233 list_add_tail(&tskim->qe, &itnim->tsk_q); 3210 list_add_tail(&tskim->qe, &itnim->tsk_q);
3234 bfa_sm_send_event(tskim, BFA_TSKIM_SM_START); 3211 bfa_sm_send_event(tskim, BFA_TSKIM_SM_START);
3235} 3212}
3213
3214/* BFA FCP module - parent module for fcpim */
3215
3216BFA_MODULE(fcp);
3217
3218static void
3219bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, u32 *dm_len)
3220{
3221 u16 num_io_req;
3222
3223 /*
3224 * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value.
3225 * So if the values are non zero, adjust them appropriately.
3226 */
3227 if (cfg->fwcfg.num_ioim_reqs &&
3228 cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN)
3229 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
3230 else if (cfg->fwcfg.num_ioim_reqs > BFA_IOIM_MAX)
3231 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
3232
3233 if (cfg->fwcfg.num_fwtio_reqs > BFA_FWTIO_MAX)
3234 cfg->fwcfg.num_fwtio_reqs = BFA_FWTIO_MAX;
3235
3236 num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs);
3237 if (num_io_req > BFA_IO_MAX) {
3238 if (cfg->fwcfg.num_ioim_reqs && cfg->fwcfg.num_fwtio_reqs) {
3239 cfg->fwcfg.num_ioim_reqs = BFA_IO_MAX/2;
3240 cfg->fwcfg.num_fwtio_reqs = BFA_IO_MAX/2;
3241 } else if (cfg->fwcfg.num_fwtio_reqs)
3242 cfg->fwcfg.num_fwtio_reqs = BFA_FWTIO_MAX;
3243 else
3244 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
3245 }
3246
3247 bfa_fcpim_meminfo(cfg, km_len, dm_len);
3248
3249 num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs);
3250 *km_len += num_io_req * sizeof(struct bfa_iotag_s);
3251 *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s);
3252 *dm_len += num_io_req * BFI_IOIM_SNSLEN;
3253}
3254
3255static void
3256bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
3257 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
3258{
3259 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
3260 u32 snsbufsz;
3261
3262 fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
3263 fcp->num_fwtio_reqs = cfg->fwcfg.num_fwtio_reqs;
3264 fcp->num_itns = cfg->fwcfg.num_rports;
3265 fcp->bfa = bfa;
3266
3267 snsbufsz = (fcp->num_ioim_reqs + fcp->num_fwtio_reqs) * BFI_IOIM_SNSLEN;
3268 fcp->snsbase.pa = bfa_meminfo_dma_phys(meminfo);
3269 bfa_meminfo_dma_phys(meminfo) += snsbufsz;
3270
3271 fcp->snsbase.kva = bfa_meminfo_dma_virt(meminfo);
3272 bfa_meminfo_dma_virt(meminfo) += snsbufsz;
3273 bfa_iocfc_set_snsbase(bfa, fcp->snsbase.pa);
3274
3275 bfa_fcpim_attach(fcp, bfad, cfg, meminfo, pcidev);
3276
3277 fcp->itn_arr = (struct bfa_itn_s *) bfa_meminfo_kva(meminfo);
3278 bfa_meminfo_kva(meminfo) = (u8 *)fcp->itn_arr +
3279 (fcp->num_itns * sizeof(struct bfa_itn_s));
3280 memset(fcp->itn_arr, 0,
3281 (fcp->num_itns * sizeof(struct bfa_itn_s)));
3282
3283 bfa_iotag_attach(fcp, meminfo);
3284}
3285
3286static void
3287bfa_fcp_detach(struct bfa_s *bfa)
3288{
3289}
3290
3291static void
3292bfa_fcp_start(struct bfa_s *bfa)
3293{
3294}
3295
3296static void
3297bfa_fcp_stop(struct bfa_s *bfa)
3298{
3299}
3300
3301static void
3302bfa_fcp_iocdisable(struct bfa_s *bfa)
3303{
3304 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
3305
3306 bfa_fcpim_iocdisable(fcp);
3307}
3308
3309void
3310bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
3311 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m))
3312{
3313 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
3314 struct bfa_itn_s *itn;
3315
3316 itn = BFA_ITN_FROM_TAG(fcp, rport->rport_tag);
3317 itn->isr = isr;
3318}
3319
3320/*
3321 * Itn interrupt processing.
3322 */
3323void
3324bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
3325{
3326 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
3327 union bfi_itn_i2h_msg_u msg;
3328 struct bfa_itn_s *itn;
3329
3330 msg.msg = m;
3331 itn = BFA_ITN_FROM_TAG(fcp, msg.create_rsp->bfa_handle);
3332
3333 if (itn->isr)
3334 itn->isr(bfa, m);
3335 else
3336 WARN_ON(1);
3337}
3338
3339void
3340bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo)
3341{
3342 struct bfa_iotag_s *iotag;
3343 u16 num_io_req, i;
3344
3345 iotag = (struct bfa_iotag_s *) bfa_meminfo_kva(minfo);
3346 fcp->iotag_arr = iotag;
3347
3348 INIT_LIST_HEAD(&fcp->iotag_ioim_free_q);
3349 INIT_LIST_HEAD(&fcp->iotag_tio_free_q);
3350
3351 num_io_req = fcp->num_ioim_reqs + fcp->num_fwtio_reqs;
3352 for (i = 0; i < num_io_req; i++, iotag++) {
3353 memset(iotag, 0, sizeof(struct bfa_iotag_s));
3354 iotag->tag = i;
3355 if (i < fcp->num_ioim_reqs)
3356 list_add_tail(&iotag->qe, &fcp->iotag_ioim_free_q);
3357 else
3358 list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q);
3359 }
3360
3361 bfa_meminfo_kva(minfo) = (u8 *) iotag;
3362}