[SCSI] scsi_transport_sas: support link error attributes
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>
This commit is contained in:
committed by
James Bottomley
parent
d25cf1ced9
commit
c3ee74c4e9
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define SAS_HOST_ATTRS 0
|
#define SAS_HOST_ATTRS 0
|
||||||
#define SAS_PORT_ATTRS 11
|
#define SAS_PORT_ATTRS 15
|
||||||
#define SAS_RPORT_ATTRS 5
|
#define SAS_RPORT_ATTRS 5
|
||||||
|
|
||||||
struct sas_internal {
|
struct sas_internal {
|
||||||
@@ -257,6 +257,26 @@ show_sas_phy_##field(struct class_device *cdev, char *buf) \
|
|||||||
sas_phy_show_linkspeed(field) \
|
sas_phy_show_linkspeed(field) \
|
||||||
static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
|
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
|
static ssize_t
|
||||||
show_sas_device_type(struct class_device *cdev, char *buf)
|
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(minimum_linkrate);
|
||||||
sas_phy_linkspeed_attr(maximum_linkrate_hw);
|
sas_phy_linkspeed_attr(maximum_linkrate_hw);
|
||||||
sas_phy_linkspeed_attr(maximum_linkrate);
|
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,
|
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(minimum_linkrate);
|
||||||
SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
|
SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
|
||||||
SETUP_PORT_ATTRIBUTE(maximum_linkrate);
|
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;
|
i->phy_attrs[count] = NULL;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@@ -41,20 +41,28 @@ struct sas_identify {
|
|||||||
u8 phy_identifier;
|
u8 phy_identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The functions by which the transport class and the driver communicate */
|
|
||||||
struct sas_function_template {
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sas_phy {
|
struct sas_phy {
|
||||||
struct device dev;
|
struct device dev;
|
||||||
int number;
|
int number;
|
||||||
|
|
||||||
|
/* phy identification */
|
||||||
struct sas_identify identify;
|
struct sas_identify identify;
|
||||||
|
|
||||||
|
/* phy attributes */
|
||||||
enum sas_linkrate negotiated_linkrate;
|
enum sas_linkrate negotiated_linkrate;
|
||||||
enum sas_linkrate minimum_linkrate_hw;
|
enum sas_linkrate minimum_linkrate_hw;
|
||||||
enum sas_linkrate minimum_linkrate;
|
enum sas_linkrate minimum_linkrate;
|
||||||
enum sas_linkrate maximum_linkrate_hw;
|
enum sas_linkrate maximum_linkrate_hw;
|
||||||
enum sas_linkrate maximum_linkrate;
|
enum sas_linkrate maximum_linkrate;
|
||||||
u8 port_identifier;
|
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;
|
struct sas_rphy *rphy;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,6 +87,13 @@ struct sas_rphy {
|
|||||||
#define rphy_to_shost(rphy) \
|
#define rphy_to_shost(rphy) \
|
||||||
dev_to_shost((rphy)->dev.parent)
|
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 void sas_remove_host(struct Scsi_Host *);
|
||||||
|
|
||||||
extern struct sas_phy *sas_phy_alloc(struct device *, int);
|
extern struct sas_phy *sas_phy_alloc(struct device *, int);
|
||||||
|
Reference in New Issue
Block a user