Skip to content

Commit 47ec530

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next
Pull networking updates from David Miller: 1) Support 6Ghz band in ath11k driver, from Rajkumar Manoharan. 2) Support UDP segmentation in code TSO code, from Eric Dumazet. 3) Allow flashing different flash images in cxgb4 driver, from Vishal Kulkarni. 4) Add drop frames counter and flow status to tc flower offloading, from Po Liu. 5) Support n-tuple filters in cxgb4, from Vishal Kulkarni. 6) Various new indirect call avoidance, from Eric Dumazet and Brian Vazquez. 7) Fix BPF verifier failures on 32-bit pointer arithmetic, from Yonghong Song. 8) Support querying and setting hardware address of a port function via devlink, use this in mlx5, from Parav Pandit. 9) Support hw ipsec offload on bonding slaves, from Jarod Wilson. 10) Switch qca8k driver over to phylink, from Jonathan McDowell. 11) In bpftool, show list of processes holding BPF FD references to maps, programs, links, and btf objects. From Andrii Nakryiko. 12) Several conversions over to generic power management, from Vaibhav Gupta. 13) Add support for SO_KEEPALIVE et al. to bpf_setsockopt(), from Dmitry Yakunin. 14) Various https url conversions, from Alexander A. Klimov. 15) Timestamping and PHC support for mscc PHY driver, from Antoine Tenart. 16) Support bpf iterating over tcp and udp sockets, from Yonghong Song. 17) Support 5GBASE-T i40e NICs, from Aleksandr Loktionov. 18) Add kTLS RX HW offload support to mlx5e, from Tariq Toukan. 19) Fix the ->ndo_start_xmit() return type to be netdev_tx_t in several drivers. From Luc Van Oostenryck. 20) XDP support for xen-netfront, from Denis Kirjanov. 21) Support receive buffer autotuning in MPTCP, from Florian Westphal. 22) Support EF100 chip in sfc driver, from Edward Cree. 23) Add XDP support to mvpp2 driver, from Matteo Croce. 24) Support MPTCP in sock_diag, from Paolo Abeni. 25) Commonize UDP tunnel offloading code by creating udp_tunnel_nic infrastructure, from Jakub Kicinski. 26) Several pci_ --> dma_ API conversions, from Christophe JAILLET. 27) Add FLOW_ACTION_POLICE support to mlxsw, from Ido Schimmel. 28) Add SK_LOOKUP bpf program type, from Jakub Sitnicki. 29) Refactor a lot of networking socket option handling code in order to avoid set_fs() calls, from Christoph Hellwig. 30) Add rfc4884 support to icmp code, from Willem de Bruijn. 31) Support TBF offload in dpaa2-eth driver, from Ioana Ciornei. 32) Support XDP_REDIRECT in qede driver, from Alexander Lobakin. 33) Support PCI relaxed ordering in mlx5 driver, from Aya Levin. 34) Support TCP syncookies in MPTCP, from Flowian Westphal. 35) Fix several tricky cases of PMTU handling wrt. briding, from Stefano Brivio. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2056 commits) net: thunderx: initialize VF's mailbox mutex before first usage usb: hso: remove bogus check for EINPROGRESS usb: hso: no complaint about kmalloc failure hso: fix bailout in error case of probe ip_tunnel_core: Fix build for archs without _HAVE_ARCH_IPV6_CSUM selftests/net: relax cpu affinity requirement in msg_zerocopy test mptcp: be careful on subflow creation selftests: rtnetlink: make kci_test_encap() return sub-test result selftests: rtnetlink: correct the final return value for the test net: dsa: sja1105: use detected device id instead of DT one on mismatch tipc: set ub->ifindex for local ipv6 address ipv6: add ipv6_dev_find() net: openvswitch: silence suspicious RCU usage warning Revert "vxlan: fix tos value before xmit" ptp: only allow phase values lower than 1 period farsync: switch from 'pci_' to 'dma_' API wan: wanxl: switch from 'pci_' to 'dma_' API hv_netvsc: do not use VF device if link is down dpaa2-eth: Fix passing zero to 'PTR_ERR' warning net: macb: Properly handle phylink on at91sam9x ...
2 parents 8186749 + c1055b7 commit 47ec530

File tree

2,088 files changed

+117531
-41040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,088 files changed

+117531
-41040
lines changed

Documentation/bpf/btf.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,42 @@ kernel API, the ``insn_off`` is the instruction offset in the unit of ``struct
691691
bpf_insn``. For ELF API, the ``insn_off`` is the byte offset from the
692692
beginning of section (``btf_ext_info_sec->sec_name_off``).
693693

694+
4.2 .BTF_ids section
695+
====================
696+
697+
The .BTF_ids section encodes BTF ID values that are used within the kernel.
698+
699+
This section is created during the kernel compilation with the help of
700+
macros defined in ``include/linux/btf_ids.h`` header file. Kernel code can
701+
use them to create lists and sets (sorted lists) of BTF ID values.
702+
703+
The ``BTF_ID_LIST`` and ``BTF_ID`` macros define unsorted list of BTF ID values,
704+
with following syntax::
705+
706+
BTF_ID_LIST(list)
707+
BTF_ID(type1, name1)
708+
BTF_ID(type2, name2)
709+
710+
resulting in following layout in .BTF_ids section::
711+
712+
__BTF_ID__type1__name1__1:
713+
.zero 4
714+
__BTF_ID__type2__name2__2:
715+
.zero 4
716+
717+
The ``u32 list[];`` variable is defined to access the list.
718+
719+
The ``BTF_ID_UNUSED`` macro defines 4 zero bytes. It's used when we
720+
want to define unused entry in BTF_ID_LIST, like::
721+
722+
BTF_ID_LIST(bpf_skb_output_btf_ids)
723+
BTF_ID(struct, sk_buff)
724+
BTF_ID_UNUSED
725+
BTF_ID(struct, task_struct)
726+
727+
All the BTF ID lists and sets are compiled in the .BTF_ids section and
728+
resolved during the linking phase of kernel build by ``resolve_btfids`` tool.
729+
694730
5. Using BTF
695731
************
696732

Documentation/bpf/index.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ BPF Documentation
55
This directory contains documentation for the BPF (Berkeley Packet
66
Filter) facility, with a focus on the extended BPF version (eBPF).
77

8-
This kernel side documentation is still work in progress. The main
8+
This kernel side documentation is still work in progress. The main
99
textual documentation is (for historical reasons) described in
10-
`Documentation/networking/filter.rst`_, which describe both classical
11-
and extended BPF instruction-set.
10+
:ref:`networking-filter`, which describe both classical and extended
11+
BPF instruction-set.
1212
The Cilium project also maintains a `BPF and XDP Reference Guide`_
1313
that goes into great technical depth about the BPF Architecture.
1414

@@ -48,6 +48,15 @@ Program types
4848
bpf_lsm
4949

5050

51+
Map types
52+
=========
53+
54+
.. toctree::
55+
:maxdepth: 1
56+
57+
map_cgroup_storage
58+
59+
5160
Testing and debugging BPF
5261
=========================
5362

@@ -67,7 +76,7 @@ Other
6776
ringbuf
6877

6978
.. Links:
70-
.. _Documentation/networking/filter.rst: ../networking/filter.txt
79+
.. _networking-filter: ../networking/filter.rst
7180
.. _man-pages: https://www.kernel.org/doc/man-pages/
72-
.. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html
73-
.. _BPF and XDP Reference Guide: http://cilium.readthedocs.io/en/latest/bpf/
81+
.. _bpf(2): https://man7.org/linux/man-pages/man2/bpf.2.html
82+
.. _BPF and XDP Reference Guide: https://docs.cilium.io/en/latest/bpf/
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
.. SPDX-License-Identifier: GPL-2.0-only
2+
.. Copyright (C) 2020 Google LLC.
3+
4+
===========================
5+
BPF_MAP_TYPE_CGROUP_STORAGE
6+
===========================
7+
8+
The ``BPF_MAP_TYPE_CGROUP_STORAGE`` map type represents a local fix-sized
9+
storage. It is only available with ``CONFIG_CGROUP_BPF``, and to programs that
10+
attach to cgroups; the programs are made available by the same Kconfig. The
11+
storage is identified by the cgroup the program is attached to.
12+
13+
The map provide a local storage at the cgroup that the BPF program is attached
14+
to. It provides a faster and simpler access than the general purpose hash
15+
table, which performs a hash table lookups, and requires user to track live
16+
cgroups on their own.
17+
18+
This document describes the usage and semantics of the
19+
``BPF_MAP_TYPE_CGROUP_STORAGE`` map type. Some of its behaviors was changed in
20+
Linux 5.9 and this document will describe the differences.
21+
22+
Usage
23+
=====
24+
25+
The map uses key of type of either ``__u64 cgroup_inode_id`` or
26+
``struct bpf_cgroup_storage_key``, declared in ``linux/bpf.h``::
27+
28+
struct bpf_cgroup_storage_key {
29+
__u64 cgroup_inode_id;
30+
__u32 attach_type;
31+
};
32+
33+
``cgroup_inode_id`` is the inode id of the cgroup directory.
34+
``attach_type`` is the the program's attach type.
35+
36+
Linux 5.9 added support for type ``__u64 cgroup_inode_id`` as the key type.
37+
When this key type is used, then all attach types of the particular cgroup and
38+
map will share the same storage. Otherwise, if the type is
39+
``struct bpf_cgroup_storage_key``, then programs of different attach types
40+
be isolated and see different storages.
41+
42+
To access the storage in a program, use ``bpf_get_local_storage``::
43+
44+
void *bpf_get_local_storage(void *map, u64 flags)
45+
46+
``flags`` is reserved for future use and must be 0.
47+
48+
There is no implicit synchronization. Storages of ``BPF_MAP_TYPE_CGROUP_STORAGE``
49+
can be accessed by multiple programs across different CPUs, and user should
50+
take care of synchronization by themselves. The bpf infrastructure provides
51+
``struct bpf_spin_lock`` to synchronize the storage. See
52+
``tools/testing/selftests/bpf/progs/test_spin_lock.c``.
53+
54+
Examples
55+
========
56+
57+
Usage with key type as ``struct bpf_cgroup_storage_key``::
58+
59+
#include <bpf/bpf.h>
60+
61+
struct {
62+
__uint(type, BPF_MAP_TYPE_CGROUP_STORAGE);
63+
__type(key, struct bpf_cgroup_storage_key);
64+
__type(value, __u32);
65+
} cgroup_storage SEC(".maps");
66+
67+
int program(struct __sk_buff *skb)
68+
{
69+
__u32 *ptr = bpf_get_local_storage(&cgroup_storage, 0);
70+
__sync_fetch_and_add(ptr, 1);
71+
72+
return 0;
73+
}
74+
75+
Userspace accessing map declared above::
76+
77+
#include <linux/bpf.h>
78+
#include <linux/libbpf.h>
79+
80+
__u32 map_lookup(struct bpf_map *map, __u64 cgrp, enum bpf_attach_type type)
81+
{
82+
struct bpf_cgroup_storage_key = {
83+
.cgroup_inode_id = cgrp,
84+
.attach_type = type,
85+
};
86+
__u32 value;
87+
bpf_map_lookup_elem(bpf_map__fd(map), &key, &value);
88+
// error checking omitted
89+
return value;
90+
}
91+
92+
Alternatively, using just ``__u64 cgroup_inode_id`` as key type::
93+
94+
#include <bpf/bpf.h>
95+
96+
struct {
97+
__uint(type, BPF_MAP_TYPE_CGROUP_STORAGE);
98+
__type(key, __u64);
99+
__type(value, __u32);
100+
} cgroup_storage SEC(".maps");
101+
102+
int program(struct __sk_buff *skb)
103+
{
104+
__u32 *ptr = bpf_get_local_storage(&cgroup_storage, 0);
105+
__sync_fetch_and_add(ptr, 1);
106+
107+
return 0;
108+
}
109+
110+
And userspace::
111+
112+
#include <linux/bpf.h>
113+
#include <linux/libbpf.h>
114+
115+
__u32 map_lookup(struct bpf_map *map, __u64 cgrp, enum bpf_attach_type type)
116+
{
117+
__u32 value;
118+
bpf_map_lookup_elem(bpf_map__fd(map), &cgrp, &value);
119+
// error checking omitted
120+
return value;
121+
}
122+
123+
Semantics
124+
=========
125+
126+
``BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE`` is a variant of this map type. This
127+
per-CPU variant will have different memory regions for each CPU for each
128+
storage. The non-per-CPU will have the same memory region for each storage.
129+
130+
Prior to Linux 5.9, the lifetime of a storage is precisely per-attachment, and
131+
for a single ``CGROUP_STORAGE`` map, there can be at most one program loaded
132+
that uses the map. A program may be attached to multiple cgroups or have
133+
multiple attach types, and each attach creates a fresh zeroed storage. The
134+
storage is freed upon detach.
135+
136+
There is a one-to-one association between the map of each type (per-CPU and
137+
non-per-CPU) and the BPF program during load verification time. As a result,
138+
each map can only be used by one BPF program and each BPF program can only use
139+
one storage map of each type. Because of map can only be used by one BPF
140+
program, sharing of this cgroup's storage with other BPF programs were
141+
impossible.
142+
143+
Since Linux 5.9, storage can be shared by multiple programs. When a program is
144+
attached to a cgroup, the kernel would create a new storage only if the map
145+
does not already contain an entry for the cgroup and attach type pair, or else
146+
the old storage is reused for the new attachment. If the map is attach type
147+
shared, then attach type is simply ignored during comparison. Storage is freed
148+
only when either the map or the cgroup attached to is being freed. Detaching
149+
will not directly free the storage, but it may cause the reference to the map
150+
to reach zero and indirectly freeing all storage in the map.
151+
152+
The map is not associated with any BPF program, thus making sharing possible.
153+
However, the BPF program can still only associate with one map of each type
154+
(per-CPU and non-per-CPU). A BPF program cannot use more than one
155+
``BPF_MAP_TYPE_CGROUP_STORAGE`` or more than one
156+
``BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE``.
157+
158+
In all versions, userspace may use the the attach parameters of cgroup and
159+
attach type pair in ``struct bpf_cgroup_storage_key`` as the key to the BPF map
160+
APIs to read or update the storage for a given attachment. For Linux 5.9
161+
attach type shared storages, only the first value in the struct, cgroup inode
162+
id, is used during comparison, so userspace may just specify a ``__u64``
163+
directly.
164+
165+
The storage is bound at attach time. Even if the program is attached to parent
166+
and triggers in child, the storage still belongs to the parent.
167+
168+
Userspace cannot create a new entry in the map or delete an existing entry.
169+
Program test runs always use a temporary storage.

Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ such as network interfaces, crypto accelerator instances, L2 switches,
1010
etc.
1111

1212
For an overview of the DPAA2 architecture and fsl-mc bus see:
13-
Documentation/networking/device_drivers/freescale/dpaa2/overview.rst
13+
Documentation/networking/device_drivers/ethernet/freescale/dpaa2/overview.rst
1414

1515
As described in the above overview, all DPAA2 objects in a DPRC share the
1616
same hardware "isolation context" and a 10-bit value called an ICID

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ select:
2222
- amlogic,meson8m2-dwmac
2323
- amlogic,meson-gxbb-dwmac
2424
- amlogic,meson-axg-dwmac
25+
- amlogic,meson-g12a-dwmac
2526
required:
2627
- compatible
2728

@@ -36,6 +37,7 @@ allOf:
3637
- amlogic,meson8m2-dwmac
3738
- amlogic,meson-gxbb-dwmac
3839
- amlogic,meson-axg-dwmac
40+
- amlogic,meson-g12a-dwmac
3941

4042
then:
4143
properties:
@@ -95,6 +97,7 @@ properties:
9597
- amlogic,meson8m2-dwmac
9698
- amlogic,meson-gxbb-dwmac
9799
- amlogic,meson-axg-dwmac
100+
- amlogic,meson-g12a-dwmac
98101
contains:
99102
enum:
100103
- snps,dwmac-3.70a

0 commit comments

Comments
 (0)