aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-07-20 20:01:34 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-07-27 06:46:12 -0400
commitf2ee76017b30c84f128dfbf716950ffc0e4d949a (patch)
treef1459794f89f68f7c9bbd1c829df257aa4c1637a /drivers/scsi/bfa
parentfb778b06299f424c4db60817bd3dcfcaad3a8a75 (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')
-rw-r--r--drivers/scsi/bfa/bfa_defs.h1
-rw-r--r--drivers/scsi/bfa/bfa_defs_svc.h1
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c535
-rw-r--r--drivers/scsi/bfa/bfad_bsg.h118
4 files changed, 655 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index 73e36de4451e..2dc4b6fc79d0 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -144,6 +144,7 @@ enum bfa_status {
144 BFA_STATUS_INVLD_DFSZ = 24, /* Invalid Max data field size */ 144 BFA_STATUS_INVLD_DFSZ = 24, /* Invalid Max data field size */
145 BFA_STATUS_CMD_NOTSUPP = 26, /* Command/API not supported */ 145 BFA_STATUS_CMD_NOTSUPP = 26, /* Command/API not supported */
146 BFA_STATUS_FABRIC_RJT = 29, /* Reject from attached fabric */ 146 BFA_STATUS_FABRIC_RJT = 29, /* Reject from attached fabric */
147 BFA_STATUS_UNKNOWN_VWWN = 30, /* VPORT PWWN not found */
147 BFA_STATUS_PORT_OFFLINE = 34, /* Port is not online */ 148 BFA_STATUS_PORT_OFFLINE = 34, /* Port is not online */
148 BFA_STATUS_VPORT_WWN_BP = 46, /* WWN is same as base port's WWN */ 149 BFA_STATUS_VPORT_WWN_BP = 46, /* WWN is same as base port's WWN */
149 BFA_STATUS_PORT_NOT_DISABLED = 47, /* Port not disabled disable port */ 150 BFA_STATUS_PORT_NOT_DISABLED = 47, /* Port not disabled disable port */
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 52866d87b24d..21e3fbf0591b 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -268,6 +268,7 @@ struct bfa_fw_port_snsm_stats_s {
268 u32 error_resets; /* error resets initiated by upsm */ 268 u32 error_resets; /* error resets initiated by upsm */
269 u32 sync_lost; /* Sync loss count */ 269 u32 sync_lost; /* Sync loss count */
270 u32 sig_lost; /* Signal loss count */ 270 u32 sig_lost; /* Signal loss count */
271 u32 asn8g_attempts; /* SNSM HWSM at 8Gbps attempts */
271}; 272};
272 273
273struct bfa_fw_port_physm_stats_s { 274struct bfa_fw_port_physm_stats_s {
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
181int 181int
182bfad_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
199int
200bfad_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
213int
182bfad_iocmd_iocfc_get_attr(struct bfad_s *bfad, void *cmd) 214bfad_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
342int
343bfad_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
363int
364bfad_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
383int
384bfad_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
397int
398bfad_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
310static int 417static int
311bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd) 418bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd)
312{ 419{
@@ -355,6 +462,40 @@ out:
355} 462}
356 463
357int 464int
465bfad_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;
494out:
495 return 0;
496}
497
498int
358bfad_iocmd_lport_get_iostats(struct bfad_s *bfad, void *cmd) 499bfad_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
684int
685bfad_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;
715out:
716 return 0;
717}
718
719int
720bfad_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;
750out:
751 return 0;
752}
753
754int
755bfad_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;
773out:
774 return 0;
775}
776
777int
778bfad_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;
801out:
802 return 0;
803}
804
805int
806bfad_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;
826out:
827 return 0;
828}
829
543static int 830static int
544bfad_iocmd_fabric_get_lports(struct bfad_s *bfad, void *cmd, 831bfad_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
585int 872int
873bfad_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
895int
896bfad_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
919int
920bfad_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
932int
586bfad_iocmd_fcpim_get_modstats(struct bfad_s *bfad, void *cmd) 933bfad_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
607int 954int
955bfad_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
976int
608bfad_iocmd_fcpim_get_del_itn_stats(struct bfad_s *bfad, void *cmd) 977bfad_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
673static int 1042static int
1043bfad_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
1071static int
674bfad_iocmd_itnim_get_itnstats(struct bfad_s *bfad, void *cmd) 1072bfad_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 */
1914int
1915bfad_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);
1941out:
1942 return 0;
1943}
1944
1945int
1946bfad_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
1966int
1967bfad_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
1515static int 1980static int
1516bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, 1981bfad_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;
diff --git a/drivers/scsi/bfa/bfad_bsg.h b/drivers/scsi/bfa/bfad_bsg.h
index 99b0e8a70c89..b6ff2a30a143 100644
--- a/drivers/scsi/bfa/bfad_bsg.h
+++ b/drivers/scsi/bfa/bfad_bsg.h
@@ -30,24 +30,48 @@ enum {
30 IOCMD_IOC_GET_INFO, 30 IOCMD_IOC_GET_INFO,
31 IOCMD_IOC_GET_STATS, 31 IOCMD_IOC_GET_STATS,
32 IOCMD_IOC_GET_FWSTATS, 32 IOCMD_IOC_GET_FWSTATS,
33 IOCMD_IOC_RESET_STATS,
34 IOCMD_IOC_RESET_FWSTATS,
35 IOCMD_IOC_SET_ADAPTER_NAME,
36 IOCMD_IOC_SET_PORT_NAME,
33 IOCMD_IOCFC_GET_ATTR, 37 IOCMD_IOCFC_GET_ATTR,
34 IOCMD_IOCFC_SET_INTR, 38 IOCMD_IOCFC_SET_INTR,
35 IOCMD_PORT_ENABLE, 39 IOCMD_PORT_ENABLE,
36 IOCMD_PORT_DISABLE, 40 IOCMD_PORT_DISABLE,
37 IOCMD_PORT_GET_ATTR, 41 IOCMD_PORT_GET_ATTR,
38 IOCMD_PORT_GET_STATS, 42 IOCMD_PORT_GET_STATS,
43 IOCMD_PORT_RESET_STATS,
44 IOCMD_PORT_CFG_TOPO,
45 IOCMD_PORT_CFG_SPEED,
46 IOCMD_PORT_CFG_ALPA,
47 IOCMD_PORT_CFG_MAXFRSZ,
48 IOCMD_PORT_CLR_ALPA,
49 IOCMD_PORT_BBSC_ENABLE,
50 IOCMD_PORT_BBSC_DISABLE,
39 IOCMD_LPORT_GET_ATTR, 51 IOCMD_LPORT_GET_ATTR,
40 IOCMD_LPORT_GET_RPORTS, 52 IOCMD_LPORT_GET_RPORTS,
41 IOCMD_LPORT_GET_STATS, 53 IOCMD_LPORT_GET_STATS,
54 IOCMD_LPORT_RESET_STATS,
42 IOCMD_LPORT_GET_IOSTATS, 55 IOCMD_LPORT_GET_IOSTATS,
43 IOCMD_RPORT_GET_ATTR, 56 IOCMD_RPORT_GET_ATTR,
44 IOCMD_RPORT_GET_ADDR, 57 IOCMD_RPORT_GET_ADDR,
45 IOCMD_RPORT_GET_STATS, 58 IOCMD_RPORT_GET_STATS,
59 IOCMD_RPORT_RESET_STATS,
60 IOCMD_RPORT_SET_SPEED,
61 IOCMD_VPORT_GET_ATTR,
62 IOCMD_VPORT_GET_STATS,
63 IOCMD_VPORT_RESET_STATS,
46 IOCMD_FABRIC_GET_LPORTS, 64 IOCMD_FABRIC_GET_LPORTS,
65 IOCMD_RATELIM_ENABLE,
66 IOCMD_RATELIM_DISABLE,
67 IOCMD_RATELIM_DEF_SPEED,
68 IOCMD_FCPIM_FAILOVER,
47 IOCMD_FCPIM_MODSTATS, 69 IOCMD_FCPIM_MODSTATS,
70 IOCMD_FCPIM_MODSTATSCLR,
48 IOCMD_FCPIM_DEL_ITN_STATS, 71 IOCMD_FCPIM_DEL_ITN_STATS,
49 IOCMD_ITNIM_GET_ATTR, 72 IOCMD_ITNIM_GET_ATTR,
50 IOCMD_ITNIM_GET_IOSTATS, 73 IOCMD_ITNIM_GET_IOSTATS,
74 IOCMD_ITNIM_RESET_STATS,
51 IOCMD_ITNIM_GET_ITNSTATS, 75 IOCMD_ITNIM_GET_ITNSTATS,
52 IOCMD_IOC_PCIFN_CFG, 76 IOCMD_IOC_PCIFN_CFG,
53 IOCMD_FCPORT_ENABLE, 77 IOCMD_FCPORT_ENABLE,
@@ -86,6 +110,12 @@ enum {
86 IOCMD_PHY_READ_FW, 110 IOCMD_PHY_READ_FW,
87 IOCMD_VHBA_QUERY, 111 IOCMD_VHBA_QUERY,
88 IOCMD_DEBUG_PORTLOG, 112 IOCMD_DEBUG_PORTLOG,
113 IOCMD_DEBUG_FW_CORE,
114 IOCMD_DEBUG_FW_STATE_CLR,
115 IOCMD_DEBUG_PORTLOG_CLR,
116 IOCMD_DEBUG_START_DTRC,
117 IOCMD_DEBUG_STOP_DTRC,
118 IOCMD_DEBUG_PORTLOG_CTL,
89}; 119};
90 120
91struct bfa_bsg_gen_s { 121struct bfa_bsg_gen_s {
@@ -94,6 +124,21 @@ struct bfa_bsg_gen_s {
94 u16 rsvd; 124 u16 rsvd;
95}; 125};
96 126
127struct bfa_bsg_portlogctl_s {
128 bfa_status_t status;
129 u16 bfad_num;
130 u16 rsvd;
131 bfa_boolean_t ctl;
132 int inst_no;
133};
134
135struct bfa_bsg_ioc_name_s {
136 bfa_status_t status;
137 u16 bfad_num;
138 u16 rsvd;
139 char name[BFA_ADAPTER_SYM_NAME_LEN];
140};
141
97struct bfa_bsg_ioc_info_s { 142struct bfa_bsg_ioc_info_s {
98 bfa_status_t status; 143 bfa_status_t status;
99 u16 bfad_num; 144 u16 bfad_num;
@@ -164,6 +209,20 @@ struct bfa_bsg_port_attr_s {
164 struct bfa_port_attr_s attr; 209 struct bfa_port_attr_s attr;
165}; 210};
166 211
212struct bfa_bsg_port_cfg_s {
213 bfa_status_t status;
214 u16 bfad_num;
215 u16 rsvd;
216 u32 param;
217 u32 rsvd1;
218};
219
220struct bfa_bsg_port_cfg_maxfrsize_s {
221 bfa_status_t status;
222 u16 bfad_num;
223 u16 maxfrsize;
224};
225
167struct bfa_bsg_port_stats_s { 226struct bfa_bsg_port_stats_s {
168 bfa_status_t status; 227 bfa_status_t status;
169 u16 bfad_num; 228 u16 bfad_num;
@@ -237,6 +296,47 @@ struct bfa_bsg_rport_scsi_addr_s {
237 u32 lun; 296 u32 lun;
238}; 297};
239 298
299struct bfa_bsg_rport_reset_stats_s {
300 bfa_status_t status;
301 u16 bfad_num;
302 u16 vf_id;
303 wwn_t pwwn;
304 wwn_t rpwwn;
305};
306
307struct bfa_bsg_rport_set_speed_s {
308 bfa_status_t status;
309 u16 bfad_num;
310 u16 vf_id;
311 enum bfa_port_speed speed;
312 u32 rsvd;
313 wwn_t pwwn;
314 wwn_t rpwwn;
315};
316
317struct bfa_bsg_vport_attr_s {
318 bfa_status_t status;
319 u16 bfad_num;
320 u16 vf_id;
321 wwn_t vpwwn;
322 struct bfa_vport_attr_s vport_attr;
323};
324
325struct bfa_bsg_vport_stats_s {
326 bfa_status_t status;
327 u16 bfad_num;
328 u16 vf_id;
329 wwn_t vpwwn;
330 struct bfa_vport_stats_s vport_stats;
331};
332
333struct bfa_bsg_reset_stats_s {
334 bfa_status_t status;
335 u16 bfad_num;
336 u16 vf_id;
337 wwn_t vpwwn;
338};
339
240struct bfa_bsg_fabric_get_lports_s { 340struct bfa_bsg_fabric_get_lports_s {
241 bfa_status_t status; 341 bfa_status_t status;
242 u16 bfad_num; 342 u16 bfad_num;
@@ -246,6 +346,19 @@ struct bfa_bsg_fabric_get_lports_s {
246 u32 rsvd; 346 u32 rsvd;
247}; 347};
248 348
349struct bfa_bsg_trl_speed_s {
350 bfa_status_t status;
351 u16 bfad_num;
352 u16 rsvd;
353 enum bfa_port_speed speed;
354};
355
356struct bfa_bsg_fcpim_s {
357 bfa_status_t status;
358 u16 bfad_num;
359 u16 param;
360};
361
249struct bfa_bsg_fcpim_modstats_s { 362struct bfa_bsg_fcpim_modstats_s {
250 bfa_status_t status; 363 bfa_status_t status;
251 u16 bfad_num; 364 u16 bfad_num;
@@ -258,6 +371,11 @@ struct bfa_bsg_fcpim_del_itn_stats_s {
258 struct bfa_fcpim_del_itn_stats_s modstats; 371 struct bfa_fcpim_del_itn_stats_s modstats;
259}; 372};
260 373
374struct bfa_bsg_fcpim_modstatsclr_s {
375 bfa_status_t status;
376 u16 bfad_num;
377};
378
261struct bfa_bsg_itnim_attr_s { 379struct bfa_bsg_itnim_attr_s {
262 bfa_status_t status; 380 bfa_status_t status;
263 u16 bfad_num; 381 u16 bfad_num;