aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi/be_iscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/be2iscsi/be_iscsi.c')
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 46cc40e83b36..43f35034585d 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -618,6 +618,79 @@ static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba)
618} 618}
619 619
620/** 620/**
621 * beiscsi_get_port_state - Get the Port State
622 * @shost : pointer to scsi_host structure
623 *
624 * returns number of bytes
625 */
626static void beiscsi_get_port_state(struct Scsi_Host *shost)
627{
628 struct beiscsi_hba *phba = iscsi_host_priv(shost);
629 struct iscsi_cls_host *ihost = shost->shost_data;
630
631 ihost->port_state = (phba->state == BE_ADAPTER_UP) ?
632 ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN;
633}
634
635/**
636 * beiscsi_get_port_speed - Get the Port Speed from Adapter
637 * @shost : pointer to scsi_host structure
638 *
639 * returns Success/Failure
640 */
641static int beiscsi_get_port_speed(struct Scsi_Host *shost)
642{
643 unsigned int tag, wrb_num;
644 unsigned short status, extd_status;
645 struct be_mcc_wrb *wrb;
646 struct be_cmd_ntwk_link_status_resp *resp;
647 struct beiscsi_hba *phba = iscsi_host_priv(shost);
648 struct iscsi_cls_host *ihost = shost->shost_data;
649 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
650
651 tag = be_cmd_get_port_speed(phba);
652 if (!tag) {
653 SE_DEBUG(DBG_LVL_1, "Getting Port Speed Failed\n");
654 return -EBUSY;
655 } else
656 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
657 phba->ctrl.mcc_numtag[tag]);
658
659 wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
660 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
661 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
662
663 if (status || extd_status) {
664 SE_DEBUG(DBG_LVL_1, "MailBox Command Failed with "
665 "status = %d extd_status = %d\n",
666 status, extd_status);
667 free_mcc_tag(&phba->ctrl, tag);
668 return -EAGAIN;
669 }
670 wrb = queue_get_wrb(mccq, wrb_num);
671 free_mcc_tag(&phba->ctrl, tag);
672 resp = embedded_payload(wrb);
673
674 switch (resp->mac_speed) {
675 case BE2ISCSI_LINK_SPEED_10MBPS:
676 ihost->port_speed = ISCSI_PORT_SPEED_10MBPS;
677 break;
678 case BE2ISCSI_LINK_SPEED_100MBPS:
679 ihost->port_speed = BE2ISCSI_LINK_SPEED_100MBPS;
680 break;
681 case BE2ISCSI_LINK_SPEED_1GBPS:
682 ihost->port_speed = ISCSI_PORT_SPEED_1GBPS;
683 break;
684 case BE2ISCSI_LINK_SPEED_10GBPS:
685 ihost->port_speed = ISCSI_PORT_SPEED_10GBPS;
686 break;
687 default:
688 ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN;
689 }
690 return 0;
691}
692
693/**
621 * beiscsi_get_host_param - get the iscsi parameter 694 * beiscsi_get_host_param - get the iscsi parameter
622 * @shost: pointer to scsi_host structure 695 * @shost: pointer to scsi_host structure
623 * @param: parameter type identifier 696 * @param: parameter type identifier
@@ -648,6 +721,19 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
648 return status; 721 return status;
649 } 722 }
650 break; 723 break;
724 case ISCSI_HOST_PARAM_PORT_STATE:
725 beiscsi_get_port_state(shost);
726 status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost));
727 break;
728 case ISCSI_HOST_PARAM_PORT_SPEED:
729 status = beiscsi_get_port_speed(shost);
730 if (status) {
731 SE_DEBUG(DBG_LVL_1,
732 "Retreiving Port Speed Failed\n");
733 return status;
734 }
735 status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost));
736 break;
651 default: 737 default:
652 return iscsi_host_get_param(shost, param, buf); 738 return iscsi_host_get_param(shost, param, buf);
653 } 739 }
@@ -1073,6 +1159,9 @@ umode_t be2iscsi_attr_is_visible(int param_type, int param)
1073 case ISCSI_HOST_PARAM: 1159 case ISCSI_HOST_PARAM:
1074 switch (param) { 1160 switch (param) {
1075 case ISCSI_HOST_PARAM_HWADDRESS: 1161 case ISCSI_HOST_PARAM_HWADDRESS:
1162 case ISCSI_HOST_PARAM_INITIATOR_NAME:
1163 case ISCSI_HOST_PARAM_PORT_STATE:
1164 case ISCSI_HOST_PARAM_PORT_SPEED:
1076 return S_IRUGO; 1165 return S_IRUGO;
1077 default: 1166 default:
1078 return 0; 1167 return 0;