Skip to contentSkip to conversation

aic94xx: sas code clean-up

PATCH In review Alexis Bruemmer 4 participants 16 messages May 9, 2006 – May 10, 2006

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

cover aic94xx: sas code clean-up

These patches were created in response to the comments from this earlier email:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114624643916659&w=2

First off, thank you Christoph for your comments. I am working to address them, starting with the ones that are easiest to implement. Follows is a set of patches that address the following concerns:

1) Move the sas readme to the Documents dir-- this still needs to be written so that it 'matches reality', but I want to merge the sas*.h files to libsas.h and sas.h first
2) Remove the sas_common.c file
3) Remove the //depot SCM comments
4) Remove the expander_conf.c from the kernel tree
5) Remove various inline functions
6) Move list_each_entry_reverse_safe from sas_discover.h to list.h
7) Remove the long queue implementation comment
8) Use bitops for setting and clearing bits

These patches are just a start and I will continue to address these issues.

Regards,

Alexis

#1 lore raw

PATCH 1/8 aic94xx: move sas README

Move the sas readme to the Documents dir

---
 drivers/scsi/sas/README    |  484 ---------------------------------------------
 Documentation/scsi/sas.txt |    3 
 2 files changed, 3 insertions(+), 484 deletions(-)
Documentation/scsi/sas.txt new file +3 -0
Index: aic94xx-sas-2.6-patched/Documentation/scsi/sas.txt
===================================================================
@@ -0,0 +1,3 @@
+SAS Layer
+---------
+Coming Soon
drivers/scsi/sas/README deleted +0 -484

484 lines not on this page · raw message

#2 lore raw

PATCH 2/8 aic94xx: remove the sas_common.c file

In reply to Alexis Bruemmer

Remove the sas_common.c file which only included redundant code

---
 drivers/scsi/sas/sas_common.c |  115 ------------------------------------------
 drivers/scsi/sas/Makefile     |    1 
 drivers/scsi/sas/sas_init.c   |   25 +++++++++
 3 files changed, 25 insertions(+), 116 deletions(-)
drivers/scsi/sas/sas_common.c deleted +0 -115
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_common.c
===================================================================
@@ -1,115 +0,0 @@
-/*
- * Serial Attached SCSI (SAS) class common functions
- *
- * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
- * Copyright (C) 2005 Luben Tuikov <[email protected]>
- *
- * This file is licensed under GPLv2.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- *
- * $Id: //depot/sas-class/sas_common.c#9 $
- */
-
-#include <scsi/sas/sas_class.h>
-#include "sas_internal.h"
-
-int sas_show_class(enum sas_class class, char *buf)
-{
-	static const char *class_str[] = {
-		[SAS] = "SAS",
-		[EXPANDER] = "EXPANDER",
-	};
-	return sprintf(buf, "%s\n", class_str[class]);
-}
-
-int sas_show_proto(enum sas_proto proto, char *page)
-{
-	static const char *proto_str[] = {
-		[SATA_PROTO] = "SATA",
-		[SAS_PROTO_SMP] = "SMP",
-		[SAS_PROTO_STP] = "STP",
-		[SAS_PROTO_SSP] = "SSP",
-	};
-	int  v;
-	char *buf = page;
-
-	for (v = 1; proto != 0 && v <= SAS_PROTO_SSP; v <<= 1) {
-		if (v & proto) {
-			buf += sprintf(buf, "%s", proto_str[v]);
-
-			if (proto & ~((v<<1)-1))
-				buf += sprintf(buf, "|");
-			else
-				buf += sprintf(buf, "\n");
-		}
-	}
-	return buf-page;
-}
-
-int sas_show_linkrate(enum sas_phy_linkrate linkrate, char *page)
-{
-	static const char *phy_linkrate_str[] = {
-		[PHY_LINKRATE_NONE] = "",
-		[PHY_DISABLED] = "disabled",
-		[PHY_RESET_PROBLEM] = "phy reset problem",
-		[PHY_SPINUP_HOLD] = "phy spinup hold",
-		[PHY_PORT_SELECTOR] = "phy port selector",
-		[PHY_LINKRATE_1_5] = "1,5 GB/s",
-		[PHY_LINKRATE_3]  = "3,0 GB/s",
-		[PHY_LINKRATE_6] = "6,0 GB/s",
-	};
-	return sprintf(page, "%s\n", phy_linkrate_str[linkrate]);
-}
-
-int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf)
-{
-	switch (oob_mode) {
-	case OOB_NOT_CONNECTED:
-		return sprintf(buf, "%s", "");
-		break;
-	case SATA_OOB_MODE:
-		return sprintf(buf, "%s\n", "SATA");
-		break;
-	case SAS_OOB_MODE:
-		return sprintf(buf, "%s\n", "SAS");
-		break;
-	}
-	return 0;
-}
-
-void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
-{
-	const u32 poly = 0x00DB2777;
-	u32 	r = 0;
-	int 	i;
-
-	for (i = 0; i < 8; i++) {
-		int b;
-		for (b = 7; b >= 0; b--) {
-			r <<= 1;
-			if ((1 << b) & sas_addr[i]) {
-				if (!(r & 0x01000000))
-					r ^= poly;
-			} else if (r & 0x01000000)
-				r ^= poly;
-		}
-	}
-
-	hashed[0] = (r >> 16) & 0xFF;
-	hashed[1] = (r >> 8) & 0xFF ;
-	hashed[2] = r & 0xFF;
-}
drivers/scsi/sas/Makefile +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/Makefile
===================================================================
@@ -32,7 +32,6 @@ clean-files += expander_conf
 
 obj-$(CONFIG_SCSI_SAS_DOMAIN_ATTRS) += scsi_transport_sas_domain.o
 scsi_transport_sas_domain-y +=  sas_init.o     \
-		sas_common.o   \
 		sas_phy.o      \
 		sas_port.o     \
 		sas_event.o    \
drivers/scsi/sas/sas_init.c +25 -0
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_init.c
===================================================================
@@ -40,6 +40,31 @@
 
 kmem_cache_t *sas_task_cache;
 
+/*------------ SAS addr hash -----------*/
+void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
+{
+        const u32 poly = 0x00DB2777;
+        u32     r = 0;
+        int     i;
+
+        for (i = 0; i < 8; i++) {
+                int b;
+                for (b = 7; b >= 0; b--) {
+                        r <<= 1;
+                        if ((1 << b) & sas_addr[i]) {
+                                if (!(r & 0x01000000))
+                                        r ^= poly;
+                        } else if (r & 0x01000000)
+                                r ^= poly;
+                }
+        }
+
+        hashed[0] = (r >> 16) & 0xFF;
+        hashed[1] = (r >> 8) & 0xFF ;
+        hashed[2] = r & 0xFF;
+}
+
+
 /* ---------- HA events ---------- */
 
 void sas_hae_reset(void *data)
#3 lore raw

PATCH 3/8 aic94xx: remove the //depot SCM comments

In reply to Alexis Bruemmer

Remove the //depot SCM comments

---
 drivers/scsi/sas/Kconfig         |    2 --
 drivers/scsi/sas/Makefile        |    2 --
 drivers/scsi/sas/sas_discover.c  |    1 -
 drivers/scsi/sas/sas_dump.c      |    1 -
 drivers/scsi/sas/sas_dump.h      |    1 -
 drivers/scsi/sas/sas_event.c     |    1 -
 drivers/scsi/sas/sas_expander.c  |    1 -
 drivers/scsi/sas/sas_init.c      |    1 -
 drivers/scsi/sas/sas_internal.h  |    1 -
 drivers/scsi/sas/sas_phy.c       |    1 -
 drivers/scsi/sas/sas_port.c      |    1 -
 drivers/scsi/sas/sas_scsi_host.c |    1 -
 include/scsi/sas/sas.h           |    1 -
 include/scsi/sas/sas_class.h     |    1 -
 include/scsi/sas/sas_discover.h  |    1 -
 include/scsi/sas/sas_expander.h  |    1 -
 include/scsi/sas/sas_frames.h    |    1 -
 include/scsi/sas/sas_frames_be.h |    1 -
 include/scsi/sas/sas_frames_le.h |    1 -
 include/scsi/sas/sas_task.h      |    1 -
 20 files changed, 22 deletions(-)
drivers/scsi/sas/sas_discover.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_discover.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_discover.c#140 $
  */
 
 #include <linux/pci.h>
drivers/scsi/sas/sas_dump.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_dump.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_dump.c#4 $
  */
 
 #include "sas_dump.h"
drivers/scsi/sas/sas_dump.h +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_dump.h
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_dump.h#2 $
  */
 
 #include "sas_internal.h"
drivers/scsi/sas/sas_event.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_event.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_event.c#26 $
  */
 
 /**
drivers/scsi/sas/sas_expander.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_expander.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_expander.c#60 $
  */
 
 #include <linux/pci.h>
drivers/scsi/sas/sas_init.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_init.c
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_init.c#45 $
  */
 
 #include <linux/module.h>
drivers/scsi/sas/sas_internal.h +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_internal.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_internal.h#35 $
  */
 
 #ifndef _SAS_INTERNAL_H_
drivers/scsi/sas/sas_phy.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_phy.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_phy.c#38 $
  */
 
 #include "sas_internal.h"
drivers/scsi/sas/sas_port.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_port.c
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_port.c#44 $
  */
 
 #include "sas_internal.h"
drivers/scsi/sas/sas_scsi_host.c +0 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_scsi_host.c
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_scsi_host.c#60 $
  */
 
 #include "sas_internal.h"
drivers/scsi/sas/Kconfig +0 -2
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/Kconfig
===================================================================
@@ -21,8 +21,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 #
-# $Id: //depot/sas-class/Kconfig#6 $
-#
 
 config SCSI_SAS_DOMAIN_ATTRS
 	tristate "SAS Domain Transport Attributes"
drivers/scsi/sas/Makefile +0 -2
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/Makefile
===================================================================
@@ -21,8 +21,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 #
-# $Id: //depot/sas-class/Makefile#20 $
-#
 
 ifeq ($(CONFIG_SCSI_SAS_DOMAIN_DEBUG),y)
 	EXTRA_CFLAGS += -DSAS_DEBUG -g
include/scsi/sas/sas.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas.h#25 $
  */
 
 #ifndef _SAS_H_
include/scsi/sas/sas_class.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_class.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_class.h#66 $
  */
 
 #ifndef _SAS_CLASS_H_
include/scsi/sas/sas_discover.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_discover.h
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_discover.h#41 $
  */
 
 #ifndef _SAS_DISCOVER_H_
include/scsi/sas/sas_expander.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_expander.h
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_expander.h#19 $
  */
 
 #ifndef _SAS_EXPANDER_H_
include/scsi/sas/sas_frames.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_frames.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_frames.h#5 $
  */
 
 #ifndef _SAS_FRAMES_
include/scsi/sas/sas_frames_be.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_frames_be.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_frames_be.h#11 $
  */
 
 #ifndef _SAS_FRAMES_BE_H_
include/scsi/sas/sas_frames_le.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_frames_le.h
===================================================================
@@ -21,7 +21,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * $Id: //depot/sas-class/sas_frames_le.h#10 $
  */
 
 #ifndef _SAS_FRAMES_LE_H_
include/scsi/sas/sas_task.h +0 -1
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_task.h
===================================================================
@@ -20,7 +20,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * $Id: //depot/sas-class/sas_task.h#27 $
  */
 
 #ifndef _SAS_TASK_H_
#4 lore raw

PATCH 4/8 aic94xx: remove expander_conf.c

In reply to Alexis Bruemmer

Remove expander_conf.c from the kernel tree

---
 drivers/scsi/sas/expander_conf.c |  463 ---------------------------------------
 drivers/scsi/sas/Makefile        |    2 
 2 files changed, 465 deletions(-)
drivers/scsi/sas/Makefile +0 -2
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/Makefile
===================================================================
@@ -26,8 +26,6 @@ ifeq ($(CONFIG_SCSI_SAS_DOMAIN_DEBUG),y)
 	EXTRA_CFLAGS += -DSAS_DEBUG -g
 endif
 
-clean-files += expander_conf
-
 obj-$(CONFIG_SCSI_SAS_DOMAIN_ATTRS) += scsi_transport_sas_domain.o
 scsi_transport_sas_domain-y +=  sas_init.o     \
 		sas_phy.o      \
drivers/scsi/sas/expander_conf.c deleted +0 -463

463 lines not on this page · raw message

#5 lore raw

Re: [PATCH 4/8] aic94xx: remove expander_conf.c

Quoted 4 lines · --- Alexis Bruemmer

Remove expander_conf.c from the kernel tree

It is easy to delete files. It is not easy to write them.

What is the immediate replacement for "expander_conf.c"? I.e. what is the immediate replacement for a utility which can address any expander on the domain and issue SMP functions to it?

Luben

Quoted 494 lines
---
 drivers/scsi/sas/expander_conf.c |  463 ---------------------------------------
 drivers/scsi/sas/Makefile        |    2 
 2 files changed, 465 deletions(-)

Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/Makefile
===================================================================

drivers/scsi/sas/Makefile +0 -2
@@ -26,8 +26,6 @@ ifeq ($(CONFIG_SCSI_SAS_DOMAIN_DEBUG),y)
 	EXTRA_CFLAGS += -DSAS_DEBUG -g
 endif
 
-clean-files += expander_conf
-
 obj-$(CONFIG_SCSI_SAS_DOMAIN_ATTRS) += scsi_transport_sas_domain.o
 scsi_transport_sas_domain-y +=  sas_init.o     \
 		sas_phy.o      \

Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/expander_conf.c
===================================================================

drivers/scsi/sas/expander_conf.c deleted +0 -464
@@ -1,463 +0,0 @@
-/*
- * Serial Attached SCSI (SAS) Expander communication user space program
- *
- * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
- * Copyright (C) 2005 Luben Tuikov <[email protected]>
- *
- * This file is licensed under GPLv2.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * $Id: //depot/sas-class/expander_conf.c#7 $
- */
-
-/* This is a simple program to show how to communicate with
- * expander devices in a SAS domain.
- *
- * The process is simple:
- * 1. Build the SMP frame you want to send. The format and layout
- *    is described in the SAS spec.  Leave the CRC field equal 0.
- * 2. Open the expander's SMP portal sysfs file in RW mode.
- * 3. Write the frame you built in 1.
- * 4. Read the amount of data you expect to receive for the frame you built.
- *    If you receive different amount of data you expected to receive,
- *    then there was some kind of error.
- * All this process is shown in detail in the function do_smp_func()
- * and its callers, below.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <string.h>
-#include <errno.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#define LEFT_FIELD_SIZE 25
-
-#ifdef __LITTLE_ENDIAN
-#define be64_to_cpu(_x)  __bswap_64(*(uint64_t *)(&(_x)))
-#define be32_to_cpu(_x)  __bswap_32(*(uint32_t *)(&(_x)))
-#define be16_to_cpu(_x)  __bswap_16(*(uint16_t *)(&(_x)))
-#define cpu_to_be64(_x)  __bswap_64(*(uint64_t *)(&(_x)))
-#define cpu_to_be32(_x)  __bswap_32(*(uint32_t *)(&(_x)))
-#define cpu_to_be16(_x)  __bswap_16(*(uint16_t *)(&(_x)))
-#else
-#define be64_to_cpu(_x)  (_x)
-#define be32_to_cpu(_x)  (_x)
-#define be16_to_cpu(_x)  (_x)
-#define cpu_to_be64(_x)  (_x)
-#define cpu_to_be32(_x)  (_x)
-#define cpu_to_be16(_x)  (_x)
-#endif
-
-#define SAS_ADDR(_x) ((unsigned long long) be64_to_cpu(*(uint64_t *)(_x)))
-#define SAS_ADDR_SIZE 8
-
-const char *prog;
-
-struct route_table_entry {
-	int      disabled;
-	uint8_t  routed_sas_addr[SAS_ADDR_SIZE];
-};
-
-struct expander {
-	int     num_phys;
-	uint8_t *phy_attr;
-	int     route_indexes;
-};
-
-static int do_smp_func(char *smp_portal_name, void *smp_req, int smp_req_size,
-		       void *smp_resp, int smp_resp_size)
-{
-	int fd;
-	ssize_t res;
-
-	fd = open(smp_portal_name, O_RDWR);
-	if (fd == -1) {
-		printf("%s: opening %s: %s(%d)\n", prog, smp_portal_name,
-		       strerror(errno), errno);
-		return fd;
-	}
-
-	res = write(fd, smp_req, smp_req_size);
-	if (!res) {
-		printf("%s: nothing could be written to %s\n", prog,
-		       smp_portal_name);
-		goto out_err;
-	} else if (res == -1) {
-		printf("%s: writing to %s: %s(%d)\n", prog, smp_portal_name,
-		       strerror(errno), errno);
-		goto out_err;
-	}
-
-	res = read(fd, smp_resp, smp_resp_size);
-	if (!res) {
-		printf("%s: nothing could be read from %s\n", prog,
-		       smp_portal_name);
-		goto out_err;
-	} else if (res == -1) {
-		printf("%s: reading from %s: %s(%d)\n", prog, smp_portal_name,
-		       strerror(errno), errno);
-		goto out_err;
-	}
-	close(fd);
-	return res;
- out_err:
-	close(fd);
-	return -1;
-}
-
-#define MI_REQ_SIZE   8
-#define MI_RESP_SIZE 64
-
-static unsigned char mi_req[MI_REQ_SIZE] = { 0x40, 1, 0, };
-static unsigned char mi_resp[MI_RESP_SIZE];
-
-#define MI_FIELD_SIZE 20
-#define MI_PRINTS(a, b) printf("%*s %*s\n",LEFT_FIELD_SIZE,a,MI_FIELD_SIZE,b)
-#define MI_PRINTD(a, b) printf("%*s %*u\n",LEFT_FIELD_SIZE,a,MI_FIELD_SIZE,b)
-#define MI_PRINTA(a, b) printf("%*s %0*llx\n",LEFT_FIELD_SIZE,a,MI_FIELD_SIZE,b)
-
-static int mi_expander(char *smp_portal_name, struct expander *ex)
-{
-	int res;
-
-	res = do_smp_func(smp_portal_name, mi_req, MI_REQ_SIZE,
-			  mi_resp, MI_RESP_SIZE);
-	if (res == MI_RESP_SIZE && mi_resp[2] == 0) {
-		char buf[20];
-
-		memcpy(buf, mi_resp+12, 8);
-		buf[8] = 0;
-		MI_PRINTS("Vendor:", buf);
-
-		memcpy(buf, mi_resp+20, 16);
-		buf[16] = 0;
-		MI_PRINTS("Product:", buf);
-
-		memcpy(buf, mi_resp+36, 4);
-		buf[4] = 0;
-		MI_PRINTS("Revision:", buf);
-
-		if (!(mi_resp[8] & 1))
-			return 0;
-
-		memcpy(buf, mi_resp+40, 8);
-		buf[8] = 0;
-		MI_PRINTS("Component:", buf);
-
-		MI_PRINTD("Component ID:", be16_to_cpu(mi_resp[48]));
-		MI_PRINTD("Component revision:", mi_resp[50]);
-	}
-	return 0;
-}
-
-#define RG_REQ_SIZE   8
-#define RG_RESP_SIZE 32
-
-static unsigned char rg_req[RG_REQ_SIZE] = { 0x40, 0, };
-static unsigned char rg_resp[RG_RESP_SIZE];
-
-static int rg_expander(char *smp_portal_name, struct expander *ex)
-{
-	int res;
-
-	res = do_smp_func(smp_portal_name, rg_req, RG_REQ_SIZE, rg_resp,
-			  RG_RESP_SIZE);
-
-	if (res == RG_RESP_SIZE && rg_resp[2] == 0) {
-		MI_PRINTD("Expander Change Count:", be16_to_cpu(rg_resp[4]));
-		MI_PRINTD("Expander Route Indexes:", be16_to_cpu(rg_resp[6]));
-		ex->route_indexes = be16_to_cpu(rg_resp[6]);
-		MI_PRINTD("Number of phys:", rg_resp[9]);
-		ex->num_phys = rg_resp[9];
-		MI_PRINTS("Configuring:", (rg_resp[10] & 2) ? "Yes" : "No");
-		MI_PRINTS("Configurable route table:",
-			  (rg_resp[10] & 1) ? "Yes" : "No");
-		MI_PRINTA("Enclosure Logical Identifier:",
-			  SAS_ADDR(rg_resp+12));
-		ex->phy_attr = malloc(ex->num_phys * sizeof(*ex->phy_attr));
-	}
-	return 0;
-}
-
-#define DISCOVER_REQ_SIZE  16
-#define DISCOVER_RESP_SIZE 56
-
-static unsigned char disc_req[DISCOVER_REQ_SIZE] = {0x40, 0x10, 0, };
-static unsigned char disc_resp[DISCOVER_RESP_SIZE];
-
-#define PHY_EEXIST 0x10
-#define PHY_VACANT 0x16
-
-static const char *attached_dev_type[8] = {
-	[0] = "none",
-	[1] = "end device",
-	[2] = "edge expander",
-	[3] = "fanout expander",
-	[4 ... 7] = "unknown",
-};
-
-static const char *phy_link_rate[16] = {
-	[0] = "unknown",
-	[1] = "disabled",
-	[2] = "phy reset problem",
-	[3] = "spinup hold",
-	[4] = "port selector",
-	[5 ... 7] = "unknown",
-	[8] = "G1 (1,5 Gb/s)",
-	[9] = "G2 (3 GB/s)",
-	[10 ... 15] = "Unknown",
-};
-
-static const char *proto_table[8] = {
-	"",
-	"SMP", "STP", "STP|SMP", "SSP",
-	"SSP|SMP", "SSP|STP", "SSP|STP|SMP",
-};
-
-#define DIRECT_ROUTING      0
-#define SUBTRACTIVE_ROUTING 1
-#define TABLE_ROUTING       2
-
-static const char *routing_attr[8] = {
-	[DIRECT_ROUTING] = "D",
-	[SUBTRACTIVE_ROUTING] = "S",
-	[TABLE_ROUTING] = "T",
-	[3 ... 7] = "x",
-};
-
-static const char *conn_type[0x80] = {
-	[0] = "No information",
-	[1] = "SAS external receptacle (i.e., SFF-8470)(see SAS-1.1)",
-	[2] = "SAS external compact receptacle (i.e., SFF-8088)(see SAS-1.1)",
-	[3 ... 0x0f ] = "External connector",
-	[0x10] = "SAS internal wide plug (i.e., SFF-8484)(see SAS-1.1)",
-	[0x11] = "SAS internal compact wide plug (i.e., SFF-8087)(see SAS-1.1)",
-	[0x12 ... 0x1f] = "Internal wide connector",
-	[0x20] = "SAS backplane receptacle (i.e., SFF-8482)(see SAS-1.1)",
-	[0x21] = "SATA-style host plug (i.e., ATA/ATAPI-7 V3)(see SAS-1.1)",
-	[0x22] = "SAS plug (i.e., SFF-8482)(see SAS-1.1)",
-	[0x23] = "SATA device plug (i.e., ATA/ATAPI-7 V3)(see SAS-1.1)",
-	[0x24 ... 0x2f] = "Internal connector to end device",
-	[0x30 ... 0x6f] = "Unknown\n",
-	[0x70 ... 0x7f] = "Vendor specific",
-};
-
-static int discover_phy(char *smp_portal_name, int phy_id, struct expander *ex)
-{
-	int res;
-	const char *dev_str;
-
-	disc_req[9] = phy_id;
-
-	res = do_smp_func(smp_portal_name, disc_req, DISCOVER_REQ_SIZE,
-			  disc_resp, DISCOVER_RESP_SIZE);
-
-	if (res != DISCOVER_RESP_SIZE) {
-		printf("%s: error disovering phy %d\n", prog, phy_id);
-		goto out;
-	}
-	switch (disc_resp[2]) {
-	case PHY_VACANT:
-		printf("phy%02d: vacant\n", phy_id);
-		goto out; break;
-	case PHY_EEXIST:
-		printf("phy%02d doesn't exist\n", phy_id);
-		goto out; break;
-	case 0:
-		break;
-	default:
-		printf("phy%02d SMP function result: 0x%x\n",
-		       phy_id, disc_resp[2]);
-		goto out;
-	}
-
-	printf("Phy%02d:%s    attached: %016llx:%02d    chg count:%02d\n",
-	       phy_id, routing_attr[disc_resp[44] & 0x0F],
-	       SAS_ADDR(disc_resp+24), disc_resp[32], disc_resp[42]);
-
-	if (ex->phy_attr)
-		ex->phy_attr[phy_id] = disc_resp[44] & 0x0F;
-
-	if (disc_resp[14] & 1)
-		dev_str = "SATA Host";
-	else if (disc_resp[15] & 0x80)
-		dev_str = "SATA Port Selector";
-	else if (disc_resp[15] & 1)
-		dev_str = "SATA device";
-	else
-		dev_str = attached_dev_type[(disc_resp[12] & 0x70) >> 4];
-	printf(" Attached device: %15s    Link rate: %15s\n",
-	       dev_str, phy_link_rate[disc_resp[13] & 0xf]);
-
-	printf(" Tproto: %15s    Iproto: %15s\n",
-	       proto_table[(disc_resp[15] & 0xe) >> 1],
-	       proto_table[(disc_resp[14] & 0xe) >> 1]);
-
-	printf(" Programmed MIN-MAX linkrate: %s - %s\n",
-	       phy_link_rate[(disc_resp[40] & 0xF0)>>4],
-	       phy_link_rate[(disc_resp[41] & 0xF0)>>4]);
-
-	printf(" Hardware   MIN-MAX linkrate: %s - %s\n",
-	       phy_link_rate[(disc_resp[40] & 0x0F)],
-	       phy_link_rate[(disc_resp[41] & 0x0F)]);
-
-	printf(" %s phy\n", (disc_resp[43] & 0x80) ? "Virtual" : "Physical");
-	printf(" Partial pathway timeout value: %d microseconds\n",
-	       disc_resp[43] & 0x0F);
-
-	printf(" Connector type: %s\n", conn_type[disc_resp[45] & 0x7F]);
-	printf(" Connector element index: %d\n", disc_resp[46]);
-	printf(" Connector physical link: %d\n", disc_resp[47]);
-out:
-	return 0;
-}
-
-#define RPEL_REQ_SIZE  16
-#define RPEL_RESP_SIZE 32
-
-static unsigned char rpel_req[RPEL_REQ_SIZE] = { 0x40, 0x11, 0, };
-static unsigned char rpel_resp[RPEL_RESP_SIZE];
-
-static int report_phy_error_log(char *smp_portal_name, int phy_id)
-{
-	int res;
-
-	rpel_req[9] = phy_id;
-
-	res = do_smp_func(smp_portal_name, rpel_req, RPEL_REQ_SIZE,
-			  rpel_resp, RPEL_RESP_SIZE);
-	if (res != RPEL_RESP_SIZE) {
-		printf("%s: error reading error log for phy %d (%d)\n",
-		       prog, phy_id, res);
-		goto out;
-	}
-	MI_PRINTD(" Invalid DW count:", be32_to_cpu(rpel_resp[12]));
-	MI_PRINTD(" RD error count:", be32_to_cpu(rpel_resp[16]));
-	MI_PRINTD(" DW sync loss count:", be32_to_cpu(rpel_resp[20]));
-	MI_PRINTD(" Reset problem count:", be32_to_cpu(rpel_resp[24]));
-out:
-	return 0;
-}
-
-#define RRI_REQ_SIZE  16
-#define RRI_RESP_SIZE 44
-
-static unsigned char rri_req[RRI_REQ_SIZE] = { 0x40, 0x13, 0, };
-static unsigned char rri_resp[RRI_RESP_SIZE];
-
-static int show_routing_table(char *smp_portal_name, int phy_id,
-			      struct expander *ex)
-{
-	struct route_table_entry *rt;
-	int res, i, last_non_zero = -1;
-
-	if (!ex->phy_attr || ex->phy_attr[phy_id] != TABLE_ROUTING)
-		return 0;
-
-	rt = malloc(sizeof(struct route_table_entry)*ex->route_indexes);
-	if (!rt)
-		return 0;
-
-	rri_req[9] = phy_id;
-
-	for (i = 0; i < ex->route_indexes; i++) {
-		*(uint16_t *)(rri_req+6) = cpu_to_be16(i);
-		res = do_smp_func(smp_portal_name, rri_req, RRI_REQ_SIZE,
-				  rri_resp, RRI_RESP_SIZE);
-		if (res != RRI_RESP_SIZE) {
-			printf("Error getting phy %d route index %d (%d)\n",
-			       phy_id, i, res);
-			goto out;
-		}
-		if (rri_resp[2] != 0)
-			break;
-		if (be16_to_cpu(rri_resp[6]) != i) {
-			printf("Expander FW error for phy %d index %d\n",
-			       phy_id, i);
-			goto out;
-		}
-		rt[i].disabled = rri_resp[12] & 0x80 ? 1 : 0;
-		memcpy(rt[i].routed_sas_addr, rri_resp+16, SAS_ADDR_SIZE);
-		if (rt[i].routed_sas_addr[0])
-			last_non_zero = i;
-	}
-	printf(" Routing Table\n");
-	if (last_non_zero == -1)
-		printf("  Empty (all zero)\n");
-	else {
-		for (i = 0; i <= last_non_zero; i++)
-			printf("  %02d %8s %016llx\n",
-			       i, rt[i].disabled ? "disabled" : "enabled",
-			       SAS_ADDR(rt[i].routed_sas_addr));
-	}
-out:
-	free(rt);
-	return 0;
-}
-
-static int discover_expander(char *smp_portal_name, struct expander *ex)
-{
-	int i;
-
-	for (i = 0; i < ex->num_phys; i++) {
-		printf("\n");
-		discover_phy(smp_portal_name, i, ex);
-		report_phy_error_log(smp_portal_name, i);
-		show_routing_table(smp_portal_name, i, ex);
-	}
-
-	return 0;
-}
-
-static void print_info(void)
-{
-	printf("%s <smp portal file>\n", prog);
-	printf("\tWhere <smp portal file> is the binary attribute file of the"
-	       "\n\texpander device in sysfs.\n");
-}
-
-int main(int argc, char *argv[])
-{
-	prog = strrchr(argv[0], '/');
-	if (prog)
-		prog++;
-	else
-		prog = argv[0];
-
-	if (argc < 2) {
-		print_info();
-		return 0;
-	} else {
-		struct expander ex;
-
-		memset(&ex, 0, sizeof(ex));
-
-		mi_expander(argv[1], &ex);
-		rg_expander(argv[1], &ex);
-		discover_expander(argv[1], &ex);
-		if (ex.phy_attr)
-			free(ex.phy_attr);
-	}
-	return 0;
-}
 
 
-

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

#6 lore raw

PATCH 5/8 aic94xx: remove inline functions

In reply to Alexis Bruemmer

Remove various needless inline functions

---
 drivers/scsi/sas/sas_discover.c  |   23 ++++++++++++++++++++++-
 drivers/scsi/sas/sas_expander.c  |   22 +++++++++++-----------
 drivers/scsi/sas/sas_scsi_host.c |    6 +++---
 include/scsi/sas/sas_discover.h  |   22 ++--------------------
 4 files changed, 38 insertions(+), 35 deletions(-)
drivers/scsi/sas/sas_discover.c +22 -1
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_discover.c
===================================================================
@@ -36,6 +36,27 @@
 
 /* ---------- Basic task processing for discovery purposes ---------- */
 
+void sas_init_dev(struct domain_device *dev)
+{
+        INIT_LIST_HEAD(&dev->siblings);
+        INIT_LIST_HEAD(&dev->dev_list_node);
+        switch (dev->dev_type) {
+        case SAS_END_DEV:
+                break;
+        case EDGE_DEV:
+        case FANOUT_DEV:
+                INIT_LIST_HEAD(&dev->ex_dev.children);
+                break;
+        case SATA_DEV:
+        case SATA_PM:
+        case SATA_PM_PORT:
+                INIT_LIST_HEAD(&dev->sata_dev.children);
+                break;
+        default:
+                break;
+        }
+}
+
 static void sas_task_timedout(unsigned long _task)
 {
 	struct sas_task *task = (void *) _task;
@@ -300,7 +321,7 @@ static int sas_get_port_device(struct sa
 
 /* ---------- SATA ---------- */
 
-static inline void sas_get_ata_command_set(struct domain_device *dev)
+static void sas_get_ata_command_set(struct domain_device *dev)
 {
 	struct dev_to_host_fis *fis =
 		(struct dev_to_host_fis *) dev->frame_rcvd;
drivers/scsi/sas/sas_expander.c +11 -11
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_expander.c
===================================================================
@@ -289,7 +289,7 @@ out_err:
 
 #define MAX_EXPANDER_PHYS 128
 
-static inline void ex_assign_report_general(struct domain_device *dev,
+static void ex_assign_report_general(struct domain_device *dev,
 					    struct smp_resp *resp)
 {
 	struct report_general_resp *rg = &resp->rg;
@@ -354,7 +354,7 @@ out:
 	return res;
 }
 
-static inline void ex_assign_manuf_info(struct domain_device *dev, void
+static void ex_assign_manuf_info(struct domain_device *dev, void
 					*_mi_resp)
 {
 	u8 *mi_resp = _mi_resp;
@@ -453,7 +453,7 @@ static inline void sas_ex_disable_phy(st
 	phy->linkrate = PHY_DISABLED;
 }
 
-static inline void sas_ex_disable_port(struct domain_device *dev, u8 *sas_addr)
+static void sas_ex_disable_port(struct domain_device *dev, u8 *sas_addr)
 {
 	struct expander_device *ex = &dev->ex_dev;
 	int i;
@@ -470,7 +470,7 @@ static inline void sas_ex_disable_port(s
 	}
 }
 
-static inline int sas_dev_present_in_domain(struct sas_port *port,
+static int sas_dev_present_in_domain(struct sas_port *port,
 					    u8 *sas_addr)
 {
 	struct domain_device *dev;
@@ -487,7 +487,7 @@ static inline int sas_dev_present_in_dom
 #define RPS_REQ_SIZE  16
 #define RPS_RESP_SIZE 60
 
-static inline int sas_get_report_phy_sata(struct domain_device *dev,
+static int sas_get_report_phy_sata(struct domain_device *dev,
 					  int phy_id,
 					  struct smp_resp *rps_resp)
 {
@@ -507,7 +507,7 @@ static inline int sas_get_report_phy_sat
 	return 0;
 }
 
-static inline void sas_ex_get_linkrate(struct domain_device *parent,
+static void sas_ex_get_linkrate(struct domain_device *parent,
 				       struct domain_device *child,
 				       struct ex_phy *parent_phy)
 {
@@ -774,7 +774,7 @@ static int sas_ex_discover_dev(struct do
 	return res;
 }
 
-static inline int sas_find_sub_addr(struct domain_device *dev, u8 *sub_addr)
+static int sas_find_sub_addr(struct domain_device *dev, u8 *sub_addr)
 {
 	struct expander_device *ex = &dev->ex_dev;
 	int i;
@@ -915,7 +915,7 @@ static int sas_check_ex_subtractive_boun
 	return 0;
 }
 
-static inline void sas_print_parent_topology_bug(struct domain_device *child,
+static void sas_print_parent_topology_bug(struct domain_device *child,
 						 struct ex_phy *parent_phy,
 						 struct ex_phy *child_phy)
 {
@@ -945,7 +945,7 @@ static inline void sas_print_parent_topo
 		   ra_char[child_phy->routing_attr]);
 }
 
-static inline int sas_check_eeds(struct domain_device *child,
+static int sas_check_eeds(struct domain_device *child,
 				 struct ex_phy *parent_phy,
 				 struct ex_phy *child_phy)
 {
@@ -1173,7 +1173,7 @@ out:
 	return res;
 }
 
-static inline int sas_configure_phy(struct domain_device *dev, int phy_id,
+static int sas_configure_phy(struct domain_device *dev, int phy_id,
 				    u8 *sas_addr, int include)
 {
 	int index;
@@ -1590,7 +1590,7 @@ out:
 	return res;
 }
 
-static inline int sas_discover_new(struct domain_device *dev, int phy_id)
+static int sas_discover_new(struct domain_device *dev, int phy_id)
 {
 	struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id];
 	struct domain_device *child;
drivers/scsi/sas/sas_scsi_host.c +3 -3
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_scsi_host.c
===================================================================
@@ -123,7 +123,7 @@ static void sas_scsi_task_done(struct sa
 		sc->scsi_done(sc);
 }
 
-static inline enum task_attribute sas_scsi_get_task_attr(struct scsi_cmnd *cmd)
+static enum task_attribute sas_scsi_get_task_attr(struct scsi_cmnd *cmd)
 {
 	enum task_attribute ta = TASK_ATTR_SIMPLE;
 	if (cmd->request && blk_rq_tagged(cmd->request)) {
@@ -134,7 +134,7 @@ static inline enum task_attribute sas_sc
 	return ta;
 }
 
-static inline struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
+static struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
 					       struct domain_device *dev,
 					       unsigned long gfp_flags)
 {
@@ -167,7 +167,7 @@ static inline struct sas_task *sas_creat
 	return task;
 }
 
-static inline int sas_queue_up(struct sas_task *task)
+static int sas_queue_up(struct sas_task *task)
 {
 	struct sas_ha_struct *sas_ha = task->dev->port->ha;
 	struct scsi_core *core = &sas_ha->core;
include/scsi/sas/sas_discover.h +2 -20
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_discover.h
===================================================================
@@ -122,26 +122,6 @@ struct domain_device {
 	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
 
 
-static inline void sas_init_dev(struct domain_device *dev)
-{
-	INIT_LIST_HEAD(&dev->siblings);
-	INIT_LIST_HEAD(&dev->dev_list_node);
-	switch (dev->dev_type) {
-	case SAS_END_DEV:
-		break;
-	case EDGE_DEV:
-	case FANOUT_DEV:
-		INIT_LIST_HEAD(&dev->ex_dev.children);
-		break;
-	case SATA_DEV:
-	case SATA_PM:
-	case SATA_PM_PORT:
-		INIT_LIST_HEAD(&dev->sata_dev.children);
-		break;
-	default:
-		break;
-	}
-}
 
 void sas_init_disc(struct sas_discovery *disc, struct sas_port *port);
 int  sas_discover_event(struct sas_port *sas_port, enum discover_event ev);
@@ -153,4 +133,6 @@ void sas_unregister_dev(struct domain_de
 
 void sas_unregister_devices(struct sas_ha_struct *sas_ha);
 
+void sas_init_dev(struct domain_device *dev);
+
 #endif /* _SAS_DISCOVER_H_ */
#7 lore raw

PATCH 6/8 aic94xx: move list_each_entry_reverse_safe from sas_discover.h to list.h

In reply to Alexis Bruemmer

Move list_each_entry_reverse_safe from sas_discover.h to the more appropriate file list.h

---
 include/linux/list.h            |    6 ++++++
 include/scsi/sas/sas_discover.h |    7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)
include/scsi/sas/sas_discover.h +0 -7
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_discover.h
===================================================================
@@ -115,13 +115,6 @@ struct domain_device {
 	void *lldd_dev;
 };
 
-#define list_for_each_entry_reverse_safe(pos, n, head, member)		\
-	for (pos = list_entry((head)->prev, typeof(*pos), member),	\
-		n = list_entry(pos->member.prev, typeof(*pos), member);	\
-	     &pos->member != (head); 					\
-	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
-
-
 
 void sas_init_disc(struct sas_discovery *disc, struct sas_port *port);
 int  sas_discover_event(struct sas_port *sas_port, enum discover_event ev);
include/linux/list.h +6 -0
Index: aic94xx-sas-2.6-patched/include/linux/list.h
===================================================================
@@ -542,6 +542,12 @@ static inline void list_splice_init(stru
 		prefetch(rcu_dereference((pos))->next), (pos) != (head); \
         	(pos) = (pos)->next)
 
+#define list_for_each_entry_reverse_safe(pos, n, head, member)          \
+	for (pos = list_entry((head)->prev, typeof(*pos), member),      \
+		n = list_entry(pos->member.prev, typeof(*pos), member); \
+		&pos->member != (head);                                    \
+		pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is
#8 lore raw

Re: [PATCH 6/8] aic94xx: move list_each_entry_reverse_safe from sas_discover.h to list.h

Quoted 5 lines · --- Alexis Bruemmer

Move list_each_entry_reverse_safe from sas_discover.h to the more appropriate file list.h

This isn't used anymore and will cause a bug in certain circumstances as is evident from the rest of the code.

Quoted 48 lines
---
 include/linux/list.h            |    6 ++++++
 include/scsi/sas/sas_discover.h |    7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)

Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_discover.h
===================================================================

include/scsi/sas/sas_discover.h +0 -7
@@ -115,13 +115,6 @@ struct domain_device {
 	void *lldd_dev;
 };
 
-#define list_for_each_entry_reverse_safe(pos, n, head, member)		\
-	for (pos = list_entry((head)->prev, typeof(*pos), member),	\
-		n = list_entry(pos->member.prev, typeof(*pos), member);	\
-	     &pos->member != (head); 					\
-	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
-
-
 
 void sas_init_disc(struct sas_discovery *disc, struct sas_port *port);
 int  sas_discover_event(struct sas_port *sas_port, enum discover_event ev);

Index: aic94xx-sas-2.6-patched/include/linux/list.h
===================================================================

include/linux/list.h +6 -1
@@ -542,6 +542,12 @@ static inline void list_splice_init(stru
 		prefetch(rcu_dereference((pos))->next), (pos) != (head); \
         	(pos) = (pos)->next)
 
+#define list_for_each_entry_reverse_safe(pos, n, head, member)          \
+	for (pos = list_entry((head)->prev, typeof(*pos), member),      \
+		n = list_entry(pos->member.prev, typeof(*pos), member); \
+		&pos->member != (head);                                    \
+		pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is
 
 
-

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

#9 lore raw

Re: [PATCH 6/8] aic94xx: move list_each_entry_reverse_safe from sas_discover.h to list.h

In reply to Alexis Bruemmer

Oh, BTW, the kernel already has that macro but the last two words are swapped. It is called:

list_for_each_entry_safe_reverse()

Your lk-2.6 base is too old.

Quoted 53 lines · --- Alexis Bruemmer

Move list_each_entry_reverse_safe from sas_discover.h to the more appropriate file list.h

---
 include/linux/list.h            |    6 ++++++
 include/scsi/sas/sas_discover.h |    7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)

Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_discover.h
===================================================================

include/scsi/sas/sas_discover.h +0 -7
@@ -115,13 +115,6 @@ struct domain_device {
 	void *lldd_dev;
 };
 
-#define list_for_each_entry_reverse_safe(pos, n, head, member)		\
-	for (pos = list_entry((head)->prev, typeof(*pos), member),	\
-		n = list_entry(pos->member.prev, typeof(*pos), member);	\
-	     &pos->member != (head); 					\
-	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
-
-
 
 void sas_init_disc(struct sas_discovery *disc, struct sas_port *port);
 int  sas_discover_event(struct sas_port *sas_port, enum discover_event ev);

Index: aic94xx-sas-2.6-patched/include/linux/list.h
===================================================================

include/linux/list.h +6 -1
@@ -542,6 +542,12 @@ static inline void list_splice_init(stru
 		prefetch(rcu_dereference((pos))->next), (pos) != (head); \
         	(pos) = (pos)->next)
 
+#define list_for_each_entry_reverse_safe(pos, n, head, member)          \
+	for (pos = list_entry((head)->prev, typeof(*pos), member),      \
+		n = list_entry(pos->member.prev, typeof(*pos), member); \
+		&pos->member != (head);                                    \
+		pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is
 
 
-

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

#10 lore raw

PATCH 7/8 aic94xx: remove queue implementation comment

In reply to Alexis Bruemmer

Remove the long queue implementation comment from sas_event.c that is no longer valid

---
 drivers/scsi/sas/sas_event.c |   40 ----------------------------------------
 1 files changed, 40 deletions(-)
drivers/scsi/sas/sas_event.c +0 -40
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_event.c
===================================================================
@@ -22,46 +22,6 @@
  *
  */
 
-/**
- * Implementation Of Priority Queue Without Duplication
- * Luben Tuikov 2005/07/11
- *
- * The SAS class implements priority queue without duplication for
- * handling ha/port/phy/discover events.  That is, we want to process
- * the last N unique/non-duplicating events, in the order they arrived.
- *
- * The requirement is that insertion is O(1), and ordered removal is O(1).
- *
- * Suppose events are identified by integers.  Then what is required
- * is that for a given sequence of any random integers R, to find a
- * sorted sequence E, where
- *     a) |E| <= |R|.  If the number of types of events is bounded,
- *        then E is also bounded by that number, from b).
- *     b) For all i and k, E[i] != E[k], except when i == k,
- *        this gives us uniqueness/non duplication.
- *     c) For all i < k, Order(E[i]) < Order(E[k]), this gives us
- *        ordering.
- *     d) If T(R) = E, then O(T) <= |R|, this ensures that insertion
- *        is O(1), and ordered removal is O(1) trivially, since we
- *        remove at the head of E.
- *
- * Example:
- * If R = {4, 5, 1, 2, 5, 3, 3, 4, 4, 3, 1}, then
- *    E = {2, 5, 4, 3, 1}.
- *
- * The algorithm, T, makes use of an array of list elements, indexed
- * by event type, and an event list head which is a linked list of the
- * elements of the array.  When the next event arrives, we index the
- * array by the event, and add that event to the tail of the event
- * list head, deleting it from its previous list position (if it had
- * one).
- *
- * Clearly insertion is O(1).
- *
- * E is given by the elements of the event list, traversed from head
- * to tail.
- */
-
 #include <scsi/scsi_host.h>
 #include "sas_internal.h"
 #include "sas_dump.h"
#11 lore raw

Re: [PATCH 7/8] aic94xx: remove queue implementation comment

Quoted 5 lines · --- Alexis Bruemmer

Remove the long queue implementation comment from sas_event.c that is no longer valid

Are you only removing this comment and leaving the rest of the file as is, as the patch indicates?

Or has the rest of the file's contents changed? Where is it?

Quoted 63 lines
---
 drivers/scsi/sas/sas_event.c |   40 ----------------------------------------
 1 files changed, 40 deletions(-)

Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_event.c
===================================================================

drivers/scsi/sas/sas_event.c +0 -41
@@ -22,46 +22,6 @@
  *
  */
 
-/**
- * Implementation Of Priority Queue Without Duplication
- * Luben Tuikov 2005/07/11
- *
- * The SAS class implements priority queue without duplication for
- * handling ha/port/phy/discover events.  That is, we want to process
- * the last N unique/non-duplicating events, in the order they arrived.
- *
- * The requirement is that insertion is O(1), and ordered removal is O(1).
- *
- * Suppose events are identified by integers.  Then what is required
- * is that for a given sequence of any random integers R, to find a
- * sorted sequence E, where
- *     a) |E| <= |R|.  If the number of types of events is bounded,
- *        then E is also bounded by that number, from b).
- *     b) For all i and k, E[i] != E[k], except when i == k,
- *        this gives us uniqueness/non duplication.
- *     c) For all i < k, Order(E[i]) < Order(E[k]), this gives us
- *        ordering.
- *     d) If T(R) = E, then O(T) <= |R|, this ensures that insertion
- *        is O(1), and ordered removal is O(1) trivially, since we
- *        remove at the head of E.
- *
- * Example:
- * If R = {4, 5, 1, 2, 5, 3, 3, 4, 4, 3, 1}, then
- *    E = {2, 5, 4, 3, 1}.
- *
- * The algorithm, T, makes use of an array of list elements, indexed
- * by event type, and an event list head which is a linked list of the
- * elements of the array.  When the next event arrives, we index the
- * array by the event, and add that event to the tail of the event
- * list head, deleting it from its previous list position (if it had
- * one).
- *
- * Clearly insertion is O(1).
- *
- * E is given by the elements of the event list, traversed from head
- * to tail.
- */
-
 #include <scsi/scsi_host.h>
 #include "sas_internal.h"
 #include "sas_dump.h"
 
 
 
-

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

#12 lore raw

PATCH 8/8 aic94xx: use bitops for testing, setting and clearing bits

In reply to Alexis Bruemmer

Use bitops for testing, setting and clearing bits

---
 drivers/scsi/sas/sas_internal.h |   16 +++++++++-------
 include/scsi/sas/sas_class.h    |    8 ++++----
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/scsi/sas/sas_internal.h +9 -7
Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_internal.h
===================================================================
@@ -27,6 +27,7 @@
 #define _SAS_INTERNAL_H_
 
 #include <scsi/sas/sas_class.h>
+#include <linux/bitops.h>
 #include <scsi/scsi_host.h>
 
 #define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__)
@@ -70,28 +71,29 @@ void sas_notify_lldd_dev_gone(struct dom
 
 void sas_hae_reset(void *);
 
-static inline void sas_queue_event(int event, spinlock_t *lock, u32 *pending,
-				   struct work_struct *work,
-				   struct Scsi_Host *shost)
+static inline void sas_queue_event(int event, spinlock_t *lock, unsigned
+				   long *pending, struct work_struct
+				   *work, struct Scsi_Host *shost)
 {
 	unsigned long flags;
 
 	spin_lock_irqsave(lock, flags);
-	if (*pending & (1 << event)) {
+	if (test_bit(event, pending)) {
 		spin_unlock_irqrestore(lock, flags);
 		return;
 	}
-	*pending |= (1 << event);
+	__set_bit(event, pending);
 	spin_unlock_irqrestore(lock, flags);
 	scsi_queue_work(shost, work);
 }
 
-static inline void sas_begin_event(int event, spinlock_t *lock, u32 *pending)
+static inline void sas_begin_event(int event, spinlock_t *lock, unsigned
+				   long *pending)
 {
 	unsigned long flags;
 
 	spin_lock_irqsave(lock, flags);
-	*pending &= ~(1 << event);
+	__clear_bit(event, pending);
 	spin_unlock_irqrestore(lock, flags);
 }
 
include/scsi/sas/sas_class.h +4 -4
Index: aic94xx-sas-2.6-patched/include/scsi/sas/sas_class.h
===================================================================
@@ -94,8 +94,8 @@ struct asd_sas_phy {
 	struct work_struct   port_events[PORT_NUM_EVENTS];
 	struct work_struct   phy_events[PHY_NUM_EVENTS];
 
-	u32 port_events_pending;
-	u32 phy_events_pending;
+	unsigned long port_events_pending;
+	unsigned long phy_events_pending;
 
 	int error;
 
@@ -138,7 +138,7 @@ struct sas_port;
 struct sas_discovery {
 	spinlock_t disc_event_lock;
 	struct work_struct disc_work[DISC_NUM_EVENTS];
-	u32    pending;
+	unsigned long    pending;
 	u8     fanout_sas_addr[8];
 	u8     eeds_a[8];
 	u8     eeds_b[8];
@@ -199,7 +199,7 @@ struct sas_ha_struct {
 /* private: */
 	spinlock_t       event_lock;
 	struct work_struct ha_events[HA_NUM_EVENTS];
-	u32		 pending;
+	unsigned long	 pending;
 
 	struct scsi_core core;
 
#13 lore raw

Re: [PATCH 8/8] aic94xx: use bitops for testing, setting and clearing bits

Am Dienstag, 9. Mai 2006 23:42 schrieben Sie:

Quoted 28 lines

Use bitops for testing, setting and clearing bits

---
drivers/scsi/sas/sas_internal.h | 16 +++++++++-------
include/scsi/sas/sas_class.h | 8 ++++----

2 files changed, 13 insertions(+), 11 deletions(-)

Index: aic94xx-sas-2.6-patched/drivers/scsi/sas/sas_internal.h
===================================================================

drivers/scsi/sas/sas_internal.h +1 -0
@@ -27,6 +27,7 @@
 #define _SAS_INTERNAL_H_
 
 #include <scsi/sas/sas_class.h>
+#include <linux/bitops.h>
 #include <scsi/scsi_host.h>
 
 #define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ##

__VA_ARGS__) @@ -70,28 +71,29 @@ void sas_notify_lldd_dev_gone(struct dom

void sas_hae_reset(void *);

-static inline void sas_queue_event(int event, spinlock_t *lock, u32 *pending,

drivers/scsi/sas/sas_internal.h void sas_notify_lldd_dev_gone(struct dom · line 76

Quoted 5 lines
drivers/scsi/sas/sas_internal.h +3 -2
-				   struct work_struct *work, 
-				   struct Scsi_Host *shost)
+static inline void sas_queue_event(int event, spinlock_t *lock, unsigned
+				   long *pending, struct work_struct
+				   *work, struct Scsi_Host *shost)

Line break in the middle of declarations? I would prefer if you would not do that.

Eike

#14 lore raw
In reply to Alexis Bruemmer
Quoted 10 lines · --- Alexis Bruemmer

These patches were created in response to the comments from this earlier email:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114624643916659&w=2

First off, thank you Christoph for your comments. I am working to address them, starting with the ones that are easiest to implement. Follows is a set of patches that address the following concerns:

1) Move the sas readme to the Documents dir-- this still needs to be written so that it 'matches reality', but I want to merge the sas*.h

Which "reality" is this? Christoph's?

Anyway, the SAS Stack has seen quite a lot of updates, more than I can list here. Some of them are
- Error Recovery,
- device lifetimes wholly dependent on kobject references,
- SAS transport layer retries,
- SAS 2.0 (as much as is available),
- SAS domain consistency (pathways, port augmentation, route tables of augmented ports, etc, etc),
- SAS versioning: the interconnect declares what SAS version it supports and this is what the SAS Stack drives.
- etc, etc, etc.

The aic94xx driver has also seen changes:
- versioning,
- NCQ error handling,
- bugfixes on recovery, TMFs, etc.

A SAT Layer (SATL) has also been added to the SAS Stack. It conforms to the SAT spec, and uses the SAS task infrastructure. SATL supports the interconnect SATA features: the interconnect declares the SATA features it supports, SATL drives them and so configures SATA devices found on the domain. NCQ is naturally supported. Other interesting features are things like MODE SELECT and READ/WRITE LONG 10/16. 5 VPD pages. Error recovery (NCQ as well). All size-version of commands, i.e. 6/10/12/16 as are defined in the appropriate specs.

This is more or less an enterprise effort.

The version from which Bottomley started is old. In contrast it did support hot-plugging as the announcement on lkml and lsml said. Now Bottomley is saying that "it [hotplug] still doesn't work".

I cannot imagine a customer wanting enterprise reliability, quality and support (as well as technical know-how), to just use the version you're pushing.

It just boggles my mind... seeing how much more complex storage is becoming.

This is why I asked "which reality" in the beginning of this message.

Good luck to everyone,
Luben

Quoted 21 lines

files to libsas.h and sas.h first
2) Remove the sas_common.c file
3) Remove the //depot SCM comments
4) Remove the expander_conf.c from the kernel tree
5) Remove various inline functions
6) Move list_each_entry_reverse_safe from sas_discover.h to list.h
7) Remove the long queue implementation comment
8) Use bitops for setting and clearing bits

These patches are just a start and I will continue to address these issues.

Regards,

Alexis

-
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

#15 lore raw
Quoted 5 lines · Luben Tuikov
Quoted 4 lines · --- Alexis Bruemmer

These patches were created in response to the comments from this earlier email:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114624643916659&w=2

Quoted 8 lines
Quoted 6 lines

First off, thank you Christoph for your comments. I am working to address them, starting with the ones that are easiest to implement. Follows is a set of patches that address the following concerns:

1) Move the sas readme to the Documents dir-- this still needs to be written so that it 'matches reality', but I want to merge the sas*.h

Which "reality" is this? Christoph's?

s/reality/the code in the tree/ if you prefer. That code is originally from you with lots of changes from James, Alexis, Mike and Jeff.

If you call documenting the interfaces actually implemented in the code "Christoph's reality", then yes it should match Christoph's reality.