/*
* Copyright (C) 2005-2006 Dell Inc.
* Released under GPL v2.
*
* Serial Attached SCSI (SAS) transport class.
*
* The SAS transport class contains common code to deal with SAS HBAs,
* an aproximated representation of SAS topologies in the driver model,
* and various sysfs attributes to expose these topologies and managment
* interfaces to userspace.
*
* In addition to the basic SCSI core objects this transport class
* introduces two additional intermediate objects: The SAS PHY
* as represented by struct sas_phy defines an "outgoing" PHY on
* a SAS HBA or Expander, and the SAS remote PHY represented by
* struct sas_rphy defines an "incoming" PHY on a SAS Expander or
* end device. Note that this is purely a software concept, the
* underlying hardware for a PHY and a remote PHY is the exactly
* the same.
*
* There is no concept of a SAS port in this code, users can see
* what PHYs form a wide port based on the port_identifier attribute,
* which is the same for all PHYs in a port.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_sas.h>
#include "scsi_sas_internal.h"
struct sas_host_attrs {
struct list_head rphy_list;
struct mutex lock;
u32 next_target_id;
u32 next_expander_id;
};
#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
/*
* Hack to allow attributes of the same name in different objects.
*/
#define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_##_prefix##_##_name = \
__ATTR(_name,_mode,_show,_store)
/*
* Pretty printing helpers
*/
#define sas_bitfield_name_match(title, table) \
static ssize_t \
get_sas_##title##_names(u32 table_key, char *buf) \
{ \
char *prefix = ""; \
ssize_t len = 0; \
int i; \
\
for (i = 0; i < ARRAY_SIZE(table); i++) { \
if (table[i].value & table_key) { \
len += sprintf(buf + len, "%s%s", \
prefix, table[i].name); \
prefix = ", "; \
} \
} \
len += sprintf(buf + len, "\n"); \
return len; \