Skip to contentSkip to conversation

aic94xx: add link error counts to the expander phys

PATCH In review James Bottomley 2 participants 3 messages Aug 25, 2006 – Aug 28, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic94xx: add link error counts to the expander phys

Unfortunately, the aic94xx seems to keep none of these mandatory error counts for the HBA phys, but the transport class can still get them from all the expanders using the REPORT_ERROR_LOG SMP function.

James

drivers/scsi/libsas/sas_init.c +11 -0
Index: BUILD-2.6/drivers/scsi/libsas/sas_init.c
===================================================================
@@ -132,6 +132,16 @@
 	return 0;
 }
 
+static int sas_get_linkerrors(struct sas_phy *phy)
+{
+	if (scsi_is_sas_phy_local(phy))
+		/* FIXME: we have no local phy stats
+		 * gathering at this time */
+		return -EINVAL;
+
+	return sas_smp_get_phy_events(phy);
+}
+
 static int sas_phy_reset(struct sas_phy *phy, int hard_reset)
 {
 	int ret;
@@ -160,6 +170,7 @@
 
 static struct sas_function_template sft = {
 	.phy_reset = sas_phy_reset,
+	.get_linkerrors = sas_get_linkerrors,
 };
 
 extern struct scsi_transport_template *
drivers/scsi/libsas/sas_expander.c +33 -0
Index: BUILD-2.6/drivers/scsi/libsas/sas_expander.c
===================================================================
@@ -502,6 +502,39 @@
 	return 0;
 }
 
+#define RPEL_REQ_SIZE	16
+#define RPEL_RESP_SIZE	32
+int sas_smp_get_phy_events(struct sas_phy *phy)
+{
+	int res;
+	struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
+	struct domain_device *dev = sas_find_dev_by_rphy(rphy);
+	u8 *req = alloc_smp_req(RPEL_REQ_SIZE);
+	u8 *resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL);
+
+	if (!resp)
+		return -ENOMEM;
+
+	req[1] = SMP_REPORT_PHY_ERR_LOG;
+	req[9] = phy->number;
+
+	res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
+			            resp, RPEL_RESP_SIZE);
+
+	if (!res)
+		goto out;
+
+	phy->invalid_dword_count = scsi_to_u32(&resp[12]);
+	phy->running_disparity_error_count = scsi_to_u32(&resp[16]);
+	phy->loss_of_dword_sync_count = scsi_to_u32(&resp[20]);
+	phy->phy_reset_problem_count = scsi_to_u32(&resp[24]);
+
+ out:
+	kfree(resp);
+	return res;
+
+}
+
 #define RPS_REQ_SIZE  16
 #define RPS_RESP_SIZE 60
 
include/scsi/scsi.h +6 -0
Index: BUILD-2.6/include/scsi/scsi.h
===================================================================
@@ -429,4 +429,10 @@
 /* Used to obtain the PCI location of a device */
 #define SCSI_IOCTL_GET_PCI		0x5387
 
+/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */
+static inline u32 scsi_to_u32(u8 *ptr)
+{
+	return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
+}
+
 #endif /* _SCSI_SCSI_H */
drivers/scsi/libsas/sas_internal.h +2 -0
Index: BUILD-2.6/drivers/scsi/libsas/sas_internal.h
===================================================================
@@ -26,6 +26,7 @@
 #ifndef _SAS_INTERNAL_H_
 #define _SAS_INTERNAL_H_
 
+#include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport_sas.h>
 #include <scsi/libsas.h>
@@ -70,6 +71,7 @@
 
 int sas_smp_phy_control(struct domain_device *dev, int phy_id,
 			enum phy_func phy_func);
+int sas_smp_get_phy_events(struct sas_phy *phy);
 
 struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
 
#1 lore raw
Quoted 2 lines · --- James Bottomley

Unfortunately, the aic94xx seems to keep none of these mandatory error counts for the HBA phys,

That's not true.

Quoted 120 lines

but the transport class can still get them from all the expanders using the REPORT_ERROR_LOG SMP function.

James

Index: BUILD-2.6/drivers/scsi/libsas/sas_init.c
===================================================================

drivers/scsi/libsas/sas_init.c +11 -0
@@ -132,6 +132,16 @@
 	return 0;
 }
 
+static int sas_get_linkerrors(struct sas_phy *phy)
+{
+	if (scsi_is_sas_phy_local(phy))
+		/* FIXME: we have no local phy stats
+		 * gathering at this time */
+		return -EINVAL;
+
+	return sas_smp_get_phy_events(phy);
+}
+
 static int sas_phy_reset(struct sas_phy *phy, int hard_reset)
 {
 	int ret;
@@ -160,6 +170,7 @@
 
 static struct sas_function_template sft = {
 	.phy_reset = sas_phy_reset,
+	.get_linkerrors = sas_get_linkerrors,
 };
 
 extern struct scsi_transport_template *

Index: BUILD-2.6/drivers/scsi/libsas/sas_expander.c
===================================================================

drivers/scsi/libsas/sas_expander.c +33 -0
@@ -502,6 +502,39 @@
 	return 0;
 }
 
+#define RPEL_REQ_SIZE	16
+#define RPEL_RESP_SIZE	32
+int sas_smp_get_phy_events(struct sas_phy *phy)
+{
+	int res;
+	struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
+	struct domain_device *dev = sas_find_dev_by_rphy(rphy);
+	u8 *req = alloc_smp_req(RPEL_REQ_SIZE);
+	u8 *resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL);
+
+	if (!resp)
+		return -ENOMEM;
+
+	req[1] = SMP_REPORT_PHY_ERR_LOG;
+	req[9] = phy->number;
+
+	res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
+			            resp, RPEL_RESP_SIZE);
+
+	if (!res)
+		goto out;
+
+	phy->invalid_dword_count = scsi_to_u32(&resp[12]);
+	phy->running_disparity_error_count = scsi_to_u32(&resp[16]);
+	phy->loss_of_dword_sync_count = scsi_to_u32(&resp[20]);
+	phy->phy_reset_problem_count = scsi_to_u32(&resp[24]);
+
+ out:
+	kfree(resp);
+	return res;
+
+}
+
 #define RPS_REQ_SIZE  16
 #define RPS_RESP_SIZE 60
 

Index: BUILD-2.6/include/scsi/scsi.h
===================================================================

include/scsi/scsi.h +6 -0
@@ -429,4 +429,10 @@
 /* Used to obtain the PCI location of a device */
 #define SCSI_IOCTL_GET_PCI		0x5387
 
+/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */
+static inline u32 scsi_to_u32(u8 *ptr)
+{
+	return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
+}
+
 #endif /* _SCSI_SCSI_H */

Index: BUILD-2.6/drivers/scsi/libsas/sas_internal.h
===================================================================

drivers/scsi/libsas/sas_internal.h +2 -1
@@ -26,6 +26,7 @@
 #ifndef _SAS_INTERNAL_H_
 #define _SAS_INTERNAL_H_
 
+#include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport_sas.h>
 #include <scsi/libsas.h>
@@ -70,6 +71,7 @@
 
 int sas_smp_phy_control(struct domain_device *dev, int phy_id,
 			enum phy_func phy_func);
+int sas_smp_get_phy_events(struct sas_phy *phy);
 
 struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
 
 
 
-

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 6 lines · Luben Tuikov
Quoted 1 line · --- James Bottomley

Unfortunately, the aic94xx seems to keep none of these mandatory

error

Quoted 1 line

counts for the HBA phys,

That's not true.

OK, so where are they? I did grep the aic94xx source code for the SAS-2 specified names for these things and didn't turn up anything. I can see the sequencer would keep these counts, but they don't seem to be exported to the driver.

James