-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvq.h
126 lines (102 loc) · 3.09 KB
/
vq.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
#include <linux/version.h>
#include <linux/skbuff.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/ktime.h>
#include <net/ip.h>
#include <net/inet_ecn.h>
#include <net/tcp.h>
#include <net/dst.h>
#include <linux/hash.h>
#include <linux/crc16.h>
#include <linux/completion.h>
#include <linux/hrtimer.h>
#include <linux/random.h>
#include <asm/atomic.h>
#include <linux/spinlock.h>
#ifndef __VQ_H__
#define __VQ_H__
#include "params.h"
#include "tx.h"
#include "rx.h"
/*
* We represent alpha, the fraction of ECN marked packets, as
* numerator/denominator. We ensure that @numerator is an integer in
* the range [0, 1 << ECN_ALPHA_FRAC_SHIFT].
*/
#define ECN_ALPHA_FRAC_SHIFT (10)
#define MUL15(x) (((x) << 4) - (x))
#define DIV16(x) ((x) >> 4)
#define EWMA_G16(old, new) DIV16(MUL15(old) + new)
struct iso_vq_stats {
u64 bytes_queued;
u64 network_marked;
u64 rx_packets;
u64 rx_bytes;
ktime_t last_feedback_gen_time;
u32 rx_since_last_feedback;
u32 rx_marked_since_last_feedback;
};
struct iso_vq {
u8 enabled;
u8 is_static;
u64 rate;
u64 total_bytes_queued;
u64 feedback_rate;
u64 rx_rate;
u64 last_rx_bytes;
u64 weight;
/* Fraction of marked packets = alpha/1024. */
u32 alpha;
ktime_t last_update_time, last_borrow_time;
struct iso_vq_stats __percpu *percpu_stats;
spinlock_t spinlock;
iso_class_t klass;
struct list_head list;
struct hlist_node hash_node;
/* The number of tx classes referring to this VQ */
atomic_t refcnt;
struct iso_rx_context *rxctx;
};
/*
extern struct list_head vq_list;
extern s64 vq_total_tokens;
extern ktime_t vq_last_update_time, vq_last_check_time;
extern atomic_t vq_active_rate;
extern struct hlist_head vq_bucket[ISO_MAX_VQ_BUCKETS];
*/
#define for_each_vq(vq, ctx) list_for_each_entry_safe(vq, vq_next, &ctx->vq_list, list)
#define ISO_VQ_DEFAULT_RATE_MBPS (100) /* This parameter shouldn't matter */
void iso_vqs_init(struct iso_rx_context *);
void iso_vqs_exit(struct iso_rx_context *);
int iso_vq_init(struct iso_vq *);
struct iso_vq *iso_vq_alloc(iso_class_t, struct iso_rx_context *);
void iso_vq_free(struct iso_vq *);
void iso_vq_enqueue(struct iso_vq *, struct sk_buff *);
void iso_vq_drain(struct iso_vq *, u64);
static inline int iso_vq_over_limits(struct iso_vq *);
void iso_vq_calculate_rates(struct iso_rx_context *);
void iso_vq_check_idle(struct iso_rx_context *);
static inline struct iso_vq *iso_vq_find(iso_class_t, struct iso_rx_context *);
void iso_vq_show(struct iso_vq *, struct seq_file *);
/* Called with rcu lock */
static inline struct iso_vq *iso_vq_find(iso_class_t klass, struct iso_rx_context *rxctx) {
u32 hash = iso_class_hash(klass);
struct hlist_head *head = &rxctx->vq_bucket[hash & (ISO_MAX_VQ_BUCKETS - 1)];
struct hlist_node *node;
struct iso_vq *vq;
hlist_for_each_entry_rcu(vq, node, head, hash_node) {
if(iso_class_cmp(vq->klass, klass) == 0)
return vq;
}
return NULL;
}
static inline int iso_vq_over_limits(struct iso_vq *vq) {
return vq->feedback_rate;
}
#endif /* __VQ_H__ */
/* Local Variables: */
/* indent-tabs-mode:t */
/* End: */