blob: 2c5fca28b242e58aa14c304f58e18cdf04ee8190 [file] [log] [blame]
Pavel Emelyanov2787b042012-08-13 05:49:39 +00001#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
70struct packet_fanout;
71struct packet_sock {
72 /* struct sock has to be the first member of packet_sock */
73 struct sock sk;
74 struct packet_fanout *fanout;
75 struct tpacket_stats stats;
76 union tpacket_stats_u stats_u;
77 struct packet_ring_buffer rx_ring;
78 struct packet_ring_buffer tx_ring;
79 int copy_thresh;
80 spinlock_t bind_lock;
81 struct mutex pg_vec_lock;
82 unsigned int running:1, /* prot_hook is attached*/
83 auxdata:1,
84 origdev:1,
85 has_vnet_hdr:1;
86 int ifindex; /* bound device */
87 __be16 num;
88 struct packet_mclist *mclist;
89 atomic_t mapped;
90 enum tpacket_versions tp_version;
91 unsigned int tp_hdrlen;
92 unsigned int tp_reserve;
93 unsigned int tp_loss:1;
94 unsigned int tp_tstamp;
95 struct packet_type prot_hook ____cacheline_aligned_in_smp;
96};
97
98static struct packet_sock *pkt_sk(struct sock *sk)
99{
100 return (struct packet_sock *)sk;
101}
102
103#endif