0001
0002 #ifndef _NET_CORE_DEV_H
0003 #define _NET_CORE_DEV_H
0004
0005 #include <linux/types.h>
0006
0007 struct net;
0008 struct net_device;
0009 struct netdev_bpf;
0010 struct netdev_phys_item_id;
0011 struct netlink_ext_ack;
0012
0013
0014 #define FLOW_LIMIT_HISTORY (1 << 7)
0015 struct sd_flow_limit {
0016 u64 count;
0017 unsigned int num_buckets;
0018 unsigned int history_head;
0019 u16 history[FLOW_LIMIT_HISTORY];
0020 u8 buckets[];
0021 };
0022
0023 extern int netdev_flow_limit_table_len;
0024
0025 #ifdef CONFIG_PROC_FS
0026 int __init dev_proc_init(void);
0027 #else
0028 #define dev_proc_init() 0
0029 #endif
0030
0031 void linkwatch_init_dev(struct net_device *dev);
0032 void linkwatch_forget_dev(struct net_device *dev);
0033 void linkwatch_run_queue(void);
0034
0035 void dev_addr_flush(struct net_device *dev);
0036 int dev_addr_init(struct net_device *dev);
0037 void dev_addr_check(struct net_device *dev);
0038
0039
0040 extern int netdev_budget;
0041 extern unsigned int netdev_budget_usecs;
0042 extern unsigned int sysctl_skb_defer_max;
0043 extern int netdev_tstamp_prequeue;
0044 extern int netdev_unregister_timeout_secs;
0045 extern int weight_p;
0046 extern int dev_weight_rx_bias;
0047 extern int dev_weight_tx_bias;
0048
0049
0050 extern struct list_head net_todo_list;
0051 void netdev_run_todo(void);
0052
0053
0054 struct netdev_name_node {
0055 struct hlist_node hlist;
0056 struct list_head list;
0057 struct net_device *dev;
0058 const char *name;
0059 };
0060
0061 int netdev_get_name(struct net *net, char *name, int ifindex);
0062 int dev_change_name(struct net_device *dev, const char *newname);
0063
0064 int netdev_name_node_alt_create(struct net_device *dev, const char *name);
0065 int netdev_name_node_alt_destroy(struct net_device *dev, const char *name);
0066
0067 int dev_validate_mtu(struct net_device *dev, int mtu,
0068 struct netlink_ext_ack *extack);
0069 int dev_set_mtu_ext(struct net_device *dev, int mtu,
0070 struct netlink_ext_ack *extack);
0071
0072 int dev_get_phys_port_id(struct net_device *dev,
0073 struct netdev_phys_item_id *ppid);
0074 int dev_get_phys_port_name(struct net_device *dev,
0075 char *name, size_t len);
0076
0077 int dev_change_proto_down(struct net_device *dev, bool proto_down);
0078 void dev_change_proto_down_reason(struct net_device *dev, unsigned long mask,
0079 u32 value);
0080
0081 typedef int (*bpf_op_t)(struct net_device *dev, struct netdev_bpf *bpf);
0082 int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
0083 int fd, int expected_fd, u32 flags);
0084
0085 int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len);
0086 void dev_set_group(struct net_device *dev, int new_group);
0087 int dev_change_carrier(struct net_device *dev, bool new_carrier);
0088
0089 void __dev_set_rx_mode(struct net_device *dev);
0090
0091 static inline void netif_set_gso_max_size(struct net_device *dev,
0092 unsigned int size)
0093 {
0094
0095 WRITE_ONCE(dev->gso_max_size, size);
0096 }
0097
0098 static inline void netif_set_gso_max_segs(struct net_device *dev,
0099 unsigned int segs)
0100 {
0101
0102 WRITE_ONCE(dev->gso_max_segs, segs);
0103 }
0104
0105 static inline void netif_set_gro_max_size(struct net_device *dev,
0106 unsigned int size)
0107 {
0108
0109 WRITE_ONCE(dev->gro_max_size, size);
0110 }
0111
0112 #endif