1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3*4882a593Smuzhiyun * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * This program is free software; you may redistribute it and/or modify
6*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by
7*4882a593Smuzhiyun * the Free Software Foundation; version 2 of the License.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12*4882a593Smuzhiyun * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13*4882a593Smuzhiyun * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14*4882a593Smuzhiyun * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15*4882a593Smuzhiyun * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16*4882a593Smuzhiyun * SOFTWARE.
17*4882a593Smuzhiyun */
18*4882a593Smuzhiyun #include <linux/string.h>
19*4882a593Smuzhiyun #include <linux/device.h>
20*4882a593Smuzhiyun #include <scsi/scsi_host.h>
21*4882a593Smuzhiyun #include "fnic.h"
22*4882a593Smuzhiyun
fnic_show_state(struct device * dev,struct device_attribute * attr,char * buf)23*4882a593Smuzhiyun static ssize_t fnic_show_state(struct device *dev,
24*4882a593Smuzhiyun struct device_attribute *attr, char *buf)
25*4882a593Smuzhiyun {
26*4882a593Smuzhiyun struct fc_lport *lp = shost_priv(class_to_shost(dev));
27*4882a593Smuzhiyun struct fnic *fnic = lport_priv(lp);
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
30*4882a593Smuzhiyun }
31*4882a593Smuzhiyun
fnic_show_drv_version(struct device * dev,struct device_attribute * attr,char * buf)32*4882a593Smuzhiyun static ssize_t fnic_show_drv_version(struct device *dev,
33*4882a593Smuzhiyun struct device_attribute *attr, char *buf)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun
fnic_show_link_state(struct device * dev,struct device_attribute * attr,char * buf)38*4882a593Smuzhiyun static ssize_t fnic_show_link_state(struct device *dev,
39*4882a593Smuzhiyun struct device_attribute *attr, char *buf)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun struct fc_lport *lp = shost_priv(class_to_shost(dev));
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
44*4882a593Smuzhiyun ? "Link Up" : "Link Down");
45*4882a593Smuzhiyun }
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
48*4882a593Smuzhiyun static DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL);
49*4882a593Smuzhiyun static DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL);
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun struct device_attribute *fnic_attrs[] = {
52*4882a593Smuzhiyun &dev_attr_fnic_state,
53*4882a593Smuzhiyun &dev_attr_drv_version,
54*4882a593Smuzhiyun &dev_attr_link_state,
55*4882a593Smuzhiyun NULL,
56*4882a593Smuzhiyun };
57