]> err.no Git - linux-2.6/commitdiff
[SCSI] scsi_transport_sas: support link error attributes
authorChristoph Hellwig <hch@lst.de>
Mon, 19 Sep 2005 19:59:42 +0000 (21:59 +0200)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 28 Oct 2005 19:57:58 +0000 (14:57 -0500)
For now supporting the ->get_linkerrors method is mandatory.  I'll
probably be beaten to implement the .show_foo variables and different
types of attributes soon..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_transport_sas.c
include/scsi/scsi_transport_sas.h

index 1d145d2f9a38b37ed6a3b0b281f60e78aa1ee7c5..63445f90097ebe72aecfb87454d29f37d41f1728 100644 (file)
@@ -34,7 +34,7 @@
 
 
 #define SAS_HOST_ATTRS         0
-#define SAS_PORT_ATTRS         11
+#define SAS_PORT_ATTRS         15
 #define SAS_RPORT_ATTRS                5
 
 struct sas_internal {
@@ -257,6 +257,26 @@ show_sas_phy_##field(struct class_device *cdev, char *buf)         \
        sas_phy_show_linkspeed(field)                                   \
 static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
 
+#define sas_phy_show_linkerror(field)                                  \
+static ssize_t                                                         \
+show_sas_phy_##field(struct class_device *cdev, char *buf)             \
+{                                                                      \
+       struct sas_phy *phy = transport_class_to_phy(cdev);             \
+       struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);        \
+       struct sas_internal *i = to_sas_internal(shost->transportt);    \
+       int error;                                                      \
+                                                                       \
+       error = i->f->get_linkerrors(phy);                              \
+       if (error)                                                      \
+               return error;                                           \
+       return snprintf(buf, 20, "%u\n", phy->field);                   \
+}
+
+#define sas_phy_linkerror_attr(field)                                  \
+       sas_phy_show_linkerror(field)                                   \
+static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
+
+
 static ssize_t
 show_sas_device_type(struct class_device *cdev, char *buf)
 {
@@ -282,6 +302,10 @@ sas_phy_linkspeed_attr(minimum_linkrate_hw);
 sas_phy_linkspeed_attr(minimum_linkrate);
 sas_phy_linkspeed_attr(maximum_linkrate_hw);
 sas_phy_linkspeed_attr(maximum_linkrate);
+sas_phy_linkerror_attr(invalid_dword_count);
+sas_phy_linkerror_attr(running_disparity_error_count);
+sas_phy_linkerror_attr(loss_of_dword_sync_count);
+sas_phy_linkerror_attr(phy_reset_problem_count);
 
 
 static DECLARE_TRANSPORT_CLASS(sas_phy_class,
@@ -749,6 +773,11 @@ sas_attach_transport(struct sas_function_template *ft)
        SETUP_PORT_ATTRIBUTE(minimum_linkrate);
        SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
        SETUP_PORT_ATTRIBUTE(maximum_linkrate);
+
+       SETUP_PORT_ATTRIBUTE(invalid_dword_count);
+       SETUP_PORT_ATTRIBUTE(running_disparity_error_count);
+       SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);
+       SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);
        i->phy_attrs[count] = NULL;
 
        count = 0;
index bc4aeb660dd3472751d0fe6cb8838fd537d1d128..38389d8dd56ea46764a548df51e1f47d818449a0 100644 (file)
@@ -41,20 +41,28 @@ struct sas_identify {
        u8                      phy_identifier;
 };
 
-/* The functions by which the transport class and the driver communicate */
-struct sas_function_template {
-};
-
 struct sas_phy {
        struct device           dev;
        int                     number;
+
+       /* phy identification */
        struct sas_identify     identify;
+
+       /* phy attributes */
        enum sas_linkrate       negotiated_linkrate;
        enum sas_linkrate       minimum_linkrate_hw;
        enum sas_linkrate       minimum_linkrate;
        enum sas_linkrate       maximum_linkrate_hw;
        enum sas_linkrate       maximum_linkrate;
        u8                      port_identifier;
+
+       /* link error statistics */
+       u32                     invalid_dword_count;
+       u32                     running_disparity_error_count;
+       u32                     loss_of_dword_sync_count;
+       u32                     phy_reset_problem_count;
+
+       /* the other end of the link */
        struct sas_rphy         *rphy;
 };
 
@@ -79,6 +87,13 @@ struct sas_rphy {
 #define rphy_to_shost(rphy) \
        dev_to_shost((rphy)->dev.parent)
 
+
+/* The functions by which the transport class and the driver communicate */
+struct sas_function_template {
+       int (*get_linkerrors)(struct sas_phy *);
+};
+
+
 extern void sas_remove_host(struct Scsi_Host *);
 
 extern struct sas_phy *sas_phy_alloc(struct device *, int);