]>
Commit | Line | Data |
---|---|---|
2787b04b PE |
1 | #ifndef __PACKET_INTERNAL_H__ |
2 | #define __PACKET_INTERNAL_H__ | |
3 | ||
fb5c2c17 RE |
4 | #include <linux/refcount.h> |
5 | ||
2787b04b PE |
6 | struct packet_mclist { |
7 | struct packet_mclist *next; | |
8 | int ifindex; | |
9 | int count; | |
10 | unsigned short type; | |
11 | unsigned short alen; | |
12 | unsigned char addr[MAX_ADDR_LEN]; | |
13 | }; | |
14 | ||
15 | /* kbdq - kernel block descriptor queue */ | |
16 | struct tpacket_kbdq_core { | |
17 | struct pgv *pkbdq; | |
18 | unsigned int feature_req_word; | |
19 | unsigned int hdrlen; | |
20 | unsigned char reset_pending_on_curr_blk; | |
21 | unsigned char delete_blk_timer; | |
22 | unsigned short kactive_blk_num; | |
23 | unsigned short blk_sizeof_priv; | |
24 | ||
25 | /* last_kactive_blk_num: | |
26 | * trick to see if user-space has caught up | |
27 | * in order to avoid refreshing timer when every single pkt arrives. | |
28 | */ | |
29 | unsigned short last_kactive_blk_num; | |
30 | ||
31 | char *pkblk_start; | |
32 | char *pkblk_end; | |
33 | int kblk_size; | |
dc808110 | 34 | unsigned int max_frame_len; |
2787b04b PE |
35 | unsigned int knum_blocks; |
36 | uint64_t knxt_seq_num; | |
37 | char *prev; | |
38 | char *nxt_offset; | |
39 | struct sk_buff *skb; | |
40 | ||
41 | atomic_t blk_fill_in_prog; | |
42 | ||
43 | /* Default is set to 8ms */ | |
44 | #define DEFAULT_PRB_RETIRE_TOV (8) | |
45 | ||
46 | unsigned short retire_blk_tov; | |
47 | unsigned short version; | |
48 | unsigned long tov_in_jiffies; | |
49 | ||
50 | /* timer to retire an outstanding block */ | |
51 | struct timer_list retire_blk_timer; | |
52 | }; | |
53 | ||
54 | struct pgv { | |
55 | char *buffer; | |
56 | }; | |
57 | ||
58 | struct packet_ring_buffer { | |
59 | struct pgv *pg_vec; | |
0578edc5 | 60 | |
2787b04b PE |
61 | unsigned int head; |
62 | unsigned int frames_per_block; | |
63 | unsigned int frame_size; | |
64 | unsigned int frame_max; | |
65 | ||
66 | unsigned int pg_vec_order; | |
67 | unsigned int pg_vec_pages; | |
68 | unsigned int pg_vec_len; | |
69 | ||
b0138408 | 70 | unsigned int __percpu *pending_refcnt; |
0578edc5 DB |
71 | |
72 | struct tpacket_kbdq_core prb_bdqc; | |
2787b04b PE |
73 | }; |
74 | ||
fff3321d PE |
75 | extern struct mutex fanout_mutex; |
76 | #define PACKET_FANOUT_MAX 256 | |
77 | ||
78 | struct packet_fanout { | |
0c5c9fb5 | 79 | possible_net_t net; |
fff3321d PE |
80 | unsigned int num_members; |
81 | u16 id; | |
82 | u8 type; | |
77f65ebd | 83 | u8 flags; |
47dceb8e WB |
84 | union { |
85 | atomic_t rr_cur; | |
86 | struct bpf_prog __rcu *bpf_prog; | |
87 | }; | |
fff3321d PE |
88 | struct list_head list; |
89 | struct sock *arr[PACKET_FANOUT_MAX]; | |
90 | spinlock_t lock; | |
fb5c2c17 | 91 | refcount_t sk_ref; |
fff3321d PE |
92 | struct packet_type prot_hook ____cacheline_aligned_in_smp; |
93 | }; | |
94 | ||
0648ab70 WB |
95 | struct packet_rollover { |
96 | int sock; | |
59f21118 | 97 | struct rcu_head rcu; |
a9b63918 WB |
98 | atomic_long_t num; |
99 | atomic_long_t num_huge; | |
100 | atomic_long_t num_failed; | |
3b3a5b0a WB |
101 | #define ROLLOVER_HLEN (L1_CACHE_BYTES / sizeof(u32)) |
102 | u32 history[ROLLOVER_HLEN] ____cacheline_aligned; | |
0648ab70 WB |
103 | } ____cacheline_aligned_in_smp; |
104 | ||
2787b04b PE |
105 | struct packet_sock { |
106 | /* struct sock has to be the first member of packet_sock */ | |
107 | struct sock sk; | |
108 | struct packet_fanout *fanout; | |
ee80fbf3 | 109 | union tpacket_stats_u stats; |
2787b04b PE |
110 | struct packet_ring_buffer rx_ring; |
111 | struct packet_ring_buffer tx_ring; | |
112 | int copy_thresh; | |
113 | spinlock_t bind_lock; | |
114 | struct mutex pg_vec_lock; | |
115 | unsigned int running:1, /* prot_hook is attached*/ | |
116 | auxdata:1, | |
117 | origdev:1, | |
118 | has_vnet_hdr:1; | |
2ccdbaa6 | 119 | int pressure; |
2787b04b PE |
120 | int ifindex; /* bound device */ |
121 | __be16 num; | |
0648ab70 | 122 | struct packet_rollover *rollover; |
2787b04b PE |
123 | struct packet_mclist *mclist; |
124 | atomic_t mapped; | |
125 | enum tpacket_versions tp_version; | |
126 | unsigned int tp_hdrlen; | |
127 | unsigned int tp_reserve; | |
128 | unsigned int tp_loss:1; | |
5920cd3a | 129 | unsigned int tp_tx_has_off:1; |
2787b04b | 130 | unsigned int tp_tstamp; |
e40526cb | 131 | struct net_device __rcu *cached_dev; |
d346a3fa | 132 | int (*xmit)(struct sk_buff *skb); |
2787b04b PE |
133 | struct packet_type prot_hook ____cacheline_aligned_in_smp; |
134 | }; | |
135 | ||
136 | static struct packet_sock *pkt_sk(struct sock *sk) | |
137 | { | |
138 | return (struct packet_sock *)sk; | |
139 | } | |
140 | ||
141 | #endif |