162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 462306a36Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#include <linux/string.h> 762306a36Sopenharmony_ci#include <linux/device.h> 862306a36Sopenharmony_ci#include <scsi/scsi_host.h> 962306a36Sopenharmony_ci#include "fnic.h" 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistatic ssize_t fnic_show_state(struct device *dev, 1262306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 1362306a36Sopenharmony_ci{ 1462306a36Sopenharmony_ci struct fc_lport *lp = shost_priv(class_to_shost(dev)); 1562306a36Sopenharmony_ci struct fnic *fnic = lport_priv(lp); 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]); 1862306a36Sopenharmony_ci} 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistatic ssize_t fnic_show_drv_version(struct device *dev, 2162306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 2262306a36Sopenharmony_ci{ 2362306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); 2462306a36Sopenharmony_ci} 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistatic ssize_t fnic_show_link_state(struct device *dev, 2762306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci struct fc_lport *lp = shost_priv(class_to_shost(dev)); 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up) 3262306a36Sopenharmony_ci ? "Link Up" : "Link Down"); 3362306a36Sopenharmony_ci} 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_cistatic DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); 3662306a36Sopenharmony_cistatic DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL); 3762306a36Sopenharmony_cistatic DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL); 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic struct attribute *fnic_host_attrs[] = { 4062306a36Sopenharmony_ci &dev_attr_fnic_state.attr, 4162306a36Sopenharmony_ci &dev_attr_drv_version.attr, 4262306a36Sopenharmony_ci &dev_attr_link_state.attr, 4362306a36Sopenharmony_ci NULL, 4462306a36Sopenharmony_ci}; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistatic const struct attribute_group fnic_host_attr_group = { 4762306a36Sopenharmony_ci .attrs = fnic_host_attrs 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ciconst struct attribute_group *fnic_host_groups[] = { 5162306a36Sopenharmony_ci &fnic_host_attr_group, 5262306a36Sopenharmony_ci NULL 5362306a36Sopenharmony_ci}; 54