diff options
Diffstat (limited to 'drivers/scsi/bfa/bfad_bsg.c')
-rw-r--r-- | drivers/scsi/bfa/bfad_bsg.c | 127 |
1 files changed, 124 insertions, 3 deletions
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 0ab1d400ac33..555e7db94a1c 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c | |||
@@ -107,9 +107,10 @@ bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd) | |||
107 | 107 | ||
108 | /* set adapter hw path */ | 108 | /* set adapter hw path */ |
109 | strcpy(iocmd->adapter_hwpath, bfad->pci_name); | 109 | strcpy(iocmd->adapter_hwpath, bfad->pci_name); |
110 | i = strlen(iocmd->adapter_hwpath) - 1; | 110 | for (i = 0; iocmd->adapter_hwpath[i] != ':' && i < BFA_STRING_32; i++) |
111 | while (iocmd->adapter_hwpath[i] != '.') | 111 | ; |
112 | i--; | 112 | for (; iocmd->adapter_hwpath[++i] != ':' && i < BFA_STRING_32; ) |
113 | ; | ||
113 | iocmd->adapter_hwpath[i] = '\0'; | 114 | iocmd->adapter_hwpath[i] = '\0'; |
114 | iocmd->status = BFA_STATUS_OK; | 115 | iocmd->status = BFA_STATUS_OK; |
115 | return 0; | 116 | return 0; |
@@ -2583,6 +2584,109 @@ bfad_iocmd_fcpim_throttle_set(struct bfad_s *bfad, void *cmd) | |||
2583 | return 0; | 2584 | return 0; |
2584 | } | 2585 | } |
2585 | 2586 | ||
2587 | int | ||
2588 | bfad_iocmd_tfru_read(struct bfad_s *bfad, void *cmd) | ||
2589 | { | ||
2590 | struct bfa_bsg_tfru_s *iocmd = | ||
2591 | (struct bfa_bsg_tfru_s *)cmd; | ||
2592 | struct bfad_hal_comp fcomp; | ||
2593 | unsigned long flags = 0; | ||
2594 | |||
2595 | init_completion(&fcomp.comp); | ||
2596 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2597 | iocmd->status = bfa_tfru_read(BFA_FRU(&bfad->bfa), | ||
2598 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2599 | bfad_hcb_comp, &fcomp); | ||
2600 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2601 | if (iocmd->status == BFA_STATUS_OK) { | ||
2602 | wait_for_completion(&fcomp.comp); | ||
2603 | iocmd->status = fcomp.status; | ||
2604 | } | ||
2605 | |||
2606 | return 0; | ||
2607 | } | ||
2608 | |||
2609 | int | ||
2610 | bfad_iocmd_tfru_write(struct bfad_s *bfad, void *cmd) | ||
2611 | { | ||
2612 | struct bfa_bsg_tfru_s *iocmd = | ||
2613 | (struct bfa_bsg_tfru_s *)cmd; | ||
2614 | struct bfad_hal_comp fcomp; | ||
2615 | unsigned long flags = 0; | ||
2616 | |||
2617 | init_completion(&fcomp.comp); | ||
2618 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2619 | iocmd->status = bfa_tfru_write(BFA_FRU(&bfad->bfa), | ||
2620 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2621 | bfad_hcb_comp, &fcomp); | ||
2622 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2623 | if (iocmd->status == BFA_STATUS_OK) { | ||
2624 | wait_for_completion(&fcomp.comp); | ||
2625 | iocmd->status = fcomp.status; | ||
2626 | } | ||
2627 | |||
2628 | return 0; | ||
2629 | } | ||
2630 | |||
2631 | int | ||
2632 | bfad_iocmd_fruvpd_read(struct bfad_s *bfad, void *cmd) | ||
2633 | { | ||
2634 | struct bfa_bsg_fruvpd_s *iocmd = | ||
2635 | (struct bfa_bsg_fruvpd_s *)cmd; | ||
2636 | struct bfad_hal_comp fcomp; | ||
2637 | unsigned long flags = 0; | ||
2638 | |||
2639 | init_completion(&fcomp.comp); | ||
2640 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2641 | iocmd->status = bfa_fruvpd_read(BFA_FRU(&bfad->bfa), | ||
2642 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2643 | bfad_hcb_comp, &fcomp); | ||
2644 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2645 | if (iocmd->status == BFA_STATUS_OK) { | ||
2646 | wait_for_completion(&fcomp.comp); | ||
2647 | iocmd->status = fcomp.status; | ||
2648 | } | ||
2649 | |||
2650 | return 0; | ||
2651 | } | ||
2652 | |||
2653 | int | ||
2654 | bfad_iocmd_fruvpd_update(struct bfad_s *bfad, void *cmd) | ||
2655 | { | ||
2656 | struct bfa_bsg_fruvpd_s *iocmd = | ||
2657 | (struct bfa_bsg_fruvpd_s *)cmd; | ||
2658 | struct bfad_hal_comp fcomp; | ||
2659 | unsigned long flags = 0; | ||
2660 | |||
2661 | init_completion(&fcomp.comp); | ||
2662 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2663 | iocmd->status = bfa_fruvpd_update(BFA_FRU(&bfad->bfa), | ||
2664 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2665 | bfad_hcb_comp, &fcomp); | ||
2666 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2667 | if (iocmd->status == BFA_STATUS_OK) { | ||
2668 | wait_for_completion(&fcomp.comp); | ||
2669 | iocmd->status = fcomp.status; | ||
2670 | } | ||
2671 | |||
2672 | return 0; | ||
2673 | } | ||
2674 | |||
2675 | int | ||
2676 | bfad_iocmd_fruvpd_get_max_size(struct bfad_s *bfad, void *cmd) | ||
2677 | { | ||
2678 | struct bfa_bsg_fruvpd_max_size_s *iocmd = | ||
2679 | (struct bfa_bsg_fruvpd_max_size_s *)cmd; | ||
2680 | unsigned long flags = 0; | ||
2681 | |||
2682 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2683 | iocmd->status = bfa_fruvpd_get_max_size(BFA_FRU(&bfad->bfa), | ||
2684 | &iocmd->max_size); | ||
2685 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2686 | |||
2687 | return 0; | ||
2688 | } | ||
2689 | |||
2586 | static int | 2690 | static int |
2587 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | 2691 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, |
2588 | unsigned int payload_len) | 2692 | unsigned int payload_len) |
@@ -2923,6 +3027,23 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
2923 | case IOCMD_FCPIM_THROTTLE_SET: | 3027 | case IOCMD_FCPIM_THROTTLE_SET: |
2924 | rc = bfad_iocmd_fcpim_throttle_set(bfad, iocmd); | 3028 | rc = bfad_iocmd_fcpim_throttle_set(bfad, iocmd); |
2925 | break; | 3029 | break; |
3030 | /* TFRU */ | ||
3031 | case IOCMD_TFRU_READ: | ||
3032 | rc = bfad_iocmd_tfru_read(bfad, iocmd); | ||
3033 | break; | ||
3034 | case IOCMD_TFRU_WRITE: | ||
3035 | rc = bfad_iocmd_tfru_write(bfad, iocmd); | ||
3036 | break; | ||
3037 | /* FRU */ | ||
3038 | case IOCMD_FRUVPD_READ: | ||
3039 | rc = bfad_iocmd_fruvpd_read(bfad, iocmd); | ||
3040 | break; | ||
3041 | case IOCMD_FRUVPD_UPDATE: | ||
3042 | rc = bfad_iocmd_fruvpd_update(bfad, iocmd); | ||
3043 | break; | ||
3044 | case IOCMD_FRUVPD_GET_MAX_SIZE: | ||
3045 | rc = bfad_iocmd_fruvpd_get_max_size(bfad, iocmd); | ||
3046 | break; | ||
2926 | default: | 3047 | default: |
2927 | rc = -EINVAL; | 3048 | rc = -EINVAL; |
2928 | break; | 3049 | break; |