1 | The following changes since commit 92f8c6fef13b31ba222c4d20ad8afd2b79c4c28e: | 1 | The following changes since commit 32c7e0ab755745e961f1772e95cac381cc68769d: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210525' into staging (2021-05-25 16:17:06 +0100) | 3 | Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20170421' into staging (2017-04-21 15:59:27 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | https://github.com/jasowang/qemu.git tags/net-pull-request | 7 | https://github.com/jasowang/qemu.git tags/net-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 90322e646e87c1440661cb3ddbc0cc94309d8a4f: | 9 | for you to fetch changes up to 0fc8aec7de64f2bf83a274a2a38b938ce03425d2: |
10 | 10 | ||
11 | MAINTAINERS: Added eBPF maintainers information. (2021-06-04 15:25:46 +0800) | 11 | COLO-compare: Optimize tcp compare trace event (2017-04-25 19:17:25 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | 14 | ||
15 | Changes from V1: | ||
16 | - Fix clang warnings | ||
17 | |||
15 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
16 | Andrew Melnychenko (7): | 19 | Cédric Le Goater (5): |
17 | net/tap: Added TUNSETSTEERINGEBPF code. | 20 | hw/net: add MII definitions |
18 | net: Added SetSteeringEBPF method for NetClientState. | 21 | net: add FTGMAC100 support |
19 | ebpf: Added eBPF RSS program. | 22 | net/ftgmac100: add a 'aspeed' property |
20 | ebpf: Added eBPF RSS loader. | 23 | aspeed: add a FTGMAC100 nic |
21 | virtio-net: Added eBPF RSS to virtio-net. | 24 | slirp: add a fake NC-SI backend |
22 | docs: Added eBPF documentation. | ||
23 | MAINTAINERS: Added eBPF maintainers information. | ||
24 | 25 | ||
25 | MAINTAINERS | 8 + | 26 | Zhang Chen (3): |
26 | configure | 8 +- | 27 | colo-compare: Fix old packet check bug. |
27 | docs/devel/ebpf_rss.rst | 125 +++++++++ | 28 | COLO-compare: Optimize tcp compare for option field |
28 | docs/devel/index.rst | 1 + | 29 | COLO-compare: Optimize tcp compare trace event |
29 | ebpf/ebpf_rss-stub.c | 40 +++ | 30 | |
30 | ebpf/ebpf_rss.c | 165 ++++++++++++ | 31 | default-configs/arm-softmmu.mak | 1 + |
31 | ebpf/ebpf_rss.h | 44 ++++ | 32 | hw/arm/aspeed_soc.c | 21 + |
32 | ebpf/meson.build | 1 + | 33 | hw/net/Makefile.objs | 1 + |
33 | ebpf/rss.bpf.skeleton.h | 431 +++++++++++++++++++++++++++++++ | 34 | hw/net/ftgmac100.c | 1016 +++++++++++++++++++++++++++++++++++++++ |
34 | ebpf/trace-events | 4 + | 35 | include/hw/arm/aspeed_soc.h | 2 + |
35 | ebpf/trace.h | 1 + | 36 | include/hw/net/ftgmac100.h | 64 +++ |
36 | hw/net/vhost_net.c | 3 + | 37 | include/hw/net/mii.h | 71 ++- |
37 | hw/net/virtio-net.c | 116 ++++++++- | 38 | include/net/eth.h | 1 + |
38 | include/hw/virtio/virtio-net.h | 4 + | 39 | net/colo-compare.c | 69 ++- |
39 | include/net/net.h | 2 + | 40 | net/trace-events | 3 +- |
40 | meson.build | 23 ++ | 41 | slirp/Makefile.objs | 2 +- |
41 | meson_options.txt | 2 + | 42 | slirp/ncsi-pkt.h | 419 ++++++++++++++++ |
42 | net/tap-bsd.c | 5 + | 43 | slirp/ncsi.c | 130 +++++ |
43 | net/tap-linux.c | 13 + | 44 | slirp/slirp.c | 4 + |
44 | net/tap-linux.h | 1 + | 45 | slirp/slirp.h | 3 + |
45 | net/tap-solaris.c | 5 + | 46 | 15 files changed, 1770 insertions(+), 37 deletions(-) |
46 | net/tap-stub.c | 5 + | 47 | create mode 100644 hw/net/ftgmac100.c |
47 | net/tap.c | 9 + | 48 | create mode 100644 include/hw/net/ftgmac100.h |
48 | net/tap_int.h | 1 + | 49 | create mode 100644 slirp/ncsi-pkt.h |
49 | net/vhost-vdpa.c | 2 + | 50 | create mode 100644 slirp/ncsi.c |
50 | tools/ebpf/Makefile.ebpf | 21 ++ | ||
51 | tools/ebpf/rss.bpf.c | 571 +++++++++++++++++++++++++++++++++++++++++ | ||
52 | 27 files changed, 1607 insertions(+), 4 deletions(-) | ||
53 | create mode 100644 docs/devel/ebpf_rss.rst | ||
54 | create mode 100644 ebpf/ebpf_rss-stub.c | ||
55 | create mode 100644 ebpf/ebpf_rss.c | ||
56 | create mode 100644 ebpf/ebpf_rss.h | ||
57 | create mode 100644 ebpf/meson.build | ||
58 | create mode 100644 ebpf/rss.bpf.skeleton.h | ||
59 | create mode 100644 ebpf/trace-events | ||
60 | create mode 100644 ebpf/trace.h | ||
61 | create mode 100755 tools/ebpf/Makefile.ebpf | ||
62 | create mode 100644 tools/ebpf/rss.bpf.c | ||
63 | 51 | ||
64 | 52 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | When RSS is enabled the device tries to load the eBPF program | 3 | If colo-compare find one old packet,we can notify colo-frame |
4 | to select RX virtqueue in the TUN. If eBPF can be loaded | 4 | do checkpoint, no need continue find more old packet here. |
5 | the RSS will function also with vhost (works with kernel 5.8 and later). | ||
6 | Software RSS is used as a fallback with vhost=off when eBPF can't be loaded | ||
7 | or when hash population requested by the guest. | ||
8 | 5 | ||
9 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> |
10 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 7 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 8 | --- |
13 | hw/net/vhost_net.c | 3 ++ | 9 | net/colo-compare.c | 15 +++++++++++---- |
14 | hw/net/virtio-net.c | 116 +++++++++++++++++++++++++++++++++++++++-- | 10 | 1 file changed, 11 insertions(+), 4 deletions(-) |
15 | include/hw/virtio/virtio-net.h | 4 ++ | ||
16 | net/vhost-vdpa.c | 2 + | ||
17 | 4 files changed, 122 insertions(+), 3 deletions(-) | ||
18 | 11 | ||
19 | diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c | 12 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
20 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/net/vhost_net.c | 14 | --- a/net/colo-compare.c |
22 | +++ b/hw/net/vhost_net.c | 15 | +++ b/net/colo-compare.c |
23 | @@ -XXX,XX +XXX,XX @@ static const int kernel_feature_bits[] = { | 16 | @@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time) |
24 | VIRTIO_NET_F_MTU, | ||
25 | VIRTIO_F_IOMMU_PLATFORM, | ||
26 | VIRTIO_F_RING_PACKED, | ||
27 | + VIRTIO_NET_F_HASH_REPORT, | ||
28 | VHOST_INVALID_FEATURE_BIT | ||
29 | }; | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static const int user_feature_bits[] = { | ||
32 | VIRTIO_NET_F_MTU, | ||
33 | VIRTIO_F_IOMMU_PLATFORM, | ||
34 | VIRTIO_F_RING_PACKED, | ||
35 | + VIRTIO_NET_F_RSS, | ||
36 | + VIRTIO_NET_F_HASH_REPORT, | ||
37 | |||
38 | /* This bit implies RARP isn't sent by QEMU out of band */ | ||
39 | VIRTIO_NET_F_GUEST_ANNOUNCE, | ||
40 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/net/virtio-net.c | ||
43 | +++ b/hw/net/virtio-net.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, | ||
45 | return features; | ||
46 | } | ||
47 | |||
48 | - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); | ||
49 | - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); | ||
50 | + if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { | ||
51 | + virtio_clear_feature(&features, VIRTIO_NET_F_RSS); | ||
52 | + } | ||
53 | features = vhost_net_get_features(get_vhost_net(nc->peer), features); | ||
54 | vdev->backend_features = features; | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_announce(VirtIONet *n, uint8_t cmd, | ||
57 | } | 17 | } |
58 | } | 18 | } |
59 | 19 | ||
60 | +static void virtio_net_detach_epbf_rss(VirtIONet *n); | 20 | -static void colo_old_packet_check_one_conn(void *opaque, |
21 | - void *user_data) | ||
22 | +static int colo_old_packet_check_one_conn(Connection *conn, | ||
23 | + void *user_data) | ||
24 | { | ||
25 | - Connection *conn = opaque; | ||
26 | GList *result = NULL; | ||
27 | int64_t check_time = REGULAR_PACKET_CHECK_MS; | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ static void colo_old_packet_check_one_conn(void *opaque, | ||
30 | if (result) { | ||
31 | /* do checkpoint will flush old packet */ | ||
32 | /* TODO: colo_notify_checkpoint();*/ | ||
33 | + return 0; | ||
34 | } | ||
61 | + | 35 | + |
62 | static void virtio_net_disable_rss(VirtIONet *n) | 36 | + return 1; |
37 | } | ||
38 | |||
39 | /* | ||
40 | @@ -XXX,XX +XXX,XX @@ static void colo_old_packet_check(void *opaque) | ||
63 | { | 41 | { |
64 | if (n->rss_data.enabled) { | 42 | CompareState *s = opaque; |
65 | trace_virtio_net_rss_disable(); | 43 | |
66 | } | 44 | - g_queue_foreach(&s->conn_list, colo_old_packet_check_one_conn, NULL); |
67 | n->rss_data.enabled = false; | 45 | + /* |
68 | + | 46 | + * If we find one old packet, stop finding job and notify |
69 | + virtio_net_detach_epbf_rss(n); | 47 | + * COLO frame do checkpoint. |
70 | +} | 48 | + */ |
71 | + | 49 | + g_queue_find_custom(&s->conn_list, NULL, |
72 | +static bool virtio_net_attach_ebpf_to_backend(NICState *nic, int prog_fd) | 50 | + (GCompareFunc)colo_old_packet_check_one_conn); |
73 | +{ | ||
74 | + NetClientState *nc = qemu_get_peer(qemu_get_queue(nic), 0); | ||
75 | + if (nc == NULL || nc->info->set_steering_ebpf == NULL) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + | ||
79 | + return nc->info->set_steering_ebpf(nc, prog_fd); | ||
80 | +} | ||
81 | + | ||
82 | +static void rss_data_to_rss_config(struct VirtioNetRssData *data, | ||
83 | + struct EBPFRSSConfig *config) | ||
84 | +{ | ||
85 | + config->redirect = data->redirect; | ||
86 | + config->populate_hash = data->populate_hash; | ||
87 | + config->hash_types = data->hash_types; | ||
88 | + config->indirections_len = data->indirections_len; | ||
89 | + config->default_queue = data->default_queue; | ||
90 | +} | ||
91 | + | ||
92 | +static bool virtio_net_attach_epbf_rss(VirtIONet *n) | ||
93 | +{ | ||
94 | + struct EBPFRSSConfig config = {}; | ||
95 | + | ||
96 | + if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { | ||
97 | + return false; | ||
98 | + } | ||
99 | + | ||
100 | + rss_data_to_rss_config(&n->rss_data, &config); | ||
101 | + | ||
102 | + if (!ebpf_rss_set_all(&n->ebpf_rss, &config, | ||
103 | + n->rss_data.indirections_table, n->rss_data.key)) { | ||
104 | + return false; | ||
105 | + } | ||
106 | + | ||
107 | + if (!virtio_net_attach_ebpf_to_backend(n->nic, n->ebpf_rss.program_fd)) { | ||
108 | + return false; | ||
109 | + } | ||
110 | + | ||
111 | + return true; | ||
112 | +} | ||
113 | + | ||
114 | +static void virtio_net_detach_epbf_rss(VirtIONet *n) | ||
115 | +{ | ||
116 | + virtio_net_attach_ebpf_to_backend(n->nic, -1); | ||
117 | +} | ||
118 | + | ||
119 | +static bool virtio_net_load_ebpf(VirtIONet *n) | ||
120 | +{ | ||
121 | + if (!virtio_net_attach_ebpf_to_backend(n->nic, -1)) { | ||
122 | + /* backend does't support steering ebpf */ | ||
123 | + return false; | ||
124 | + } | ||
125 | + | ||
126 | + return ebpf_rss_load(&n->ebpf_rss); | ||
127 | +} | ||
128 | + | ||
129 | +static void virtio_net_unload_ebpf(VirtIONet *n) | ||
130 | +{ | ||
131 | + virtio_net_attach_ebpf_to_backend(n->nic, -1); | ||
132 | + ebpf_rss_unload(&n->ebpf_rss); | ||
133 | } | 51 | } |
134 | 52 | ||
135 | static uint16_t virtio_net_handle_rss(VirtIONet *n, | 53 | /* |
136 | @@ -XXX,XX +XXX,XX @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, | ||
137 | goto error; | ||
138 | } | ||
139 | n->rss_data.enabled = true; | ||
140 | + | ||
141 | + if (!n->rss_data.populate_hash) { | ||
142 | + if (!virtio_net_attach_epbf_rss(n)) { | ||
143 | + /* EBPF must be loaded for vhost */ | ||
144 | + if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { | ||
145 | + warn_report("Can't load eBPF RSS for vhost"); | ||
146 | + goto error; | ||
147 | + } | ||
148 | + /* fallback to software RSS */ | ||
149 | + warn_report("Can't load eBPF RSS - fallback to software RSS"); | ||
150 | + n->rss_data.enabled_software_rss = true; | ||
151 | + } | ||
152 | + } else { | ||
153 | + /* use software RSS for hash populating */ | ||
154 | + /* and detach eBPF if was loaded before */ | ||
155 | + virtio_net_detach_epbf_rss(n); | ||
156 | + n->rss_data.enabled_software_rss = true; | ||
157 | + } | ||
158 | + | ||
159 | trace_virtio_net_rss_enable(n->rss_data.hash_types, | ||
160 | n->rss_data.indirections_len, | ||
161 | temp.b); | ||
162 | @@ -XXX,XX +XXX,XX @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, | ||
163 | return -1; | ||
164 | } | ||
165 | |||
166 | - if (!no_rss && n->rss_data.enabled) { | ||
167 | + if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss) { | ||
168 | int index = virtio_net_process_rss(nc, buf, size); | ||
169 | if (index >= 0) { | ||
170 | NetClientState *nc2 = qemu_get_subqueue(n->nic, index); | ||
171 | @@ -XXX,XX +XXX,XX @@ static int virtio_net_post_load_device(void *opaque, int version_id) | ||
172 | } | ||
173 | |||
174 | if (n->rss_data.enabled) { | ||
175 | + n->rss_data.enabled_software_rss = n->rss_data.populate_hash; | ||
176 | + if (!n->rss_data.populate_hash) { | ||
177 | + if (!virtio_net_attach_epbf_rss(n)) { | ||
178 | + if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { | ||
179 | + warn_report("Can't post-load eBPF RSS for vhost"); | ||
180 | + } else { | ||
181 | + warn_report("Can't post-load eBPF RSS - " | ||
182 | + "fallback to software RSS"); | ||
183 | + n->rss_data.enabled_software_rss = true; | ||
184 | + } | ||
185 | + } | ||
186 | + } | ||
187 | + | ||
188 | trace_virtio_net_rss_enable(n->rss_data.hash_types, | ||
189 | n->rss_data.indirections_len, | ||
190 | sizeof(n->rss_data.key)); | ||
191 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) | ||
192 | n->qdev = dev; | ||
193 | |||
194 | net_rx_pkt_init(&n->rx_pkt, false); | ||
195 | + | ||
196 | + if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { | ||
197 | + virtio_net_load_ebpf(n); | ||
198 | + } | ||
199 | } | ||
200 | |||
201 | static void virtio_net_device_unrealize(DeviceState *dev) | ||
202 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_device_unrealize(DeviceState *dev) | ||
203 | VirtIONet *n = VIRTIO_NET(dev); | ||
204 | int i, max_queues; | ||
205 | |||
206 | + if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { | ||
207 | + virtio_net_unload_ebpf(n); | ||
208 | + } | ||
209 | + | ||
210 | /* This will stop vhost backend if appropriate. */ | ||
211 | virtio_net_set_status(vdev, 0); | ||
212 | |||
213 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_instance_init(Object *obj) | ||
214 | device_add_bootindex_property(obj, &n->nic_conf.bootindex, | ||
215 | "bootindex", "/ethernet-phy@0", | ||
216 | DEVICE(n)); | ||
217 | + | ||
218 | + ebpf_rss_init(&n->ebpf_rss); | ||
219 | } | ||
220 | |||
221 | static int virtio_net_pre_save(void *opaque) | ||
222 | diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h | ||
223 | index XXXXXXX..XXXXXXX 100644 | ||
224 | --- a/include/hw/virtio/virtio-net.h | ||
225 | +++ b/include/hw/virtio/virtio-net.h | ||
226 | @@ -XXX,XX +XXX,XX @@ | ||
227 | #include "qemu/option_int.h" | ||
228 | #include "qom/object.h" | ||
229 | |||
230 | +#include "ebpf/ebpf_rss.h" | ||
231 | + | ||
232 | #define TYPE_VIRTIO_NET "virtio-net-device" | ||
233 | OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET) | ||
234 | |||
235 | @@ -XXX,XX +XXX,XX @@ typedef struct VirtioNetRscChain { | ||
236 | |||
237 | typedef struct VirtioNetRssData { | ||
238 | bool enabled; | ||
239 | + bool enabled_software_rss; | ||
240 | bool redirect; | ||
241 | bool populate_hash; | ||
242 | uint32_t hash_types; | ||
243 | @@ -XXX,XX +XXX,XX @@ struct VirtIONet { | ||
244 | Notifier migration_state; | ||
245 | VirtioNetRssData rss_data; | ||
246 | struct NetRxPkt *rx_pkt; | ||
247 | + struct EBPFRSSContext ebpf_rss; | ||
248 | }; | ||
249 | |||
250 | void virtio_net_set_netclient_name(VirtIONet *n, const char *name, | ||
251 | diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c | ||
252 | index XXXXXXX..XXXXXXX 100644 | ||
253 | --- a/net/vhost-vdpa.c | ||
254 | +++ b/net/vhost-vdpa.c | ||
255 | @@ -XXX,XX +XXX,XX @@ const int vdpa_feature_bits[] = { | ||
256 | VIRTIO_NET_F_MTU, | ||
257 | VIRTIO_F_IOMMU_PLATFORM, | ||
258 | VIRTIO_F_RING_PACKED, | ||
259 | + VIRTIO_NET_F_RSS, | ||
260 | + VIRTIO_NET_F_HASH_REPORT, | ||
261 | VIRTIO_NET_F_GUEST_ANNOUNCE, | ||
262 | VIRTIO_NET_F_STATUS, | ||
263 | VHOST_INVALID_FEATURE_BIT | ||
264 | -- | 54 | -- |
265 | 2.7.4 | 55 | 2.7.4 |
266 | 56 | ||
267 | 57 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
1 | 2 | ||
3 | This adds comments on the Basic mode control and status registers bit | ||
4 | definitions. It also adds a couple of bits for 1000BASE-T and the | ||
5 | RealTek 8211E PHY for the FTGMAC100 model to use. | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
10 | --- | ||
11 | include/hw/net/mii.h | 71 +++++++++++++++++++++++++++++++++++++++------------- | ||
12 | 1 file changed, 53 insertions(+), 18 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/net/mii.h | ||
17 | +++ b/include/hw/net/mii.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #define MII_H | ||
20 | |||
21 | /* PHY registers */ | ||
22 | -#define MII_BMCR 0 | ||
23 | -#define MII_BMSR 1 | ||
24 | -#define MII_PHYID1 2 | ||
25 | -#define MII_PHYID2 3 | ||
26 | -#define MII_ANAR 4 | ||
27 | -#define MII_ANLPAR 5 | ||
28 | -#define MII_ANER 6 | ||
29 | +#define MII_BMCR 0 /* Basic mode control register */ | ||
30 | +#define MII_BMSR 1 /* Basic mode status register */ | ||
31 | +#define MII_PHYID1 2 /* ID register 1 */ | ||
32 | +#define MII_PHYID2 3 /* ID register 2 */ | ||
33 | +#define MII_ANAR 4 /* Autonegotiation advertisement */ | ||
34 | +#define MII_ANLPAR 5 /* Autonegotiation lnk partner abilities */ | ||
35 | +#define MII_ANER 6 /* Autonegotiation expansion */ | ||
36 | +#define MII_ANNP 7 /* Autonegotiation next page */ | ||
37 | +#define MII_ANLPRNP 8 /* Autonegotiation link partner rx next page */ | ||
38 | +#define MII_CTRL1000 9 /* 1000BASE-T control */ | ||
39 | +#define MII_STAT1000 10 /* 1000BASE-T status */ | ||
40 | +#define MII_MDDACR 13 /* MMD access control */ | ||
41 | +#define MII_MDDAADR 14 /* MMD access address data */ | ||
42 | +#define MII_EXTSTAT 15 /* Extended Status */ | ||
43 | #define MII_NSR 16 | ||
44 | #define MII_LBREMR 17 | ||
45 | #define MII_REC 18 | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | /* PHY registers fields */ | ||
48 | #define MII_BMCR_RESET (1 << 15) | ||
49 | #define MII_BMCR_LOOPBACK (1 << 14) | ||
50 | -#define MII_BMCR_SPEED (1 << 13) | ||
51 | -#define MII_BMCR_AUTOEN (1 << 12) | ||
52 | -#define MII_BMCR_FD (1 << 8) | ||
53 | +#define MII_BMCR_SPEED100 (1 << 13) /* LSB of Speed (100) */ | ||
54 | +#define MII_BMCR_SPEED MII_BMCR_SPEED100 | ||
55 | +#define MII_BMCR_AUTOEN (1 << 12) /* Autonegotiation enable */ | ||
56 | +#define MII_BMCR_PDOWN (1 << 11) /* Enable low power state */ | ||
57 | +#define MII_BMCR_ISOLATE (1 << 10) /* Isolate data paths from MII */ | ||
58 | +#define MII_BMCR_ANRESTART (1 << 9) /* Auto negotiation restart */ | ||
59 | +#define MII_BMCR_FD (1 << 8) /* Set duplex mode */ | ||
60 | +#define MII_BMCR_CTST (1 << 7) /* Collision test */ | ||
61 | +#define MII_BMCR_SPEED1000 (1 << 6) /* MSB of Speed (1000) */ | ||
62 | |||
63 | -#define MII_BMSR_100TX_FD (1 << 14) | ||
64 | -#define MII_BMSR_100TX_HD (1 << 13) | ||
65 | -#define MII_BMSR_10T_FD (1 << 12) | ||
66 | -#define MII_BMSR_10T_HD (1 << 11) | ||
67 | -#define MII_BMSR_MFPS (1 << 6) | ||
68 | -#define MII_BMSR_AN_COMP (1 << 5) | ||
69 | -#define MII_BMSR_AUTONEG (1 << 3) | ||
70 | -#define MII_BMSR_LINK_ST (1 << 2) | ||
71 | +#define MII_BMSR_100TX_FD (1 << 14) /* Can do 100mbps, full-duplex */ | ||
72 | +#define MII_BMSR_100TX_HD (1 << 13) /* Can do 100mbps, half-duplex */ | ||
73 | +#define MII_BMSR_10T_FD (1 << 12) /* Can do 10mbps, full-duplex */ | ||
74 | +#define MII_BMSR_10T_HD (1 << 11) /* Can do 10mbps, half-duplex */ | ||
75 | +#define MII_BMSR_100T2_FD (1 << 10) /* Can do 100mbps T2, full-duplex */ | ||
76 | +#define MII_BMSR_100T2_HD (1 << 9) /* Can do 100mbps T2, half-duplex */ | ||
77 | +#define MII_BMSR_EXTSTAT (1 << 8) /* Extended status in register 15 */ | ||
78 | +#define MII_BMSR_MFPS (1 << 6) /* MII Frame Preamble Suppression */ | ||
79 | +#define MII_BMSR_AN_COMP (1 << 5) /* Auto-negotiation complete */ | ||
80 | +#define MII_BMSR_RFAULT (1 << 4) /* Remote fault */ | ||
81 | +#define MII_BMSR_AUTONEG (1 << 3) /* Able to do auto-negotiation */ | ||
82 | +#define MII_BMSR_LINK_ST (1 << 2) /* Link status */ | ||
83 | +#define MII_BMSR_JABBER (1 << 1) /* Jabber detected */ | ||
84 | +#define MII_BMSR_EXTCAP (1 << 0) /* Ext-reg capability */ | ||
85 | |||
86 | +#define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymetric pause */ | ||
87 | +#define MII_ANAR_PAUSE (1 << 10) /* Try for pause */ | ||
88 | #define MII_ANAR_TXFD (1 << 8) | ||
89 | #define MII_ANAR_TX (1 << 7) | ||
90 | #define MII_ANAR_10FD (1 << 6) | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #define MII_ANAR_CSMACD (1 << 0) | ||
93 | |||
94 | #define MII_ANLPAR_ACK (1 << 14) | ||
95 | +#define MII_ANLPAR_PAUSEASY (1 << 11) /* can pause asymmetrically */ | ||
96 | +#define MII_ANLPAR_PAUSE (1 << 10) /* can pause */ | ||
97 | #define MII_ANLPAR_TXFD (1 << 8) | ||
98 | #define MII_ANLPAR_TX (1 << 7) | ||
99 | #define MII_ANLPAR_10FD (1 << 6) | ||
100 | #define MII_ANLPAR_10 (1 << 5) | ||
101 | #define MII_ANLPAR_CSMACD (1 << 0) | ||
102 | |||
103 | +#define MII_ANER_NWAY (1 << 0) /* Can do N-way auto-nego */ | ||
104 | + | ||
105 | +#define MII_CTRL1000_FULL (1 << 9) /* 1000BASE-T full duplex */ | ||
106 | +#define MII_CTRL1000_HALF (1 << 8) /* 1000BASE-T half duplex */ | ||
107 | + | ||
108 | +#define MII_STAT1000_FULL (1 << 11) /* 1000BASE-T full duplex */ | ||
109 | +#define MII_STAT1000_HALF (1 << 10) /* 1000BASE-T half duplex */ | ||
110 | + | ||
111 | /* List of vendor identifiers */ | ||
112 | /* RealTek 8201 */ | ||
113 | #define RTL8201CP_PHYID1 0x0000 | ||
114 | #define RTL8201CP_PHYID2 0x8201 | ||
115 | |||
116 | +/* RealTek 8211E */ | ||
117 | +#define RTL8211E_PHYID1 0x001c | ||
118 | +#define RTL8211E_PHYID2 0xc915 | ||
119 | + | ||
120 | /* National Semiconductor DP83848 */ | ||
121 | #define DP83848_PHYID1 0x2000 | ||
122 | #define DP83848_PHYID2 0x5c90 | ||
123 | -- | ||
124 | 2.7.4 | ||
125 | |||
126 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | RSS program and Makefile to build it. | 3 | The FTGMAC100 device is an Ethernet controller with DMA function that |
4 | The bpftool used to generate '.h' file. | 4 | can be found on Aspeed SoCs (which include NCSI). |
5 | The data in that file may be loaded by libbpf. | ||
6 | EBPF compilation is not required for building qemu. | ||
7 | You can use Makefile if you need to regenerate rss.bpf.skeleton.h. | ||
8 | 5 | ||
9 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 6 | It is fully compliant with IEEE 802.3 specification for 10/100 Mbps |
10 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 7 | Ethernet and IEEE 802.3z specification for 1000 Mbps Ethernet and |
8 | includes Reduced Media Independent Interface (RMII) and Reduced | ||
9 | Gigabit Media Independent Interface (RGMII) interfaces. It adopts an | ||
10 | AHB bus interface and integrates a link list DMA engine with direct | ||
11 | M-Bus accesses for transmitting and receiving packets. It has | ||
12 | independent TX/RX fifos, supports half and full duplex (1000 Mbps mode | ||
13 | only supports full duplex), flow control for full duplex and | ||
14 | backpressure for half duplex. | ||
15 | |||
16 | The FTGMAC100 also implements IP, TCP, UDP checksum offloads and | ||
17 | supports IEEE 802.1Q VLAN tag insertion and removal. It offers | ||
18 | high-priority transmit queue for QoS and CoS applications | ||
19 | |||
20 | This model is backed with a RealTek 8211E PHY which is the chip found | ||
21 | on the AST2500 EVB. It is complete enough to satisfy two different | ||
22 | Linux drivers and a U-Boot driver. Not supported features are : | ||
23 | |||
24 | - IEEE 802.1Q VLAN | ||
25 | - High Priority Transmit Queue | ||
26 | - Wake-On-LAN functions | ||
27 | |||
28 | The code is based on the Coldfire Fast Ethernet Controller model. | ||
29 | |||
30 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 31 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 32 | --- |
13 | tools/ebpf/Makefile.ebpf | 21 ++ | 33 | default-configs/arm-softmmu.mak | 1 + |
14 | tools/ebpf/rss.bpf.c | 571 +++++++++++++++++++++++++++++++++++++++++++++++ | 34 | hw/net/Makefile.objs | 1 + |
15 | 2 files changed, 592 insertions(+) | 35 | hw/net/ftgmac100.c | 1003 +++++++++++++++++++++++++++++++++++++++ |
16 | create mode 100755 tools/ebpf/Makefile.ebpf | 36 | include/hw/net/ftgmac100.h | 60 +++ |
17 | create mode 100644 tools/ebpf/rss.bpf.c | 37 | 4 files changed, 1065 insertions(+) |
38 | create mode 100644 hw/net/ftgmac100.c | ||
39 | create mode 100644 include/hw/net/ftgmac100.h | ||
18 | 40 | ||
19 | diff --git a/tools/ebpf/Makefile.ebpf b/tools/ebpf/Makefile.ebpf | 41 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak |
20 | new file mode 100755 | 42 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX | 43 | --- a/default-configs/arm-softmmu.mak |
22 | --- /dev/null | 44 | +++ b/default-configs/arm-softmmu.mak |
23 | +++ b/tools/ebpf/Makefile.ebpf | 45 | @@ -XXX,XX +XXX,XX @@ CONFIG_LAN9118=y |
24 | @@ -XXX,XX +XXX,XX @@ | 46 | CONFIG_SMC91C111=y |
25 | +OBJS = rss.bpf.o | 47 | CONFIG_ALLWINNER_EMAC=y |
26 | + | 48 | CONFIG_IMX_FEC=y |
27 | +LLC ?= llc | 49 | +CONFIG_FTGMAC100=y |
28 | +CLANG ?= clang | 50 | CONFIG_DS1338=y |
29 | +INC_FLAGS = `$(CLANG) -print-file-name=include` | 51 | CONFIG_PFLASH_CFI01=y |
30 | +EXTRA_CFLAGS ?= -O2 -emit-llvm -fno-stack-protector | 52 | CONFIG_PFLASH_CFI02=y |
31 | + | 53 | diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs |
32 | +all: $(OBJS) | 54 | index XXXXXXX..XXXXXXX 100644 |
33 | + | 55 | --- a/hw/net/Makefile.objs |
34 | +.PHONY: clean | 56 | +++ b/hw/net/Makefile.objs |
35 | + | 57 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_IMX_FEC) += imx_fec.o |
36 | +clean: | 58 | common-obj-$(CONFIG_CADENCE) += cadence_gem.o |
37 | + rm -f $(OBJS) | 59 | common-obj-$(CONFIG_STELLARIS_ENET) += stellaris_enet.o |
38 | + | 60 | common-obj-$(CONFIG_LANCE) += lance.o |
39 | +$(OBJS): %.o:%.c | 61 | +common-obj-$(CONFIG_FTGMAC100) += ftgmac100.o |
40 | + $(CLANG) $(INC_FLAGS) \ | 62 | |
41 | + -D__KERNEL__ -D__ASM_SYSREG_H \ | 63 | obj-$(CONFIG_ETRAXFS) += etraxfs_eth.o |
42 | + -I../include $(LINUXINCLUDE) \ | 64 | obj-$(CONFIG_COLDFIRE) += mcf_fec.o |
43 | + $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ | 65 | diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c |
44 | + bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h | ||
45 | + cp rss.bpf.skeleton.h ../../ebpf/ | ||
46 | diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c | ||
47 | new file mode 100644 | 66 | new file mode 100644 |
48 | index XXXXXXX..XXXXXXX | 67 | index XXXXXXX..XXXXXXX |
49 | --- /dev/null | 68 | --- /dev/null |
50 | +++ b/tools/ebpf/rss.bpf.c | 69 | +++ b/hw/net/ftgmac100.c |
51 | @@ -XXX,XX +XXX,XX @@ | 70 | @@ -XXX,XX +XXX,XX @@ |
52 | +/* | 71 | +/* |
53 | + * eBPF RSS program | 72 | + * Faraday FTGMAC100 Gigabit Ethernet |
54 | + * | 73 | + * |
55 | + * Developed by Daynix Computing LTD (http://www.daynix.com) | 74 | + * Copyright (C) 2016-2017, IBM Corporation. |
56 | + * | 75 | + * |
57 | + * Authors: | 76 | + * Based on Coldfire Fast Ethernet Controller emulation. |
58 | + * Andrew Melnychenko <andrew@daynix.com> | ||
59 | + * Yuri Benditovich <yuri.benditovich@daynix.com> | ||
60 | + * | 77 | + * |
61 | + * This work is licensed under the terms of the GNU GPL, version 2. See | 78 | + * Copyright (c) 2007 CodeSourcery. |
62 | + * the COPYING file in the top-level directory. | ||
63 | + * | 79 | + * |
64 | + * Prepare: | 80 | + * This code is licensed under the GPL version 2 or later. See the |
65 | + * Requires llvm, clang, bpftool, linux kernel tree | 81 | + * COPYING file in the top-level directory. |
82 | + */ | ||
83 | + | ||
84 | +#include "qemu/osdep.h" | ||
85 | +#include "hw/net/ftgmac100.h" | ||
86 | +#include "sysemu/dma.h" | ||
87 | +#include "qemu/log.h" | ||
88 | +#include "net/checksum.h" | ||
89 | +#include "net/eth.h" | ||
90 | +#include "hw/net/mii.h" | ||
91 | + | ||
92 | +/* For crc32 */ | ||
93 | +#include <zlib.h> | ||
94 | + | ||
95 | +/* | ||
96 | + * FTGMAC100 registers | ||
97 | + */ | ||
98 | +#define FTGMAC100_ISR 0x00 | ||
99 | +#define FTGMAC100_IER 0x04 | ||
100 | +#define FTGMAC100_MAC_MADR 0x08 | ||
101 | +#define FTGMAC100_MAC_LADR 0x0c | ||
102 | +#define FTGMAC100_MATH0 0x10 | ||
103 | +#define FTGMAC100_MATH1 0x14 | ||
104 | +#define FTGMAC100_NPTXPD 0x18 | ||
105 | +#define FTGMAC100_RXPD 0x1C | ||
106 | +#define FTGMAC100_NPTXR_BADR 0x20 | ||
107 | +#define FTGMAC100_RXR_BADR 0x24 | ||
108 | +#define FTGMAC100_HPTXPD 0x28 | ||
109 | +#define FTGMAC100_HPTXR_BADR 0x2c | ||
110 | +#define FTGMAC100_ITC 0x30 | ||
111 | +#define FTGMAC100_APTC 0x34 | ||
112 | +#define FTGMAC100_DBLAC 0x38 | ||
113 | +#define FTGMAC100_REVR 0x40 | ||
114 | +#define FTGMAC100_FEAR1 0x44 | ||
115 | +#define FTGMAC100_RBSR 0x4c | ||
116 | +#define FTGMAC100_TPAFCR 0x48 | ||
117 | + | ||
118 | +#define FTGMAC100_MACCR 0x50 | ||
119 | +#define FTGMAC100_MACSR 0x54 | ||
120 | +#define FTGMAC100_PHYCR 0x60 | ||
121 | +#define FTGMAC100_PHYDATA 0x64 | ||
122 | +#define FTGMAC100_FCR 0x68 | ||
123 | + | ||
124 | +/* | ||
125 | + * Interrupt status register & interrupt enable register | ||
126 | + */ | ||
127 | +#define FTGMAC100_INT_RPKT_BUF (1 << 0) | ||
128 | +#define FTGMAC100_INT_RPKT_FIFO (1 << 1) | ||
129 | +#define FTGMAC100_INT_NO_RXBUF (1 << 2) | ||
130 | +#define FTGMAC100_INT_RPKT_LOST (1 << 3) | ||
131 | +#define FTGMAC100_INT_XPKT_ETH (1 << 4) | ||
132 | +#define FTGMAC100_INT_XPKT_FIFO (1 << 5) | ||
133 | +#define FTGMAC100_INT_NO_NPTXBUF (1 << 6) | ||
134 | +#define FTGMAC100_INT_XPKT_LOST (1 << 7) | ||
135 | +#define FTGMAC100_INT_AHB_ERR (1 << 8) | ||
136 | +#define FTGMAC100_INT_PHYSTS_CHG (1 << 9) | ||
137 | +#define FTGMAC100_INT_NO_HPTXBUF (1 << 10) | ||
138 | + | ||
139 | +/* | ||
140 | + * Automatic polling timer control register | ||
141 | + */ | ||
142 | +#define FTGMAC100_APTC_RXPOLL_CNT(x) ((x) & 0xf) | ||
143 | +#define FTGMAC100_APTC_RXPOLL_TIME_SEL (1 << 4) | ||
144 | +#define FTGMAC100_APTC_TXPOLL_CNT(x) (((x) >> 8) & 0xf) | ||
145 | +#define FTGMAC100_APTC_TXPOLL_TIME_SEL (1 << 12) | ||
146 | + | ||
147 | +/* | ||
148 | + * PHY control register | ||
149 | + */ | ||
150 | +#define FTGMAC100_PHYCR_MIIRD (1 << 26) | ||
151 | +#define FTGMAC100_PHYCR_MIIWR (1 << 27) | ||
152 | + | ||
153 | +#define FTGMAC100_PHYCR_DEV(x) (((x) >> 16) & 0x1f) | ||
154 | +#define FTGMAC100_PHYCR_REG(x) (((x) >> 21) & 0x1f) | ||
155 | + | ||
156 | +/* | ||
157 | + * PHY data register | ||
158 | + */ | ||
159 | +#define FTGMAC100_PHYDATA_MIIWDATA(x) ((x) & 0xffff) | ||
160 | +#define FTGMAC100_PHYDATA_MIIRDATA(x) (((x) >> 16) & 0xffff) | ||
161 | + | ||
162 | +/* | ||
163 | + * Feature Register | ||
164 | + */ | ||
165 | +#define FTGMAC100_REVR_NEW_MDIO_INTERFACE (1 << 31) | ||
166 | + | ||
167 | +/* | ||
168 | + * MAC control register | ||
169 | + */ | ||
170 | +#define FTGMAC100_MACCR_TXDMA_EN (1 << 0) | ||
171 | +#define FTGMAC100_MACCR_RXDMA_EN (1 << 1) | ||
172 | +#define FTGMAC100_MACCR_TXMAC_EN (1 << 2) | ||
173 | +#define FTGMAC100_MACCR_RXMAC_EN (1 << 3) | ||
174 | +#define FTGMAC100_MACCR_RM_VLAN (1 << 4) | ||
175 | +#define FTGMAC100_MACCR_HPTXR_EN (1 << 5) | ||
176 | +#define FTGMAC100_MACCR_LOOP_EN (1 << 6) | ||
177 | +#define FTGMAC100_MACCR_ENRX_IN_HALFTX (1 << 7) | ||
178 | +#define FTGMAC100_MACCR_FULLDUP (1 << 8) | ||
179 | +#define FTGMAC100_MACCR_GIGA_MODE (1 << 9) | ||
180 | +#define FTGMAC100_MACCR_CRC_APD (1 << 10) /* not needed */ | ||
181 | +#define FTGMAC100_MACCR_RX_RUNT (1 << 12) | ||
182 | +#define FTGMAC100_MACCR_JUMBO_LF (1 << 13) | ||
183 | +#define FTGMAC100_MACCR_RX_ALL (1 << 14) | ||
184 | +#define FTGMAC100_MACCR_HT_MULTI_EN (1 << 15) | ||
185 | +#define FTGMAC100_MACCR_RX_MULTIPKT (1 << 16) | ||
186 | +#define FTGMAC100_MACCR_RX_BROADPKT (1 << 17) | ||
187 | +#define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18) | ||
188 | +#define FTGMAC100_MACCR_FAST_MODE (1 << 19) | ||
189 | +#define FTGMAC100_MACCR_SW_RST (1 << 31) | ||
190 | + | ||
191 | +/* | ||
192 | + * Transmit descriptor | ||
193 | + */ | ||
194 | +#define FTGMAC100_TXDES0_TXBUF_SIZE(x) ((x) & 0x3fff) | ||
195 | +#define FTGMAC100_TXDES0_EDOTR (1 << 15) | ||
196 | +#define FTGMAC100_TXDES0_CRC_ERR (1 << 19) | ||
197 | +#define FTGMAC100_TXDES0_LTS (1 << 28) | ||
198 | +#define FTGMAC100_TXDES0_FTS (1 << 29) | ||
199 | +#define FTGMAC100_TXDES0_TXDMA_OWN (1 << 31) | ||
200 | + | ||
201 | +#define FTGMAC100_TXDES1_VLANTAG_CI(x) ((x) & 0xffff) | ||
202 | +#define FTGMAC100_TXDES1_INS_VLANTAG (1 << 16) | ||
203 | +#define FTGMAC100_TXDES1_TCP_CHKSUM (1 << 17) | ||
204 | +#define FTGMAC100_TXDES1_UDP_CHKSUM (1 << 18) | ||
205 | +#define FTGMAC100_TXDES1_IP_CHKSUM (1 << 19) | ||
206 | +#define FTGMAC100_TXDES1_LLC (1 << 22) | ||
207 | +#define FTGMAC100_TXDES1_TX2FIC (1 << 30) | ||
208 | +#define FTGMAC100_TXDES1_TXIC (1 << 31) | ||
209 | + | ||
210 | +/* | ||
211 | + * Receive descriptor | ||
212 | + */ | ||
213 | +#define FTGMAC100_RXDES0_VDBC 0x3fff | ||
214 | +#define FTGMAC100_RXDES0_EDORR (1 << 15) | ||
215 | +#define FTGMAC100_RXDES0_MULTICAST (1 << 16) | ||
216 | +#define FTGMAC100_RXDES0_BROADCAST (1 << 17) | ||
217 | +#define FTGMAC100_RXDES0_RX_ERR (1 << 18) | ||
218 | +#define FTGMAC100_RXDES0_CRC_ERR (1 << 19) | ||
219 | +#define FTGMAC100_RXDES0_FTL (1 << 20) | ||
220 | +#define FTGMAC100_RXDES0_RUNT (1 << 21) | ||
221 | +#define FTGMAC100_RXDES0_RX_ODD_NB (1 << 22) | ||
222 | +#define FTGMAC100_RXDES0_FIFO_FULL (1 << 23) | ||
223 | +#define FTGMAC100_RXDES0_PAUSE_OPCODE (1 << 24) | ||
224 | +#define FTGMAC100_RXDES0_PAUSE_FRAME (1 << 25) | ||
225 | +#define FTGMAC100_RXDES0_LRS (1 << 28) | ||
226 | +#define FTGMAC100_RXDES0_FRS (1 << 29) | ||
227 | +#define FTGMAC100_RXDES0_RXPKT_RDY (1 << 31) | ||
228 | + | ||
229 | +#define FTGMAC100_RXDES1_VLANTAG_CI 0xffff | ||
230 | +#define FTGMAC100_RXDES1_PROT_MASK (0x3 << 20) | ||
231 | +#define FTGMAC100_RXDES1_PROT_NONIP (0x0 << 20) | ||
232 | +#define FTGMAC100_RXDES1_PROT_IP (0x1 << 20) | ||
233 | +#define FTGMAC100_RXDES1_PROT_TCPIP (0x2 << 20) | ||
234 | +#define FTGMAC100_RXDES1_PROT_UDPIP (0x3 << 20) | ||
235 | +#define FTGMAC100_RXDES1_LLC (1 << 22) | ||
236 | +#define FTGMAC100_RXDES1_DF (1 << 23) | ||
237 | +#define FTGMAC100_RXDES1_VLANTAG_AVAIL (1 << 24) | ||
238 | +#define FTGMAC100_RXDES1_TCP_CHKSUM_ERR (1 << 25) | ||
239 | +#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26) | ||
240 | +#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27) | ||
241 | + | ||
242 | +/* | ||
243 | + * Receive and transmit Buffer Descriptor | ||
244 | + */ | ||
245 | +typedef struct { | ||
246 | + uint32_t des0; | ||
247 | + uint32_t des1; | ||
248 | + uint32_t des2; /* not used by HW */ | ||
249 | + uint32_t des3; | ||
250 | +} FTGMAC100Desc; | ||
251 | + | ||
252 | +/* | ||
253 | + * Specific RTL8211E MII Registers | ||
254 | + */ | ||
255 | +#define RTL8211E_MII_PHYCR 16 /* PHY Specific Control */ | ||
256 | +#define RTL8211E_MII_PHYSR 17 /* PHY Specific Status */ | ||
257 | +#define RTL8211E_MII_INER 18 /* Interrupt Enable */ | ||
258 | +#define RTL8211E_MII_INSR 19 /* Interrupt Status */ | ||
259 | +#define RTL8211E_MII_RXERC 24 /* Receive Error Counter */ | ||
260 | +#define RTL8211E_MII_LDPSR 27 /* Link Down Power Saving */ | ||
261 | +#define RTL8211E_MII_EPAGSR 30 /* Extension Page Select */ | ||
262 | +#define RTL8211E_MII_PAGSEL 31 /* Page Select */ | ||
263 | + | ||
264 | +/* | ||
265 | + * RTL8211E Interrupt Status | ||
266 | + */ | ||
267 | +#define PHY_INT_AUTONEG_ERROR (1 << 15) | ||
268 | +#define PHY_INT_PAGE_RECV (1 << 12) | ||
269 | +#define PHY_INT_AUTONEG_COMPLETE (1 << 11) | ||
270 | +#define PHY_INT_LINK_STATUS (1 << 10) | ||
271 | +#define PHY_INT_ERROR (1 << 9) | ||
272 | +#define PHY_INT_DOWN (1 << 8) | ||
273 | +#define PHY_INT_JABBER (1 << 0) | ||
274 | + | ||
275 | +/* | ||
276 | + * Max frame size for the receiving buffer | ||
277 | + */ | ||
278 | +#define FTGMAC100_MAX_FRAME_SIZE 10240 | ||
279 | + | ||
280 | +/* Limits depending on the type of the frame | ||
66 | + * | 281 | + * |
67 | + * Build rss.bpf.skeleton.h: | 282 | + * 9216 for Jumbo frames (+ 4 for VLAN) |
68 | + * make -f Makefile.ebpf clean all | 283 | + * 1518 for other frames (+ 4 for VLAN) |
69 | + */ | 284 | + */ |
70 | + | 285 | +static int ftgmac100_max_frame_size(FTGMAC100State *s) |
71 | +#include <stddef.h> | 286 | +{ |
72 | +#include <stdbool.h> | 287 | + return (s->maccr & FTGMAC100_MACCR_JUMBO_LF ? 9216 : 1518) + 4; |
73 | +#include <linux/bpf.h> | 288 | +} |
74 | + | 289 | + |
75 | +#include <linux/in.h> | 290 | +static void ftgmac100_update_irq(FTGMAC100State *s) |
76 | +#include <linux/if_ether.h> | 291 | +{ |
77 | +#include <linux/ip.h> | 292 | + qemu_set_irq(s->irq, s->isr & s->ier); |
78 | +#include <linux/ipv6.h> | 293 | +} |
79 | + | 294 | + |
80 | +#include <linux/udp.h> | 295 | +/* |
81 | +#include <linux/tcp.h> | 296 | + * The MII phy could raise a GPIO to the processor which in turn |
82 | + | 297 | + * could be handled as an interrpt by the OS. |
83 | +#include <bpf/bpf_helpers.h> | 298 | + * For now we don't handle any GPIO/interrupt line, so the OS will |
84 | +#include <bpf/bpf_endian.h> | 299 | + * have to poll for the PHY status. |
85 | +#include <linux/virtio_net.h> | 300 | + */ |
86 | + | 301 | +static void phy_update_irq(FTGMAC100State *s) |
87 | +#define INDIRECTION_TABLE_SIZE 128 | 302 | +{ |
88 | +#define HASH_CALCULATION_BUFFER_SIZE 36 | 303 | + ftgmac100_update_irq(s); |
89 | + | 304 | +} |
90 | +struct rss_config_t { | 305 | + |
91 | + __u8 redirect; | 306 | +static void phy_update_link(FTGMAC100State *s) |
92 | + __u8 populate_hash; | 307 | +{ |
93 | + __u32 hash_types; | 308 | + /* Autonegotiation status mirrors link status. */ |
94 | + __u16 indirections_len; | 309 | + if (qemu_get_queue(s->nic)->link_down) { |
95 | + __u16 default_queue; | 310 | + s->phy_status &= ~(MII_BMSR_LINK_ST | MII_BMSR_AN_COMP); |
96 | +} __attribute__((packed)); | 311 | + s->phy_int |= PHY_INT_DOWN; |
97 | + | 312 | + } else { |
98 | +struct toeplitz_key_data_t { | 313 | + s->phy_status |= (MII_BMSR_LINK_ST | MII_BMSR_AN_COMP); |
99 | + __u32 leftmost_32_bits; | 314 | + s->phy_int |= PHY_INT_AUTONEG_COMPLETE; |
100 | + __u8 next_byte[HASH_CALCULATION_BUFFER_SIZE]; | 315 | + } |
316 | + phy_update_irq(s); | ||
317 | +} | ||
318 | + | ||
319 | +static void ftgmac100_set_link(NetClientState *nc) | ||
320 | +{ | ||
321 | + phy_update_link(FTGMAC100(qemu_get_nic_opaque(nc))); | ||
322 | +} | ||
323 | + | ||
324 | +static void phy_reset(FTGMAC100State *s) | ||
325 | +{ | ||
326 | + s->phy_status = (MII_BMSR_100TX_FD | MII_BMSR_100TX_HD | MII_BMSR_10T_FD | | ||
327 | + MII_BMSR_10T_HD | MII_BMSR_EXTSTAT | MII_BMSR_MFPS | | ||
328 | + MII_BMSR_AN_COMP | MII_BMSR_AUTONEG | MII_BMSR_LINK_ST | | ||
329 | + MII_BMSR_EXTCAP); | ||
330 | + s->phy_control = (MII_BMCR_AUTOEN | MII_BMCR_FD | MII_BMCR_SPEED1000); | ||
331 | + s->phy_advertise = (MII_ANAR_PAUSE_ASYM | MII_ANAR_PAUSE | MII_ANAR_TXFD | | ||
332 | + MII_ANAR_TX | MII_ANAR_10FD | MII_ANAR_10 | | ||
333 | + MII_ANAR_CSMACD); | ||
334 | + s->phy_int_mask = 0; | ||
335 | + s->phy_int = 0; | ||
336 | +} | ||
337 | + | ||
338 | +static uint32_t do_phy_read(FTGMAC100State *s, int reg) | ||
339 | +{ | ||
340 | + uint32_t val; | ||
341 | + | ||
342 | + switch (reg) { | ||
343 | + case MII_BMCR: /* Basic Control */ | ||
344 | + val = s->phy_control; | ||
345 | + break; | ||
346 | + case MII_BMSR: /* Basic Status */ | ||
347 | + val = s->phy_status; | ||
348 | + break; | ||
349 | + case MII_PHYID1: /* ID1 */ | ||
350 | + val = RTL8211E_PHYID1; | ||
351 | + break; | ||
352 | + case MII_PHYID2: /* ID2 */ | ||
353 | + val = RTL8211E_PHYID2; | ||
354 | + break; | ||
355 | + case MII_ANAR: /* Auto-neg advertisement */ | ||
356 | + val = s->phy_advertise; | ||
357 | + break; | ||
358 | + case MII_ANLPAR: /* Auto-neg Link Partner Ability */ | ||
359 | + val = (MII_ANLPAR_ACK | MII_ANLPAR_PAUSE | MII_ANLPAR_TXFD | | ||
360 | + MII_ANLPAR_TX | MII_ANLPAR_10FD | MII_ANLPAR_10 | | ||
361 | + MII_ANLPAR_CSMACD); | ||
362 | + break; | ||
363 | + case MII_ANER: /* Auto-neg Expansion */ | ||
364 | + val = MII_ANER_NWAY; | ||
365 | + break; | ||
366 | + case MII_CTRL1000: /* 1000BASE-T control */ | ||
367 | + val = (MII_CTRL1000_HALF | MII_CTRL1000_FULL); | ||
368 | + break; | ||
369 | + case MII_STAT1000: /* 1000BASE-T status */ | ||
370 | + val = MII_STAT1000_FULL; | ||
371 | + break; | ||
372 | + case RTL8211E_MII_INSR: /* Interrupt status. */ | ||
373 | + val = s->phy_int; | ||
374 | + s->phy_int = 0; | ||
375 | + phy_update_irq(s); | ||
376 | + break; | ||
377 | + case RTL8211E_MII_INER: /* Interrupt enable */ | ||
378 | + val = s->phy_int_mask; | ||
379 | + break; | ||
380 | + case RTL8211E_MII_PHYCR: | ||
381 | + case RTL8211E_MII_PHYSR: | ||
382 | + case RTL8211E_MII_RXERC: | ||
383 | + case RTL8211E_MII_LDPSR: | ||
384 | + case RTL8211E_MII_EPAGSR: | ||
385 | + case RTL8211E_MII_PAGSEL: | ||
386 | + qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n", | ||
387 | + __func__, reg); | ||
388 | + val = 0; | ||
389 | + break; | ||
390 | + default: | ||
391 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n", | ||
392 | + __func__, reg); | ||
393 | + val = 0; | ||
394 | + break; | ||
395 | + } | ||
396 | + | ||
397 | + return val; | ||
398 | +} | ||
399 | + | ||
400 | +#define MII_BMCR_MASK (MII_BMCR_LOOPBACK | MII_BMCR_SPEED100 | \ | ||
401 | + MII_BMCR_SPEED | MII_BMCR_AUTOEN | MII_BMCR_PDOWN | \ | ||
402 | + MII_BMCR_FD | MII_BMCR_CTST) | ||
403 | +#define MII_ANAR_MASK 0x2d7f | ||
404 | + | ||
405 | +static void do_phy_write(FTGMAC100State *s, int reg, uint32_t val) | ||
406 | +{ | ||
407 | + switch (reg) { | ||
408 | + case MII_BMCR: /* Basic Control */ | ||
409 | + if (val & MII_BMCR_RESET) { | ||
410 | + phy_reset(s); | ||
411 | + } else { | ||
412 | + s->phy_control = val & MII_BMCR_MASK; | ||
413 | + /* Complete autonegotiation immediately. */ | ||
414 | + if (val & MII_BMCR_AUTOEN) { | ||
415 | + s->phy_status |= MII_BMSR_AN_COMP; | ||
416 | + } | ||
417 | + } | ||
418 | + break; | ||
419 | + case MII_ANAR: /* Auto-neg advertisement */ | ||
420 | + s->phy_advertise = (val & MII_ANAR_MASK) | MII_ANAR_TX; | ||
421 | + break; | ||
422 | + case RTL8211E_MII_INER: /* Interrupt enable */ | ||
423 | + s->phy_int_mask = val & 0xff; | ||
424 | + phy_update_irq(s); | ||
425 | + break; | ||
426 | + case RTL8211E_MII_PHYCR: | ||
427 | + case RTL8211E_MII_PHYSR: | ||
428 | + case RTL8211E_MII_RXERC: | ||
429 | + case RTL8211E_MII_LDPSR: | ||
430 | + case RTL8211E_MII_EPAGSR: | ||
431 | + case RTL8211E_MII_PAGSEL: | ||
432 | + qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n", | ||
433 | + __func__, reg); | ||
434 | + break; | ||
435 | + default: | ||
436 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n", | ||
437 | + __func__, reg); | ||
438 | + break; | ||
439 | + } | ||
440 | +} | ||
441 | + | ||
442 | +static int ftgmac100_read_bd(FTGMAC100Desc *bd, dma_addr_t addr) | ||
443 | +{ | ||
444 | + if (dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd))) { | ||
445 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read descriptor @ 0x%" | ||
446 | + HWADDR_PRIx "\n", __func__, addr); | ||
447 | + return -1; | ||
448 | + } | ||
449 | + bd->des0 = le32_to_cpu(bd->des0); | ||
450 | + bd->des1 = le32_to_cpu(bd->des1); | ||
451 | + bd->des2 = le32_to_cpu(bd->des2); | ||
452 | + bd->des3 = le32_to_cpu(bd->des3); | ||
453 | + return 0; | ||
454 | +} | ||
455 | + | ||
456 | +static int ftgmac100_write_bd(FTGMAC100Desc *bd, dma_addr_t addr) | ||
457 | +{ | ||
458 | + FTGMAC100Desc lebd; | ||
459 | + | ||
460 | + lebd.des0 = cpu_to_le32(bd->des0); | ||
461 | + lebd.des1 = cpu_to_le32(bd->des1); | ||
462 | + lebd.des2 = cpu_to_le32(bd->des2); | ||
463 | + lebd.des3 = cpu_to_le32(bd->des3); | ||
464 | + if (dma_memory_write(&address_space_memory, addr, &lebd, sizeof(lebd))) { | ||
465 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to write descriptor @ 0x%" | ||
466 | + HWADDR_PRIx "\n", __func__, addr); | ||
467 | + return -1; | ||
468 | + } | ||
469 | + return 0; | ||
470 | +} | ||
471 | + | ||
472 | +static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring, | ||
473 | + uint32_t tx_descriptor) | ||
474 | +{ | ||
475 | + int frame_size = 0; | ||
476 | + uint8_t *ptr = s->frame; | ||
477 | + uint32_t addr = tx_descriptor; | ||
478 | + uint32_t flags = 0; | ||
479 | + int max_frame_size = ftgmac100_max_frame_size(s); | ||
480 | + | ||
481 | + while (1) { | ||
482 | + FTGMAC100Desc bd; | ||
483 | + int len; | ||
484 | + | ||
485 | + if (ftgmac100_read_bd(&bd, addr) || | ||
486 | + ((bd.des0 & FTGMAC100_TXDES0_TXDMA_OWN) == 0)) { | ||
487 | + /* Run out of descriptors to transmit. */ | ||
488 | + s->isr |= FTGMAC100_INT_NO_NPTXBUF; | ||
489 | + break; | ||
490 | + } | ||
491 | + | ||
492 | + /* record transmit flags as they are valid only on the first | ||
493 | + * segment */ | ||
494 | + if (bd.des0 & FTGMAC100_TXDES0_FTS) { | ||
495 | + flags = bd.des1; | ||
496 | + } | ||
497 | + | ||
498 | + len = bd.des0 & 0x3FFF; | ||
499 | + if (frame_size + len > max_frame_size) { | ||
500 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %d bytes\n", | ||
501 | + __func__, len); | ||
502 | + len = max_frame_size - frame_size; | ||
503 | + } | ||
504 | + | ||
505 | + if (dma_memory_read(&address_space_memory, bd.des3, ptr, len)) { | ||
506 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read packet @ 0x%x\n", | ||
507 | + __func__, bd.des3); | ||
508 | + s->isr |= FTGMAC100_INT_NO_NPTXBUF; | ||
509 | + break; | ||
510 | + } | ||
511 | + | ||
512 | + ptr += len; | ||
513 | + frame_size += len; | ||
514 | + if (bd.des0 & FTGMAC100_TXDES0_LTS) { | ||
515 | + if (flags & FTGMAC100_TXDES1_IP_CHKSUM) { | ||
516 | + net_checksum_calculate(s->frame, frame_size); | ||
517 | + } | ||
518 | + /* Last buffer in frame. */ | ||
519 | + qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); | ||
520 | + ptr = s->frame; | ||
521 | + frame_size = 0; | ||
522 | + if (flags & FTGMAC100_TXDES1_TXIC) { | ||
523 | + s->isr |= FTGMAC100_INT_XPKT_ETH; | ||
524 | + } | ||
525 | + } | ||
526 | + | ||
527 | + if (flags & FTGMAC100_TXDES1_TX2FIC) { | ||
528 | + s->isr |= FTGMAC100_INT_XPKT_FIFO; | ||
529 | + } | ||
530 | + bd.des0 &= ~FTGMAC100_TXDES0_TXDMA_OWN; | ||
531 | + | ||
532 | + /* Write back the modified descriptor. */ | ||
533 | + ftgmac100_write_bd(&bd, addr); | ||
534 | + /* Advance to the next descriptor. */ | ||
535 | + if (bd.des0 & FTGMAC100_TXDES0_EDOTR) { | ||
536 | + addr = tx_ring; | ||
537 | + } else { | ||
538 | + addr += sizeof(FTGMAC100Desc); | ||
539 | + } | ||
540 | + } | ||
541 | + | ||
542 | + s->tx_descriptor = addr; | ||
543 | + | ||
544 | + ftgmac100_update_irq(s); | ||
545 | +} | ||
546 | + | ||
547 | +static int ftgmac100_can_receive(NetClientState *nc) | ||
548 | +{ | ||
549 | + FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc)); | ||
550 | + FTGMAC100Desc bd; | ||
551 | + | ||
552 | + if ((s->maccr & (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) | ||
553 | + != (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) { | ||
554 | + return 0; | ||
555 | + } | ||
556 | + | ||
557 | + if (ftgmac100_read_bd(&bd, s->rx_descriptor)) { | ||
558 | + return 0; | ||
559 | + } | ||
560 | + return !(bd.des0 & FTGMAC100_RXDES0_RXPKT_RDY); | ||
561 | +} | ||
562 | + | ||
563 | +/* | ||
564 | + * This is purely informative. The HW can poll the RW (and RX) ring | ||
565 | + * buffers for available descriptors but we don't need to trigger a | ||
566 | + * timer for that in qemu. | ||
567 | + */ | ||
568 | +static uint32_t ftgmac100_rxpoll(FTGMAC100State *s) | ||
569 | +{ | ||
570 | + /* Polling times : | ||
571 | + * | ||
572 | + * Speed TIME_SEL=0 TIME_SEL=1 | ||
573 | + * | ||
574 | + * 10 51.2 ms 819.2 ms | ||
575 | + * 100 5.12 ms 81.92 ms | ||
576 | + * 1000 1.024 ms 16.384 ms | ||
577 | + */ | ||
578 | + static const int div[] = { 20, 200, 1000 }; | ||
579 | + | ||
580 | + uint32_t cnt = 1024 * FTGMAC100_APTC_RXPOLL_CNT(s->aptcr); | ||
581 | + uint32_t speed = (s->maccr & FTGMAC100_MACCR_FAST_MODE) ? 1 : 0; | ||
582 | + uint32_t period; | ||
583 | + | ||
584 | + if (s->aptcr & FTGMAC100_APTC_RXPOLL_TIME_SEL) { | ||
585 | + cnt <<= 4; | ||
586 | + } | ||
587 | + | ||
588 | + if (s->maccr & FTGMAC100_MACCR_GIGA_MODE) { | ||
589 | + speed = 2; | ||
590 | + } | ||
591 | + | ||
592 | + period = cnt / div[speed]; | ||
593 | + | ||
594 | + return period; | ||
595 | +} | ||
596 | + | ||
597 | +static void ftgmac100_reset(DeviceState *d) | ||
598 | +{ | ||
599 | + FTGMAC100State *s = FTGMAC100(d); | ||
600 | + | ||
601 | + /* Reset the FTGMAC100 */ | ||
602 | + s->isr = 0; | ||
603 | + s->ier = 0; | ||
604 | + s->rx_enabled = 0; | ||
605 | + s->rx_ring = 0; | ||
606 | + s->rbsr = 0x640; | ||
607 | + s->rx_descriptor = 0; | ||
608 | + s->tx_ring = 0; | ||
609 | + s->tx_descriptor = 0; | ||
610 | + s->math[0] = 0; | ||
611 | + s->math[1] = 0; | ||
612 | + s->itc = 0; | ||
613 | + s->aptcr = 1; | ||
614 | + s->dblac = 0x00022f00; | ||
615 | + s->revr = 0; | ||
616 | + s->fear1 = 0; | ||
617 | + s->tpafcr = 0xf1; | ||
618 | + | ||
619 | + s->maccr = 0; | ||
620 | + s->phycr = 0; | ||
621 | + s->phydata = 0; | ||
622 | + s->fcr = 0x400; | ||
623 | + | ||
624 | + /* and the PHY */ | ||
625 | + phy_reset(s); | ||
626 | +} | ||
627 | + | ||
628 | +static uint64_t ftgmac100_read(void *opaque, hwaddr addr, unsigned size) | ||
629 | +{ | ||
630 | + FTGMAC100State *s = FTGMAC100(opaque); | ||
631 | + | ||
632 | + switch (addr & 0xff) { | ||
633 | + case FTGMAC100_ISR: | ||
634 | + return s->isr; | ||
635 | + case FTGMAC100_IER: | ||
636 | + return s->ier; | ||
637 | + case FTGMAC100_MAC_MADR: | ||
638 | + return (s->conf.macaddr.a[0] << 8) | s->conf.macaddr.a[1]; | ||
639 | + case FTGMAC100_MAC_LADR: | ||
640 | + return ((uint32_t) s->conf.macaddr.a[2] << 24) | | ||
641 | + (s->conf.macaddr.a[3] << 16) | (s->conf.macaddr.a[4] << 8) | | ||
642 | + s->conf.macaddr.a[5]; | ||
643 | + case FTGMAC100_MATH0: | ||
644 | + return s->math[0]; | ||
645 | + case FTGMAC100_MATH1: | ||
646 | + return s->math[1]; | ||
647 | + case FTGMAC100_ITC: | ||
648 | + return s->itc; | ||
649 | + case FTGMAC100_DBLAC: | ||
650 | + return s->dblac; | ||
651 | + case FTGMAC100_REVR: | ||
652 | + return s->revr; | ||
653 | + case FTGMAC100_FEAR1: | ||
654 | + return s->fear1; | ||
655 | + case FTGMAC100_TPAFCR: | ||
656 | + return s->tpafcr; | ||
657 | + case FTGMAC100_FCR: | ||
658 | + return s->fcr; | ||
659 | + case FTGMAC100_MACCR: | ||
660 | + return s->maccr; | ||
661 | + case FTGMAC100_PHYCR: | ||
662 | + return s->phycr; | ||
663 | + case FTGMAC100_PHYDATA: | ||
664 | + return s->phydata; | ||
665 | + | ||
666 | + /* We might want to support these one day */ | ||
667 | + case FTGMAC100_HPTXPD: /* High Priority Transmit Poll Demand */ | ||
668 | + case FTGMAC100_HPTXR_BADR: /* High Priority Transmit Ring Base Address */ | ||
669 | + case FTGMAC100_MACSR: /* MAC Status Register (MACSR) */ | ||
670 | + qemu_log_mask(LOG_UNIMP, "%s: read to unimplemented register 0x%" | ||
671 | + HWADDR_PRIx "\n", __func__, addr); | ||
672 | + return 0; | ||
673 | + default: | ||
674 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset 0x%" | ||
675 | + HWADDR_PRIx "\n", __func__, addr); | ||
676 | + return 0; | ||
677 | + } | ||
678 | +} | ||
679 | + | ||
680 | +static void ftgmac100_write(void *opaque, hwaddr addr, | ||
681 | + uint64_t value, unsigned size) | ||
682 | +{ | ||
683 | + FTGMAC100State *s = FTGMAC100(opaque); | ||
684 | + int reg; | ||
685 | + | ||
686 | + switch (addr & 0xff) { | ||
687 | + case FTGMAC100_ISR: /* Interrupt status */ | ||
688 | + s->isr &= ~value; | ||
689 | + break; | ||
690 | + case FTGMAC100_IER: /* Interrupt control */ | ||
691 | + s->ier = value; | ||
692 | + break; | ||
693 | + case FTGMAC100_MAC_MADR: /* MAC */ | ||
694 | + s->conf.macaddr.a[0] = value >> 8; | ||
695 | + s->conf.macaddr.a[1] = value; | ||
696 | + break; | ||
697 | + case FTGMAC100_MAC_LADR: | ||
698 | + s->conf.macaddr.a[2] = value >> 24; | ||
699 | + s->conf.macaddr.a[3] = value >> 16; | ||
700 | + s->conf.macaddr.a[4] = value >> 8; | ||
701 | + s->conf.macaddr.a[5] = value; | ||
702 | + break; | ||
703 | + case FTGMAC100_MATH0: /* Multicast Address Hash Table 0 */ | ||
704 | + s->math[0] = value; | ||
705 | + break; | ||
706 | + case FTGMAC100_MATH1: /* Multicast Address Hash Table 1 */ | ||
707 | + s->math[1] = value; | ||
708 | + break; | ||
709 | + case FTGMAC100_ITC: /* TODO: Interrupt Timer Control */ | ||
710 | + s->itc = value; | ||
711 | + break; | ||
712 | + case FTGMAC100_RXR_BADR: /* Ring buffer address */ | ||
713 | + s->rx_ring = value; | ||
714 | + s->rx_descriptor = s->rx_ring; | ||
715 | + break; | ||
716 | + | ||
717 | + case FTGMAC100_RBSR: /* DMA buffer size */ | ||
718 | + s->rbsr = value; | ||
719 | + break; | ||
720 | + | ||
721 | + case FTGMAC100_NPTXR_BADR: /* Transmit buffer address */ | ||
722 | + s->tx_ring = value; | ||
723 | + s->tx_descriptor = s->tx_ring; | ||
724 | + break; | ||
725 | + | ||
726 | + case FTGMAC100_NPTXPD: /* Trigger transmit */ | ||
727 | + if ((s->maccr & (FTGMAC100_MACCR_TXDMA_EN | FTGMAC100_MACCR_TXMAC_EN)) | ||
728 | + == (FTGMAC100_MACCR_TXDMA_EN | FTGMAC100_MACCR_TXMAC_EN)) { | ||
729 | + /* TODO: high priority tx ring */ | ||
730 | + ftgmac100_do_tx(s, s->tx_ring, s->tx_descriptor); | ||
731 | + } | ||
732 | + if (ftgmac100_can_receive(qemu_get_queue(s->nic))) { | ||
733 | + qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
734 | + } | ||
735 | + break; | ||
736 | + | ||
737 | + case FTGMAC100_RXPD: /* Receive Poll Demand Register */ | ||
738 | + if (ftgmac100_can_receive(qemu_get_queue(s->nic))) { | ||
739 | + qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
740 | + } | ||
741 | + break; | ||
742 | + | ||
743 | + case FTGMAC100_APTC: /* Automatic polling */ | ||
744 | + s->aptcr = value; | ||
745 | + | ||
746 | + if (FTGMAC100_APTC_RXPOLL_CNT(s->aptcr)) { | ||
747 | + ftgmac100_rxpoll(s); | ||
748 | + } | ||
749 | + | ||
750 | + if (FTGMAC100_APTC_TXPOLL_CNT(s->aptcr)) { | ||
751 | + qemu_log_mask(LOG_UNIMP, "%s: no transmit polling\n", __func__); | ||
752 | + } | ||
753 | + break; | ||
754 | + | ||
755 | + case FTGMAC100_MACCR: /* MAC Device control */ | ||
756 | + s->maccr = value; | ||
757 | + if (value & FTGMAC100_MACCR_SW_RST) { | ||
758 | + ftgmac100_reset(DEVICE(s)); | ||
759 | + } | ||
760 | + | ||
761 | + if (ftgmac100_can_receive(qemu_get_queue(s->nic))) { | ||
762 | + qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
763 | + } | ||
764 | + break; | ||
765 | + | ||
766 | + case FTGMAC100_PHYCR: /* PHY Device control */ | ||
767 | + reg = FTGMAC100_PHYCR_REG(value); | ||
768 | + s->phycr = value; | ||
769 | + if (value & FTGMAC100_PHYCR_MIIWR) { | ||
770 | + do_phy_write(s, reg, s->phydata & 0xffff); | ||
771 | + s->phycr &= ~FTGMAC100_PHYCR_MIIWR; | ||
772 | + } else { | ||
773 | + s->phydata = do_phy_read(s, reg) << 16; | ||
774 | + s->phycr &= ~FTGMAC100_PHYCR_MIIRD; | ||
775 | + } | ||
776 | + break; | ||
777 | + case FTGMAC100_PHYDATA: | ||
778 | + s->phydata = value & 0xffff; | ||
779 | + break; | ||
780 | + case FTGMAC100_DBLAC: /* DMA Burst Length and Arbitration Control */ | ||
781 | + s->dblac = value; | ||
782 | + break; | ||
783 | + case FTGMAC100_REVR: /* Feature Register */ | ||
784 | + /* TODO: Only Old MDIO interface is supported */ | ||
785 | + s->revr = value & ~FTGMAC100_REVR_NEW_MDIO_INTERFACE; | ||
786 | + break; | ||
787 | + case FTGMAC100_FEAR1: /* Feature Register 1 */ | ||
788 | + s->fear1 = value; | ||
789 | + break; | ||
790 | + case FTGMAC100_TPAFCR: /* Transmit Priority Arbitration and FIFO Control */ | ||
791 | + s->tpafcr = value; | ||
792 | + break; | ||
793 | + case FTGMAC100_FCR: /* Flow Control */ | ||
794 | + s->fcr = value; | ||
795 | + break; | ||
796 | + | ||
797 | + case FTGMAC100_HPTXPD: /* High Priority Transmit Poll Demand */ | ||
798 | + case FTGMAC100_HPTXR_BADR: /* High Priority Transmit Ring Base Address */ | ||
799 | + case FTGMAC100_MACSR: /* MAC Status Register (MACSR) */ | ||
800 | + qemu_log_mask(LOG_UNIMP, "%s: write to unimplemented register 0x%" | ||
801 | + HWADDR_PRIx "\n", __func__, addr); | ||
802 | + break; | ||
803 | + default: | ||
804 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset 0x%" | ||
805 | + HWADDR_PRIx "\n", __func__, addr); | ||
806 | + break; | ||
807 | + } | ||
808 | + | ||
809 | + ftgmac100_update_irq(s); | ||
810 | +} | ||
811 | + | ||
812 | +static int ftgmac100_filter(FTGMAC100State *s, const uint8_t *buf, size_t len) | ||
813 | +{ | ||
814 | + unsigned mcast_idx; | ||
815 | + | ||
816 | + if (s->maccr & FTGMAC100_MACCR_RX_ALL) { | ||
817 | + return 1; | ||
818 | + } | ||
819 | + | ||
820 | + switch (get_eth_packet_type(PKT_GET_ETH_HDR(buf))) { | ||
821 | + case ETH_PKT_BCAST: | ||
822 | + if (!(s->maccr & FTGMAC100_MACCR_RX_BROADPKT)) { | ||
823 | + return 0; | ||
824 | + } | ||
825 | + break; | ||
826 | + case ETH_PKT_MCAST: | ||
827 | + if (!(s->maccr & FTGMAC100_MACCR_RX_MULTIPKT)) { | ||
828 | + if (!(s->maccr & FTGMAC100_MACCR_HT_MULTI_EN)) { | ||
829 | + return 0; | ||
830 | + } | ||
831 | + | ||
832 | + /* TODO: this does not seem to work for ftgmac100 */ | ||
833 | + mcast_idx = compute_mcast_idx(buf); | ||
834 | + if (!(s->math[mcast_idx / 32] & (1 << (mcast_idx % 32)))) { | ||
835 | + return 0; | ||
836 | + } | ||
837 | + } | ||
838 | + break; | ||
839 | + case ETH_PKT_UCAST: | ||
840 | + if (memcmp(s->conf.macaddr.a, buf, 6)) { | ||
841 | + return 0; | ||
842 | + } | ||
843 | + break; | ||
844 | + } | ||
845 | + | ||
846 | + return 1; | ||
847 | +} | ||
848 | + | ||
849 | +static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf, | ||
850 | + size_t len) | ||
851 | +{ | ||
852 | + FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc)); | ||
853 | + FTGMAC100Desc bd; | ||
854 | + uint32_t flags = 0; | ||
855 | + uint32_t addr; | ||
856 | + uint32_t crc; | ||
857 | + uint32_t buf_addr; | ||
858 | + uint8_t *crc_ptr; | ||
859 | + uint32_t buf_len; | ||
860 | + size_t size = len; | ||
861 | + uint32_t first = FTGMAC100_RXDES0_FRS; | ||
862 | + int max_frame_size = ftgmac100_max_frame_size(s); | ||
863 | + | ||
864 | + if ((s->maccr & (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) | ||
865 | + != (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) { | ||
866 | + return -1; | ||
867 | + } | ||
868 | + | ||
869 | + /* TODO : Pad to minimum Ethernet frame length */ | ||
870 | + /* handle small packets. */ | ||
871 | + if (size < 10) { | ||
872 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dropped frame of %zd bytes\n", | ||
873 | + __func__, size); | ||
874 | + return size; | ||
875 | + } | ||
876 | + | ||
877 | + if (size < 64 && !(s->maccr & FTGMAC100_MACCR_RX_RUNT)) { | ||
878 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dropped runt frame of %zd bytes\n", | ||
879 | + __func__, size); | ||
880 | + return size; | ||
881 | + } | ||
882 | + | ||
883 | + if (!ftgmac100_filter(s, buf, size)) { | ||
884 | + return size; | ||
885 | + } | ||
886 | + | ||
887 | + /* 4 bytes for the CRC. */ | ||
888 | + size += 4; | ||
889 | + crc = cpu_to_be32(crc32(~0, buf, size)); | ||
890 | + crc_ptr = (uint8_t *) &crc; | ||
891 | + | ||
892 | + /* Huge frames are truncated. */ | ||
893 | + if (size > max_frame_size) { | ||
894 | + size = max_frame_size; | ||
895 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %zd bytes\n", | ||
896 | + __func__, size); | ||
897 | + flags |= FTGMAC100_RXDES0_FTL; | ||
898 | + } | ||
899 | + | ||
900 | + switch (get_eth_packet_type(PKT_GET_ETH_HDR(buf))) { | ||
901 | + case ETH_PKT_BCAST: | ||
902 | + flags |= FTGMAC100_RXDES0_BROADCAST; | ||
903 | + break; | ||
904 | + case ETH_PKT_MCAST: | ||
905 | + flags |= FTGMAC100_RXDES0_MULTICAST; | ||
906 | + break; | ||
907 | + case ETH_PKT_UCAST: | ||
908 | + break; | ||
909 | + } | ||
910 | + | ||
911 | + addr = s->rx_descriptor; | ||
912 | + while (size > 0) { | ||
913 | + if (!ftgmac100_can_receive(nc)) { | ||
914 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unexpected packet\n", __func__); | ||
915 | + return -1; | ||
916 | + } | ||
917 | + | ||
918 | + if (ftgmac100_read_bd(&bd, addr) || | ||
919 | + (bd.des0 & FTGMAC100_RXDES0_RXPKT_RDY)) { | ||
920 | + /* No descriptors available. Bail out. */ | ||
921 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Lost end of frame\n", | ||
922 | + __func__); | ||
923 | + s->isr |= FTGMAC100_INT_NO_RXBUF; | ||
924 | + break; | ||
925 | + } | ||
926 | + buf_len = (size <= s->rbsr) ? size : s->rbsr; | ||
927 | + bd.des0 |= buf_len & 0x3fff; | ||
928 | + size -= buf_len; | ||
929 | + | ||
930 | + /* The last 4 bytes are the CRC. */ | ||
931 | + if (size < 4) { | ||
932 | + buf_len += size - 4; | ||
933 | + } | ||
934 | + buf_addr = bd.des3; | ||
935 | + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); | ||
936 | + buf += buf_len; | ||
937 | + if (size < 4) { | ||
938 | + dma_memory_write(&address_space_memory, buf_addr + buf_len, | ||
939 | + crc_ptr, 4 - size); | ||
940 | + crc_ptr += 4 - size; | ||
941 | + } | ||
942 | + | ||
943 | + bd.des0 |= first | FTGMAC100_RXDES0_RXPKT_RDY; | ||
944 | + first = 0; | ||
945 | + if (size == 0) { | ||
946 | + /* Last buffer in frame. */ | ||
947 | + bd.des0 |= flags | FTGMAC100_RXDES0_LRS; | ||
948 | + s->isr |= FTGMAC100_INT_RPKT_BUF; | ||
949 | + } else { | ||
950 | + s->isr |= FTGMAC100_INT_RPKT_FIFO; | ||
951 | + } | ||
952 | + ftgmac100_write_bd(&bd, addr); | ||
953 | + if (bd.des0 & FTGMAC100_RXDES0_EDORR) { | ||
954 | + addr = s->rx_ring; | ||
955 | + } else { | ||
956 | + addr += sizeof(FTGMAC100Desc); | ||
957 | + } | ||
958 | + } | ||
959 | + s->rx_descriptor = addr; | ||
960 | + | ||
961 | + ftgmac100_update_irq(s); | ||
962 | + return len; | ||
963 | +} | ||
964 | + | ||
965 | +static const MemoryRegionOps ftgmac100_ops = { | ||
966 | + .read = ftgmac100_read, | ||
967 | + .write = ftgmac100_write, | ||
968 | + .valid.min_access_size = 4, | ||
969 | + .valid.max_access_size = 4, | ||
970 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
101 | +}; | 971 | +}; |
102 | + | 972 | + |
103 | +struct packet_hash_info_t { | 973 | +static void ftgmac100_cleanup(NetClientState *nc) |
104 | + __u8 is_ipv4; | 974 | +{ |
105 | + __u8 is_ipv6; | 975 | + FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc)); |
106 | + __u8 is_udp; | 976 | + |
107 | + __u8 is_tcp; | 977 | + s->nic = NULL; |
108 | + __u8 is_ipv6_ext_src; | 978 | +} |
109 | + __u8 is_ipv6_ext_dst; | 979 | + |
110 | + __u8 is_fragmented; | 980 | +static NetClientInfo net_ftgmac100_info = { |
111 | + | 981 | + .type = NET_CLIENT_DRIVER_NIC, |
112 | + __u16 src_port; | 982 | + .size = sizeof(NICState), |
113 | + __u16 dst_port; | 983 | + .can_receive = ftgmac100_can_receive, |
114 | + | 984 | + .receive = ftgmac100_receive, |
115 | + union { | 985 | + .cleanup = ftgmac100_cleanup, |
116 | + struct { | 986 | + .link_status_changed = ftgmac100_set_link, |
117 | + __be32 in_src; | ||
118 | + __be32 in_dst; | ||
119 | + }; | ||
120 | + | ||
121 | + struct { | ||
122 | + struct in6_addr in6_src; | ||
123 | + struct in6_addr in6_dst; | ||
124 | + struct in6_addr in6_ext_src; | ||
125 | + struct in6_addr in6_ext_dst; | ||
126 | + }; | ||
127 | + }; | ||
128 | +}; | 987 | +}; |
129 | + | 988 | + |
130 | +struct bpf_map_def SEC("maps") | 989 | +static void ftgmac100_realize(DeviceState *dev, Error **errp) |
131 | +tap_rss_map_configurations = { | 990 | +{ |
132 | + .type = BPF_MAP_TYPE_ARRAY, | 991 | + FTGMAC100State *s = FTGMAC100(dev); |
133 | + .key_size = sizeof(__u32), | 992 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
134 | + .value_size = sizeof(struct rss_config_t), | 993 | + |
135 | + .max_entries = 1, | 994 | + memory_region_init_io(&s->iomem, OBJECT(dev), &ftgmac100_ops, s, |
995 | + TYPE_FTGMAC100, 0x2000); | ||
996 | + sysbus_init_mmio(sbd, &s->iomem); | ||
997 | + sysbus_init_irq(sbd, &s->irq); | ||
998 | + qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
999 | + | ||
1000 | + s->conf.peers.ncs[0] = nd_table[0].netdev; | ||
1001 | + | ||
1002 | + s->nic = qemu_new_nic(&net_ftgmac100_info, &s->conf, | ||
1003 | + object_get_typename(OBJECT(dev)), DEVICE(dev)->id, | ||
1004 | + s); | ||
1005 | + qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); | ||
1006 | + | ||
1007 | + s->frame = g_malloc(FTGMAC100_MAX_FRAME_SIZE); | ||
1008 | +} | ||
1009 | + | ||
1010 | +static const VMStateDescription vmstate_ftgmac100 = { | ||
1011 | + .name = TYPE_FTGMAC100, | ||
1012 | + .version_id = 1, | ||
1013 | + .minimum_version_id = 1, | ||
1014 | + .fields = (VMStateField[]) { | ||
1015 | + VMSTATE_UINT32(irq_state, FTGMAC100State), | ||
1016 | + VMSTATE_UINT32(isr, FTGMAC100State), | ||
1017 | + VMSTATE_UINT32(ier, FTGMAC100State), | ||
1018 | + VMSTATE_UINT32(rx_enabled, FTGMAC100State), | ||
1019 | + VMSTATE_UINT32(rx_ring, FTGMAC100State), | ||
1020 | + VMSTATE_UINT32(rbsr, FTGMAC100State), | ||
1021 | + VMSTATE_UINT32(tx_ring, FTGMAC100State), | ||
1022 | + VMSTATE_UINT32(rx_descriptor, FTGMAC100State), | ||
1023 | + VMSTATE_UINT32(tx_descriptor, FTGMAC100State), | ||
1024 | + VMSTATE_UINT32_ARRAY(math, FTGMAC100State, 2), | ||
1025 | + VMSTATE_UINT32(itc, FTGMAC100State), | ||
1026 | + VMSTATE_UINT32(aptcr, FTGMAC100State), | ||
1027 | + VMSTATE_UINT32(dblac, FTGMAC100State), | ||
1028 | + VMSTATE_UINT32(revr, FTGMAC100State), | ||
1029 | + VMSTATE_UINT32(fear1, FTGMAC100State), | ||
1030 | + VMSTATE_UINT32(tpafcr, FTGMAC100State), | ||
1031 | + VMSTATE_UINT32(maccr, FTGMAC100State), | ||
1032 | + VMSTATE_UINT32(phycr, FTGMAC100State), | ||
1033 | + VMSTATE_UINT32(phydata, FTGMAC100State), | ||
1034 | + VMSTATE_UINT32(fcr, FTGMAC100State), | ||
1035 | + VMSTATE_UINT32(phy_status, FTGMAC100State), | ||
1036 | + VMSTATE_UINT32(phy_control, FTGMAC100State), | ||
1037 | + VMSTATE_UINT32(phy_advertise, FTGMAC100State), | ||
1038 | + VMSTATE_UINT32(phy_int, FTGMAC100State), | ||
1039 | + VMSTATE_UINT32(phy_int_mask, FTGMAC100State), | ||
1040 | + VMSTATE_END_OF_LIST() | ||
1041 | + } | ||
136 | +}; | 1042 | +}; |
137 | + | 1043 | + |
138 | +struct bpf_map_def SEC("maps") | 1044 | +static Property ftgmac100_properties[] = { |
139 | +tap_rss_map_toeplitz_key = { | 1045 | + DEFINE_NIC_PROPERTIES(FTGMAC100State, conf), |
140 | + .type = BPF_MAP_TYPE_ARRAY, | 1046 | + DEFINE_PROP_END_OF_LIST(), |
141 | + .key_size = sizeof(__u32), | ||
142 | + .value_size = sizeof(struct toeplitz_key_data_t), | ||
143 | + .max_entries = 1, | ||
144 | +}; | 1047 | +}; |
145 | + | 1048 | + |
146 | +struct bpf_map_def SEC("maps") | 1049 | +static void ftgmac100_class_init(ObjectClass *klass, void *data) |
147 | +tap_rss_map_indirection_table = { | 1050 | +{ |
148 | + .type = BPF_MAP_TYPE_ARRAY, | 1051 | + DeviceClass *dc = DEVICE_CLASS(klass); |
149 | + .key_size = sizeof(__u32), | 1052 | + |
150 | + .value_size = sizeof(__u16), | 1053 | + dc->vmsd = &vmstate_ftgmac100; |
151 | + .max_entries = INDIRECTION_TABLE_SIZE, | 1054 | + dc->reset = ftgmac100_reset; |
1055 | + dc->props = ftgmac100_properties; | ||
1056 | + set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); | ||
1057 | + dc->realize = ftgmac100_realize; | ||
1058 | + dc->desc = "Faraday FTGMAC100 Gigabit Ethernet emulation"; | ||
1059 | +} | ||
1060 | + | ||
1061 | +static const TypeInfo ftgmac100_info = { | ||
1062 | + .name = TYPE_FTGMAC100, | ||
1063 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1064 | + .instance_size = sizeof(FTGMAC100State), | ||
1065 | + .class_init = ftgmac100_class_init, | ||
152 | +}; | 1066 | +}; |
153 | + | 1067 | + |
154 | +static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_written, | 1068 | +static void ftgmac100_register_types(void) |
155 | + const void *ptr, size_t size) { | 1069 | +{ |
156 | + __builtin_memcpy(&rss_input[*bytes_written], ptr, size); | 1070 | + type_register_static(&ftgmac100_info); |
157 | + *bytes_written += size; | 1071 | +} |
158 | +} | 1072 | + |
159 | + | 1073 | +type_init(ftgmac100_register_types) |
160 | +static inline | 1074 | diff --git a/include/hw/net/ftgmac100.h b/include/hw/net/ftgmac100.h |
161 | +void net_toeplitz_add(__u32 *result, | 1075 | new file mode 100644 |
162 | + __u8 *input, | 1076 | index XXXXXXX..XXXXXXX |
163 | + __u32 len | 1077 | --- /dev/null |
164 | + , struct toeplitz_key_data_t *key) { | 1078 | +++ b/include/hw/net/ftgmac100.h |
165 | + | 1079 | @@ -XXX,XX +XXX,XX @@ |
166 | + __u32 accumulator = *result; | 1080 | +/* |
167 | + __u32 leftmost_32_bits = key->leftmost_32_bits; | 1081 | + * Faraday FTGMAC100 Gigabit Ethernet |
168 | + __u32 byte; | 1082 | + * |
169 | + | 1083 | + * Copyright (C) 2016-2017, IBM Corporation. |
170 | + for (byte = 0; byte < HASH_CALCULATION_BUFFER_SIZE; byte++) { | 1084 | + * |
171 | + __u8 input_byte = input[byte]; | 1085 | + * This code is licensed under the GPL version 2 or later. See the |
172 | + __u8 key_byte = key->next_byte[byte]; | 1086 | + * COPYING file in the top-level directory. |
173 | + __u8 bit; | 1087 | + */ |
174 | + | 1088 | + |
175 | + for (bit = 0; bit < 8; bit++) { | 1089 | +#ifndef FTGMAC100_H |
176 | + if (input_byte & (1 << 7)) { | 1090 | +#define FTGMAC100_H |
177 | + accumulator ^= leftmost_32_bits; | 1091 | + |
178 | + } | 1092 | +#define TYPE_FTGMAC100 "ftgmac100" |
179 | + | 1093 | +#define FTGMAC100(obj) OBJECT_CHECK(FTGMAC100State, (obj), TYPE_FTGMAC100) |
180 | + leftmost_32_bits = | 1094 | + |
181 | + (leftmost_32_bits << 1) | ((key_byte & (1 << 7)) >> 7); | 1095 | +#include "hw/sysbus.h" |
182 | + | 1096 | +#include "net/net.h" |
183 | + input_byte <<= 1; | 1097 | + |
184 | + key_byte <<= 1; | 1098 | +typedef struct FTGMAC100State { |
185 | + } | 1099 | + /*< private >*/ |
186 | + } | 1100 | + SysBusDevice parent_obj; |
187 | + | 1101 | + |
188 | + *result = accumulator; | 1102 | + /*< public >*/ |
189 | +} | 1103 | + NICState *nic; |
190 | + | 1104 | + NICConf conf; |
191 | + | 1105 | + qemu_irq irq; |
192 | +static inline int ip6_extension_header_type(__u8 hdr_type) | 1106 | + MemoryRegion iomem; |
193 | +{ | 1107 | + |
194 | + switch (hdr_type) { | 1108 | + uint8_t *frame; |
195 | + case IPPROTO_HOPOPTS: | 1109 | + |
196 | + case IPPROTO_ROUTING: | 1110 | + uint32_t irq_state; |
197 | + case IPPROTO_FRAGMENT: | 1111 | + uint32_t isr; |
198 | + case IPPROTO_ICMPV6: | 1112 | + uint32_t ier; |
199 | + case IPPROTO_NONE: | 1113 | + uint32_t rx_enabled; |
200 | + case IPPROTO_DSTOPTS: | 1114 | + uint32_t rx_ring; |
201 | + case IPPROTO_MH: | 1115 | + uint32_t rx_descriptor; |
202 | + return 1; | 1116 | + uint32_t tx_ring; |
203 | + default: | 1117 | + uint32_t tx_descriptor; |
204 | + return 0; | 1118 | + uint32_t math[2]; |
205 | + } | 1119 | + uint32_t rbsr; |
206 | +} | 1120 | + uint32_t itc; |
207 | +/* | 1121 | + uint32_t aptcr; |
208 | + * According to | 1122 | + uint32_t dblac; |
209 | + * https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml | 1123 | + uint32_t revr; |
210 | + * we expect that there are would be no more than 11 extensions in IPv6 header, | 1124 | + uint32_t fear1; |
211 | + * also there is 27 TLV options for Destination and Hop-by-hop extensions. | 1125 | + uint32_t tpafcr; |
212 | + * Need to choose reasonable amount of maximum extensions/options we may | 1126 | + uint32_t maccr; |
213 | + * check to find ext src/dst. | 1127 | + uint32_t phycr; |
214 | + */ | 1128 | + uint32_t phydata; |
215 | +#define IP6_EXTENSIONS_COUNT 11 | 1129 | + uint32_t fcr; |
216 | +#define IP6_OPTIONS_COUNT 30 | 1130 | + |
217 | + | 1131 | + |
218 | +static inline int parse_ipv6_ext(struct __sk_buff *skb, | 1132 | + uint32_t phy_status; |
219 | + struct packet_hash_info_t *info, | 1133 | + uint32_t phy_control; |
220 | + __u8 *l4_protocol, size_t *l4_offset) | 1134 | + uint32_t phy_advertise; |
221 | +{ | 1135 | + uint32_t phy_int; |
222 | + int err = 0; | 1136 | + uint32_t phy_int_mask; |
223 | + | 1137 | +} FTGMAC100State; |
224 | + if (!ip6_extension_header_type(*l4_protocol)) { | 1138 | + |
225 | + return 0; | 1139 | +#endif |
226 | + } | ||
227 | + | ||
228 | + struct ipv6_opt_hdr ext_hdr = {}; | ||
229 | + | ||
230 | + for (unsigned int i = 0; i < IP6_EXTENSIONS_COUNT; ++i) { | ||
231 | + | ||
232 | + err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_hdr, | ||
233 | + sizeof(ext_hdr), BPF_HDR_START_NET); | ||
234 | + if (err) { | ||
235 | + goto error; | ||
236 | + } | ||
237 | + | ||
238 | + if (*l4_protocol == IPPROTO_ROUTING) { | ||
239 | + struct ipv6_rt_hdr ext_rt = {}; | ||
240 | + | ||
241 | + err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_rt, | ||
242 | + sizeof(ext_rt), BPF_HDR_START_NET); | ||
243 | + if (err) { | ||
244 | + goto error; | ||
245 | + } | ||
246 | + | ||
247 | + if ((ext_rt.type == IPV6_SRCRT_TYPE_2) && | ||
248 | + (ext_rt.hdrlen == sizeof(struct in6_addr) / 8) && | ||
249 | + (ext_rt.segments_left == 1)) { | ||
250 | + | ||
251 | + err = bpf_skb_load_bytes_relative(skb, | ||
252 | + *l4_offset + offsetof(struct rt2_hdr, addr), | ||
253 | + &info->in6_ext_dst, sizeof(info->in6_ext_dst), | ||
254 | + BPF_HDR_START_NET); | ||
255 | + if (err) { | ||
256 | + goto error; | ||
257 | + } | ||
258 | + | ||
259 | + info->is_ipv6_ext_dst = 1; | ||
260 | + } | ||
261 | + | ||
262 | + } else if (*l4_protocol == IPPROTO_DSTOPTS) { | ||
263 | + struct ipv6_opt_t { | ||
264 | + __u8 type; | ||
265 | + __u8 length; | ||
266 | + } __attribute__((packed)) opt = {}; | ||
267 | + | ||
268 | + size_t opt_offset = sizeof(ext_hdr); | ||
269 | + | ||
270 | + for (unsigned int j = 0; j < IP6_OPTIONS_COUNT; ++j) { | ||
271 | + err = bpf_skb_load_bytes_relative(skb, *l4_offset + opt_offset, | ||
272 | + &opt, sizeof(opt), BPF_HDR_START_NET); | ||
273 | + if (err) { | ||
274 | + goto error; | ||
275 | + } | ||
276 | + | ||
277 | + if (opt.type == IPV6_TLV_HAO) { | ||
278 | + err = bpf_skb_load_bytes_relative(skb, | ||
279 | + *l4_offset + opt_offset | ||
280 | + + offsetof(struct ipv6_destopt_hao, addr), | ||
281 | + &info->in6_ext_src, sizeof(info->in6_ext_src), | ||
282 | + BPF_HDR_START_NET); | ||
283 | + if (err) { | ||
284 | + goto error; | ||
285 | + } | ||
286 | + | ||
287 | + info->is_ipv6_ext_src = 1; | ||
288 | + break; | ||
289 | + } | ||
290 | + | ||
291 | + opt_offset += (opt.type == IPV6_TLV_PAD1) ? | ||
292 | + 1 : opt.length + sizeof(opt); | ||
293 | + | ||
294 | + if (opt_offset + 1 >= ext_hdr.hdrlen * 8) { | ||
295 | + break; | ||
296 | + } | ||
297 | + } | ||
298 | + } else if (*l4_protocol == IPPROTO_FRAGMENT) { | ||
299 | + info->is_fragmented = true; | ||
300 | + } | ||
301 | + | ||
302 | + *l4_protocol = ext_hdr.nexthdr; | ||
303 | + *l4_offset += (ext_hdr.hdrlen + 1) * 8; | ||
304 | + | ||
305 | + if (!ip6_extension_header_type(ext_hdr.nexthdr)) { | ||
306 | + return 0; | ||
307 | + } | ||
308 | + } | ||
309 | + | ||
310 | + return 0; | ||
311 | +error: | ||
312 | + return err; | ||
313 | +} | ||
314 | + | ||
315 | +static __be16 parse_eth_type(struct __sk_buff *skb) | ||
316 | +{ | ||
317 | + unsigned int offset = 12; | ||
318 | + __be16 ret = 0; | ||
319 | + int err = 0; | ||
320 | + | ||
321 | + err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret), | ||
322 | + BPF_HDR_START_MAC); | ||
323 | + if (err) { | ||
324 | + return 0; | ||
325 | + } | ||
326 | + | ||
327 | + switch (bpf_ntohs(ret)) { | ||
328 | + case ETH_P_8021AD: | ||
329 | + offset += 4; | ||
330 | + case ETH_P_8021Q: | ||
331 | + offset += 4; | ||
332 | + err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret), | ||
333 | + BPF_HDR_START_MAC); | ||
334 | + default: | ||
335 | + break; | ||
336 | + } | ||
337 | + | ||
338 | + if (err) { | ||
339 | + return 0; | ||
340 | + } | ||
341 | + | ||
342 | + return ret; | ||
343 | +} | ||
344 | + | ||
345 | +static inline int parse_packet(struct __sk_buff *skb, | ||
346 | + struct packet_hash_info_t *info) | ||
347 | +{ | ||
348 | + int err = 0; | ||
349 | + | ||
350 | + if (!info || !skb) { | ||
351 | + return -1; | ||
352 | + } | ||
353 | + | ||
354 | + size_t l4_offset = 0; | ||
355 | + __u8 l4_protocol = 0; | ||
356 | + __u16 l3_protocol = bpf_ntohs(parse_eth_type(skb)); | ||
357 | + if (l3_protocol == 0) { | ||
358 | + err = -1; | ||
359 | + goto error; | ||
360 | + } | ||
361 | + | ||
362 | + if (l3_protocol == ETH_P_IP) { | ||
363 | + info->is_ipv4 = 1; | ||
364 | + | ||
365 | + struct iphdr ip = {}; | ||
366 | + err = bpf_skb_load_bytes_relative(skb, 0, &ip, sizeof(ip), | ||
367 | + BPF_HDR_START_NET); | ||
368 | + if (err) { | ||
369 | + goto error; | ||
370 | + } | ||
371 | + | ||
372 | + info->in_src = ip.saddr; | ||
373 | + info->in_dst = ip.daddr; | ||
374 | + info->is_fragmented = !!ip.frag_off; | ||
375 | + | ||
376 | + l4_protocol = ip.protocol; | ||
377 | + l4_offset = ip.ihl * 4; | ||
378 | + } else if (l3_protocol == ETH_P_IPV6) { | ||
379 | + info->is_ipv6 = 1; | ||
380 | + | ||
381 | + struct ipv6hdr ip6 = {}; | ||
382 | + err = bpf_skb_load_bytes_relative(skb, 0, &ip6, sizeof(ip6), | ||
383 | + BPF_HDR_START_NET); | ||
384 | + if (err) { | ||
385 | + goto error; | ||
386 | + } | ||
387 | + | ||
388 | + info->in6_src = ip6.saddr; | ||
389 | + info->in6_dst = ip6.daddr; | ||
390 | + | ||
391 | + l4_protocol = ip6.nexthdr; | ||
392 | + l4_offset = sizeof(ip6); | ||
393 | + | ||
394 | + err = parse_ipv6_ext(skb, info, &l4_protocol, &l4_offset); | ||
395 | + if (err) { | ||
396 | + goto error; | ||
397 | + } | ||
398 | + } | ||
399 | + | ||
400 | + if (l4_protocol != 0 && !info->is_fragmented) { | ||
401 | + if (l4_protocol == IPPROTO_TCP) { | ||
402 | + info->is_tcp = 1; | ||
403 | + | ||
404 | + struct tcphdr tcp = {}; | ||
405 | + err = bpf_skb_load_bytes_relative(skb, l4_offset, &tcp, sizeof(tcp), | ||
406 | + BPF_HDR_START_NET); | ||
407 | + if (err) { | ||
408 | + goto error; | ||
409 | + } | ||
410 | + | ||
411 | + info->src_port = tcp.source; | ||
412 | + info->dst_port = tcp.dest; | ||
413 | + } else if (l4_protocol == IPPROTO_UDP) { /* TODO: add udplite? */ | ||
414 | + info->is_udp = 1; | ||
415 | + | ||
416 | + struct udphdr udp = {}; | ||
417 | + err = bpf_skb_load_bytes_relative(skb, l4_offset, &udp, sizeof(udp), | ||
418 | + BPF_HDR_START_NET); | ||
419 | + if (err) { | ||
420 | + goto error; | ||
421 | + } | ||
422 | + | ||
423 | + info->src_port = udp.source; | ||
424 | + info->dst_port = udp.dest; | ||
425 | + } | ||
426 | + } | ||
427 | + | ||
428 | + return 0; | ||
429 | + | ||
430 | +error: | ||
431 | + return err; | ||
432 | +} | ||
433 | + | ||
434 | +static inline __u32 calculate_rss_hash(struct __sk_buff *skb, | ||
435 | + struct rss_config_t *config, struct toeplitz_key_data_t *toe) | ||
436 | +{ | ||
437 | + __u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] = {}; | ||
438 | + size_t bytes_written = 0; | ||
439 | + __u32 result = 0; | ||
440 | + int err = 0; | ||
441 | + struct packet_hash_info_t packet_info = {}; | ||
442 | + | ||
443 | + err = parse_packet(skb, &packet_info); | ||
444 | + if (err) { | ||
445 | + return 0; | ||
446 | + } | ||
447 | + | ||
448 | + if (packet_info.is_ipv4) { | ||
449 | + if (packet_info.is_tcp && | ||
450 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4) { | ||
451 | + | ||
452 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
453 | + &packet_info.in_src, | ||
454 | + sizeof(packet_info.in_src)); | ||
455 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
456 | + &packet_info.in_dst, | ||
457 | + sizeof(packet_info.in_dst)); | ||
458 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
459 | + &packet_info.src_port, | ||
460 | + sizeof(packet_info.src_port)); | ||
461 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
462 | + &packet_info.dst_port, | ||
463 | + sizeof(packet_info.dst_port)); | ||
464 | + } else if (packet_info.is_udp && | ||
465 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4) { | ||
466 | + | ||
467 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
468 | + &packet_info.in_src, | ||
469 | + sizeof(packet_info.in_src)); | ||
470 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
471 | + &packet_info.in_dst, | ||
472 | + sizeof(packet_info.in_dst)); | ||
473 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
474 | + &packet_info.src_port, | ||
475 | + sizeof(packet_info.src_port)); | ||
476 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
477 | + &packet_info.dst_port, | ||
478 | + sizeof(packet_info.dst_port)); | ||
479 | + } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) { | ||
480 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
481 | + &packet_info.in_src, | ||
482 | + sizeof(packet_info.in_src)); | ||
483 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
484 | + &packet_info.in_dst, | ||
485 | + sizeof(packet_info.in_dst)); | ||
486 | + } | ||
487 | + } else if (packet_info.is_ipv6) { | ||
488 | + if (packet_info.is_tcp && | ||
489 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv6) { | ||
490 | + | ||
491 | + if (packet_info.is_ipv6_ext_src && | ||
492 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) { | ||
493 | + | ||
494 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
495 | + &packet_info.in6_ext_src, | ||
496 | + sizeof(packet_info.in6_ext_src)); | ||
497 | + } else { | ||
498 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
499 | + &packet_info.in6_src, | ||
500 | + sizeof(packet_info.in6_src)); | ||
501 | + } | ||
502 | + if (packet_info.is_ipv6_ext_dst && | ||
503 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) { | ||
504 | + | ||
505 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
506 | + &packet_info.in6_ext_dst, | ||
507 | + sizeof(packet_info.in6_ext_dst)); | ||
508 | + } else { | ||
509 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
510 | + &packet_info.in6_dst, | ||
511 | + sizeof(packet_info.in6_dst)); | ||
512 | + } | ||
513 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
514 | + &packet_info.src_port, | ||
515 | + sizeof(packet_info.src_port)); | ||
516 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
517 | + &packet_info.dst_port, | ||
518 | + sizeof(packet_info.dst_port)); | ||
519 | + } else if (packet_info.is_udp && | ||
520 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv6) { | ||
521 | + | ||
522 | + if (packet_info.is_ipv6_ext_src && | ||
523 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) { | ||
524 | + | ||
525 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
526 | + &packet_info.in6_ext_src, | ||
527 | + sizeof(packet_info.in6_ext_src)); | ||
528 | + } else { | ||
529 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
530 | + &packet_info.in6_src, | ||
531 | + sizeof(packet_info.in6_src)); | ||
532 | + } | ||
533 | + if (packet_info.is_ipv6_ext_dst && | ||
534 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) { | ||
535 | + | ||
536 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
537 | + &packet_info.in6_ext_dst, | ||
538 | + sizeof(packet_info.in6_ext_dst)); | ||
539 | + } else { | ||
540 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
541 | + &packet_info.in6_dst, | ||
542 | + sizeof(packet_info.in6_dst)); | ||
543 | + } | ||
544 | + | ||
545 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
546 | + &packet_info.src_port, | ||
547 | + sizeof(packet_info.src_port)); | ||
548 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
549 | + &packet_info.dst_port, | ||
550 | + sizeof(packet_info.dst_port)); | ||
551 | + | ||
552 | + } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv6) { | ||
553 | + if (packet_info.is_ipv6_ext_src && | ||
554 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) { | ||
555 | + | ||
556 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
557 | + &packet_info.in6_ext_src, | ||
558 | + sizeof(packet_info.in6_ext_src)); | ||
559 | + } else { | ||
560 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
561 | + &packet_info.in6_src, | ||
562 | + sizeof(packet_info.in6_src)); | ||
563 | + } | ||
564 | + if (packet_info.is_ipv6_ext_dst && | ||
565 | + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) { | ||
566 | + | ||
567 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
568 | + &packet_info.in6_ext_dst, | ||
569 | + sizeof(packet_info.in6_ext_dst)); | ||
570 | + } else { | ||
571 | + net_rx_rss_add_chunk(rss_input, &bytes_written, | ||
572 | + &packet_info.in6_dst, | ||
573 | + sizeof(packet_info.in6_dst)); | ||
574 | + } | ||
575 | + } | ||
576 | + } | ||
577 | + | ||
578 | + if (bytes_written) { | ||
579 | + net_toeplitz_add(&result, rss_input, bytes_written, toe); | ||
580 | + } | ||
581 | + | ||
582 | + return result; | ||
583 | +} | ||
584 | + | ||
585 | +SEC("tun_rss_steering") | ||
586 | +int tun_rss_steering_prog(struct __sk_buff *skb) | ||
587 | +{ | ||
588 | + | ||
589 | + struct rss_config_t *config; | ||
590 | + struct toeplitz_key_data_t *toe; | ||
591 | + | ||
592 | + __u32 key = 0; | ||
593 | + __u32 hash = 0; | ||
594 | + | ||
595 | + config = bpf_map_lookup_elem(&tap_rss_map_configurations, &key); | ||
596 | + toe = bpf_map_lookup_elem(&tap_rss_map_toeplitz_key, &key); | ||
597 | + | ||
598 | + if (config && toe) { | ||
599 | + if (!config->redirect) { | ||
600 | + return config->default_queue; | ||
601 | + } | ||
602 | + | ||
603 | + hash = calculate_rss_hash(skb, config, toe); | ||
604 | + if (hash) { | ||
605 | + __u32 table_idx = hash % config->indirections_len; | ||
606 | + __u16 *queue = 0; | ||
607 | + | ||
608 | + queue = bpf_map_lookup_elem(&tap_rss_map_indirection_table, | ||
609 | + &table_idx); | ||
610 | + | ||
611 | + if (queue) { | ||
612 | + return *queue; | ||
613 | + } | ||
614 | + } | ||
615 | + | ||
616 | + return config->default_queue; | ||
617 | + } | ||
618 | + | ||
619 | + return -1; | ||
620 | +} | ||
621 | + | ||
622 | +char _license[] SEC("license") = "GPL v2"; | ||
623 | -- | 1140 | -- |
624 | 2.7.4 | 1141 | 2.7.4 |
625 | 1142 | ||
626 | 1143 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | For now, that method supported only by Linux TAP. | 3 | The Aspeed SoCs have a different definition of the end of the ring |
4 | Linux TAP uses TUNSETSTEERINGEBPF ioctl. | 4 | buffer bit. Add a property to specify which set of bits should be used |
5 | by the NIC. | ||
5 | 6 | ||
6 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 8 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
8 | --- | 9 | --- |
9 | include/net/net.h | 2 ++ | 10 | hw/net/ftgmac100.c | 17 +++++++++++++++-- |
10 | net/tap-bsd.c | 5 +++++ | 11 | include/hw/net/ftgmac100.h | 4 ++++ |
11 | net/tap-linux.c | 13 +++++++++++++ | 12 | 2 files changed, 19 insertions(+), 2 deletions(-) |
12 | net/tap-solaris.c | 5 +++++ | ||
13 | net/tap-stub.c | 5 +++++ | ||
14 | net/tap.c | 9 +++++++++ | ||
15 | net/tap_int.h | 1 + | ||
16 | 7 files changed, 40 insertions(+) | ||
17 | 13 | ||
18 | diff --git a/include/net/net.h b/include/net/net.h | 14 | diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/net/net.h | 16 | --- a/hw/net/ftgmac100.c |
21 | +++ b/include/net/net.h | 17 | +++ b/hw/net/ftgmac100.c |
22 | @@ -XXX,XX +XXX,XX @@ typedef int (SetVnetBE)(NetClientState *, bool); | 18 | @@ -XXX,XX +XXX,XX @@ |
23 | typedef struct SocketReadState SocketReadState; | 19 | #define FTGMAC100_TXDES0_CRC_ERR (1 << 19) |
24 | typedef void (SocketReadStateFinalize)(SocketReadState *rs); | 20 | #define FTGMAC100_TXDES0_LTS (1 << 28) |
25 | typedef void (NetAnnounce)(NetClientState *); | 21 | #define FTGMAC100_TXDES0_FTS (1 << 29) |
26 | +typedef bool (SetSteeringEBPF)(NetClientState *, int); | 22 | +#define FTGMAC100_TXDES0_EDOTR_ASPEED (1 << 30) |
27 | 23 | #define FTGMAC100_TXDES0_TXDMA_OWN (1 << 31) | |
28 | typedef struct NetClientInfo { | 24 | |
29 | NetClientDriver type; | 25 | #define FTGMAC100_TXDES1_VLANTAG_CI(x) ((x) & 0xffff) |
30 | @@ -XXX,XX +XXX,XX @@ typedef struct NetClientInfo { | 26 | @@ -XXX,XX +XXX,XX @@ |
31 | SetVnetLE *set_vnet_le; | 27 | #define FTGMAC100_RXDES0_PAUSE_FRAME (1 << 25) |
32 | SetVnetBE *set_vnet_be; | 28 | #define FTGMAC100_RXDES0_LRS (1 << 28) |
33 | NetAnnounce *announce; | 29 | #define FTGMAC100_RXDES0_FRS (1 << 29) |
34 | + SetSteeringEBPF *set_steering_ebpf; | 30 | +#define FTGMAC100_RXDES0_EDORR_ASPEED (1 << 30) |
35 | } NetClientInfo; | 31 | #define FTGMAC100_RXDES0_RXPKT_RDY (1 << 31) |
36 | 32 | ||
37 | struct NetClientState { | 33 | #define FTGMAC100_RXDES1_VLANTAG_CI 0xffff |
38 | diff --git a/net/tap-bsd.c b/net/tap-bsd.c | 34 | @@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring, |
39 | index XXXXXXX..XXXXXXX 100644 | 35 | /* Write back the modified descriptor. */ |
40 | --- a/net/tap-bsd.c | 36 | ftgmac100_write_bd(&bd, addr); |
41 | +++ b/net/tap-bsd.c | 37 | /* Advance to the next descriptor. */ |
42 | @@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname) | 38 | - if (bd.des0 & FTGMAC100_TXDES0_EDOTR) { |
43 | { | 39 | + if (bd.des0 & s->txdes0_edotr) { |
44 | return -1; | 40 | addr = tx_ring; |
45 | } | 41 | } else { |
46 | + | 42 | addr += sizeof(FTGMAC100Desc); |
47 | +int tap_fd_set_steering_ebpf(int fd, int prog_fd) | 43 | @@ -XXX,XX +XXX,XX @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf, |
48 | +{ | 44 | s->isr |= FTGMAC100_INT_RPKT_FIFO; |
49 | + return -1; | 45 | } |
50 | +} | 46 | ftgmac100_write_bd(&bd, addr); |
51 | diff --git a/net/tap-linux.c b/net/tap-linux.c | 47 | - if (bd.des0 & FTGMAC100_RXDES0_EDORR) { |
52 | index XXXXXXX..XXXXXXX 100644 | 48 | + if (bd.des0 & s->rxdes0_edorr) { |
53 | --- a/net/tap-linux.c | 49 | addr = s->rx_ring; |
54 | +++ b/net/tap-linux.c | 50 | } else { |
55 | @@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname) | 51 | addr += sizeof(FTGMAC100Desc); |
56 | pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name); | 52 | @@ -XXX,XX +XXX,XX @@ static void ftgmac100_realize(DeviceState *dev, Error **errp) |
57 | return 0; | 53 | FTGMAC100State *s = FTGMAC100(dev); |
58 | } | 54 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
59 | + | 55 | |
60 | +int tap_fd_set_steering_ebpf(int fd, int prog_fd) | 56 | + if (s->aspeed) { |
61 | +{ | 57 | + s->txdes0_edotr = FTGMAC100_TXDES0_EDOTR_ASPEED; |
62 | + if (ioctl(fd, TUNSETSTEERINGEBPF, (void *) &prog_fd) != 0) { | 58 | + s->rxdes0_edorr = FTGMAC100_RXDES0_EDORR_ASPEED; |
63 | + error_report("Issue while setting TUNSETSTEERINGEBPF:" | 59 | + } else { |
64 | + " %s with fd: %d, prog_fd: %d", | 60 | + s->txdes0_edotr = FTGMAC100_TXDES0_EDOTR; |
65 | + strerror(errno), fd, prog_fd); | 61 | + s->rxdes0_edorr = FTGMAC100_RXDES0_EDORR; |
66 | + | ||
67 | + return -1; | ||
68 | + } | 62 | + } |
69 | + | 63 | + |
70 | + return 0; | 64 | memory_region_init_io(&s->iomem, OBJECT(dev), &ftgmac100_ops, s, |
71 | +} | 65 | TYPE_FTGMAC100, 0x2000); |
72 | diff --git a/net/tap-solaris.c b/net/tap-solaris.c | 66 | sysbus_init_mmio(sbd, &s->iomem); |
67 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_ftgmac100 = { | ||
68 | VMSTATE_UINT32(phy_advertise, FTGMAC100State), | ||
69 | VMSTATE_UINT32(phy_int, FTGMAC100State), | ||
70 | VMSTATE_UINT32(phy_int_mask, FTGMAC100State), | ||
71 | + VMSTATE_UINT32(txdes0_edotr, FTGMAC100State), | ||
72 | + VMSTATE_UINT32(rxdes0_edorr, FTGMAC100State), | ||
73 | VMSTATE_END_OF_LIST() | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | static Property ftgmac100_properties[] = { | ||
78 | + DEFINE_PROP_BOOL("aspeed", FTGMAC100State, aspeed, false), | ||
79 | DEFINE_NIC_PROPERTIES(FTGMAC100State, conf), | ||
80 | DEFINE_PROP_END_OF_LIST(), | ||
81 | }; | ||
82 | diff --git a/include/hw/net/ftgmac100.h b/include/hw/net/ftgmac100.h | ||
73 | index XXXXXXX..XXXXXXX 100644 | 83 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/net/tap-solaris.c | 84 | --- a/include/hw/net/ftgmac100.h |
75 | +++ b/net/tap-solaris.c | 85 | +++ b/include/hw/net/ftgmac100.h |
76 | @@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname) | 86 | @@ -XXX,XX +XXX,XX @@ typedef struct FTGMAC100State { |
77 | { | 87 | uint32_t phy_advertise; |
78 | return -1; | 88 | uint32_t phy_int; |
79 | } | 89 | uint32_t phy_int_mask; |
80 | + | 90 | + |
81 | +int tap_fd_set_steering_ebpf(int fd, int prog_fd) | 91 | + bool aspeed; |
82 | +{ | 92 | + uint32_t txdes0_edotr; |
83 | + return -1; | 93 | + uint32_t rxdes0_edorr; |
84 | +} | 94 | } FTGMAC100State; |
85 | diff --git a/net/tap-stub.c b/net/tap-stub.c | 95 | |
86 | index XXXXXXX..XXXXXXX 100644 | 96 | #endif |
87 | --- a/net/tap-stub.c | ||
88 | +++ b/net/tap-stub.c | ||
89 | @@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname) | ||
90 | { | ||
91 | return -1; | ||
92 | } | ||
93 | + | ||
94 | +int tap_fd_set_steering_ebpf(int fd, int prog_fd) | ||
95 | +{ | ||
96 | + return -1; | ||
97 | +} | ||
98 | diff --git a/net/tap.c b/net/tap.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/net/tap.c | ||
101 | +++ b/net/tap.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static void tap_poll(NetClientState *nc, bool enable) | ||
103 | tap_write_poll(s, enable); | ||
104 | } | ||
105 | |||
106 | +static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd) | ||
107 | +{ | ||
108 | + TAPState *s = DO_UPCAST(TAPState, nc, nc); | ||
109 | + assert(nc->info->type == NET_CLIENT_DRIVER_TAP); | ||
110 | + | ||
111 | + return tap_fd_set_steering_ebpf(s->fd, prog_fd) == 0; | ||
112 | +} | ||
113 | + | ||
114 | int tap_get_fd(NetClientState *nc) | ||
115 | { | ||
116 | TAPState *s = DO_UPCAST(TAPState, nc, nc); | ||
117 | @@ -XXX,XX +XXX,XX @@ static NetClientInfo net_tap_info = { | ||
118 | .set_vnet_hdr_len = tap_set_vnet_hdr_len, | ||
119 | .set_vnet_le = tap_set_vnet_le, | ||
120 | .set_vnet_be = tap_set_vnet_be, | ||
121 | + .set_steering_ebpf = tap_set_steering_ebpf, | ||
122 | }; | ||
123 | |||
124 | static TAPState *net_tap_fd_init(NetClientState *peer, | ||
125 | diff --git a/net/tap_int.h b/net/tap_int.h | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/net/tap_int.h | ||
128 | +++ b/net/tap_int.h | ||
129 | @@ -XXX,XX +XXX,XX @@ int tap_fd_set_vnet_be(int fd, int vnet_is_be); | ||
130 | int tap_fd_enable(int fd); | ||
131 | int tap_fd_disable(int fd); | ||
132 | int tap_fd_get_ifname(int fd, char *ifname); | ||
133 | +int tap_fd_set_steering_ebpf(int fd, int prog_fd); | ||
134 | |||
135 | #endif /* NET_TAP_INT_H */ | ||
136 | -- | 97 | -- |
137 | 2.7.4 | 98 | 2.7.4 |
138 | 99 | ||
139 | 100 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 3 | There is a second NIC but we do not use it for the moment. We use the |
4 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 4 | 'aspeed' property to tune the definition of the end of ring buffer bit |
5 | for the Aspeed SoCs. | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
5 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 8 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
6 | --- | 9 | --- |
7 | MAINTAINERS | 8 ++++++++ | 10 | hw/arm/aspeed_soc.c | 21 +++++++++++++++++++++ |
8 | 1 file changed, 8 insertions(+) | 11 | include/hw/arm/aspeed_soc.h | 2 ++ |
12 | 2 files changed, 23 insertions(+) | ||
9 | 13 | ||
10 | diff --git a/MAINTAINERS b/MAINTAINERS | 14 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
11 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/MAINTAINERS | 16 | --- a/hw/arm/aspeed_soc.c |
13 | +++ b/MAINTAINERS | 17 | +++ b/hw/arm/aspeed_soc.c |
14 | @@ -XXX,XX +XXX,XX @@ F: include/hw/remote/proxy-memory-listener.h | 18 | @@ -XXX,XX +XXX,XX @@ |
15 | F: hw/remote/iohub.c | 19 | #include "hw/char/serial.h" |
16 | F: include/hw/remote/iohub.h | 20 | #include "qemu/log.h" |
17 | 21 | #include "hw/i2c/aspeed_i2c.h" | |
18 | +EBPF: | 22 | +#include "net/net.h" |
19 | +M: Jason Wang <jasowang@redhat.com> | 23 | |
20 | +R: Andrew Melnychenko <andrew@daynix.com> | 24 | #define ASPEED_SOC_UART_5_BASE 0x00184000 |
21 | +R: Yuri Benditovich <yuri.benditovich@daynix.com> | 25 | #define ASPEED_SOC_IOMEM_SIZE 0x00200000 |
22 | +S: Maintained | 26 | @@ -XXX,XX +XXX,XX @@ |
23 | +F: ebpf/* | 27 | #define ASPEED_SOC_TIMER_BASE 0x1E782000 |
24 | +F: tools/ebpf/* | 28 | #define ASPEED_SOC_WDT_BASE 0x1E785000 |
29 | #define ASPEED_SOC_I2C_BASE 0x1E78A000 | ||
30 | +#define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
31 | +#define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
32 | |||
33 | static const int uart_irqs[] = { 9, 32, 33, 34, 10 }; | ||
34 | static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, }; | ||
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
36 | object_initialize(&s->wdt, sizeof(s->wdt), TYPE_ASPEED_WDT); | ||
37 | object_property_add_child(obj, "wdt", OBJECT(&s->wdt), NULL); | ||
38 | qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default()); | ||
25 | + | 39 | + |
26 | Build and test automation | 40 | + object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100); |
27 | ------------------------- | 41 | + object_property_add_child(obj, "ftgmac100", OBJECT(&s->ftgmac100), NULL); |
28 | Build and test automation, general continuous integration | 42 | + qdev_set_parent_bus(DEVICE(&s->ftgmac100), sysbus_get_default()); |
43 | } | ||
44 | |||
45 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
46 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
47 | return; | ||
48 | } | ||
49 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, ASPEED_SOC_WDT_BASE); | ||
50 | + | ||
51 | + /* Net */ | ||
52 | + qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]); | ||
53 | + object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err); | ||
54 | + object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", | ||
55 | + &local_err); | ||
56 | + error_propagate(&err, local_err); | ||
57 | + if (err) { | ||
58 | + error_propagate(errp, err); | ||
59 | + return; | ||
60 | + } | ||
61 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); | ||
62 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
63 | + qdev_get_gpio_in(DEVICE(&s->vic), 2)); | ||
64 | } | ||
65 | |||
66 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
67 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/include/hw/arm/aspeed_soc.h | ||
70 | +++ b/include/hw/arm/aspeed_soc.h | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | #include "hw/i2c/aspeed_i2c.h" | ||
73 | #include "hw/ssi/aspeed_smc.h" | ||
74 | #include "hw/watchdog/wdt_aspeed.h" | ||
75 | +#include "hw/net/ftgmac100.h" | ||
76 | |||
77 | #define ASPEED_SPIS_NUM 2 | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | ||
80 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | ||
81 | AspeedSDMCState sdmc; | ||
82 | AspeedWDTState wdt; | ||
83 | + FTGMAC100State ftgmac100; | ||
84 | } AspeedSoCState; | ||
85 | |||
86 | #define TYPE_ASPEED_SOC "aspeed-soc" | ||
29 | -- | 87 | -- |
30 | 2.7.4 | 88 | 2.7.4 |
31 | 89 | ||
32 | 90 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Added function that loads RSS eBPF program. | 3 | NC-SI (Network Controller Sideband Interface) enables a BMC to manage |
4 | Added stub functions for RSS eBPF loader. | 4 | a set of NICs on a system. This model takes the simplest approach and |
5 | Added meson and configuration options. | 5 | reverses the NC-SI packets to pretend a NIC is present and exercise |
6 | the Linux driver. | ||
6 | 7 | ||
7 | By default, eBPF feature enabled if libbpf is present in the build system. | 8 | The NCSI header file <ncsi-pkt.h> comes from mainline Linux and was |
8 | libbpf checked in configuration shell script and meson script. | 9 | untabified. |
9 | 10 | ||
10 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
11 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
13 | Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
12 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 14 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
13 | --- | 15 | --- |
14 | configure | 8 +- | 16 | include/net/eth.h | 1 + |
15 | ebpf/ebpf_rss-stub.c | 40 +++++ | 17 | slirp/Makefile.objs | 2 +- |
16 | ebpf/ebpf_rss.c | 165 ++++++++++++++++++ | 18 | slirp/ncsi-pkt.h | 419 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 | ebpf/ebpf_rss.h | 44 +++++ | 19 | slirp/ncsi.c | 130 ++++++++++++++++ |
18 | ebpf/meson.build | 1 + | 20 | slirp/slirp.c | 4 + |
19 | ebpf/rss.bpf.skeleton.h | 431 ++++++++++++++++++++++++++++++++++++++++++++++++ | 21 | slirp/slirp.h | 3 + |
20 | ebpf/trace-events | 4 + | 22 | 6 files changed, 558 insertions(+), 1 deletion(-) |
21 | ebpf/trace.h | 1 + | 23 | create mode 100644 slirp/ncsi-pkt.h |
22 | meson.build | 23 +++ | 24 | create mode 100644 slirp/ncsi.c |
23 | meson_options.txt | 2 + | ||
24 | 10 files changed, 718 insertions(+), 1 deletion(-) | ||
25 | create mode 100644 ebpf/ebpf_rss-stub.c | ||
26 | create mode 100644 ebpf/ebpf_rss.c | ||
27 | create mode 100644 ebpf/ebpf_rss.h | ||
28 | create mode 100644 ebpf/meson.build | ||
29 | create mode 100644 ebpf/rss.bpf.skeleton.h | ||
30 | create mode 100644 ebpf/trace-events | ||
31 | create mode 100644 ebpf/trace.h | ||
32 | 25 | ||
33 | diff --git a/configure b/configure | 26 | diff --git a/include/net/eth.h b/include/net/eth.h |
34 | index XXXXXXX..XXXXXXX 100755 | 27 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/configure | 28 | --- a/include/net/eth.h |
36 | +++ b/configure | 29 | +++ b/include/net/eth.h |
37 | @@ -XXX,XX +XXX,XX @@ vhost_vsock="$default_feature" | 30 | @@ -XXX,XX +XXX,XX @@ struct tcp_hdr { |
38 | vhost_user="no" | 31 | #define ETH_P_IPV6 (0x86dd) |
39 | vhost_user_blk_server="auto" | 32 | #define ETH_P_VLAN (0x8100) |
40 | vhost_user_fs="$default_feature" | 33 | #define ETH_P_DVLAN (0x88a8) |
41 | +bpf="auto" | 34 | +#define ETH_P_NCSI (0x88f8) |
42 | kvm="auto" | 35 | #define ETH_P_UNKNOWN (0xffff) |
43 | hax="auto" | 36 | #define VLAN_VID_MASK 0x0fff |
44 | hvf="auto" | 37 | #define IP_HEADER_VERSION_4 (4) |
45 | @@ -XXX,XX +XXX,XX @@ for opt do | 38 | diff --git a/slirp/Makefile.objs b/slirp/Makefile.objs |
46 | ;; | 39 | index XXXXXXX..XXXXXXX 100644 |
47 | --enable-membarrier) membarrier="yes" | 40 | --- a/slirp/Makefile.objs |
48 | ;; | 41 | +++ b/slirp/Makefile.objs |
49 | + --disable-bpf) bpf="disabled" | 42 | @@ -XXX,XX +XXX,XX @@ common-obj-y = cksum.o if.o ip_icmp.o ip6_icmp.o ip6_input.o ip6_output.o \ |
50 | + ;; | 43 | ip_input.o ip_output.o dnssearch.o dhcpv6.o |
51 | + --enable-bpf) bpf="enabled" | 44 | common-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o |
52 | + ;; | 45 | common-obj-y += tcp_subr.o tcp_timer.o udp.o udp6.o bootp.o tftp.o arp_table.o \ |
53 | --disable-blobs) blobs="false" | 46 | - ndp_table.o |
54 | ;; | 47 | + ndp_table.o ncsi.o |
55 | --with-pkgversion=*) pkgversion="$optarg" | 48 | diff --git a/slirp/ncsi-pkt.h b/slirp/ncsi-pkt.h |
56 | @@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available | ||
57 | vhost-user vhost-user backend support | ||
58 | vhost-user-blk-server vhost-user-blk server support | ||
59 | vhost-vdpa vhost-vdpa kernel backend support | ||
60 | + bpf BPF kernel support | ||
61 | spice spice | ||
62 | spice-protocol spice-protocol | ||
63 | rbd rados block device (rbd) | ||
64 | @@ -XXX,XX +XXX,XX @@ if test "$skip_meson" = no; then | ||
65 | -Dattr=$attr -Ddefault_devices=$default_devices \ | ||
66 | -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \ | ||
67 | -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \ | ||
68 | - -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \ | ||
69 | + -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\ | ||
70 | $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \ | ||
71 | -Dtcg_interpreter=$tcg_interpreter \ | ||
72 | $cross_arg \ | ||
73 | diff --git a/ebpf/ebpf_rss-stub.c b/ebpf/ebpf_rss-stub.c | ||
74 | new file mode 100644 | 49 | new file mode 100644 |
75 | index XXXXXXX..XXXXXXX | 50 | index XXXXXXX..XXXXXXX |
76 | --- /dev/null | 51 | --- /dev/null |
77 | +++ b/ebpf/ebpf_rss-stub.c | 52 | +++ b/slirp/ncsi-pkt.h |
78 | @@ -XXX,XX +XXX,XX @@ | 53 | @@ -XXX,XX +XXX,XX @@ |
79 | +/* | 54 | +/* |
80 | + * eBPF RSS stub file | 55 | + * Copyright Gavin Shan, IBM Corporation 2016. |
81 | + * | 56 | + * |
82 | + * Developed by Daynix Computing LTD (http://www.daynix.com) | 57 | + * This program is free software; you can redistribute it and/or modify |
83 | + * | 58 | + * it under the terms of the GNU General Public License as published by |
84 | + * Authors: | 59 | + * the Free Software Foundation; either version 2 of the License, or |
85 | + * Yuri Benditovich <yuri.benditovich@daynix.com> | 60 | + * (at your option) any later version. |
86 | + * | ||
87 | + * This work is licensed under the terms of the GNU GPL, version 2. See | ||
88 | + * the COPYING file in the top-level directory. | ||
89 | + */ | 61 | + */ |
90 | + | 62 | + |
91 | +#include "qemu/osdep.h" | 63 | +#ifndef NCSI_PKT_H |
92 | +#include "ebpf/ebpf_rss.h" | 64 | +#define NCSI_PKT_H |
93 | + | 65 | + |
94 | +void ebpf_rss_init(struct EBPFRSSContext *ctx) | 66 | +/* from linux/net/ncsi/ncsi-pkt.h */ |
95 | +{ | 67 | +#define __be32 uint32_t |
96 | + | 68 | +#define __be16 uint16_t |
97 | +} | 69 | + |
98 | + | 70 | +struct ncsi_pkt_hdr { |
99 | +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) | 71 | + unsigned char mc_id; /* Management controller ID */ |
100 | +{ | 72 | + unsigned char revision; /* NCSI version - 0x01 */ |
101 | + return false; | 73 | + unsigned char reserved; /* Reserved */ |
102 | +} | 74 | + unsigned char id; /* Packet sequence number */ |
103 | + | 75 | + unsigned char type; /* Packet type */ |
104 | +bool ebpf_rss_load(struct EBPFRSSContext *ctx) | 76 | + unsigned char channel; /* Network controller ID */ |
105 | +{ | 77 | + __be16 length; /* Payload length */ |
106 | + return false; | 78 | + __be32 reserved1[2]; /* Reserved */ |
107 | +} | 79 | +}; |
108 | + | 80 | + |
109 | +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config, | 81 | +struct ncsi_cmd_pkt_hdr { |
110 | + uint16_t *indirections_table, uint8_t *toeplitz_key) | 82 | + struct ncsi_pkt_hdr common; /* Common NCSI packet header */ |
111 | +{ | 83 | +}; |
112 | + return false; | 84 | + |
113 | +} | 85 | +struct ncsi_rsp_pkt_hdr { |
114 | + | 86 | + struct ncsi_pkt_hdr common; /* Common NCSI packet header */ |
115 | +void ebpf_rss_unload(struct EBPFRSSContext *ctx) | 87 | + __be16 code; /* Response code */ |
116 | +{ | 88 | + __be16 reason; /* Response reason */ |
117 | + | 89 | +}; |
118 | +} | 90 | + |
119 | diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c | 91 | +struct ncsi_aen_pkt_hdr { |
92 | + struct ncsi_pkt_hdr common; /* Common NCSI packet header */ | ||
93 | + unsigned char reserved2[3]; /* Reserved */ | ||
94 | + unsigned char type; /* AEN packet type */ | ||
95 | +}; | ||
96 | + | ||
97 | +/* NCSI common command packet */ | ||
98 | +struct ncsi_cmd_pkt { | ||
99 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
100 | + __be32 checksum; /* Checksum */ | ||
101 | + unsigned char pad[26]; | ||
102 | +}; | ||
103 | + | ||
104 | +struct ncsi_rsp_pkt { | ||
105 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
106 | + __be32 checksum; /* Checksum */ | ||
107 | + unsigned char pad[22]; | ||
108 | +}; | ||
109 | + | ||
110 | +/* Select Package */ | ||
111 | +struct ncsi_cmd_sp_pkt { | ||
112 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
113 | + unsigned char reserved[3]; /* Reserved */ | ||
114 | + unsigned char hw_arbitration; /* HW arbitration */ | ||
115 | + __be32 checksum; /* Checksum */ | ||
116 | + unsigned char pad[22]; | ||
117 | +}; | ||
118 | + | ||
119 | +/* Disable Channel */ | ||
120 | +struct ncsi_cmd_dc_pkt { | ||
121 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
122 | + unsigned char reserved[3]; /* Reserved */ | ||
123 | + unsigned char ald; /* Allow link down */ | ||
124 | + __be32 checksum; /* Checksum */ | ||
125 | + unsigned char pad[22]; | ||
126 | +}; | ||
127 | + | ||
128 | +/* Reset Channel */ | ||
129 | +struct ncsi_cmd_rc_pkt { | ||
130 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
131 | + __be32 reserved; /* Reserved */ | ||
132 | + __be32 checksum; /* Checksum */ | ||
133 | + unsigned char pad[22]; | ||
134 | +}; | ||
135 | + | ||
136 | +/* AEN Enable */ | ||
137 | +struct ncsi_cmd_ae_pkt { | ||
138 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
139 | + unsigned char reserved[3]; /* Reserved */ | ||
140 | + unsigned char mc_id; /* MC ID */ | ||
141 | + __be32 mode; /* AEN working mode */ | ||
142 | + __be32 checksum; /* Checksum */ | ||
143 | + unsigned char pad[18]; | ||
144 | +}; | ||
145 | + | ||
146 | +/* Set Link */ | ||
147 | +struct ncsi_cmd_sl_pkt { | ||
148 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
149 | + __be32 mode; /* Link working mode */ | ||
150 | + __be32 oem_mode; /* OEM link mode */ | ||
151 | + __be32 checksum; /* Checksum */ | ||
152 | + unsigned char pad[18]; | ||
153 | +}; | ||
154 | + | ||
155 | +/* Set VLAN Filter */ | ||
156 | +struct ncsi_cmd_svf_pkt { | ||
157 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
158 | + __be16 reserved; /* Reserved */ | ||
159 | + __be16 vlan; /* VLAN ID */ | ||
160 | + __be16 reserved1; /* Reserved */ | ||
161 | + unsigned char index; /* VLAN table index */ | ||
162 | + unsigned char enable; /* Enable or disable */ | ||
163 | + __be32 checksum; /* Checksum */ | ||
164 | + unsigned char pad[14]; | ||
165 | +}; | ||
166 | + | ||
167 | +/* Enable VLAN */ | ||
168 | +struct ncsi_cmd_ev_pkt { | ||
169 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
170 | + unsigned char reserved[3]; /* Reserved */ | ||
171 | + unsigned char mode; /* VLAN filter mode */ | ||
172 | + __be32 checksum; /* Checksum */ | ||
173 | + unsigned char pad[22]; | ||
174 | +}; | ||
175 | + | ||
176 | +/* Set MAC Address */ | ||
177 | +struct ncsi_cmd_sma_pkt { | ||
178 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
179 | + unsigned char mac[6]; /* MAC address */ | ||
180 | + unsigned char index; /* MAC table index */ | ||
181 | + unsigned char at_e; /* Addr type and operation */ | ||
182 | + __be32 checksum; /* Checksum */ | ||
183 | + unsigned char pad[18]; | ||
184 | +}; | ||
185 | + | ||
186 | +/* Enable Broadcast Filter */ | ||
187 | +struct ncsi_cmd_ebf_pkt { | ||
188 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
189 | + __be32 mode; /* Filter mode */ | ||
190 | + __be32 checksum; /* Checksum */ | ||
191 | + unsigned char pad[22]; | ||
192 | +}; | ||
193 | + | ||
194 | +/* Enable Global Multicast Filter */ | ||
195 | +struct ncsi_cmd_egmf_pkt { | ||
196 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
197 | + __be32 mode; /* Global MC mode */ | ||
198 | + __be32 checksum; /* Checksum */ | ||
199 | + unsigned char pad[22]; | ||
200 | +}; | ||
201 | + | ||
202 | +/* Set NCSI Flow Control */ | ||
203 | +struct ncsi_cmd_snfc_pkt { | ||
204 | + struct ncsi_cmd_pkt_hdr cmd; /* Command header */ | ||
205 | + unsigned char reserved[3]; /* Reserved */ | ||
206 | + unsigned char mode; /* Flow control mode */ | ||
207 | + __be32 checksum; /* Checksum */ | ||
208 | + unsigned char pad[22]; | ||
209 | +}; | ||
210 | + | ||
211 | +/* Get Link Status */ | ||
212 | +struct ncsi_rsp_gls_pkt { | ||
213 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
214 | + __be32 status; /* Link status */ | ||
215 | + __be32 other; /* Other indications */ | ||
216 | + __be32 oem_status; /* OEM link status */ | ||
217 | + __be32 checksum; | ||
218 | + unsigned char pad[10]; | ||
219 | +}; | ||
220 | + | ||
221 | +/* Get Version ID */ | ||
222 | +struct ncsi_rsp_gvi_pkt { | ||
223 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
224 | + __be32 ncsi_version; /* NCSI version */ | ||
225 | + unsigned char reserved[3]; /* Reserved */ | ||
226 | + unsigned char alpha2; /* NCSI version */ | ||
227 | + unsigned char fw_name[12]; /* f/w name string */ | ||
228 | + __be32 fw_version; /* f/w version */ | ||
229 | + __be16 pci_ids[4]; /* PCI IDs */ | ||
230 | + __be32 mf_id; /* Manufacture ID */ | ||
231 | + __be32 checksum; | ||
232 | +}; | ||
233 | + | ||
234 | +/* Get Capabilities */ | ||
235 | +struct ncsi_rsp_gc_pkt { | ||
236 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
237 | + __be32 cap; /* Capabilities */ | ||
238 | + __be32 bc_cap; /* Broadcast cap */ | ||
239 | + __be32 mc_cap; /* Multicast cap */ | ||
240 | + __be32 buf_cap; /* Buffering cap */ | ||
241 | + __be32 aen_cap; /* AEN cap */ | ||
242 | + unsigned char vlan_cnt; /* VLAN filter count */ | ||
243 | + unsigned char mixed_cnt; /* Mix filter count */ | ||
244 | + unsigned char mc_cnt; /* MC filter count */ | ||
245 | + unsigned char uc_cnt; /* UC filter count */ | ||
246 | + unsigned char reserved[2]; /* Reserved */ | ||
247 | + unsigned char vlan_mode; /* VLAN mode */ | ||
248 | + unsigned char channel_cnt; /* Channel count */ | ||
249 | + __be32 checksum; /* Checksum */ | ||
250 | +}; | ||
251 | + | ||
252 | +/* Get Parameters */ | ||
253 | +struct ncsi_rsp_gp_pkt { | ||
254 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
255 | + unsigned char mac_cnt; /* Number of MAC addr */ | ||
256 | + unsigned char reserved[2]; /* Reserved */ | ||
257 | + unsigned char mac_enable; /* MAC addr enable flags */ | ||
258 | + unsigned char vlan_cnt; /* VLAN tag count */ | ||
259 | + unsigned char reserved1; /* Reserved */ | ||
260 | + __be16 vlan_enable; /* VLAN tag enable flags */ | ||
261 | + __be32 link_mode; /* Link setting */ | ||
262 | + __be32 bc_mode; /* BC filter mode */ | ||
263 | + __be32 valid_modes; /* Valid mode parameters */ | ||
264 | + unsigned char vlan_mode; /* VLAN mode */ | ||
265 | + unsigned char fc_mode; /* Flow control mode */ | ||
266 | + unsigned char reserved2[2]; /* Reserved */ | ||
267 | + __be32 aen_mode; /* AEN mode */ | ||
268 | + unsigned char mac[6]; /* Supported MAC addr */ | ||
269 | + __be16 vlan; /* Supported VLAN tags */ | ||
270 | + __be32 checksum; /* Checksum */ | ||
271 | +}; | ||
272 | + | ||
273 | +/* Get Controller Packet Statistics */ | ||
274 | +struct ncsi_rsp_gcps_pkt { | ||
275 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
276 | + __be32 cnt_hi; /* Counter cleared */ | ||
277 | + __be32 cnt_lo; /* Counter cleared */ | ||
278 | + __be32 rx_bytes; /* Rx bytes */ | ||
279 | + __be32 tx_bytes; /* Tx bytes */ | ||
280 | + __be32 rx_uc_pkts; /* Rx UC packets */ | ||
281 | + __be32 rx_mc_pkts; /* Rx MC packets */ | ||
282 | + __be32 rx_bc_pkts; /* Rx BC packets */ | ||
283 | + __be32 tx_uc_pkts; /* Tx UC packets */ | ||
284 | + __be32 tx_mc_pkts; /* Tx MC packets */ | ||
285 | + __be32 tx_bc_pkts; /* Tx BC packets */ | ||
286 | + __be32 fcs_err; /* FCS errors */ | ||
287 | + __be32 align_err; /* Alignment errors */ | ||
288 | + __be32 false_carrier; /* False carrier detection */ | ||
289 | + __be32 runt_pkts; /* Rx runt packets */ | ||
290 | + __be32 jabber_pkts; /* Rx jabber packets */ | ||
291 | + __be32 rx_pause_xon; /* Rx pause XON frames */ | ||
292 | + __be32 rx_pause_xoff; /* Rx XOFF frames */ | ||
293 | + __be32 tx_pause_xon; /* Tx XON frames */ | ||
294 | + __be32 tx_pause_xoff; /* Tx XOFF frames */ | ||
295 | + __be32 tx_s_collision; /* Single collision frames */ | ||
296 | + __be32 tx_m_collision; /* Multiple collision frames */ | ||
297 | + __be32 l_collision; /* Late collision frames */ | ||
298 | + __be32 e_collision; /* Excessive collision frames */ | ||
299 | + __be32 rx_ctl_frames; /* Rx control frames */ | ||
300 | + __be32 rx_64_frames; /* Rx 64-bytes frames */ | ||
301 | + __be32 rx_127_frames; /* Rx 65-127 bytes frames */ | ||
302 | + __be32 rx_255_frames; /* Rx 128-255 bytes frames */ | ||
303 | + __be32 rx_511_frames; /* Rx 256-511 bytes frames */ | ||
304 | + __be32 rx_1023_frames; /* Rx 512-1023 bytes frames */ | ||
305 | + __be32 rx_1522_frames; /* Rx 1024-1522 bytes frames */ | ||
306 | + __be32 rx_9022_frames; /* Rx 1523-9022 bytes frames */ | ||
307 | + __be32 tx_64_frames; /* Tx 64-bytes frames */ | ||
308 | + __be32 tx_127_frames; /* Tx 65-127 bytes frames */ | ||
309 | + __be32 tx_255_frames; /* Tx 128-255 bytes frames */ | ||
310 | + __be32 tx_511_frames; /* Tx 256-511 bytes frames */ | ||
311 | + __be32 tx_1023_frames; /* Tx 512-1023 bytes frames */ | ||
312 | + __be32 tx_1522_frames; /* Tx 1024-1522 bytes frames */ | ||
313 | + __be32 tx_9022_frames; /* Tx 1523-9022 bytes frames */ | ||
314 | + __be32 rx_valid_bytes; /* Rx valid bytes */ | ||
315 | + __be32 rx_runt_pkts; /* Rx error runt packets */ | ||
316 | + __be32 rx_jabber_pkts; /* Rx error jabber packets */ | ||
317 | + __be32 checksum; /* Checksum */ | ||
318 | +}; | ||
319 | + | ||
320 | +/* Get NCSI Statistics */ | ||
321 | +struct ncsi_rsp_gns_pkt { | ||
322 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
323 | + __be32 rx_cmds; /* Rx NCSI commands */ | ||
324 | + __be32 dropped_cmds; /* Dropped commands */ | ||
325 | + __be32 cmd_type_errs; /* Command type errors */ | ||
326 | + __be32 cmd_csum_errs; /* Command checksum errors */ | ||
327 | + __be32 rx_pkts; /* Rx NCSI packets */ | ||
328 | + __be32 tx_pkts; /* Tx NCSI packets */ | ||
329 | + __be32 tx_aen_pkts; /* Tx AEN packets */ | ||
330 | + __be32 checksum; /* Checksum */ | ||
331 | +}; | ||
332 | + | ||
333 | +/* Get NCSI Pass-through Statistics */ | ||
334 | +struct ncsi_rsp_gnpts_pkt { | ||
335 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
336 | + __be32 tx_pkts; /* Tx packets */ | ||
337 | + __be32 tx_dropped; /* Tx dropped packets */ | ||
338 | + __be32 tx_channel_err; /* Tx channel errors */ | ||
339 | + __be32 tx_us_err; /* Tx undersize errors */ | ||
340 | + __be32 rx_pkts; /* Rx packets */ | ||
341 | + __be32 rx_dropped; /* Rx dropped packets */ | ||
342 | + __be32 rx_channel_err; /* Rx channel errors */ | ||
343 | + __be32 rx_us_err; /* Rx undersize errors */ | ||
344 | + __be32 rx_os_err; /* Rx oversize errors */ | ||
345 | + __be32 checksum; /* Checksum */ | ||
346 | +}; | ||
347 | + | ||
348 | +/* Get package status */ | ||
349 | +struct ncsi_rsp_gps_pkt { | ||
350 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
351 | + __be32 status; /* Hardware arbitration status */ | ||
352 | + __be32 checksum; | ||
353 | +}; | ||
354 | + | ||
355 | +/* Get package UUID */ | ||
356 | +struct ncsi_rsp_gpuuid_pkt { | ||
357 | + struct ncsi_rsp_pkt_hdr rsp; /* Response header */ | ||
358 | + unsigned char uuid[16]; /* UUID */ | ||
359 | + __be32 checksum; | ||
360 | +}; | ||
361 | + | ||
362 | +/* AEN: Link State Change */ | ||
363 | +struct ncsi_aen_lsc_pkt { | ||
364 | + struct ncsi_aen_pkt_hdr aen; /* AEN header */ | ||
365 | + __be32 status; /* Link status */ | ||
366 | + __be32 oem_status; /* OEM link status */ | ||
367 | + __be32 checksum; /* Checksum */ | ||
368 | + unsigned char pad[14]; | ||
369 | +}; | ||
370 | + | ||
371 | +/* AEN: Configuration Required */ | ||
372 | +struct ncsi_aen_cr_pkt { | ||
373 | + struct ncsi_aen_pkt_hdr aen; /* AEN header */ | ||
374 | + __be32 checksum; /* Checksum */ | ||
375 | + unsigned char pad[22]; | ||
376 | +}; | ||
377 | + | ||
378 | +/* AEN: Host Network Controller Driver Status Change */ | ||
379 | +struct ncsi_aen_hncdsc_pkt { | ||
380 | + struct ncsi_aen_pkt_hdr aen; /* AEN header */ | ||
381 | + __be32 status; /* Status */ | ||
382 | + __be32 checksum; /* Checksum */ | ||
383 | + unsigned char pad[18]; | ||
384 | +}; | ||
385 | + | ||
386 | +/* NCSI packet revision */ | ||
387 | +#define NCSI_PKT_REVISION 0x01 | ||
388 | + | ||
389 | +/* NCSI packet commands */ | ||
390 | +#define NCSI_PKT_CMD_CIS 0x00 /* Clear Initial State */ | ||
391 | +#define NCSI_PKT_CMD_SP 0x01 /* Select Package */ | ||
392 | +#define NCSI_PKT_CMD_DP 0x02 /* Deselect Package */ | ||
393 | +#define NCSI_PKT_CMD_EC 0x03 /* Enable Channel */ | ||
394 | +#define NCSI_PKT_CMD_DC 0x04 /* Disable Channel */ | ||
395 | +#define NCSI_PKT_CMD_RC 0x05 /* Reset Channel */ | ||
396 | +#define NCSI_PKT_CMD_ECNT 0x06 /* Enable Channel Network Tx */ | ||
397 | +#define NCSI_PKT_CMD_DCNT 0x07 /* Disable Channel Network Tx */ | ||
398 | +#define NCSI_PKT_CMD_AE 0x08 /* AEN Enable */ | ||
399 | +#define NCSI_PKT_CMD_SL 0x09 /* Set Link */ | ||
400 | +#define NCSI_PKT_CMD_GLS 0x0a /* Get Link */ | ||
401 | +#define NCSI_PKT_CMD_SVF 0x0b /* Set VLAN Filter */ | ||
402 | +#define NCSI_PKT_CMD_EV 0x0c /* Enable VLAN */ | ||
403 | +#define NCSI_PKT_CMD_DV 0x0d /* Disable VLAN */ | ||
404 | +#define NCSI_PKT_CMD_SMA 0x0e /* Set MAC address */ | ||
405 | +#define NCSI_PKT_CMD_EBF 0x10 /* Enable Broadcast Filter */ | ||
406 | +#define NCSI_PKT_CMD_DBF 0x11 /* Disable Broadcast Filter */ | ||
407 | +#define NCSI_PKT_CMD_EGMF 0x12 /* Enable Global Multicast Filter */ | ||
408 | +#define NCSI_PKT_CMD_DGMF 0x13 /* Disable Global Multicast Filter */ | ||
409 | +#define NCSI_PKT_CMD_SNFC 0x14 /* Set NCSI Flow Control */ | ||
410 | +#define NCSI_PKT_CMD_GVI 0x15 /* Get Version ID */ | ||
411 | +#define NCSI_PKT_CMD_GC 0x16 /* Get Capabilities */ | ||
412 | +#define NCSI_PKT_CMD_GP 0x17 /* Get Parameters */ | ||
413 | +#define NCSI_PKT_CMD_GCPS 0x18 /* Get Controller Packet Statistics */ | ||
414 | +#define NCSI_PKT_CMD_GNS 0x19 /* Get NCSI Statistics */ | ||
415 | +#define NCSI_PKT_CMD_GNPTS 0x1a /* Get NCSI Pass-throu Statistics */ | ||
416 | +#define NCSI_PKT_CMD_GPS 0x1b /* Get package status */ | ||
417 | +#define NCSI_PKT_CMD_OEM 0x50 /* OEM */ | ||
418 | +#define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */ | ||
419 | +#define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */ | ||
420 | + | ||
421 | +/* NCSI packet responses */ | ||
422 | +#define NCSI_PKT_RSP_CIS (NCSI_PKT_CMD_CIS + 0x80) | ||
423 | +#define NCSI_PKT_RSP_SP (NCSI_PKT_CMD_SP + 0x80) | ||
424 | +#define NCSI_PKT_RSP_DP (NCSI_PKT_CMD_DP + 0x80) | ||
425 | +#define NCSI_PKT_RSP_EC (NCSI_PKT_CMD_EC + 0x80) | ||
426 | +#define NCSI_PKT_RSP_DC (NCSI_PKT_CMD_DC + 0x80) | ||
427 | +#define NCSI_PKT_RSP_RC (NCSI_PKT_CMD_RC + 0x80) | ||
428 | +#define NCSI_PKT_RSP_ECNT (NCSI_PKT_CMD_ECNT + 0x80) | ||
429 | +#define NCSI_PKT_RSP_DCNT (NCSI_PKT_CMD_DCNT + 0x80) | ||
430 | +#define NCSI_PKT_RSP_AE (NCSI_PKT_CMD_AE + 0x80) | ||
431 | +#define NCSI_PKT_RSP_SL (NCSI_PKT_CMD_SL + 0x80) | ||
432 | +#define NCSI_PKT_RSP_GLS (NCSI_PKT_CMD_GLS + 0x80) | ||
433 | +#define NCSI_PKT_RSP_SVF (NCSI_PKT_CMD_SVF + 0x80) | ||
434 | +#define NCSI_PKT_RSP_EV (NCSI_PKT_CMD_EV + 0x80) | ||
435 | +#define NCSI_PKT_RSP_DV (NCSI_PKT_CMD_DV + 0x80) | ||
436 | +#define NCSI_PKT_RSP_SMA (NCSI_PKT_CMD_SMA + 0x80) | ||
437 | +#define NCSI_PKT_RSP_EBF (NCSI_PKT_CMD_EBF + 0x80) | ||
438 | +#define NCSI_PKT_RSP_DBF (NCSI_PKT_CMD_DBF + 0x80) | ||
439 | +#define NCSI_PKT_RSP_EGMF (NCSI_PKT_CMD_EGMF + 0x80) | ||
440 | +#define NCSI_PKT_RSP_DGMF (NCSI_PKT_CMD_DGMF + 0x80) | ||
441 | +#define NCSI_PKT_RSP_SNFC (NCSI_PKT_CMD_SNFC + 0x80) | ||
442 | +#define NCSI_PKT_RSP_GVI (NCSI_PKT_CMD_GVI + 0x80) | ||
443 | +#define NCSI_PKT_RSP_GC (NCSI_PKT_CMD_GC + 0x80) | ||
444 | +#define NCSI_PKT_RSP_GP (NCSI_PKT_CMD_GP + 0x80) | ||
445 | +#define NCSI_PKT_RSP_GCPS (NCSI_PKT_CMD_GCPS + 0x80) | ||
446 | +#define NCSI_PKT_RSP_GNS (NCSI_PKT_CMD_GNS + 0x80) | ||
447 | +#define NCSI_PKT_RSP_GNPTS (NCSI_PKT_CMD_GNPTS + 0x80) | ||
448 | +#define NCSI_PKT_RSP_GPS (NCSI_PKT_CMD_GPS + 0x80) | ||
449 | +#define NCSI_PKT_RSP_OEM (NCSI_PKT_CMD_OEM + 0x80) | ||
450 | +#define NCSI_PKT_RSP_PLDM (NCSI_PKT_CMD_PLDM + 0x80) | ||
451 | +#define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80) | ||
452 | + | ||
453 | +/* NCSI response code/reason */ | ||
454 | +#define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */ | ||
455 | +#define NCSI_PKT_RSP_C_FAILED 0x0001 /* Command Failed */ | ||
456 | +#define NCSI_PKT_RSP_C_UNAVAILABLE 0x0002 /* Command Unavailable */ | ||
457 | +#define NCSI_PKT_RSP_C_UNSUPPORTED 0x0003 /* Command Unsupported */ | ||
458 | +#define NCSI_PKT_RSP_R_NO_ERROR 0x0000 /* No Error */ | ||
459 | +#define NCSI_PKT_RSP_R_INTERFACE 0x0001 /* Interface not ready */ | ||
460 | +#define NCSI_PKT_RSP_R_PARAM 0x0002 /* Invalid Parameter */ | ||
461 | +#define NCSI_PKT_RSP_R_CHANNEL 0x0003 /* Channel not Ready */ | ||
462 | +#define NCSI_PKT_RSP_R_PACKAGE 0x0004 /* Package not Ready */ | ||
463 | +#define NCSI_PKT_RSP_R_LENGTH 0x0005 /* Invalid payload length */ | ||
464 | +#define NCSI_PKT_RSP_R_UNKNOWN 0x7fff /* Command type unsupported */ | ||
465 | + | ||
466 | +/* NCSI AEN packet type */ | ||
467 | +#define NCSI_PKT_AEN 0xFF /* AEN Packet */ | ||
468 | +#define NCSI_PKT_AEN_LSC 0x00 /* Link status change */ | ||
469 | +#define NCSI_PKT_AEN_CR 0x01 /* Configuration required */ | ||
470 | +#define NCSI_PKT_AEN_HNCDSC 0x02 /* HNC driver status change */ | ||
471 | + | ||
472 | +#endif /* NCSI_PKT_H */ | ||
473 | diff --git a/slirp/ncsi.c b/slirp/ncsi.c | ||
120 | new file mode 100644 | 474 | new file mode 100644 |
121 | index XXXXXXX..XXXXXXX | 475 | index XXXXXXX..XXXXXXX |
122 | --- /dev/null | 476 | --- /dev/null |
123 | +++ b/ebpf/ebpf_rss.c | 477 | +++ b/slirp/ncsi.c |
124 | @@ -XXX,XX +XXX,XX @@ | 478 | @@ -XXX,XX +XXX,XX @@ |
125 | +/* | 479 | +/* |
126 | + * eBPF RSS loader | 480 | + * NC-SI (Network Controller Sideband Interface) "echo" model |
127 | + * | 481 | + * |
128 | + * Developed by Daynix Computing LTD (http://www.daynix.com) | 482 | + * Copyright (C) 2016 IBM Corp. |
129 | + * | 483 | + * |
130 | + * Authors: | 484 | + * This code is licensed under the GPL version 2 or later. See the |
131 | + * Andrew Melnychenko <andrew@daynix.com> | 485 | + * COPYING file in the top-level directory. |
132 | + * Yuri Benditovich <yuri.benditovich@daynix.com> | ||
133 | + * | ||
134 | + * This work is licensed under the terms of the GNU GPL, version 2. See | ||
135 | + * the COPYING file in the top-level directory. | ||
136 | + */ | 486 | + */ |
137 | + | ||
138 | +#include "qemu/osdep.h" | 487 | +#include "qemu/osdep.h" |
139 | +#include "qemu/error-report.h" | 488 | +#include "slirp.h" |
140 | + | 489 | + |
141 | +#include <bpf/libbpf.h> | 490 | +#include "ncsi-pkt.h" |
142 | +#include <bpf/bpf.h> | 491 | + |
143 | + | 492 | +/* Get Capabilities */ |
144 | +#include "hw/virtio/virtio-net.h" /* VIRTIO_NET_RSS_MAX_TABLE_LEN */ | 493 | +static int ncsi_rsp_handler_gc(struct ncsi_rsp_pkt_hdr *rnh) |
145 | + | ||
146 | +#include "ebpf/ebpf_rss.h" | ||
147 | +#include "ebpf/rss.bpf.skeleton.h" | ||
148 | +#include "trace.h" | ||
149 | + | ||
150 | +void ebpf_rss_init(struct EBPFRSSContext *ctx) | ||
151 | +{ | 494 | +{ |
152 | + if (ctx != NULL) { | 495 | + struct ncsi_rsp_gc_pkt *rsp = (struct ncsi_rsp_gc_pkt *) rnh; |
153 | + ctx->obj = NULL; | 496 | + |
154 | + } | 497 | + rsp->cap = htonl(~0); |
498 | + rsp->bc_cap = htonl(~0); | ||
499 | + rsp->mc_cap = htonl(~0); | ||
500 | + rsp->buf_cap = htonl(~0); | ||
501 | + rsp->aen_cap = htonl(~0); | ||
502 | + rsp->vlan_mode = 0xff; | ||
503 | + rsp->uc_cnt = 2; | ||
504 | + return 0; | ||
155 | +} | 505 | +} |
156 | + | 506 | + |
157 | +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) | 507 | +/* Get Link status */ |
508 | +static int ncsi_rsp_handler_gls(struct ncsi_rsp_pkt_hdr *rnh) | ||
158 | +{ | 509 | +{ |
159 | + return ctx != NULL && ctx->obj != NULL; | 510 | + struct ncsi_rsp_gls_pkt *rsp = (struct ncsi_rsp_gls_pkt *) rnh; |
511 | + | ||
512 | + rsp->status = htonl(0x1); | ||
513 | + return 0; | ||
160 | +} | 514 | +} |
161 | + | 515 | + |
162 | +bool ebpf_rss_load(struct EBPFRSSContext *ctx) | 516 | +static const struct ncsi_rsp_handler { |
517 | + unsigned char type; | ||
518 | + int payload; | ||
519 | + int (*handler)(struct ncsi_rsp_pkt_hdr *rnh); | ||
520 | +} ncsi_rsp_handlers[] = { | ||
521 | + { NCSI_PKT_RSP_CIS, 4, NULL }, | ||
522 | + { NCSI_PKT_RSP_SP, 4, NULL }, | ||
523 | + { NCSI_PKT_RSP_DP, 4, NULL }, | ||
524 | + { NCSI_PKT_RSP_EC, 4, NULL }, | ||
525 | + { NCSI_PKT_RSP_DC, 4, NULL }, | ||
526 | + { NCSI_PKT_RSP_RC, 4, NULL }, | ||
527 | + { NCSI_PKT_RSP_ECNT, 4, NULL }, | ||
528 | + { NCSI_PKT_RSP_DCNT, 4, NULL }, | ||
529 | + { NCSI_PKT_RSP_AE, 4, NULL }, | ||
530 | + { NCSI_PKT_RSP_SL, 4, NULL }, | ||
531 | + { NCSI_PKT_RSP_GLS, 16, ncsi_rsp_handler_gls }, | ||
532 | + { NCSI_PKT_RSP_SVF, 4, NULL }, | ||
533 | + { NCSI_PKT_RSP_EV, 4, NULL }, | ||
534 | + { NCSI_PKT_RSP_DV, 4, NULL }, | ||
535 | + { NCSI_PKT_RSP_SMA, 4, NULL }, | ||
536 | + { NCSI_PKT_RSP_EBF, 4, NULL }, | ||
537 | + { NCSI_PKT_RSP_DBF, 4, NULL }, | ||
538 | + { NCSI_PKT_RSP_EGMF, 4, NULL }, | ||
539 | + { NCSI_PKT_RSP_DGMF, 4, NULL }, | ||
540 | + { NCSI_PKT_RSP_SNFC, 4, NULL }, | ||
541 | + { NCSI_PKT_RSP_GVI, 36, NULL }, | ||
542 | + { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc }, | ||
543 | + { NCSI_PKT_RSP_GP, -1, NULL }, | ||
544 | + { NCSI_PKT_RSP_GCPS, 172, NULL }, | ||
545 | + { NCSI_PKT_RSP_GNS, 172, NULL }, | ||
546 | + { NCSI_PKT_RSP_GNPTS, 172, NULL }, | ||
547 | + { NCSI_PKT_RSP_GPS, 8, NULL }, | ||
548 | + { NCSI_PKT_RSP_OEM, 0, NULL }, | ||
549 | + { NCSI_PKT_RSP_PLDM, 0, NULL }, | ||
550 | + { NCSI_PKT_RSP_GPUUID, 20, NULL } | ||
551 | +}; | ||
552 | + | ||
553 | +/* | ||
554 | + * packet format : ncsi header + payload + checksum | ||
555 | + */ | ||
556 | +#define NCSI_MAX_PAYLOAD 172 | ||
557 | +#define NCSI_MAX_LEN (sizeof(struct ncsi_pkt_hdr) + NCSI_MAX_PAYLOAD + 4) | ||
558 | + | ||
559 | +void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) | ||
163 | +{ | 560 | +{ |
164 | + struct rss_bpf *rss_bpf_ctx; | 561 | + struct ncsi_pkt_hdr *nh = (struct ncsi_pkt_hdr *)(pkt + ETH_HLEN); |
165 | + | 562 | + uint8_t ncsi_reply[ETH_HLEN + NCSI_MAX_LEN]; |
166 | + if (ctx == NULL) { | 563 | + struct ethhdr *reh = (struct ethhdr *)ncsi_reply; |
167 | + return false; | 564 | + struct ncsi_rsp_pkt_hdr *rnh = (struct ncsi_rsp_pkt_hdr *) |
168 | + } | 565 | + (ncsi_reply + ETH_HLEN); |
169 | + | 566 | + const struct ncsi_rsp_handler *handler = NULL; |
170 | + rss_bpf_ctx = rss_bpf__open(); | 567 | + int i; |
171 | + if (rss_bpf_ctx == NULL) { | 568 | + |
172 | + trace_ebpf_error("eBPF RSS", "can not open eBPF RSS object"); | 569 | + memset(ncsi_reply, 0, sizeof(ncsi_reply)); |
173 | + goto error; | 570 | + |
174 | + } | 571 | + memset(reh->h_dest, 0xff, ETH_ALEN); |
175 | + | 572 | + memset(reh->h_source, 0xff, ETH_ALEN); |
176 | + bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_prog); | 573 | + reh->h_proto = htons(ETH_P_NCSI); |
177 | + | 574 | + |
178 | + if (rss_bpf__load(rss_bpf_ctx)) { | 575 | + for (i = 0; i < ARRAY_SIZE(ncsi_rsp_handlers); i++) { |
179 | + trace_ebpf_error("eBPF RSS", "can not load RSS program"); | 576 | + if (ncsi_rsp_handlers[i].type == nh->type + 0x80) { |
180 | + goto error; | 577 | + handler = &ncsi_rsp_handlers[i]; |
181 | + } | 578 | + break; |
182 | + | ||
183 | + ctx->obj = rss_bpf_ctx; | ||
184 | + ctx->program_fd = bpf_program__fd( | ||
185 | + rss_bpf_ctx->progs.tun_rss_steering_prog); | ||
186 | + ctx->map_configuration = bpf_map__fd( | ||
187 | + rss_bpf_ctx->maps.tap_rss_map_configurations); | ||
188 | + ctx->map_indirections_table = bpf_map__fd( | ||
189 | + rss_bpf_ctx->maps.tap_rss_map_indirection_table); | ||
190 | + ctx->map_toeplitz_key = bpf_map__fd( | ||
191 | + rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); | ||
192 | + | ||
193 | + return true; | ||
194 | +error: | ||
195 | + rss_bpf__destroy(rss_bpf_ctx); | ||
196 | + ctx->obj = NULL; | ||
197 | + | ||
198 | + return false; | ||
199 | +} | ||
200 | + | ||
201 | +static bool ebpf_rss_set_config(struct EBPFRSSContext *ctx, | ||
202 | + struct EBPFRSSConfig *config) | ||
203 | +{ | ||
204 | + uint32_t map_key = 0; | ||
205 | + | ||
206 | + if (!ebpf_rss_is_loaded(ctx)) { | ||
207 | + return false; | ||
208 | + } | ||
209 | + if (bpf_map_update_elem(ctx->map_configuration, | ||
210 | + &map_key, config, 0) < 0) { | ||
211 | + return false; | ||
212 | + } | ||
213 | + return true; | ||
214 | +} | ||
215 | + | ||
216 | +static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, | ||
217 | + uint16_t *indirections_table, | ||
218 | + size_t len) | ||
219 | +{ | ||
220 | + uint32_t i = 0; | ||
221 | + | ||
222 | + if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL || | ||
223 | + len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { | ||
224 | + return false; | ||
225 | + } | ||
226 | + | ||
227 | + for (; i < len; ++i) { | ||
228 | + if (bpf_map_update_elem(ctx->map_indirections_table, &i, | ||
229 | + indirections_table + i, 0) < 0) { | ||
230 | + return false; | ||
231 | + } | 579 | + } |
232 | + } | 580 | + } |
233 | + return true; | 581 | + |
582 | + rnh->common.mc_id = nh->mc_id; | ||
583 | + rnh->common.revision = NCSI_PKT_REVISION; | ||
584 | + rnh->common.id = nh->id; | ||
585 | + rnh->common.type = nh->type + 0x80; | ||
586 | + rnh->common.channel = nh->channel; | ||
587 | + | ||
588 | + if (handler) { | ||
589 | + rnh->common.length = htons(handler->payload); | ||
590 | + rnh->code = htons(NCSI_PKT_RSP_C_COMPLETED); | ||
591 | + rnh->reason = htons(NCSI_PKT_RSP_R_NO_ERROR); | ||
592 | + | ||
593 | + if (handler->handler) { | ||
594 | + /* TODO: handle errors */ | ||
595 | + handler->handler(rnh); | ||
596 | + } | ||
597 | + } else { | ||
598 | + rnh->common.length = 0; | ||
599 | + rnh->code = htons(NCSI_PKT_RSP_C_UNAVAILABLE); | ||
600 | + rnh->reason = htons(NCSI_PKT_RSP_R_UNKNOWN); | ||
601 | + } | ||
602 | + | ||
603 | + /* TODO: add a checksum at the end of the frame but the specs | ||
604 | + * allows it to be zero */ | ||
605 | + | ||
606 | + slirp_output(slirp->opaque, ncsi_reply, ETH_HLEN + sizeof(*nh) + | ||
607 | + (handler ? handler->payload : 0) + 4); | ||
234 | +} | 608 | +} |
235 | + | 609 | diff --git a/slirp/slirp.c b/slirp/slirp.c |
236 | +static bool ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, | ||
237 | + uint8_t *toeplitz_key) | ||
238 | +{ | ||
239 | + uint32_t map_key = 0; | ||
240 | + | ||
241 | + /* prepare toeplitz key */ | ||
242 | + uint8_t toe[VIRTIO_NET_RSS_MAX_KEY_SIZE] = {}; | ||
243 | + | ||
244 | + if (!ebpf_rss_is_loaded(ctx) || toeplitz_key == NULL) { | ||
245 | + return false; | ||
246 | + } | ||
247 | + memcpy(toe, toeplitz_key, VIRTIO_NET_RSS_MAX_KEY_SIZE); | ||
248 | + *(uint32_t *)toe = ntohl(*(uint32_t *)toe); | ||
249 | + | ||
250 | + if (bpf_map_update_elem(ctx->map_toeplitz_key, &map_key, toe, | ||
251 | + 0) < 0) { | ||
252 | + return false; | ||
253 | + } | ||
254 | + return true; | ||
255 | +} | ||
256 | + | ||
257 | +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config, | ||
258 | + uint16_t *indirections_table, uint8_t *toeplitz_key) | ||
259 | +{ | ||
260 | + if (!ebpf_rss_is_loaded(ctx) || config == NULL || | ||
261 | + indirections_table == NULL || toeplitz_key == NULL) { | ||
262 | + return false; | ||
263 | + } | ||
264 | + | ||
265 | + if (!ebpf_rss_set_config(ctx, config)) { | ||
266 | + return false; | ||
267 | + } | ||
268 | + | ||
269 | + if (!ebpf_rss_set_indirections_table(ctx, indirections_table, | ||
270 | + config->indirections_len)) { | ||
271 | + return false; | ||
272 | + } | ||
273 | + | ||
274 | + if (!ebpf_rss_set_toepliz_key(ctx, toeplitz_key)) { | ||
275 | + return false; | ||
276 | + } | ||
277 | + | ||
278 | + return true; | ||
279 | +} | ||
280 | + | ||
281 | +void ebpf_rss_unload(struct EBPFRSSContext *ctx) | ||
282 | +{ | ||
283 | + if (!ebpf_rss_is_loaded(ctx)) { | ||
284 | + return; | ||
285 | + } | ||
286 | + | ||
287 | + rss_bpf__destroy(ctx->obj); | ||
288 | + ctx->obj = NULL; | ||
289 | +} | ||
290 | diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h | ||
291 | new file mode 100644 | ||
292 | index XXXXXXX..XXXXXXX | ||
293 | --- /dev/null | ||
294 | +++ b/ebpf/ebpf_rss.h | ||
295 | @@ -XXX,XX +XXX,XX @@ | ||
296 | +/* | ||
297 | + * eBPF RSS header | ||
298 | + * | ||
299 | + * Developed by Daynix Computing LTD (http://www.daynix.com) | ||
300 | + * | ||
301 | + * Authors: | ||
302 | + * Andrew Melnychenko <andrew@daynix.com> | ||
303 | + * Yuri Benditovich <yuri.benditovich@daynix.com> | ||
304 | + * | ||
305 | + * This work is licensed under the terms of the GNU GPL, version 2. See | ||
306 | + * the COPYING file in the top-level directory. | ||
307 | + */ | ||
308 | + | ||
309 | +#ifndef QEMU_EBPF_RSS_H | ||
310 | +#define QEMU_EBPF_RSS_H | ||
311 | + | ||
312 | +struct EBPFRSSContext { | ||
313 | + void *obj; | ||
314 | + int program_fd; | ||
315 | + int map_configuration; | ||
316 | + int map_toeplitz_key; | ||
317 | + int map_indirections_table; | ||
318 | +}; | ||
319 | + | ||
320 | +struct EBPFRSSConfig { | ||
321 | + uint8_t redirect; | ||
322 | + uint8_t populate_hash; | ||
323 | + uint32_t hash_types; | ||
324 | + uint16_t indirections_len; | ||
325 | + uint16_t default_queue; | ||
326 | +} __attribute__((packed)); | ||
327 | + | ||
328 | +void ebpf_rss_init(struct EBPFRSSContext *ctx); | ||
329 | + | ||
330 | +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx); | ||
331 | + | ||
332 | +bool ebpf_rss_load(struct EBPFRSSContext *ctx); | ||
333 | + | ||
334 | +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config, | ||
335 | + uint16_t *indirections_table, uint8_t *toeplitz_key); | ||
336 | + | ||
337 | +void ebpf_rss_unload(struct EBPFRSSContext *ctx); | ||
338 | + | ||
339 | +#endif /* QEMU_EBPF_RSS_H */ | ||
340 | diff --git a/ebpf/meson.build b/ebpf/meson.build | ||
341 | new file mode 100644 | ||
342 | index XXXXXXX..XXXXXXX | ||
343 | --- /dev/null | ||
344 | +++ b/ebpf/meson.build | ||
345 | @@ -0,0 +1 @@ | ||
346 | +common_ss.add(when: libbpf, if_true: files('ebpf_rss.c'), if_false: files('ebpf_rss-stub.c')) | ||
347 | diff --git a/ebpf/rss.bpf.skeleton.h b/ebpf/rss.bpf.skeleton.h | ||
348 | new file mode 100644 | ||
349 | index XXXXXXX..XXXXXXX | ||
350 | --- /dev/null | ||
351 | +++ b/ebpf/rss.bpf.skeleton.h | ||
352 | @@ -XXX,XX +XXX,XX @@ | ||
353 | +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ | ||
354 | + | ||
355 | +/* THIS FILE IS AUTOGENERATED! */ | ||
356 | +#ifndef __RSS_BPF_SKEL_H__ | ||
357 | +#define __RSS_BPF_SKEL_H__ | ||
358 | + | ||
359 | +#include <stdlib.h> | ||
360 | +#include <bpf/libbpf.h> | ||
361 | + | ||
362 | +struct rss_bpf { | ||
363 | + struct bpf_object_skeleton *skeleton; | ||
364 | + struct bpf_object *obj; | ||
365 | + struct { | ||
366 | + struct bpf_map *tap_rss_map_configurations; | ||
367 | + struct bpf_map *tap_rss_map_indirection_table; | ||
368 | + struct bpf_map *tap_rss_map_toeplitz_key; | ||
369 | + } maps; | ||
370 | + struct { | ||
371 | + struct bpf_program *tun_rss_steering_prog; | ||
372 | + } progs; | ||
373 | + struct { | ||
374 | + struct bpf_link *tun_rss_steering_prog; | ||
375 | + } links; | ||
376 | +}; | ||
377 | + | ||
378 | +static void | ||
379 | +rss_bpf__destroy(struct rss_bpf *obj) | ||
380 | +{ | ||
381 | + if (!obj) | ||
382 | + return; | ||
383 | + if (obj->skeleton) | ||
384 | + bpf_object__destroy_skeleton(obj->skeleton); | ||
385 | + free(obj); | ||
386 | +} | ||
387 | + | ||
388 | +static inline int | ||
389 | +rss_bpf__create_skeleton(struct rss_bpf *obj); | ||
390 | + | ||
391 | +static inline struct rss_bpf * | ||
392 | +rss_bpf__open_opts(const struct bpf_object_open_opts *opts) | ||
393 | +{ | ||
394 | + struct rss_bpf *obj; | ||
395 | + | ||
396 | + obj = (struct rss_bpf *)calloc(1, sizeof(*obj)); | ||
397 | + if (!obj) | ||
398 | + return NULL; | ||
399 | + if (rss_bpf__create_skeleton(obj)) | ||
400 | + goto err; | ||
401 | + if (bpf_object__open_skeleton(obj->skeleton, opts)) | ||
402 | + goto err; | ||
403 | + | ||
404 | + return obj; | ||
405 | +err: | ||
406 | + rss_bpf__destroy(obj); | ||
407 | + return NULL; | ||
408 | +} | ||
409 | + | ||
410 | +static inline struct rss_bpf * | ||
411 | +rss_bpf__open(void) | ||
412 | +{ | ||
413 | + return rss_bpf__open_opts(NULL); | ||
414 | +} | ||
415 | + | ||
416 | +static inline int | ||
417 | +rss_bpf__load(struct rss_bpf *obj) | ||
418 | +{ | ||
419 | + return bpf_object__load_skeleton(obj->skeleton); | ||
420 | +} | ||
421 | + | ||
422 | +static inline struct rss_bpf * | ||
423 | +rss_bpf__open_and_load(void) | ||
424 | +{ | ||
425 | + struct rss_bpf *obj; | ||
426 | + | ||
427 | + obj = rss_bpf__open(); | ||
428 | + if (!obj) | ||
429 | + return NULL; | ||
430 | + if (rss_bpf__load(obj)) { | ||
431 | + rss_bpf__destroy(obj); | ||
432 | + return NULL; | ||
433 | + } | ||
434 | + return obj; | ||
435 | +} | ||
436 | + | ||
437 | +static inline int | ||
438 | +rss_bpf__attach(struct rss_bpf *obj) | ||
439 | +{ | ||
440 | + return bpf_object__attach_skeleton(obj->skeleton); | ||
441 | +} | ||
442 | + | ||
443 | +static inline void | ||
444 | +rss_bpf__detach(struct rss_bpf *obj) | ||
445 | +{ | ||
446 | + return bpf_object__detach_skeleton(obj->skeleton); | ||
447 | +} | ||
448 | + | ||
449 | +static inline int | ||
450 | +rss_bpf__create_skeleton(struct rss_bpf *obj) | ||
451 | +{ | ||
452 | + struct bpf_object_skeleton *s; | ||
453 | + | ||
454 | + s = (struct bpf_object_skeleton *)calloc(1, sizeof(*s)); | ||
455 | + if (!s) | ||
456 | + return -1; | ||
457 | + obj->skeleton = s; | ||
458 | + | ||
459 | + s->sz = sizeof(*s); | ||
460 | + s->name = "rss_bpf"; | ||
461 | + s->obj = &obj->obj; | ||
462 | + | ||
463 | + /* maps */ | ||
464 | + s->map_cnt = 3; | ||
465 | + s->map_skel_sz = sizeof(*s->maps); | ||
466 | + s->maps = (struct bpf_map_skeleton *)calloc(s->map_cnt, s->map_skel_sz); | ||
467 | + if (!s->maps) | ||
468 | + goto err; | ||
469 | + | ||
470 | + s->maps[0].name = "tap_rss_map_configurations"; | ||
471 | + s->maps[0].map = &obj->maps.tap_rss_map_configurations; | ||
472 | + | ||
473 | + s->maps[1].name = "tap_rss_map_indirection_table"; | ||
474 | + s->maps[1].map = &obj->maps.tap_rss_map_indirection_table; | ||
475 | + | ||
476 | + s->maps[2].name = "tap_rss_map_toeplitz_key"; | ||
477 | + s->maps[2].map = &obj->maps.tap_rss_map_toeplitz_key; | ||
478 | + | ||
479 | + /* programs */ | ||
480 | + s->prog_cnt = 1; | ||
481 | + s->prog_skel_sz = sizeof(*s->progs); | ||
482 | + s->progs = (struct bpf_prog_skeleton *)calloc(s->prog_cnt, s->prog_skel_sz); | ||
483 | + if (!s->progs) | ||
484 | + goto err; | ||
485 | + | ||
486 | + s->progs[0].name = "tun_rss_steering_prog"; | ||
487 | + s->progs[0].prog = &obj->progs.tun_rss_steering_prog; | ||
488 | + s->progs[0].link = &obj->links.tun_rss_steering_prog; | ||
489 | + | ||
490 | + s->data_sz = 8088; | ||
491 | + s->data = (void *)"\ | ||
492 | +\x7f\x45\x4c\x46\x02\x01\x01\0\0\0\0\0\0\0\0\0\x01\0\xf7\0\x01\0\0\0\0\0\0\0\0\ | ||
493 | +\0\0\0\0\0\0\0\0\0\0\0\x18\x1d\0\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\x40\0\x0a\0\ | ||
494 | +\x01\0\xbf\x18\0\0\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\x4c\xff\0\0\0\0\xbf\xa7\ | ||
495 | +\0\0\0\0\0\0\x07\x07\0\0\x4c\xff\xff\xff\x18\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
496 | +\xbf\x72\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x06\0\0\0\0\0\0\x18\x01\0\0\0\0\0\ | ||
497 | +\0\0\0\0\0\0\0\0\0\xbf\x72\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x07\0\0\0\0\0\0\ | ||
498 | +\x18\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\x15\x06\x66\x02\0\0\0\0\xbf\x79\0\0\ | ||
499 | +\0\0\0\0\x15\x09\x64\x02\0\0\0\0\x71\x61\0\0\0\0\0\0\x55\x01\x01\0\0\0\0\0\x05\ | ||
500 | +\0\x5d\x02\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\xc0\xff\0\0\0\0\x7b\x1a\xb8\xff\ | ||
501 | +\0\0\0\0\x7b\x1a\xb0\xff\0\0\0\0\x7b\x1a\xa8\xff\0\0\0\0\x7b\x1a\xa0\xff\0\0\0\ | ||
502 | +\0\x63\x1a\x98\xff\0\0\0\0\x7b\x1a\x90\xff\0\0\0\0\x7b\x1a\x88\xff\0\0\0\0\x7b\ | ||
503 | +\x1a\x80\xff\0\0\0\0\x7b\x1a\x78\xff\0\0\0\0\x7b\x1a\x70\xff\0\0\0\0\x7b\x1a\ | ||
504 | +\x68\xff\0\0\0\0\x7b\x1a\x60\xff\0\0\0\0\x7b\x1a\x58\xff\0\0\0\0\x7b\x1a\x50\ | ||
505 | +\xff\0\0\0\0\x15\x08\x4c\x02\0\0\0\0\x6b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\ | ||
506 | +\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x02\0\0\x0c\0\0\0\xb7\ | ||
507 | +\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\x85\0\0\0\x44\0\0\0\x67\0\0\0\x20\0\0\0\ | ||
508 | +\x77\0\0\0\x20\0\0\0\x55\0\x11\0\0\0\0\0\xb7\x02\0\0\x10\0\0\0\x69\xa1\xd0\xff\ | ||
509 | +\0\0\0\0\xbf\x13\0\0\0\0\0\0\xdc\x03\0\0\x10\0\0\0\x15\x03\x02\0\0\x81\0\0\x55\ | ||
510 | +\x03\x0c\0\xa8\x88\0\0\xb7\x02\0\0\x14\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\ | ||
511 | +\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\ | ||
512 | +\x85\0\0\0\x44\0\0\0\x69\xa1\xd0\xff\0\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\ | ||
513 | +\0\0\0\x15\0\x01\0\0\0\0\0\x05\0\x2f\x02\0\0\0\0\x15\x01\x2e\x02\0\0\0\0\x7b\ | ||
514 | +\x9a\x30\xff\0\0\0\0\x15\x01\x57\0\x86\xdd\0\0\x55\x01\x3b\0\x08\0\0\0\x7b\x7a\ | ||
515 | +\x20\xff\0\0\0\0\xb7\x07\0\0\x01\0\0\0\x73\x7a\x50\xff\0\0\0\0\xb7\x01\0\0\0\0\ | ||
516 | +\0\0\x63\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\ | ||
517 | +\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x02\0\ | ||
518 | +\0\0\0\0\0\xb7\x04\0\0\x14\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x67\ | ||
519 | +\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\x1a\x02\0\0\0\0\x69\xa1\xd6\xff\0\0\ | ||
520 | +\0\0\x55\x01\x01\0\0\0\0\0\xb7\x07\0\0\0\0\0\0\x61\xa1\xdc\xff\0\0\0\0\x63\x1a\ | ||
521 | +\x5c\xff\0\0\0\0\x61\xa1\xe0\xff\0\0\0\0\x63\x1a\x60\xff\0\0\0\0\x73\x7a\x56\ | ||
522 | +\xff\0\0\0\0\x71\xa9\xd9\xff\0\0\0\0\x71\xa1\xd0\xff\0\0\0\0\x67\x01\0\0\x02\0\ | ||
523 | +\0\0\x57\x01\0\0\x3c\0\0\0\x7b\x1a\x40\xff\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\xbf\ | ||
524 | +\x91\0\0\0\0\0\0\x57\x01\0\0\xff\0\0\0\x15\x01\x19\0\0\0\0\0\x71\xa1\x56\xff\0\ | ||
525 | +\0\0\0\x55\x01\x17\0\0\0\0\0\x57\x09\0\0\xff\0\0\0\x15\x09\x7a\x01\x11\0\0\0\ | ||
526 | +\x55\x09\x14\0\x06\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x53\xff\0\0\0\0\xb7\x01\ | ||
527 | +\0\0\0\0\0\0\x63\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\ | ||
528 | +\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\ | ||
529 | +\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x14\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\ | ||
530 | +\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\xf4\x01\0\0\0\0\x69\xa1\ | ||
531 | +\xd0\xff\0\0\0\0\x6b\x1a\x58\xff\0\0\0\0\x69\xa1\xd2\xff\0\0\0\0\x6b\x1a\x5a\ | ||
532 | +\xff\0\0\0\0\x71\xa1\x50\xff\0\0\0\0\x15\x01\xd4\0\0\0\0\0\x71\x62\x03\0\0\0\0\ | ||
533 | +\0\x67\x02\0\0\x08\0\0\0\x71\x61\x02\0\0\0\0\0\x4f\x12\0\0\0\0\0\0\x71\x63\x04\ | ||
534 | +\0\0\0\0\0\x71\x61\x05\0\0\0\0\0\x67\x01\0\0\x08\0\0\0\x4f\x31\0\0\0\0\0\0\x67\ | ||
535 | +\x01\0\0\x10\0\0\0\x4f\x21\0\0\0\0\0\0\x71\xa2\x53\xff\0\0\0\0\x79\xa0\x30\xff\ | ||
536 | +\0\0\0\0\x15\x02\x06\x01\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x02\0\0\0\x15\ | ||
537 | +\x02\x03\x01\0\0\0\0\x61\xa1\x5c\xff\0\0\0\0\x63\x1a\xa0\xff\0\0\0\0\x61\xa1\ | ||
538 | +\x60\xff\0\0\0\0\x63\x1a\xa4\xff\0\0\0\0\x69\xa1\x58\xff\0\0\0\0\x6b\x1a\xa8\ | ||
539 | +\xff\0\0\0\0\x69\xa1\x5a\xff\0\0\0\0\x6b\x1a\xaa\xff\0\0\0\0\x05\0\x65\x01\0\0\ | ||
540 | +\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x51\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\ | ||
541 | +\xf0\xff\0\0\0\0\x7b\x1a\xe8\xff\0\0\0\0\x7b\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\ | ||
542 | +\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\ | ||
543 | +\xff\xff\xb7\x01\0\0\x28\0\0\0\x7b\x1a\x40\xff\0\0\0\0\xbf\x81\0\0\0\0\0\0\xb7\ | ||
544 | +\x02\0\0\0\0\0\0\xb7\x04\0\0\x28\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\ | ||
545 | +\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\x10\x01\0\0\0\0\x79\xa1\xe0\ | ||
546 | +\xff\0\0\0\0\x63\x1a\x64\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x68\xff\0\0\ | ||
547 | +\0\0\x79\xa1\xd8\xff\0\0\0\0\x63\x1a\x5c\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\ | ||
548 | +\x1a\x60\xff\0\0\0\0\x79\xa1\xe8\xff\0\0\0\0\x63\x1a\x6c\xff\0\0\0\0\x77\x01\0\ | ||
549 | +\0\x20\0\0\0\x63\x1a\x70\xff\0\0\0\0\x79\xa1\xf0\xff\0\0\0\0\x63\x1a\x74\xff\0\ | ||
550 | +\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x78\xff\0\0\0\0\x71\xa9\xd6\xff\0\0\0\0\ | ||
551 | +\x25\x09\xff\0\x3c\0\0\0\xb7\x01\0\0\x01\0\0\0\x6f\x91\0\0\0\0\0\0\x18\x02\0\0\ | ||
552 | +\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x21\0\0\0\0\0\0\x55\x01\x01\0\0\0\0\0\x05\0\ | ||
553 | +\xf8\0\0\0\0\0\xb7\x01\0\0\0\0\0\0\x6b\x1a\xfe\xff\0\0\0\0\xb7\x01\0\0\x28\0\0\ | ||
554 | +\0\x7b\x1a\x40\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x8c\xff\xff\xff\x7b\ | ||
555 | +\x1a\x18\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x7c\xff\xff\xff\x7b\x1a\ | ||
556 | +\x10\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\x28\xff\0\0\0\0\x7b\x7a\x20\xff\0\ | ||
557 | +\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xfe\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\ | ||
558 | +\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\ | ||
559 | +\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x15\0\x01\0\0\0\0\0\x05\0\x90\ | ||
560 | +\x01\0\0\0\0\xbf\x91\0\0\0\0\0\0\x15\x01\x23\0\x3c\0\0\0\x15\x01\x59\0\x2c\0\0\ | ||
561 | +\0\x55\x01\x5a\0\x2b\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\xf8\xff\0\0\0\0\xbf\xa3\ | ||
562 | +\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\xa2\x40\xff\0\ | ||
563 | +\0\0\0\xb7\x04\0\0\x04\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\ | ||
564 | +\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\x03\x01\0\0\0\ | ||
565 | +\0\x71\xa1\xfa\xff\0\0\0\0\x55\x01\x4b\0\x02\0\0\0\x71\xa1\xf9\xff\0\0\0\0\x55\ | ||
566 | +\x01\x49\0\x02\0\0\0\x71\xa1\xfb\xff\0\0\0\0\x55\x01\x47\0\x01\0\0\0\x79\xa2\ | ||
567 | +\x40\xff\0\0\0\0\x07\x02\0\0\x08\0\0\0\xbf\x81\0\0\0\0\0\0\x79\xa3\x18\xff\0\0\ | ||
568 | +\0\0\xb7\x04\0\0\x10\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\0\ | ||
569 | +\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\xf2\0\0\0\0\0\ | ||
570 | +\xb7\x01\0\0\x01\0\0\0\x73\x1a\x55\xff\0\0\0\0\x05\0\x39\0\0\0\0\0\xb7\x01\0\0\ | ||
571 | +\0\0\0\0\x6b\x1a\xf8\xff\0\0\0\0\xb7\x09\0\0\x02\0\0\0\xb7\x07\0\0\x1e\0\0\0\ | ||
572 | +\x05\0\x0e\0\0\0\0\0\x79\xa2\x38\xff\0\0\0\0\x0f\x29\0\0\0\0\0\0\xbf\x92\0\0\0\ | ||
573 | +\0\0\0\x07\x02\0\0\x01\0\0\0\x71\xa3\xff\xff\0\0\0\0\x67\x03\0\0\x03\0\0\0\x2d\ | ||
574 | +\x23\x02\0\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\x05\0\x2b\0\0\0\0\0\x07\x07\0\0\xff\ | ||
575 | +\xff\xff\xff\xbf\x72\0\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x77\x02\0\0\x20\0\0\0\ | ||
576 | +\x15\x02\xf9\xff\0\0\0\0\x7b\x9a\x38\xff\0\0\0\0\x79\xa1\x40\xff\0\0\0\0\x0f\ | ||
577 | +\x19\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\xbf\x81\0\0\0\ | ||
578 | +\0\0\0\xbf\x92\0\0\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\ | ||
579 | +\0\x44\0\0\0\xbf\x01\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\ | ||
580 | +\x55\x01\x94\0\0\0\0\0\x71\xa2\xf8\xff\0\0\0\0\x55\x02\x0f\0\xc9\0\0\0\x07\x09\ | ||
581 | +\0\0\x02\0\0\0\xbf\x81\0\0\0\0\0\0\xbf\x92\0\0\0\0\0\0\x79\xa3\x10\xff\0\0\0\0\ | ||
582 | +\xb7\x04\0\0\x10\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\0\0\0\ | ||
583 | +\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\x87\0\0\0\0\0\xb7\ | ||
584 | +\x01\0\0\x01\0\0\0\x73\x1a\x54\xff\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\x05\0\x07\0\ | ||
585 | +\0\0\0\0\xb7\x09\0\0\x01\0\0\0\x15\x02\xd1\xff\0\0\0\0\x71\xa9\xf9\xff\0\0\0\0\ | ||
586 | +\x07\x09\0\0\x02\0\0\0\x05\0\xce\xff\0\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x56\ | ||
587 | +\xff\0\0\0\0\x71\xa1\xff\xff\0\0\0\0\x67\x01\0\0\x03\0\0\0\x79\xa2\x40\xff\0\0\ | ||
588 | +\0\0\x0f\x12\0\0\0\0\0\0\x07\x02\0\0\x08\0\0\0\x7b\x2a\x40\xff\0\0\0\0\x71\xa9\ | ||
589 | +\xfe\xff\0\0\0\0\x25\x09\x0e\0\x3c\0\0\0\xb7\x01\0\0\x01\0\0\0\x6f\x91\0\0\0\0\ | ||
590 | +\0\0\x18\x02\0\0\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x21\0\0\0\0\0\0\x55\x01\x01\ | ||
591 | +\0\0\0\0\0\x05\0\x07\0\0\0\0\0\x79\xa1\x28\xff\0\0\0\0\x07\x01\0\0\x01\0\0\0\ | ||
592 | +\x7b\x1a\x28\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\ | ||
593 | +\x82\xff\x0b\0\0\0\x05\0\x10\xff\0\0\0\0\x15\x09\xf8\xff\x87\0\0\0\x05\0\xfd\ | ||
594 | +\xff\0\0\0\0\x71\xa1\x51\xff\0\0\0\0\x79\xa0\x30\xff\0\0\0\0\x15\x01\x17\x01\0\ | ||
595 | +\0\0\0\x71\x62\x03\0\0\0\0\0\x67\x02\0\0\x08\0\0\0\x71\x61\x02\0\0\0\0\0\x4f\ | ||
596 | +\x12\0\0\0\0\0\0\x71\x63\x04\0\0\0\0\0\x71\x61\x05\0\0\0\0\0\x67\x01\0\0\x08\0\ | ||
597 | +\0\0\x4f\x31\0\0\0\0\0\0\x67\x01\0\0\x10\0\0\0\x4f\x21\0\0\0\0\0\0\x71\xa2\x53\ | ||
598 | +\xff\0\0\0\0\x15\x02\x3d\0\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x10\0\0\0\ | ||
599 | +\x15\x02\x3a\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x71\xa4\ | ||
600 | +\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\ | ||
601 | +\x07\x03\0\0\x7c\xff\xff\xff\x67\x01\0\0\x38\0\0\0\xc7\x01\0\0\x38\0\0\0\x65\ | ||
602 | +\x01\x01\0\xff\xff\xff\xff\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\ | ||
603 | +\x6c\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0\x15\x05\x02\0\0\0\ | ||
604 | +\0\0\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x65\x01\x01\0\xff\xff\xff\ | ||
605 | +\xff\xbf\x43\0\0\0\0\0\0\x61\x21\x04\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\x24\0\ | ||
606 | +\0\0\0\0\0\x4f\x41\0\0\0\0\0\0\x7b\x1a\xa0\xff\0\0\0\0\x61\x21\x08\0\0\0\0\0\ | ||
607 | +\x61\x22\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0\0\0\0\0\x7b\x2a\xa8\ | ||
608 | +\xff\0\0\0\0\x61\x31\0\0\0\0\0\0\x61\x32\x04\0\0\0\0\0\x61\x34\x08\0\0\0\0\0\ | ||
609 | +\x61\x33\x0c\0\0\0\0\0\x69\xa5\x5a\xff\0\0\0\0\x6b\x5a\xc2\xff\0\0\0\0\x69\xa5\ | ||
610 | +\x58\xff\0\0\0\0\x6b\x5a\xc0\xff\0\0\0\0\x67\x03\0\0\x20\0\0\0\x4f\x43\0\0\0\0\ | ||
611 | +\0\0\x7b\x3a\xb8\xff\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0\0\0\0\0\x7b\x2a\ | ||
612 | +\xb0\xff\0\0\0\0\x05\0\x6b\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x15\x02\x04\0\0\0\ | ||
613 | +\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x04\0\0\0\x15\x02\x01\0\0\0\0\0\x05\0\xf7\ | ||
614 | +\xfe\0\0\0\0\x57\x01\0\0\x01\0\0\0\x15\x01\xd3\0\0\0\0\0\x61\xa1\x5c\xff\0\0\0\ | ||
615 | +\0\x63\x1a\xa0\xff\0\0\0\0\x61\xa1\x60\xff\0\0\0\0\x63\x1a\xa4\xff\0\0\0\0\x05\ | ||
616 | +\0\x5e\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x15\x02\x1e\0\0\0\0\0\xbf\x12\0\0\0\0\ | ||
617 | +\0\0\x57\x02\0\0\x20\0\0\0\x15\x02\x1b\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\ | ||
618 | +\0\x5c\xff\xff\xff\x71\xa4\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\ | ||
619 | +\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\x7c\xff\xff\xff\x57\x01\0\0\0\x01\0\0\ | ||
620 | +\x15\x01\x01\0\0\0\0\0\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\x6c\ | ||
621 | +\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0\x15\x05\x02\0\0\0\0\0\ | ||
622 | +\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x15\x01\xc3\xff\0\0\0\0\x05\0\ | ||
623 | +\xc1\xff\0\0\0\0\xb7\x09\0\0\x3c\0\0\0\x79\xa7\x20\xff\0\0\0\0\x67\0\0\0\x20\0\ | ||
624 | +\0\0\x77\0\0\0\x20\0\0\0\x15\0\xa5\xfe\0\0\0\0\x05\0\xb0\0\0\0\0\0\x15\x09\x07\ | ||
625 | +\xff\x87\0\0\0\x05\0\xa2\xfe\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x08\0\0\0\ | ||
626 | +\x15\x02\xab\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x71\xa4\ | ||
627 | +\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\ | ||
628 | +\x07\x03\0\0\x7c\xff\xff\xff\x57\x01\0\0\x40\0\0\0\x15\x01\x01\0\0\0\0\0\xbf\ | ||
629 | +\x32\0\0\0\0\0\0\x61\x23\x04\0\0\0\0\0\x67\x03\0\0\x20\0\0\0\x61\x24\0\0\0\0\0\ | ||
630 | +\0\x4f\x43\0\0\0\0\0\0\x7b\x3a\xa0\xff\0\0\0\0\x61\x23\x08\0\0\0\0\0\x61\x22\ | ||
631 | +\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x32\0\0\0\0\0\0\x7b\x2a\xa8\xff\0\0\0\ | ||
632 | +\0\x15\x01\x1c\0\0\0\0\0\x71\xa1\x55\xff\0\0\0\0\x15\x01\x1a\0\0\0\0\0\x61\xa1\ | ||
633 | +\x98\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x94\xff\0\0\0\0\x4f\x21\0\0\0\0\ | ||
634 | +\0\0\x7b\x1a\xb8\xff\0\0\0\0\x61\xa1\x90\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\ | ||
635 | +\xa2\x8c\xff\0\0\0\0\x05\0\x19\0\0\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x52\xff\ | ||
636 | +\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\ | ||
637 | +\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\xa2\x40\xff\0\0\0\0\xb7\x04\0\ | ||
638 | +\0\x08\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x67\0\0\0\x20\0\0\0\x77\ | ||
639 | +\0\0\0\x20\0\0\0\x55\0\x7d\0\0\0\0\0\x05\0\x88\xfe\0\0\0\0\xb7\x09\0\0\x2b\0\0\ | ||
640 | +\0\x05\0\xc6\xff\0\0\0\0\x61\xa1\x78\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\ | ||
641 | +\x74\xff\0\0\0\0\x4f\x21\0\0\0\0\0\0\x7b\x1a\xb8\xff\0\0\0\0\x61\xa1\x70\xff\0\ | ||
642 | +\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x6c\xff\0\0\0\0\x4f\x21\0\0\0\0\0\0\x7b\ | ||
643 | +\x1a\xb0\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x07\x07\0\0\x04\0\0\0\x61\x03\0\0\0\0\ | ||
644 | +\0\0\xb7\x05\0\0\0\0\0\0\x05\0\x4e\0\0\0\0\0\xaf\x52\0\0\0\0\0\0\xbf\x75\0\0\0\ | ||
645 | +\0\0\0\x0f\x15\0\0\0\0\0\0\x71\x55\0\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\ | ||
646 | +\0\0\0\0\0\x77\0\0\0\x07\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\ | ||
647 | +\0\x39\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\ | ||
648 | +\x50\0\0\0\0\0\0\x77\0\0\0\x06\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\ | ||
649 | +\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3a\0\0\0\xc7\0\0\0\x3f\0\0\ | ||
650 | +\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\0\0\ | ||
651 | +\0\0\0\x77\0\0\0\x05\0\0\0\x57\0\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\ | ||
652 | +\0\0\0\0\x67\0\0\0\x3b\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\ | ||
653 | +\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x04\0\0\0\x57\0\ | ||
654 | +\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3c\0\0\0\xc7\ | ||
655 | +\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\ | ||
656 | +\x77\0\0\0\x03\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x03\0\0\0\0\ | ||
657 | +\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3d\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\ | ||
658 | +\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x02\0\0\0\x57\0\0\0\ | ||
659 | +\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\ | ||
660 | +\0\0\x3e\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\ | ||
661 | +\x50\0\0\0\0\0\0\x77\0\0\0\x01\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\ | ||
662 | +\x4f\x03\0\0\0\0\0\0\x57\x04\0\0\x01\0\0\0\x87\x04\0\0\0\0\0\0\x5f\x34\0\0\0\0\ | ||
663 | +\0\0\xaf\x42\0\0\0\0\0\0\x57\x05\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x53\0\ | ||
664 | +\0\0\0\0\0\x07\x01\0\0\x01\0\0\0\xbf\x25\0\0\0\0\0\0\x15\x01\x0b\0\x24\0\0\0\ | ||
665 | +\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\xa0\xff\xff\xff\x0f\x12\0\0\0\0\0\0\x71\x24\0\ | ||
666 | +\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x38\0\0\0\xc7\0\0\0\x38\0\0\0\xb7\x02\ | ||
667 | +\0\0\0\0\0\0\x65\0\xa9\xff\xff\xff\xff\xff\xbf\x32\0\0\0\0\0\0\x05\0\xa7\xff\0\ | ||
668 | +\0\0\0\xbf\x21\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x15\x01\ | ||
669 | +\x0e\0\0\0\0\0\x71\x63\x06\0\0\0\0\0\x71\x64\x07\0\0\0\0\0\x67\x04\0\0\x08\0\0\ | ||
670 | +\0\x4f\x34\0\0\0\0\0\0\x3f\x41\0\0\0\0\0\0\x2f\x41\0\0\0\0\0\0\x1f\x12\0\0\0\0\ | ||
671 | +\0\0\x63\x2a\x50\xff\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x50\xff\xff\xff\ | ||
672 | +\x18\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\x55\0\x05\0\0\0\0\0\ | ||
673 | +\x71\x61\x08\0\0\0\0\0\x71\x60\x09\0\0\0\0\0\x67\0\0\0\x08\0\0\0\x4f\x10\0\0\0\ | ||
674 | +\0\0\0\x95\0\0\0\0\0\0\0\x69\0\0\0\0\0\0\0\x05\0\xfd\xff\0\0\0\0\x02\0\0\0\x04\ | ||
675 | +\0\0\0\x0a\0\0\0\x01\0\0\0\0\0\0\0\x02\0\0\0\x04\0\0\0\x28\0\0\0\x01\0\0\0\0\0\ | ||
676 | +\0\0\x02\0\0\0\x04\0\0\0\x02\0\0\0\x80\0\0\0\0\0\0\0\x47\x50\x4c\x20\x76\x32\0\ | ||
677 | +\0\0\0\0\0\x10\0\0\0\0\0\0\0\x01\x7a\x52\0\x08\x7c\x0b\x01\x0c\0\0\0\x18\0\0\0\ | ||
678 | +\x18\0\0\0\0\0\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
679 | +\0\0\0\0\0\0\0\0\0\0\0\0\xa0\0\0\0\x04\0\xf1\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
680 | +\0\x60\x02\0\0\0\0\x03\0\x20\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3f\x02\0\0\0\0\ | ||
681 | +\x03\0\xd0\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xed\x01\0\0\0\0\x03\0\x10\x10\0\0\0\ | ||
682 | +\0\0\0\0\0\0\0\0\0\0\0\xd4\x01\0\0\0\0\x03\0\x20\x10\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
683 | +\0\xa3\x01\0\0\0\0\x03\0\xb8\x12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x63\x01\0\0\0\0\ | ||
684 | +\x03\0\x48\x10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2a\x01\0\0\0\0\x03\0\x10\x13\0\0\0\ | ||
685 | +\0\0\0\0\0\0\0\0\0\0\0\xe1\0\0\0\0\0\x03\0\xa0\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
686 | +\x2e\x02\0\0\0\0\x03\0\x28\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x68\x02\0\0\0\0\x03\ | ||
687 | +\0\xc0\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x36\x02\0\0\0\0\x03\0\xc8\x13\0\0\0\0\0\ | ||
688 | +\0\0\0\0\0\0\0\0\0\x22\x01\0\0\0\0\x03\0\xe8\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
689 | +\x02\x01\0\0\0\0\x03\0\x40\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd9\0\0\0\0\0\x03\0\ | ||
690 | +\xf8\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x26\x02\0\0\0\0\x03\0\x20\x0e\0\0\0\0\0\0\ | ||
691 | +\0\0\0\0\0\0\0\0\xcc\x01\0\0\0\0\x03\0\x60\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x9b\ | ||
692 | +\x01\0\0\0\0\x03\0\xc8\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x5b\x01\0\0\0\0\x03\0\ | ||
693 | +\x20\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x7c\x01\0\0\0\0\x03\0\x48\x08\0\0\0\0\0\0\ | ||
694 | +\0\0\0\0\0\0\0\0\x53\x01\0\0\0\0\x03\0\xb8\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1a\ | ||
695 | +\x01\0\0\0\0\x03\0\xe0\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x84\x01\0\0\0\0\x03\0\ | ||
696 | +\xb8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1e\x02\0\0\0\0\x03\0\xd8\x09\0\0\0\0\0\0\0\ | ||
697 | +\0\0\0\0\0\0\0\xc4\x01\0\0\0\0\x03\0\x70\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x93\ | ||
698 | +\x01\0\0\0\0\x03\0\xa8\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x74\x01\0\0\0\0\x03\0\ | ||
699 | +\xf0\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x4b\x01\0\0\0\0\x03\0\0\x0a\0\0\0\0\0\0\0\ | ||
700 | +\0\0\0\0\0\0\0\x12\x01\0\0\0\0\x03\0\x10\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xfa\0\ | ||
701 | +\0\0\0\0\x03\0\xc0\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x58\x02\0\0\0\0\x03\0\x88\ | ||
702 | +\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x16\x02\0\0\0\0\x03\0\xb8\x0a\0\0\0\0\0\0\0\0\ | ||
703 | +\0\0\0\0\0\0\xe5\x01\0\0\0\0\x03\0\xc0\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xbc\x01\ | ||
704 | +\0\0\0\0\x03\0\0\x0e\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x8b\x01\0\0\0\0\x03\0\x18\x0e\ | ||
705 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd1\0\0\0\0\0\x03\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
706 | +\0\0\x50\x02\0\0\0\0\x03\0\x20\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0e\x02\0\0\0\0\ | ||
707 | +\x03\0\x48\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6c\x01\0\0\0\0\x03\0\xb0\x04\0\0\0\ | ||
708 | +\0\0\0\0\0\0\0\0\0\0\0\x43\x01\0\0\0\0\x03\0\xc8\x0c\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
709 | +\0\xc9\0\0\0\0\0\x03\0\xf8\x0c\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x06\x02\0\0\0\0\x03\ | ||
710 | +\0\xd0\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3b\x01\0\0\0\0\x03\0\x98\x0b\0\0\0\0\0\ | ||
711 | +\0\0\0\0\0\0\0\0\0\xf2\0\0\0\0\0\x03\0\xb8\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x48\ | ||
712 | +\x02\0\0\0\0\x03\0\xf0\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xfe\x01\0\0\0\0\x03\0\ | ||
713 | +\xf8\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xdd\x01\0\0\0\0\x03\0\0\x0c\0\0\0\0\0\0\0\ | ||
714 | +\0\0\0\0\0\0\0\xb4\x01\0\0\0\0\x03\0\x30\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0a\ | ||
715 | +\x01\0\0\0\0\x03\0\x90\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xc1\0\0\0\0\0\x03\0\xa8\ | ||
716 | +\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xba\0\0\0\0\0\x03\0\xd0\x01\0\0\0\0\0\0\0\0\0\ | ||
717 | +\0\0\0\0\0\xf6\x01\0\0\0\0\x03\0\xe0\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xac\x01\0\ | ||
718 | +\0\0\0\x03\0\x30\x0e\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x33\x01\0\0\0\0\x03\0\x80\x0e\ | ||
719 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xea\0\0\0\0\0\x03\0\x98\x0e\0\0\0\0\0\0\0\0\0\0\0\ | ||
720 | +\0\0\0\0\0\0\0\x03\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6b\0\0\0\x11\0\x06\ | ||
721 | +\0\0\0\0\0\0\0\0\0\x07\0\0\0\0\0\0\0\x25\0\0\0\x11\0\x05\0\0\0\0\0\0\0\0\0\x14\ | ||
722 | +\0\0\0\0\0\0\0\x82\0\0\0\x11\0\x05\0\x28\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x01\0\ | ||
723 | +\0\0\x11\0\x05\0\x14\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x40\0\0\0\x12\0\x03\0\0\0\ | ||
724 | +\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\x28\0\0\0\0\0\0\0\x01\0\0\0\x3a\0\0\0\x50\0\0\ | ||
725 | +\0\0\0\0\0\x01\0\0\0\x3c\0\0\0\x80\x13\0\0\0\0\0\0\x01\0\0\0\x3b\0\0\0\x1c\0\0\ | ||
726 | +\0\0\0\0\0\x01\0\0\0\x38\0\0\0\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\ | ||
727 | +\x5f\x74\x6f\x65\x70\x6c\x69\x74\x7a\x5f\x6b\x65\x79\0\x2e\x74\x65\x78\x74\0\ | ||
728 | +\x6d\x61\x70\x73\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x63\x6f\x6e\ | ||
729 | +\x66\x69\x67\x75\x72\x61\x74\x69\x6f\x6e\x73\0\x74\x75\x6e\x5f\x72\x73\x73\x5f\ | ||
730 | +\x73\x74\x65\x65\x72\x69\x6e\x67\x5f\x70\x72\x6f\x67\0\x2e\x72\x65\x6c\x74\x75\ | ||
731 | +\x6e\x5f\x72\x73\x73\x5f\x73\x74\x65\x65\x72\x69\x6e\x67\0\x5f\x6c\x69\x63\x65\ | ||
732 | +\x6e\x73\x65\0\x2e\x72\x65\x6c\x2e\x65\x68\x5f\x66\x72\x61\x6d\x65\0\x74\x61\ | ||
733 | +\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x69\x6e\x64\x69\x72\x65\x63\x74\x69\ | ||
734 | +\x6f\x6e\x5f\x74\x61\x62\x6c\x65\0\x72\x73\x73\x2e\x62\x70\x66\x2e\x63\0\x2e\ | ||
735 | +\x73\x74\x72\x74\x61\x62\0\x2e\x73\x79\x6d\x74\x61\x62\0\x4c\x42\x42\x30\x5f\ | ||
736 | +\x39\0\x4c\x42\x42\x30\x5f\x38\x39\0\x4c\x42\x42\x30\x5f\x36\x39\0\x4c\x42\x42\ | ||
737 | +\x30\x5f\x35\x39\0\x4c\x42\x42\x30\x5f\x31\x39\0\x4c\x42\x42\x30\x5f\x31\x30\ | ||
738 | +\x39\0\x4c\x42\x42\x30\x5f\x39\x38\0\x4c\x42\x42\x30\x5f\x37\x38\0\x4c\x42\x42\ | ||
739 | +\x30\x5f\x34\x38\0\x4c\x42\x42\x30\x5f\x31\x38\0\x4c\x42\x42\x30\x5f\x38\x37\0\ | ||
740 | +\x4c\x42\x42\x30\x5f\x34\x37\0\x4c\x42\x42\x30\x5f\x33\x37\0\x4c\x42\x42\x30\ | ||
741 | +\x5f\x31\x37\0\x4c\x42\x42\x30\x5f\x31\x30\x37\0\x4c\x42\x42\x30\x5f\x39\x36\0\ | ||
742 | +\x4c\x42\x42\x30\x5f\x37\x36\0\x4c\x42\x42\x30\x5f\x36\x36\0\x4c\x42\x42\x30\ | ||
743 | +\x5f\x34\x36\0\x4c\x42\x42\x30\x5f\x33\x36\0\x4c\x42\x42\x30\x5f\x32\x36\0\x4c\ | ||
744 | +\x42\x42\x30\x5f\x31\x30\x36\0\x4c\x42\x42\x30\x5f\x36\x35\0\x4c\x42\x42\x30\ | ||
745 | +\x5f\x34\x35\0\x4c\x42\x42\x30\x5f\x33\x35\0\x4c\x42\x42\x30\x5f\x34\0\x4c\x42\ | ||
746 | +\x42\x30\x5f\x35\x34\0\x4c\x42\x42\x30\x5f\x34\x34\0\x4c\x42\x42\x30\x5f\x32\ | ||
747 | +\x34\0\x4c\x42\x42\x30\x5f\x31\x30\x34\0\x4c\x42\x42\x30\x5f\x39\x33\0\x4c\x42\ | ||
748 | +\x42\x30\x5f\x38\x33\0\x4c\x42\x42\x30\x5f\x35\x33\0\x4c\x42\x42\x30\x5f\x34\ | ||
749 | +\x33\0\x4c\x42\x42\x30\x5f\x32\x33\0\x4c\x42\x42\x30\x5f\x31\x30\x33\0\x4c\x42\ | ||
750 | +\x42\x30\x5f\x38\x32\0\x4c\x42\x42\x30\x5f\x35\x32\0\x4c\x42\x42\x30\x5f\x31\ | ||
751 | +\x30\x32\0\x4c\x42\x42\x30\x5f\x39\x31\0\x4c\x42\x42\x30\x5f\x38\x31\0\x4c\x42\ | ||
752 | +\x42\x30\x5f\x37\x31\0\x4c\x42\x42\x30\x5f\x36\x31\0\x4c\x42\x42\x30\x5f\x35\ | ||
753 | +\x31\0\x4c\x42\x42\x30\x5f\x34\x31\0\x4c\x42\x42\x30\x5f\x32\x31\0\x4c\x42\x42\ | ||
754 | +\x30\x5f\x31\x31\0\x4c\x42\x42\x30\x5f\x31\x31\x31\0\x4c\x42\x42\x30\x5f\x31\ | ||
755 | +\x30\x31\0\x4c\x42\x42\x30\x5f\x38\x30\0\x4c\x42\x42\x30\x5f\x36\x30\0\x4c\x42\ | ||
756 | +\x42\x30\x5f\x35\x30\0\x4c\x42\x42\x30\x5f\x31\x30\0\x4c\x42\x42\x30\x5f\x31\ | ||
757 | +\x31\x30\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
758 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xaa\ | ||
759 | +\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xa0\x1a\0\0\0\0\0\0\x71\x02\0\ | ||
760 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1a\0\0\0\x01\0\0\ | ||
761 | +\0\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
762 | +\0\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x5a\0\0\0\x01\0\0\0\x06\0\0\0\0\0\0\ | ||
763 | +\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08\0\ | ||
764 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x56\0\0\0\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
765 | +\0\x60\x1a\0\0\0\0\0\0\x30\0\0\0\0\0\0\0\x09\0\0\0\x03\0\0\0\x08\0\0\0\0\0\0\0\ | ||
766 | +\x10\0\0\0\0\0\0\0\x20\0\0\0\x01\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x18\ | ||
767 | +\x14\0\0\0\0\0\0\x3c\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\ | ||
768 | +\0\0\0\x6c\0\0\0\x01\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x54\x14\0\0\0\0\0\ | ||
769 | +\0\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x78\0\0\ | ||
770 | +\0\x01\0\0\0\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x60\x14\0\0\0\0\0\0\x30\0\0\0\0\ | ||
771 | +\0\0\0\0\0\0\0\0\0\0\0\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x74\0\0\0\x09\0\0\0\0\ | ||
772 | +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x90\x1a\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x09\0\0\0\ | ||
773 | +\x07\0\0\0\x08\0\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\xb2\0\0\0\x02\0\0\0\0\0\0\0\0\0\ | ||
774 | +\0\0\0\0\0\0\0\0\0\0\x90\x14\0\0\0\0\0\0\xd0\x05\0\0\0\0\0\0\x01\0\0\0\x39\0\0\ | ||
775 | +\0\x08\0\0\0\0\0\0\0\x18\0\0\0\0\0\0\0"; | ||
776 | + | ||
777 | + return 0; | ||
778 | +err: | ||
779 | + bpf_object__destroy_skeleton(s); | ||
780 | + return -1; | ||
781 | +} | ||
782 | + | ||
783 | +#endif /* __RSS_BPF_SKEL_H__ */ | ||
784 | diff --git a/ebpf/trace-events b/ebpf/trace-events | ||
785 | new file mode 100644 | ||
786 | index XXXXXXX..XXXXXXX | ||
787 | --- /dev/null | ||
788 | +++ b/ebpf/trace-events | ||
789 | @@ -XXX,XX +XXX,XX @@ | ||
790 | +# See docs/devel/tracing.txt for syntax documentation. | ||
791 | + | ||
792 | +# ebpf-rss.c | ||
793 | +ebpf_error(const char *s1, const char *s2) "error in %s: %s" | ||
794 | diff --git a/ebpf/trace.h b/ebpf/trace.h | ||
795 | new file mode 100644 | ||
796 | index XXXXXXX..XXXXXXX | ||
797 | --- /dev/null | ||
798 | +++ b/ebpf/trace.h | ||
799 | @@ -0,0 +1 @@ | ||
800 | +#include "trace/trace-ebpf.h" | ||
801 | diff --git a/meson.build b/meson.build | ||
802 | index XXXXXXX..XXXXXXX 100644 | 610 | index XXXXXXX..XXXXXXX 100644 |
803 | --- a/meson.build | 611 | --- a/slirp/slirp.c |
804 | +++ b/meson.build | 612 | +++ b/slirp/slirp.c |
805 | @@ -XXX,XX +XXX,XX @@ if not get_option('fuse_lseek').disabled() | 613 | @@ -XXX,XX +XXX,XX @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) |
806 | endif | 614 | } |
807 | endif | 615 | break; |
808 | 616 | ||
809 | +# libbpf | 617 | + case ETH_P_NCSI: |
810 | +libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config') | 618 | + ncsi_input(slirp, pkt, pkt_len); |
811 | +if libbpf.found() and not cc.links(''' | 619 | + break; |
812 | + #include <bpf/libbpf.h> | 620 | + |
813 | + int main(void) | 621 | default: |
814 | + { | 622 | break; |
815 | + bpf_object__destroy_skeleton(NULL); | 623 | } |
816 | + return 0; | 624 | diff --git a/slirp/slirp.h b/slirp/slirp.h |
817 | + }''', dependencies: libbpf) | ||
818 | + libbpf = not_found | ||
819 | + if get_option('bpf').enabled() | ||
820 | + error('libbpf skeleton test failed') | ||
821 | + else | ||
822 | + warning('libbpf skeleton test failed, disabling') | ||
823 | + endif | ||
824 | +endif | ||
825 | + | ||
826 | if get_option('cfi') | ||
827 | cfi_flags=[] | ||
828 | # Check for dependency on LTO | ||
829 | @@ -XXX,XX +XXX,XX @@ endif | ||
830 | config_host_data.set('CONFIG_GTK', gtk.found()) | ||
831 | config_host_data.set('CONFIG_LIBATTR', have_old_libattr) | ||
832 | config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found()) | ||
833 | +config_host_data.set('CONFIG_EBPF', libbpf.found()) | ||
834 | config_host_data.set('CONFIG_LIBISCSI', libiscsi.found()) | ||
835 | config_host_data.set('CONFIG_LIBNFS', libnfs.found()) | ||
836 | config_host_data.set('CONFIG_RBD', rbd.found()) | ||
837 | @@ -XXX,XX +XXX,XX @@ if have_system | ||
838 | 'backends', | ||
839 | 'backends/tpm', | ||
840 | 'chardev', | ||
841 | + 'ebpf', | ||
842 | 'hw/9pfs', | ||
843 | 'hw/acpi', | ||
844 | 'hw/adc', | ||
845 | @@ -XXX,XX +XXX,XX @@ subdir('accel') | ||
846 | subdir('plugins') | ||
847 | subdir('bsd-user') | ||
848 | subdir('linux-user') | ||
849 | +subdir('ebpf') | ||
850 | + | ||
851 | +common_ss.add(libbpf) | ||
852 | |||
853 | bsd_user_ss.add(files('gdbstub.c')) | ||
854 | specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) | ||
855 | @@ -XXX,XX +XXX,XX @@ summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')} | ||
856 | summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')} | ||
857 | summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt} | ||
858 | summary_info += {'libcap-ng support': libcap_ng.found()} | ||
859 | +summary_info += {'bpf support': libbpf.found()} | ||
860 | # TODO: add back protocol and server version | ||
861 | summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')} | ||
862 | summary_info += {'rbd support': rbd.found()} | ||
863 | diff --git a/meson_options.txt b/meson_options.txt | ||
864 | index XXXXXXX..XXXXXXX 100644 | 625 | index XXXXXXX..XXXXXXX 100644 |
865 | --- a/meson_options.txt | 626 | --- a/slirp/slirp.h |
866 | +++ b/meson_options.txt | 627 | +++ b/slirp/slirp.h |
867 | @@ -XXX,XX +XXX,XX @@ option('bzip2', type : 'feature', value : 'auto', | 628 | @@ -XXX,XX +XXX,XX @@ extern Slirp *slirp_instance; |
868 | description: 'bzip2 support for DMG images') | 629 | |
869 | option('cap_ng', type : 'feature', value : 'auto', | 630 | void if_start(Slirp *); |
870 | description: 'cap_ng support') | 631 | |
871 | +option('bpf', type : 'feature', value : 'auto', | 632 | +/* ncsi.c */ |
872 | + description: 'eBPF support') | 633 | +void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len); |
873 | option('cocoa', type : 'feature', value : 'auto', | 634 | + |
874 | description: 'Cocoa user interface (macOS only)') | 635 | #ifndef _WIN32 |
875 | option('curl', type : 'feature', value : 'auto', | 636 | #include <netdb.h> |
637 | #endif | ||
876 | -- | 638 | -- |
877 | 2.7.4 | 639 | 2.7.4 |
878 | 640 | ||
879 | 641 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 3 | In this patch we support packet that have tcp options field. |
4 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 4 | Add tcp options field check, If the packet have options |
5 | field we just skip it and compare tcp payload, | ||
6 | Avoid unnecessary checkpoint, optimize performance. | ||
7 | |||
8 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
5 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 9 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
6 | --- | 10 | --- |
7 | docs/devel/ebpf_rss.rst | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ | 11 | net/colo-compare.c | 27 ++++++++++++++++++++++++++- |
8 | docs/devel/index.rst | 1 + | 12 | 1 file changed, 26 insertions(+), 1 deletion(-) |
9 | 2 files changed, 126 insertions(+) | ||
10 | create mode 100644 docs/devel/ebpf_rss.rst | ||
11 | 13 | ||
12 | diff --git a/docs/devel/ebpf_rss.rst b/docs/devel/ebpf_rss.rst | 14 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
13 | new file mode 100644 | ||
14 | index XXXXXXX..XXXXXXX | ||
15 | --- /dev/null | ||
16 | +++ b/docs/devel/ebpf_rss.rst | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | +=========================== | ||
19 | +eBPF RSS virtio-net support | ||
20 | +=========================== | ||
21 | + | ||
22 | +RSS(Receive Side Scaling) is used to distribute network packets to guest virtqueues | ||
23 | +by calculating packet hash. Usually every queue is processed then by a specific guest CPU core. | ||
24 | + | ||
25 | +For now there are 2 RSS implementations in qemu: | ||
26 | +- 'in-qemu' RSS (functions if qemu receives network packets, i.e. vhost=off) | ||
27 | +- eBPF RSS (can function with also with vhost=on) | ||
28 | + | ||
29 | +eBPF support (CONFIG_EBPF) is enabled by 'configure' script. | ||
30 | +To enable eBPF RSS support use './configure --enable-bpf'. | ||
31 | + | ||
32 | +If steering BPF is not set for kernel's TUN module, the TUN uses automatic selection | ||
33 | +of rx virtqueue based on lookup table built according to calculated symmetric hash | ||
34 | +of transmitted packets. | ||
35 | +If steering BPF is set for TUN the BPF code calculates the hash of packet header and | ||
36 | +returns the virtqueue number to place the packet to. | ||
37 | + | ||
38 | +Simplified decision formula: | ||
39 | + | ||
40 | +.. code:: C | ||
41 | + | ||
42 | + queue_index = indirection_table[hash(<packet data>)%<indirection_table size>] | ||
43 | + | ||
44 | + | ||
45 | +Not for all packets, the hash can/should be calculated. | ||
46 | + | ||
47 | +Note: currently, eBPF RSS does not support hash reporting. | ||
48 | + | ||
49 | +eBPF RSS turned on by different combinations of vhost-net, vitrio-net and tap configurations: | ||
50 | + | ||
51 | +- eBPF is used: | ||
52 | + | ||
53 | + tap,vhost=off & virtio-net-pci,rss=on,hash=off | ||
54 | + | ||
55 | +- eBPF is used: | ||
56 | + | ||
57 | + tap,vhost=on & virtio-net-pci,rss=on,hash=off | ||
58 | + | ||
59 | +- 'in-qemu' RSS is used: | ||
60 | + | ||
61 | + tap,vhost=off & virtio-net-pci,rss=on,hash=on | ||
62 | + | ||
63 | +- eBPF is used, hash population feature is not reported to the guest: | ||
64 | + | ||
65 | + tap,vhost=on & virtio-net-pci,rss=on,hash=on | ||
66 | + | ||
67 | +If CONFIG_EBPF is not set then only 'in-qemu' RSS is supported. | ||
68 | +Also 'in-qemu' RSS, as a fallback, is used if the eBPF program failed to load or set to TUN. | ||
69 | + | ||
70 | +RSS eBPF program | ||
71 | +---------------- | ||
72 | + | ||
73 | +RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool. | ||
74 | +So the program is part of the qemu binary. | ||
75 | +Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c. | ||
76 | +Prerequisites to recompile the eBPF program (regenerate ebpf/rss.bpf.skeleton.h): | ||
77 | + | ||
78 | + llvm, clang, kernel source tree, bpftool | ||
79 | + Adjust Makefile.ebpf to reflect the location of the kernel source tree | ||
80 | + | ||
81 | + $ cd tools/ebpf | ||
82 | + $ make -f Makefile.ebpf | ||
83 | + | ||
84 | +Current eBPF RSS implementation uses 'bounded loops' with 'backward jump instructions' which present in the last kernels. | ||
85 | +Overall eBPF RSS works on kernels 5.8+. | ||
86 | + | ||
87 | +eBPF RSS implementation | ||
88 | +----------------------- | ||
89 | + | ||
90 | +eBPF RSS loading functionality located in ebpf/ebpf_rss.c and ebpf/ebpf_rss.h. | ||
91 | + | ||
92 | +The `struct EBPFRSSContext` structure that holds 4 file descriptors: | ||
93 | + | ||
94 | +- ctx - pointer of the libbpf context. | ||
95 | +- program_fd - file descriptor of the eBPF RSS program. | ||
96 | +- map_configuration - file descriptor of the 'configuration' map. This map contains one element of 'struct EBPFRSSConfig'. This configuration determines eBPF program behavior. | ||
97 | +- map_toeplitz_key - file descriptor of the 'Toeplitz key' map. One element of the 40byte key prepared for the hashing algorithm. | ||
98 | +- map_indirections_table - 128 elements of queue indexes. | ||
99 | + | ||
100 | +`struct EBPFRSSConfig` fields: | ||
101 | + | ||
102 | +- redirect - "boolean" value, should the hash be calculated, on false - `default_queue` would be used as the final decision. | ||
103 | +- populate_hash - for now, not used. eBPF RSS doesn't support hash reporting. | ||
104 | +- hash_types - binary mask of different hash types. See `VIRTIO_NET_RSS_HASH_TYPE_*` defines. If for packet hash should not be calculated - `default_queue` would be used. | ||
105 | +- indirections_len - length of the indirections table, maximum 128. | ||
106 | +- default_queue - the queue index that used for packet that shouldn't be hashed. For some packets, the hash can't be calculated(g.e ARP). | ||
107 | + | ||
108 | +Functions: | ||
109 | + | ||
110 | +- `ebpf_rss_init()` - sets ctx to NULL, which indicates that EBPFRSSContext is not loaded. | ||
111 | +- `ebpf_rss_load()` - creates 3 maps and loads eBPF program from the rss.bpf.skeleton.h. Returns 'true' on success. After that, program_fd can be used to set steering for TAP. | ||
112 | +- `ebpf_rss_set_all()` - sets values for eBPF maps. `indirections_table` length is in EBPFRSSConfig. `toeplitz_key` is VIRTIO_NET_RSS_MAX_KEY_SIZE aka 40 bytes array. | ||
113 | +- `ebpf_rss_unload()` - close all file descriptors and set ctx to NULL. | ||
114 | + | ||
115 | +Simplified eBPF RSS workflow: | ||
116 | + | ||
117 | +.. code:: C | ||
118 | + | ||
119 | + struct EBPFRSSConfig config; | ||
120 | + config.redirect = 1; | ||
121 | + config.hash_types = VIRTIO_NET_RSS_HASH_TYPE_UDPv4 | VIRTIO_NET_RSS_HASH_TYPE_TCPv4; | ||
122 | + config.indirections_len = VIRTIO_NET_RSS_MAX_TABLE_LEN; | ||
123 | + config.default_queue = 0; | ||
124 | + | ||
125 | + uint16_t table[VIRTIO_NET_RSS_MAX_TABLE_LEN] = {...}; | ||
126 | + uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE] = {...}; | ||
127 | + | ||
128 | + struct EBPFRSSContext ctx; | ||
129 | + ebpf_rss_init(&ctx); | ||
130 | + ebpf_rss_load(&ctx); | ||
131 | + ebpf_rss_set_all(&ctx, &config, table, key); | ||
132 | + if (net_client->info->set_steering_ebpf != NULL) { | ||
133 | + net_client->info->set_steering_ebpf(net_client, ctx->program_fd); | ||
134 | + } | ||
135 | + ... | ||
136 | + ebpf_unload(&ctx); | ||
137 | + | ||
138 | + | ||
139 | +NetClientState SetSteeringEBPF() | ||
140 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
141 | + | ||
142 | +For now, `set_steering_ebpf()` method supported by Linux TAP NetClientState. The method requires an eBPF program file descriptor as an argument. | ||
143 | diff --git a/docs/devel/index.rst b/docs/devel/index.rst | ||
144 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
145 | --- a/docs/devel/index.rst | 16 | --- a/net/colo-compare.c |
146 | +++ b/docs/devel/index.rst | 17 | +++ b/net/colo-compare.c |
147 | @@ -XXX,XX +XXX,XX @@ Contents: | 18 | @@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) |
148 | qom | 19 | spkt->ip->ip_sum = ppkt->ip->ip_sum; |
149 | block-coroutine-wrapper | 20 | } |
150 | multi-process | 21 | |
151 | + ebpf_rss | 22 | - if (ptcp->th_sum == stcp->th_sum) { |
23 | + /* | ||
24 | + * Check tcp header length for tcp option field. | ||
25 | + * th_off > 5 means this tcp packet have options field. | ||
26 | + * The tcp options maybe always different. | ||
27 | + * for example: | ||
28 | + * From RFC 7323. | ||
29 | + * TCP Timestamps option (TSopt): | ||
30 | + * Kind: 8 | ||
31 | + * | ||
32 | + * Length: 10 bytes | ||
33 | + * | ||
34 | + * +-------+-------+---------------------+---------------------+ | ||
35 | + * |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)| | ||
36 | + * +-------+-------+---------------------+---------------------+ | ||
37 | + * 1 1 4 4 | ||
38 | + * | ||
39 | + * In this case the primary guest's timestamp always different with | ||
40 | + * the secondary guest's timestamp. COLO just focus on payload, | ||
41 | + * so we just need skip this field. | ||
42 | + */ | ||
43 | + if (ptcp->th_off > 5) { | ||
44 | + ptrdiff_t tcp_offset; | ||
45 | + tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data | ||
46 | + + (ptcp->th_off * 4); | ||
47 | + res = colo_packet_compare_common(ppkt, spkt, tcp_offset); | ||
48 | + } else if (ptcp->th_sum == stcp->th_sum) { | ||
49 | res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN); | ||
50 | } else { | ||
51 | res = -1; | ||
152 | -- | 52 | -- |
153 | 2.7.4 | 53 | 2.7.4 |
154 | 54 | ||
155 | 55 | diff view generated by jsdifflib |
1 | From: Andrew Melnychenko <andrew@daynix.com> | 1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | Additional code that will be used for eBPF setting steering routine. | 3 | Optimize two trace events as one, adjust print format make |
4 | it easy to read. rename trace_colo_compare_pkt_info_src/dst | ||
5 | to trace_colo_compare_tcp_info. | ||
4 | 6 | ||
5 | Signed-off-by: Andrew Melnychenko <andrew@daynix.com> | 7 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> |
6 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 8 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
7 | --- | 9 | --- |
8 | net/tap-linux.h | 1 + | 10 | net/colo-compare.c | 29 +++++++++++++++++------------ |
9 | 1 file changed, 1 insertion(+) | 11 | net/trace-events | 3 +-- |
12 | 2 files changed, 18 insertions(+), 14 deletions(-) | ||
10 | 13 | ||
11 | diff --git a/net/tap-linux.h b/net/tap-linux.h | 14 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/net/tap-linux.h | 16 | --- a/net/colo-compare.c |
14 | +++ b/net/tap-linux.h | 17 | +++ b/net/colo-compare.c |
15 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) |
16 | #define TUNSETQUEUE _IOW('T', 217, int) | 19 | res = -1; |
17 | #define TUNSETVNETLE _IOW('T', 220, int) | 20 | } |
18 | #define TUNSETVNETBE _IOW('T', 222, int) | 21 | |
19 | +#define TUNSETSTEERINGEBPF _IOR('T', 224, int) | 22 | - if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { |
20 | 23 | - trace_colo_compare_pkt_info_src(inet_ntoa(ppkt->ip->ip_src), | |
21 | #endif | 24 | - ntohl(stcp->th_seq), |
22 | 25 | - ntohl(stcp->th_ack), | |
26 | - res, stcp->th_flags, | ||
27 | - spkt->size); | ||
28 | - | ||
29 | - trace_colo_compare_pkt_info_dst(inet_ntoa(ppkt->ip->ip_dst), | ||
30 | - ntohl(ptcp->th_seq), | ||
31 | - ntohl(ptcp->th_ack), | ||
32 | - res, ptcp->th_flags, | ||
33 | - ppkt->size); | ||
34 | + if (res && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { | ||
35 | + char ip_src[20], ip_dst[20]; | ||
36 | + | ||
37 | + strcpy(ip_src, inet_ntoa(ppkt->ip->ip_src)); | ||
38 | + strcpy(ip_dst, inet_ntoa(ppkt->ip->ip_dst)); | ||
39 | + | ||
40 | + trace_colo_compare_tcp_info(ip_src, | ||
41 | + ip_dst, | ||
42 | + ntohl(ptcp->th_seq), | ||
43 | + ntohl(stcp->th_seq), | ||
44 | + ntohl(ptcp->th_ack), | ||
45 | + ntohl(stcp->th_ack), | ||
46 | + res, | ||
47 | + ptcp->th_flags, | ||
48 | + stcp->th_flags, | ||
49 | + ppkt->size, | ||
50 | + spkt->size); | ||
51 | |||
52 | qemu_hexdump((char *)ppkt->data, stderr, | ||
53 | "colo-compare ppkt", ppkt->size); | ||
54 | diff --git a/net/trace-events b/net/trace-events | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/net/trace-events | ||
57 | +++ b/net/trace-events | ||
58 | @@ -XXX,XX +XXX,XX @@ colo_compare_icmp_miscompare(const char *sta, int size) ": %s = %d" | ||
59 | colo_compare_ip_info(int psize, const char *sta, const char *stb, int ssize, const char *stc, const char *std) "ppkt size = %d, ip_src = %s, ip_dst = %s, spkt size = %d, ip_src = %s, ip_dst = %s" | ||
60 | colo_old_packet_check_found(int64_t old_time) "%" PRId64 | ||
61 | colo_compare_miscompare(void) "" | ||
62 | -colo_compare_pkt_info_src(const char *src, uint32_t sseq, uint32_t sack, int res, uint32_t sflag, int ssize) "src/dst: %s s: seq/ack=%u/%u res=%d flags=%x spkt_size: %d\n" | ||
63 | -colo_compare_pkt_info_dst(const char *dst, uint32_t dseq, uint32_t dack, int res, uint32_t dflag, int dsize) "src/dst: %s d: seq/ack=%u/%u res=%d flags=%x dpkt_size: %d\n" | ||
64 | +colo_compare_tcp_info(const char *src, const char *dst, uint32_t pseq, uint32_t sseq, uint32_t pack, uint32_t sack, int res, uint32_t pflag, uint32_t sflag, int psize, int ssize) "src/dst: %s/%s pseq/sseq:%u/%u pack/sack:%u/%u res=%d pflags/sflag:%x/%x psize/ssize:%d/%d \n" | ||
65 | |||
66 | # net/filter-rewriter.c | ||
67 | colo_filter_rewriter_debug(void) "" | ||
23 | -- | 68 | -- |
24 | 2.7.4 | 69 | 2.7.4 |
25 | 70 | ||
26 | 71 | diff view generated by jsdifflib |