2022-06-07 16:11:25 +02:00
// SPDX-License-Identifier: GPL-2.0-only
// Copyright 2014 Cisco Systems, Inc. All rights reserved.
2015-05-29 01:04:01 -07:00
# include <linux/string.h>
# include <linux/device.h>
# include "snic.h"
static ssize_t
snic_show_sym_name ( struct device * dev ,
struct device_attribute * attr ,
char * buf )
{
struct snic * snic = shost_priv ( class_to_shost ( dev ) ) ;
2024-03-19 14:31:19 +08:00
return sysfs_emit ( buf , " %s \n " , snic - > name ) ;
2015-05-29 01:04:01 -07:00
}
static ssize_t
snic_show_state ( struct device * dev ,
struct device_attribute * attr ,
char * buf )
{
struct snic * snic = shost_priv ( class_to_shost ( dev ) ) ;
2024-03-19 14:31:19 +08:00
return sysfs_emit ( buf , " %s \n " , snic_state_str [ snic_get_state ( snic ) ] ) ;
2015-05-29 01:04:01 -07:00
}
static ssize_t
snic_show_drv_version ( struct device * dev ,
struct device_attribute * attr ,
char * buf )
{
2024-03-19 14:31:19 +08:00
return sysfs_emit ( buf , " %s \n " , SNIC_DRV_VERSION ) ;
2015-05-29 01:04:01 -07:00
}
static ssize_t
snic_show_link_state ( struct device * dev ,
struct device_attribute * attr ,
char * buf )
{
struct snic * snic = shost_priv ( class_to_shost ( dev ) ) ;
if ( snic - > config . xpt_type = = SNIC_DAS )
snic - > link_status = svnic_dev_link_status ( snic - > vdev ) ;
2024-03-19 14:31:19 +08:00
return sysfs_emit ( buf , " %s \n " ,
( snic - > link_status ) ? " Link Up " : " Link Down " ) ;
2015-05-29 01:04:01 -07:00
}
static DEVICE_ATTR ( snic_sym_name , S_IRUGO , snic_show_sym_name , NULL ) ;
static DEVICE_ATTR ( snic_state , S_IRUGO , snic_show_state , NULL ) ;
static DEVICE_ATTR ( drv_version , S_IRUGO , snic_show_drv_version , NULL ) ;
static DEVICE_ATTR ( link_state , S_IRUGO , snic_show_link_state , NULL ) ;
2021-10-12 16:35:55 -07:00
static struct attribute * snic_host_attrs [ ] = {
& dev_attr_snic_sym_name . attr ,
& dev_attr_snic_state . attr ,
& dev_attr_drv_version . attr ,
& dev_attr_link_state . attr ,
2015-05-29 01:04:01 -07:00
NULL ,
} ;
2021-10-12 16:35:55 -07:00
static const struct attribute_group snic_host_attr_group = {
. attrs = snic_host_attrs
} ;
const struct attribute_group * snic_host_groups [ ] = {
& snic_host_attr_group ,
NULL
} ;