]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - net/core/dev.h
net: move netdev_budget and netdev_budget to net_hotdata
[thirdparty/kernel/stable.git] / net / core / dev.h
CommitLineData
6264f58c
JK
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>
c7d52737 6#include <linux/rwsem.h>
6264f58c
JK
7
8struct net;
9struct net_device;
10struct netdev_bpf;
11struct netdev_phys_item_id;
12struct netlink_ext_ack;
370ca718 13struct cpumask;
6264f58c
JK
14
15/* Random bits of netdevice that don't need to be exposed */
16#define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */
17struct sd_flow_limit {
18 u64 count;
19 unsigned int num_buckets;
20 unsigned int history_head;
21 u16 history[FLOW_LIMIT_HISTORY];
22 u8 buckets[];
23};
24
25extern int netdev_flow_limit_table_len;
26
27#ifdef CONFIG_PROC_FS
28int __init dev_proc_init(void);
29#else
30#define dev_proc_init() 0
31#endif
32
33void linkwatch_init_dev(struct net_device *dev);
6264f58c
JK
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/ */
39564c3f 41extern unsigned int sysctl_skb_defer_max;
6264f58c
JK
42extern int netdev_tstamp_prequeue;
43extern int netdev_unregister_timeout_secs;
44extern int weight_p;
45extern int dev_weight_rx_bias;
46extern int dev_weight_tx_bias;
47
c7d52737
ED
48extern struct rw_semaphore dev_addr_sem;
49
6264f58c
JK
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;
723de3eb 60 struct rcu_head rcu;
6264f58c
JK
61};
62
63int netdev_get_name(struct net *net, char *name, int ifindex);
64int dev_change_name(struct net_device *dev, const char *newname);
65
7663d522
JK
66#define netdev_for_each_altname(dev, namenode) \
67 list_for_each_entry((namenode), &(dev)->name_node->list, list)
d09486a0
JK
68#define netdev_for_each_altname_safe(dev, namenode, next) \
69 list_for_each_entry_safe((namenode), (next), &(dev)->name_node->list, \
70 list)
7663d522 71
6264f58c
JK
72int netdev_name_node_alt_create(struct net_device *dev, const char *name);
73int netdev_name_node_alt_destroy(struct net_device *dev, const char *name);
74
75int dev_validate_mtu(struct net_device *dev, int mtu,
76 struct netlink_ext_ack *extack);
77int dev_set_mtu_ext(struct net_device *dev, int mtu,
78 struct netlink_ext_ack *extack);
79
80int dev_get_phys_port_id(struct net_device *dev,
81 struct netdev_phys_item_id *ppid);
82int dev_get_phys_port_name(struct net_device *dev,
83 char *name, size_t len);
84
85int dev_change_proto_down(struct net_device *dev, bool proto_down);
86void dev_change_proto_down_reason(struct net_device *dev, unsigned long mask,
87 u32 value);
88
89typedef int (*bpf_op_t)(struct net_device *dev, struct netdev_bpf *bpf);
90int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
91 int fd, int expected_fd, u32 flags);
92
93int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len);
94void dev_set_group(struct net_device *dev, int new_group);
95int dev_change_carrier(struct net_device *dev, bool new_carrier);
96
97void __dev_set_rx_mode(struct net_device *dev);
98
1d997f10
HL
99void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
100 unsigned int gchanges, u32 portid,
101 const struct nlmsghdr *nlh);
102
77f4aa9a
HL
103void unregister_netdevice_many_notify(struct list_head *head,
104 u32 portid, const struct nlmsghdr *nlh);
105
744d49da
JK
106static inline void netif_set_gso_max_size(struct net_device *dev,
107 unsigned int size)
108{
109 /* dev->gso_max_size is read locklessly from sk_setup_caps() */
110 WRITE_ONCE(dev->gso_max_size, size);
9eefedd5
XL
111 if (size <= GSO_LEGACY_MAX_SIZE)
112 WRITE_ONCE(dev->gso_ipv4_max_size, size);
744d49da
JK
113}
114
115static inline void netif_set_gso_max_segs(struct net_device *dev,
116 unsigned int segs)
117{
118 /* dev->gso_max_segs is read locklessly from sk_setup_caps() */
119 WRITE_ONCE(dev->gso_max_segs, segs);
120}
121
122static inline void netif_set_gro_max_size(struct net_device *dev,
123 unsigned int size)
124{
125 /* This pairs with the READ_ONCE() in skb_gro_receive() */
126 WRITE_ONCE(dev->gro_max_size, size);
9eefedd5
XL
127 if (size <= GRO_LEGACY_MAX_SIZE)
128 WRITE_ONCE(dev->gro_ipv4_max_size, size);
129}
130
131static inline void netif_set_gso_ipv4_max_size(struct net_device *dev,
132 unsigned int size)
133{
134 /* dev->gso_ipv4_max_size is read locklessly from sk_setup_caps() */
135 WRITE_ONCE(dev->gso_ipv4_max_size, size);
136}
137
138static inline void netif_set_gro_ipv4_max_size(struct net_device *dev,
139 unsigned int size)
140{
141 /* This pairs with the READ_ONCE() in skb_gro_receive() */
142 WRITE_ONCE(dev->gro_ipv4_max_size, size);
744d49da
JK
143}
144
370ca718 145int rps_cpumask_housekeeping(struct cpumask *mask);
9a675ba5
SAS
146
147#if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL)
148void xdp_do_check_flushed(struct napi_struct *napi);
149#else
150static inline void xdp_do_check_flushed(struct napi_struct *napi) { }
151#endif
27f91aaf
AN
152
153struct napi_struct *napi_by_id(unsigned int napi_id);
6264f58c 154#endif