Commit 85175168 authored by James Bottomley's avatar James Bottomley

SCSI: Add FC transport host attributes

From: 	James.Smart@Emulex.Com

This patch updates the fc_transport with attributes for local FC ports
(e.g. Hosts).  The port attributes are defined per HBAAPI v2.0 definitions.

This patch results in the following in /sys/class:
-----------------------------------------------------

[jsmart@elxware class]$ cd /sys/class
[jsmart@elxware class]$ ls
fc_host       graphics  misc     pci_bus       scsi_host  usb_host
fc_transport  input     net      scsi_device   tty        vc
firmware      mem       netlink  scsi_generic  usb
[jsmart@elxware class]$ cd fc_host
[jsmart@elxware fc_host]$ ls
host4

[jsmart@elxware fc_host]$ cd host4
[jsmart@elxware host4]$ ls
device                 host_port_maxframe_size      host_port_supported_speeds
host_fabric_name       host_port_name               host_port_symbolic_name
host_link_down_tmo     host_port_speed              host_port_type
host_node_name         host_port_state              host_tgtid_bind_type
host_port_active_fc4s  host_port_supported_classes  statistics
host_port_id           host_port_supported_fc4s
[jsmart@elxware host4]$ ls -ld *
lrwxrwxrwx  1 root root    0 Oct 13 18:24 device -> ../../../devices/platform/host4
-r--r--r--  1 root root 4096 Oct 13 18:24 host_fabric_name
-rw-r--r--  1 root root 4096 Oct 13 18:24 host_link_down_tmo
-r--r--r--  1 root root 4096 Oct 13 18:24 host_node_name
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_active_fc4s
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_id
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_maxframe_size
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_name
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_speed
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_state
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_supported_classes
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_supported_fc4s
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_supported_speeds
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_symbolic_name
-r--r--r--  1 root root 4096 Oct 13 18:24 host_port_type
-rw-r--r--  1 root root 4096 Oct 13 18:24 host_tgtid_bind_type
drwxr-xr-x  2 root root    0 Oct 13 18:24 statistics


Using the following script (/tmp/show_attributes):
    #!/bin/sh
    FILES=`ls *`
    for file in $FILES; do
      if [ -f $file ] ; then
        echo "$file : " `cat $file`
      fi
    done

Here's a sample of querying the attributes:

[jsmart@elxware /]$ cd /sys/class/fc_host/host4
[jsmart@elxware host4]$ /tmp/show_attributes
host_fabric_name :  0x33334444ffeeddcc
host_link_down_tmo :  30
host_node_name :  0x78563412aabbccdd
host_port_active_fc4s :  hex: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
host_port_id :  0x789abc
host_port_maxframe_size :  2511 bytes
host_port_name :  0xefcdab9011223344
host_port_speed :  2 Gbit
host_port_state :  Online
host_port_supported_classes :  Class 2, Class 3
host_port_supported_fc4s :  hex: 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
host_port_supported_speeds :  2 Gbit, 4 Gbit, 10 Gbit
host_port_symbolic_name :  LP9052 Dual Port Adapter
host_port_type :  NPort (fabric via point-to-point)
host_tgtid_bind_type :  wwpn (World Wide Port Name)
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 18a1de8b
This diff is collapsed.
...@@ -24,11 +24,101 @@ ...@@ -24,11 +24,101 @@
struct scsi_transport_template; struct scsi_transport_template;
/*
* FC Port definitions - Following FC HBAAPI guidelines
*
* Note: Not all binary values for the different fields match HBAAPI.
* Instead, we use densely packed ordinal values or enums.
* We get away with this as we never present the actual binary values
* externally. For sysfs, we always present the string that describes
* the value. Thus, an admin doesn't need a magic HBAAPI decoder ring
* to understand the values. The HBAAPI user-space library is free to
* convert the strings into the HBAAPI-specified binary values.
*
* Note: Not all HBAAPI-defined values are contained in the definitions
* below. Those not appropriate to an fc_host (e.g. FCP initiator) have
* been removed.
*/
/*
* fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c
* (for the ascii descriptions).
*/
enum fc_port_type {
FC_PORTTYPE_UNKNOWN,
FC_PORTTYPE_OTHER,
FC_PORTTYPE_NOTPRESENT,
FC_PORTTYPE_NPORT, /* Attached to FPort */
FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
};
/*
* fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
* (for the ascii descriptions).
*/
enum fc_port_state {
FC_PORTSTATE_UNKNOWN,
FC_PORTSTATE_ONLINE,
FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */
FC_PORTSTATE_BYPASSED,
FC_PORTSTATE_DIAGNOSTICS,
FC_PORTSTATE_LINKDOWN,
FC_PORTSTATE_ERROR,
FC_PORTSTATE_LOOPBACK,
};
/*
* FC Classes of Service
* Note: values are not enumerated, as they can be "or'd" together
* for reporting (e.g. report supported_classes). If you alter this list,
* you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/
#define FC_COS_UNSPECIFIED 0
#define FC_COS_CLASS1 2
#define FC_COS_CLASS2 4
#define FC_COS_CLASS3 8
#define FC_COS_CLASS4 0x10
#define FC_COS_CLASS6 0x40
/*
* FC Port Speeds
* Note: values are not enumerated, as they can be "or'd" together
* for reporting (e.g. report supported_speeds). If you alter this list,
* you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/
#define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver
incapable of reporting */
#define FC_PORTSPEED_1GBIT 1
#define FC_PORTSPEED_2GBIT 2
#define FC_PORTSPEED_10GBIT 4
#define FC_PORTSPEED_4GBIT 8
#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
/*
* fc_tgtid_binding_type: If you alter this, you also need to alter
* scsi_transport_fc.c (for the ascii descriptions).
*/
enum fc_tgtid_binding_type {
FC_TGTID_BIND_BY_WWPN,
FC_TGTID_BIND_BY_WWNN,
FC_TGTID_BIND_BY_ID,
};
/*
* FC Remote Port (Target) Attributes
*/
struct fc_starget_attrs { /* aka fc_target_attrs */ struct fc_starget_attrs { /* aka fc_target_attrs */
int port_id; int port_id;
uint64_t node_name; u64 node_name;
uint64_t port_name; u64 port_name;
uint32_t dev_loss_tmo; /* Remote Port loss timeout in seconds. */ u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */
struct work_struct dev_loss_work; struct work_struct dev_loss_work;
}; };
...@@ -51,38 +141,107 @@ struct fc_starget_attrs { /* aka fc_target_attrs */ ...@@ -51,38 +141,107 @@ struct fc_starget_attrs { /* aka fc_target_attrs */
/* FC Statistics - Following FC HBAAPI v2.0 guidelines */ /* FC Statistics - Following FC HBAAPI v2.0 guidelines */
struct fc_host_statistics { struct fc_host_statistics {
/* port statistics */ /* port statistics */
uint64_t seconds_since_last_reset; u64 seconds_since_last_reset;
uint64_t tx_frames; u64 tx_frames;
uint64_t tx_words; u64 tx_words;
uint64_t rx_frames; u64 rx_frames;
uint64_t rx_words; u64 rx_words;
uint64_t lip_count; u64 lip_count;
uint64_t nos_count; u64 nos_count;
uint64_t error_frames; u64 error_frames;
uint64_t dumped_frames; u64 dumped_frames;
uint64_t link_failure_count; u64 link_failure_count;
uint64_t loss_of_sync_count; u64 loss_of_sync_count;
uint64_t loss_of_signal_count; u64 loss_of_signal_count;
uint64_t prim_seq_protocol_err_count; u64 prim_seq_protocol_err_count;
uint64_t invalid_tx_word_count; u64 invalid_tx_word_count;
uint64_t invalid_crc_count; u64 invalid_crc_count;
/* fc4 statistics (only FCP supported currently) */ /* fc4 statistics (only FCP supported currently) */
uint64_t fcp_input_requests; u64 fcp_input_requests;
uint64_t fcp_output_requests; u64 fcp_output_requests;
uint64_t fcp_control_requests; u64 fcp_control_requests;
uint64_t fcp_input_megabytes; u64 fcp_input_megabytes;
uint64_t fcp_output_megabytes; u64 fcp_output_megabytes;
}; };
/*
* FC Local Port (Host) Attributes
*
* Attributes are based on HBAAPI V2.0 definitions.
* Note: OSDeviceName is determined by user-space library
*
* Fixed attributes are not expected to change. The driver is
* expected to set these values after successfully calling scsi_add_host().
* The transport fully manages all get functions w/o driver interaction.
*
* Dynamic attributes are expected to change. The driver participates
* in all get/set operations via functions provided by the driver.
*
* Private attributes are transport-managed values. They are fully
* managed by the transport w/o driver interaction.
*/
#define FC_FC4_LIST_SIZE 32
#define FC_SYMBOLIC_NAME_SIZE 256
struct fc_host_attrs { struct fc_host_attrs {
uint32_t link_down_tmo; /* Link Down timeout in seconds. */ /* Fixed Attributes */
u64 node_name;
u64 port_name;
u32 supported_classes;
u8 supported_fc4s[FC_FC4_LIST_SIZE];
char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
u32 supported_speeds;
u32 maxframe_size;
/* Dynamic Attributes */
u32 port_id;
enum fc_port_type port_type;
enum fc_port_state port_state;
u8 active_fc4s[FC_FC4_LIST_SIZE];
u32 speed;
u64 fabric_name;
u32 link_down_tmo; /* Link Down timeout in seconds. */
/* Private (Transport-managed) Attributes */
enum fc_tgtid_binding_type tgtid_bind_type;
/* internal data */
struct work_struct link_down_work; struct work_struct link_down_work;
}; };
#define fc_host_node_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->node_name)
#define fc_host_port_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_name)
#define fc_host_supported_classes(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
#define fc_host_supported_fc4s(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
#define fc_host_symbolic_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
#define fc_host_supported_speeds(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
#define fc_host_maxframe_size(x) \
(((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
#define fc_host_port_id(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_id)
#define fc_host_port_type(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_type)
#define fc_host_port_state(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_state)
#define fc_host_active_fc4s(x) \
(((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)
#define fc_host_speed(x) \
(((struct fc_host_attrs *)(x)->shost_data)->speed)
#define fc_host_fabric_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
#define fc_host_link_down_tmo(x) \ #define fc_host_link_down_tmo(x) \
(((struct fc_host_attrs *)(x)->shost_data)->link_down_tmo) (((struct fc_host_attrs *)(x)->shost_data)->link_down_tmo)
#define fc_host_tgtid_bind_type(x) \
(((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
#define fc_host_link_down_work(x) \ #define fc_host_link_down_work(x) \
(((struct fc_host_attrs *)(x)->shost_data)->link_down_work) (((struct fc_host_attrs *)(x)->shost_data)->link_down_work)
...@@ -93,10 +252,16 @@ struct fc_function_template { ...@@ -93,10 +252,16 @@ struct fc_function_template {
void (*get_starget_node_name)(struct scsi_target *); void (*get_starget_node_name)(struct scsi_target *);
void (*get_starget_port_name)(struct scsi_target *); void (*get_starget_port_name)(struct scsi_target *);
void (*get_starget_dev_loss_tmo)(struct scsi_target *); void (*get_starget_dev_loss_tmo)(struct scsi_target *);
void (*set_starget_dev_loss_tmo)(struct scsi_target *, uint32_t); void (*set_starget_dev_loss_tmo)(struct scsi_target *, u32);
void (*get_host_port_id)(struct Scsi_Host *);
void (*get_host_port_type)(struct Scsi_Host *);
void (*get_host_port_state)(struct Scsi_Host *);
void (*get_host_active_fc4s)(struct Scsi_Host *);
void (*get_host_speed)(struct Scsi_Host *);
void (*get_host_fabric_name)(struct Scsi_Host *);
void (*get_host_link_down_tmo)(struct Scsi_Host *); void (*get_host_link_down_tmo)(struct Scsi_Host *);
void (*set_host_link_down_tmo)(struct Scsi_Host *, uint32_t); void (*set_host_link_down_tmo)(struct Scsi_Host *, u32);
struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
void (*reset_fc_host_stats)(struct Scsi_Host *); void (*reset_fc_host_stats)(struct Scsi_Host *);
...@@ -112,11 +277,25 @@ struct fc_function_template { ...@@ -112,11 +277,25 @@ struct fc_function_template {
unsigned long show_starget_port_name:1; unsigned long show_starget_port_name:1;
unsigned long show_starget_dev_loss_tmo:1; unsigned long show_starget_dev_loss_tmo:1;
/* host fixed attributes */
unsigned long show_host_node_name:1;
unsigned long show_host_port_name:1;
unsigned long show_host_supported_classes:1;
unsigned long show_host_supported_fc4s:1;
unsigned long show_host_symbolic_name:1;
unsigned long show_host_supported_speeds:1;
unsigned long show_host_maxframe_size:1;
/* host dynamic attributes */
unsigned long show_host_port_id:1;
unsigned long show_host_port_type:1;
unsigned long show_host_port_state:1;
unsigned long show_host_active_fc4s:1;
unsigned long show_host_speed:1;
unsigned long show_host_fabric_name:1;
unsigned long show_host_link_down_tmo:1; unsigned long show_host_link_down_tmo:1;
/* Private Attributes */
}; };
struct scsi_transport_template *fc_attach_transport(struct fc_function_template *); struct scsi_transport_template *fc_attach_transport(struct fc_function_template *);
void fc_release_transport(struct scsi_transport_template *); void fc_release_transport(struct scsi_transport_template *);
int fc_target_block(struct scsi_target *starget); int fc_target_block(struct scsi_target *starget);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment