-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1431 lines (1286 loc) · 68.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Top-level XDP project management</title>
<meta name="generator" content="Org Mode" />
<link rel="stylesheet" type="text/css" href="/styles/bigblow/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="/styles/bigblow/css/bigblow.css"/>
<link rel="stylesheet" type="text/css" href="/styles/bigblow/css/hideshow.css"/>
<script type="text/javascript" src="/styles/bigblow/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/jquery-ui-1.10.2.min.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/jquery.localscroll-min.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/jquery.scrollTo-1.4.3.1-min.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/jquery.zclip.min.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/bigblow.js"></script>
<script type="text/javascript" src="/styles/bigblow/js/hideshow.js"></script>
<script type="text/javascript" src="/styles/lib/js/jquery.stickytableheaders.min.js"></script>
</head>
<body>
<div id="content">
<h1 class="title">Top-level XDP project management</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#Current-high-priority-tasks">Current high-priority tasks   <span class="tag"><span class="_short">@short</span></span></a>
<ul>
<li><a href="#Consistency-for-statistics-with-XDP"><span class="todo TODO">TODO</span> Consistency for statistics with XDP</a>
<ul>
<li><a href="#Missing-update-of-ifconfig-counters"><span class="todo TODO">TODO</span> Missing update of ifconfig counters</a></li>
<li><a href="#Figure-out-the-counter-semantics-upstream"><span class="todo NEXT">NEXT</span> Figure out the counter semantics upstream</a></li>
<li><a href="#Statistics-per-XDP-action"><span class="todo TODO">TODO</span> Statistics per XDP-action</a>
<ul>
<li><a href="#Implement-simple-XDP-actions-counter-and-measure"><span class="todo NEXT">NEXT</span> Implement simple XDP-actions counter and measure</a></li>
<li><a href="#Exporting-XDP-actions-counter-to-userspace"><span class="todo TODO">TODO</span> Exporting XDP-actions counter to userspace</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Better-ndo_xdp_xmit-resource-management"><span class="todo TODO">TODO</span> Better ndo_xdp_xmit resource management</a>
<ul>
<li><a href="#Change-non-map-xdp_redirect-helper-to-use-a-hidden-map"><span class="todo NEXT">NEXT</span> Change non-map xdp_redirect helper to use a hidden map</a></li>
<li><a href="#Ethtool-interface-for-enabling-TX-resources"><span class="todo TODO">TODO</span> Ethtool interface for enabling TX resources</a>
<ul>
<li><a href="#Interface-for-defining-what-a-TX-resource-is">Interface for defining what a TX resource is</a></li>
</ul>
</li>
<li><a href="#Add-automatic-TX-resource-allocation-to-libbpf"><span class="todo TODO">TODO</span> Add automatic TX resource allocation to libbpf</a></li>
</ul>
</li>
<li><a href="#XDP-feature-flags"><span class="todo TODO">TODO</span> XDP feature flags</a>
<ul>
<li><a href="#Submit-LPC-network-track-talk-about--XDP-feature-detection"><span class="done DONE">DONE</span> Submit LPC network track talk about: XDP feature detection</a></li>
<li><a href="#Propose-a-driver-API-to-communicate-feature-flags"><span class="todo NEXT">NEXT</span> Propose a driver API to communicate feature flags</a>
<ul>
<li><a href="#Notes--implementation-plan">Notes: implementation plan</a></li>
</ul>
</li>
<li><a href="#Add-a-userspace-API-to-query-features"><span class="todo TODO">TODO</span> Add a userspace API to query features</a></li>
</ul>
</li>
<li><a href="#Multiple-XDP-programs-on-a-single-interface"><span class="done DONE">DONE</span> Multiple XDP programs on a single interface</a>
<ul>
<li><a href="#Build-an-XDP-chain-loader-on-top-of-the-kernel-support"><span class="done DONE">DONE</span> Build an XDP chain loader on top of the kernel support</a></li>
<li><a href="#Implement-freplace-re-attachment"><span class="done DONE">DONE</span> Implement freplace re-attachment</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Important-medium-term-tasks">Important medium-term tasks   <span class="tag"><span class="_medium">@medium</span></span></a>
<ul>
<li><a href="#Usability-of-programs-in-samples-bpf"><span class="todo TODO">TODO</span> Usability of programs in samples/bpf</a>
<ul>
<li><a href="#Change-sample-programs-to-accept-ifnames-as-well-as-indexes"><span class="done DONE">DONE</span> Change sample programs to accept ifnames as well as indexes</a></li>
<li><a href="#Add-TX-counters-to-redirect-samples-bpf-programs"><span class="todo NEXT">NEXT</span> Add TX counters to redirect samples/bpf programs</a></li>
<li><a href="#Fix-unloading-wrong-XDP-on-xdp-sample-exit"><span class="done DONE">DONE</span> Fix unloading wrong XDP on xdp-sample exit</a></li>
<li><a href="#Change-XDP-samples-to-enforce-native-XDP-and-report-if-not-avail"><span class="todo TODO">TODO</span> Change XDP-samples to enforce native-XDP and report if not avail</a></li>
<li><a href="#Add-xdpsock-option-to-allow-XDP_PASS-for-AF_XDP-zero-copy-mode"><span class="todo TODO">TODO</span> Add xdpsock option to allow XDP_PASS for AF_XDP zero-copy mode</a></li>
<li><a href="#xdp_monitor--record-and-show-errno"><span class="todo TODO">TODO</span> xdp_monitor: record and show errno</a></li>
<li><a href="#xdp_monitor--convert-to-use-raw-tracepoints"><span class="todo TODO">TODO</span> xdp_monitor: convert to use raw-tracepoints</a></li>
</ul>
</li>
<li><a href="#BPF-selftests---top-level-TODOs"><span class="todo TODO">TODO</span> BPF-selftests - top-level TODOs</a>
<ul>
<li><a href="#bpf-selftest--improve-XDP-VLAN-selftests"><span class="done DONE">DONE</span> bpf-selftest: improve XDP VLAN selftests</a></li>
<li><a href="#bpf-selftest--find-XDP-selftests-affected-by-veth-native-XDP"><span class="todo TODO">TODO</span> bpf-selftest: find XDP-selftests affected by veth native-XDP</a></li>
<li><a href="#Make-more-XDP-tests-using-BPF_PROG_TEST_RUN"><span class="todo TODO">TODO</span> Make more XDP tests using BPF_PROG_TEST_RUN</a></li>
<li><a href="#Could-this-be-a--introduction-job--"><span class="todo NEXT">NEXT</span> Could this be a "introduction job"?</a></li>
</ul>
</li>
<li><a href="#Busy-poll-support-for-AF_XDP"><span class="todo TODO">TODO</span> Busy-poll support for AF_XDP</a></li>
<li><a href="#Exposing-more-kernel-data-structures-through-helpers"><span class="todo TODO">TODO</span> Exposing more kernel data structures through helpers</a>
<ul>
<li><a href="#Layer-2-bridging-helper"><span class="todo NEXT">NEXT</span> Layer-2 bridging helper</a>
<ul>
<li><a href="#What-to-do-about-broadcast-multicast-"><span class="todo TODO">TODO</span> What to do about broadcast/multicast?</a></li>
</ul>
</li>
<li><a href="#Connection-flow-tracking"><span class="todo TODO">TODO</span> Connection/flow tracking</a></li>
</ul>
</li>
<li><a href="#Port-iproute2-to-libbpf"><span class="done DONE">DONE</span> Port iproute2 to libbpf</a></li>
<li><a href="#Metadata-available-to-programs"><span class="todo TODO">TODO</span> Metadata available to programs</a>
<ul>
<li><a href="#XDP-frame-length"><span class="done DONE">DONE</span> XDP frame length</a></li>
<li><a href="#Metadata-from-hardware"><span class="todo TODO">TODO</span> Metadata from hardware</a>
<ul>
<li><a href="#Needs-BTF-based-metadata"><span class="todo TODO">TODO</span> Needs BTF-based metadata</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Improvements-to-XDP_REDIRECT"><span class="todo TODO">TODO</span> Improvements to XDP_REDIRECT</a>
<ul>
<li><a href="#Handling-multicast"><span class="todo TODO">TODO</span> Handling multicast</a></li>
<li><a href="#Queueing-and-QoS"><span class="todo TODO">TODO</span> Queueing and QoS</a></li>
<li><a href="#Handling-XDP_REDIRECT-failures"><span class="todo TODO">TODO</span> Handling XDP_REDIRECT failures</a>
<ul>
<li><a href="#Allow-lookups-in-devmap-cpumap"><span class="done DONE">DONE</span> Allow lookups in devmap/cpumap</a></li>
<li><a href="#Make-bpf_redirect_map---check-map-contents"><span class="done DONE">DONE</span> Make bpf_redirect_map() check map contents</a></li>
<li><a href="#In-samples-bpf--use-that-bpf_redirect_map---can-check-map-content"><span class="todo NEXT">NEXT</span> In samples/bpf: use that bpf_redirect_map() can check map content</a></li>
<li><a href="#Retire-bpf_redirect---helper"><span class="done CANCELLED">CANCELLED</span> Retire bpf_redirect() helper   <span class="tag"><span class="CANCELLED">CANCELLED</span></span></a></li>
<li><a href="#What-happens-if-redirect-fails-even-though-TX-resources-are-available-"><span class="todo TODO">TODO</span> What happens if redirect fails even though TX resources are available?</a></li>
<li><a href="#Add-selftests-for-devmaps"><span class="todo TODO">TODO</span> Add selftests for devmaps</a></li>
<li><a href="#REDIRECT_MAP-idx-type---what-happens-with-namespace-moving-"><span class="todo TODO">TODO</span> REDIRECT_MAP idx type - what happens with namespace moving?</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Multi-buffer-XDP--aka.-jumbo-frames-"><span class="todo TODO">TODO</span> Multi-buffer XDP (aka. jumbo-frames)</a>
<ul>
<li><a href="#Start-upstream-discussion-on-multi-buffer"><span class="done DONE">DONE</span> Start upstream discussion on multi-buffer</a></li>
<li><a href="#Create-plan-to-move-forward-with-initial-constraints"><span class="todo TODO">TODO</span> Create plan to move forward with initial constraints</a></li>
<li><a href="#Find-driver-developers-that-will-participate-in-multi-buffer-work"><span class="todo TODO">TODO</span> Find driver developers that will participate in multi-buffer work</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Longer-term-preliminary-plans">Longer-term preliminary plans   <span class="tag"><span class="_long">@long</span></span></a>
<ul>
<li><a href="#Adding-AF_XDP-support-to-relevant-userspace-programs"><span class="todo TODO">TODO</span> Adding AF_XDP support to relevant userspace programs</a></li>
<li><a href="#BTF-based-metadata-for-XDP"><span class="todo WAIT">WAIT</span> BTF-based metadata for XDP   <span class="tag"><span class="WAITING">WAITING</span></span></a></li>
<li><a href="#XDP-latency-jit-vs-no-jit--tuning-etc"><span class="todo WAIT">WAIT</span> XDP latency jit-vs-no jit, tuning etc   <span class="tag"><span class="WAITING">WAITING</span></span></a></li>
<li><a href="#Generic-XDP-fixes"><span class="todo TODO">TODO</span> Generic XDP fixes</a>
<ul>
<li><a href="#Bulking-for-redirect-maps"><span class="todo TODO">TODO</span> Bulking for redirect maps</a></li>
<li><a href="#BUG--TCP-packets-skip----"><span class="done DONE">DONE</span> BUG: TCP packets skip (?)</a></li>
<li><a href="#Fix-CPUMAP"><span class="todo TODO">TODO</span> Fix CPUMAP</a></li>
</ul>
</li>
<li><a href="#XDP-hook-at-TX"><span class="todo TODO">TODO</span> XDP hook at TX</a></li>
</ul>
</li>
<li><a href="#Site-navigation">Site navigation</a></li>
</ul>
</div>
</div>
<p>
This is the XDP project website - a rendered version of <a href="https://github.com/xdp-project/xdp-project">the Github repository</a>
for project planning.
</p>
<p>
This file contains the high-level XDP tasks. The items in this file are
divided into three categories, reflecting the urgency and time frame we
envision them being completed; although this is somewhat of a soft
categorisation, as the development is also dependent on the priorities of
the people and organisations involved. These categories are:
</p>
<ul class="org-ul">
<li>Current high-priority tasks</li>
<li>Important medium-term tasks</li>
<li>Longer-term preliminary plans</li>
</ul>
<p>
Tasks are filed under the headings corresponding to these categories below,
and each category contains a description of what it (is supposed to)
include.
</p>
<div id="outline-container-Current-high-priority-tasks" class="outline-2">
<h2 id="Current-high-priority-tasks"><a href="#Current-high-priority-tasks">Current high-priority tasks   <span class="tag"><span class="_short">@short</span></span></a></h2>
<div class="outline-text-2" id="text-Current-high-priority-tasks">
<p>
These are tasks that are blockers for getting the XDP system ready for
general consumption, i.e., to a state that might reasonably be considered
"feature complete". This means that tasks in this category include essential
pieces of missing functionality, or significant user interface issues that
need to be resolved for wider adoption.
</p>
<p>
Tasks in this category should have a fleshed-out problem description, and
preferably a plan and someone working on them.
</p>
</div>
<div id="outline-container-Consistency-for-statistics-with-XDP" class="outline-3">
<h3 id="Consistency-for-statistics-with-XDP"><a href="#Consistency-for-statistics-with-XDP"><span class="todo TODO">TODO</span> Consistency for statistics with XDP</a></h3>
<div class="outline-text-3" id="text-Consistency-for-statistics-with-XDP">
<p>
The short of it is that we need consistency in the counters across NIC
drivers and virtual devices. Right now stats are specific to a driver with
no clear accounting for the packets and bytes handled in XDP.
</p>
<p>
Progress: @dsahern (David Ahern) have started an email thread on the
subject: <a href="https://www.spinics.net/lists/netdev/msg535239.html">consistency for statistics with XDP mode</a>
</p>
</div>
<div id="outline-container-Missing-update-of-ifconfig-counters" class="outline-4">
<h4 id="Missing-update-of-ifconfig-counters"><a href="#Missing-update-of-ifconfig-counters"><span class="todo TODO">TODO</span> Missing update of ifconfig counters</a></h4>
<div class="outline-text-4" id="text-Missing-update-of-ifconfig-counters">
<p>
Some drivers are not updating the "ifconfig" stats counters,
when in XDP mode. This makes receive or send via XDP invisible to
sysadm/management tools. This for-sure is going to cause confusion.
</p>
<p>
Closer look at other drivers.
</p>
<ul class="org-ul">
<li>ixgbe driver is doing the right thing.</li>
<li>i40e had a bug, where RX/TX stats are swapped (fixed in
commit <a href="https://git.kernel.org/torvalds/c/cdec2141c24e">cdec2141c24e(v4.20-rc1)</a>
("i40e: report correct statistics when XDP is enabled")).</li>
<li>mlx5 driver is not updating the regular RX/TX counters, but A LOT
of other ethtool stats counters (which are the ones I usually
monitor when testing).</li>
</ul>
</div>
</div>
<div id="outline-container-Figure-out-the-counter-semantics-upstream" class="outline-4">
<h4 id="Figure-out-the-counter-semantics-upstream"><a href="#Figure-out-the-counter-semantics-upstream"><span class="todo NEXT">NEXT</span> Figure out the counter semantics upstream</a></h4>
<div class="outline-text-4" id="text-Figure-out-the-counter-semantics-upstream">
<p>
Need to have an upstream discussion, on what is the semantic. IHMO
the regular RX/TX counters must be updated even for XDP frames.
</p>
</div>
</div>
<div id="outline-container-Statistics-per-XDP-action" class="outline-4">
<h4 id="Statistics-per-XDP-action"><a href="#Statistics-per-XDP-action"><span class="todo TODO">TODO</span> Statistics per XDP-action</a></h4>
<div class="outline-text-4" id="text-Statistics-per-XDP-action">
<p>
Accounting per XDP-action is also inconsistent across drivers. Some driver
account nothing, while others have elaborate counters exposed as ethtool
stats.
</p>
<p>
The common pattern is that XDP programs do their own accounting of action as
they see fit, and export this as BPF maps to their associated userspace
application, which a very per application specific approach.
</p>
<p>
David Ahern (@dsahern) argues that sysadm's need something more generic and
consistent, as they need a way to diagnose the system, regardless of the XDP
program that some developer asked to get installed. This argument that a 3rd
person should be able to diagnose a running XDP program was generally
accepted upstream.
</p>
<p>
There were a lot of performance concerns around introducing XDP-action
counters. Generally upstream voices wanted this to be opt-in, e.g. something
that the sysadm explicitly enable when needed, and not default on.
</p>
</div>
<div id="outline-container-Implement-simple-XDP-actions-counter-and-measure" class="outline-5">
<h5 id="Implement-simple-XDP-actions-counter-and-measure"><a href="#Implement-simple-XDP-actions-counter-and-measure"><span class="todo NEXT">NEXT</span> Implement simple XDP-actions counter and measure</a></h5>
<div class="outline-text-5" id="text-Implement-simple-XDP-actions-counter-and-measure">
<p>
As Saeed suggested do something really simple and central like:
</p>
<div class="org-src-container">
<pre class="src src-diff"><span style="font-weight: bold;">+++ </span><span style="font-weight: bold;">b/include/linux/filter.h</span>
<span style="font-weight: bold;">@@ -651,7 +651,9 @@</span><span style="font-weight: bold;"> static __always_inline u32 bpf_prog_run_xdp(const</span>
struct bpf_prog *prog,
* already takes rcu_read_lock() when fetching the program, so
* it's not necessary here anymore.
*/
- return BPF_PROG_RUN(prog, xdp);
+ u32 ret = BPF_PROG_RUN(prog, xdp);
+ xdp->xdp_rxq_info.stats[ret]++
+ return ret;
}
</pre>
</div>
<p>
WARNING: Realised above code is subject to speculative execution
side-channel leaking.
</p>
<p>
And measure if the performance concerns are real or not. Ilias or Jesper can
measure this on a slow ARM64 platform (espressobin), as only testing this on
Intel might lead to the wrong conclusion.
</p>
</div>
</div>
<div id="outline-container-Exporting-XDP-actions-counter-to-userspace" class="outline-5">
<h5 id="Exporting-XDP-actions-counter-to-userspace"><a href="#Exporting-XDP-actions-counter-to-userspace"><span class="todo TODO">TODO</span> Exporting XDP-actions counter to userspace</a></h5>
<div class="outline-text-5" id="text-Exporting-XDP-actions-counter-to-userspace">
<p>
Collecting XDP-actions counter is only the first step. We need to figure
out the best solution for exporting this to userspace.
</p>
<p>
One option is to piggyback on ethtool stats, which the drivers already use,
and it would also standardise the driver related XDP ethool stats.
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-Better-ndo_xdp_xmit-resource-management" class="outline-3">
<h3 id="Better-ndo_xdp_xmit-resource-management"><a href="#Better-ndo_xdp_xmit-resource-management"><span class="todo TODO">TODO</span> Better ndo_xdp_xmit resource management</a></h3>
<div class="outline-text-3" id="text-Better-ndo_xdp_xmit-resource-management">
<p>
Stalled on Intel/Magnus NIC queue management interface.
</p>
<p>
Driver resources needed to handle a ndo_xdp_xmit() is currently tied
to the driver having loaded an RX XDP program. This is strange, as
allocating these Driver TX HW resources is independent.
</p>
<p>
This can quickly lead to exhausting HW resources, like IRQs lines or
NIC TX HW queues, given it is assumed a TX queue is alloc/dedicated
for each CPU core.
</p>
</div>
<div id="outline-container-Change-non-map-xdp_redirect-helper-to-use-a-hidden-map" class="outline-4">
<h4 id="Change-non-map-xdp_redirect-helper-to-use-a-hidden-map"><a href="#Change-non-map-xdp_redirect-helper-to-use-a-hidden-map"><span class="todo NEXT">NEXT</span> Change non-map xdp_redirect helper to use a hidden map</a></h4>
<div class="outline-text-4" id="text-Change-non-map-xdp_redirect-helper-to-use-a-hidden-map">
<p>
To be able to tie resource allocation to the interface maps (<code>devmap</code>), we
first need to change the non-map redirect variant so it uses a map under the
hood. Since xdp_redirect_map() is also significantly faster than the non-map
variant, this change should be a win in itself.
</p>
<p>
v1 comments and discussion: <a href="https://patchwork.ozlabs.org/patch/1046099/">Patch 1</a> <a href="https://patchwork.ozlabs.org/patch/1046100/">Patch 2</a>
</p>
<p>
<a href="https://patchwork.ozlabs.org/cover/1050219/">v3 patchwork link</a>
</p>
</div>
</div>
<div id="outline-container-Ethtool-interface-for-enabling-TX-resources" class="outline-4">
<h4 id="Ethtool-interface-for-enabling-TX-resources"><a href="#Ethtool-interface-for-enabling-TX-resources"><span class="todo TODO">TODO</span> Ethtool interface for enabling TX resources</a></h4>
<div class="outline-text-4" id="text-Ethtool-interface-for-enabling-TX-resources">
<p>
Turns out the initial idea of using insertion into devmap as a trigger for
resource allocation doesn't work because of generic XDP. So we'll need an
ethtool interface; look into the existing channel configuration interface on
the kernel side and figure out how to express XDP resource allocation in a
good way.
</p>
</div>
<div id="outline-container-Interface-for-defining-what-a-TX-resource-is" class="outline-5">
<h5 id="Interface-for-defining-what-a-TX-resource-is"><a href="#Interface-for-defining-what-a-TX-resource-is">Interface for defining what a TX resource is</a></h5>
<div class="outline-text-5" id="text-Interface-for-defining-what-a-TX-resource-is">
<p>
Need to define:
</p>
<ul class="org-ul">
<li>Number of TX queues</li>
<li>Algorithm for picking one on a given redirect (e.g., hash on CPU)</li>
<li>Queueing behaviour</li>
</ul>
<p>
How to handle life cycle management?
</p>
</div>
</div>
</div>
<div id="outline-container-Add-automatic-TX-resource-allocation-to-libbpf" class="outline-4">
<h4 id="Add-automatic-TX-resource-allocation-to-libbpf"><a href="#Add-automatic-TX-resource-allocation-to-libbpf"><span class="todo TODO">TODO</span> Add automatic TX resource allocation to libbpf</a></h4>
<div class="outline-text-4" id="text-Add-automatic-TX-resource-allocation-to-libbpf">
<p>
Because we can't tie resource allocation to map insertion on the kernel
side, we need to solve the UI interface in userspace. So add a hook/wrapper
to libbpf that will automatically allocate TX resources when inserting into
a map.
</p>
</div>
</div>
</div>
<div id="outline-container-XDP-feature-flags" class="outline-3">
<h3 id="XDP-feature-flags"><a href="#XDP-feature-flags"><span class="todo TODO">TODO</span> XDP feature flags</a></h3>
<div class="outline-text-3" id="text-XDP-feature-flags">
<p>
We are probably going to need feature flags for XDP after all. There are use
cases (e.g. Surricata, VM migration) that will want to know what to expect
from the system before committing to loading an XDP program.
</p>
</div>
<div id="outline-container-Submit-LPC-network-track-talk-about--XDP-feature-detection" class="outline-4">
<h4 id="Submit-LPC-network-track-talk-about--XDP-feature-detection"><a href="#Submit-LPC-network-track-talk-about--XDP-feature-detection"><span class="done DONE">DONE</span> Submit LPC network track talk about: XDP feature detection</a></h4>
<div class="outline-text-4" id="text-Submit-LPC-network-track-talk-about--XDP-feature-detection">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2019-07-31 Wed 17:10]</span></span></p>
<p>
Title:
</p>
<ul class="org-ul">
<li>Improving the XDP User eXperience: via feature detection</li>
</ul>
<p>
Abstract:
</p>
<blockquote>
<p>
The most common asked question is: Does my NIC support XDP, and our current
answer is read the source code. We really need to come up with a better
answer.
</p>
<p>
The real issue is that users can attach an XDP bpf_prog to a drivers that
use features the driver doesn't implement, which cause silent drops. Or user
doesn't notice, that NIC loading fallback to generic-XDP, which is first
discovered when observing lower performance, or worse not all features are
supported with generic-XDP, resulting in unexpected packet drops.
</p>
<p>
BPF feature detection, recently added to bpftool, is based on probing the
BPF-core by loading BPF-programs using individual features (notice BPF load
time, not attaching it).
</p>
<p>
Even if your BPF loader doesn't use feature probing, it will notice if
loaded on a incompatible kernel. As an BPF-prog using something the kernel
BPF-core doesn't support will get rejected at load-time, before you attach
the BPF-prog.
</p>
<p>
This doesn't work for XDP, as features vary on a per driver basis. Currently
an XDP BPF-prog isn't aware of that driver it will get used on, until driver
attach-time. Unfortunately, due to BPF tail-calls, we cannot use the driver
attach-time hook to check for compatibility (given new XDP BPF-progs can be
indirectly "attached" via tail-call map inserts).
</p>
<p>
In this talk, we will investigate the possibilities of doing XDP feature
check at BPF load-time, by assigning an ifindex to the BPF-prog. The ground
work have already been laid by XDP hardware offload, which already need
ifindex at BPF load-time (to perform BPF byte-code translation into NIC
compatible code).
</p>
<p>
The open question are:
</p>
<ul class="org-ul">
<li>Can the verifier detect/deduce XDP feature in use, for us?</li>
<li>How does drivers express/expose XDP features?</li>
<li>Are features more than XDP return codes, like meta-data support?</li>
<li>How does this interact with generic-XDP?</li>
<li>How to expose this to userspace? (to answer does NIC support XDP)</li>
<li>How to handle tail-call map inserts?</li>
</ul>
</blockquote>
</div>
</div>
<div id="outline-container-Propose-a-driver-API-to-communicate-feature-flags" class="outline-4">
<h4 id="Propose-a-driver-API-to-communicate-feature-flags"><a href="#Propose-a-driver-API-to-communicate-feature-flags"><span class="todo NEXT">NEXT</span> Propose a driver API to communicate feature flags</a></h4>
<div class="outline-text-4" id="text-Propose-a-driver-API-to-communicate-feature-flags">
<ul class="org-ul">
<li>Daniel: Needs to go through driver BPF ndo</li>
</ul>
<p>
Needs to be an API that queries support. We cannot validate on program load
time because of tail call. Not even with cooperation from the tail-calling
program, because that may not know what features are used by the programs it
is tail-calling into.
</p>
</div>
<div id="outline-container-Notes--implementation-plan" class="outline-5">
<h5 id="Notes--implementation-plan"><a href="#Notes--implementation-plan">Notes: implementation plan</a></h5>
<div class="outline-text-5" id="text-Notes--implementation-plan">
<ul class="org-ul">
<li>On load: verifier populates bpf_prog->feature_bits</li>
<li>On load, if ifindex: reject if prog->features ^ iface->features</li>
<li>On attach: reject if prog->features ^ iface->features</li>
<li>Tail call maps:
<ul class="org-ul">
<li>On insert: if (map->feature_lock) {reject_if(prog->features ^ map->feature_lock)}
else Map->features |= prog->features</li>
<li>On prog load, if ifindex: reject if map->features ^ ifindex->features, else
progs->maps[]->feature_lock = ifindex->features
progs->features |= ifindex->features</li>
</ul></li>
</ul>
</div>
</div>
</div>
<div id="outline-container-Add-a-userspace-API-to-query-features" class="outline-4">
<h4 id="Add-a-userspace-API-to-query-features"><a href="#Add-a-userspace-API-to-query-features"><span class="todo TODO">TODO</span> Add a userspace API to query features</a></h4>
<div class="outline-text-4" id="text-Add-a-userspace-API-to-query-features">
<p>
Netlink? Ethtool?
</p>
</div>
</div>
</div>
<div id="outline-container-Multiple-XDP-programs-on-a-single-interface" class="outline-3">
<h3 id="Multiple-XDP-programs-on-a-single-interface"><a href="#Multiple-XDP-programs-on-a-single-interface"><span class="done DONE">DONE</span> Multiple XDP programs on a single interface</a></h3>
<div class="outline-text-3" id="text-Multiple-XDP-programs-on-a-single-interface">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-12-15 Tue 13:18]</span></span></p>
<p>
Being able to load multiple programs on the same XDP interface is an
important use case if XDP is to see more widespread deployment (as otherwise
applications will step on each others' toes when trying to accelerate using
XDP).
</p>
<p>
The upstream solution for this is known as "dynamic re-linking", which
allows BPF global functions to be replaced by other programs. The last piece
of the kernel functionality for this was posted upstream on January 18th:
<a href="https://lore.kernel.org/bpf/[email protected]/T/#t">https://lore.kernel.org/bpf/[email protected]/T/#t</a>
</p>
</div>
<div id="outline-container-Build-an-XDP-chain-loader-on-top-of-the-kernel-support" class="outline-4">
<h4 id="Build-an-XDP-chain-loader-on-top-of-the-kernel-support"><a href="#Build-an-XDP-chain-loader-on-top-of-the-kernel-support"><span class="done DONE">DONE</span> Build an XDP chain loader on top of the kernel support</a></h4>
<div class="outline-text-4" id="text-Build-an-XDP-chain-loader-on-top-of-the-kernel-support">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-06-02 Tue 18:45]</span></span></p>
<p>
This is implemented as part of libxdp in the <a href="https://github.com/xdp-project/xdp-tools">XDP tools repo</a>. The current
implementation works for loading a dispatcher with multiple programs, but
only if they are all attached at the same time (until kernel support for
re-attaching freplace programs land).
</p>
</div>
</div>
<div id="outline-container-Implement-freplace-re-attachment" class="outline-4">
<h4 id="Implement-freplace-re-attachment"><a href="#Implement-freplace-re-attachment"><span class="done DONE">DONE</span> Implement freplace re-attachment</a></h4>
<div class="outline-text-4" id="text-Implement-freplace-re-attachment">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-12-15 Tue 13:17]</span></span></p>
<p>
To support seamlessly attaching additional XDP programs onto an interface,
we need the kernel to support re-attaching an existing freplace program in
multiple places, so the programs can be attached to a new dispatcher which
can then be atomically swapped onto the interface XDP hook.
</p>
<p>
This is now supported in the 5.10 kernel, with the userspace support
available in <a href="https://github.com/xdp-project/xdp-tools">libxdp and xdp-tools</a>.
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-Important-medium-term-tasks" class="outline-2">
<h2 id="Important-medium-term-tasks"><a href="#Important-medium-term-tasks">Important medium-term tasks   <span class="tag"><span class="_medium">@medium</span></span></a></h2>
<div class="outline-text-2" id="text-Important-medium-term-tasks">
<p>
These are tasks that are important to fix in the medium term, but that are
not immediate blockers for functionality. This includes things like
expanding driver support, and adding new features that improve things, but
which are not essential for the basic usefulness of XDP.
</p>
<p>
Tasks in this category should at a minimum have a fleshed-out problem
description.
</p>
</div>
<div id="outline-container-Usability-of-programs-in-samples-bpf" class="outline-3">
<h3 id="Usability-of-programs-in-samples-bpf"><a href="#Usability-of-programs-in-samples-bpf"><span class="todo TODO">TODO</span> Usability of programs in samples/bpf</a></h3>
<div class="outline-text-3" id="text-Usability-of-programs-in-samples-bpf">
<p>
The samples/bpf programs xdp_redirect + xdp_redirect_map are very user
unfriendly. #1 they use raw ifindex'es as input + output. #2 the pkt/s
number count RX packets, not TX'ed packets which can be dropped silently.
Red Hat QA, got very confused by #2.
</p>
</div>
<div id="outline-container-Change-sample-programs-to-accept-ifnames-as-well-as-indexes" class="outline-4">
<h4 id="Change-sample-programs-to-accept-ifnames-as-well-as-indexes"><a href="#Change-sample-programs-to-accept-ifnames-as-well-as-indexes"><span class="done DONE">DONE</span> Change sample programs to accept ifnames as well as indexes</a></h4>
<div class="outline-text-4" id="text-Change-sample-programs-to-accept-ifnames-as-well-as-indexes">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2019-06-25 Tue 13:32]</span></span></p>
<p>
Fixed by <a href="https://patchwork.ozlabs.org/patch/1121683/">https://patchwork.ozlabs.org/patch/1121683/</a>
</p>
</div>
</div>
<div id="outline-container-Add-TX-counters-to-redirect-samples-bpf-programs" class="outline-4">
<h4 id="Add-TX-counters-to-redirect-samples-bpf-programs"><a href="#Add-TX-counters-to-redirect-samples-bpf-programs"><span class="todo NEXT">NEXT</span> Add TX counters to redirect samples/bpf programs</a></h4>
<div class="outline-text-4" id="text-Add-TX-counters-to-redirect-samples-bpf-programs">
<p>
Simply include/sample the net_device TX stats.
</p>
</div>
</div>
<div id="outline-container-Fix-unloading-wrong-XDP-on-xdp-sample-exit" class="outline-4">
<h4 id="Fix-unloading-wrong-XDP-on-xdp-sample-exit"><a href="#Fix-unloading-wrong-XDP-on-xdp-sample-exit"><span class="done DONE">DONE</span> Fix unloading wrong XDP on xdp-sample exit</a></h4>
<div class="outline-text-4" id="text-Fix-unloading-wrong-XDP-on-xdp-sample-exit">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-01-24 Fri 10:50]</span></span></p>
<p>
The XDP sample programs unconditionally unload the current running XDP
program (via -1) on exit. If users are not careful with the order in-which
they start and stop XDP programs, then they get confused.
</p>
<p>
This was fixed upstream by by <a href="https://patchwork.ozlabs.org/project/netdev/list/?series=89625&state=%2A&archive=both">Maciej Fijalkowski</a>.
</p>
</div>
</div>
<div id="outline-container-Change-XDP-samples-to-enforce-native-XDP-and-report-if-not-avail" class="outline-4">
<h4 id="Change-XDP-samples-to-enforce-native-XDP-and-report-if-not-avail"><a href="#Change-XDP-samples-to-enforce-native-XDP-and-report-if-not-avail"><span class="todo TODO">TODO</span> Change XDP-samples to enforce native-XDP and report if not avail</a></h4>
<div class="outline-text-4" id="text-Change-XDP-samples-to-enforce-native-XDP-and-report-if-not-avail">
<p>
The default behaviour when attaching an XDP program on a driver that doesn't
have native-XDP is to fallback to generic-XDP, without notifying the user of
the end-state.
</p>
<p>
This behaviour is also used by xdp-samples, which unfortunately have lead
end-users to falsely think a given driver supports native-XDP. (QA are using
these xdp-samples and create cases due to this confusion).
</p>
<p>
Proposal is to change xdp-samples to enforce native-XDP, and report if this
was not possible, together with help text that display cmdline option for
enabling generic-XDP/SKB-mode.
</p>
</div>
</div>
<div id="outline-container-Add-xdpsock-option-to-allow-XDP_PASS-for-AF_XDP-zero-copy-mode" class="outline-4">
<h4 id="Add-xdpsock-option-to-allow-XDP_PASS-for-AF_XDP-zero-copy-mode"><a href="#Add-xdpsock-option-to-allow-XDP_PASS-for-AF_XDP-zero-copy-mode"><span class="todo TODO">TODO</span> Add xdpsock option to allow XDP_PASS for AF_XDP zero-copy mode</a></h4>
<div class="outline-text-4" id="text-Add-xdpsock-option-to-allow-XDP_PASS-for-AF_XDP-zero-copy-mode">
<p>
In AF_XDP zero-copy mode, sending frame to the network stack via XDP_PASS
results in an expense code path, e.g new page_alloc for copy of payload and
SKB alloc. We need this test how slow this code path is.
</p>
<p>
Also consider testing XDP-level redirect out another net_device with
AF_XDP-ZC enabled. (I think this will just drop the packets due to
mem_type).
</p>
</div>
</div>
<div id="outline-container-xdp_monitor--record-and-show-errno" class="outline-4">
<h4 id="xdp_monitor--record-and-show-errno"><a href="#xdp_monitor--record-and-show-errno"><span class="todo TODO">TODO</span> xdp_monitor: record and show errno</a></h4>
<div class="outline-text-4" id="text-xdp_monitor--record-and-show-errno">
<p>
It would be a big help diagnosing XDP issues if the xdp_monitor program also
reported the errno.
</p>
</div>
</div>
<div id="outline-container-xdp_monitor--convert-to-use-raw-tracepoints" class="outline-4">
<h4 id="xdp_monitor--convert-to-use-raw-tracepoints"><a href="#xdp_monitor--convert-to-use-raw-tracepoints"><span class="todo TODO">TODO</span> xdp_monitor: convert to use raw-tracepoints</a></h4>
<div class="outline-text-4" id="text-xdp_monitor--convert-to-use-raw-tracepoints">
<p>
The raw-tracepoints are suppose to be much faster, and XDP monitor want to
have as little impact on the system as possible. Thus, convert to use
raw-tracepoints.
</p>
</div>
</div>
</div>
<div id="outline-container-BPF-selftests---top-level-TODOs" class="outline-3">
<h3 id="BPF-selftests---top-level-TODOs"><a href="#BPF-selftests---top-level-TODOs"><span class="todo TODO">TODO</span> BPF-selftests - top-level TODOs</a></h3>
<div class="outline-text-3" id="text-BPF-selftests---top-level-TODOs">
<p>
The kernel git-tree contains a lot of selftests for BPF located in:
<code>tools/testing/selftests/bpf/</code>.
</p>
<p>
XDP (and its performance gain) is tied closely to NIC driver code, which
makes it hard to implement selftests for (including benchmark selftests).
Still we should have a goal of doing functional testing of the XDP core-code
components (via selftests).
</p>
<p>
Since driver <code>veth</code> got native-XDP support, we have an opportunity for
writing selftests that cover both generic-XDP and native-XDP.
</p>
</div>
<div id="outline-container-bpf-selftest--improve-XDP-VLAN-selftests" class="outline-4">
<h4 id="bpf-selftest--improve-XDP-VLAN-selftests"><a href="#bpf-selftest--improve-XDP-VLAN-selftests"><span class="done DONE">DONE</span> bpf-selftest: improve XDP VLAN selftests</a></h4>
<div class="outline-text-4" id="text-bpf-selftest--improve-XDP-VLAN-selftests">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-01-24 Fri 10:55]</span></span></p>
<p>
<b>Assignment</b> is to improve the selftest shell-script to test both
generic-XDP and native-XDP (for veth driver).
</p>
<p>
In-progress:
</p>
<ul class="org-ul">
<li><a href="https://patchwork.ozlabs.org/project/netdev/list/?series=122796&state=%2a">Patchset V1</a></li>
</ul>
<p>
XDP add/remove VLAN headers have a selftest in <code>tools/testing/selftests/bpf/</code>
in files <code>test_xdp_vlan.c</code> and <code>test_xdp_vlan.sh</code>. This test was developed
in conjunction with fixing a bug in generic-XDP (see kernel commit
<a href="https://git.kernel.org/torvalds/c/297249569932">297249569932</a> ("net: fix generic XDP to handle if eth header was mangled")).
</p>
<p>
Since driver <code>veth</code> got native-XDP support, the selftest no-longer tests
generic-XDP code path.
</p>
<p>
The ip utility (from iproute2) already support specifying, that an XDP prog
must use generic XDP when loading an XDP prog (option <code>xdpgeneric</code>).
</p>
</div>
</div>
<div id="outline-container-bpf-selftest--find-XDP-selftests-affected-by-veth-native-XDP" class="outline-4">
<h4 id="bpf-selftest--find-XDP-selftests-affected-by-veth-native-XDP"><a href="#bpf-selftest--find-XDP-selftests-affected-by-veth-native-XDP"><span class="todo TODO">TODO</span> bpf-selftest: find XDP-selftests affected by veth native-XDP</a></h4>
<div class="outline-text-4" id="text-bpf-selftest--find-XDP-selftests-affected-by-veth-native-XDP">
<p>
When driver <code>veth</code> got native-XDP support, then the XDP-selftests that were
based on <code>veth</code> changed from testing generic-XDP into testing native-XDP.
</p>
<p>
<b>Assignments:</b>
</p>
<ol class="org-ol">
<li>Determine how many and which veth based XDP-selftests are affected</li>
<li>Convert these selftests to test both generic-XDP and native-XDP</li>
</ol>
</div>
</div>
<div id="outline-container-Make-more-XDP-tests-using-BPF_PROG_TEST_RUN" class="outline-4">
<h4 id="Make-more-XDP-tests-using-BPF_PROG_TEST_RUN"><a href="#Make-more-XDP-tests-using-BPF_PROG_TEST_RUN"><span class="todo TODO">TODO</span> Make more XDP tests using BPF_PROG_TEST_RUN</a></h4>
<div class="outline-text-4" id="text-Make-more-XDP-tests-using-BPF_PROG_TEST_RUN">
<p>
<a href="https://twitter.com/bjorntopel/status/1098563282884014080?s=03">Tweet</a> by Björn Töpel (@bjorntopel):
</p>
<p>
Many people aren't aware of the BPF_PROG_TEST_RUN command. It's really neat
being able to test your XDP programs "offline". The selftests use this a
lot. Docs: <a href="https://t.co/GDd7SfNYng">https://t.co/GDd7SfNYng</a> and examples in tools/testing/selftests/bpf/.
</p>
</div>
</div>
<div id="outline-container-Could-this-be-a--introduction-job--" class="outline-4">
<h4 id="Could-this-be-a--introduction-job--"><a href="#Could-this-be-a--introduction-job--"><span class="todo NEXT">NEXT</span> Could this be a "introduction job"?</a></h4>
<div class="outline-text-4" id="text-Could-this-be-a--introduction-job--">
</div>
</div>
</div>
<div id="outline-container-Busy-poll-support-for-AF_XDP" class="outline-3">
<h3 id="Busy-poll-support-for-AF_XDP"><a href="#Busy-poll-support-for-AF_XDP"><span class="todo TODO">TODO</span> Busy-poll support for AF_XDP</a></h3>
<div class="outline-text-3" id="text-Busy-poll-support-for-AF_XDP">
<p>
Adding BUSY_POLL support to AF_XDP sockets was presented at the Linux
Plumbers Conference 2018 in Vancouver, BC. With this feature, the NAPI
context of the driver is executed from the process context by the
application calling the poll() syscall, instead of being driven by the
softirq mechanism. This has a number of benefits, for example,
being able to efficiently use a single core for application, driver
and other kernel infra that the application might need. With softirq,
we would need two cores to maintain any performance. Another benefit
is that the cachelines containing the descriptors do not have to
bounce between two caches, since this is now a core local operation as
the driver and the application is on the same core. The drawback is
that we now have to use a syscall (poll) in the data path and this
will slow things down.
</p>
<p>
There is already a busy_poll mechanisms in the kernel:
/proc/sys/net/core/busy_poll. When writing a non zero value in this
file, the busy poll support will be enabled for ALL sockets in the
system. There are a number of issues with this existing code when
applied to AF_XDP sockets.
</p>
<ul class="org-ul">
<li>The batch size is hardcoded to 8, a value that is too small for the</li>
</ul>
<p>
fast processing of XDP.
</p>
<ul class="org-ul">
<li>The semantics of poll() in busy_poll mode is that if you provide more</li>
</ul>
<p>
than one file descriptor, it will drive the napi context of the first
one supplied and if it has a packet, then it will NOT drive any of the
other. In other words, it will quit once it has found an fd with a
packet. This will not work for us, since we need all fd's napis to be
called since it is very likely that a packet will be found in each of
them. One could argue that this can be solved in user-space by
manipulating the array of fds supplied to poll() before every singel
call, but this would really complicate multi socket handling in
user-space.
</p>
<ul class="org-ul">
<li>The option is global across all sockets. Enough said.</li>
</ul>
<p>
My suggestion for addressing these issues is to introduce a new
busy_poll option that is only for AF_XDP called
XDP_BUSY_POLL_BATCH_SIZE (or something like it). This is a setsockopt
that can be supplied to individual AF_XDP sockets and the batch size
can thus also be set individually by suppling a value > 0. The
semantics of this mode is that both Rx and Tx have to be driven by
calling poll(). There is no guarantee that your packets will arrive or
be sent unless you call poll() (a sendto() will still work for the Tx
case, though, but it is not necessary). In this first patch set, we
can still get interrupts and processing from NAPI in this mode, but we
have some ideas on how to disable this so that NAPI is only driven
from poll(). But that is for a later patch set. Note that the sematics
would not change when we introduce this as we already today say that
you must call poll(), since there is no guarantee otherwise that you
will receive or send packets.
</p>
<p>
When suppling multiple busy_poll AF_XDP sockets to poll() all of them
will get theire napi contexts executed, so it is guaranteed that all of
them will be driven. It is also possible to mix regular sockets,
global busy_poll sockets and the new AF_XDP sockets in the same poll()
call. The semantics for each type will be maintained, as expected.
</p>
<p>
From an implementation point of view, I believe this can be
implemented with minimal changes to the net and fs code. We can get
this new behavior by using the standar fd (non-busy poll path) and
then drive the napi from the xsk specific poll callback. We do need to
change one internal interface in order to be able to have a variable
batch size. And Jesper's xdp_rxq_info struct need to be enlarged with a
napi_id field that the drivers need to populate. This can then be used
by the xsk poll code to drive the correct NAPI.
</p>
</div>
</div>
<div id="outline-container-Exposing-more-kernel-data-structures-through-helpers" class="outline-3">
<h3 id="Exposing-more-kernel-data-structures-through-helpers"><a href="#Exposing-more-kernel-data-structures-through-helpers"><span class="todo TODO">TODO</span> Exposing more kernel data structures through helpers</a></h3>
<div class="outline-text-3" id="text-Exposing-more-kernel-data-structures-through-helpers">
<p>
One of the strengths of XDP over kernel bypass solutions is the ability to
re-use existing in-kernel data structures, such as the routing table. This
happens through kernel helpers. We already have routing, but we will need
more helpers.
</p>
</div>
<div id="outline-container-Layer-2-bridging-helper" class="outline-4">
<h4 id="Layer-2-bridging-helper"><a href="#Layer-2-bridging-helper"><span class="todo NEXT">NEXT</span> Layer-2 bridging helper</a></h4>
<div class="outline-text-4" id="text-Layer-2-bridging-helper">
<p>
The obvious next step is a l2 bridging helper that mirrors the l3 routing
one. Should be fairly straight forward to implement.
</p>
<p>
<a href="https://lore.kernel.org/bpf/[email protected]/">RFC series posted for this</a>.
</p>
</div>
<div id="outline-container-What-to-do-about-broadcast-multicast-" class="outline-5">
<h5 id="What-to-do-about-broadcast-multicast-"><a href="#What-to-do-about-broadcast-multicast-"><span class="todo TODO">TODO</span> What to do about broadcast/multicast?</a></h5>
<div class="outline-text-5" id="text-What-to-do-about-broadcast-multicast-">
<p>
See <a href="#Handling-multicast">Handling multicast</a> below.
</p>
</div>
</div>
</div>
<div id="outline-container-Connection-flow-tracking" class="outline-4">
<h4 id="Connection-flow-tracking"><a href="#Connection-flow-tracking"><span class="todo TODO">TODO</span> Connection/flow tracking</a></h4>
<div class="outline-text-4" id="text-Connection-flow-tracking">
<p>
Exposing either full conntrack, or the more light-weight flow tracking
support would make things like stateful firewalls easier to implement.
Probably need a concrete use case for this first, though.
</p>
</div>
</div>
</div>
<div id="outline-container-Port-iproute2-to-libbpf" class="outline-3">
<h3 id="Port-iproute2-to-libbpf"><a href="#Port-iproute2-to-libbpf"><span class="done DONE">DONE</span> Port iproute2 to libbpf</a></h3>
<div class="outline-text-3" id="text-Port-iproute2-to-libbpf">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-12-15 Tue 13:18]</span></span></p>
<p>
The iproute2 XDP loader does not use libbpf, because its implementation
predates the introduction of libbpf as the "official" upstream-blessed
library. This means that there are compatibility issues between the way
iproute2 handles maps, and the way libbpf-based loaders do.
</p>
<p>
The easiest way to fix this is probably just to port iproute2 to use libbpf,
which has now been merged into upstream iproute2.
</p>
</div>
</div>
<div id="outline-container-Metadata-available-to-programs" class="outline-3">
<h3 id="Metadata-available-to-programs"><a href="#Metadata-available-to-programs"><span class="todo TODO">TODO</span> Metadata available to programs</a></h3>
<div class="outline-text-3" id="text-Metadata-available-to-programs">
<p>
The metadata available to XDP programs through the XDP context object could
be expanded with other useful entries. This section collects lists of which
items would be useful to have, and explains why for each of them.
</p>
</div>
<div id="outline-container-XDP-frame-length" class="outline-4">
<h4 id="XDP-frame-length"><a href="#XDP-frame-length"><span class="done DONE">DONE</span> XDP frame length</a></h4>
<div class="outline-text-4" id="text-XDP-frame-length">
<p><span class="timestamp-wrapper"><span class="timestamp-kwd">CLOSED:</span> <span class="timestamp">[2020-10-19 Mon 12:55]</span></span></p>
<p>
DONE: Merge commit: <a href="https://git.kernel.org/torvalds/c/5cc5924d8315">https://git.kernel.org/torvalds/c/5cc5924d8315</a>
</p>
<p>
The length of the XDP <b>frame</b> (as opposed to the data packet) is needed for
various things: