at v6.4 4.3 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2#ifndef _NET_CORE_DEV_H 3#define _NET_CORE_DEV_H 4 5#include <linux/types.h> 6 7struct net; 8struct net_device; 9struct netdev_bpf; 10struct netdev_phys_item_id; 11struct netlink_ext_ack; 12struct cpumask; 13 14/* Random bits of netdevice that don't need to be exposed */ 15#define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */ 16struct sd_flow_limit { 17 u64 count; 18 unsigned int num_buckets; 19 unsigned int history_head; 20 u16 history[FLOW_LIMIT_HISTORY]; 21 u8 buckets[]; 22}; 23 24extern int netdev_flow_limit_table_len; 25 26#ifdef CONFIG_PROC_FS 27int __init dev_proc_init(void); 28#else 29#define dev_proc_init() 0 30#endif 31 32void linkwatch_init_dev(struct net_device *dev); 33void linkwatch_forget_dev(struct net_device *dev); 34void linkwatch_run_queue(void); 35 36void dev_addr_flush(struct net_device *dev); 37int dev_addr_init(struct net_device *dev); 38void dev_addr_check(struct net_device *dev); 39 40/* sysctls not referred to from outside net/core/ */ 41extern int netdev_budget; 42extern unsigned int netdev_budget_usecs; 43extern unsigned int sysctl_skb_defer_max; 44extern int netdev_tstamp_prequeue; 45extern int netdev_unregister_timeout_secs; 46extern int weight_p; 47extern int dev_weight_rx_bias; 48extern int dev_weight_tx_bias; 49 50/* rtnl helpers */ 51extern struct list_head net_todo_list; 52void netdev_run_todo(void); 53 54/* netdev management, shared between various uAPI entry points */ 55struct netdev_name_node { 56 struct hlist_node hlist; 57 struct list_head list; 58 struct net_device *dev; 59 const char *name; 60}; 61 62int netdev_get_name(struct net *net, char *name, int ifindex); 63int dev_change_name(struct net_device *dev, const char *newname); 64 65int netdev_name_node_alt_create(struct net_device *dev, const char *name); 66int netdev_name_node_alt_destroy(struct net_device *dev, const char *name); 67 68int dev_validate_mtu(struct net_device *dev, int mtu, 69 struct netlink_ext_ack *extack); 70int dev_set_mtu_ext(struct net_device *dev, int mtu, 71 struct netlink_ext_ack *extack); 72 73int dev_get_phys_port_id(struct net_device *dev, 74 struct netdev_phys_item_id *ppid); 75int dev_get_phys_port_name(struct net_device *dev, 76 char *name, size_t len); 77 78int dev_change_proto_down(struct net_device *dev, bool proto_down); 79void dev_change_proto_down_reason(struct net_device *dev, unsigned long mask, 80 u32 value); 81 82typedef int (*bpf_op_t)(struct net_device *dev, struct netdev_bpf *bpf); 83int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, 84 int fd, int expected_fd, u32 flags); 85 86int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len); 87void dev_set_group(struct net_device *dev, int new_group); 88int dev_change_carrier(struct net_device *dev, bool new_carrier); 89 90void __dev_set_rx_mode(struct net_device *dev); 91 92void __dev_notify_flags(struct net_device *dev, unsigned int old_flags, 93 unsigned int gchanges, u32 portid, 94 const struct nlmsghdr *nlh); 95 96void unregister_netdevice_many_notify(struct list_head *head, 97 u32 portid, const struct nlmsghdr *nlh); 98 99static inline void netif_set_gso_max_size(struct net_device *dev, 100 unsigned int size) 101{ 102 /* dev->gso_max_size is read locklessly from sk_setup_caps() */ 103 WRITE_ONCE(dev->gso_max_size, size); 104 if (size <= GSO_LEGACY_MAX_SIZE) 105 WRITE_ONCE(dev->gso_ipv4_max_size, size); 106} 107 108static inline void netif_set_gso_max_segs(struct net_device *dev, 109 unsigned int segs) 110{ 111 /* dev->gso_max_segs is read locklessly from sk_setup_caps() */ 112 WRITE_ONCE(dev->gso_max_segs, segs); 113} 114 115static inline void netif_set_gro_max_size(struct net_device *dev, 116 unsigned int size) 117{ 118 /* This pairs with the READ_ONCE() in skb_gro_receive() */ 119 WRITE_ONCE(dev->gro_max_size, size); 120 if (size <= GRO_LEGACY_MAX_SIZE) 121 WRITE_ONCE(dev->gro_ipv4_max_size, size); 122} 123 124static inline void netif_set_gso_ipv4_max_size(struct net_device *dev, 125 unsigned int size) 126{ 127 /* dev->gso_ipv4_max_size is read locklessly from sk_setup_caps() */ 128 WRITE_ONCE(dev->gso_ipv4_max_size, size); 129} 130 131static inline void netif_set_gro_ipv4_max_size(struct net_device *dev, 132 unsigned int size) 133{ 134 /* This pairs with the READ_ONCE() in skb_gro_receive() */ 135 WRITE_ONCE(dev->gro_ipv4_max_size, size); 136} 137 138int rps_cpumask_housekeeping(struct cpumask *mask); 139#endif