aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/packet/internal.h')
-rw-r--r--net/packet/internal.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/net/packet/internal.h b/net/packet/internal.h
new file mode 100644
index 000000000000..44945f6b7252
--- /dev/null
+++ b/net/packet/internal.h
@@ -0,0 +1,121 @@
1#ifndef __PACKET_INTERNAL_H__
2#define __PACKET_INTERNAL_H__
3
4struct packet_mclist {
5 struct packet_mclist *next;
6 int ifindex;
7 int count;
8 unsigned short type;
9 unsigned short alen;
10 unsigned char addr[MAX_ADDR_LEN];
11};
12
13/* kbdq - kernel block descriptor queue */
14struct tpacket_kbdq_core {
15 struct pgv *pkbdq;
16 unsigned int feature_req_word;
17 unsigned int hdrlen;
18 unsigned char reset_pending_on_curr_blk;
19 unsigned char delete_blk_timer;
20 unsigned short kactive_blk_num;
21 unsigned short blk_sizeof_priv;
22
23 /* last_kactive_blk_num:
24 * trick to see if user-space has caught up
25 * in order to avoid refreshing timer when every single pkt arrives.
26 */
27 unsigned short last_kactive_blk_num;
28
29 char *pkblk_start;
30 char *pkblk_end;
31 int kblk_size;
32 unsigned int knum_blocks;
33 uint64_t knxt_seq_num;
34 char *prev;
35 char *nxt_offset;
36 struct sk_buff *skb;
37
38 atomic_t blk_fill_in_prog;
39
40 /* Default is set to 8ms */
41#define DEFAULT_PRB_RETIRE_TOV (8)
42
43 unsigned short retire_blk_tov;
44 unsigned short version;
45 unsigned long tov_in_jiffies;
46
47 /* timer to retire an outstanding block */
48 struct timer_list retire_blk_timer;
49};
50
51struct pgv {
52 char *buffer;
53};
54
55struct packet_ring_buffer {
56 struct pgv *pg_vec;
57 unsigned int head;
58 unsigned int frames_per_block;
59 unsigned int frame_size;
60 unsigned int frame_max;
61
62 unsigned int pg_vec_order;
63 unsigned int pg_vec_pages;
64 unsigned int pg_vec_len;
65
66 struct tpacket_kbdq_core prb_bdqc;
67 atomic_t pending;
68};
69
70extern struct mutex fanout_mutex;
71#define PACKET_FANOUT_MAX 256
72
73struct packet_fanout {
74#ifdef CONFIG_NET_NS
75 struct net *net;
76#endif
77 unsigned int num_members;
78 u16 id;
79 u8 type;
80 u8 defrag;
81 atomic_t rr_cur;
82 struct list_head list;
83 struct sock *arr[PACKET_FANOUT_MAX];
84 spinlock_t lock;
85 atomic_t sk_ref;
86 struct packet_type prot_hook ____cacheline_aligned_in_smp;
87};
88
89struct packet_sock {
90 /* struct sock has to be the first member of packet_sock */
91 struct sock sk;
92 struct packet_fanout *fanout;
93 struct tpacket_stats stats;
94 union tpacket_stats_u stats_u;
95 struct packet_ring_buffer rx_ring;
96 struct packet_ring_buffer tx_ring;
97 int copy_thresh;
98 spinlock_t bind_lock;
99 struct mutex pg_vec_lock;
100 unsigned int running:1, /* prot_hook is attached*/
101 auxdata:1,
102 origdev:1,
103 has_vnet_hdr:1;
104 int ifindex; /* bound device */
105 __be16 num;
106 struct packet_mclist *mclist;
107 atomic_t mapped;
108 enum tpacket_versions tp_version;
109 unsigned int tp_hdrlen;
110 unsigned int tp_reserve;
111 unsigned int tp_loss:1;
112 unsigned int tp_tstamp;
113 struct packet_type prot_hook ____cacheline_aligned_in_smp;
114};
115
116static struct packet_sock *pkt_sk(struct sock *sk)
117{
118 return (struct packet_sock *)sk;
119}
120
121#endif