| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* Copyright 2008 Cisco Systems, Inc. All rights reserved. |
| 4 |
* Copyright 2007 Nuova Systems, Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
#include <linux/string.h> |
| 7 |
#include <linux/device.h> |
| 8 |
#include <scsi/scsi_host.h> |
| 9 |
#include "fnic.h" |
| 10 |
|
| 11 |
static ssize_t fnic_show_state(struct device *dev, |
| 12 |
struct device_attribute *attr, char *buf) |
| 13 |
{ |
| 14 |
struct fnic *fnic = |
| 15 |
*((struct fnic **) shost_priv(class_to_shost(dev))); |
| 16 |
|
| 17 |
return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]); |
| 18 |
} |
| 19 |
|
| 20 |
static ssize_t fnic_show_drv_version(struct device *dev, |
| 21 |
struct device_attribute *attr, char *buf) |
| 22 |
{ |
| 23 |
return sysfs_emit(buf, "%s\n", DRV_VERSION); |
| 24 |
} |
| 25 |
|
| 26 |
static ssize_t fnic_show_link_state(struct device *dev, |
| 27 |
struct device_attribute *attr, char *buf) |
| 28 |
{ |
| 29 |
struct fnic *fnic = |
| 30 |
*((struct fnic **) shost_priv(class_to_shost(dev))); |
| 31 |
|
| 32 |
return sysfs_emit(buf, "%s\n", |
| 33 |
((fnic->iport.state != FNIC_IPORT_STATE_INIT) && |
| 34 |
(fnic->iport.state != FNIC_IPORT_STATE_LINK_WAIT)) ? |
| 35 |
"Link Up" : "Link Down"); |
| 36 |
} |
| 37 |
|
| 38 |
static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); |
| 39 |
static DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL); |
| 40 |
static DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL); |
| 41 |
|
| 42 |
static struct attribute *fnic_host_attrs[] = { |
| 43 |
&dev_attr_fnic_state.attr, |
| 44 |
&dev_attr_drv_version.attr, |
| 45 |
&dev_attr_link_state.attr, |
| 46 |
NULL, |
| 47 |
}; |
| 48 |
|
| 49 |
static const struct attribute_group fnic_host_attr_group = { |
| 50 |
.attrs = fnic_host_attrs |
| 51 |
}; |
| 52 |
|
| 53 |
const struct attribute_group *fnic_host_groups[] = { |
| 54 |
&fnic_host_attr_group, |
| 55 |
NULL |
| 56 |
}; |