diff options
author | John Soni Jose <sony.john-n@emulex.com> | 2012-04-04 00:41:52 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-04-25 04:36:47 -0400 |
commit | c62eef0d1b592cfbe4793173e8af4098b13e4455 (patch) | |
tree | 6f311045ca00a77a59d6ba497665182cef6ab846 /drivers/scsi/be2iscsi | |
parent | 0e43895ec1f405a25b5d57bc95c11fe17224ec43 (diff) |
[SCSI] be2iscsi: Get Port State and Speed of the Adapter
Implement ISCSI_HOST_PARAM_PORT_STATE and ISCSI_HOST_PARAM_PORT_SPEED
to get the Adapter port state and port name
Signed-off-by: John Soni Jose <sony.john-n@emulex.com>
Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r-- | drivers/scsi/be2iscsi/be_cmds.h | 24 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 89 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_mgmt.c | 27 |
3 files changed, 140 insertions, 0 deletions
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 60d144550f76..b0b36c6a145f 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h | |||
@@ -596,6 +596,28 @@ struct be_cmd_hba_name { | |||
596 | u8 initiator_alias[BEISCSI_ALIAS_LEN]; | 596 | u8 initiator_alias[BEISCSI_ALIAS_LEN]; |
597 | } __packed; | 597 | } __packed; |
598 | 598 | ||
599 | struct be_cmd_ntwk_link_status_req { | ||
600 | struct be_cmd_req_hdr hdr; | ||
601 | u32 rsvd0; | ||
602 | } __packed; | ||
603 | |||
604 | /*** Port Speed Values ***/ | ||
605 | #define BE2ISCSI_LINK_SPEED_ZERO 0x00 | ||
606 | #define BE2ISCSI_LINK_SPEED_10MBPS 0x01 | ||
607 | #define BE2ISCSI_LINK_SPEED_100MBPS 0x02 | ||
608 | #define BE2ISCSI_LINK_SPEED_1GBPS 0x03 | ||
609 | #define BE2ISCSI_LINK_SPEED_10GBPS 0x04 | ||
610 | struct be_cmd_ntwk_link_status_resp { | ||
611 | struct be_cmd_resp_hdr hdr; | ||
612 | u8 phys_port; | ||
613 | u8 mac_duplex; | ||
614 | u8 mac_speed; | ||
615 | u8 mac_fault; | ||
616 | u8 mgmt_mac_duplex; | ||
617 | u8 mgmt_mac_speed; | ||
618 | u16 qos_link_speed; | ||
619 | u32 logical_link_speed; | ||
620 | } __packed; | ||
599 | 621 | ||
600 | int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, | 622 | int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, |
601 | struct be_queue_info *eq, int eq_delay); | 623 | struct be_queue_info *eq, int eq_delay); |
@@ -615,6 +637,7 @@ int be_poll_mcc(struct be_ctrl_info *ctrl); | |||
615 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | 637 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, |
616 | struct beiscsi_hba *phba); | 638 | struct beiscsi_hba *phba); |
617 | unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); | 639 | unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); |
640 | unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba); | ||
618 | 641 | ||
619 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); | 642 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); |
620 | /*ISCSI Functuions */ | 643 | /*ISCSI Functuions */ |
@@ -879,6 +902,7 @@ struct be_cmd_get_all_if_id_req { | |||
879 | } __packed; | 902 | } __packed; |
880 | 903 | ||
881 | #define ISCSI_OPCODE_SCSI_DATA_OUT 5 | 904 | #define ISCSI_OPCODE_SCSI_DATA_OUT 5 |
905 | #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5 | ||
882 | #define OPCODE_COMMON_MODIFY_EQ_DELAY 41 | 906 | #define OPCODE_COMMON_MODIFY_EQ_DELAY 41 |
883 | #define OPCODE_COMMON_ISCSI_CLEANUP 59 | 907 | #define OPCODE_COMMON_ISCSI_CLEANUP 59 |
884 | #define OPCODE_COMMON_TCP_UPLOAD 56 | 908 | #define OPCODE_COMMON_TCP_UPLOAD 56 |
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 | */ | ||
626 | static 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 | */ | ||
641 | static 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; |
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index e6cb10d2e74e..01bb04cd9e75 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c | |||
@@ -898,3 +898,30 @@ unsigned int be_cmd_get_initname(struct beiscsi_hba *phba) | |||
898 | spin_unlock(&ctrl->mbox_lock); | 898 | spin_unlock(&ctrl->mbox_lock); |
899 | return tag; | 899 | return tag; |
900 | } | 900 | } |
901 | |||
902 | unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba) | ||
903 | { | ||
904 | unsigned int tag = 0; | ||
905 | struct be_mcc_wrb *wrb; | ||
906 | struct be_cmd_ntwk_link_status_req *req; | ||
907 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
908 | |||
909 | spin_lock(&ctrl->mbox_lock); | ||
910 | tag = alloc_mcc_tag(phba); | ||
911 | if (!tag) { | ||
912 | spin_unlock(&ctrl->mbox_lock); | ||
913 | return tag; | ||
914 | } | ||
915 | |||
916 | wrb = wrb_from_mccq(phba); | ||
917 | req = embedded_payload(wrb); | ||
918 | wrb->tag0 |= tag; | ||
919 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | ||
920 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
921 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, | ||
922 | sizeof(*req)); | ||
923 | |||
924 | be_mcc_notify(phba); | ||
925 | spin_unlock(&ctrl->mbox_lock); | ||
926 | return tag; | ||
927 | } | ||