diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2011-07-20 20:01:34 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-07-27 06:46:12 -0400 |
commit | f2ee76017b30c84f128dfbf716950ffc0e4d949a (patch) | |
tree | f1459794f89f68f7c9bbd1c829df257aa4c1637a /drivers/scsi/bfa/bfad_bsg.c | |
parent | fb778b06299f424c4db60817bd3dcfcaad3a8a75 (diff) |
[SCSI] bfa: Extend BSG to support more user commands
Extended BSG to support stats, port log and trace reset and to support
adapter, port SET operations.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfad_bsg.c')
-rw-r--r-- | drivers/scsi/bfa/bfad_bsg.c | 535 |
1 files changed, 535 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 3601508900b3..45753dcba571 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c | |||
@@ -179,6 +179,38 @@ out: | |||
179 | } | 179 | } |
180 | 180 | ||
181 | int | 181 | int |
182 | bfad_iocmd_ioc_reset_stats(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | ||
183 | { | ||
184 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd; | ||
185 | unsigned long flags; | ||
186 | |||
187 | if (v_cmd == IOCMD_IOC_RESET_STATS) { | ||
188 | bfa_ioc_clear_stats(&bfad->bfa); | ||
189 | iocmd->status = BFA_STATUS_OK; | ||
190 | } else if (v_cmd == IOCMD_IOC_RESET_FWSTATS) { | ||
191 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
192 | iocmd->status = bfa_ioc_fw_stats_clear(&bfad->bfa.ioc); | ||
193 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
194 | } | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | int | ||
200 | bfad_iocmd_ioc_set_name(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | ||
201 | { | ||
202 | struct bfa_bsg_ioc_name_s *iocmd = (struct bfa_bsg_ioc_name_s *) cmd; | ||
203 | |||
204 | if (v_cmd == IOCMD_IOC_SET_ADAPTER_NAME) | ||
205 | strcpy(bfad->adapter_name, iocmd->name); | ||
206 | else if (v_cmd == IOCMD_IOC_SET_PORT_NAME) | ||
207 | strcpy(bfad->port_name, iocmd->name); | ||
208 | |||
209 | iocmd->status = BFA_STATUS_OK; | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | int | ||
182 | bfad_iocmd_iocfc_get_attr(struct bfad_s *bfad, void *cmd) | 214 | bfad_iocmd_iocfc_get_attr(struct bfad_s *bfad, void *cmd) |
183 | { | 215 | { |
184 | struct bfa_bsg_iocfc_attr_s *iocmd = (struct bfa_bsg_iocfc_attr_s *)cmd; | 216 | struct bfa_bsg_iocfc_attr_s *iocmd = (struct bfa_bsg_iocfc_attr_s *)cmd; |
@@ -307,6 +339,81 @@ out: | |||
307 | return 0; | 339 | return 0; |
308 | } | 340 | } |
309 | 341 | ||
342 | int | ||
343 | bfad_iocmd_port_reset_stats(struct bfad_s *bfad, void *cmd) | ||
344 | { | ||
345 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd; | ||
346 | struct bfad_hal_comp fcomp; | ||
347 | unsigned long flags; | ||
348 | |||
349 | init_completion(&fcomp.comp); | ||
350 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
351 | iocmd->status = bfa_port_clear_stats(&bfad->bfa.modules.port, | ||
352 | bfad_hcb_comp, &fcomp); | ||
353 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
354 | if (iocmd->status != BFA_STATUS_OK) { | ||
355 | bfa_trc(bfad, iocmd->status); | ||
356 | return 0; | ||
357 | } | ||
358 | wait_for_completion(&fcomp.comp); | ||
359 | iocmd->status = fcomp.status; | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | int | ||
364 | bfad_iocmd_set_port_cfg(struct bfad_s *bfad, void *iocmd, unsigned int v_cmd) | ||
365 | { | ||
366 | struct bfa_bsg_port_cfg_s *cmd = (struct bfa_bsg_port_cfg_s *)iocmd; | ||
367 | unsigned long flags; | ||
368 | |||
369 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
370 | if (v_cmd == IOCMD_PORT_CFG_TOPO) | ||
371 | cmd->status = bfa_fcport_cfg_topology(&bfad->bfa, cmd->param); | ||
372 | else if (v_cmd == IOCMD_PORT_CFG_SPEED) | ||
373 | cmd->status = bfa_fcport_cfg_speed(&bfad->bfa, cmd->param); | ||
374 | else if (v_cmd == IOCMD_PORT_CFG_ALPA) | ||
375 | cmd->status = bfa_fcport_cfg_hardalpa(&bfad->bfa, cmd->param); | ||
376 | else if (v_cmd == IOCMD_PORT_CLR_ALPA) | ||
377 | cmd->status = bfa_fcport_clr_hardalpa(&bfad->bfa); | ||
378 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | int | ||
384 | bfad_iocmd_port_cfg_maxfrsize(struct bfad_s *bfad, void *cmd) | ||
385 | { | ||
386 | struct bfa_bsg_port_cfg_maxfrsize_s *iocmd = | ||
387 | (struct bfa_bsg_port_cfg_maxfrsize_s *)cmd; | ||
388 | unsigned long flags; | ||
389 | |||
390 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
391 | iocmd->status = bfa_fcport_cfg_maxfrsize(&bfad->bfa, iocmd->maxfrsize); | ||
392 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
393 | |||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | int | ||
398 | bfad_iocmd_port_cfg_bbsc(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | ||
399 | { | ||
400 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd; | ||
401 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); | ||
402 | unsigned long flags; | ||
403 | |||
404 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
405 | if (bfa_ioc_get_type(&bfad->bfa.ioc) == BFA_IOC_TYPE_FC) { | ||
406 | if (v_cmd == IOCMD_PORT_BBSC_ENABLE) | ||
407 | fcport->cfg.bb_scn_state = BFA_TRUE; | ||
408 | else if (v_cmd == IOCMD_PORT_BBSC_DISABLE) | ||
409 | fcport->cfg.bb_scn_state = BFA_FALSE; | ||
410 | } | ||
411 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
412 | |||
413 | iocmd->status = BFA_STATUS_OK; | ||
414 | return 0; | ||
415 | } | ||
416 | |||
310 | static int | 417 | static int |
311 | bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd) | 418 | bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd) |
312 | { | 419 | { |
@@ -355,6 +462,40 @@ out: | |||
355 | } | 462 | } |
356 | 463 | ||
357 | int | 464 | int |
465 | bfad_iocmd_lport_reset_stats(struct bfad_s *bfad, void *cmd) | ||
466 | { | ||
467 | struct bfa_fcs_lport_s *fcs_port; | ||
468 | struct bfa_bsg_reset_stats_s *iocmd = | ||
469 | (struct bfa_bsg_reset_stats_s *)cmd; | ||
470 | struct bfa_fcpim_s *fcpim = BFA_FCPIM(&bfad->bfa); | ||
471 | struct list_head *qe, *qen; | ||
472 | struct bfa_itnim_s *itnim; | ||
473 | unsigned long flags; | ||
474 | |||
475 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
476 | fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs, | ||
477 | iocmd->vf_id, iocmd->vpwwn); | ||
478 | if (fcs_port == NULL) { | ||
479 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
480 | iocmd->status = BFA_STATUS_UNKNOWN_LWWN; | ||
481 | goto out; | ||
482 | } | ||
483 | |||
484 | bfa_fcs_lport_clear_stats(fcs_port); | ||
485 | /* clear IO stats from all active itnims */ | ||
486 | list_for_each_safe(qe, qen, &fcpim->itnim_q) { | ||
487 | itnim = (struct bfa_itnim_s *) qe; | ||
488 | if (itnim->rport->rport_info.lp_tag != fcs_port->lp_tag) | ||
489 | continue; | ||
490 | bfa_itnim_clear_stats(itnim); | ||
491 | } | ||
492 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
493 | iocmd->status = BFA_STATUS_OK; | ||
494 | out: | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | int | ||
358 | bfad_iocmd_lport_get_iostats(struct bfad_s *bfad, void *cmd) | 499 | bfad_iocmd_lport_get_iostats(struct bfad_s *bfad, void *cmd) |
359 | { | 500 | { |
360 | struct bfa_fcs_lport_s *fcs_port; | 501 | struct bfa_fcs_lport_s *fcs_port; |
@@ -540,6 +681,152 @@ out: | |||
540 | return 0; | 681 | return 0; |
541 | } | 682 | } |
542 | 683 | ||
684 | int | ||
685 | bfad_iocmd_rport_clr_stats(struct bfad_s *bfad, void *cmd) | ||
686 | { | ||
687 | struct bfa_bsg_rport_reset_stats_s *iocmd = | ||
688 | (struct bfa_bsg_rport_reset_stats_s *)cmd; | ||
689 | struct bfa_fcs_lport_s *fcs_port; | ||
690 | struct bfa_fcs_rport_s *fcs_rport; | ||
691 | struct bfa_rport_s *rport; | ||
692 | unsigned long flags; | ||
693 | |||
694 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
695 | fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs, | ||
696 | iocmd->vf_id, iocmd->pwwn); | ||
697 | if (fcs_port == NULL) { | ||
698 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
699 | iocmd->status = BFA_STATUS_UNKNOWN_LWWN; | ||
700 | goto out; | ||
701 | } | ||
702 | |||
703 | fcs_rport = bfa_fcs_rport_lookup(fcs_port, iocmd->rpwwn); | ||
704 | if (fcs_rport == NULL) { | ||
705 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
706 | iocmd->status = BFA_STATUS_UNKNOWN_RWWN; | ||
707 | goto out; | ||
708 | } | ||
709 | |||
710 | memset((char *)&fcs_rport->stats, 0, sizeof(struct bfa_rport_stats_s)); | ||
711 | rport = bfa_fcs_rport_get_halrport(fcs_rport); | ||
712 | memset(&rport->stats, 0, sizeof(rport->stats)); | ||
713 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
714 | iocmd->status = BFA_STATUS_OK; | ||
715 | out: | ||
716 | return 0; | ||
717 | } | ||
718 | |||
719 | int | ||
720 | bfad_iocmd_rport_set_speed(struct bfad_s *bfad, void *cmd) | ||
721 | { | ||
722 | struct bfa_bsg_rport_set_speed_s *iocmd = | ||
723 | (struct bfa_bsg_rport_set_speed_s *)cmd; | ||
724 | struct bfa_fcs_lport_s *fcs_port; | ||
725 | struct bfa_fcs_rport_s *fcs_rport; | ||
726 | unsigned long flags; | ||
727 | |||
728 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
729 | fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs, | ||
730 | iocmd->vf_id, iocmd->pwwn); | ||
731 | if (fcs_port == NULL) { | ||
732 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
733 | iocmd->status = BFA_STATUS_UNKNOWN_LWWN; | ||
734 | goto out; | ||
735 | } | ||
736 | |||
737 | fcs_rport = bfa_fcs_rport_lookup(fcs_port, iocmd->rpwwn); | ||
738 | if (fcs_rport == NULL) { | ||
739 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
740 | iocmd->status = BFA_STATUS_UNKNOWN_RWWN; | ||
741 | goto out; | ||
742 | } | ||
743 | |||
744 | fcs_rport->rpf.assigned_speed = iocmd->speed; | ||
745 | /* Set this speed in f/w only if the RPSC speed is not available */ | ||
746 | if (fcs_rport->rpf.rpsc_speed == BFA_PORT_SPEED_UNKNOWN) | ||
747 | bfa_rport_speed(fcs_rport->bfa_rport, iocmd->speed); | ||
748 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
749 | iocmd->status = BFA_STATUS_OK; | ||
750 | out: | ||
751 | return 0; | ||
752 | } | ||
753 | |||
754 | int | ||
755 | bfad_iocmd_vport_get_attr(struct bfad_s *bfad, void *cmd) | ||
756 | { | ||
757 | struct bfa_fcs_vport_s *fcs_vport; | ||
758 | struct bfa_bsg_vport_attr_s *iocmd = (struct bfa_bsg_vport_attr_s *)cmd; | ||
759 | unsigned long flags; | ||
760 | |||
761 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
762 | fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, | ||
763 | iocmd->vf_id, iocmd->vpwwn); | ||
764 | if (fcs_vport == NULL) { | ||
765 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
766 | iocmd->status = BFA_STATUS_UNKNOWN_VWWN; | ||
767 | goto out; | ||
768 | } | ||
769 | |||
770 | bfa_fcs_vport_get_attr(fcs_vport, &iocmd->vport_attr); | ||
771 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
772 | iocmd->status = BFA_STATUS_OK; | ||
773 | out: | ||
774 | return 0; | ||
775 | } | ||
776 | |||
777 | int | ||
778 | bfad_iocmd_vport_get_stats(struct bfad_s *bfad, void *cmd) | ||
779 | { | ||
780 | struct bfa_fcs_vport_s *fcs_vport; | ||
781 | struct bfa_bsg_vport_stats_s *iocmd = | ||
782 | (struct bfa_bsg_vport_stats_s *)cmd; | ||
783 | unsigned long flags; | ||
784 | |||
785 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
786 | fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, | ||
787 | iocmd->vf_id, iocmd->vpwwn); | ||
788 | if (fcs_vport == NULL) { | ||
789 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
790 | iocmd->status = BFA_STATUS_UNKNOWN_VWWN; | ||
791 | goto out; | ||
792 | } | ||
793 | |||
794 | memcpy((void *)&iocmd->vport_stats, (void *)&fcs_vport->vport_stats, | ||
795 | sizeof(struct bfa_vport_stats_s)); | ||
796 | memcpy((void *)&iocmd->vport_stats.port_stats, | ||
797 | (void *)&fcs_vport->lport.stats, | ||
798 | sizeof(struct bfa_lport_stats_s)); | ||
799 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
800 | iocmd->status = BFA_STATUS_OK; | ||
801 | out: | ||
802 | return 0; | ||
803 | } | ||
804 | |||
805 | int | ||
806 | bfad_iocmd_vport_clr_stats(struct bfad_s *bfad, void *cmd) | ||
807 | { | ||
808 | struct bfa_fcs_vport_s *fcs_vport; | ||
809 | struct bfa_bsg_reset_stats_s *iocmd = | ||
810 | (struct bfa_bsg_reset_stats_s *)cmd; | ||
811 | unsigned long flags; | ||
812 | |||
813 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
814 | fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, | ||
815 | iocmd->vf_id, iocmd->vpwwn); | ||
816 | if (fcs_vport == NULL) { | ||
817 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
818 | iocmd->status = BFA_STATUS_UNKNOWN_VWWN; | ||
819 | goto out; | ||
820 | } | ||
821 | |||
822 | memset(&fcs_vport->vport_stats, 0, sizeof(struct bfa_vport_stats_s)); | ||
823 | memset(&fcs_vport->lport.stats, 0, sizeof(struct bfa_lport_stats_s)); | ||
824 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
825 | iocmd->status = BFA_STATUS_OK; | ||
826 | out: | ||
827 | return 0; | ||
828 | } | ||
829 | |||
543 | static int | 830 | static int |
544 | bfad_iocmd_fabric_get_lports(struct bfad_s *bfad, void *cmd, | 831 | bfad_iocmd_fabric_get_lports(struct bfad_s *bfad, void *cmd, |
545 | unsigned int payload_len) | 832 | unsigned int payload_len) |
@@ -583,6 +870,66 @@ out: | |||
583 | } | 870 | } |
584 | 871 | ||
585 | int | 872 | int |
873 | bfad_iocmd_ratelim(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | ||
874 | { | ||
875 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd; | ||
876 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); | ||
877 | unsigned long flags; | ||
878 | |||
879 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
880 | |||
881 | if (cmd == IOCMD_RATELIM_ENABLE) | ||
882 | fcport->cfg.ratelimit = BFA_TRUE; | ||
883 | else if (cmd == IOCMD_RATELIM_DISABLE) | ||
884 | fcport->cfg.ratelimit = BFA_FALSE; | ||
885 | |||
886 | if (fcport->cfg.trl_def_speed == BFA_PORT_SPEED_UNKNOWN) | ||
887 | fcport->cfg.trl_def_speed = BFA_PORT_SPEED_1GBPS; | ||
888 | |||
889 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
890 | iocmd->status = BFA_STATUS_OK; | ||
891 | |||
892 | return 0; | ||
893 | } | ||
894 | |||
895 | int | ||
896 | bfad_iocmd_ratelim_speed(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | ||
897 | { | ||
898 | struct bfa_bsg_trl_speed_s *iocmd = (struct bfa_bsg_trl_speed_s *)pcmd; | ||
899 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); | ||
900 | unsigned long flags; | ||
901 | |||
902 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
903 | |||
904 | /* Auto and speeds greater than the supported speed, are invalid */ | ||
905 | if ((iocmd->speed == BFA_PORT_SPEED_AUTO) || | ||
906 | (iocmd->speed > fcport->speed_sup)) { | ||
907 | iocmd->status = BFA_STATUS_UNSUPP_SPEED; | ||
908 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
909 | return 0; | ||
910 | } | ||
911 | |||
912 | fcport->cfg.trl_def_speed = iocmd->speed; | ||
913 | iocmd->status = BFA_STATUS_OK; | ||
914 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
915 | |||
916 | return 0; | ||
917 | } | ||
918 | |||
919 | int | ||
920 | bfad_iocmd_cfg_fcpim(struct bfad_s *bfad, void *cmd) | ||
921 | { | ||
922 | struct bfa_bsg_fcpim_s *iocmd = (struct bfa_bsg_fcpim_s *)cmd; | ||
923 | unsigned long flags; | ||
924 | |||
925 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
926 | bfa_fcpim_path_tov_set(&bfad->bfa, iocmd->param); | ||
927 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
928 | iocmd->status = BFA_STATUS_OK; | ||
929 | return 0; | ||
930 | } | ||
931 | |||
932 | int | ||
586 | bfad_iocmd_fcpim_get_modstats(struct bfad_s *bfad, void *cmd) | 933 | bfad_iocmd_fcpim_get_modstats(struct bfad_s *bfad, void *cmd) |
587 | { | 934 | { |
588 | struct bfa_bsg_fcpim_modstats_s *iocmd = | 935 | struct bfa_bsg_fcpim_modstats_s *iocmd = |
@@ -605,6 +952,28 @@ bfad_iocmd_fcpim_get_modstats(struct bfad_s *bfad, void *cmd) | |||
605 | } | 952 | } |
606 | 953 | ||
607 | int | 954 | int |
955 | bfad_iocmd_fcpim_clr_modstats(struct bfad_s *bfad, void *cmd) | ||
956 | { | ||
957 | struct bfa_bsg_fcpim_modstatsclr_s *iocmd = | ||
958 | (struct bfa_bsg_fcpim_modstatsclr_s *)cmd; | ||
959 | struct bfa_fcpim_s *fcpim = BFA_FCPIM(&bfad->bfa); | ||
960 | struct list_head *qe, *qen; | ||
961 | struct bfa_itnim_s *itnim; | ||
962 | unsigned long flags; | ||
963 | |||
964 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
965 | list_for_each_safe(qe, qen, &fcpim->itnim_q) { | ||
966 | itnim = (struct bfa_itnim_s *) qe; | ||
967 | bfa_itnim_clear_stats(itnim); | ||
968 | } | ||
969 | memset(&fcpim->del_itn_stats, 0, | ||
970 | sizeof(struct bfa_fcpim_del_itn_stats_s)); | ||
971 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
972 | iocmd->status = BFA_STATUS_OK; | ||
973 | return 0; | ||
974 | } | ||
975 | |||
976 | int | ||
608 | bfad_iocmd_fcpim_get_del_itn_stats(struct bfad_s *bfad, void *cmd) | 977 | bfad_iocmd_fcpim_get_del_itn_stats(struct bfad_s *bfad, void *cmd) |
609 | { | 978 | { |
610 | struct bfa_bsg_fcpim_del_itn_stats_s *iocmd = | 979 | struct bfa_bsg_fcpim_del_itn_stats_s *iocmd = |
@@ -671,6 +1040,35 @@ bfad_iocmd_itnim_get_iostats(struct bfad_s *bfad, void *cmd) | |||
671 | } | 1040 | } |
672 | 1041 | ||
673 | static int | 1042 | static int |
1043 | bfad_iocmd_itnim_reset_stats(struct bfad_s *bfad, void *cmd) | ||
1044 | { | ||
1045 | struct bfa_bsg_rport_reset_stats_s *iocmd = | ||
1046 | (struct bfa_bsg_rport_reset_stats_s *)cmd; | ||
1047 | struct bfa_fcs_lport_s *fcs_port; | ||
1048 | struct bfa_fcs_itnim_s *itnim; | ||
1049 | unsigned long flags; | ||
1050 | |||
1051 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
1052 | fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs, | ||
1053 | iocmd->vf_id, iocmd->pwwn); | ||
1054 | if (!fcs_port) | ||
1055 | iocmd->status = BFA_STATUS_UNKNOWN_LWWN; | ||
1056 | else { | ||
1057 | itnim = bfa_fcs_itnim_lookup(fcs_port, iocmd->rpwwn); | ||
1058 | if (itnim == NULL) | ||
1059 | iocmd->status = BFA_STATUS_UNKNOWN_RWWN; | ||
1060 | else { | ||
1061 | iocmd->status = BFA_STATUS_OK; | ||
1062 | bfa_fcs_itnim_stats_clear(fcs_port, iocmd->rpwwn); | ||
1063 | bfa_itnim_clear_stats(bfa_fcs_itnim_get_halitn(itnim)); | ||
1064 | } | ||
1065 | } | ||
1066 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1067 | |||
1068 | return 0; | ||
1069 | } | ||
1070 | |||
1071 | static int | ||
674 | bfad_iocmd_itnim_get_itnstats(struct bfad_s *bfad, void *cmd) | 1072 | bfad_iocmd_itnim_get_itnstats(struct bfad_s *bfad, void *cmd) |
675 | { | 1073 | { |
676 | struct bfa_bsg_itnim_itnstats_s *iocmd = | 1074 | struct bfa_bsg_itnim_itnstats_s *iocmd = |
@@ -1512,6 +1910,73 @@ out: | |||
1512 | return 0; | 1910 | return 0; |
1513 | } | 1911 | } |
1514 | 1912 | ||
1913 | #define BFA_DEBUG_FW_CORE_CHUNK_SZ 0x4000U /* 16K chunks for FW dump */ | ||
1914 | int | ||
1915 | bfad_iocmd_debug_fw_core(struct bfad_s *bfad, void *cmd, | ||
1916 | unsigned int payload_len) | ||
1917 | { | ||
1918 | struct bfa_bsg_debug_s *iocmd = (struct bfa_bsg_debug_s *)cmd; | ||
1919 | void *iocmd_bufptr; | ||
1920 | unsigned long flags; | ||
1921 | |||
1922 | if (bfad_chk_iocmd_sz(payload_len, sizeof(struct bfa_bsg_debug_s), | ||
1923 | BFA_DEBUG_FW_CORE_CHUNK_SZ) != BFA_STATUS_OK) { | ||
1924 | iocmd->status = BFA_STATUS_VERSION_FAIL; | ||
1925 | return 0; | ||
1926 | } | ||
1927 | |||
1928 | if (iocmd->bufsz < BFA_DEBUG_FW_CORE_CHUNK_SZ || | ||
1929 | !IS_ALIGNED(iocmd->bufsz, sizeof(u16)) || | ||
1930 | !IS_ALIGNED(iocmd->offset, sizeof(u32))) { | ||
1931 | bfa_trc(bfad, BFA_DEBUG_FW_CORE_CHUNK_SZ); | ||
1932 | iocmd->status = BFA_STATUS_EINVAL; | ||
1933 | goto out; | ||
1934 | } | ||
1935 | |||
1936 | iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_debug_s); | ||
1937 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
1938 | iocmd->status = bfa_ioc_debug_fwcore(&bfad->bfa.ioc, iocmd_bufptr, | ||
1939 | (u32 *)&iocmd->offset, &iocmd->bufsz); | ||
1940 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1941 | out: | ||
1942 | return 0; | ||
1943 | } | ||
1944 | |||
1945 | int | ||
1946 | bfad_iocmd_debug_ctl(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | ||
1947 | { | ||
1948 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd; | ||
1949 | unsigned long flags; | ||
1950 | |||
1951 | if (v_cmd == IOCMD_DEBUG_FW_STATE_CLR) { | ||
1952 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
1953 | bfad->bfa.ioc.dbg_fwsave_once = BFA_TRUE; | ||
1954 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1955 | } else if (v_cmd == IOCMD_DEBUG_PORTLOG_CLR) | ||
1956 | bfad->plog_buf.head = bfad->plog_buf.tail = 0; | ||
1957 | else if (v_cmd == IOCMD_DEBUG_START_DTRC) | ||
1958 | bfa_trc_init(bfad->trcmod); | ||
1959 | else if (v_cmd == IOCMD_DEBUG_STOP_DTRC) | ||
1960 | bfa_trc_stop(bfad->trcmod); | ||
1961 | |||
1962 | iocmd->status = BFA_STATUS_OK; | ||
1963 | return 0; | ||
1964 | } | ||
1965 | |||
1966 | int | ||
1967 | bfad_iocmd_porglog_ctl(struct bfad_s *bfad, void *cmd) | ||
1968 | { | ||
1969 | struct bfa_bsg_portlogctl_s *iocmd = (struct bfa_bsg_portlogctl_s *)cmd; | ||
1970 | |||
1971 | if (iocmd->ctl == BFA_TRUE) | ||
1972 | bfad->plog_buf.plog_enabled = 1; | ||
1973 | else | ||
1974 | bfad->plog_buf.plog_enabled = 0; | ||
1975 | |||
1976 | iocmd->status = BFA_STATUS_OK; | ||
1977 | return 0; | ||
1978 | } | ||
1979 | |||
1515 | static int | 1980 | static int |
1516 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | 1981 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, |
1517 | unsigned int payload_len) | 1982 | unsigned int payload_len) |
@@ -1537,6 +2002,14 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
1537 | case IOCMD_IOC_GET_FWSTATS: | 2002 | case IOCMD_IOC_GET_FWSTATS: |
1538 | rc = bfad_iocmd_ioc_get_fwstats(bfad, iocmd, payload_len); | 2003 | rc = bfad_iocmd_ioc_get_fwstats(bfad, iocmd, payload_len); |
1539 | break; | 2004 | break; |
2005 | case IOCMD_IOC_RESET_STATS: | ||
2006 | case IOCMD_IOC_RESET_FWSTATS: | ||
2007 | rc = bfad_iocmd_ioc_reset_stats(bfad, iocmd, cmd); | ||
2008 | break; | ||
2009 | case IOCMD_IOC_SET_ADAPTER_NAME: | ||
2010 | case IOCMD_IOC_SET_PORT_NAME: | ||
2011 | rc = bfad_iocmd_ioc_set_name(bfad, iocmd, cmd); | ||
2012 | break; | ||
1540 | case IOCMD_IOCFC_GET_ATTR: | 2013 | case IOCMD_IOCFC_GET_ATTR: |
1541 | rc = bfad_iocmd_iocfc_get_attr(bfad, iocmd); | 2014 | rc = bfad_iocmd_iocfc_get_attr(bfad, iocmd); |
1542 | break; | 2015 | break; |
@@ -1555,12 +2028,31 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
1555 | case IOCMD_PORT_GET_STATS: | 2028 | case IOCMD_PORT_GET_STATS: |
1556 | rc = bfad_iocmd_port_get_stats(bfad, iocmd, payload_len); | 2029 | rc = bfad_iocmd_port_get_stats(bfad, iocmd, payload_len); |
1557 | break; | 2030 | break; |
2031 | case IOCMD_PORT_RESET_STATS: | ||
2032 | rc = bfad_iocmd_port_reset_stats(bfad, iocmd); | ||
2033 | break; | ||
2034 | case IOCMD_PORT_CFG_TOPO: | ||
2035 | case IOCMD_PORT_CFG_SPEED: | ||
2036 | case IOCMD_PORT_CFG_ALPA: | ||
2037 | case IOCMD_PORT_CLR_ALPA: | ||
2038 | rc = bfad_iocmd_set_port_cfg(bfad, iocmd, cmd); | ||
2039 | break; | ||
2040 | case IOCMD_PORT_CFG_MAXFRSZ: | ||
2041 | rc = bfad_iocmd_port_cfg_maxfrsize(bfad, iocmd); | ||
2042 | break; | ||
2043 | case IOCMD_PORT_BBSC_ENABLE: | ||
2044 | case IOCMD_PORT_BBSC_DISABLE: | ||
2045 | rc = bfad_iocmd_port_cfg_bbsc(bfad, iocmd, cmd); | ||
2046 | break; | ||
1558 | case IOCMD_LPORT_GET_ATTR: | 2047 | case IOCMD_LPORT_GET_ATTR: |
1559 | rc = bfad_iocmd_lport_get_attr(bfad, iocmd); | 2048 | rc = bfad_iocmd_lport_get_attr(bfad, iocmd); |
1560 | break; | 2049 | break; |
1561 | case IOCMD_LPORT_GET_STATS: | 2050 | case IOCMD_LPORT_GET_STATS: |
1562 | rc = bfad_iocmd_lport_get_stats(bfad, iocmd); | 2051 | rc = bfad_iocmd_lport_get_stats(bfad, iocmd); |
1563 | break; | 2052 | break; |
2053 | case IOCMD_LPORT_RESET_STATS: | ||
2054 | rc = bfad_iocmd_lport_reset_stats(bfad, iocmd); | ||
2055 | break; | ||
1564 | case IOCMD_LPORT_GET_IOSTATS: | 2056 | case IOCMD_LPORT_GET_IOSTATS: |
1565 | rc = bfad_iocmd_lport_get_iostats(bfad, iocmd); | 2057 | rc = bfad_iocmd_lport_get_iostats(bfad, iocmd); |
1566 | break; | 2058 | break; |
@@ -1576,12 +2068,40 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
1576 | case IOCMD_RPORT_GET_STATS: | 2068 | case IOCMD_RPORT_GET_STATS: |
1577 | rc = bfad_iocmd_rport_get_stats(bfad, iocmd); | 2069 | rc = bfad_iocmd_rport_get_stats(bfad, iocmd); |
1578 | break; | 2070 | break; |
2071 | case IOCMD_RPORT_RESET_STATS: | ||
2072 | rc = bfad_iocmd_rport_clr_stats(bfad, iocmd); | ||
2073 | break; | ||
2074 | case IOCMD_RPORT_SET_SPEED: | ||
2075 | rc = bfad_iocmd_rport_set_speed(bfad, iocmd); | ||
2076 | break; | ||
2077 | case IOCMD_VPORT_GET_ATTR: | ||
2078 | rc = bfad_iocmd_vport_get_attr(bfad, iocmd); | ||
2079 | break; | ||
2080 | case IOCMD_VPORT_GET_STATS: | ||
2081 | rc = bfad_iocmd_vport_get_stats(bfad, iocmd); | ||
2082 | break; | ||
2083 | case IOCMD_VPORT_RESET_STATS: | ||
2084 | rc = bfad_iocmd_vport_clr_stats(bfad, iocmd); | ||
2085 | break; | ||
1579 | case IOCMD_FABRIC_GET_LPORTS: | 2086 | case IOCMD_FABRIC_GET_LPORTS: |
1580 | rc = bfad_iocmd_fabric_get_lports(bfad, iocmd, payload_len); | 2087 | rc = bfad_iocmd_fabric_get_lports(bfad, iocmd, payload_len); |
1581 | break; | 2088 | break; |
2089 | case IOCMD_RATELIM_ENABLE: | ||
2090 | case IOCMD_RATELIM_DISABLE: | ||
2091 | rc = bfad_iocmd_ratelim(bfad, cmd, iocmd); | ||
2092 | break; | ||
2093 | case IOCMD_RATELIM_DEF_SPEED: | ||
2094 | rc = bfad_iocmd_ratelim_speed(bfad, cmd, iocmd); | ||
2095 | break; | ||
2096 | case IOCMD_FCPIM_FAILOVER: | ||
2097 | rc = bfad_iocmd_cfg_fcpim(bfad, iocmd); | ||
2098 | break; | ||
1582 | case IOCMD_FCPIM_MODSTATS: | 2099 | case IOCMD_FCPIM_MODSTATS: |
1583 | rc = bfad_iocmd_fcpim_get_modstats(bfad, iocmd); | 2100 | rc = bfad_iocmd_fcpim_get_modstats(bfad, iocmd); |
1584 | break; | 2101 | break; |
2102 | case IOCMD_FCPIM_MODSTATSCLR: | ||
2103 | rc = bfad_iocmd_fcpim_clr_modstats(bfad, iocmd); | ||
2104 | break; | ||
1585 | case IOCMD_FCPIM_DEL_ITN_STATS: | 2105 | case IOCMD_FCPIM_DEL_ITN_STATS: |
1586 | rc = bfad_iocmd_fcpim_get_del_itn_stats(bfad, iocmd); | 2106 | rc = bfad_iocmd_fcpim_get_del_itn_stats(bfad, iocmd); |
1587 | break; | 2107 | break; |
@@ -1591,6 +2111,9 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
1591 | case IOCMD_ITNIM_GET_IOSTATS: | 2111 | case IOCMD_ITNIM_GET_IOSTATS: |
1592 | rc = bfad_iocmd_itnim_get_iostats(bfad, iocmd); | 2112 | rc = bfad_iocmd_itnim_get_iostats(bfad, iocmd); |
1593 | break; | 2113 | break; |
2114 | case IOCMD_ITNIM_RESET_STATS: | ||
2115 | rc = bfad_iocmd_itnim_reset_stats(bfad, iocmd); | ||
2116 | break; | ||
1594 | case IOCMD_ITNIM_GET_ITNSTATS: | 2117 | case IOCMD_ITNIM_GET_ITNSTATS: |
1595 | rc = bfad_iocmd_itnim_get_itnstats(bfad, iocmd); | 2118 | rc = bfad_iocmd_itnim_get_itnstats(bfad, iocmd); |
1596 | break; | 2119 | break; |
@@ -1703,6 +2226,18 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
1703 | case IOCMD_DEBUG_PORTLOG: | 2226 | case IOCMD_DEBUG_PORTLOG: |
1704 | rc = bfad_iocmd_porglog_get(bfad, iocmd); | 2227 | rc = bfad_iocmd_porglog_get(bfad, iocmd); |
1705 | break; | 2228 | break; |
2229 | case IOCMD_DEBUG_FW_CORE: | ||
2230 | rc = bfad_iocmd_debug_fw_core(bfad, iocmd, payload_len); | ||
2231 | break; | ||
2232 | case IOCMD_DEBUG_FW_STATE_CLR: | ||
2233 | case IOCMD_DEBUG_PORTLOG_CLR: | ||
2234 | case IOCMD_DEBUG_START_DTRC: | ||
2235 | case IOCMD_DEBUG_STOP_DTRC: | ||
2236 | rc = bfad_iocmd_debug_ctl(bfad, iocmd, cmd); | ||
2237 | break; | ||
2238 | case IOCMD_DEBUG_PORTLOG_CTL: | ||
2239 | rc = bfad_iocmd_porglog_ctl(bfad, iocmd); | ||
2240 | break; | ||
1706 | default: | 2241 | default: |
1707 | rc = -EINVAL; | 2242 | rc = -EINVAL; |
1708 | break; | 2243 | break; |