aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorVikas Chaudhary <vikas.chaudhary@qlogic.com>2012-01-19 06:06:56 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-19 09:08:54 -0500
commit3254dbe9d95e1a6eb04f00e8164d14a06f6e485a (patch)
tree1214ba64f92cd07823a6942946f6067e373c9536 /drivers/scsi
parentaeddde2978f8931740032880134039fb937bb07c (diff)
[SCSI] qla4xxx: Added support to show port_state and port_speed in sysfs
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c47
2 files changed, 51 insertions, 0 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 7825c141bc1a..5f82b5decd0f 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -396,6 +396,10 @@ struct qla_flt_region {
396#define FW_ADDSTATE_DHCPv4_LEASE_EXPIRED 0x0008 396#define FW_ADDSTATE_DHCPv4_LEASE_EXPIRED 0x0008
397#define FW_ADDSTATE_LINK_UP 0x0010 397#define FW_ADDSTATE_LINK_UP 0x0010
398#define FW_ADDSTATE_ISNS_SVC_ENABLED 0x0020 398#define FW_ADDSTATE_ISNS_SVC_ENABLED 0x0020
399#define FW_ADDSTATE_LINK_SPEED_10MBPS 0x0100
400#define FW_ADDSTATE_LINK_SPEED_100MBPS 0x0200
401#define FW_ADDSTATE_LINK_SPEED_1GBPS 0x0400
402#define FW_ADDSTATE_LINK_SPEED_10GBPS 0x0800
399 403
400#define MBOX_CMD_GET_DATABASE_ENTRY_DEFAULTS 0x006B 404#define MBOX_CMD_GET_DATABASE_ENTRY_DEFAULTS 0x006B
401#define IPV6_DEFAULT_DDB_ENTRY 0x0001 405#define IPV6_DEFAULT_DDB_ENTRY 0x0001
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 2bd9f1dfb6a3..c1189e5fab14 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -206,6 +206,8 @@ static umode_t ql4_attr_is_visible(int param_type, int param)
206 case ISCSI_HOST_PARAM_HWADDRESS: 206 case ISCSI_HOST_PARAM_HWADDRESS:
207 case ISCSI_HOST_PARAM_IPADDRESS: 207 case ISCSI_HOST_PARAM_IPADDRESS:
208 case ISCSI_HOST_PARAM_INITIATOR_NAME: 208 case ISCSI_HOST_PARAM_INITIATOR_NAME:
209 case ISCSI_HOST_PARAM_PORT_STATE:
210 case ISCSI_HOST_PARAM_PORT_SPEED:
209 return S_IRUGO; 211 return S_IRUGO;
210 default: 212 default:
211 return 0; 213 return 0;
@@ -548,6 +550,43 @@ static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)
548 return ret; 550 return ret;
549} 551}
550 552
553static void qla4xxx_set_port_speed(struct Scsi_Host *shost)
554{
555 struct scsi_qla_host *ha = to_qla_host(shost);
556 struct iscsi_cls_host *ihost = shost_priv(shost);
557 uint32_t speed = ISCSI_PORT_SPEED_UNKNOWN;
558
559 qla4xxx_get_firmware_state(ha);
560
561 switch (ha->addl_fw_state & 0x0F00) {
562 case FW_ADDSTATE_LINK_SPEED_10MBPS:
563 speed = ISCSI_PORT_SPEED_10MBPS;
564 break;
565 case FW_ADDSTATE_LINK_SPEED_100MBPS:
566 speed = ISCSI_PORT_SPEED_100MBPS;
567 break;
568 case FW_ADDSTATE_LINK_SPEED_1GBPS:
569 speed = ISCSI_PORT_SPEED_1GBPS;
570 break;
571 case FW_ADDSTATE_LINK_SPEED_10GBPS:
572 speed = ISCSI_PORT_SPEED_10GBPS;
573 break;
574 }
575 ihost->port_speed = speed;
576}
577
578static void qla4xxx_set_port_state(struct Scsi_Host *shost)
579{
580 struct scsi_qla_host *ha = to_qla_host(shost);
581 struct iscsi_cls_host *ihost = shost_priv(shost);
582 uint32_t state = ISCSI_PORT_STATE_DOWN;
583
584 if (test_bit(AF_LINK_UP, &ha->flags))
585 state = ISCSI_PORT_STATE_UP;
586
587 ihost->port_state = state;
588}
589
551static int qla4xxx_host_get_param(struct Scsi_Host *shost, 590static int qla4xxx_host_get_param(struct Scsi_Host *shost,
552 enum iscsi_host_param param, char *buf) 591 enum iscsi_host_param param, char *buf)
553{ 592{
@@ -564,6 +603,14 @@ static int qla4xxx_host_get_param(struct Scsi_Host *shost,
564 case ISCSI_HOST_PARAM_INITIATOR_NAME: 603 case ISCSI_HOST_PARAM_INITIATOR_NAME:
565 len = sprintf(buf, "%s\n", ha->name_string); 604 len = sprintf(buf, "%s\n", ha->name_string);
566 break; 605 break;
606 case ISCSI_HOST_PARAM_PORT_STATE:
607 qla4xxx_set_port_state(shost);
608 len = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost));
609 break;
610 case ISCSI_HOST_PARAM_PORT_SPEED:
611 qla4xxx_set_port_speed(shost);
612 len = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost));
613 break;
567 default: 614 default:
568 return -ENOSYS; 615 return -ENOSYS;
569 } 616 }