#include "core_priv.h"
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <rdma/ib_mad.h>
#include <rdma/ib_pma.h>
#include <rdma/ib_cache.h>
#include <rdma/rdma_counter.h>
#include <rdma/ib_sysfs.h>
struct port_table_attribute { … };
struct gid_attr_group { … };
struct ib_port { … };
struct hw_stats_device_attribute { … };
struct hw_stats_port_attribute { … };
struct hw_stats_device_data { … };
struct hw_stats_port_data { … };
static ssize_t port_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{ … }
static ssize_t port_attr_store(struct kobject *kobj,
struct attribute *attr,
const char *buf, size_t count)
{ … }
struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
u32 *port_num)
{ … }
EXPORT_SYMBOL(…);
static const struct sysfs_ops port_sysfs_ops = …;
static ssize_t hw_stat_device_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t hw_stat_device_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t hw_stat_port_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr, char *buf)
{ … }
static ssize_t hw_stat_port_store(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t gid_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{ … }
static const struct sysfs_ops gid_attr_sysfs_ops = …;
static ssize_t state_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t lid_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t lid_mask_count_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t sm_lid_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t sm_sl_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t cap_mask_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t rate_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static const char *phys_state_to_str(enum ib_port_phys_state phys_state)
{ … }
static ssize_t phys_state_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static ssize_t link_layer_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *unused, char *buf)
{ … }
static IB_PORT_ATTR_RO(state);
static IB_PORT_ATTR_RO(lid);
static IB_PORT_ATTR_RO(lid_mask_count);
static IB_PORT_ATTR_RO(sm_lid);
static IB_PORT_ATTR_RO(sm_sl);
static IB_PORT_ATTR_RO(cap_mask);
static IB_PORT_ATTR_RO(rate);
static IB_PORT_ATTR_RO(phys_state);
static IB_PORT_ATTR_RO(link_layer);
static struct attribute *port_default_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static ssize_t print_ndev(const struct ib_gid_attr *gid_attr, char *buf)
{ … }
static ssize_t print_gid_type(const struct ib_gid_attr *gid_attr, char *buf)
{ … }
static ssize_t _show_port_gid_attr(
struct ib_device *ibdev, u32 port_num, struct ib_port_attribute *attr,
char *buf,
ssize_t (*print)(const struct ib_gid_attr *gid_attr, char *buf))
{ … }
static ssize_t show_port_gid(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr, char *buf)
{ … }
static ssize_t show_port_gid_attr_ndev(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr,
char *buf)
{ … }
static ssize_t show_port_gid_attr_gid_type(struct ib_device *ibdev,
u32 port_num,
struct ib_port_attribute *attr,
char *buf)
{ … }
static ssize_t show_port_pkey(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr, char *buf)
{ … }
#define PORT_PMA_ATTR(_name, _counter, _width, _offset) …
#define PORT_PMA_ATTR_EXT(_name, _width, _offset) …
static int get_perf_mad(struct ib_device *dev, int port_num, __be16 attr,
void *data, int offset, size_t size)
{ … }
static ssize_t show_pma_counter(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *attr, char *buf)
{ … }
static PORT_PMA_ATTR(symbol_error , 0, 16, 32);
static PORT_PMA_ATTR(link_error_recovery , 1, 8, 48);
static PORT_PMA_ATTR(link_downed , 2, 8, 56);
static PORT_PMA_ATTR(port_rcv_errors , 3, 16, 64);
static PORT_PMA_ATTR(port_rcv_remote_physical_errors, 4, 16, 80);
static PORT_PMA_ATTR(port_rcv_switch_relay_errors , 5, 16, 96);
static PORT_PMA_ATTR(port_xmit_discards , 6, 16, 112);
static PORT_PMA_ATTR(port_xmit_constraint_errors , 7, 8, 128);
static PORT_PMA_ATTR(port_rcv_constraint_errors , 8, 8, 136);
static PORT_PMA_ATTR(local_link_integrity_errors , 9, 4, 152);
static PORT_PMA_ATTR(excessive_buffer_overrun_errors, 10, 4, 156);
static PORT_PMA_ATTR(VL15_dropped , 11, 16, 176);
static PORT_PMA_ATTR(port_xmit_data , 12, 32, 192);
static PORT_PMA_ATTR(port_rcv_data , 13, 32, 224);
static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256);
static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288);
static PORT_PMA_ATTR(port_xmit_wait , 0, 32, 320);
static PORT_PMA_ATTR_EXT(port_xmit_data , 64, 64);
static PORT_PMA_ATTR_EXT(port_rcv_data , 64, 128);
static PORT_PMA_ATTR_EXT(port_xmit_packets , 64, 192);
static PORT_PMA_ATTR_EXT(port_rcv_packets , 64, 256);
static PORT_PMA_ATTR_EXT(unicast_xmit_packets , 64, 320);
static PORT_PMA_ATTR_EXT(unicast_rcv_packets , 64, 384);
static PORT_PMA_ATTR_EXT(multicast_xmit_packets , 64, 448);
static PORT_PMA_ATTR_EXT(multicast_rcv_packets , 64, 512);
static struct attribute *pma_attrs[] = …;
static struct attribute *pma_attrs_ext[] = …;
static struct attribute *pma_attrs_noietf[] = …;
static const struct attribute_group pma_group = …;
static const struct attribute_group pma_group_ext = …;
static const struct attribute_group pma_group_noietf = …;
static void ib_port_release(struct kobject *kobj)
{ … }
static void ib_port_gid_attr_release(struct kobject *kobj)
{ … }
static struct kobj_type port_type = …;
static struct kobj_type gid_attr_type = …;
static const struct attribute_group *get_counter_table(struct ib_device *dev,
int port_num)
{ … }
static int update_hw_stats(struct ib_device *dev, struct rdma_hw_stats *stats,
u32 port_num, int index)
{ … }
static int print_hw_stat(struct ib_device *dev, int port_num,
struct rdma_hw_stats *stats, int index, char *buf)
{ … }
static ssize_t show_hw_stats(struct ib_device *ibdev,
struct rdma_hw_stats *stats, unsigned int index,
unsigned int port_num, char *buf)
{ … }
static ssize_t show_stats_lifespan(struct ib_device *ibdev,
struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num,
char *buf)
{ … }
static ssize_t set_stats_lifespan(struct ib_device *ibdev,
struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num,
const char *buf, size_t count)
{ … }
static struct hw_stats_device_data *
alloc_hw_stats_device(struct ib_device *ibdev)
{ … }
void ib_device_release_hw_stats(struct hw_stats_device_data *data)
{ … }
int ib_setup_device_attrs(struct ib_device *ibdev)
{ … }
static struct hw_stats_port_data *
alloc_hw_stats_port(struct ib_port *port, struct attribute_group *group)
{ … }
static int setup_hw_port_stats(struct ib_port *port,
struct attribute_group *group)
{ … }
struct rdma_hw_stats *ib_get_hw_stats_port(struct ib_device *ibdev,
u32 port_num)
{ … }
static int
alloc_port_table_group(const char *name, struct attribute_group *group,
struct port_table_attribute *attrs, size_t num,
ssize_t (*show)(struct ib_device *ibdev, u32 port_num,
struct ib_port_attribute *, char *buf))
{ … }
static int setup_gid_attrs(struct ib_port *port,
const struct ib_port_attr *attr)
{ … }
static void destroy_gid_attrs(struct ib_port *port)
{ … }
static struct ib_port *setup_port(struct ib_core_device *coredev, int port_num,
const struct ib_port_attr *attr)
{ … }
static void destroy_port(struct ib_core_device *coredev, struct ib_port *port)
{ … }
static const char *node_type_string(int node_type)
{ … }
static ssize_t node_type_show(struct device *device,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(node_type);
static ssize_t sys_image_guid_show(struct device *device,
struct device_attribute *dev_attr, char *buf)
{ … }
static DEVICE_ATTR_RO(sys_image_guid);
static ssize_t node_guid_show(struct device *device,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(node_guid);
static ssize_t node_desc_show(struct device *device,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t node_desc_store(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(node_desc);
static ssize_t fw_ver_show(struct device *device, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(fw_ver);
static struct attribute *ib_dev_attrs[] = …;
const struct attribute_group ib_dev_attr_group = …;
void ib_free_port_attrs(struct ib_core_device *coredev)
{ … }
int ib_setup_port_attrs(struct ib_core_device *coredev)
{ … }
int ib_port_register_client_groups(struct ib_device *ibdev, u32 port_num,
const struct attribute_group **groups)
{ … }
EXPORT_SYMBOL(…);
void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num,
const struct attribute_group **groups)
{ … }
EXPORT_SYMBOL(…);