diff options
-rw-r--r-- | drivers/scsi/bfa/bfa.h | 50 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_core.c | 271 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_fcpim.c | 119 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_fcpim.h | 28 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc.h | 64 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_modules.h | 12 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_port.h | 3 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_svc.c | 372 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfa_svc.h | 75 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfad.c | 149 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfad_drv.h | 15 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfi.h | 25 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfi_ms.h | 10 |
13 files changed, 624 insertions, 569 deletions
diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h index ee072d99b8f9..67742dca675f 100644 --- a/drivers/scsi/bfa/bfa.h +++ b/drivers/scsi/bfa/bfa.h | |||
@@ -172,34 +172,6 @@ struct bfa_pciid_s { | |||
172 | 172 | ||
173 | extern char bfa_version[]; | 173 | extern char bfa_version[]; |
174 | 174 | ||
175 | /* | ||
176 | * BFA memory resources | ||
177 | */ | ||
178 | enum bfa_mem_type { | ||
179 | BFA_MEM_TYPE_KVA = 1, /* Kernel Virtual Memory *(non-dma-able) */ | ||
180 | BFA_MEM_TYPE_DMA = 2, /* DMA-able memory */ | ||
181 | BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA, | ||
182 | }; | ||
183 | |||
184 | struct bfa_mem_elem_s { | ||
185 | enum bfa_mem_type mem_type; /* see enum bfa_mem_type */ | ||
186 | u32 mem_len; /* Total Length in Bytes */ | ||
187 | u8 *kva; /* kernel virtual address */ | ||
188 | u64 dma; /* dma address if DMA memory */ | ||
189 | u8 *kva_curp; /* kva allocation cursor */ | ||
190 | u64 dma_curp; /* dma allocation cursor */ | ||
191 | }; | ||
192 | |||
193 | struct bfa_meminfo_s { | ||
194 | struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX]; | ||
195 | }; | ||
196 | #define bfa_meminfo_kva(_m) \ | ||
197 | ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp) | ||
198 | #define bfa_meminfo_dma_virt(_m) \ | ||
199 | ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp) | ||
200 | #define bfa_meminfo_dma_phys(_m) \ | ||
201 | ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp) | ||
202 | |||
203 | struct bfa_iocfc_regs_s { | 175 | struct bfa_iocfc_regs_s { |
204 | void __iomem *intr_status; | 176 | void __iomem *intr_status; |
205 | void __iomem *intr_mask; | 177 | void __iomem *intr_mask; |
@@ -294,8 +266,19 @@ struct bfa_iocfc_s { | |||
294 | void *updateq_cbarg; /* bios callback arg */ | 266 | void *updateq_cbarg; /* bios callback arg */ |
295 | u32 intr_mask; | 267 | u32 intr_mask; |
296 | struct bfa_faa_args_s faa_args; | 268 | struct bfa_faa_args_s faa_args; |
269 | struct bfa_mem_dma_s ioc_dma; | ||
270 | struct bfa_mem_dma_s iocfc_dma; | ||
271 | struct bfa_mem_dma_s reqq_dma[BFI_IOC_MAX_CQS]; | ||
272 | struct bfa_mem_dma_s rspq_dma[BFI_IOC_MAX_CQS]; | ||
273 | struct bfa_mem_kva_s kva_seg; | ||
297 | }; | 274 | }; |
298 | 275 | ||
276 | #define BFA_MEM_IOC_DMA(_bfa) (&((_bfa)->iocfc.ioc_dma)) | ||
277 | #define BFA_MEM_IOCFC_DMA(_bfa) (&((_bfa)->iocfc.iocfc_dma)) | ||
278 | #define BFA_MEM_REQQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.reqq_dma[(_qno)])) | ||
279 | #define BFA_MEM_RSPQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.rspq_dma[(_qno)])) | ||
280 | #define BFA_MEM_IOCFC_KVA(_bfa) (&((_bfa)->iocfc.kva_seg)) | ||
281 | |||
299 | #define bfa_fn_lpu(__bfa) \ | 282 | #define bfa_fn_lpu(__bfa) \ |
300 | bfi_fn_lpu(bfa_ioc_pcifn(&(__bfa)->ioc), bfa_ioc_portid(&(__bfa)->ioc)) | 283 | bfi_fn_lpu(bfa_ioc_pcifn(&(__bfa)->ioc), bfa_ioc_portid(&(__bfa)->ioc)) |
301 | #define bfa_msix_init(__bfa, __nvecs) \ | 284 | #define bfa_msix_init(__bfa, __nvecs) \ |
@@ -329,17 +312,17 @@ struct bfa_iocfc_s { | |||
329 | /* | 312 | /* |
330 | * FC specific IOC functions. | 313 | * FC specific IOC functions. |
331 | */ | 314 | */ |
332 | void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 315 | void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, |
333 | u32 *dm_len); | 316 | struct bfa_meminfo_s *meminfo, |
317 | struct bfa_s *bfa); | ||
334 | void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, | 318 | void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, |
335 | struct bfa_iocfc_cfg_s *cfg, | 319 | struct bfa_iocfc_cfg_s *cfg, |
336 | struct bfa_meminfo_s *meminfo, | ||
337 | struct bfa_pcidev_s *pcidev); | 320 | struct bfa_pcidev_s *pcidev); |
338 | void bfa_iocfc_init(struct bfa_s *bfa); | 321 | void bfa_iocfc_init(struct bfa_s *bfa); |
339 | void bfa_iocfc_start(struct bfa_s *bfa); | 322 | void bfa_iocfc_start(struct bfa_s *bfa); |
340 | void bfa_iocfc_stop(struct bfa_s *bfa); | 323 | void bfa_iocfc_stop(struct bfa_s *bfa); |
341 | void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg); | 324 | void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg); |
342 | void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa); | 325 | void bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa); |
343 | bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa); | 326 | bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa); |
344 | void bfa_iocfc_reset_queues(struct bfa_s *bfa); | 327 | void bfa_iocfc_reset_queues(struct bfa_s *bfa); |
345 | 328 | ||
@@ -418,7 +401,8 @@ void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids); | |||
418 | void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg); | 401 | void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg); |
419 | void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg); | 402 | void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg); |
420 | void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, | 403 | void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, |
421 | struct bfa_meminfo_s *meminfo); | 404 | struct bfa_meminfo_s *meminfo, |
405 | struct bfa_s *bfa); | ||
422 | void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 406 | void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
423 | struct bfa_meminfo_s *meminfo, | 407 | struct bfa_meminfo_s *meminfo, |
424 | struct bfa_pcidev_s *pcidev); | 408 | struct bfa_pcidev_s *pcidev); |
diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c index 0048fc8646b4..602dc3508ed8 100644 --- a/drivers/scsi/bfa/bfa_core.c +++ b/drivers/scsi/bfa/bfa_core.c | |||
@@ -89,46 +89,26 @@ static bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = { | |||
89 | 89 | ||
90 | 90 | ||
91 | static void | 91 | static void |
92 | bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi) | 92 | bfa_com_port_attach(struct bfa_s *bfa) |
93 | { | 93 | { |
94 | struct bfa_port_s *port = &bfa->modules.port; | 94 | struct bfa_port_s *port = &bfa->modules.port; |
95 | u32 dm_len; | 95 | struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa); |
96 | u8 *dm_kva; | ||
97 | u64 dm_pa; | ||
98 | 96 | ||
99 | dm_len = bfa_port_meminfo(); | ||
100 | dm_kva = bfa_meminfo_dma_virt(mi); | ||
101 | dm_pa = bfa_meminfo_dma_phys(mi); | ||
102 | |||
103 | memset(port, 0, sizeof(struct bfa_port_s)); | ||
104 | bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod); | 97 | bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod); |
105 | bfa_port_mem_claim(port, dm_kva, dm_pa); | 98 | bfa_port_mem_claim(port, port_dma->kva_curp, port_dma->dma_curp); |
106 | |||
107 | bfa_meminfo_dma_virt(mi) = dm_kva + dm_len; | ||
108 | bfa_meminfo_dma_phys(mi) = dm_pa + dm_len; | ||
109 | } | 99 | } |
110 | 100 | ||
111 | /* | 101 | /* |
112 | * ablk module attach | 102 | * ablk module attach |
113 | */ | 103 | */ |
114 | static void | 104 | static void |
115 | bfa_com_ablk_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi) | 105 | bfa_com_ablk_attach(struct bfa_s *bfa) |
116 | { | 106 | { |
117 | struct bfa_ablk_s *ablk = &bfa->modules.ablk; | 107 | struct bfa_ablk_s *ablk = &bfa->modules.ablk; |
118 | u32 dm_len; | 108 | struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa); |
119 | u8 *dm_kva; | ||
120 | u64 dm_pa; | ||
121 | 109 | ||
122 | dm_len = bfa_ablk_meminfo(); | ||
123 | dm_kva = bfa_meminfo_dma_virt(mi); | ||
124 | dm_pa = bfa_meminfo_dma_phys(mi); | ||
125 | |||
126 | memset(ablk, 0, sizeof(struct bfa_ablk_s)); | ||
127 | bfa_ablk_attach(ablk, &bfa->ioc); | 110 | bfa_ablk_attach(ablk, &bfa->ioc); |
128 | bfa_ablk_memclaim(ablk, dm_kva, dm_pa); | 111 | bfa_ablk_memclaim(ablk, ablk_dma->kva_curp, ablk_dma->dma_curp); |
129 | |||
130 | bfa_meminfo_dma_virt(mi) = dm_kva + dm_len; | ||
131 | bfa_meminfo_dma_phys(mi) = dm_pa + dm_len; | ||
132 | } | 112 | } |
133 | 113 | ||
134 | /* | 114 | /* |
@@ -444,41 +424,6 @@ bfa_msix_lpu_err(struct bfa_s *bfa, int vec) | |||
444 | * BFA IOC private functions | 424 | * BFA IOC private functions |
445 | */ | 425 | */ |
446 | 426 | ||
447 | static void | ||
448 | bfa_iocfc_cqs_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len) | ||
449 | { | ||
450 | int i, per_reqq_sz, per_rspq_sz; | ||
451 | |||
452 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), | ||
453 | BFA_DMA_ALIGN_SZ); | ||
454 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), | ||
455 | BFA_DMA_ALIGN_SZ); | ||
456 | |||
457 | /* | ||
458 | * Calculate CQ size | ||
459 | */ | ||
460 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { | ||
461 | *dm_len = *dm_len + per_reqq_sz; | ||
462 | *dm_len = *dm_len + per_rspq_sz; | ||
463 | } | ||
464 | |||
465 | /* | ||
466 | * Calculate Shadow CI/PI size | ||
467 | */ | ||
468 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) | ||
469 | *dm_len += (2 * BFA_CACHELINE_SZ); | ||
470 | } | ||
471 | |||
472 | static void | ||
473 | bfa_iocfc_fw_cfg_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len) | ||
474 | { | ||
475 | *dm_len += | ||
476 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); | ||
477 | *dm_len += | ||
478 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), | ||
479 | BFA_CACHELINE_SZ); | ||
480 | } | ||
481 | |||
482 | /* | 427 | /* |
483 | * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ | 428 | * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ |
484 | */ | 429 | */ |
@@ -604,48 +549,42 @@ bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
604 | } | 549 | } |
605 | 550 | ||
606 | static void | 551 | static void |
607 | bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg, | 552 | bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg) |
608 | struct bfa_meminfo_s *meminfo) | ||
609 | { | 553 | { |
610 | u8 *dm_kva; | 554 | u8 *dm_kva = NULL; |
611 | u64 dm_pa; | 555 | u64 dm_pa = 0; |
612 | int i, per_reqq_sz, per_rspq_sz; | 556 | int i, per_reqq_sz, per_rspq_sz, dbgsz; |
613 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; | 557 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
614 | int dbgsz; | 558 | struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa); |
559 | struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa); | ||
560 | struct bfa_mem_dma_s *reqq_dma, *rspq_dma; | ||
615 | 561 | ||
616 | dm_kva = bfa_meminfo_dma_virt(meminfo); | 562 | /* First allocate dma memory for IOC */ |
617 | dm_pa = bfa_meminfo_dma_phys(meminfo); | 563 | bfa_ioc_mem_claim(&bfa->ioc, bfa_mem_dma_virt(ioc_dma), |
564 | bfa_mem_dma_phys(ioc_dma)); | ||
618 | 565 | ||
619 | /* | 566 | /* Claim DMA-able memory for the request/response queues */ |
620 | * First allocate dma memory for IOC. | ||
621 | */ | ||
622 | bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa); | ||
623 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ); | ||
624 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ); | ||
625 | |||
626 | /* | ||
627 | * Claim DMA-able memory for the request/response queues and for shadow | ||
628 | * ci/pi registers | ||
629 | */ | ||
630 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), | 567 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), |
631 | BFA_DMA_ALIGN_SZ); | 568 | BFA_DMA_ALIGN_SZ); |
632 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), | 569 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), |
633 | BFA_DMA_ALIGN_SZ); | 570 | BFA_DMA_ALIGN_SZ); |
634 | 571 | ||
635 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { | 572 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
636 | iocfc->req_cq_ba[i].kva = dm_kva; | 573 | reqq_dma = BFA_MEM_REQQ_DMA(bfa, i); |
637 | iocfc->req_cq_ba[i].pa = dm_pa; | 574 | iocfc->req_cq_ba[i].kva = bfa_mem_dma_virt(reqq_dma); |
638 | memset(dm_kva, 0, per_reqq_sz); | 575 | iocfc->req_cq_ba[i].pa = bfa_mem_dma_phys(reqq_dma); |
639 | dm_kva += per_reqq_sz; | 576 | memset(iocfc->req_cq_ba[i].kva, 0, per_reqq_sz); |
640 | dm_pa += per_reqq_sz; | 577 | |
641 | 578 | rspq_dma = BFA_MEM_RSPQ_DMA(bfa, i); | |
642 | iocfc->rsp_cq_ba[i].kva = dm_kva; | 579 | iocfc->rsp_cq_ba[i].kva = bfa_mem_dma_virt(rspq_dma); |
643 | iocfc->rsp_cq_ba[i].pa = dm_pa; | 580 | iocfc->rsp_cq_ba[i].pa = bfa_mem_dma_phys(rspq_dma); |
644 | memset(dm_kva, 0, per_rspq_sz); | 581 | memset(iocfc->rsp_cq_ba[i].kva, 0, per_rspq_sz); |
645 | dm_kva += per_rspq_sz; | ||
646 | dm_pa += per_rspq_sz; | ||
647 | } | 582 | } |
648 | 583 | ||
584 | /* Claim IOCFC dma memory - for shadow CI/PI */ | ||
585 | dm_kva = bfa_mem_dma_virt(iocfc_dma); | ||
586 | dm_pa = bfa_mem_dma_phys(iocfc_dma); | ||
587 | |||
649 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { | 588 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
650 | iocfc->req_cq_shadow_ci[i].kva = dm_kva; | 589 | iocfc->req_cq_shadow_ci[i].kva = dm_kva; |
651 | iocfc->req_cq_shadow_ci[i].pa = dm_pa; | 590 | iocfc->req_cq_shadow_ci[i].pa = dm_pa; |
@@ -658,36 +597,27 @@ bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg, | |||
658 | dm_pa += BFA_CACHELINE_SZ; | 597 | dm_pa += BFA_CACHELINE_SZ; |
659 | } | 598 | } |
660 | 599 | ||
661 | /* | 600 | /* Claim IOCFC dma memory - for the config info page */ |
662 | * Claim DMA-able memory for the config info page | ||
663 | */ | ||
664 | bfa->iocfc.cfg_info.kva = dm_kva; | 601 | bfa->iocfc.cfg_info.kva = dm_kva; |
665 | bfa->iocfc.cfg_info.pa = dm_pa; | 602 | bfa->iocfc.cfg_info.pa = dm_pa; |
666 | bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva; | 603 | bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva; |
667 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); | 604 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
668 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); | 605 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
669 | 606 | ||
670 | /* | 607 | /* Claim IOCFC dma memory - for the config response */ |
671 | * Claim DMA-able memory for the config response | ||
672 | */ | ||
673 | bfa->iocfc.cfgrsp_dma.kva = dm_kva; | 608 | bfa->iocfc.cfgrsp_dma.kva = dm_kva; |
674 | bfa->iocfc.cfgrsp_dma.pa = dm_pa; | 609 | bfa->iocfc.cfgrsp_dma.pa = dm_pa; |
675 | bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva; | 610 | bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva; |
676 | 611 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), | |
677 | dm_kva += | 612 | BFA_CACHELINE_SZ); |
678 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), | ||
679 | BFA_CACHELINE_SZ); | ||
680 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), | 613 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
681 | BFA_CACHELINE_SZ); | 614 | BFA_CACHELINE_SZ); |
682 | |||
683 | |||
684 | bfa_meminfo_dma_virt(meminfo) = dm_kva; | ||
685 | bfa_meminfo_dma_phys(meminfo) = dm_pa; | ||
686 | 615 | ||
616 | /* Claim IOCFC kva memory */ | ||
687 | dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0; | 617 | dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0; |
688 | if (dbgsz > 0) { | 618 | if (dbgsz > 0) { |
689 | bfa_ioc_debug_memclaim(&bfa->ioc, bfa_meminfo_kva(meminfo)); | 619 | bfa_ioc_debug_memclaim(&bfa->ioc, bfa_mem_kva_curp(iocfc)); |
690 | bfa_meminfo_kva(meminfo) += dbgsz; | 620 | bfa_mem_kva_curp(iocfc) += dbgsz; |
691 | } | 621 | } |
692 | } | 622 | } |
693 | 623 | ||
@@ -1102,15 +1032,47 @@ bfa_iocfc_reset_cbfn(void *bfa_arg) | |||
1102 | * Query IOC memory requirement information. | 1032 | * Query IOC memory requirement information. |
1103 | */ | 1033 | */ |
1104 | void | 1034 | void |
1105 | bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 1035 | bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, |
1106 | u32 *dm_len) | 1036 | struct bfa_s *bfa) |
1107 | { | 1037 | { |
1108 | /* dma memory for IOC */ | 1038 | int q, per_reqq_sz, per_rspq_sz; |
1109 | *dm_len += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ); | 1039 | struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa); |
1040 | struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa); | ||
1041 | struct bfa_mem_kva_s *iocfc_kva = BFA_MEM_IOCFC_KVA(bfa); | ||
1042 | u32 dm_len = 0; | ||
1043 | |||
1044 | /* dma memory setup for IOC */ | ||
1045 | bfa_mem_dma_setup(meminfo, ioc_dma, | ||
1046 | BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ)); | ||
1047 | |||
1048 | /* dma memory setup for REQ/RSP queues */ | ||
1049 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), | ||
1050 | BFA_DMA_ALIGN_SZ); | ||
1051 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), | ||
1052 | BFA_DMA_ALIGN_SZ); | ||
1053 | |||
1054 | for (q = 0; q < cfg->fwcfg.num_cqs; q++) { | ||
1055 | bfa_mem_dma_setup(meminfo, BFA_MEM_REQQ_DMA(bfa, q), | ||
1056 | per_reqq_sz); | ||
1057 | bfa_mem_dma_setup(meminfo, BFA_MEM_RSPQ_DMA(bfa, q), | ||
1058 | per_rspq_sz); | ||
1059 | } | ||
1110 | 1060 | ||
1111 | bfa_iocfc_fw_cfg_sz(cfg, dm_len); | 1061 | /* IOCFC dma memory - calculate Shadow CI/PI size */ |
1112 | bfa_iocfc_cqs_sz(cfg, dm_len); | 1062 | for (q = 0; q < cfg->fwcfg.num_cqs; q++) |
1113 | *km_len += (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0; | 1063 | dm_len += (2 * BFA_CACHELINE_SZ); |
1064 | |||
1065 | /* IOCFC dma memory - calculate config info / rsp size */ | ||
1066 | dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); | ||
1067 | dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), | ||
1068 | BFA_CACHELINE_SZ); | ||
1069 | |||
1070 | /* dma memory setup for IOCFC */ | ||
1071 | bfa_mem_dma_setup(meminfo, iocfc_dma, dm_len); | ||
1072 | |||
1073 | /* kva memory setup for IOCFC */ | ||
1074 | bfa_mem_kva_setup(meminfo, iocfc_kva, | ||
1075 | ((bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0)); | ||
1114 | } | 1076 | } |
1115 | 1077 | ||
1116 | /* | 1078 | /* |
@@ -1118,7 +1080,7 @@ bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | |||
1118 | */ | 1080 | */ |
1119 | void | 1081 | void |
1120 | bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 1082 | bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
1121 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 1083 | struct bfa_pcidev_s *pcidev) |
1122 | { | 1084 | { |
1123 | int i; | 1085 | int i; |
1124 | struct bfa_ioc_s *ioc = &bfa->ioc; | 1086 | struct bfa_ioc_s *ioc = &bfa->ioc; |
@@ -1135,7 +1097,7 @@ bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
1135 | bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); | 1097 | bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); |
1136 | 1098 | ||
1137 | bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev); | 1099 | bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev); |
1138 | bfa_iocfc_mem_claim(bfa, cfg, meminfo); | 1100 | bfa_iocfc_mem_claim(bfa, cfg); |
1139 | INIT_LIST_HEAD(&bfa->timer_mod.timer_q); | 1101 | INIT_LIST_HEAD(&bfa->timer_mod.timer_q); |
1140 | 1102 | ||
1141 | INIT_LIST_HEAD(&bfa->comp_q); | 1103 | INIT_LIST_HEAD(&bfa->comp_q); |
@@ -1259,12 +1221,12 @@ bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr) | |||
1259 | } | 1221 | } |
1260 | 1222 | ||
1261 | void | 1223 | void |
1262 | bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa) | 1224 | bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa) |
1263 | { | 1225 | { |
1264 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; | 1226 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
1265 | 1227 | ||
1266 | iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1); | 1228 | iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1); |
1267 | bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase, snsbase_pa); | 1229 | bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase[seg_no], snsbase_pa); |
1268 | } | 1230 | } |
1269 | /* | 1231 | /* |
1270 | * Enable IOC after it is disabled. | 1232 | * Enable IOC after it is disabled. |
@@ -1353,34 +1315,37 @@ bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport) | |||
1353 | * starting address for each block and provide the same | 1315 | * starting address for each block and provide the same |
1354 | * structure as input parameter to bfa_attach() call. | 1316 | * structure as input parameter to bfa_attach() call. |
1355 | * | 1317 | * |
1318 | * @param[in] bfa - pointer to the bfa structure, used while fetching the | ||
1319 | * dma, kva memory information of the bfa sub-modules. | ||
1320 | * | ||
1356 | * @return void | 1321 | * @return void |
1357 | * | 1322 | * |
1358 | * Special Considerations: @note | 1323 | * Special Considerations: @note |
1359 | */ | 1324 | */ |
1360 | void | 1325 | void |
1361 | bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo) | 1326 | bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, |
1327 | struct bfa_s *bfa) | ||
1362 | { | 1328 | { |
1363 | int i; | 1329 | int i; |
1364 | u32 km_len = 0, dm_len = 0; | 1330 | struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa); |
1331 | struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa); | ||
1365 | 1332 | ||
1366 | WARN_ON((cfg == NULL) || (meminfo == NULL)); | 1333 | WARN_ON((cfg == NULL) || (meminfo == NULL)); |
1367 | 1334 | ||
1368 | memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s)); | 1335 | memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s)); |
1369 | meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_type = | ||
1370 | BFA_MEM_TYPE_KVA; | ||
1371 | meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_type = | ||
1372 | BFA_MEM_TYPE_DMA; | ||
1373 | 1336 | ||
1374 | bfa_iocfc_meminfo(cfg, &km_len, &dm_len); | 1337 | /* Initialize the DMA & KVA meminfo queues */ |
1338 | INIT_LIST_HEAD(&meminfo->dma_info.qe); | ||
1339 | INIT_LIST_HEAD(&meminfo->kva_info.qe); | ||
1375 | 1340 | ||
1376 | for (i = 0; hal_mods[i]; i++) | 1341 | bfa_iocfc_meminfo(cfg, meminfo, bfa); |
1377 | hal_mods[i]->meminfo(cfg, &km_len, &dm_len); | ||
1378 | 1342 | ||
1379 | dm_len += bfa_port_meminfo(); | 1343 | for (i = 0; hal_mods[i]; i++) |
1380 | dm_len += bfa_ablk_meminfo(); | 1344 | hal_mods[i]->meminfo(cfg, meminfo, bfa); |
1381 | 1345 | ||
1382 | meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_len = km_len; | 1346 | /* dma info setup */ |
1383 | meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_len = dm_len; | 1347 | bfa_mem_dma_setup(meminfo, port_dma, bfa_port_meminfo()); |
1348 | bfa_mem_dma_setup(meminfo, ablk_dma, bfa_ablk_meminfo()); | ||
1384 | } | 1349 | } |
1385 | 1350 | ||
1386 | /* | 1351 | /* |
@@ -1413,29 +1378,41 @@ void | |||
1413 | bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 1378 | bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
1414 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 1379 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) |
1415 | { | 1380 | { |
1416 | int i; | 1381 | int i; |
1417 | struct bfa_mem_elem_s *melem; | 1382 | struct bfa_mem_dma_s *dma_info, *dma_elem; |
1383 | struct bfa_mem_kva_s *kva_info, *kva_elem; | ||
1384 | struct list_head *dm_qe, *km_qe; | ||
1418 | 1385 | ||
1419 | bfa->fcs = BFA_FALSE; | 1386 | bfa->fcs = BFA_FALSE; |
1420 | 1387 | ||
1421 | WARN_ON((cfg == NULL) || (meminfo == NULL)); | 1388 | WARN_ON((cfg == NULL) || (meminfo == NULL)); |
1422 | 1389 | ||
1423 | /* | 1390 | /* Initialize memory pointers for iterative allocation */ |
1424 | * initialize all memory pointers for iterative allocation | 1391 | dma_info = &meminfo->dma_info; |
1425 | */ | 1392 | dma_info->kva_curp = dma_info->kva; |
1426 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { | 1393 | dma_info->dma_curp = dma_info->dma; |
1427 | melem = meminfo->meminfo + i; | 1394 | |
1428 | melem->kva_curp = melem->kva; | 1395 | kva_info = &meminfo->kva_info; |
1429 | melem->dma_curp = melem->dma; | 1396 | kva_info->kva_curp = kva_info->kva; |
1397 | |||
1398 | list_for_each(dm_qe, &dma_info->qe) { | ||
1399 | dma_elem = (struct bfa_mem_dma_s *) dm_qe; | ||
1400 | dma_elem->kva_curp = dma_elem->kva; | ||
1401 | dma_elem->dma_curp = dma_elem->dma; | ||
1402 | } | ||
1403 | |||
1404 | list_for_each(km_qe, &kva_info->qe) { | ||
1405 | kva_elem = (struct bfa_mem_kva_s *) km_qe; | ||
1406 | kva_elem->kva_curp = kva_elem->kva; | ||
1430 | } | 1407 | } |
1431 | 1408 | ||
1432 | bfa_iocfc_attach(bfa, bfad, cfg, meminfo, pcidev); | 1409 | bfa_iocfc_attach(bfa, bfad, cfg, pcidev); |
1433 | 1410 | ||
1434 | for (i = 0; hal_mods[i]; i++) | 1411 | for (i = 0; hal_mods[i]; i++) |
1435 | hal_mods[i]->attach(bfa, bfad, cfg, meminfo, pcidev); | 1412 | hal_mods[i]->attach(bfa, bfad, cfg, pcidev); |
1436 | 1413 | ||
1437 | bfa_com_port_attach(bfa, meminfo); | 1414 | bfa_com_port_attach(bfa); |
1438 | bfa_com_ablk_attach(bfa, meminfo); | 1415 | bfa_com_ablk_attach(bfa); |
1439 | } | 1416 | } |
1440 | 1417 | ||
1441 | /* | 1418 | /* |
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c index eb14fd6193a0..27eab36f89a5 100644 --- a/drivers/scsi/bfa/bfa_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcpim.c | |||
@@ -286,10 +286,9 @@ static void bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, | |||
286 | * Compute and return memory needed by FCP(im) module. | 286 | * Compute and return memory needed by FCP(im) module. |
287 | */ | 287 | */ |
288 | static void | 288 | static void |
289 | bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 289 | bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len) |
290 | u32 *dm_len) | ||
291 | { | 290 | { |
292 | bfa_itnim_meminfo(cfg, km_len, dm_len); | 291 | bfa_itnim_meminfo(cfg, km_len); |
293 | 292 | ||
294 | /* | 293 | /* |
295 | * IO memory | 294 | * IO memory |
@@ -308,8 +307,7 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | |||
308 | 307 | ||
309 | static void | 308 | static void |
310 | bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, | 309 | bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, |
311 | struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, | 310 | struct bfa_iocfc_cfg_s *cfg, struct bfa_pcidev_s *pcidev) |
312 | struct bfa_pcidev_s *pcidev) | ||
313 | { | 311 | { |
314 | struct bfa_fcpim_s *fcpim = &fcp->fcpim; | 312 | struct bfa_fcpim_s *fcpim = &fcp->fcpim; |
315 | struct bfa_s *bfa = fcp->bfa; | 313 | struct bfa_s *bfa = fcp->bfa; |
@@ -328,9 +326,9 @@ bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, | |||
328 | fcpim->profile_comp = NULL; | 326 | fcpim->profile_comp = NULL; |
329 | fcpim->profile_start = NULL; | 327 | fcpim->profile_start = NULL; |
330 | 328 | ||
331 | bfa_itnim_attach(fcpim, meminfo); | 329 | bfa_itnim_attach(fcpim); |
332 | bfa_tskim_attach(fcpim, meminfo); | 330 | bfa_tskim_attach(fcpim); |
333 | bfa_ioim_attach(fcpim, meminfo); | 331 | bfa_ioim_attach(fcpim); |
334 | } | 332 | } |
335 | 333 | ||
336 | static void | 334 | static void |
@@ -972,8 +970,7 @@ bfa_itnim_tskdone(struct bfa_itnim_s *itnim) | |||
972 | } | 970 | } |
973 | 971 | ||
974 | void | 972 | void |
975 | bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 973 | bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len) |
976 | u32 *dm_len) | ||
977 | { | 974 | { |
978 | /* | 975 | /* |
979 | * ITN memory | 976 | * ITN memory |
@@ -982,15 +979,16 @@ bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | |||
982 | } | 979 | } |
983 | 980 | ||
984 | void | 981 | void |
985 | bfa_itnim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 982 | bfa_itnim_attach(struct bfa_fcpim_s *fcpim) |
986 | { | 983 | { |
987 | struct bfa_s *bfa = fcpim->bfa; | 984 | struct bfa_s *bfa = fcpim->bfa; |
985 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
988 | struct bfa_itnim_s *itnim; | 986 | struct bfa_itnim_s *itnim; |
989 | int i, j; | 987 | int i, j; |
990 | 988 | ||
991 | INIT_LIST_HEAD(&fcpim->itnim_q); | 989 | INIT_LIST_HEAD(&fcpim->itnim_q); |
992 | 990 | ||
993 | itnim = (struct bfa_itnim_s *) bfa_meminfo_kva(minfo); | 991 | itnim = (struct bfa_itnim_s *) bfa_mem_kva_curp(fcp); |
994 | fcpim->itnim_arr = itnim; | 992 | fcpim->itnim_arr = itnim; |
995 | 993 | ||
996 | for (i = 0; i < fcpim->num_itnims; i++, itnim++) { | 994 | for (i = 0; i < fcpim->num_itnims; i++, itnim++) { |
@@ -1012,7 +1010,7 @@ bfa_itnim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | |||
1012 | bfa_sm_set_state(itnim, bfa_itnim_sm_uninit); | 1010 | bfa_sm_set_state(itnim, bfa_itnim_sm_uninit); |
1013 | } | 1011 | } |
1014 | 1012 | ||
1015 | bfa_meminfo_kva(minfo) = (u8 *) itnim; | 1013 | bfa_mem_kva_curp(fcp) = (u8 *) itnim; |
1016 | } | 1014 | } |
1017 | 1015 | ||
1018 | void | 1016 | void |
@@ -2345,22 +2343,23 @@ bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov) | |||
2345 | * Memory allocation and initialization. | 2343 | * Memory allocation and initialization. |
2346 | */ | 2344 | */ |
2347 | void | 2345 | void |
2348 | bfa_ioim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 2346 | bfa_ioim_attach(struct bfa_fcpim_s *fcpim) |
2349 | { | 2347 | { |
2350 | struct bfa_ioim_s *ioim; | 2348 | struct bfa_ioim_s *ioim; |
2349 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
2351 | struct bfa_ioim_sp_s *iosp; | 2350 | struct bfa_ioim_sp_s *iosp; |
2352 | u16 i; | 2351 | u16 i; |
2353 | 2352 | ||
2354 | /* | 2353 | /* |
2355 | * claim memory first | 2354 | * claim memory first |
2356 | */ | 2355 | */ |
2357 | ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo); | 2356 | ioim = (struct bfa_ioim_s *) bfa_mem_kva_curp(fcp); |
2358 | fcpim->ioim_arr = ioim; | 2357 | fcpim->ioim_arr = ioim; |
2359 | bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs); | 2358 | bfa_mem_kva_curp(fcp) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs); |
2360 | 2359 | ||
2361 | iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo); | 2360 | iosp = (struct bfa_ioim_sp_s *) bfa_mem_kva_curp(fcp); |
2362 | fcpim->ioim_sp_arr = iosp; | 2361 | fcpim->ioim_sp_arr = iosp; |
2363 | bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs); | 2362 | bfa_mem_kva_curp(fcp) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs); |
2364 | 2363 | ||
2365 | /* | 2364 | /* |
2366 | * Initialize ioim free queues | 2365 | * Initialize ioim free queues |
@@ -3109,15 +3108,16 @@ bfa_tskim_cleanup(struct bfa_tskim_s *tskim) | |||
3109 | * Memory allocation and initialization. | 3108 | * Memory allocation and initialization. |
3110 | */ | 3109 | */ |
3111 | void | 3110 | void |
3112 | bfa_tskim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 3111 | bfa_tskim_attach(struct bfa_fcpim_s *fcpim) |
3113 | { | 3112 | { |
3114 | struct bfa_tskim_s *tskim; | 3113 | struct bfa_tskim_s *tskim; |
3114 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
3115 | u16 i; | 3115 | u16 i; |
3116 | 3116 | ||
3117 | INIT_LIST_HEAD(&fcpim->tskim_free_q); | 3117 | INIT_LIST_HEAD(&fcpim->tskim_free_q); |
3118 | INIT_LIST_HEAD(&fcpim->tskim_unused_q); | 3118 | INIT_LIST_HEAD(&fcpim->tskim_unused_q); |
3119 | 3119 | ||
3120 | tskim = (struct bfa_tskim_s *) bfa_meminfo_kva(minfo); | 3120 | tskim = (struct bfa_tskim_s *) bfa_mem_kva_curp(fcp); |
3121 | fcpim->tskim_arr = tskim; | 3121 | fcpim->tskim_arr = tskim; |
3122 | 3122 | ||
3123 | for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) { | 3123 | for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) { |
@@ -3136,7 +3136,7 @@ bfa_tskim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | |||
3136 | list_add_tail(&tskim->qe, &fcpim->tskim_free_q); | 3136 | list_add_tail(&tskim->qe, &fcpim->tskim_free_q); |
3137 | } | 3137 | } |
3138 | 3138 | ||
3139 | bfa_meminfo_kva(minfo) = (u8 *) tskim; | 3139 | bfa_mem_kva_curp(fcp) = (u8 *) tskim; |
3140 | } | 3140 | } |
3141 | 3141 | ||
3142 | void | 3142 | void |
@@ -3233,9 +3233,14 @@ bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw) | |||
3233 | BFA_MODULE(fcp); | 3233 | BFA_MODULE(fcp); |
3234 | 3234 | ||
3235 | static void | 3235 | static void |
3236 | bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, u32 *dm_len) | 3236 | bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
3237 | struct bfa_s *bfa) | ||
3237 | { | 3238 | { |
3238 | u16 num_io_req; | 3239 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); |
3240 | struct bfa_mem_kva_s *fcp_kva = BFA_MEM_FCP_KVA(bfa); | ||
3241 | struct bfa_mem_dma_s *seg_ptr; | ||
3242 | u16 nsegs, idx, per_seg_ios, num_io_req; | ||
3243 | u32 km_len = 0; | ||
3239 | 3244 | ||
3240 | /* | 3245 | /* |
3241 | * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value. | 3246 | * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value. |
@@ -3261,43 +3266,69 @@ bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, u32 *dm_len) | |||
3261 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX; | 3266 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX; |
3262 | } | 3267 | } |
3263 | 3268 | ||
3264 | bfa_fcpim_meminfo(cfg, km_len, dm_len); | 3269 | bfa_fcpim_meminfo(cfg, &km_len); |
3265 | 3270 | ||
3266 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); | 3271 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); |
3267 | *km_len += num_io_req * sizeof(struct bfa_iotag_s); | 3272 | km_len += num_io_req * sizeof(struct bfa_iotag_s); |
3268 | *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s); | 3273 | km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s); |
3269 | *dm_len += num_io_req * BFI_IOIM_SNSLEN; | 3274 | |
3275 | /* dma memory */ | ||
3276 | nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN); | ||
3277 | per_seg_ios = BFI_MEM_NREQS_SEG(BFI_IOIM_SNSLEN); | ||
3278 | |||
3279 | bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) { | ||
3280 | if (num_io_req >= per_seg_ios) { | ||
3281 | num_io_req -= per_seg_ios; | ||
3282 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
3283 | per_seg_ios * BFI_IOIM_SNSLEN); | ||
3284 | } else | ||
3285 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
3286 | num_io_req * BFI_IOIM_SNSLEN); | ||
3287 | } | ||
3288 | |||
3289 | /* kva memory */ | ||
3290 | bfa_mem_kva_setup(minfo, fcp_kva, km_len); | ||
3270 | } | 3291 | } |
3271 | 3292 | ||
3272 | static void | 3293 | static void |
3273 | bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 3294 | bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
3274 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 3295 | struct bfa_pcidev_s *pcidev) |
3275 | { | 3296 | { |
3276 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); | 3297 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); |
3277 | u32 snsbufsz; | 3298 | struct bfa_mem_dma_s *seg_ptr; |
3299 | u16 idx, nsegs, num_io_req; | ||
3278 | 3300 | ||
3279 | fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs; | 3301 | fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs; |
3280 | fcp->num_fwtio_reqs = cfg->fwcfg.num_fwtio_reqs; | 3302 | fcp->num_fwtio_reqs = cfg->fwcfg.num_fwtio_reqs; |
3281 | fcp->num_itns = cfg->fwcfg.num_rports; | 3303 | fcp->num_itns = cfg->fwcfg.num_rports; |
3282 | fcp->bfa = bfa; | 3304 | fcp->bfa = bfa; |
3283 | 3305 | ||
3284 | snsbufsz = (fcp->num_ioim_reqs + fcp->num_fwtio_reqs) * BFI_IOIM_SNSLEN; | 3306 | /* |
3285 | fcp->snsbase.pa = bfa_meminfo_dma_phys(meminfo); | 3307 | * Setup the pool of snsbase addr's, that is passed to fw as |
3286 | bfa_meminfo_dma_phys(meminfo) += snsbufsz; | 3308 | * part of bfi_iocfc_cfg_s. |
3309 | */ | ||
3310 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); | ||
3311 | nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN); | ||
3312 | |||
3313 | bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) { | ||
3314 | |||
3315 | if (!bfa_mem_dma_virt(seg_ptr)) | ||
3316 | break; | ||
3317 | |||
3318 | fcp->snsbase[idx].pa = bfa_mem_dma_phys(seg_ptr); | ||
3319 | fcp->snsbase[idx].kva = bfa_mem_dma_virt(seg_ptr); | ||
3320 | bfa_iocfc_set_snsbase(bfa, idx, fcp->snsbase[idx].pa); | ||
3321 | } | ||
3287 | 3322 | ||
3288 | fcp->snsbase.kva = bfa_meminfo_dma_virt(meminfo); | 3323 | bfa_fcpim_attach(fcp, bfad, cfg, pcidev); |
3289 | bfa_meminfo_dma_virt(meminfo) += snsbufsz; | ||
3290 | bfa_iocfc_set_snsbase(bfa, fcp->snsbase.pa); | ||
3291 | 3324 | ||
3292 | bfa_fcpim_attach(fcp, bfad, cfg, meminfo, pcidev); | 3325 | bfa_iotag_attach(fcp); |
3293 | 3326 | ||
3294 | fcp->itn_arr = (struct bfa_itn_s *) bfa_meminfo_kva(meminfo); | 3327 | fcp->itn_arr = (struct bfa_itn_s *) bfa_mem_kva_curp(fcp); |
3295 | bfa_meminfo_kva(meminfo) = (u8 *)fcp->itn_arr + | 3328 | bfa_mem_kva_curp(fcp) = (u8 *)fcp->itn_arr + |
3296 | (fcp->num_itns * sizeof(struct bfa_itn_s)); | 3329 | (fcp->num_itns * sizeof(struct bfa_itn_s)); |
3297 | memset(fcp->itn_arr, 0, | 3330 | memset(fcp->itn_arr, 0, |
3298 | (fcp->num_itns * sizeof(struct bfa_itn_s))); | 3331 | (fcp->num_itns * sizeof(struct bfa_itn_s))); |
3299 | |||
3300 | bfa_iotag_attach(fcp, meminfo); | ||
3301 | } | 3332 | } |
3302 | 3333 | ||
3303 | static void | 3334 | static void |
@@ -3370,12 +3401,12 @@ bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m) | |||
3370 | } | 3401 | } |
3371 | 3402 | ||
3372 | void | 3403 | void |
3373 | bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo) | 3404 | bfa_iotag_attach(struct bfa_fcp_mod_s *fcp) |
3374 | { | 3405 | { |
3375 | struct bfa_iotag_s *iotag; | 3406 | struct bfa_iotag_s *iotag; |
3376 | u16 num_io_req, i; | 3407 | u16 num_io_req, i; |
3377 | 3408 | ||
3378 | iotag = (struct bfa_iotag_s *) bfa_meminfo_kva(minfo); | 3409 | iotag = (struct bfa_iotag_s *) bfa_mem_kva_curp(fcp); |
3379 | fcp->iotag_arr = iotag; | 3410 | fcp->iotag_arr = iotag; |
3380 | 3411 | ||
3381 | INIT_LIST_HEAD(&fcp->iotag_ioim_free_q); | 3412 | INIT_LIST_HEAD(&fcp->iotag_ioim_free_q); |
@@ -3392,5 +3423,5 @@ bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo) | |||
3392 | list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q); | 3423 | list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q); |
3393 | } | 3424 | } |
3394 | 3425 | ||
3395 | bfa_meminfo_kva(minfo) = (u8 *) iotag; | 3426 | bfa_mem_kva_curp(fcp) = (u8 *) iotag; |
3396 | } | 3427 | } |
diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h index bc6b294426ec..ccb7c6ebebf9 100644 --- a/drivers/scsi/bfa/bfa_fcpim.h +++ b/drivers/scsi/bfa/bfa_fcpim.h | |||
@@ -25,8 +25,8 @@ | |||
25 | #include "bfa_cs.h" | 25 | #include "bfa_cs.h" |
26 | 26 | ||
27 | /* FCP module related definitions */ | 27 | /* FCP module related definitions */ |
28 | #define BFA_IO_MAX 2000 | 28 | #define BFA_IO_MAX BFI_IO_MAX |
29 | #define BFA_FWTIO_MAX 0 | 29 | #define BFA_FWTIO_MAX 2000 |
30 | 30 | ||
31 | struct bfa_fcp_mod_s; | 31 | struct bfa_fcp_mod_s; |
32 | struct bfa_iotag_s { | 32 | struct bfa_iotag_s { |
@@ -41,16 +41,17 @@ struct bfa_itn_s { | |||
41 | void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport, | 41 | void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport, |
42 | void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m)); | 42 | void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m)); |
43 | void bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m); | 43 | void bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m); |
44 | void bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo); | 44 | void bfa_iotag_attach(struct bfa_fcp_mod_s *fcp); |
45 | void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw); | 45 | void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw); |
46 | 46 | ||
47 | #define BFA_FCP_MOD(_hal) (&(_hal)->modules.fcp_mod) | 47 | #define BFA_FCP_MOD(_hal) (&(_hal)->modules.fcp_mod) |
48 | #define BFA_MEM_FCP_KVA(__bfa) (&(BFA_FCP_MOD(__bfa)->kva_seg)) | ||
48 | #define BFA_IOTAG_FROM_TAG(_fcp, _tag) \ | 49 | #define BFA_IOTAG_FROM_TAG(_fcp, _tag) \ |
49 | (&(_fcp)->iotag_arr[(_tag & BFA_IOIM_IOTAG_MASK)]) | 50 | (&(_fcp)->iotag_arr[(_tag & BFA_IOIM_IOTAG_MASK)]) |
50 | #define BFA_ITN_FROM_TAG(_fcp, _tag) \ | 51 | #define BFA_ITN_FROM_TAG(_fcp, _tag) \ |
51 | ((_fcp)->itn_arr + ((_tag) & ((_fcp)->num_itns - 1))) | 52 | ((_fcp)->itn_arr + ((_tag) & ((_fcp)->num_itns - 1))) |
52 | #define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \ | 53 | #define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \ |
53 | (((u8 *)(_fcp)->snsbase.kva) + (_tag * BFI_IOIM_SNSLEN)) | 54 | bfa_mem_get_dmabuf_kva(_fcp, _tag, BFI_IOIM_SNSLEN) |
54 | 55 | ||
55 | #define BFA_ITNIM_MIN 32 | 56 | #define BFA_ITNIM_MIN 32 |
56 | #define BFA_ITNIM_MAX 1024 | 57 | #define BFA_ITNIM_MAX 1024 |
@@ -130,6 +131,9 @@ struct bfa_fcpim_s { | |||
130 | bfa_fcpim_profile_t profile_start; | 131 | bfa_fcpim_profile_t profile_start; |
131 | }; | 132 | }; |
132 | 133 | ||
134 | /* Max FCP dma segs required */ | ||
135 | #define BFA_FCP_DMA_SEGS BFI_IOIM_SNSBUF_SEGS | ||
136 | |||
133 | struct bfa_fcp_mod_s { | 137 | struct bfa_fcp_mod_s { |
134 | struct bfa_s *bfa; | 138 | struct bfa_s *bfa; |
135 | struct list_head iotag_ioim_free_q; /* free IO resources */ | 139 | struct list_head iotag_ioim_free_q; /* free IO resources */ |
@@ -140,8 +144,10 @@ struct bfa_fcp_mod_s { | |||
140 | int num_ioim_reqs; | 144 | int num_ioim_reqs; |
141 | int num_fwtio_reqs; | 145 | int num_fwtio_reqs; |
142 | int num_itns; | 146 | int num_itns; |
143 | struct bfa_dma_s snsbase; | 147 | struct bfa_dma_s snsbase[BFA_FCP_DMA_SEGS]; |
144 | struct bfa_fcpim_s fcpim; | 148 | struct bfa_fcpim_s fcpim; |
149 | struct bfa_mem_dma_s dma_seg[BFA_FCP_DMA_SEGS]; | ||
150 | struct bfa_mem_kva_s kva_seg; | ||
145 | }; | 151 | }; |
146 | 152 | ||
147 | /* | 153 | /* |
@@ -256,8 +262,7 @@ bfa_ioim_maxretry_reached(struct bfa_ioim_s *ioim) | |||
256 | /* | 262 | /* |
257 | * function prototypes | 263 | * function prototypes |
258 | */ | 264 | */ |
259 | void bfa_ioim_attach(struct bfa_fcpim_s *fcpim, | 265 | void bfa_ioim_attach(struct bfa_fcpim_s *fcpim); |
260 | struct bfa_meminfo_s *minfo); | ||
261 | void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); | 266 | void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
262 | void bfa_ioim_good_comp_isr(struct bfa_s *bfa, | 267 | void bfa_ioim_good_comp_isr(struct bfa_s *bfa, |
263 | struct bfi_msg_s *msg); | 268 | struct bfi_msg_s *msg); |
@@ -267,18 +272,15 @@ void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim, | |||
267 | void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim); | 272 | void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim); |
268 | void bfa_ioim_tov(struct bfa_ioim_s *ioim); | 273 | void bfa_ioim_tov(struct bfa_ioim_s *ioim); |
269 | 274 | ||
270 | void bfa_tskim_attach(struct bfa_fcpim_s *fcpim, | 275 | void bfa_tskim_attach(struct bfa_fcpim_s *fcpim); |
271 | struct bfa_meminfo_s *minfo); | ||
272 | void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); | 276 | void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
273 | void bfa_tskim_iodone(struct bfa_tskim_s *tskim); | 277 | void bfa_tskim_iodone(struct bfa_tskim_s *tskim); |
274 | void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim); | 278 | void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim); |
275 | void bfa_tskim_cleanup(struct bfa_tskim_s *tskim); | 279 | void bfa_tskim_cleanup(struct bfa_tskim_s *tskim); |
276 | void bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw); | 280 | void bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw); |
277 | 281 | ||
278 | void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 282 | void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len); |
279 | u32 *dm_len); | 283 | void bfa_itnim_attach(struct bfa_fcpim_s *fcpim); |
280 | void bfa_itnim_attach(struct bfa_fcpim_s *fcpim, | ||
281 | struct bfa_meminfo_s *minfo); | ||
282 | void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim); | 284 | void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim); |
283 | void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); | 285 | void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
284 | void bfa_itnim_iodone(struct bfa_itnim_s *itnim); | 286 | void bfa_itnim_iodone(struct bfa_itnim_s *itnim); |
diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h index 1055ca9f6043..83c3f2fc3411 100644 --- a/drivers/scsi/bfa/bfa_ioc.h +++ b/drivers/scsi/bfa/bfa_ioc.h | |||
@@ -85,6 +85,68 @@ struct bfa_sge_s { | |||
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * BFA memory resources | ||
89 | */ | ||
90 | struct bfa_mem_dma_s { | ||
91 | struct list_head qe; /* Queue of DMA elements */ | ||
92 | u32 mem_len; /* Total Length in Bytes */ | ||
93 | u8 *kva; /* kernel virtual address */ | ||
94 | u64 dma; /* dma address if DMA memory */ | ||
95 | u8 *kva_curp; /* kva allocation cursor */ | ||
96 | u64 dma_curp; /* dma allocation cursor */ | ||
97 | }; | ||
98 | #define bfa_mem_dma_t struct bfa_mem_dma_s | ||
99 | |||
100 | struct bfa_mem_kva_s { | ||
101 | struct list_head qe; /* Queue of KVA elements */ | ||
102 | u32 mem_len; /* Total Length in Bytes */ | ||
103 | u8 *kva; /* kernel virtual address */ | ||
104 | u8 *kva_curp; /* kva allocation cursor */ | ||
105 | }; | ||
106 | #define bfa_mem_kva_t struct bfa_mem_kva_s | ||
107 | |||
108 | struct bfa_meminfo_s { | ||
109 | struct bfa_mem_dma_s dma_info; | ||
110 | struct bfa_mem_kva_s kva_info; | ||
111 | }; | ||
112 | |||
113 | /* BFA memory segment setup macros */ | ||
114 | #define bfa_mem_dma_setup(_meminfo, _dm_ptr, _seg_sz) do { \ | ||
115 | ((bfa_mem_dma_t *)(_dm_ptr))->mem_len = (_seg_sz); \ | ||
116 | if (_seg_sz) \ | ||
117 | list_add_tail(&((bfa_mem_dma_t *)_dm_ptr)->qe, \ | ||
118 | &(_meminfo)->dma_info.qe); \ | ||
119 | } while (0) | ||
120 | |||
121 | #define bfa_mem_kva_setup(_meminfo, _kva_ptr, _seg_sz) do { \ | ||
122 | ((bfa_mem_kva_t *)(_kva_ptr))->mem_len = (_seg_sz); \ | ||
123 | if (_seg_sz) \ | ||
124 | list_add_tail(&((bfa_mem_kva_t *)_kva_ptr)->qe, \ | ||
125 | &(_meminfo)->kva_info.qe); \ | ||
126 | } while (0) | ||
127 | |||
128 | /* BFA dma memory segments iterator */ | ||
129 | #define bfa_mem_dma_sptr(_mod, _i) (&(_mod)->dma_seg[(_i)]) | ||
130 | #define bfa_mem_dma_seg_iter(_mod, _sptr, _nr, _i) \ | ||
131 | for (_i = 0, _sptr = bfa_mem_dma_sptr(_mod, _i); _i < (_nr); \ | ||
132 | _i++, _sptr = bfa_mem_dma_sptr(_mod, _i)) | ||
133 | |||
134 | #define bfa_mem_kva_curp(_mod) ((_mod)->kva_seg.kva_curp) | ||
135 | #define bfa_mem_dma_virt(_sptr) ((_sptr)->kva_curp) | ||
136 | #define bfa_mem_dma_phys(_sptr) ((_sptr)->dma_curp) | ||
137 | #define bfa_mem_dma_len(_sptr) ((_sptr)->mem_len) | ||
138 | |||
139 | /* Get the corresponding dma buf kva for a req - from the tag */ | ||
140 | #define bfa_mem_get_dmabuf_kva(_mod, _tag, _rqsz) \ | ||
141 | (((u8 *)(_mod)->dma_seg[BFI_MEM_SEG_FROM_TAG(_tag, _rqsz)].kva_curp) +\ | ||
142 | BFI_MEM_SEG_REQ_OFFSET(_tag, _rqsz) * (_rqsz)) | ||
143 | |||
144 | /* Get the corresponding dma buf pa for a req - from the tag */ | ||
145 | #define bfa_mem_get_dmabuf_pa(_mod, _tag, _rqsz) \ | ||
146 | ((_mod)->dma_seg[BFI_MEM_SEG_FROM_TAG(_tag, _rqsz)].dma_curp + \ | ||
147 | BFI_MEM_SEG_REQ_OFFSET(_tag, _rqsz) * (_rqsz)) | ||
148 | |||
149 | /* | ||
88 | * PCI device information required by IOC | 150 | * PCI device information required by IOC |
89 | */ | 151 | */ |
90 | struct bfa_pcidev_s { | 152 | struct bfa_pcidev_s { |
@@ -301,7 +363,9 @@ struct bfa_ablk_s { | |||
301 | bfa_ablk_cbfn_t cbfn; | 363 | bfa_ablk_cbfn_t cbfn; |
302 | void *cbarg; | 364 | void *cbarg; |
303 | struct bfa_ioc_notify_s ioc_notify; | 365 | struct bfa_ioc_notify_s ioc_notify; |
366 | struct bfa_mem_dma_s ablk_dma; | ||
304 | }; | 367 | }; |
368 | #define BFA_MEM_ABLK_DMA(__bfa) (&((__bfa)->modules.ablk.ablk_dma)) | ||
305 | 369 | ||
306 | #define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func) | 370 | #define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func) |
307 | #define bfa_ioc_devid(__ioc) ((__ioc)->pcidev.device_id) | 371 | #define bfa_ioc_devid(__ioc) ((__ioc)->pcidev.device_id) |
diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h index 7311169089a9..e27fde8c6f2f 100644 --- a/drivers/scsi/bfa/bfa_modules.h +++ b/drivers/scsi/bfa/bfa_modules.h | |||
@@ -57,11 +57,11 @@ enum { | |||
57 | */ | 57 | */ |
58 | #define BFA_MODULE(__mod) \ | 58 | #define BFA_MODULE(__mod) \ |
59 | static void bfa_ ## __mod ## _meminfo( \ | 59 | static void bfa_ ## __mod ## _meminfo( \ |
60 | struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, \ | 60 | struct bfa_iocfc_cfg_s *cfg, \ |
61 | u32 *dm_len); \ | 61 | struct bfa_meminfo_s *meminfo, \ |
62 | struct bfa_s *bfa); \ | ||
62 | static void bfa_ ## __mod ## _attach(struct bfa_s *bfa, \ | 63 | static void bfa_ ## __mod ## _attach(struct bfa_s *bfa, \ |
63 | void *bfad, struct bfa_iocfc_cfg_s *cfg, \ | 64 | void *bfad, struct bfa_iocfc_cfg_s *cfg, \ |
64 | struct bfa_meminfo_s *meminfo, \ | ||
65 | struct bfa_pcidev_s *pcidev); \ | 65 | struct bfa_pcidev_s *pcidev); \ |
66 | static void bfa_ ## __mod ## _detach(struct bfa_s *bfa); \ | 66 | static void bfa_ ## __mod ## _detach(struct bfa_s *bfa); \ |
67 | static void bfa_ ## __mod ## _start(struct bfa_s *bfa); \ | 67 | static void bfa_ ## __mod ## _start(struct bfa_s *bfa); \ |
@@ -87,11 +87,11 @@ enum { | |||
87 | * can leave entry points as NULL) | 87 | * can leave entry points as NULL) |
88 | */ | 88 | */ |
89 | struct bfa_module_s { | 89 | struct bfa_module_s { |
90 | void (*meminfo) (struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 90 | void (*meminfo) (struct bfa_iocfc_cfg_s *cfg, |
91 | u32 *dm_len); | 91 | struct bfa_meminfo_s *meminfo, |
92 | struct bfa_s *bfa); | ||
92 | void (*attach) (struct bfa_s *bfa, void *bfad, | 93 | void (*attach) (struct bfa_s *bfa, void *bfad, |
93 | struct bfa_iocfc_cfg_s *cfg, | 94 | struct bfa_iocfc_cfg_s *cfg, |
94 | struct bfa_meminfo_s *meminfo, | ||
95 | struct bfa_pcidev_s *pcidev); | 95 | struct bfa_pcidev_s *pcidev); |
96 | void (*detach) (struct bfa_s *bfa); | 96 | void (*detach) (struct bfa_s *bfa); |
97 | void (*start) (struct bfa_s *bfa); | 97 | void (*start) (struct bfa_s *bfa); |
diff --git a/drivers/scsi/bfa/bfa_port.h b/drivers/scsi/bfa/bfa_port.h index 1587a6f08b26..b8bdc54aaeb4 100644 --- a/drivers/scsi/bfa/bfa_port.h +++ b/drivers/scsi/bfa/bfa_port.h | |||
@@ -45,8 +45,11 @@ struct bfa_port_s { | |||
45 | bfa_status_t endis_status; | 45 | bfa_status_t endis_status; |
46 | struct bfa_ioc_notify_s ioc_notify; | 46 | struct bfa_ioc_notify_s ioc_notify; |
47 | bfa_boolean_t pbc_disabled; | 47 | bfa_boolean_t pbc_disabled; |
48 | struct bfa_mem_dma_s port_dma; | ||
48 | }; | 49 | }; |
49 | 50 | ||
51 | #define BFA_MEM_PORT_DMA(__bfa) (&((__bfa)->modules.port.port_dma)) | ||
52 | |||
50 | void bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, | 53 | void bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, |
51 | void *dev, struct bfa_trc_mod_s *trcmod); | 54 | void *dev, struct bfa_trc_mod_s *trcmod); |
52 | void bfa_port_notify(void *arg, enum bfa_ioc_event_e event); | 55 | void bfa_port_notify(void *arg, enum bfa_ioc_event_e event); |
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c index cfc0b09465ec..4dcf9b9a34d0 100644 --- a/drivers/scsi/bfa/bfa_svc.c +++ b/drivers/scsi/bfa/bfa_svc.c | |||
@@ -113,11 +113,10 @@ static void bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, | |||
113 | /* | 113 | /* |
114 | * forward declarations for LPS functions | 114 | * forward declarations for LPS functions |
115 | */ | 115 | */ |
116 | static void bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, | 116 | static void bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, |
117 | u32 *dm_len); | 117 | struct bfa_meminfo_s *minfo, struct bfa_s *bfa); |
118 | static void bfa_lps_attach(struct bfa_s *bfa, void *bfad, | 118 | static void bfa_lps_attach(struct bfa_s *bfa, void *bfad, |
119 | struct bfa_iocfc_cfg_s *cfg, | 119 | struct bfa_iocfc_cfg_s *cfg, |
120 | struct bfa_meminfo_s *meminfo, | ||
121 | struct bfa_pcidev_s *pcidev); | 120 | struct bfa_pcidev_s *pcidev); |
122 | static void bfa_lps_detach(struct bfa_s *bfa); | 121 | static void bfa_lps_detach(struct bfa_s *bfa); |
123 | static void bfa_lps_start(struct bfa_s *bfa); | 122 | static void bfa_lps_start(struct bfa_s *bfa); |
@@ -431,47 +430,12 @@ bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid, | |||
431 | */ | 430 | */ |
432 | 431 | ||
433 | static void | 432 | static void |
434 | claim_fcxp_req_rsp_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi) | 433 | claim_fcxps_mem(struct bfa_fcxp_mod_s *mod) |
435 | { | ||
436 | u8 *dm_kva = NULL; | ||
437 | u64 dm_pa; | ||
438 | u32 buf_pool_sz; | ||
439 | |||
440 | dm_kva = bfa_meminfo_dma_virt(mi); | ||
441 | dm_pa = bfa_meminfo_dma_phys(mi); | ||
442 | |||
443 | buf_pool_sz = mod->req_pld_sz * mod->num_fcxps; | ||
444 | |||
445 | /* | ||
446 | * Initialize the fcxp req payload list | ||
447 | */ | ||
448 | mod->req_pld_list_kva = dm_kva; | ||
449 | mod->req_pld_list_pa = dm_pa; | ||
450 | dm_kva += buf_pool_sz; | ||
451 | dm_pa += buf_pool_sz; | ||
452 | memset(mod->req_pld_list_kva, 0, buf_pool_sz); | ||
453 | |||
454 | /* | ||
455 | * Initialize the fcxp rsp payload list | ||
456 | */ | ||
457 | buf_pool_sz = mod->rsp_pld_sz * mod->num_fcxps; | ||
458 | mod->rsp_pld_list_kva = dm_kva; | ||
459 | mod->rsp_pld_list_pa = dm_pa; | ||
460 | dm_kva += buf_pool_sz; | ||
461 | dm_pa += buf_pool_sz; | ||
462 | memset(mod->rsp_pld_list_kva, 0, buf_pool_sz); | ||
463 | |||
464 | bfa_meminfo_dma_virt(mi) = dm_kva; | ||
465 | bfa_meminfo_dma_phys(mi) = dm_pa; | ||
466 | } | ||
467 | |||
468 | static void | ||
469 | claim_fcxps_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi) | ||
470 | { | 434 | { |
471 | u16 i; | 435 | u16 i; |
472 | struct bfa_fcxp_s *fcxp; | 436 | struct bfa_fcxp_s *fcxp; |
473 | 437 | ||
474 | fcxp = (struct bfa_fcxp_s *) bfa_meminfo_kva(mi); | 438 | fcxp = (struct bfa_fcxp_s *) bfa_mem_kva_curp(mod); |
475 | memset(fcxp, 0, sizeof(struct bfa_fcxp_s) * mod->num_fcxps); | 439 | memset(fcxp, 0, sizeof(struct bfa_fcxp_s) * mod->num_fcxps); |
476 | 440 | ||
477 | INIT_LIST_HEAD(&mod->fcxp_free_q); | 441 | INIT_LIST_HEAD(&mod->fcxp_free_q); |
@@ -491,40 +455,53 @@ claim_fcxps_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi) | |||
491 | fcxp = fcxp + 1; | 455 | fcxp = fcxp + 1; |
492 | } | 456 | } |
493 | 457 | ||
494 | bfa_meminfo_kva(mi) = (void *)fcxp; | 458 | bfa_mem_kva_curp(mod) = (void *)fcxp; |
495 | } | 459 | } |
496 | 460 | ||
497 | static void | 461 | static void |
498 | bfa_fcxp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, | 462 | bfa_fcxp_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
499 | u32 *dm_len) | 463 | struct bfa_s *bfa) |
500 | { | 464 | { |
501 | u16 num_fcxp_reqs = cfg->fwcfg.num_fcxp_reqs; | 465 | struct bfa_fcxp_mod_s *fcxp_mod = BFA_FCXP_MOD(bfa); |
466 | struct bfa_mem_kva_s *fcxp_kva = BFA_MEM_FCXP_KVA(bfa); | ||
467 | struct bfa_mem_dma_s *seg_ptr; | ||
468 | u16 nsegs, idx, per_seg_fcxp; | ||
469 | u16 num_fcxps = cfg->fwcfg.num_fcxp_reqs; | ||
470 | u32 per_fcxp_sz; | ||
502 | 471 | ||
503 | if (num_fcxp_reqs == 0) | 472 | if (num_fcxps == 0) |
504 | return; | 473 | return; |
505 | 474 | ||
506 | /* | ||
507 | * Account for req/rsp payload | ||
508 | */ | ||
509 | *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs; | ||
510 | if (cfg->drvcfg.min_cfg) | 475 | if (cfg->drvcfg.min_cfg) |
511 | *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs; | 476 | per_fcxp_sz = 2 * BFA_FCXP_MAX_IBUF_SZ; |
512 | else | 477 | else |
513 | *dm_len += BFA_FCXP_MAX_LBUF_SZ * num_fcxp_reqs; | 478 | per_fcxp_sz = BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ; |
514 | 479 | ||
515 | /* | 480 | /* dma memory */ |
516 | * Account for fcxp structs | 481 | nsegs = BFI_MEM_DMA_NSEGS(num_fcxps, per_fcxp_sz); |
517 | */ | 482 | per_seg_fcxp = BFI_MEM_NREQS_SEG(per_fcxp_sz); |
518 | *ndm_len += sizeof(struct bfa_fcxp_s) * num_fcxp_reqs; | 483 | |
484 | bfa_mem_dma_seg_iter(fcxp_mod, seg_ptr, nsegs, idx) { | ||
485 | if (num_fcxps >= per_seg_fcxp) { | ||
486 | num_fcxps -= per_seg_fcxp; | ||
487 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
488 | per_seg_fcxp * per_fcxp_sz); | ||
489 | } else | ||
490 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
491 | num_fcxps * per_fcxp_sz); | ||
492 | } | ||
493 | |||
494 | /* kva memory */ | ||
495 | bfa_mem_kva_setup(minfo, fcxp_kva, | ||
496 | cfg->fwcfg.num_fcxp_reqs * sizeof(struct bfa_fcxp_s)); | ||
519 | } | 497 | } |
520 | 498 | ||
521 | static void | 499 | static void |
522 | bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 500 | bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
523 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 501 | struct bfa_pcidev_s *pcidev) |
524 | { | 502 | { |
525 | struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa); | 503 | struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa); |
526 | 504 | ||
527 | memset(mod, 0, sizeof(struct bfa_fcxp_mod_s)); | ||
528 | mod->bfa = bfa; | 505 | mod->bfa = bfa; |
529 | mod->num_fcxps = cfg->fwcfg.num_fcxp_reqs; | 506 | mod->num_fcxps = cfg->fwcfg.num_fcxp_reqs; |
530 | 507 | ||
@@ -537,8 +514,7 @@ bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
537 | 514 | ||
538 | INIT_LIST_HEAD(&mod->wait_q); | 515 | INIT_LIST_HEAD(&mod->wait_q); |
539 | 516 | ||
540 | claim_fcxp_req_rsp_mem(mod, meminfo); | 517 | claim_fcxps_mem(mod); |
541 | claim_fcxps_mem(mod, meminfo); | ||
542 | } | 518 | } |
543 | 519 | ||
544 | static void | 520 | static void |
@@ -962,8 +938,8 @@ bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp) | |||
962 | void *reqbuf; | 938 | void *reqbuf; |
963 | 939 | ||
964 | WARN_ON(fcxp->use_ireqbuf != 1); | 940 | WARN_ON(fcxp->use_ireqbuf != 1); |
965 | reqbuf = ((u8 *)mod->req_pld_list_kva) + | 941 | reqbuf = bfa_mem_get_dmabuf_kva(mod, fcxp->fcxp_tag, |
966 | fcxp->fcxp_tag * mod->req_pld_sz; | 942 | mod->req_pld_sz + mod->rsp_pld_sz); |
967 | return reqbuf; | 943 | return reqbuf; |
968 | } | 944 | } |
969 | 945 | ||
@@ -986,13 +962,15 @@ void * | |||
986 | bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp) | 962 | bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp) |
987 | { | 963 | { |
988 | struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod; | 964 | struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod; |
989 | void *rspbuf; | 965 | void *fcxp_buf; |
990 | 966 | ||
991 | WARN_ON(fcxp->use_irspbuf != 1); | 967 | WARN_ON(fcxp->use_irspbuf != 1); |
992 | 968 | ||
993 | rspbuf = ((u8 *)mod->rsp_pld_list_kva) + | 969 | fcxp_buf = bfa_mem_get_dmabuf_kva(mod, fcxp->fcxp_tag, |
994 | fcxp->fcxp_tag * mod->rsp_pld_sz; | 970 | mod->req_pld_sz + mod->rsp_pld_sz); |
995 | return rspbuf; | 971 | |
972 | /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */ | ||
973 | return ((u8 *) fcxp_buf) + mod->req_pld_sz; | ||
996 | } | 974 | } |
997 | 975 | ||
998 | /* | 976 | /* |
@@ -1473,13 +1451,17 @@ bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event event) | |||
1473 | * return memory requirement | 1451 | * return memory requirement |
1474 | */ | 1452 | */ |
1475 | static void | 1453 | static void |
1476 | bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, | 1454 | bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
1477 | u32 *dm_len) | 1455 | struct bfa_s *bfa) |
1478 | { | 1456 | { |
1457 | struct bfa_mem_kva_s *lps_kva = BFA_MEM_LPS_KVA(bfa); | ||
1458 | |||
1479 | if (cfg->drvcfg.min_cfg) | 1459 | if (cfg->drvcfg.min_cfg) |
1480 | *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MIN_LPORTS; | 1460 | bfa_mem_kva_setup(minfo, lps_kva, |
1461 | sizeof(struct bfa_lps_s) * BFA_LPS_MIN_LPORTS); | ||
1481 | else | 1462 | else |
1482 | *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MAX_LPORTS; | 1463 | bfa_mem_kva_setup(minfo, lps_kva, |
1464 | sizeof(struct bfa_lps_s) * BFA_LPS_MAX_LPORTS); | ||
1483 | } | 1465 | } |
1484 | 1466 | ||
1485 | /* | 1467 | /* |
@@ -1487,21 +1469,20 @@ bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, | |||
1487 | */ | 1469 | */ |
1488 | static void | 1470 | static void |
1489 | bfa_lps_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 1471 | bfa_lps_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
1490 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 1472 | struct bfa_pcidev_s *pcidev) |
1491 | { | 1473 | { |
1492 | struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa); | 1474 | struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa); |
1493 | struct bfa_lps_s *lps; | 1475 | struct bfa_lps_s *lps; |
1494 | int i; | 1476 | int i; |
1495 | 1477 | ||
1496 | memset(mod, 0, sizeof(struct bfa_lps_mod_s)); | ||
1497 | mod->num_lps = BFA_LPS_MAX_LPORTS; | 1478 | mod->num_lps = BFA_LPS_MAX_LPORTS; |
1498 | if (cfg->drvcfg.min_cfg) | 1479 | if (cfg->drvcfg.min_cfg) |
1499 | mod->num_lps = BFA_LPS_MIN_LPORTS; | 1480 | mod->num_lps = BFA_LPS_MIN_LPORTS; |
1500 | else | 1481 | else |
1501 | mod->num_lps = BFA_LPS_MAX_LPORTS; | 1482 | mod->num_lps = BFA_LPS_MAX_LPORTS; |
1502 | mod->lps_arr = lps = (struct bfa_lps_s *) bfa_meminfo_kva(meminfo); | 1483 | mod->lps_arr = lps = (struct bfa_lps_s *) bfa_mem_kva_curp(mod); |
1503 | 1484 | ||
1504 | bfa_meminfo_kva(meminfo) += mod->num_lps * sizeof(struct bfa_lps_s); | 1485 | bfa_mem_kva_curp(mod) += mod->num_lps * sizeof(struct bfa_lps_s); |
1505 | 1486 | ||
1506 | INIT_LIST_HEAD(&mod->lps_free_q); | 1487 | INIT_LIST_HEAD(&mod->lps_free_q); |
1507 | INIT_LIST_HEAD(&mod->lps_active_q); | 1488 | INIT_LIST_HEAD(&mod->lps_active_q); |
@@ -2829,10 +2810,12 @@ bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_port_linkstate event) | |||
2829 | BFA_CACHELINE_SZ)) | 2810 | BFA_CACHELINE_SZ)) |
2830 | 2811 | ||
2831 | static void | 2812 | static void |
2832 | bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, | 2813 | bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
2833 | u32 *dm_len) | 2814 | struct bfa_s *bfa) |
2834 | { | 2815 | { |
2835 | *dm_len += FCPORT_STATS_DMA_SZ; | 2816 | struct bfa_mem_dma_s *fcport_dma = BFA_MEM_FCPORT_DMA(bfa); |
2817 | |||
2818 | bfa_mem_dma_setup(minfo, fcport_dma, FCPORT_STATS_DMA_SZ); | ||
2836 | } | 2819 | } |
2837 | 2820 | ||
2838 | static void | 2821 | static void |
@@ -2844,23 +2827,14 @@ bfa_fcport_qresume(void *cbarg) | |||
2844 | } | 2827 | } |
2845 | 2828 | ||
2846 | static void | 2829 | static void |
2847 | bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) | 2830 | bfa_fcport_mem_claim(struct bfa_fcport_s *fcport) |
2848 | { | 2831 | { |
2849 | u8 *dm_kva; | 2832 | struct bfa_mem_dma_s *fcport_dma = &fcport->fcport_dma; |
2850 | u64 dm_pa; | ||
2851 | 2833 | ||
2852 | dm_kva = bfa_meminfo_dma_virt(meminfo); | 2834 | fcport->stats_kva = bfa_mem_dma_virt(fcport_dma); |
2853 | dm_pa = bfa_meminfo_dma_phys(meminfo); | 2835 | fcport->stats_pa = bfa_mem_dma_phys(fcport_dma); |
2854 | 2836 | fcport->stats = (union bfa_fcport_stats_u *) | |
2855 | fcport->stats_kva = dm_kva; | 2837 | bfa_mem_dma_virt(fcport_dma); |
2856 | fcport->stats_pa = dm_pa; | ||
2857 | fcport->stats = (union bfa_fcport_stats_u *) dm_kva; | ||
2858 | |||
2859 | dm_kva += FCPORT_STATS_DMA_SZ; | ||
2860 | dm_pa += FCPORT_STATS_DMA_SZ; | ||
2861 | |||
2862 | bfa_meminfo_dma_virt(meminfo) = dm_kva; | ||
2863 | bfa_meminfo_dma_phys(meminfo) = dm_pa; | ||
2864 | } | 2838 | } |
2865 | 2839 | ||
2866 | /* | 2840 | /* |
@@ -2868,18 +2842,17 @@ bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) | |||
2868 | */ | 2842 | */ |
2869 | static void | 2843 | static void |
2870 | bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 2844 | bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
2871 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 2845 | struct bfa_pcidev_s *pcidev) |
2872 | { | 2846 | { |
2873 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); | 2847 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
2874 | struct bfa_port_cfg_s *port_cfg = &fcport->cfg; | 2848 | struct bfa_port_cfg_s *port_cfg = &fcport->cfg; |
2875 | struct bfa_fcport_ln_s *ln = &fcport->ln; | 2849 | struct bfa_fcport_ln_s *ln = &fcport->ln; |
2876 | struct timeval tv; | 2850 | struct timeval tv; |
2877 | 2851 | ||
2878 | memset(fcport, 0, sizeof(struct bfa_fcport_s)); | ||
2879 | fcport->bfa = bfa; | 2852 | fcport->bfa = bfa; |
2880 | ln->fcport = fcport; | 2853 | ln->fcport = fcport; |
2881 | 2854 | ||
2882 | bfa_fcport_mem_claim(fcport, meminfo); | 2855 | bfa_fcport_mem_claim(fcport); |
2883 | 2856 | ||
2884 | bfa_sm_set_state(fcport, bfa_fcport_sm_uninit); | 2857 | bfa_sm_set_state(fcport, bfa_fcport_sm_uninit); |
2885 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); | 2858 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); |
@@ -4417,18 +4390,22 @@ bfa_rport_qresume(void *cbarg) | |||
4417 | } | 4390 | } |
4418 | 4391 | ||
4419 | static void | 4392 | static void |
4420 | bfa_rport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 4393 | bfa_rport_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
4421 | u32 *dm_len) | 4394 | struct bfa_s *bfa) |
4422 | { | 4395 | { |
4396 | struct bfa_mem_kva_s *rport_kva = BFA_MEM_RPORT_KVA(bfa); | ||
4397 | |||
4423 | if (cfg->fwcfg.num_rports < BFA_RPORT_MIN) | 4398 | if (cfg->fwcfg.num_rports < BFA_RPORT_MIN) |
4424 | cfg->fwcfg.num_rports = BFA_RPORT_MIN; | 4399 | cfg->fwcfg.num_rports = BFA_RPORT_MIN; |
4425 | 4400 | ||
4426 | *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_rport_s); | 4401 | /* kva memory */ |
4402 | bfa_mem_kva_setup(minfo, rport_kva, | ||
4403 | cfg->fwcfg.num_rports * sizeof(struct bfa_rport_s)); | ||
4427 | } | 4404 | } |
4428 | 4405 | ||
4429 | static void | 4406 | static void |
4430 | bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 4407 | bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
4431 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 4408 | struct bfa_pcidev_s *pcidev) |
4432 | { | 4409 | { |
4433 | struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa); | 4410 | struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa); |
4434 | struct bfa_rport_s *rp; | 4411 | struct bfa_rport_s *rp; |
@@ -4438,7 +4415,7 @@ bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
4438 | INIT_LIST_HEAD(&mod->rp_active_q); | 4415 | INIT_LIST_HEAD(&mod->rp_active_q); |
4439 | INIT_LIST_HEAD(&mod->rp_unused_q); | 4416 | INIT_LIST_HEAD(&mod->rp_unused_q); |
4440 | 4417 | ||
4441 | rp = (struct bfa_rport_s *) bfa_meminfo_kva(meminfo); | 4418 | rp = (struct bfa_rport_s *) bfa_mem_kva_curp(mod); |
4442 | mod->rps_list = rp; | 4419 | mod->rps_list = rp; |
4443 | mod->num_rports = cfg->fwcfg.num_rports; | 4420 | mod->num_rports = cfg->fwcfg.num_rports; |
4444 | 4421 | ||
@@ -4463,7 +4440,7 @@ bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
4463 | /* | 4440 | /* |
4464 | * consume memory | 4441 | * consume memory |
4465 | */ | 4442 | */ |
4466 | bfa_meminfo_kva(meminfo) = (u8 *) rp; | 4443 | bfa_mem_kva_curp(mod) = (u8 *) rp; |
4467 | } | 4444 | } |
4468 | 4445 | ||
4469 | static void | 4446 | static void |
@@ -4723,26 +4700,51 @@ bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed) | |||
4723 | * Compute and return memory needed by FCP(im) module. | 4700 | * Compute and return memory needed by FCP(im) module. |
4724 | */ | 4701 | */ |
4725 | static void | 4702 | static void |
4726 | bfa_sgpg_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 4703 | bfa_sgpg_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
4727 | u32 *dm_len) | 4704 | struct bfa_s *bfa) |
4728 | { | 4705 | { |
4706 | struct bfa_sgpg_mod_s *sgpg_mod = BFA_SGPG_MOD(bfa); | ||
4707 | struct bfa_mem_kva_s *sgpg_kva = BFA_MEM_SGPG_KVA(bfa); | ||
4708 | struct bfa_mem_dma_s *seg_ptr; | ||
4709 | u16 nsegs, idx, per_seg_sgpg, num_sgpg; | ||
4710 | u32 sgpg_sz = sizeof(struct bfi_sgpg_s); | ||
4711 | |||
4729 | if (cfg->drvcfg.num_sgpgs < BFA_SGPG_MIN) | 4712 | if (cfg->drvcfg.num_sgpgs < BFA_SGPG_MIN) |
4730 | cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN; | 4713 | cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN; |
4714 | else if (cfg->drvcfg.num_sgpgs > BFA_SGPG_MAX) | ||
4715 | cfg->drvcfg.num_sgpgs = BFA_SGPG_MAX; | ||
4731 | 4716 | ||
4732 | *km_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfa_sgpg_s); | 4717 | num_sgpg = cfg->drvcfg.num_sgpgs; |
4733 | *dm_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfi_sgpg_s); | 4718 | |
4734 | } | 4719 | nsegs = BFI_MEM_DMA_NSEGS(num_sgpg, sgpg_sz); |
4720 | per_seg_sgpg = BFI_MEM_NREQS_SEG(sgpg_sz); | ||
4721 | |||
4722 | bfa_mem_dma_seg_iter(sgpg_mod, seg_ptr, nsegs, idx) { | ||
4723 | if (num_sgpg >= per_seg_sgpg) { | ||
4724 | num_sgpg -= per_seg_sgpg; | ||
4725 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
4726 | per_seg_sgpg * sgpg_sz); | ||
4727 | } else | ||
4728 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
4729 | num_sgpg * sgpg_sz); | ||
4730 | } | ||
4735 | 4731 | ||
4732 | /* kva memory */ | ||
4733 | bfa_mem_kva_setup(minfo, sgpg_kva, | ||
4734 | cfg->drvcfg.num_sgpgs * sizeof(struct bfa_sgpg_s)); | ||
4735 | } | ||
4736 | 4736 | ||
4737 | static void | 4737 | static void |
4738 | bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 4738 | bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
4739 | struct bfa_meminfo_s *minfo, struct bfa_pcidev_s *pcidev) | 4739 | struct bfa_pcidev_s *pcidev) |
4740 | { | 4740 | { |
4741 | struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa); | 4741 | struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa); |
4742 | int i; | ||
4743 | struct bfa_sgpg_s *hsgpg; | 4742 | struct bfa_sgpg_s *hsgpg; |
4744 | struct bfi_sgpg_s *sgpg; | 4743 | struct bfi_sgpg_s *sgpg; |
4745 | u64 align_len; | 4744 | u64 align_len; |
4745 | struct bfa_mem_dma_s *seg_ptr; | ||
4746 | u32 sgpg_sz = sizeof(struct bfi_sgpg_s); | ||
4747 | u16 i, idx, nsegs, per_seg_sgpg, num_sgpg; | ||
4746 | 4748 | ||
4747 | union { | 4749 | union { |
4748 | u64 pa; | 4750 | u64 pa; |
@@ -4754,39 +4756,45 @@ bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | |||
4754 | 4756 | ||
4755 | bfa_trc(bfa, cfg->drvcfg.num_sgpgs); | 4757 | bfa_trc(bfa, cfg->drvcfg.num_sgpgs); |
4756 | 4758 | ||
4757 | mod->num_sgpgs = cfg->drvcfg.num_sgpgs; | 4759 | mod->free_sgpgs = mod->num_sgpgs = cfg->drvcfg.num_sgpgs; |
4758 | mod->sgpg_arr_pa = bfa_meminfo_dma_phys(minfo); | 4760 | |
4759 | align_len = (BFA_SGPG_ROUNDUP(mod->sgpg_arr_pa) - mod->sgpg_arr_pa); | 4761 | num_sgpg = cfg->drvcfg.num_sgpgs; |
4760 | mod->sgpg_arr_pa += align_len; | 4762 | nsegs = BFI_MEM_DMA_NSEGS(num_sgpg, sgpg_sz); |
4761 | mod->hsgpg_arr = (struct bfa_sgpg_s *) (bfa_meminfo_kva(minfo) + | 4763 | |
4762 | align_len); | 4764 | /* dma/kva mem claim */ |
4763 | mod->sgpg_arr = (struct bfi_sgpg_s *) (bfa_meminfo_dma_virt(minfo) + | 4765 | hsgpg = (struct bfa_sgpg_s *) bfa_mem_kva_curp(mod); |
4764 | align_len); | 4766 | |
4765 | 4767 | bfa_mem_dma_seg_iter(mod, seg_ptr, nsegs, idx) { | |
4766 | hsgpg = mod->hsgpg_arr; | 4768 | |
4767 | sgpg = mod->sgpg_arr; | 4769 | if (!bfa_mem_dma_virt(seg_ptr)) |
4768 | sgpg_pa.pa = mod->sgpg_arr_pa; | 4770 | break; |
4769 | mod->free_sgpgs = mod->num_sgpgs; | 4771 | |
4770 | 4772 | align_len = BFA_SGPG_ROUNDUP(bfa_mem_dma_phys(seg_ptr)) - | |
4771 | WARN_ON(sgpg_pa.pa & (sizeof(struct bfi_sgpg_s) - 1)); | 4773 | bfa_mem_dma_phys(seg_ptr); |
4772 | 4774 | ||
4773 | for (i = 0; i < mod->num_sgpgs; i++) { | 4775 | sgpg = (struct bfi_sgpg_s *) |
4774 | memset(hsgpg, 0, sizeof(*hsgpg)); | 4776 | (((u8 *) bfa_mem_dma_virt(seg_ptr)) + align_len); |
4775 | memset(sgpg, 0, sizeof(*sgpg)); | 4777 | sgpg_pa.pa = bfa_mem_dma_phys(seg_ptr) + align_len; |
4776 | 4778 | WARN_ON(sgpg_pa.pa & (sgpg_sz - 1)); | |
4777 | hsgpg->sgpg = sgpg; | 4779 | |
4778 | sgpg_pa_tmp.pa = bfa_sgaddr_le(sgpg_pa.pa); | 4780 | per_seg_sgpg = (seg_ptr->mem_len - (u32)align_len) / sgpg_sz; |
4779 | hsgpg->sgpg_pa = sgpg_pa_tmp.addr; | 4781 | |
4780 | list_add_tail(&hsgpg->qe, &mod->sgpg_q); | 4782 | for (i = 0; num_sgpg > 0 && i < per_seg_sgpg; i++, num_sgpg--) { |
4781 | 4783 | memset(hsgpg, 0, sizeof(*hsgpg)); | |
4782 | hsgpg++; | 4784 | memset(sgpg, 0, sizeof(*sgpg)); |
4783 | sgpg++; | 4785 | |
4784 | sgpg_pa.pa += sizeof(struct bfi_sgpg_s); | 4786 | hsgpg->sgpg = sgpg; |
4787 | sgpg_pa_tmp.pa = bfa_sgaddr_le(sgpg_pa.pa); | ||
4788 | hsgpg->sgpg_pa = sgpg_pa_tmp.addr; | ||
4789 | list_add_tail(&hsgpg->qe, &mod->sgpg_q); | ||
4790 | |||
4791 | sgpg++; | ||
4792 | hsgpg++; | ||
4793 | sgpg_pa.pa += sgpg_sz; | ||
4794 | } | ||
4785 | } | 4795 | } |
4786 | 4796 | ||
4787 | bfa_meminfo_kva(minfo) = (u8 *) hsgpg; | 4797 | bfa_mem_kva_curp(mod) = (u8 *) hsgpg; |
4788 | bfa_meminfo_dma_virt(minfo) = (u8 *) sgpg; | ||
4789 | bfa_meminfo_dma_phys(minfo) = sgpg_pa.pa; | ||
4790 | } | 4798 | } |
4791 | 4799 | ||
4792 | static void | 4800 | static void |
@@ -4928,29 +4936,13 @@ __bfa_cb_uf_recv(void *cbarg, bfa_boolean_t complete) | |||
4928 | } | 4936 | } |
4929 | 4937 | ||
4930 | static void | 4938 | static void |
4931 | claim_uf_pbs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | 4939 | claim_uf_post_msgs(struct bfa_uf_mod_s *ufm) |
4932 | { | ||
4933 | u32 uf_pb_tot_sz; | ||
4934 | |||
4935 | ufm->uf_pbs_kva = (struct bfa_uf_buf_s *) bfa_meminfo_dma_virt(mi); | ||
4936 | ufm->uf_pbs_pa = bfa_meminfo_dma_phys(mi); | ||
4937 | uf_pb_tot_sz = BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * ufm->num_ufs), | ||
4938 | BFA_DMA_ALIGN_SZ); | ||
4939 | |||
4940 | bfa_meminfo_dma_virt(mi) += uf_pb_tot_sz; | ||
4941 | bfa_meminfo_dma_phys(mi) += uf_pb_tot_sz; | ||
4942 | |||
4943 | memset((void *)ufm->uf_pbs_kva, 0, uf_pb_tot_sz); | ||
4944 | } | ||
4945 | |||
4946 | static void | ||
4947 | claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | ||
4948 | { | 4940 | { |
4949 | struct bfi_uf_buf_post_s *uf_bp_msg; | 4941 | struct bfi_uf_buf_post_s *uf_bp_msg; |
4950 | u16 i; | 4942 | u16 i; |
4951 | u16 buf_len; | 4943 | u16 buf_len; |
4952 | 4944 | ||
4953 | ufm->uf_buf_posts = (struct bfi_uf_buf_post_s *) bfa_meminfo_kva(mi); | 4945 | ufm->uf_buf_posts = (struct bfi_uf_buf_post_s *) bfa_mem_kva_curp(ufm); |
4954 | uf_bp_msg = ufm->uf_buf_posts; | 4946 | uf_bp_msg = ufm->uf_buf_posts; |
4955 | 4947 | ||
4956 | for (i = 0, uf_bp_msg = ufm->uf_buf_posts; i < ufm->num_ufs; | 4948 | for (i = 0, uf_bp_msg = ufm->uf_buf_posts; i < ufm->num_ufs; |
@@ -4968,11 +4960,11 @@ claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | |||
4968 | /* | 4960 | /* |
4969 | * advance pointer beyond consumed memory | 4961 | * advance pointer beyond consumed memory |
4970 | */ | 4962 | */ |
4971 | bfa_meminfo_kva(mi) = (u8 *) uf_bp_msg; | 4963 | bfa_mem_kva_curp(ufm) = (u8 *) uf_bp_msg; |
4972 | } | 4964 | } |
4973 | 4965 | ||
4974 | static void | 4966 | static void |
4975 | claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | 4967 | claim_ufs(struct bfa_uf_mod_s *ufm) |
4976 | { | 4968 | { |
4977 | u16 i; | 4969 | u16 i; |
4978 | struct bfa_uf_s *uf; | 4970 | struct bfa_uf_s *uf; |
@@ -4980,7 +4972,7 @@ claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | |||
4980 | /* | 4972 | /* |
4981 | * Claim block of memory for UF list | 4973 | * Claim block of memory for UF list |
4982 | */ | 4974 | */ |
4983 | ufm->uf_list = (struct bfa_uf_s *) bfa_meminfo_kva(mi); | 4975 | ufm->uf_list = (struct bfa_uf_s *) bfa_mem_kva_curp(ufm); |
4984 | 4976 | ||
4985 | /* | 4977 | /* |
4986 | * Initialize UFs and queue it in UF free queue | 4978 | * Initialize UFs and queue it in UF free queue |
@@ -4989,8 +4981,8 @@ claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | |||
4989 | memset(uf, 0, sizeof(struct bfa_uf_s)); | 4981 | memset(uf, 0, sizeof(struct bfa_uf_s)); |
4990 | uf->bfa = ufm->bfa; | 4982 | uf->bfa = ufm->bfa; |
4991 | uf->uf_tag = i; | 4983 | uf->uf_tag = i; |
4992 | uf->pb_len = sizeof(struct bfa_uf_buf_s); | 4984 | uf->pb_len = BFA_PER_UF_DMA_SZ; |
4993 | uf->buf_kva = (void *)&ufm->uf_pbs_kva[i]; | 4985 | uf->buf_kva = bfa_mem_get_dmabuf_kva(ufm, i, BFA_PER_UF_DMA_SZ); |
4994 | uf->buf_pa = ufm_pbs_pa(ufm, i); | 4986 | uf->buf_pa = ufm_pbs_pa(ufm, i); |
4995 | list_add_tail(&uf->qe, &ufm->uf_free_q); | 4987 | list_add_tail(&uf->qe, &ufm->uf_free_q); |
4996 | } | 4988 | } |
@@ -4998,49 +4990,57 @@ claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | |||
4998 | /* | 4990 | /* |
4999 | * advance memory pointer | 4991 | * advance memory pointer |
5000 | */ | 4992 | */ |
5001 | bfa_meminfo_kva(mi) = (u8 *) uf; | 4993 | bfa_mem_kva_curp(ufm) = (u8 *) uf; |
5002 | } | 4994 | } |
5003 | 4995 | ||
5004 | static void | 4996 | static void |
5005 | uf_mem_claim(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) | 4997 | uf_mem_claim(struct bfa_uf_mod_s *ufm) |
5006 | { | 4998 | { |
5007 | claim_uf_pbs(ufm, mi); | 4999 | claim_ufs(ufm); |
5008 | claim_ufs(ufm, mi); | 5000 | claim_uf_post_msgs(ufm); |
5009 | claim_uf_post_msgs(ufm, mi); | ||
5010 | } | 5001 | } |
5011 | 5002 | ||
5012 | static void | 5003 | static void |
5013 | bfa_uf_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, u32 *dm_len) | 5004 | bfa_uf_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
5005 | struct bfa_s *bfa) | ||
5014 | { | 5006 | { |
5015 | u32 num_ufs = cfg->fwcfg.num_uf_bufs; | 5007 | struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa); |
5016 | 5008 | struct bfa_mem_kva_s *uf_kva = BFA_MEM_UF_KVA(bfa); | |
5017 | /* | 5009 | u32 num_ufs = cfg->fwcfg.num_uf_bufs; |
5018 | * dma-able memory for UF posted bufs | 5010 | struct bfa_mem_dma_s *seg_ptr; |
5019 | */ | 5011 | u16 nsegs, idx, per_seg_uf = 0; |
5020 | *dm_len += BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * num_ufs), | 5012 | |
5021 | BFA_DMA_ALIGN_SZ); | 5013 | nsegs = BFI_MEM_DMA_NSEGS(num_ufs, BFA_PER_UF_DMA_SZ); |
5014 | per_seg_uf = BFI_MEM_NREQS_SEG(BFA_PER_UF_DMA_SZ); | ||
5015 | |||
5016 | bfa_mem_dma_seg_iter(ufm, seg_ptr, nsegs, idx) { | ||
5017 | if (num_ufs >= per_seg_uf) { | ||
5018 | num_ufs -= per_seg_uf; | ||
5019 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
5020 | per_seg_uf * BFA_PER_UF_DMA_SZ); | ||
5021 | } else | ||
5022 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
5023 | num_ufs * BFA_PER_UF_DMA_SZ); | ||
5024 | } | ||
5022 | 5025 | ||
5023 | /* | 5026 | /* kva memory */ |
5024 | * kernel Virtual memory for UFs and UF buf post msg copies | 5027 | bfa_mem_kva_setup(minfo, uf_kva, cfg->fwcfg.num_uf_bufs * |
5025 | */ | 5028 | (sizeof(struct bfa_uf_s) + sizeof(struct bfi_uf_buf_post_s))); |
5026 | *ndm_len += sizeof(struct bfa_uf_s) * num_ufs; | ||
5027 | *ndm_len += sizeof(struct bfi_uf_buf_post_s) * num_ufs; | ||
5028 | } | 5029 | } |
5029 | 5030 | ||
5030 | static void | 5031 | static void |
5031 | bfa_uf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 5032 | bfa_uf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
5032 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 5033 | struct bfa_pcidev_s *pcidev) |
5033 | { | 5034 | { |
5034 | struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa); | 5035 | struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa); |
5035 | 5036 | ||
5036 | memset(ufm, 0, sizeof(struct bfa_uf_mod_s)); | ||
5037 | ufm->bfa = bfa; | 5037 | ufm->bfa = bfa; |
5038 | ufm->num_ufs = cfg->fwcfg.num_uf_bufs; | 5038 | ufm->num_ufs = cfg->fwcfg.num_uf_bufs; |
5039 | INIT_LIST_HEAD(&ufm->uf_free_q); | 5039 | INIT_LIST_HEAD(&ufm->uf_free_q); |
5040 | INIT_LIST_HEAD(&ufm->uf_posted_q); | 5040 | INIT_LIST_HEAD(&ufm->uf_posted_q); |
5041 | INIT_LIST_HEAD(&ufm->uf_unused_q); | 5041 | INIT_LIST_HEAD(&ufm->uf_unused_q); |
5042 | 5042 | ||
5043 | uf_mem_claim(ufm, meminfo); | 5043 | uf_mem_claim(ufm); |
5044 | } | 5044 | } |
5045 | 5045 | ||
5046 | static void | 5046 | static void |
@@ -5098,11 +5098,15 @@ uf_recv(struct bfa_s *bfa, struct bfi_uf_frm_rcvd_s *m) | |||
5098 | { | 5098 | { |
5099 | struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa); | 5099 | struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa); |
5100 | u16 uf_tag = m->buf_tag; | 5100 | u16 uf_tag = m->buf_tag; |
5101 | struct bfa_uf_buf_s *uf_buf = &ufm->uf_pbs_kva[uf_tag]; | ||
5102 | struct bfa_uf_s *uf = &ufm->uf_list[uf_tag]; | 5101 | struct bfa_uf_s *uf = &ufm->uf_list[uf_tag]; |
5103 | u8 *buf = &uf_buf->d[0]; | 5102 | struct bfa_uf_buf_s *uf_buf; |
5103 | uint8_t *buf; | ||
5104 | struct fchs_s *fchs; | 5104 | struct fchs_s *fchs; |
5105 | 5105 | ||
5106 | uf_buf = (struct bfa_uf_buf_s *) | ||
5107 | bfa_mem_get_dmabuf_kva(ufm, uf_tag, uf->pb_len); | ||
5108 | buf = &uf_buf->d[0]; | ||
5109 | |||
5106 | m->frm_len = be16_to_cpu(m->frm_len); | 5110 | m->frm_len = be16_to_cpu(m->frm_len); |
5107 | m->xfr_len = be16_to_cpu(m->xfr_len); | 5111 | m->xfr_len = be16_to_cpu(m->xfr_len); |
5108 | 5112 | ||
diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h index 6df1492089cf..4c0ac3e1a137 100644 --- a/drivers/scsi/bfa/bfa_svc.h +++ b/drivers/scsi/bfa/bfa_svc.h | |||
@@ -26,6 +26,7 @@ | |||
26 | * Scatter-gather DMA related defines | 26 | * Scatter-gather DMA related defines |
27 | */ | 27 | */ |
28 | #define BFA_SGPG_MIN (16) | 28 | #define BFA_SGPG_MIN (16) |
29 | #define BFA_SGPG_MAX (8192) | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * Alignment macro for SG page allocation | 32 | * Alignment macro for SG page allocation |
@@ -54,17 +55,21 @@ struct bfa_sgpg_s { | |||
54 | */ | 55 | */ |
55 | #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1) | 56 | #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1) |
56 | 57 | ||
58 | /* Max SGPG dma segs required */ | ||
59 | #define BFA_SGPG_DMA_SEGS \ | ||
60 | BFI_MEM_DMA_NSEGS(BFA_SGPG_MAX, (uint32_t)sizeof(struct bfi_sgpg_s)) | ||
61 | |||
57 | struct bfa_sgpg_mod_s { | 62 | struct bfa_sgpg_mod_s { |
58 | struct bfa_s *bfa; | 63 | struct bfa_s *bfa; |
59 | int num_sgpgs; /* number of SG pages */ | 64 | int num_sgpgs; /* number of SG pages */ |
60 | int free_sgpgs; /* number of free SG pages */ | 65 | int free_sgpgs; /* number of free SG pages */ |
61 | struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */ | ||
62 | struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */ | ||
63 | u64 sgpg_arr_pa; /* SG page array DMA addr */ | ||
64 | struct list_head sgpg_q; /* queue of free SG pages */ | 66 | struct list_head sgpg_q; /* queue of free SG pages */ |
65 | struct list_head sgpg_wait_q; /* wait queue for SG pages */ | 67 | struct list_head sgpg_wait_q; /* wait queue for SG pages */ |
68 | struct bfa_mem_dma_s dma_seg[BFA_SGPG_DMA_SEGS]; | ||
69 | struct bfa_mem_kva_s kva_seg; | ||
66 | }; | 70 | }; |
67 | #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod) | 71 | #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod) |
72 | #define BFA_MEM_SGPG_KVA(__bfa) (&(BFA_SGPG_MOD(__bfa)->kva_seg)) | ||
68 | 73 | ||
69 | bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, | 74 | bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, |
70 | int nsgpgs); | 75 | int nsgpgs); |
@@ -79,27 +84,32 @@ void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe); | |||
79 | * FCXP related defines | 84 | * FCXP related defines |
80 | */ | 85 | */ |
81 | #define BFA_FCXP_MIN (1) | 86 | #define BFA_FCXP_MIN (1) |
87 | #define BFA_FCXP_MAX (256) | ||
82 | #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256) | 88 | #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256) |
83 | #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256) | 89 | #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256) |
84 | 90 | ||
91 | /* Max FCXP dma segs required */ | ||
92 | #define BFA_FCXP_DMA_SEGS \ | ||
93 | BFI_MEM_DMA_NSEGS(BFA_FCXP_MAX, \ | ||
94 | (u32)BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ) | ||
95 | |||
85 | struct bfa_fcxp_mod_s { | 96 | struct bfa_fcxp_mod_s { |
86 | struct bfa_s *bfa; /* backpointer to BFA */ | 97 | struct bfa_s *bfa; /* backpointer to BFA */ |
87 | struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */ | 98 | struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */ |
88 | u16 num_fcxps; /* max num FCXP requests */ | 99 | u16 num_fcxps; /* max num FCXP requests */ |
89 | struct list_head fcxp_free_q; /* free FCXPs */ | 100 | struct list_head fcxp_free_q; /* free FCXPs */ |
90 | struct list_head fcxp_active_q; /* active FCXPs */ | 101 | struct list_head fcxp_active_q; /* active FCXPs */ |
91 | void *req_pld_list_kva; /* list of FCXP req pld */ | ||
92 | u64 req_pld_list_pa; /* list of FCXP req pld */ | ||
93 | void *rsp_pld_list_kva; /* list of FCXP resp pld */ | ||
94 | u64 rsp_pld_list_pa; /* list of FCXP resp pld */ | ||
95 | struct list_head wait_q; /* wait queue for free fcxp */ | 102 | struct list_head wait_q; /* wait queue for free fcxp */ |
96 | struct list_head fcxp_unused_q; /* unused fcxps */ | 103 | struct list_head fcxp_unused_q; /* unused fcxps */ |
97 | u32 req_pld_sz; | 104 | u32 req_pld_sz; |
98 | u32 rsp_pld_sz; | 105 | u32 rsp_pld_sz; |
106 | struct bfa_mem_dma_s dma_seg[BFA_FCXP_DMA_SEGS]; | ||
107 | struct bfa_mem_kva_s kva_seg; | ||
99 | }; | 108 | }; |
100 | 109 | ||
101 | #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod) | 110 | #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod) |
102 | #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag]) | 111 | #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag]) |
112 | #define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg)) | ||
103 | 113 | ||
104 | typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp, | 114 | typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp, |
105 | void *cb_arg, bfa_status_t req_status, | 115 | void *cb_arg, bfa_status_t req_status, |
@@ -207,13 +217,15 @@ struct bfa_fcxp_wqe_s { | |||
207 | #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs)) | 217 | #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs)) |
208 | #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp)) | 218 | #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp)) |
209 | 219 | ||
210 | #define BFA_FCXP_REQ_PLD_PA(_fcxp) \ | 220 | #define BFA_FCXP_REQ_PLD_PA(_fcxp) \ |
211 | ((_fcxp)->fcxp_mod->req_pld_list_pa + \ | 221 | bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \ |
212 | ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag)) | 222 | (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) |
213 | 223 | ||
214 | #define BFA_FCXP_RSP_PLD_PA(_fcxp) \ | 224 | /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */ |
215 | ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \ | 225 | #define BFA_FCXP_RSP_PLD_PA(_fcxp) \ |
216 | ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag)) | 226 | (bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \ |
227 | (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \ | ||
228 | (_fcxp)->fcxp_mod->req_pld_sz) | ||
217 | 229 | ||
218 | void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); | 230 | void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
219 | 231 | ||
@@ -241,9 +253,11 @@ struct bfa_rport_mod_s { | |||
241 | struct list_head rp_active_q; /* free bfa_rports */ | 253 | struct list_head rp_active_q; /* free bfa_rports */ |
242 | struct list_head rp_unused_q; /* unused bfa rports */ | 254 | struct list_head rp_unused_q; /* unused bfa rports */ |
243 | u16 num_rports; /* number of rports */ | 255 | u16 num_rports; /* number of rports */ |
256 | struct bfa_mem_kva_s kva_seg; | ||
244 | }; | 257 | }; |
245 | 258 | ||
246 | #define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod) | 259 | #define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod) |
260 | #define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg)) | ||
247 | 261 | ||
248 | /* | 262 | /* |
249 | * Convert rport tag to RPORT | 263 | * Convert rport tag to RPORT |
@@ -301,7 +315,7 @@ struct bfa_rport_s { | |||
301 | */ | 315 | */ |
302 | 316 | ||
303 | #define BFA_UF_MIN (4) | 317 | #define BFA_UF_MIN (4) |
304 | 318 | #define BFA_UF_MAX (256) | |
305 | 319 | ||
306 | struct bfa_uf_s { | 320 | struct bfa_uf_s { |
307 | struct list_head qe; /* queue element */ | 321 | struct list_head qe; /* queue element */ |
@@ -329,6 +343,18 @@ struct bfa_uf_s { | |||
329 | */ | 343 | */ |
330 | typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf); | 344 | typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf); |
331 | 345 | ||
346 | #define BFA_UF_BUFSZ (2 * 1024 + 256) | ||
347 | |||
348 | struct bfa_uf_buf_s { | ||
349 | u8 d[BFA_UF_BUFSZ]; | ||
350 | }; | ||
351 | |||
352 | #define BFA_PER_UF_DMA_SZ \ | ||
353 | (u32)BFA_ROUNDUP(sizeof(struct bfa_uf_buf_s), BFA_DMA_ALIGN_SZ) | ||
354 | |||
355 | /* Max UF dma segs required */ | ||
356 | #define BFA_UF_DMA_SEGS BFI_MEM_DMA_NSEGS(BFA_UF_MAX, BFA_PER_UF_DMA_SZ) | ||
357 | |||
332 | struct bfa_uf_mod_s { | 358 | struct bfa_uf_mod_s { |
333 | struct bfa_s *bfa; /* back pointer to BFA */ | 359 | struct bfa_s *bfa; /* back pointer to BFA */ |
334 | struct bfa_uf_s *uf_list; /* array of UFs */ | 360 | struct bfa_uf_s *uf_list; /* array of UFs */ |
@@ -336,32 +362,23 @@ struct bfa_uf_mod_s { | |||
336 | struct list_head uf_free_q; /* free UFs */ | 362 | struct list_head uf_free_q; /* free UFs */ |
337 | struct list_head uf_posted_q; /* UFs posted to IOC */ | 363 | struct list_head uf_posted_q; /* UFs posted to IOC */ |
338 | struct list_head uf_unused_q; /* unused UF's */ | 364 | struct list_head uf_unused_q; /* unused UF's */ |
339 | struct bfa_uf_buf_s *uf_pbs_kva; /* list UF bufs request pld */ | ||
340 | u64 uf_pbs_pa; /* phy addr for UF bufs */ | ||
341 | struct bfi_uf_buf_post_s *uf_buf_posts; | 365 | struct bfi_uf_buf_post_s *uf_buf_posts; |
342 | /* pre-built UF post msgs */ | 366 | /* pre-built UF post msgs */ |
343 | bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */ | 367 | bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */ |
344 | void *cbarg; /* uf receive handler arg */ | 368 | void *cbarg; /* uf receive handler arg */ |
369 | struct bfa_mem_dma_s dma_seg[BFA_UF_DMA_SEGS]; | ||
370 | struct bfa_mem_kva_s kva_seg; | ||
345 | }; | 371 | }; |
346 | 372 | ||
347 | #define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod) | 373 | #define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod) |
374 | #define BFA_MEM_UF_KVA(__bfa) (&(BFA_UF_MOD(__bfa)->kva_seg)) | ||
348 | 375 | ||
349 | #define ufm_pbs_pa(_ufmod, _uftag) \ | 376 | #define ufm_pbs_pa(_ufmod, _uftag) \ |
350 | ((_ufmod)->uf_pbs_pa + sizeof(struct bfa_uf_buf_s) * (_uftag)) | 377 | bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ) |
351 | 378 | ||
352 | void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); | 379 | void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
353 | void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw); | 380 | void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw); |
354 | 381 | ||
355 | #define BFA_UF_BUFSZ (2 * 1024 + 256) | ||
356 | |||
357 | /* | ||
358 | * @todo private | ||
359 | */ | ||
360 | struct bfa_uf_buf_s { | ||
361 | u8 d[BFA_UF_BUFSZ]; | ||
362 | }; | ||
363 | |||
364 | |||
365 | /* | 382 | /* |
366 | * LPS - bfa lport login/logout service interface | 383 | * LPS - bfa lport login/logout service interface |
367 | */ | 384 | */ |
@@ -406,10 +423,12 @@ struct bfa_lps_mod_s { | |||
406 | struct list_head lps_login_q; | 423 | struct list_head lps_login_q; |
407 | struct bfa_lps_s *lps_arr; | 424 | struct bfa_lps_s *lps_arr; |
408 | int num_lps; | 425 | int num_lps; |
426 | struct bfa_mem_kva_s kva_seg; | ||
409 | }; | 427 | }; |
410 | 428 | ||
411 | #define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod) | 429 | #define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod) |
412 | #define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag]) | 430 | #define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag]) |
431 | #define BFA_MEM_LPS_KVA(__bfa) (&(BFA_LPS_MOD(__bfa)->kva_seg)) | ||
413 | 432 | ||
414 | /* | 433 | /* |
415 | * external functions | 434 | * external functions |
@@ -489,9 +508,11 @@ struct bfa_fcport_s { | |||
489 | bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */ | 508 | bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */ |
490 | struct bfa_fcport_trunk_s trunk; | 509 | struct bfa_fcport_trunk_s trunk; |
491 | u16 fcoe_vlan; | 510 | u16 fcoe_vlan; |
511 | struct bfa_mem_dma_s fcport_dma; | ||
492 | }; | 512 | }; |
493 | 513 | ||
494 | #define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport) | 514 | #define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport) |
515 | #define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma)) | ||
495 | 516 | ||
496 | /* | 517 | /* |
497 | * protected functions | 518 | * protected functions |
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 76af7ac02fd0..872c9df590b9 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c | |||
@@ -531,28 +531,26 @@ bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s pbc_vport) | |||
531 | void | 531 | void |
532 | bfad_hal_mem_release(struct bfad_s *bfad) | 532 | bfad_hal_mem_release(struct bfad_s *bfad) |
533 | { | 533 | { |
534 | int i; | ||
535 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; | 534 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; |
536 | struct bfa_mem_elem_s *meminfo_elem; | 535 | struct bfa_mem_dma_s *dma_info, *dma_elem; |
537 | 536 | struct bfa_mem_kva_s *kva_info, *kva_elem; | |
538 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { | 537 | struct list_head *dm_qe, *km_qe; |
539 | meminfo_elem = &hal_meminfo->meminfo[i]; | 538 | |
540 | if (meminfo_elem->kva != NULL) { | 539 | dma_info = &hal_meminfo->dma_info; |
541 | switch (meminfo_elem->mem_type) { | 540 | kva_info = &hal_meminfo->kva_info; |
542 | case BFA_MEM_TYPE_KVA: | 541 | |
543 | vfree(meminfo_elem->kva); | 542 | /* Iterate through the KVA meminfo queue */ |
544 | break; | 543 | list_for_each(km_qe, &kva_info->qe) { |
545 | case BFA_MEM_TYPE_DMA: | 544 | kva_elem = (struct bfa_mem_kva_s *) km_qe; |
546 | dma_free_coherent(&bfad->pcidev->dev, | 545 | vfree(kva_elem->kva); |
547 | meminfo_elem->mem_len, | 546 | } |
548 | meminfo_elem->kva, | 547 | |
549 | (dma_addr_t) meminfo_elem->dma); | 548 | /* Iterate through the DMA meminfo queue */ |
550 | break; | 549 | list_for_each(dm_qe, &dma_info->qe) { |
551 | default: | 550 | dma_elem = (struct bfa_mem_dma_s *) dm_qe; |
552 | WARN_ON(1); | 551 | dma_free_coherent(&bfad->pcidev->dev, |
553 | break; | 552 | dma_elem->mem_len, dma_elem->kva, |
554 | } | 553 | (dma_addr_t) dma_elem->dma); |
555 | } | ||
556 | } | 554 | } |
557 | 555 | ||
558 | memset(hal_meminfo, 0, sizeof(struct bfa_meminfo_s)); | 556 | memset(hal_meminfo, 0, sizeof(struct bfa_meminfo_s)); |
@@ -567,15 +565,15 @@ bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg) | |||
567 | bfa_cfg->fwcfg.num_ioim_reqs = num_ios; | 565 | bfa_cfg->fwcfg.num_ioim_reqs = num_ios; |
568 | if (num_tms > 0) | 566 | if (num_tms > 0) |
569 | bfa_cfg->fwcfg.num_tskim_reqs = num_tms; | 567 | bfa_cfg->fwcfg.num_tskim_reqs = num_tms; |
570 | if (num_fcxps > 0) | 568 | if (num_fcxps > 0 && num_fcxps <= BFA_FCXP_MAX) |
571 | bfa_cfg->fwcfg.num_fcxp_reqs = num_fcxps; | 569 | bfa_cfg->fwcfg.num_fcxp_reqs = num_fcxps; |
572 | if (num_ufbufs > 0) | 570 | if (num_ufbufs > 0 && num_ufbufs <= BFA_UF_MAX) |
573 | bfa_cfg->fwcfg.num_uf_bufs = num_ufbufs; | 571 | bfa_cfg->fwcfg.num_uf_bufs = num_ufbufs; |
574 | if (reqq_size > 0) | 572 | if (reqq_size > 0) |
575 | bfa_cfg->drvcfg.num_reqq_elems = reqq_size; | 573 | bfa_cfg->drvcfg.num_reqq_elems = reqq_size; |
576 | if (rspq_size > 0) | 574 | if (rspq_size > 0) |
577 | bfa_cfg->drvcfg.num_rspq_elems = rspq_size; | 575 | bfa_cfg->drvcfg.num_rspq_elems = rspq_size; |
578 | if (num_sgpgs > 0) | 576 | if (num_sgpgs > 0 && num_sgpgs <= BFA_SGPG_MAX) |
579 | bfa_cfg->drvcfg.num_sgpgs = num_sgpgs; | 577 | bfa_cfg->drvcfg.num_sgpgs = num_sgpgs; |
580 | 578 | ||
581 | /* | 579 | /* |
@@ -595,85 +593,46 @@ bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg) | |||
595 | bfa_status_t | 593 | bfa_status_t |
596 | bfad_hal_mem_alloc(struct bfad_s *bfad) | 594 | bfad_hal_mem_alloc(struct bfad_s *bfad) |
597 | { | 595 | { |
598 | int i; | ||
599 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; | 596 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; |
600 | struct bfa_mem_elem_s *meminfo_elem; | 597 | struct bfa_mem_dma_s *dma_info, *dma_elem; |
601 | dma_addr_t phys_addr; | 598 | struct bfa_mem_kva_s *kva_info, *kva_elem; |
602 | void *kva; | 599 | struct list_head *dm_qe, *km_qe; |
603 | bfa_status_t rc = BFA_STATUS_OK; | 600 | bfa_status_t rc = BFA_STATUS_OK; |
604 | int retry_count = 0; | 601 | dma_addr_t phys_addr; |
605 | int reset_value = 1; | ||
606 | int min_num_sgpgs = 512; | ||
607 | 602 | ||
608 | bfa_cfg_get_default(&bfad->ioc_cfg); | 603 | bfa_cfg_get_default(&bfad->ioc_cfg); |
609 | |||
610 | retry: | ||
611 | bfad_update_hal_cfg(&bfad->ioc_cfg); | 604 | bfad_update_hal_cfg(&bfad->ioc_cfg); |
612 | bfad->cfg_data.ioc_queue_depth = bfad->ioc_cfg.fwcfg.num_ioim_reqs; | 605 | bfad->cfg_data.ioc_queue_depth = bfad->ioc_cfg.fwcfg.num_ioim_reqs; |
613 | bfa_cfg_get_meminfo(&bfad->ioc_cfg, hal_meminfo); | 606 | bfa_cfg_get_meminfo(&bfad->ioc_cfg, hal_meminfo, &bfad->bfa); |
614 | 607 | ||
615 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { | 608 | dma_info = &hal_meminfo->dma_info; |
616 | meminfo_elem = &hal_meminfo->meminfo[i]; | 609 | kva_info = &hal_meminfo->kva_info; |
617 | switch (meminfo_elem->mem_type) { | 610 | |
618 | case BFA_MEM_TYPE_KVA: | 611 | /* Iterate through the KVA meminfo queue */ |
619 | kva = vmalloc(meminfo_elem->mem_len); | 612 | list_for_each(km_qe, &kva_info->qe) { |
620 | if (kva == NULL) { | 613 | kva_elem = (struct bfa_mem_kva_s *) km_qe; |
621 | bfad_hal_mem_release(bfad); | 614 | kva_elem->kva = vmalloc(kva_elem->mem_len); |
622 | rc = BFA_STATUS_ENOMEM; | 615 | if (kva_elem->kva == NULL) { |
623 | goto ext; | 616 | bfad_hal_mem_release(bfad); |
624 | } | 617 | rc = BFA_STATUS_ENOMEM; |
625 | memset(kva, 0, meminfo_elem->mem_len); | 618 | goto ext; |
626 | meminfo_elem->kva = kva; | 619 | } |
627 | break; | 620 | memset(kva_elem->kva, 0, kva_elem->mem_len); |
628 | case BFA_MEM_TYPE_DMA: | 621 | } |
629 | kva = dma_alloc_coherent(&bfad->pcidev->dev, | ||
630 | meminfo_elem->mem_len, &phys_addr, GFP_KERNEL); | ||
631 | if (kva == NULL) { | ||
632 | bfad_hal_mem_release(bfad); | ||
633 | /* | ||
634 | * If we cannot allocate with default | ||
635 | * num_sgpages try with half the value. | ||
636 | */ | ||
637 | if (num_sgpgs > min_num_sgpgs) { | ||
638 | printk(KERN_INFO | ||
639 | "bfad[%d]: memory allocation failed" | ||
640 | " with num_sgpgs: %d\n", | ||
641 | bfad->inst_no, num_sgpgs); | ||
642 | nextLowerInt(&num_sgpgs); | ||
643 | printk(KERN_INFO | ||
644 | "bfad[%d]: trying to allocate memory" | ||
645 | " with num_sgpgs: %d\n", | ||
646 | bfad->inst_no, num_sgpgs); | ||
647 | retry_count++; | ||
648 | goto retry; | ||
649 | } else { | ||
650 | if (num_sgpgs_parm > 0) | ||
651 | num_sgpgs = num_sgpgs_parm; | ||
652 | else { | ||
653 | reset_value = | ||
654 | (1 << retry_count); | ||
655 | num_sgpgs *= reset_value; | ||
656 | } | ||
657 | rc = BFA_STATUS_ENOMEM; | ||
658 | goto ext; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | if (num_sgpgs_parm > 0) | ||
663 | num_sgpgs = num_sgpgs_parm; | ||
664 | else { | ||
665 | reset_value = (1 << retry_count); | ||
666 | num_sgpgs *= reset_value; | ||
667 | } | ||
668 | |||
669 | memset(kva, 0, meminfo_elem->mem_len); | ||
670 | meminfo_elem->kva = kva; | ||
671 | meminfo_elem->dma = phys_addr; | ||
672 | break; | ||
673 | default: | ||
674 | break; | ||
675 | 622 | ||
623 | /* Iterate through the DMA meminfo queue */ | ||
624 | list_for_each(dm_qe, &dma_info->qe) { | ||
625 | dma_elem = (struct bfa_mem_dma_s *) dm_qe; | ||
626 | dma_elem->kva = dma_alloc_coherent(&bfad->pcidev->dev, | ||
627 | dma_elem->mem_len, | ||
628 | &phys_addr, GFP_KERNEL); | ||
629 | if (dma_elem->kva == NULL) { | ||
630 | bfad_hal_mem_release(bfad); | ||
631 | rc = BFA_STATUS_ENOMEM; | ||
632 | goto ext; | ||
676 | } | 633 | } |
634 | dma_elem->dma = phys_addr; | ||
635 | memset(dma_elem->kva, 0, dma_elem->mem_len); | ||
677 | } | 636 | } |
678 | ext: | 637 | ext: |
679 | return rc; | 638 | return rc; |
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index 7cfaa62aad43..e5163c7d3958 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h | |||
@@ -276,21 +276,6 @@ struct bfad_hal_comp { | |||
276 | struct completion comp; | 276 | struct completion comp; |
277 | }; | 277 | }; |
278 | 278 | ||
279 | /* | ||
280 | * Macro to obtain the immediate lower power | ||
281 | * of two for the integer. | ||
282 | */ | ||
283 | #define nextLowerInt(x) \ | ||
284 | do { \ | ||
285 | int __i; \ | ||
286 | (*x)--; \ | ||
287 | for (__i = 1; __i < (sizeof(int)*8); __i <<= 1) \ | ||
288 | (*x) = (*x) | (*x) >> __i; \ | ||
289 | (*x)++; \ | ||
290 | (*x) = (*x) >> 1; \ | ||
291 | } while (0) | ||
292 | |||
293 | |||
294 | #define BFA_LOG(level, bfad, mask, fmt, arg...) \ | 279 | #define BFA_LOG(level, bfad, mask, fmt, arg...) \ |
295 | do { \ | 280 | do { \ |
296 | if (((mask) == 4) || (level[1] <= '4')) \ | 281 | if (((mask) == 4) || (level[1] <= '4')) \ |
diff --git a/drivers/scsi/bfa/bfi.h b/drivers/scsi/bfa/bfi.h index 40002f4ea008..d36c81b88f69 100644 --- a/drivers/scsi/bfa/bfi.h +++ b/drivers/scsi/bfa/bfi.h | |||
@@ -23,6 +23,24 @@ | |||
23 | 23 | ||
24 | #pragma pack(1) | 24 | #pragma pack(1) |
25 | 25 | ||
26 | /* Per dma segment max size */ | ||
27 | #define BFI_MEM_DMA_SEG_SZ (131072) | ||
28 | |||
29 | /* Get number of dma segments required */ | ||
30 | #define BFI_MEM_DMA_NSEGS(_num_reqs, _req_sz) \ | ||
31 | ((u16)(((((_num_reqs) * (_req_sz)) + BFI_MEM_DMA_SEG_SZ - 1) & \ | ||
32 | ~(BFI_MEM_DMA_SEG_SZ - 1)) / BFI_MEM_DMA_SEG_SZ)) | ||
33 | |||
34 | /* Get num dma reqs - that fit in a segment */ | ||
35 | #define BFI_MEM_NREQS_SEG(_rqsz) (BFI_MEM_DMA_SEG_SZ / (_rqsz)) | ||
36 | |||
37 | /* Get segment num from tag */ | ||
38 | #define BFI_MEM_SEG_FROM_TAG(_tag, _rqsz) ((_tag) / BFI_MEM_NREQS_SEG(_rqsz)) | ||
39 | |||
40 | /* Get dma req offset in a segment */ | ||
41 | #define BFI_MEM_SEG_REQ_OFFSET(_tag, _sz) \ | ||
42 | ((_tag) - (BFI_MEM_SEG_FROM_TAG(_tag, _sz) * BFI_MEM_NREQS_SEG(_sz))) | ||
43 | |||
26 | /* | 44 | /* |
27 | * BFI FW image type | 45 | * BFI FW image type |
28 | */ | 46 | */ |
@@ -46,7 +64,6 @@ struct bfi_mhdr_s { | |||
46 | 64 | ||
47 | #define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu)) | 65 | #define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu)) |
48 | #define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1) | 66 | #define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1) |
49 | #define bfi_mhdr_2_qid(_m) ((_mh)->mtag.h2i.qid) | ||
50 | 67 | ||
51 | #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \ | 68 | #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \ |
52 | (_mh).msg_class = (_mc); \ | 69 | (_mh).msg_class = (_mc); \ |
@@ -133,6 +150,12 @@ struct bfi_sgpg_s { | |||
133 | u32 rsvd[BFI_SGPG_RSVD_WD_LEN]; | 150 | u32 rsvd[BFI_SGPG_RSVD_WD_LEN]; |
134 | }; | 151 | }; |
135 | 152 | ||
153 | /* FCP module definitions */ | ||
154 | #define BFI_IO_MAX (2000) | ||
155 | #define BFI_IOIM_SNSLEN (256) | ||
156 | #define BFI_IOIM_SNSBUF_SEGS \ | ||
157 | BFI_MEM_DMA_NSEGS(BFI_IO_MAX, BFI_IOIM_SNSLEN) | ||
158 | |||
136 | /* | 159 | /* |
137 | * Large Message structure - 128 Bytes size Msgs | 160 | * Large Message structure - 128 Bytes size Msgs |
138 | */ | 161 | */ |
diff --git a/drivers/scsi/bfa/bfi_ms.h b/drivers/scsi/bfa/bfi_ms.h index 0727c7595b1d..0d9f1fb50db0 100644 --- a/drivers/scsi/bfa/bfi_ms.h +++ b/drivers/scsi/bfa/bfi_ms.h | |||
@@ -46,10 +46,12 @@ struct bfi_iocfc_cfg_s { | |||
46 | u8 sense_buf_len; /* SCSI sense length */ | 46 | u8 sense_buf_len; /* SCSI sense length */ |
47 | u16 rsvd_1; | 47 | u16 rsvd_1; |
48 | u32 endian_sig; /* endian signature of host */ | 48 | u32 endian_sig; /* endian signature of host */ |
49 | u8 rsvd_2; | ||
50 | u8 single_msix_vec; | ||
51 | u8 rsvd[2]; | ||
49 | __be16 num_ioim_reqs; | 52 | __be16 num_ioim_reqs; |
50 | __be16 num_fwtio_reqs; | 53 | __be16 num_fwtio_reqs; |
51 | u8 single_msix_vec; | 54 | |
52 | u8 rsvd[3]; | ||
53 | 55 | ||
54 | /* | 56 | /* |
55 | * Request and response circular queue base addresses, size and | 57 | * Request and response circular queue base addresses, size and |
@@ -64,7 +66,8 @@ struct bfi_iocfc_cfg_s { | |||
64 | 66 | ||
65 | union bfi_addr_u stats_addr; /* DMA-able address for stats */ | 67 | union bfi_addr_u stats_addr; /* DMA-able address for stats */ |
66 | union bfi_addr_u cfgrsp_addr; /* config response dma address */ | 68 | union bfi_addr_u cfgrsp_addr; /* config response dma address */ |
67 | union bfi_addr_u ioim_snsbase; /* IO sense buffer base address */ | 69 | union bfi_addr_u ioim_snsbase[BFI_IOIM_SNSBUF_SEGS]; |
70 | /* IO sense buf base addr segments */ | ||
68 | struct bfa_iocfc_intr_attr_s intr_attr; /* IOC interrupt attributes */ | 71 | struct bfa_iocfc_intr_attr_s intr_attr; /* IOC interrupt attributes */ |
69 | }; | 72 | }; |
70 | 73 | ||
@@ -753,7 +756,6 @@ enum bfi_ioim_status { | |||
753 | BFI_IOIM_STS_PATHTOV = 8, | 756 | BFI_IOIM_STS_PATHTOV = 8, |
754 | }; | 757 | }; |
755 | 758 | ||
756 | #define BFI_IOIM_SNSLEN (256) | ||
757 | /* | 759 | /* |
758 | * I/O response message | 760 | * I/O response message |
759 | */ | 761 | */ |