18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 78c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 108c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 118c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 128c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 138c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 158c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 168c2ecf20Sopenharmony_ci * SOFTWARE. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#include <linux/string.h> 198c2ecf20Sopenharmony_ci#include <linux/device.h> 208c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h> 218c2ecf20Sopenharmony_ci#include "fnic.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic ssize_t fnic_show_state(struct device *dev, 248c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci struct fc_lport *lp = shost_priv(class_to_shost(dev)); 278c2ecf20Sopenharmony_ci struct fnic *fnic = lport_priv(lp); 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic ssize_t fnic_show_drv_version(struct device *dev, 338c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic ssize_t fnic_show_link_state(struct device *dev, 398c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci struct fc_lport *lp = shost_priv(class_to_shost(dev)); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up) 448c2ecf20Sopenharmony_ci ? "Link Up" : "Link Down"); 458c2ecf20Sopenharmony_ci} 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); 488c2ecf20Sopenharmony_cistatic DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL); 498c2ecf20Sopenharmony_cistatic DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct device_attribute *fnic_attrs[] = { 528c2ecf20Sopenharmony_ci &dev_attr_fnic_state, 538c2ecf20Sopenharmony_ci &dev_attr_drv_version, 548c2ecf20Sopenharmony_ci &dev_attr_link_state, 558c2ecf20Sopenharmony_ci NULL, 568c2ecf20Sopenharmony_ci}; 57