diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2011-07-20 20:04:24 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-07-27 06:57:31 -0400 |
commit | 4c5d22bf7bdea68d3d449f6a8e1835da84909346 (patch) | |
tree | fb891101e865e1794c2c4cca71e1f0ecc6485bcb /drivers/scsi/bfa/bfa_fcpim.c | |
parent | 83763d591b343b07331cebe86715205230c568b1 (diff) |
[SCSI] bfa: Added support to configure lunmasking
- Added support to enable / disable lunmasking on Brocade adapter ports.
- Added support to query / clear lunmasking configuration.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfa_fcpim.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_fcpim.c | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c index e601f178c5a6..e07bd4745d8b 100644 --- a/drivers/scsi/bfa/bfa_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcpim.c | |||
@@ -2553,6 +2553,200 @@ bfa_fcpim_lunmask_rp_update(struct bfa_s *bfa, wwn_t lp_wwn, wwn_t rp_wwn, | |||
2553 | } | 2553 | } |
2554 | } | 2554 | } |
2555 | 2555 | ||
2556 | /* | ||
2557 | * set UA for all active luns in LM DB | ||
2558 | */ | ||
2559 | static void | ||
2560 | bfa_ioim_lm_set_ua(struct bfa_s *bfa) | ||
2561 | { | ||
2562 | struct bfa_lun_mask_s *lunm_list; | ||
2563 | int i; | ||
2564 | |||
2565 | lunm_list = bfa_get_lun_mask_list(bfa); | ||
2566 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2567 | if (lunm_list[i].state != BFA_IOIM_LUN_MASK_ACTIVE) | ||
2568 | continue; | ||
2569 | lunm_list[i].ua = BFA_IOIM_LM_UA_SET; | ||
2570 | } | ||
2571 | } | ||
2572 | |||
2573 | bfa_status_t | ||
2574 | bfa_fcpim_lunmask_update(struct bfa_s *bfa, u32 update) | ||
2575 | { | ||
2576 | struct bfa_lunmask_cfg_s *lun_mask; | ||
2577 | |||
2578 | bfa_trc(bfa, bfa_get_lun_mask_status(bfa)); | ||
2579 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG) | ||
2580 | return BFA_STATUS_FAILED; | ||
2581 | |||
2582 | if (bfa_get_lun_mask_status(bfa) == update) | ||
2583 | return BFA_STATUS_NO_CHANGE; | ||
2584 | |||
2585 | lun_mask = bfa_get_lun_mask(bfa); | ||
2586 | lun_mask->status = update; | ||
2587 | |||
2588 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_ENABLED) | ||
2589 | bfa_ioim_lm_set_ua(bfa); | ||
2590 | |||
2591 | return bfa_dconf_update(bfa); | ||
2592 | } | ||
2593 | |||
2594 | bfa_status_t | ||
2595 | bfa_fcpim_lunmask_clear(struct bfa_s *bfa) | ||
2596 | { | ||
2597 | int i; | ||
2598 | struct bfa_lun_mask_s *lunm_list; | ||
2599 | |||
2600 | bfa_trc(bfa, bfa_get_lun_mask_status(bfa)); | ||
2601 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG) | ||
2602 | return BFA_STATUS_FAILED; | ||
2603 | |||
2604 | lunm_list = bfa_get_lun_mask_list(bfa); | ||
2605 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2606 | if (lunm_list[i].state == BFA_IOIM_LUN_MASK_ACTIVE) { | ||
2607 | if (lunm_list[i].rp_tag != BFA_RPORT_TAG_INVALID) | ||
2608 | bfa_rport_unset_lunmask(bfa, | ||
2609 | BFA_RPORT_FROM_TAG(bfa, lunm_list[i].rp_tag)); | ||
2610 | } | ||
2611 | } | ||
2612 | |||
2613 | memset(lunm_list, 0, sizeof(struct bfa_lun_mask_s) * MAX_LUN_MASK_CFG); | ||
2614 | return bfa_dconf_update(bfa); | ||
2615 | } | ||
2616 | |||
2617 | bfa_status_t | ||
2618 | bfa_fcpim_lunmask_query(struct bfa_s *bfa, void *buf) | ||
2619 | { | ||
2620 | struct bfa_lunmask_cfg_s *lun_mask; | ||
2621 | |||
2622 | bfa_trc(bfa, bfa_get_lun_mask_status(bfa)); | ||
2623 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG) | ||
2624 | return BFA_STATUS_FAILED; | ||
2625 | |||
2626 | lun_mask = bfa_get_lun_mask(bfa); | ||
2627 | memcpy(buf, lun_mask, sizeof(struct bfa_lunmask_cfg_s)); | ||
2628 | return BFA_STATUS_OK; | ||
2629 | } | ||
2630 | |||
2631 | bfa_status_t | ||
2632 | bfa_fcpim_lunmask_add(struct bfa_s *bfa, u16 vf_id, wwn_t *pwwn, | ||
2633 | wwn_t rpwwn, struct scsi_lun lun) | ||
2634 | { | ||
2635 | struct bfa_lun_mask_s *lunm_list; | ||
2636 | struct bfa_rport_s *rp = NULL; | ||
2637 | int i, free_index = MAX_LUN_MASK_CFG + 1; | ||
2638 | struct bfa_fcs_lport_s *port = NULL; | ||
2639 | struct bfa_fcs_rport_s *rp_fcs; | ||
2640 | |||
2641 | bfa_trc(bfa, bfa_get_lun_mask_status(bfa)); | ||
2642 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG) | ||
2643 | return BFA_STATUS_FAILED; | ||
2644 | |||
2645 | port = bfa_fcs_lookup_port(&((struct bfad_s *)bfa->bfad)->bfa_fcs, | ||
2646 | vf_id, *pwwn); | ||
2647 | if (port) { | ||
2648 | *pwwn = port->port_cfg.pwwn; | ||
2649 | rp_fcs = bfa_fcs_lport_get_rport_by_pwwn(port, rpwwn); | ||
2650 | rp = rp_fcs->bfa_rport; | ||
2651 | } | ||
2652 | |||
2653 | lunm_list = bfa_get_lun_mask_list(bfa); | ||
2654 | /* if entry exists */ | ||
2655 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2656 | if (lunm_list[i].state != BFA_IOIM_LUN_MASK_ACTIVE) | ||
2657 | free_index = i; | ||
2658 | if ((lunm_list[i].lp_wwn == *pwwn) && | ||
2659 | (lunm_list[i].rp_wwn == rpwwn) && | ||
2660 | (scsilun_to_int((struct scsi_lun *)&lunm_list[i].lun) == | ||
2661 | scsilun_to_int((struct scsi_lun *)&lun))) | ||
2662 | return BFA_STATUS_ENTRY_EXISTS; | ||
2663 | } | ||
2664 | |||
2665 | if (free_index > MAX_LUN_MASK_CFG) | ||
2666 | return BFA_STATUS_MAX_ENTRY_REACHED; | ||
2667 | |||
2668 | if (rp) { | ||
2669 | lunm_list[free_index].lp_tag = bfa_lps_get_tag_from_pid(bfa, | ||
2670 | rp->rport_info.local_pid); | ||
2671 | lunm_list[free_index].rp_tag = rp->rport_tag; | ||
2672 | } else { | ||
2673 | lunm_list[free_index].lp_tag = BFA_LP_TAG_INVALID; | ||
2674 | lunm_list[free_index].rp_tag = BFA_RPORT_TAG_INVALID; | ||
2675 | } | ||
2676 | |||
2677 | lunm_list[free_index].lp_wwn = *pwwn; | ||
2678 | lunm_list[free_index].rp_wwn = rpwwn; | ||
2679 | lunm_list[free_index].lun = lun; | ||
2680 | lunm_list[free_index].state = BFA_IOIM_LUN_MASK_ACTIVE; | ||
2681 | |||
2682 | /* set for all luns in this rp */ | ||
2683 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2684 | if ((lunm_list[i].lp_wwn == *pwwn) && | ||
2685 | (lunm_list[i].rp_wwn == rpwwn)) | ||
2686 | lunm_list[i].ua = BFA_IOIM_LM_UA_SET; | ||
2687 | } | ||
2688 | |||
2689 | return bfa_dconf_update(bfa); | ||
2690 | } | ||
2691 | |||
2692 | bfa_status_t | ||
2693 | bfa_fcpim_lunmask_delete(struct bfa_s *bfa, u16 vf_id, wwn_t *pwwn, | ||
2694 | wwn_t rpwwn, struct scsi_lun lun) | ||
2695 | { | ||
2696 | struct bfa_lun_mask_s *lunm_list; | ||
2697 | struct bfa_rport_s *rp = NULL; | ||
2698 | struct bfa_fcs_lport_s *port = NULL; | ||
2699 | struct bfa_fcs_rport_s *rp_fcs; | ||
2700 | int i; | ||
2701 | |||
2702 | /* in min cfg lunm_list could be NULL but no commands should run. */ | ||
2703 | if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG) | ||
2704 | return BFA_STATUS_FAILED; | ||
2705 | |||
2706 | bfa_trc(bfa, bfa_get_lun_mask_status(bfa)); | ||
2707 | bfa_trc(bfa, *pwwn); | ||
2708 | bfa_trc(bfa, rpwwn); | ||
2709 | bfa_trc(bfa, scsilun_to_int((struct scsi_lun *)&lun)); | ||
2710 | |||
2711 | if (*pwwn == 0) { | ||
2712 | port = bfa_fcs_lookup_port( | ||
2713 | &((struct bfad_s *)bfa->bfad)->bfa_fcs, | ||
2714 | vf_id, *pwwn); | ||
2715 | if (port) { | ||
2716 | *pwwn = port->port_cfg.pwwn; | ||
2717 | rp_fcs = bfa_fcs_lport_get_rport_by_pwwn(port, rpwwn); | ||
2718 | rp = rp_fcs->bfa_rport; | ||
2719 | } | ||
2720 | } | ||
2721 | |||
2722 | lunm_list = bfa_get_lun_mask_list(bfa); | ||
2723 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2724 | if ((lunm_list[i].lp_wwn == *pwwn) && | ||
2725 | (lunm_list[i].rp_wwn == rpwwn) && | ||
2726 | (scsilun_to_int((struct scsi_lun *)&lunm_list[i].lun) == | ||
2727 | scsilun_to_int((struct scsi_lun *)&lun))) { | ||
2728 | lunm_list[i].lp_wwn = 0; | ||
2729 | lunm_list[i].rp_wwn = 0; | ||
2730 | int_to_scsilun(0, &lunm_list[i].lun); | ||
2731 | lunm_list[i].state = BFA_IOIM_LUN_MASK_INACTIVE; | ||
2732 | if (lunm_list[i].rp_tag != BFA_RPORT_TAG_INVALID) { | ||
2733 | lunm_list[i].rp_tag = BFA_RPORT_TAG_INVALID; | ||
2734 | lunm_list[i].lp_tag = BFA_LP_TAG_INVALID; | ||
2735 | } | ||
2736 | return bfa_dconf_update(bfa); | ||
2737 | } | ||
2738 | } | ||
2739 | |||
2740 | /* set for all luns in this rp */ | ||
2741 | for (i = 0; i < MAX_LUN_MASK_CFG; i++) { | ||
2742 | if ((lunm_list[i].lp_wwn == *pwwn) && | ||
2743 | (lunm_list[i].rp_wwn == rpwwn)) | ||
2744 | lunm_list[i].ua = BFA_IOIM_LM_UA_SET; | ||
2745 | } | ||
2746 | |||
2747 | return BFA_STATUS_ENTRY_NOT_EXISTS; | ||
2748 | } | ||
2749 | |||
2556 | static void | 2750 | static void |
2557 | __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete) | 2751 | __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete) |
2558 | { | 2752 | { |