linux/net/core/net-sysfs.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * net-sysfs.c - network device class and attributes
 *
 * Copyright (c) 2003 Stephen Hemminger <[email protected]>
 */

#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>
#include <linux/sched/isolation.h>
#include <linux/nsproxy.h>
#include <net/sock.h>
#include <net/net_namespace.h>
#include <linux/rtnetlink.h>
#include <linux/vmalloc.h>
#include <linux/export.h>
#include <linux/jiffies.h>
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/cpu.h>
#include <net/netdev_rx_queue.h>
#include <net/rps.h>

#include "dev.h"
#include "net-sysfs.h"

#ifdef CONFIG_SYSFS
static const char fmt_hex[] =;
static const char fmt_dec[] =;
static const char fmt_ulong[] =;
static const char fmt_u64[] =;

/* Caller holds RTNL or RCU */
static inline int dev_isalive(const struct net_device *dev)
{}

/* use same locking rules as GIF* ioctl's */
static ssize_t netdev_show(const struct device *dev,
			   struct device_attribute *attr, char *buf,
			   ssize_t (*format)(const struct net_device *, char *))
{}

/* generate a show function for simple field */
#define NETDEVICE_SHOW(field, format_string)									\

#define NETDEVICE_SHOW_RO(field, format_string)

#define NETDEVICE_SHOW_RW(field, format_string)

/* use same locking and permission rules as SIF* ioctl's */
static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t len,
			    int (*set)(struct net_device *, unsigned long))
{}

NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();
NETDEVICE_SHOW_RO();

static ssize_t iflink_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(iflink);

static ssize_t format_name_assign_type(const struct net_device *dev, char *buf)
{}

static ssize_t name_assign_type_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{}
static DEVICE_ATTR_RO(name_assign_type);

/* use same locking rules as GIFHWADDR ioctl's (dev_get_mac_address()) */
static ssize_t address_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}
static DEVICE_ATTR_RO(address);

static ssize_t broadcast_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(broadcast);

static int change_carrier(struct net_device *dev, unsigned long new_carrier)
{}

static ssize_t carrier_store(struct device *dev, struct device_attribute *attr,
			     const char *buf, size_t len)
{}

static ssize_t carrier_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(carrier);

static ssize_t speed_show(struct device *dev,
			  struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(speed);

static ssize_t duplex_show(struct device *dev,
			   struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(duplex);

static ssize_t testing_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(testing);

static ssize_t dormant_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dormant);

static const char *const operstates[] =;

static ssize_t operstate_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(operstate);

static ssize_t carrier_changes_show(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{}
static DEVICE_ATTR_RO(carrier_changes);

static ssize_t carrier_up_count_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{}
static DEVICE_ATTR_RO(carrier_up_count);

static ssize_t carrier_down_count_show(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{}
static DEVICE_ATTR_RO(carrier_down_count);

/* read-write attributes */

static int change_mtu(struct net_device *dev, unsigned long new_mtu)
{}

static ssize_t mtu_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static int change_flags(struct net_device *dev, unsigned long new_flags)
{}

static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static ssize_t tx_queue_len_store(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static int change_gro_flush_timeout(struct net_device *dev, unsigned long val)
{}

static ssize_t gro_flush_timeout_store(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static int change_napi_defer_hard_irqs(struct net_device *dev, unsigned long val)
{}

static ssize_t napi_defer_hard_irqs_store(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
			     const char *buf, size_t len)
{}

static ssize_t ifalias_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(ifalias);

static int change_group(struct net_device *dev, unsigned long new_group)
{}

static ssize_t group_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t len)
{}
NETDEVICE_SHOW(group, fmt_dec);
static DEVICE_ATTR(netdev_group, 0644, group_show, group_store);

static int change_proto_down(struct net_device *dev, unsigned long proto_down)
{}

static ssize_t proto_down_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t len)
{}
NETDEVICE_SHOW_RW();

static ssize_t phys_port_id_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(phys_port_id);

static ssize_t phys_port_name_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(phys_port_name);

static ssize_t phys_switch_id_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(phys_switch_id);

static ssize_t threaded_show(struct device *dev,
			     struct device_attribute *attr, char *buf)
{}

static int modify_napi_threaded(struct net_device *dev, unsigned long val)
{}

static ssize_t threaded_store(struct device *dev,
			      struct device_attribute *attr,
			      const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(threaded);

static struct attribute *net_class_attrs[] __ro_after_init =;
ATTRIBUTE_GROUPS();

/* Show a given an attribute in the statistics group */
static ssize_t netstat_show(const struct device *d,
			    struct device_attribute *attr, char *buf,
			    unsigned long offset)
{}

/* generate a read-only statistics attribute */
#define NETSTAT_ENTRY(name)

NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();
NETSTAT_ENTRY();

static struct attribute *netstat_attrs[] __ro_after_init =;

static const struct attribute_group netstat_group =;

static struct attribute *wireless_attrs[] =;

static const struct attribute_group wireless_group =;

static bool wireless_group_needed(struct net_device *ndev)
{}

#else /* CONFIG_SYSFS */
#define net_class_groups
#endif /* CONFIG_SYSFS */

#ifdef CONFIG_SYSFS
#define to_rx_queue_attr(_attr)

#define to_rx_queue(obj)

static ssize_t rx_queue_attr_show(struct kobject *kobj, struct attribute *attr,
				  char *buf)
{}

static ssize_t rx_queue_attr_store(struct kobject *kobj, struct attribute *attr,
				   const char *buf, size_t count)
{}

static const struct sysfs_ops rx_queue_sysfs_ops =;

#ifdef CONFIG_RPS
static ssize_t show_rps_map(struct netdev_rx_queue *queue, char *buf)
{}

static int netdev_rx_queue_set_rps_mask(struct netdev_rx_queue *queue,
					cpumask_var_t mask)
{}

int rps_cpumask_housekeeping(struct cpumask *mask)
{}

static ssize_t store_rps_map(struct netdev_rx_queue *queue,
			     const char *buf, size_t len)
{}

static ssize_t show_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
					   char *buf)
{}

static void rps_dev_flow_table_release(struct rcu_head *rcu)
{}

static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
					    const char *buf, size_t len)
{}

static struct rx_queue_attribute rps_cpus_attribute __ro_after_init
	=;

static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute __ro_after_init
	=;
#endif /* CONFIG_RPS */

static struct attribute *rx_queue_default_attrs[] __ro_after_init =;
ATTRIBUTE_GROUPS();

static void rx_queue_release(struct kobject *kobj)
{}

static const void *rx_queue_namespace(const struct kobject *kobj)
{}

static void rx_queue_get_ownership(const struct kobject *kobj,
				   kuid_t *uid, kgid_t *gid)
{}

static const struct kobj_type rx_queue_ktype =;

static int rx_queue_default_mask(struct net_device *dev,
				 struct netdev_rx_queue *queue)
{}

static int rx_queue_add_kobject(struct net_device *dev, int index)
{}

static int rx_queue_change_owner(struct net_device *dev, int index, kuid_t kuid,
				 kgid_t kgid)
{}
#endif /* CONFIG_SYSFS */

int
net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
{}

static int net_rx_queue_change_owner(struct net_device *dev, int num,
				     kuid_t kuid, kgid_t kgid)
{}

#ifdef CONFIG_SYSFS
/*
 * netdev_queue sysfs structures and functions.
 */
struct netdev_queue_attribute {};
#define to_netdev_queue_attr(_attr)

#define to_netdev_queue(obj)

static ssize_t netdev_queue_attr_show(struct kobject *kobj,
				      struct attribute *attr, char *buf)
{}

static ssize_t netdev_queue_attr_store(struct kobject *kobj,
				       struct attribute *attr,
				       const char *buf, size_t count)
{}

static const struct sysfs_ops netdev_queue_sysfs_ops =;

static ssize_t tx_timeout_show(struct netdev_queue *queue, char *buf)
{}

static unsigned int get_netdev_queue_index(struct netdev_queue *queue)
{}

static ssize_t traffic_class_show(struct netdev_queue *queue,
				  char *buf)
{}

#ifdef CONFIG_XPS
static ssize_t tx_maxrate_show(struct netdev_queue *queue,
			       char *buf)
{}

static ssize_t tx_maxrate_store(struct netdev_queue *queue,
				const char *buf, size_t len)
{}

static struct netdev_queue_attribute queue_tx_maxrate __ro_after_init
	=;
#endif

static struct netdev_queue_attribute queue_trans_timeout __ro_after_init
	=;

static struct netdev_queue_attribute queue_traffic_class __ro_after_init
	=;

#ifdef CONFIG_BQL
/*
 * Byte queue limits sysfs structures and functions.
 */
static ssize_t bql_show(char *buf, unsigned int value)
{}

static ssize_t bql_set(const char *buf, const size_t count,
		       unsigned int *pvalue)
{}

static ssize_t bql_show_hold_time(struct netdev_queue *queue,
				  char *buf)
{}

static ssize_t bql_set_hold_time(struct netdev_queue *queue,
				 const char *buf, size_t len)
{}

static struct netdev_queue_attribute bql_hold_time_attribute __ro_after_init
	=;

static ssize_t bql_show_stall_thrs(struct netdev_queue *queue, char *buf)
{}

static ssize_t bql_set_stall_thrs(struct netdev_queue *queue,
				  const char *buf, size_t len)
{}

static struct netdev_queue_attribute bql_stall_thrs_attribute __ro_after_init =;

static ssize_t bql_show_stall_max(struct netdev_queue *queue, char *buf)
{}

static ssize_t bql_set_stall_max(struct netdev_queue *queue,
				 const char *buf, size_t len)
{}

static struct netdev_queue_attribute bql_stall_max_attribute __ro_after_init =;

static ssize_t bql_show_stall_cnt(struct netdev_queue *queue, char *buf)
{}

static struct netdev_queue_attribute bql_stall_cnt_attribute __ro_after_init =;

static ssize_t bql_show_inflight(struct netdev_queue *queue,
				 char *buf)
{}

static struct netdev_queue_attribute bql_inflight_attribute __ro_after_init =;

#define BQL_ATTR(NAME, FIELD)

BQL_ATTR();
BQL_ATTR();
BQL_ATTR();

static struct attribute *dql_attrs[] __ro_after_init =;

static const struct attribute_group dql_group =;
#else
/* Fake declaration, all the code using it should be dead */
extern const struct attribute_group dql_group;
#endif /* CONFIG_BQL */

#ifdef CONFIG_XPS
static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
			      int tc, char *buf, enum xps_map_type type)
{}

static ssize_t xps_cpus_show(struct netdev_queue *queue, char *buf)
{}

static ssize_t xps_cpus_store(struct netdev_queue *queue,
			      const char *buf, size_t len)
{}

static struct netdev_queue_attribute xps_cpus_attribute __ro_after_init
	=;

static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
{}

static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf,
			      size_t len)
{}

static struct netdev_queue_attribute xps_rxqs_attribute __ro_after_init
	=;
#endif /* CONFIG_XPS */

static struct attribute *netdev_queue_default_attrs[] __ro_after_init =;
ATTRIBUTE_GROUPS();

static void netdev_queue_release(struct kobject *kobj)
{}

static const void *netdev_queue_namespace(const struct kobject *kobj)
{}

static void netdev_queue_get_ownership(const struct kobject *kobj,
				       kuid_t *uid, kgid_t *gid)
{}

static const struct kobj_type netdev_queue_ktype =;

static bool netdev_uses_bql(const struct net_device *dev)
{}

static int netdev_queue_add_kobject(struct net_device *dev, int index)
{}

static int tx_queue_change_owner(struct net_device *ndev, int index,
				 kuid_t kuid, kgid_t kgid)
{}
#endif /* CONFIG_SYSFS */

int
netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
{}

static int net_tx_queue_change_owner(struct net_device *dev, int num,
				     kuid_t kuid, kgid_t kgid)
{}

static int register_queue_kobjects(struct net_device *dev)
{}

static int queue_change_owner(struct net_device *ndev, kuid_t kuid, kgid_t kgid)
{}

static void remove_queue_kobjects(struct net_device *dev)
{}

static bool net_current_may_mount(void)
{}

static void *net_grab_current_ns(void)
{}

static const void *net_initial_ns(void)
{}

static const void *net_netlink_ns(struct sock *sk)
{}

const struct kobj_ns_type_operations net_ns_type_operations =;
EXPORT_SYMBOL_GPL();

static int netdev_uevent(const struct device *d, struct kobj_uevent_env *env)
{}

/*
 *	netdev_release -- destroy and free a dead device.
 *	Called when last reference to device kobject is gone.
 */
static void netdev_release(struct device *d)
{}

static const void *net_namespace(const struct device *d)
{}

static void net_get_ownership(const struct device *d, kuid_t *uid, kgid_t *gid)
{}

static const struct class net_class =;

#ifdef CONFIG_OF
static int of_dev_node_match(struct device *dev, const void *data)
{}

/*
 * of_find_net_device_by_node - lookup the net device for the device node
 * @np: OF device node
 *
 * Looks up the net_device structure corresponding with the device node.
 * If successful, returns a pointer to the net_device with the embedded
 * struct device refcount incremented by one, or NULL on failure. The
 * refcount must be dropped when done with the net_device.
 */
struct net_device *of_find_net_device_by_node(struct device_node *np)
{}
EXPORT_SYMBOL();
#endif

/* Delete sysfs entries but hold kobject reference until after all
 * netdev references are gone.
 */
void netdev_unregister_kobject(struct net_device *ndev)
{}

/* Create sysfs entries for network device. */
int netdev_register_kobject(struct net_device *ndev)
{}

/* Change owner for sysfs entries when moving network devices across network
 * namespaces owned by different user namespaces.
 */
int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
			const struct net *net_new)
{}

int netdev_class_create_file_ns(const struct class_attribute *class_attr,
				const void *ns)
{}
EXPORT_SYMBOL();

void netdev_class_remove_file_ns(const struct class_attribute *class_attr,
				 const void *ns)
{}
EXPORT_SYMBOL();

int __init netdev_kobject_init(void)
{}