diff options
author | Vikas Chaudhary <vikas.chaudhary@qlogic.com> | 2012-01-19 06:06:55 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-02-19 09:08:54 -0500 |
commit | aeddde2978f8931740032880134039fb937bb07c (patch) | |
tree | 8df6317dcd09ba6d13f24fe67c25ab9bcecf7dac /drivers/scsi/scsi_transport_iscsi.c | |
parent | 6c1b8789b0dd0ceeb04229f059dde08d84f28221 (diff) |
[SCSI] scsi_transport_iscsi: Added support to show port_state and port_speed in sysfs
sysfs patch to view port_state:
/sys/class/iscsi_host/host*/port_state
sysfs patch to view port_speed:
/sys/class/iscsi_host/host*/port_speed
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/scsi_transport_iscsi.c')
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index cfd491437239..97832a2876bd 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -2476,12 +2476,16 @@ iscsi_host_attr(netdev, ISCSI_HOST_PARAM_NETDEV_NAME); | |||
2476 | iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS); | 2476 | iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS); |
2477 | iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS); | 2477 | iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS); |
2478 | iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); | 2478 | iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); |
2479 | iscsi_host_attr(port_state, ISCSI_HOST_PARAM_PORT_STATE); | ||
2480 | iscsi_host_attr(port_speed, ISCSI_HOST_PARAM_PORT_SPEED); | ||
2479 | 2481 | ||
2480 | static struct attribute *iscsi_host_attrs[] = { | 2482 | static struct attribute *iscsi_host_attrs[] = { |
2481 | &dev_attr_host_netdev.attr, | 2483 | &dev_attr_host_netdev.attr, |
2482 | &dev_attr_host_hwaddress.attr, | 2484 | &dev_attr_host_hwaddress.attr, |
2483 | &dev_attr_host_ipaddress.attr, | 2485 | &dev_attr_host_ipaddress.attr, |
2484 | &dev_attr_host_initiatorname.attr, | 2486 | &dev_attr_host_initiatorname.attr, |
2487 | &dev_attr_host_port_state.attr, | ||
2488 | &dev_attr_host_port_speed.attr, | ||
2485 | NULL, | 2489 | NULL, |
2486 | }; | 2490 | }; |
2487 | 2491 | ||
@@ -2501,6 +2505,10 @@ static umode_t iscsi_host_attr_is_visible(struct kobject *kobj, | |||
2501 | param = ISCSI_HOST_PARAM_IPADDRESS; | 2505 | param = ISCSI_HOST_PARAM_IPADDRESS; |
2502 | else if (attr == &dev_attr_host_initiatorname.attr) | 2506 | else if (attr == &dev_attr_host_initiatorname.attr) |
2503 | param = ISCSI_HOST_PARAM_INITIATOR_NAME; | 2507 | param = ISCSI_HOST_PARAM_INITIATOR_NAME; |
2508 | else if (attr == &dev_attr_host_port_state.attr) | ||
2509 | param = ISCSI_HOST_PARAM_PORT_STATE; | ||
2510 | else if (attr == &dev_attr_host_port_speed.attr) | ||
2511 | param = ISCSI_HOST_PARAM_PORT_SPEED; | ||
2504 | else { | 2512 | else { |
2505 | WARN_ONCE(1, "Invalid host attr"); | 2513 | WARN_ONCE(1, "Invalid host attr"); |
2506 | return 0; | 2514 | return 0; |
@@ -2514,6 +2522,61 @@ static struct attribute_group iscsi_host_group = { | |||
2514 | .is_visible = iscsi_host_attr_is_visible, | 2522 | .is_visible = iscsi_host_attr_is_visible, |
2515 | }; | 2523 | }; |
2516 | 2524 | ||
2525 | /* convert iscsi_port_speed values to ascii string name */ | ||
2526 | static const struct { | ||
2527 | enum iscsi_port_speed value; | ||
2528 | char *name; | ||
2529 | } iscsi_port_speed_names[] = { | ||
2530 | {ISCSI_PORT_SPEED_UNKNOWN, "Unknown" }, | ||
2531 | {ISCSI_PORT_SPEED_10MBPS, "10 Mbps" }, | ||
2532 | {ISCSI_PORT_SPEED_100MBPS, "100 Mbps" }, | ||
2533 | {ISCSI_PORT_SPEED_1GBPS, "1 Gbps" }, | ||
2534 | {ISCSI_PORT_SPEED_10GBPS, "10 Gbps" }, | ||
2535 | }; | ||
2536 | |||
2537 | char *iscsi_get_port_speed_name(struct Scsi_Host *shost) | ||
2538 | { | ||
2539 | int i; | ||
2540 | char *speed = "Unknown!"; | ||
2541 | struct iscsi_cls_host *ihost = shost->shost_data; | ||
2542 | uint32_t port_speed = ihost->port_speed; | ||
2543 | |||
2544 | for (i = 0; i < ARRAY_SIZE(iscsi_port_speed_names); i++) { | ||
2545 | if (iscsi_port_speed_names[i].value & port_speed) { | ||
2546 | speed = iscsi_port_speed_names[i].name; | ||
2547 | break; | ||
2548 | } | ||
2549 | } | ||
2550 | return speed; | ||
2551 | } | ||
2552 | EXPORT_SYMBOL_GPL(iscsi_get_port_speed_name); | ||
2553 | |||
2554 | /* convert iscsi_port_state values to ascii string name */ | ||
2555 | static const struct { | ||
2556 | enum iscsi_port_state value; | ||
2557 | char *name; | ||
2558 | } iscsi_port_state_names[] = { | ||
2559 | {ISCSI_PORT_STATE_DOWN, "LINK DOWN" }, | ||
2560 | {ISCSI_PORT_STATE_UP, "LINK UP" }, | ||
2561 | }; | ||
2562 | |||
2563 | char *iscsi_get_port_state_name(struct Scsi_Host *shost) | ||
2564 | { | ||
2565 | int i; | ||
2566 | char *state = "Unknown!"; | ||
2567 | struct iscsi_cls_host *ihost = shost->shost_data; | ||
2568 | uint32_t port_state = ihost->port_state; | ||
2569 | |||
2570 | for (i = 0; i < ARRAY_SIZE(iscsi_port_state_names); i++) { | ||
2571 | if (iscsi_port_state_names[i].value & port_state) { | ||
2572 | state = iscsi_port_state_names[i].name; | ||
2573 | break; | ||
2574 | } | ||
2575 | } | ||
2576 | return state; | ||
2577 | } | ||
2578 | EXPORT_SYMBOL_GPL(iscsi_get_port_state_name); | ||
2579 | |||
2517 | static int iscsi_session_match(struct attribute_container *cont, | 2580 | static int iscsi_session_match(struct attribute_container *cont, |
2518 | struct device *dev) | 2581 | struct device *dev) |
2519 | { | 2582 | { |