switchdev.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. include:: <isonum.txt>
  3. .. _switchdev:
  4. ===============================================
  5. Ethernet switch device driver model (switchdev)
  6. ===============================================
  7. Copyright |copy| 2014 Jiri Pirko <jiri@resnulli.us>
  8. Copyright |copy| 2014-2015 Scott Feldman <sfeldma@gmail.com>
  9. The Ethernet switch device driver model (switchdev) is an in-kernel driver
  10. model for switch devices which offload the forwarding (data) plane from the
  11. kernel.
  12. Figure 1 is a block diagram showing the components of the switchdev model for
  13. an example setup using a data-center-class switch ASIC chip. Other setups
  14. with SR-IOV or soft switches, such as OVS, are possible.
  15. ::
  16. User-space tools
  17. user space |
  18. +-------------------------------------------------------------------+
  19. kernel | Netlink
  20. |
  21. +--------------+-------------------------------+
  22. | Network stack |
  23. | (Linux) |
  24. | |
  25. +----------------------------------------------+
  26. sw1p2 sw1p4 sw1p6
  27. sw1p1 + sw1p3 + sw1p5 + eth1
  28. + | + | + | +
  29. | | | | | | |
  30. +--+----+----+----+----+----+---+ +-----+-----+
  31. | Switch driver | | mgmt |
  32. | (this document) | | driver |
  33. | | | |
  34. +--------------+----------------+ +-----------+
  35. |
  36. kernel | HW bus (eg PCI)
  37. +-------------------------------------------------------------------+
  38. hardware |
  39. +--------------+----------------+
  40. | Switch device (sw1) |
  41. | +----+ +--------+
  42. | | v offloaded data path | mgmt port
  43. | | | |
  44. +--|----|----+----+----+----+---+
  45. | | | | | |
  46. + + + + + +
  47. p1 p2 p3 p4 p5 p6
  48. front-panel ports
  49. Fig 1.
  50. Include Files
  51. -------------
  52. ::
  53. #include <linux/netdevice.h>
  54. #include <net/switchdev.h>
  55. Configuration
  56. -------------
  57. Use "depends NET_SWITCHDEV" in driver's Kconfig to ensure switchdev model
  58. support is built for driver.
  59. Switch Ports
  60. ------------
  61. On switchdev driver initialization, the driver will allocate and register a
  62. struct net_device (using register_netdev()) for each enumerated physical switch
  63. port, called the port netdev. A port netdev is the software representation of
  64. the physical port and provides a conduit for control traffic to/from the
  65. controller (the kernel) and the network, as well as an anchor point for higher
  66. level constructs such as bridges, bonds, VLANs, tunnels, and L3 routers. Using
  67. standard netdev tools (iproute2, ethtool, etc), the port netdev can also
  68. provide to the user access to the physical properties of the switch port such
  69. as PHY link state and I/O statistics.
  70. There is (currently) no higher-level kernel object for the switch beyond the
  71. port netdevs. All of the switchdev driver ops are netdev ops or switchdev ops.
  72. A switch management port is outside the scope of the switchdev driver model.
  73. Typically, the management port is not participating in offloaded data plane and
  74. is loaded with a different driver, such as a NIC driver, on the management port
  75. device.
  76. Switch ID
  77. ^^^^^^^^^
  78. The switchdev driver must implement the net_device operation
  79. ndo_get_port_parent_id for each port netdev, returning the same physical ID for
  80. each port of a switch. The ID must be unique between switches on the same
  81. system. The ID does not need to be unique between switches on different
  82. systems.
  83. The switch ID is used to locate ports on a switch and to know if aggregated
  84. ports belong to the same switch.
  85. Port Netdev Naming
  86. ^^^^^^^^^^^^^^^^^^
  87. Udev rules should be used for port netdev naming, using some unique attribute
  88. of the port as a key, for example the port MAC address or the port PHYS name.
  89. Hard-coding of kernel netdev names within the driver is discouraged; let the
  90. kernel pick the default netdev name, and let udev set the final name based on a
  91. port attribute.
  92. Using port PHYS name (ndo_get_phys_port_name) for the key is particularly
  93. useful for dynamically-named ports where the device names its ports based on
  94. external configuration. For example, if a physical 40G port is split logically
  95. into 4 10G ports, resulting in 4 port netdevs, the device can give a unique
  96. name for each port using port PHYS name. The udev rule would be::
  97. SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}=="<phys_switch_id>", \
  98. ATTR{phys_port_name}!="", NAME="swX$attr{phys_port_name}"
  99. Suggested naming convention is "swXpYsZ", where X is the switch name or ID, Y
  100. is the port name or ID, and Z is the sub-port name or ID. For example, sw1p1s0
  101. would be sub-port 0 on port 1 on switch 1.
  102. Port Features
  103. ^^^^^^^^^^^^^
  104. dev->netns_immutable
  105. If the switchdev driver (and device) only supports offloading of the default
  106. network namespace (netns), the driver should set this private flag to prevent
  107. the port netdev from being moved out of the default netns. A netns-aware
  108. driver/device would not set this flag and be responsible for partitioning
  109. hardware to preserve netns containment. This means hardware cannot forward
  110. traffic from a port in one namespace to another port in another namespace.
  111. Port Topology
  112. ^^^^^^^^^^^^^
  113. The port netdevs representing the physical switch ports can be organized into
  114. higher-level switching constructs. The default construct is a standalone
  115. router port, used to offload L3 forwarding. Two or more ports can be bonded
  116. together to form a LAG. Two or more ports (or LAGs) can be bridged to bridge
  117. L2 networks. VLANs can be applied to sub-divide L2 networks. L2-over-L3
  118. tunnels can be built on ports. These constructs are built using standard Linux
  119. tools such as the bridge driver, the bonding/team drivers, and netlink-based
  120. tools such as iproute2.
  121. The switchdev driver can know a particular port's position in the topology by
  122. monitoring NETDEV_CHANGEUPPER notifications. For example, a port moved into a
  123. bond will see its upper master change. If that bond is moved into a bridge,
  124. the bond's upper master will change. And so on. The driver will track such
  125. movements to know what position a port is in in the overall topology by
  126. registering for netdevice events and acting on NETDEV_CHANGEUPPER.
  127. L2 Forwarding Offload
  128. ---------------------
  129. The idea is to offload the L2 data forwarding (switching) path from the kernel
  130. to the switchdev device by mirroring bridge FDB entries down to the device. An
  131. FDB entry is the {port, MAC, VLAN} tuple forwarding destination.
  132. To offloading L2 bridging, the switchdev driver/device should support:
  133. - Static FDB entries installed on a bridge port
  134. - Notification of learned/forgotten src mac/vlans from device
  135. - STP state changes on the port
  136. - VLAN flooding of multicast/broadcast and unknown unicast packets
  137. Static FDB Entries
  138. ^^^^^^^^^^^^^^^^^^
  139. A driver which implements the ``ndo_fdb_add``, ``ndo_fdb_del`` and
  140. ``ndo_fdb_dump`` operations is able to support the command below, which adds a
  141. static bridge FDB entry::
  142. bridge fdb add dev DEV ADDRESS [vlan VID] [self] static
  143. (the "static" keyword is non-optional: if not specified, the entry defaults to
  144. being "local", which means that it should not be forwarded)
  145. The "self" keyword (optional because it is implicit) has the role of
  146. instructing the kernel to fulfill the operation through the ``ndo_fdb_add``
  147. implementation of the ``DEV`` device itself. If ``DEV`` is a bridge port, this
  148. will bypass the bridge and therefore leave the software database out of sync
  149. with the hardware one.
  150. To avoid this, the "master" keyword can be used::
  151. bridge fdb add dev DEV ADDRESS [vlan VID] master static
  152. The above command instructs the kernel to search for a master interface of
  153. ``DEV`` and fulfill the operation through the ``ndo_fdb_add`` method of that.
  154. This time, the bridge generates a ``SWITCHDEV_FDB_ADD_TO_DEVICE`` notification
  155. which the port driver can handle and use it to program its hardware table. This
  156. way, the software and the hardware database will both contain this static FDB
  157. entry.
  158. Note: for new switchdev drivers that offload the Linux bridge, implementing the
  159. ``ndo_fdb_add`` and ``ndo_fdb_del`` bridge bypass methods is strongly
  160. discouraged: all static FDB entries should be added on a bridge port using the
  161. "master" flag. The ``ndo_fdb_dump`` is an exception and can be implemented to
  162. visualize the hardware tables, if the device does not have an interrupt for
  163. notifying the operating system of newly learned/forgotten dynamic FDB
  164. addresses. In that case, the hardware FDB might end up having entries that the
  165. software FDB does not, and implementing ``ndo_fdb_dump`` is the only way to see
  166. them.
  167. Note: by default, the bridge does not filter on VLAN and only bridges untagged
  168. traffic. To enable VLAN support, turn on VLAN filtering::
  169. echo 1 >/sys/class/net/<bridge>/bridge/vlan_filtering
  170. Notification of Learned/Forgotten Source MAC/VLANs
  171. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  172. The switch device will learn/forget source MAC address/VLAN on ingress packets
  173. and notify the switch driver of the mac/vlan/port tuples. The switch driver,
  174. in turn, will notify the bridge driver using the switchdev notifier call::
  175. err = call_switchdev_notifiers(val, dev, info, extack);
  176. Where val is SWITCHDEV_FDB_ADD when learning and SWITCHDEV_FDB_DEL when
  177. forgetting, and info points to a struct switchdev_notifier_fdb_info. On
  178. SWITCHDEV_FDB_ADD, the bridge driver will install the FDB entry into the
  179. bridge's FDB and mark the entry as NTF_EXT_LEARNED. The iproute2 bridge
  180. command will label these entries "offload"::
  181. $ bridge fdb
  182. 52:54:00:12:35:01 dev sw1p1 master br0 permanent
  183. 00:02:00:00:02:00 dev sw1p1 master br0 offload
  184. 00:02:00:00:02:00 dev sw1p1 self
  185. 52:54:00:12:35:02 dev sw1p2 master br0 permanent
  186. 00:02:00:00:03:00 dev sw1p2 master br0 offload
  187. 00:02:00:00:03:00 dev sw1p2 self
  188. 33:33:00:00:00:01 dev eth0 self permanent
  189. 01:00:5e:00:00:01 dev eth0 self permanent
  190. 33:33:ff:00:00:00 dev eth0 self permanent
  191. 01:80:c2:00:00:0e dev eth0 self permanent
  192. 33:33:00:00:00:01 dev br0 self permanent
  193. 01:00:5e:00:00:01 dev br0 self permanent
  194. 33:33:ff:12:35:01 dev br0 self permanent
  195. Learning on the port should be disabled on the bridge using the bridge command::
  196. bridge link set dev DEV learning off
  197. Learning on the device port should be enabled, as well as learning_sync::
  198. bridge link set dev DEV learning on self
  199. bridge link set dev DEV learning_sync on self
  200. Learning_sync attribute enables syncing of the learned/forgotten FDB entry to
  201. the bridge's FDB. It's possible, but not optimal, to enable learning on the
  202. device port and on the bridge port, and disable learning_sync.
  203. To support learning, the driver implements switchdev op
  204. switchdev_port_attr_set for SWITCHDEV_ATTR_PORT_ID_{PRE}_BRIDGE_FLAGS.
  205. FDB Ageing
  206. ^^^^^^^^^^
  207. The bridge will skip ageing FDB entries marked with NTF_EXT_LEARNED and it is
  208. the responsibility of the port driver/device to age out these entries. If the
  209. port device supports ageing, when the FDB entry expires, it will notify the
  210. driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL. If the
  211. device does not support ageing, the driver can simulate ageing using a
  212. garbage collection timer to monitor FDB entries. Expired entries will be
  213. notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for
  214. example of driver running ageing timer.
  215. To keep an NTF_EXT_LEARNED entry "alive", the driver should refresh the FDB
  216. entry by calling call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The
  217. notification will reset the FDB entry's last-used time to now. The driver
  218. should rate limit refresh notifications, for example, no more than once a
  219. second. (The last-used time is visible using the bridge -s fdb option).
  220. STP State Change on Port
  221. ^^^^^^^^^^^^^^^^^^^^^^^^
  222. Internally or with a third-party STP protocol implementation (e.g. mstpd), the
  223. bridge driver maintains the STP state for ports, and will notify the switch
  224. driver of STP state change on a port using the switchdev op
  225. switchdev_attr_port_set for SWITCHDEV_ATTR_PORT_ID_STP_UPDATE.
  226. State is one of BR_STATE_*. The switch driver can use STP state updates to
  227. update ingress packet filter list for the port. For example, if port is
  228. DISABLED, no packets should pass, but if port moves to BLOCKED, then STP BPDUs
  229. and other IEEE 01:80:c2:xx:xx:xx link-local multicast packets can pass.
  230. Note that STP BDPUs are untagged and STP state applies to all VLANs on the port
  231. so packet filters should be applied consistently across untagged and tagged
  232. VLANs on the port.
  233. Flooding L2 domain
  234. ^^^^^^^^^^^^^^^^^^
  235. For a given L2 VLAN domain, the switch device should flood multicast/broadcast
  236. and unknown unicast packets to all ports in domain, if allowed by port's
  237. current STP state. The switch driver, knowing which ports are within which
  238. vlan L2 domain, can program the switch device for flooding. The packet may
  239. be sent to the port netdev for processing by the bridge driver. The
  240. bridge should not reflood the packet to the same ports the device flooded,
  241. otherwise there will be duplicate packets on the wire.
  242. To avoid duplicate packets, the switch driver should mark a packet as already
  243. forwarded by setting the skb->offload_fwd_mark bit. The bridge driver will mark
  244. the skb using the ingress bridge port's mark and prevent it from being forwarded
  245. through any bridge port with the same mark.
  246. It is possible for the switch device to not handle flooding and push the
  247. packets up to the bridge driver for flooding. This is not ideal as the number
  248. of ports scale in the L2 domain as the device is much more efficient at
  249. flooding packets that software.
  250. If supported by the device, flood control can be offloaded to it, preventing
  251. certain netdevs from flooding unicast traffic for which there is no FDB entry.
  252. IGMP Snooping
  253. ^^^^^^^^^^^^^
  254. In order to support IGMP snooping, the port netdevs should trap to the bridge
  255. driver all IGMP join and leave messages.
  256. The bridge multicast module will notify port netdevs on every multicast group
  257. changed whether it is static configured or dynamically joined/leave.
  258. The hardware implementation should be forwarding all registered multicast
  259. traffic groups only to the configured ports.
  260. L3 Routing Offload
  261. ------------------
  262. Offloading L3 routing requires that device be programmed with FIB entries from
  263. the kernel, with the device doing the FIB lookup and forwarding. The device
  264. does a longest prefix match (LPM) on FIB entries matching route prefix and
  265. forwards the packet to the matching FIB entry's nexthop(s) egress ports.
  266. To program the device, the driver has to register a FIB notifier handler
  267. using register_fib_notifier. The following events are available:
  268. =================== ===================================================
  269. FIB_EVENT_ENTRY_ADD used for both adding a new FIB entry to the device,
  270. or modifying an existing entry on the device.
  271. FIB_EVENT_ENTRY_DEL used for removing a FIB entry
  272. FIB_EVENT_RULE_ADD,
  273. FIB_EVENT_RULE_DEL used to propagate FIB rule changes
  274. =================== ===================================================
  275. FIB_EVENT_ENTRY_ADD and FIB_EVENT_ENTRY_DEL events pass::
  276. struct fib_entry_notifier_info {
  277. struct fib_notifier_info info; /* must be first */
  278. u32 dst;
  279. int dst_len;
  280. struct fib_info *fi;
  281. u8 tos;
  282. u8 type;
  283. u32 tb_id;
  284. u32 nlflags;
  285. };
  286. to add/modify/delete IPv4 dst/dest_len prefix on table tb_id. The ``*fi``
  287. structure holds details on the route and route's nexthops. ``*dev`` is one
  288. of the port netdevs mentioned in the route's next hop list.
  289. Routes offloaded to the device are labeled with "offload" in the ip route
  290. listing::
  291. $ ip route show
  292. default via 192.168.0.2 dev eth0
  293. 11.0.0.0/30 dev sw1p1 proto kernel scope link src 11.0.0.2 offload
  294. 11.0.0.4/30 via 11.0.0.1 dev sw1p1 proto zebra metric 20 offload
  295. 11.0.0.8/30 dev sw1p2 proto kernel scope link src 11.0.0.10 offload
  296. 11.0.0.12/30 via 11.0.0.9 dev sw1p2 proto zebra metric 20 offload
  297. 12.0.0.2 proto zebra metric 30 offload
  298. nexthop via 11.0.0.1 dev sw1p1 weight 1
  299. nexthop via 11.0.0.9 dev sw1p2 weight 1
  300. 12.0.0.3 via 11.0.0.1 dev sw1p1 proto zebra metric 20 offload
  301. 12.0.0.4 via 11.0.0.9 dev sw1p2 proto zebra metric 20 offload
  302. 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.15
  303. The "offload" flag is set in case at least one device offloads the FIB entry.
  304. XXX: add/mod/del IPv6 FIB API
  305. Nexthop Resolution
  306. ^^^^^^^^^^^^^^^^^^
  307. The FIB entry's nexthop list contains the nexthop tuple (gateway, dev), but for
  308. the switch device to forward the packet with the correct dst mac address, the
  309. nexthop gateways must be resolved to the neighbor's mac address. Neighbor mac
  310. address discovery comes via the ARP (or ND) process and is available via the
  311. arp_tbl neighbor table. To resolve the routes nexthop gateways, the driver
  312. should trigger the kernel's neighbor resolution process. See the rocker
  313. driver's rocker_port_ipv4_resolve() for an example.
  314. The driver can monitor for updates to arp_tbl using the netevent notifier
  315. NETEVENT_NEIGH_UPDATE. The device can be programmed with resolved nexthops
  316. for the routes as arp_tbl updates. The driver implements ndo_neigh_destroy
  317. to know when arp_tbl neighbor entries are purged from the port.
  318. Device driver expected behavior
  319. -------------------------------
  320. Below is a set of defined behavior that switchdev enabled network devices must
  321. adhere to.
  322. Configuration-less state
  323. ^^^^^^^^^^^^^^^^^^^^^^^^
  324. Upon driver bring up, the network devices must be fully operational, and the
  325. backing driver must configure the network device such that it is possible to
  326. send and receive traffic to this network device and it is properly separated
  327. from other network devices/ports (e.g.: as is frequent with a switch ASIC). How
  328. this is achieved is heavily hardware dependent, but a simple solution can be to
  329. use per-port VLAN identifiers unless a better mechanism is available
  330. (proprietary metadata for each network port for instance).
  331. The network device must be capable of running a full IP protocol stack
  332. including multicast, DHCP, IPv4/6, etc. If necessary, it should program the
  333. appropriate filters for VLAN, multicast, unicast etc. The underlying device
  334. driver must effectively be configured in a similar fashion to what it would do
  335. when IGMP snooping is enabled for IP multicast over these switchdev network
  336. devices and unsolicited multicast must be filtered as early as possible in
  337. the hardware.
  338. When configuring VLANs on top of the network device, all VLANs must be working,
  339. irrespective of the state of other network devices (e.g.: other ports being part
  340. of a VLAN-aware bridge doing ingress VID checking). See below for details.
  341. If the device implements e.g.: VLAN filtering, putting the interface in
  342. promiscuous mode should allow the reception of all VLAN tags (including those
  343. not present in the filter(s)).
  344. Bridged switch ports
  345. ^^^^^^^^^^^^^^^^^^^^
  346. When a switchdev enabled network device is added as a bridge member, it should
  347. not disrupt any functionality of non-bridged network devices and they
  348. should continue to behave as normal network devices. Depending on the bridge
  349. configuration knobs below, the expected behavior is documented.
  350. Bridge VLAN filtering
  351. ^^^^^^^^^^^^^^^^^^^^^
  352. The Linux bridge allows the configuration of a VLAN filtering mode (statically,
  353. at device creation time, and dynamically, during run time) which must be
  354. observed by the underlying switchdev network device/hardware:
  355. - with VLAN filtering turned off: the bridge is strictly VLAN unaware and its
  356. data path will process all Ethernet frames as if they are VLAN-untagged.
  357. The bridge VLAN database can still be modified, but the modifications should
  358. have no effect while VLAN filtering is turned off. Frames ingressing the
  359. device with a VID that is not programmed into the bridge/switch's VLAN table
  360. must be forwarded and may be processed using a VLAN device (see below).
  361. - with VLAN filtering turned on: the bridge is VLAN-aware and frames ingressing
  362. the device with a VID that is not programmed into the bridges/switch's VLAN
  363. table must be dropped (strict VID checking).
  364. When there is a VLAN device (e.g: sw0p1.100) configured on top of a switchdev
  365. network device which is a bridge port member, the behavior of the software
  366. network stack must be preserved, or the configuration must be refused if that
  367. is not possible.
  368. - with VLAN filtering turned off, the bridge will process all ingress traffic
  369. for the port, except for the traffic tagged with a VLAN ID destined for a
  370. VLAN upper. The VLAN upper interface (which consumes the VLAN tag) can even
  371. be added to a second bridge, which includes other switch ports or software
  372. interfaces. Some approaches to ensure that the forwarding domain for traffic
  373. belonging to the VLAN upper interfaces are managed properly:
  374. * If forwarding destinations can be managed per VLAN, the hardware could be
  375. configured to map all traffic, except the packets tagged with a VID
  376. belonging to a VLAN upper interface, to an internal VID corresponding to
  377. untagged packets. This internal VID spans all ports of the VLAN-unaware
  378. bridge. The VID corresponding to the VLAN upper interface spans the
  379. physical port of that VLAN interface, as well as the other ports that
  380. might be bridged with it.
  381. * Treat bridge ports with VLAN upper interfaces as standalone, and let
  382. forwarding be handled in the software data path.
  383. - with VLAN filtering turned on, these VLAN devices can be created as long as
  384. the bridge does not have an existing VLAN entry with the same VID on any
  385. bridge port. These VLAN devices cannot be enslaved into the bridge since they
  386. duplicate functionality/use case with the bridge's VLAN data path processing.
  387. Non-bridged network ports of the same switch fabric must not be disturbed in any
  388. way by the enabling of VLAN filtering on the bridge device(s). If the VLAN
  389. filtering setting is global to the entire chip, then the standalone ports
  390. should indicate to the network stack that VLAN filtering is required by setting
  391. 'rx-vlan-filter: on [fixed]' in the ethtool features.
  392. Because VLAN filtering can be turned on/off at runtime, the switchdev driver
  393. must be able to reconfigure the underlying hardware on the fly to honor the
  394. toggling of that option and behave appropriately. If that is not possible, the
  395. switchdev driver can also refuse to support dynamic toggling of the VLAN
  396. filtering knob at runtime and require a destruction of the bridge device(s) and
  397. creation of new bridge device(s) with a different VLAN filtering value to
  398. ensure VLAN awareness is pushed down to the hardware.
  399. Even when VLAN filtering in the bridge is turned off, the underlying switch
  400. hardware and driver may still configure itself in a VLAN-aware mode provided
  401. that the behavior described above is observed.
  402. The VLAN protocol of the bridge plays a role in deciding whether a packet is
  403. treated as tagged or not: a bridge using the 802.1ad protocol must treat both
  404. VLAN-untagged packets, as well as packets tagged with 802.1Q headers, as
  405. untagged.
  406. The 802.1p (VID 0) tagged packets must be treated in the same way by the device
  407. as untagged packets, since the bridge device does not allow the manipulation of
  408. VID 0 in its database.
  409. When the bridge has VLAN filtering enabled and a PVID is not configured on the
  410. ingress port, untagged and 802.1p tagged packets must be dropped. When the bridge
  411. has VLAN filtering enabled and a PVID exists on the ingress port, untagged and
  412. priority-tagged packets must be accepted and forwarded according to the
  413. bridge's port membership of the PVID VLAN. When the bridge has VLAN filtering
  414. disabled, the presence/lack of a PVID should not influence the packet
  415. forwarding decision.
  416. Bridge IGMP snooping
  417. ^^^^^^^^^^^^^^^^^^^^
  418. The Linux bridge allows the configuration of IGMP snooping (statically, at
  419. interface creation time, or dynamically, during runtime) which must be observed
  420. by the underlying switchdev network device/hardware in the following way:
  421. - when IGMP snooping is turned off, multicast traffic must be flooded to all
  422. ports within the same bridge that have mcast_flood=true. The CPU/management
  423. port should ideally not be flooded (unless the ingress interface has
  424. IFF_ALLMULTI or IFF_PROMISC) and continue to learn multicast traffic through
  425. the network stack notifications. If the hardware is not capable of doing that
  426. then the CPU/management port must also be flooded and multicast filtering
  427. happens in software.
  428. - when IGMP snooping is turned on, multicast traffic must selectively flow
  429. to the appropriate network ports (including CPU/management port). Flooding of
  430. unknown multicast should be only towards the ports connected to a multicast
  431. router (the local device may also act as a multicast router).
  432. The switch must adhere to RFC 4541 and flood multicast traffic accordingly
  433. since that is what the Linux bridge implementation does.
  434. Because IGMP snooping can be turned on/off at runtime, the switchdev driver
  435. must be able to reconfigure the underlying hardware on the fly to honor the
  436. toggling of that option and behave appropriately.
  437. A switchdev driver can also refuse to support dynamic toggling of the multicast
  438. snooping knob at runtime and require the destruction of the bridge device(s)
  439. and creation of a new bridge device(s) with a different multicast snooping
  440. value.