diff options
Diffstat (limited to 'drivers/scsi/cxgb3i/cxgb3i_ddp.c')
-rw-r--r-- | drivers/scsi/cxgb3i/cxgb3i_ddp.c | 275 |
1 files changed, 109 insertions, 166 deletions
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.c b/drivers/scsi/cxgb3i/cxgb3i_ddp.c index 4eb6f5593b3e..d06a661c209f 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_ddp.c +++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.c | |||
@@ -23,19 +23,6 @@ | |||
23 | 23 | ||
24 | #include "cxgb3i_ddp.h" | 24 | #include "cxgb3i_ddp.h" |
25 | 25 | ||
26 | #define DRV_MODULE_NAME "cxgb3i_ddp" | ||
27 | #define DRV_MODULE_VERSION "1.0.0" | ||
28 | #define DRV_MODULE_RELDATE "Dec. 1, 2008" | ||
29 | |||
30 | static char version[] = | ||
31 | "Chelsio S3xx iSCSI DDP " DRV_MODULE_NAME | ||
32 | " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; | ||
33 | |||
34 | MODULE_AUTHOR("Karen Xie <kxie@chelsio.com>"); | ||
35 | MODULE_DESCRIPTION("cxgb3i ddp pagepod manager"); | ||
36 | MODULE_LICENSE("GPL"); | ||
37 | MODULE_VERSION(DRV_MODULE_VERSION); | ||
38 | |||
39 | #define ddp_log_error(fmt...) printk(KERN_ERR "cxgb3i_ddp: ERR! " fmt) | 26 | #define ddp_log_error(fmt...) printk(KERN_ERR "cxgb3i_ddp: ERR! " fmt) |
40 | #define ddp_log_warn(fmt...) printk(KERN_WARNING "cxgb3i_ddp: WARN! " fmt) | 27 | #define ddp_log_warn(fmt...) printk(KERN_WARNING "cxgb3i_ddp: WARN! " fmt) |
41 | #define ddp_log_info(fmt...) printk(KERN_INFO "cxgb3i_ddp: " fmt) | 28 | #define ddp_log_info(fmt...) printk(KERN_INFO "cxgb3i_ddp: " fmt) |
@@ -66,9 +53,6 @@ static unsigned char ddp_page_order[DDP_PGIDX_MAX] = {0, 1, 2, 4}; | |||
66 | static unsigned char ddp_page_shift[DDP_PGIDX_MAX] = {12, 13, 14, 16}; | 53 | static unsigned char ddp_page_shift[DDP_PGIDX_MAX] = {12, 13, 14, 16}; |
67 | static unsigned char page_idx = DDP_PGIDX_MAX; | 54 | static unsigned char page_idx = DDP_PGIDX_MAX; |
68 | 55 | ||
69 | static LIST_HEAD(cxgb3i_ddp_list); | ||
70 | static DEFINE_RWLOCK(cxgb3i_ddp_rwlock); | ||
71 | |||
72 | /* | 56 | /* |
73 | * functions to program the pagepod in h/w | 57 | * functions to program the pagepod in h/w |
74 | */ | 58 | */ |
@@ -113,8 +97,8 @@ static int set_ddp_map(struct cxgb3i_ddp_info *ddp, struct pagepod_hdr *hdr, | |||
113 | return 0; | 97 | return 0; |
114 | } | 98 | } |
115 | 99 | ||
116 | static int clear_ddp_map(struct cxgb3i_ddp_info *ddp, unsigned int idx, | 100 | static void clear_ddp_map(struct cxgb3i_ddp_info *ddp, unsigned int tag, |
117 | unsigned int npods) | 101 | unsigned int idx, unsigned int npods) |
118 | { | 102 | { |
119 | unsigned int pm_addr = (idx << PPOD_SIZE_SHIFT) + ddp->llimit; | 103 | unsigned int pm_addr = (idx << PPOD_SIZE_SHIFT) + ddp->llimit; |
120 | int i; | 104 | int i; |
@@ -122,13 +106,17 @@ static int clear_ddp_map(struct cxgb3i_ddp_info *ddp, unsigned int idx, | |||
122 | for (i = 0; i < npods; i++, idx++, pm_addr += PPOD_SIZE) { | 106 | for (i = 0; i < npods; i++, idx++, pm_addr += PPOD_SIZE) { |
123 | struct sk_buff *skb = ddp->gl_skb[idx]; | 107 | struct sk_buff *skb = ddp->gl_skb[idx]; |
124 | 108 | ||
109 | if (!skb) { | ||
110 | ddp_log_error("ddp tag 0x%x, 0x%x, %d/%u, skb NULL.\n", | ||
111 | tag, idx, i, npods); | ||
112 | continue; | ||
113 | } | ||
125 | ddp->gl_skb[idx] = NULL; | 114 | ddp->gl_skb[idx] = NULL; |
126 | memset((skb->head + sizeof(struct ulp_mem_io)), 0, PPOD_SIZE); | 115 | memset((skb->head + sizeof(struct ulp_mem_io)), 0, PPOD_SIZE); |
127 | ulp_mem_io_set_hdr(skb, pm_addr); | 116 | ulp_mem_io_set_hdr(skb, pm_addr); |
128 | skb->priority = CPL_PRIORITY_CONTROL; | 117 | skb->priority = CPL_PRIORITY_CONTROL; |
129 | cxgb3_ofld_send(ddp->tdev, skb); | 118 | cxgb3_ofld_send(ddp->tdev, skb); |
130 | } | 119 | } |
131 | return 0; | ||
132 | } | 120 | } |
133 | 121 | ||
134 | static inline int ddp_find_unused_entries(struct cxgb3i_ddp_info *ddp, | 122 | static inline int ddp_find_unused_entries(struct cxgb3i_ddp_info *ddp, |
@@ -211,7 +199,6 @@ int cxgb3i_ddp_find_page_index(unsigned long pgsz) | |||
211 | ddp_log_debug("ddp page size 0x%lx not supported.\n", pgsz); | 199 | ddp_log_debug("ddp page size 0x%lx not supported.\n", pgsz); |
212 | return DDP_PGIDX_MAX; | 200 | return DDP_PGIDX_MAX; |
213 | } | 201 | } |
214 | EXPORT_SYMBOL_GPL(cxgb3i_ddp_find_page_index); | ||
215 | 202 | ||
216 | static inline void ddp_gl_unmap(struct pci_dev *pdev, | 203 | static inline void ddp_gl_unmap(struct pci_dev *pdev, |
217 | struct cxgb3i_gather_list *gl) | 204 | struct cxgb3i_gather_list *gl) |
@@ -334,7 +321,6 @@ error_out: | |||
334 | kfree(gl); | 321 | kfree(gl); |
335 | return NULL; | 322 | return NULL; |
336 | } | 323 | } |
337 | EXPORT_SYMBOL_GPL(cxgb3i_ddp_make_gl); | ||
338 | 324 | ||
339 | /** | 325 | /** |
340 | * cxgb3i_ddp_release_gl - release a page buffer list | 326 | * cxgb3i_ddp_release_gl - release a page buffer list |
@@ -348,7 +334,6 @@ void cxgb3i_ddp_release_gl(struct cxgb3i_gather_list *gl, | |||
348 | ddp_gl_unmap(pdev, gl); | 334 | ddp_gl_unmap(pdev, gl); |
349 | kfree(gl); | 335 | kfree(gl); |
350 | } | 336 | } |
351 | EXPORT_SYMBOL_GPL(cxgb3i_ddp_release_gl); | ||
352 | 337 | ||
353 | /** | 338 | /** |
354 | * cxgb3i_ddp_tag_reserve - set up ddp for a data transfer | 339 | * cxgb3i_ddp_tag_reserve - set up ddp for a data transfer |
@@ -430,7 +415,6 @@ unmark_entries: | |||
430 | ddp_unmark_entries(ddp, idx, npods); | 415 | ddp_unmark_entries(ddp, idx, npods); |
431 | return err; | 416 | return err; |
432 | } | 417 | } |
433 | EXPORT_SYMBOL_GPL(cxgb3i_ddp_tag_reserve); | ||
434 | 418 | ||
435 | /** | 419 | /** |
436 | * cxgb3i_ddp_tag_release - release a ddp tag | 420 | * cxgb3i_ddp_tag_release - release a ddp tag |
@@ -453,22 +437,21 @@ void cxgb3i_ddp_tag_release(struct t3cdev *tdev, u32 tag) | |||
453 | struct cxgb3i_gather_list *gl = ddp->gl_map[idx]; | 437 | struct cxgb3i_gather_list *gl = ddp->gl_map[idx]; |
454 | unsigned int npods; | 438 | unsigned int npods; |
455 | 439 | ||
456 | if (!gl) { | 440 | if (!gl || !gl->nelem) { |
457 | ddp_log_error("release ddp 0x%x, idx 0x%x, gl NULL.\n", | 441 | ddp_log_error("release 0x%x, idx 0x%x, gl 0x%p, %u.\n", |
458 | tag, idx); | 442 | tag, idx, gl, gl ? gl->nelem : 0); |
459 | return; | 443 | return; |
460 | } | 444 | } |
461 | npods = (gl->nelem + PPOD_PAGES_MAX - 1) >> PPOD_PAGES_SHIFT; | 445 | npods = (gl->nelem + PPOD_PAGES_MAX - 1) >> PPOD_PAGES_SHIFT; |
462 | ddp_log_debug("ddp tag 0x%x, release idx 0x%x, npods %u.\n", | 446 | ddp_log_debug("ddp tag 0x%x, release idx 0x%x, npods %u.\n", |
463 | tag, idx, npods); | 447 | tag, idx, npods); |
464 | clear_ddp_map(ddp, idx, npods); | 448 | clear_ddp_map(ddp, tag, idx, npods); |
465 | ddp_unmark_entries(ddp, idx, npods); | 449 | ddp_unmark_entries(ddp, idx, npods); |
466 | cxgb3i_ddp_release_gl(gl, ddp->pdev); | 450 | cxgb3i_ddp_release_gl(gl, ddp->pdev); |
467 | } else | 451 | } else |
468 | ddp_log_error("ddp tag 0x%x, idx 0x%x > max 0x%x.\n", | 452 | ddp_log_error("ddp tag 0x%x, idx 0x%x > max 0x%x.\n", |
469 | tag, idx, ddp->nppods); | 453 | tag, idx, ddp->nppods); |
470 | } | 454 | } |
471 | EXPORT_SYMBOL_GPL(cxgb3i_ddp_tag_release); | ||
472 | 455 | ||
473 | static int setup_conn_pgidx(struct t3cdev *tdev, unsigned int tid, int pg_idx, | 456 | static int setup_conn_pgidx(struct t3cdev *tdev, unsigned int tid, int pg_idx, |
474 | int reply) | 457 | int reply) |
@@ -509,7 +492,6 @@ int cxgb3i_setup_conn_host_pagesize(struct t3cdev *tdev, unsigned int tid, | |||
509 | { | 492 | { |
510 | return setup_conn_pgidx(tdev, tid, page_idx, reply); | 493 | return setup_conn_pgidx(tdev, tid, page_idx, reply); |
511 | } | 494 | } |
512 | EXPORT_SYMBOL_GPL(cxgb3i_setup_conn_host_pagesize); | ||
513 | 495 | ||
514 | /** | 496 | /** |
515 | * cxgb3i_setup_conn_pagesize - setup the conn.'s ddp page size | 497 | * cxgb3i_setup_conn_pagesize - setup the conn.'s ddp page size |
@@ -526,7 +508,6 @@ int cxgb3i_setup_conn_pagesize(struct t3cdev *tdev, unsigned int tid, | |||
526 | 508 | ||
527 | return setup_conn_pgidx(tdev, tid, pgidx, reply); | 509 | return setup_conn_pgidx(tdev, tid, pgidx, reply); |
528 | } | 510 | } |
529 | EXPORT_SYMBOL_GPL(cxgb3i_setup_conn_pagesize); | ||
530 | 511 | ||
531 | /** | 512 | /** |
532 | * cxgb3i_setup_conn_digest - setup conn. digest setting | 513 | * cxgb3i_setup_conn_digest - setup conn. digest setting |
@@ -562,26 +543,104 @@ int cxgb3i_setup_conn_digest(struct t3cdev *tdev, unsigned int tid, | |||
562 | cxgb3_ofld_send(tdev, skb); | 543 | cxgb3_ofld_send(tdev, skb); |
563 | return 0; | 544 | return 0; |
564 | } | 545 | } |
565 | EXPORT_SYMBOL_GPL(cxgb3i_setup_conn_digest); | ||
566 | 546 | ||
567 | static int ddp_init(struct t3cdev *tdev) | 547 | |
548 | /** | ||
549 | * cxgb3i_adapter_ddp_info - read the adapter's ddp information | ||
550 | * @tdev: t3cdev adapter | ||
551 | * @tformat: tag format | ||
552 | * @txsz: max tx pdu payload size, filled in by this func. | ||
553 | * @rxsz: max rx pdu payload size, filled in by this func. | ||
554 | * setup the tag format for a given iscsi entity | ||
555 | */ | ||
556 | int cxgb3i_adapter_ddp_info(struct t3cdev *tdev, | ||
557 | struct cxgb3i_tag_format *tformat, | ||
558 | unsigned int *txsz, unsigned int *rxsz) | ||
559 | { | ||
560 | struct cxgb3i_ddp_info *ddp; | ||
561 | unsigned char idx_bits; | ||
562 | |||
563 | if (!tformat) | ||
564 | return -EINVAL; | ||
565 | |||
566 | if (!tdev->ulp_iscsi) | ||
567 | return -EINVAL; | ||
568 | |||
569 | ddp = (struct cxgb3i_ddp_info *)tdev->ulp_iscsi; | ||
570 | |||
571 | idx_bits = 32 - tformat->sw_bits; | ||
572 | tformat->rsvd_bits = ddp->idx_bits; | ||
573 | tformat->rsvd_shift = PPOD_IDX_SHIFT; | ||
574 | tformat->rsvd_mask = (1 << tformat->rsvd_bits) - 1; | ||
575 | |||
576 | ddp_log_info("tag format: sw %u, rsvd %u,%u, mask 0x%x.\n", | ||
577 | tformat->sw_bits, tformat->rsvd_bits, | ||
578 | tformat->rsvd_shift, tformat->rsvd_mask); | ||
579 | |||
580 | *txsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD, | ||
581 | ddp->max_txsz - ISCSI_PDU_NONPAYLOAD_LEN); | ||
582 | *rxsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD, | ||
583 | ddp->max_rxsz - ISCSI_PDU_NONPAYLOAD_LEN); | ||
584 | ddp_log_info("max payload size: %u/%u, %u/%u.\n", | ||
585 | *txsz, ddp->max_txsz, *rxsz, ddp->max_rxsz); | ||
586 | return 0; | ||
587 | } | ||
588 | |||
589 | /** | ||
590 | * cxgb3i_ddp_cleanup - release the cxgb3 adapter's ddp resource | ||
591 | * @tdev: t3cdev adapter | ||
592 | * release all the resource held by the ddp pagepod manager for a given | ||
593 | * adapter if needed | ||
594 | */ | ||
595 | void cxgb3i_ddp_cleanup(struct t3cdev *tdev) | ||
596 | { | ||
597 | int i = 0; | ||
598 | struct cxgb3i_ddp_info *ddp = (struct cxgb3i_ddp_info *)tdev->ulp_iscsi; | ||
599 | |||
600 | ddp_log_info("t3dev 0x%p, release ddp 0x%p.\n", tdev, ddp); | ||
601 | |||
602 | if (ddp) { | ||
603 | tdev->ulp_iscsi = NULL; | ||
604 | while (i < ddp->nppods) { | ||
605 | struct cxgb3i_gather_list *gl = ddp->gl_map[i]; | ||
606 | if (gl) { | ||
607 | int npods = (gl->nelem + PPOD_PAGES_MAX - 1) | ||
608 | >> PPOD_PAGES_SHIFT; | ||
609 | ddp_log_info("t3dev 0x%p, ddp %d + %d.\n", | ||
610 | tdev, i, npods); | ||
611 | kfree(gl); | ||
612 | ddp_free_gl_skb(ddp, i, npods); | ||
613 | i += npods; | ||
614 | } else | ||
615 | i++; | ||
616 | } | ||
617 | cxgb3i_free_big_mem(ddp); | ||
618 | } | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * ddp_init - initialize the cxgb3 adapter's ddp resource | ||
623 | * @tdev: t3cdev adapter | ||
624 | * initialize the ddp pagepod manager for a given adapter | ||
625 | */ | ||
626 | static void ddp_init(struct t3cdev *tdev) | ||
568 | { | 627 | { |
569 | struct cxgb3i_ddp_info *ddp; | 628 | struct cxgb3i_ddp_info *ddp; |
570 | struct ulp_iscsi_info uinfo; | 629 | struct ulp_iscsi_info uinfo; |
571 | unsigned int ppmax, bits; | 630 | unsigned int ppmax, bits; |
572 | int i, err; | 631 | int i, err; |
573 | static int vers_printed; | ||
574 | 632 | ||
575 | if (!vers_printed) { | 633 | if (tdev->ulp_iscsi) { |
576 | printk(KERN_INFO "%s", version); | 634 | ddp_log_warn("t3dev 0x%p, ddp 0x%p already set up.\n", |
577 | vers_printed = 1; | 635 | tdev, tdev->ulp_iscsi); |
636 | return; | ||
578 | } | 637 | } |
579 | 638 | ||
580 | err = tdev->ctl(tdev, ULP_ISCSI_GET_PARAMS, &uinfo); | 639 | err = tdev->ctl(tdev, ULP_ISCSI_GET_PARAMS, &uinfo); |
581 | if (err < 0) { | 640 | if (err < 0) { |
582 | ddp_log_error("%s, failed to get iscsi param err=%d.\n", | 641 | ddp_log_error("%s, failed to get iscsi param err=%d.\n", |
583 | tdev->name, err); | 642 | tdev->name, err); |
584 | return err; | 643 | return; |
585 | } | 644 | } |
586 | 645 | ||
587 | ppmax = (uinfo.ulimit - uinfo.llimit + 1) >> PPOD_SIZE_SHIFT; | 646 | ppmax = (uinfo.ulimit - uinfo.llimit + 1) >> PPOD_SIZE_SHIFT; |
@@ -598,7 +657,7 @@ static int ddp_init(struct t3cdev *tdev) | |||
598 | if (!ddp) { | 657 | if (!ddp) { |
599 | ddp_log_warn("%s unable to alloc ddp 0x%d, ddp disabled.\n", | 658 | ddp_log_warn("%s unable to alloc ddp 0x%d, ddp disabled.\n", |
600 | tdev->name, ppmax); | 659 | tdev->name, ppmax); |
601 | return 0; | 660 | return; |
602 | } | 661 | } |
603 | ddp->gl_map = (struct cxgb3i_gather_list **)(ddp + 1); | 662 | ddp->gl_map = (struct cxgb3i_gather_list **)(ddp + 1); |
604 | ddp->gl_skb = (struct sk_buff **)(((char *)ddp->gl_map) + | 663 | ddp->gl_skb = (struct sk_buff **)(((char *)ddp->gl_map) + |
@@ -632,142 +691,26 @@ static int ddp_init(struct t3cdev *tdev) | |||
632 | 691 | ||
633 | tdev->ulp_iscsi = ddp; | 692 | tdev->ulp_iscsi = ddp; |
634 | 693 | ||
635 | /* add to the list */ | 694 | ddp_log_info("tdev 0x%p, nppods %u, bits %u, mask 0x%x,0x%x pkt %u/%u," |
636 | write_lock(&cxgb3i_ddp_rwlock); | 695 | " %u/%u.\n", |
637 | list_add_tail(&ddp->list, &cxgb3i_ddp_list); | 696 | tdev, ppmax, ddp->idx_bits, ddp->idx_mask, |
638 | write_unlock(&cxgb3i_ddp_rwlock); | 697 | ddp->rsvd_tag_mask, ddp->max_txsz, uinfo.max_txsz, |
639 | |||
640 | ddp_log_info("nppods %u (0x%x ~ 0x%x), bits %u, mask 0x%x,0x%x " | ||
641 | "pkt %u/%u, %u/%u.\n", | ||
642 | ppmax, ddp->llimit, ddp->ulimit, ddp->idx_bits, | ||
643 | ddp->idx_mask, ddp->rsvd_tag_mask, | ||
644 | ddp->max_txsz, uinfo.max_txsz, | ||
645 | ddp->max_rxsz, uinfo.max_rxsz); | 698 | ddp->max_rxsz, uinfo.max_rxsz); |
646 | return 0; | 699 | return; |
647 | 700 | ||
648 | free_ddp_map: | 701 | free_ddp_map: |
649 | cxgb3i_free_big_mem(ddp); | 702 | cxgb3i_free_big_mem(ddp); |
650 | return err; | ||
651 | } | ||
652 | |||
653 | /** | ||
654 | * cxgb3i_adapter_ddp_init - initialize the adapter's ddp resource | ||
655 | * @tdev: t3cdev adapter | ||
656 | * @tformat: tag format | ||
657 | * @txsz: max tx pdu payload size, filled in by this func. | ||
658 | * @rxsz: max rx pdu payload size, filled in by this func. | ||
659 | * initialize the ddp pagepod manager for a given adapter if needed and | ||
660 | * setup the tag format for a given iscsi entity | ||
661 | */ | ||
662 | int cxgb3i_adapter_ddp_init(struct t3cdev *tdev, | ||
663 | struct cxgb3i_tag_format *tformat, | ||
664 | unsigned int *txsz, unsigned int *rxsz) | ||
665 | { | ||
666 | struct cxgb3i_ddp_info *ddp; | ||
667 | unsigned char idx_bits; | ||
668 | |||
669 | if (!tformat) | ||
670 | return -EINVAL; | ||
671 | |||
672 | if (!tdev->ulp_iscsi) { | ||
673 | int err = ddp_init(tdev); | ||
674 | if (err < 0) | ||
675 | return err; | ||
676 | } | ||
677 | ddp = (struct cxgb3i_ddp_info *)tdev->ulp_iscsi; | ||
678 | |||
679 | idx_bits = 32 - tformat->sw_bits; | ||
680 | tformat->rsvd_bits = ddp->idx_bits; | ||
681 | tformat->rsvd_shift = PPOD_IDX_SHIFT; | ||
682 | tformat->rsvd_mask = (1 << tformat->rsvd_bits) - 1; | ||
683 | |||
684 | ddp_log_info("tag format: sw %u, rsvd %u,%u, mask 0x%x.\n", | ||
685 | tformat->sw_bits, tformat->rsvd_bits, | ||
686 | tformat->rsvd_shift, tformat->rsvd_mask); | ||
687 | |||
688 | *txsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD, | ||
689 | ddp->max_txsz - ISCSI_PDU_NONPAYLOAD_LEN); | ||
690 | *rxsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD, | ||
691 | ddp->max_rxsz - ISCSI_PDU_NONPAYLOAD_LEN); | ||
692 | ddp_log_info("max payload size: %u/%u, %u/%u.\n", | ||
693 | *txsz, ddp->max_txsz, *rxsz, ddp->max_rxsz); | ||
694 | return 0; | ||
695 | } | ||
696 | EXPORT_SYMBOL_GPL(cxgb3i_adapter_ddp_init); | ||
697 | |||
698 | static void ddp_release(struct cxgb3i_ddp_info *ddp) | ||
699 | { | ||
700 | int i = 0; | ||
701 | struct t3cdev *tdev = ddp->tdev; | ||
702 | |||
703 | tdev->ulp_iscsi = NULL; | ||
704 | while (i < ddp->nppods) { | ||
705 | struct cxgb3i_gather_list *gl = ddp->gl_map[i]; | ||
706 | if (gl) { | ||
707 | int npods = (gl->nelem + PPOD_PAGES_MAX - 1) | ||
708 | >> PPOD_PAGES_SHIFT; | ||
709 | |||
710 | kfree(gl); | ||
711 | ddp_free_gl_skb(ddp, i, npods); | ||
712 | } else | ||
713 | i++; | ||
714 | } | ||
715 | cxgb3i_free_big_mem(ddp); | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * cxgb3i_adapter_ddp_cleanup - release the adapter's ddp resource | ||
720 | * @tdev: t3cdev adapter | ||
721 | * release all the resource held by the ddp pagepod manager for a given | ||
722 | * adapter if needed | ||
723 | */ | ||
724 | void cxgb3i_adapter_ddp_cleanup(struct t3cdev *tdev) | ||
725 | { | ||
726 | struct cxgb3i_ddp_info *ddp; | ||
727 | |||
728 | /* remove from the list */ | ||
729 | write_lock(&cxgb3i_ddp_rwlock); | ||
730 | list_for_each_entry(ddp, &cxgb3i_ddp_list, list) { | ||
731 | if (ddp->tdev == tdev) { | ||
732 | list_del(&ddp->list); | ||
733 | break; | ||
734 | } | ||
735 | } | ||
736 | write_unlock(&cxgb3i_ddp_rwlock); | ||
737 | |||
738 | if (ddp) | ||
739 | ddp_release(ddp); | ||
740 | } | ||
741 | EXPORT_SYMBOL_GPL(cxgb3i_adapter_ddp_cleanup); | ||
742 | |||
743 | /** | ||
744 | * cxgb3i_ddp_init_module - module init entry point | ||
745 | * initialize any driver wide global data structures | ||
746 | */ | ||
747 | static int __init cxgb3i_ddp_init_module(void) | ||
748 | { | ||
749 | page_idx = cxgb3i_ddp_find_page_index(PAGE_SIZE); | ||
750 | ddp_log_info("system PAGE_SIZE %lu, ddp idx %u.\n", | ||
751 | PAGE_SIZE, page_idx); | ||
752 | return 0; | ||
753 | } | 703 | } |
754 | 704 | ||
755 | /** | 705 | /** |
756 | * cxgb3i_ddp_exit_module - module cleanup/exit entry point | 706 | * cxgb3i_ddp_init - initialize ddp functions |
757 | * go through the ddp list and release any resource held. | ||
758 | */ | 707 | */ |
759 | static void __exit cxgb3i_ddp_exit_module(void) | 708 | void cxgb3i_ddp_init(struct t3cdev *tdev) |
760 | { | 709 | { |
761 | struct cxgb3i_ddp_info *ddp; | 710 | if (page_idx == DDP_PGIDX_MAX) { |
762 | 711 | page_idx = cxgb3i_ddp_find_page_index(PAGE_SIZE); | |
763 | /* release all ddp manager if there is any */ | 712 | ddp_log_info("system PAGE_SIZE %lu, ddp idx %u.\n", |
764 | write_lock(&cxgb3i_ddp_rwlock); | 713 | PAGE_SIZE, page_idx); |
765 | list_for_each_entry(ddp, &cxgb3i_ddp_list, list) { | ||
766 | list_del(&ddp->list); | ||
767 | ddp_release(ddp); | ||
768 | } | 714 | } |
769 | write_unlock(&cxgb3i_ddp_rwlock); | 715 | ddp_init(tdev); |
770 | } | 716 | } |
771 | |||
772 | module_init(cxgb3i_ddp_init_module); | ||
773 | module_exit(cxgb3i_ddp_exit_module); | ||