Skip to contentSkip to conversation

mptsas: support link error attributes[2 round] - and phy_reset attributes

PATCH In review Moore, Eric Dean 2 participants 2 messages Oct 13, 2005 – Oct 17, 2005

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

PATCH 1/1 mptsas: support link error attributes[2 round] - and phy_reset attributes

This patch applies ontop of 2.6.14-rc4
and two patches previous posted by Christoph

(1) [PATCH] mptsas: support link error attributes
http://marc.theaimsgroup.com/?l=linux-scsi&m=112716006932685&w=2

(2) [PATCH] scsi_transport_sas: support link error attributes
http://marc.theaimsgroup.com/?l=linux-scsi&m=112716000904268&w=2

This attached patch changelog as follows:

(1) fix´s the proper phy_identifier attribute to be set properly so link_attributes returns correct values from firmware.

(2) Only link_attributes work for hba attached phys. Its not implemented for expanders.

(3) Add phy link_reset and hard_reset support. These work for hba attached phys, not for expanders. This was a patch previously provided by Christoph - added support in scsi_transport_sas.

drivers/message/fusion/Makefile +1 -1
diff -uarN b/drivers/message/fusion/Makefile a/drivers/message/fusion/Makefile
@@ -7,7 +7,7 @@
 #EXTRA_CFLAGS += -DMPT_DEBUG_INIT
 #EXTRA_CFLAGS += -DMPT_DEBUG_EXIT
 #EXTRA_CFLAGS += -DMPT_DEBUG_FAIL
-
+#EXTRA_CFLAGS += -DSASDEBUG
 
 #
 # driver/module specifics...
drivers/message/fusion/mptbase.h +14 -2
diff -uarN b/drivers/message/fusion/mptbase.h a/drivers/message/fusion/mptbase.h
@@ -77,8 +77,8 @@
 #define COPYRIGHT	"Copyright (c) 1999-2005 " MODULEAUTHOR
 #endif
 
-#define MPT_LINUX_VERSION_COMMON	"3.03.03"
-#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.03.03"
+#define MPT_LINUX_VERSION_COMMON	"3.03.04"
+#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.03.04"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
 
 #define show_mptmod_ver(s,ver)  \
@@ -421,6 +421,17 @@
 	struct semaphore	 sem_ioc;
 } MPT_IOCTL;
 
+#define MPT_SAS_MGMT_STATUS_RF_VALID	0x02	/* The Reply Frame is VALID */
+#define MPT_SAS_MGMT_STATUS_COMMAND_GOOD	0x10	/* Command Status GOOD */
+#define MPT_SAS_MGMT_STATUS_TM_FAILED	0x40	/* User TM request failed */
+
+typedef struct _MPT_SAS_MGMT {
+	struct semaphore	 mutex;
+	struct completion	 done;
+	u8			 reply[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */
+	u8			 status;	/* current command status */
+}MPT_SAS_MGMT;
+
 /*
  *  Event Structure and define
  */
@@ -604,6 +615,7 @@
 	struct list_head	 list;
 	struct net_device	*netdev;
 	struct list_head	 sas_topology;
+	MPT_SAS_MGMT		 sas_mgmt;
 } MPT_ADAPTER;
 
 /*
drivers/message/fusion/mptsas.c +108 -10

200 lines not on this page · raw message

drivers/scsi/scsi_transport_sas.c +38 -2
diff -uarN b/drivers/scsi/scsi_transport_sas.c a/drivers/scsi/scsi_transport_sas.c
@@ -34,7 +34,7 @@
 
 
 #define SAS_HOST_ATTRS		0
-#define SAS_PORT_ATTRS		15
+#define SAS_PORT_ATTRS		17
 #define SAS_RPORT_ATTRS		5
 
 struct sas_internal {
@@ -286,9 +286,36 @@
 		return snprintf(buf, 20, "none\n");
 	return get_sas_device_type_names(phy->identify.device_type, buf);
 }
-
 static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
 
+static ssize_t do_sas_phy_reset(struct class_device *cdev,
+		size_t count, int hard_reset)
+{
+	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->phy_reset(phy, hard_reset);
+	if (error)
+		return error;
+	return count;
+};
+
+static ssize_t store_sas_link_reset(struct class_device *cdev,
+		const char *buf, size_t count)
+{
+	return do_sas_phy_reset(cdev, count, 0);
+}
+static CLASS_DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset);
+
+static ssize_t store_sas_hard_reset(struct class_device *cdev,
+		const char *buf, size_t count)
+{
+	return do_sas_phy_reset(cdev, count, 1);
+}
+static CLASS_DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset);
+
 sas_phy_protocol_attr(identify.initiator_port_protocols,
 		initiator_port_protocols);
 sas_phy_protocol_attr(identify.target_port_protocols,
@@ -722,6 +749,13 @@
         i->phy_attrs[count] = &i->private_phy_attrs[count];		\
 	count++
 
+#define SETUP_PORT_ATTRIBUTE_WRONLY(field)				\
+	i->private_phy_attrs[count] = class_device_attr_##field;	\
+	i->private_phy_attrs[count].attr.mode = S_IWUGO;		\
+	i->private_phy_attrs[count].show = NULL;			\
+	i->phy_attrs[count] = &i->private_phy_attrs[count];		\
+	count++
+
 
 /**
  * sas_attach_transport  --  instantiate SAS transport template
@@ -778,6 +812,8 @@
 	SETUP_PORT_ATTRIBUTE(running_disparity_error_count);
 	SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);
 	SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);
+	SETUP_PORT_ATTRIBUTE_WRONLY(link_reset);
+	SETUP_PORT_ATTRIBUTE_WRONLY(hard_reset);
 	i->phy_attrs[count] = NULL;
 
 	count = 0;
include/scsi/scsi_transport_sas.h +5 -5
diff -uarN b/include/scsi/scsi_transport_sas.h a/include/scsi/scsi_transport_sas.h
@@ -57,10 +57,10 @@
 	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;
+	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;
@@ -87,10 +87,10 @@
 #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 *);
+	int (*phy_reset)(struct sas_phy *, int);
 };
 
 
#1 lore raw
Quoted 14 lines · Eric Dean

This patch applies ontop of 2.6.14-rc4
and two patches previous posted by Christoph

(1) [PATCH] mptsas: support link error attributes
http://marc.theaimsgroup.com/?l=linux-scsi&m=112716006932685&w=2

(2) [PATCH] scsi_transport_sas: support link error attributes
http://marc.theaimsgroup.com/?l=linux-scsi&m=112716000904268&w=2

This attached patch changelog as follows:

(1) fix?s the proper phy_identifier attribute to be set properly so link_attributes returns correct values from firmware.

Quoted 6 lines

(2) Only link_attributes work for hba attached phys. Its not implemented for expanders.

(3) Add phy link_reset and hard_reset support. These work for hba attached phys, not for expanders. This was a patch previously provided by Christoph - added support in scsi_transport_sas.

Except for some whitespace changes and some odd bits about the reply handle this looks good. But it really needs to be split up, we should try to get the phy identifier fix into 2.6.14 if possible, and the transport class bits needs to be separate from the mptsas changes for the link reset. I'll resend some split-up patches.