-
Notifications
You must be signed in to change notification settings - Fork 2
/
virtReorder.h
134 lines (105 loc) · 2.88 KB
/
virtReorder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Copyright (C) 2014 Joshua Hare, Lance Hartung, and Suman Banerjee.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _VIRT_REORDER_H__
#define _VIRT_REORDER_H__
#define REORDER_ACCEPT 0
#define REORDER_STOLEN 1
#define REORDER_DROP -1
struct sk_buff;
struct flow_table_entry;
struct packet;
struct virt_priv;
struct xor_entry {
struct sk_buff *skb;
u32 seq;
u8 coding_rate;
long drop_time;
struct list_head list;
};
struct reorder_entry {
struct sk_buff *skb;
bool delivered;
long store_time;
long release_time;
struct list_head list;
};
/*
* forwarded = in_order + early + late + recovered
* received = dropped + in_order + early + late
*/
struct reorder_stats {
long forwarded;
long received;
long dropped;
long in_order;
long early;
long late;
long recovered;
/* delays stored in jiffies */
long max_delay;
long avg_delay;
};
/**
* struct reorder_head
*
* @resync_time: deadline for resynchronizing sequence numbers
*/
struct reorder_head {
unsigned queue_size;
struct reorder_entry *queue;
int tail_index;
u32 tail_seq;
u32 head_seq;
struct list_head xor_list;
unsigned xor_list_len;
struct net_device *master_dev;
u32 next_rx_seq;
long resync_time;
struct reorder_stats stats;
struct timer_list timer;
bool restart_timer;
spinlock_t lock;
};
/* This must fit in sk_buff cb field. */
struct virt_skb_cb {
struct virt_priv *virt;
struct flow_table_entry *flow;
};
struct virt_network;
void reorder_head_init(struct net_device *master_dev, struct reorder_head *head);
void reorder_head_destroy(struct reorder_head *head);
int reorder_rx_packet(struct virt_network *net, struct packet *pkt);
int reorder_try_recover(struct reorder_head *head, struct sk_buff *xor_skb);
void insert_xor_packet(struct reorder_head *head, struct sk_buff *skb);
#ifndef before
static inline int before(u32 seq1, u32 seq2)
{
return (s32)(seq1 - seq2) < 0;
}
#endif
#ifndef after
static inline int after(u32 seq1, u32 seq2)
{
return (s32)(seq1 - seq2) > 0;
}
#endif
static inline int afterl(unsigned long a, unsigned long b)
{
return (long)(a - b) > 0;
}
#endif //_VIRT_REORDER_H__