@@ -49,6 +49,9 @@ In this documentation the following Ethernet interfaces are used:
49
49
*eth0 *
50
50
the master interface
51
51
52
+ *eth1 *
53
+ another master interface
54
+
52
55
*lan1 *
53
56
a slave interface
54
57
@@ -360,3 +363,96 @@ the ``self`` flag) has been removed. This results in the following changes:
360
363
361
364
Script writers are therefore encouraged to use the ``master static `` set of
362
365
flags when working with bridge FDB entries on DSA switch interfaces.
366
+
367
+ Affinity of user ports to CPU ports
368
+ -----------------------------------
369
+
370
+ Typically, DSA switches are attached to the host via a single Ethernet
371
+ interface, but in cases where the switch chip is discrete, the hardware design
372
+ may permit the use of 2 or more ports connected to the host, for an increase in
373
+ termination throughput.
374
+
375
+ DSA can make use of multiple CPU ports in two ways. First, it is possible to
376
+ statically assign the termination traffic associated with a certain user port
377
+ to be processed by a certain CPU port. This way, user space can implement
378
+ custom policies of static load balancing between user ports, by spreading the
379
+ affinities according to the available CPU ports.
380
+
381
+ Secondly, it is possible to perform load balancing between CPU ports on a per
382
+ packet basis, rather than statically assigning user ports to CPU ports.
383
+ This can be achieved by placing the DSA masters under a LAG interface (bonding
384
+ or team). DSA monitors this operation and creates a mirror of this software LAG
385
+ on the CPU ports facing the physical DSA masters that constitute the LAG slave
386
+ devices.
387
+
388
+ To make use of multiple CPU ports, the firmware (device tree) description of
389
+ the switch must mark all the links between CPU ports and their DSA masters
390
+ using the ``ethernet `` reference/phandle. At startup, only a single CPU port
391
+ and DSA master will be used - the numerically first port from the firmware
392
+ description which has an ``ethernet `` property. It is up to the user to
393
+ configure the system for the switch to use other masters.
394
+
395
+ DSA uses the ``rtnl_link_ops `` mechanism (with a "dsa" ``kind ``) to allow
396
+ changing the DSA master of a user port. The ``IFLA_DSA_MASTER `` u32 netlink
397
+ attribute contains the ifindex of the master device that handles each slave
398
+ device. The DSA master must be a valid candidate based on firmware node
399
+ information, or a LAG interface which contains only slaves which are valid
400
+ candidates.
401
+
402
+ Using iproute2, the following manipulations are possible:
403
+
404
+ .. code-block :: sh
405
+
406
+ # See the DSA master in current use
407
+ ip -d link show dev swp0
408
+ (...)
409
+ dsa master eth0
410
+
411
+ # Static CPU port distribution
412
+ ip link set swp0 type dsa master eth1
413
+ ip link set swp1 type dsa master eth0
414
+ ip link set swp2 type dsa master eth1
415
+ ip link set swp3 type dsa master eth0
416
+
417
+ # CPU ports in LAG, using explicit assignment of the DSA master
418
+ ip link add bond0 type bond mode balance-xor && ip link set bond0 up
419
+ ip link set eth1 down && ip link set eth1 master bond0
420
+ ip link set swp0 type dsa master bond0
421
+ ip link set swp1 type dsa master bond0
422
+ ip link set swp2 type dsa master bond0
423
+ ip link set swp3 type dsa master bond0
424
+ ip link set eth0 down && ip link set eth0 master bond0
425
+ ip -d link show dev swp0
426
+ (...)
427
+ dsa master bond0
428
+
429
+ # CPU ports in LAG, relying on implicit migration of the DSA master
430
+ ip link add bond0 type bond mode balance-xor && ip link set bond0 up
431
+ ip link set eth0 down && ip link set eth0 master bond0
432
+ ip link set eth1 down && ip link set eth1 master bond0
433
+ ip -d link show dev swp0
434
+ (...)
435
+ dsa master bond0
436
+
437
+ Notice that in the case of CPU ports under a LAG, the use of the
438
+ ``IFLA_DSA_MASTER `` netlink attribute is not strictly needed, but rather, DSA
439
+ reacts to the ``IFLA_MASTER `` attribute change of its present master (``eth0 ``)
440
+ and migrates all user ports to the new upper of ``eth0 ``, ``bond0 ``. Similarly,
441
+ when ``bond0 `` is destroyed using ``RTM_DELLINK ``, DSA migrates the user ports
442
+ that were assigned to this interface to the first physical DSA master which is
443
+ eligible, based on the firmware description (it effectively reverts to the
444
+ startup configuration).
445
+
446
+ In a setup with more than 2 physical CPU ports, it is therefore possible to mix
447
+ static user to CPU port assignment with LAG between DSA masters. It is not
448
+ possible to statically assign a user port towards a DSA master that has any
449
+ upper interfaces (this includes LAG devices - the master must always be the LAG
450
+ in this case).
451
+
452
+ Live changing of the DSA master (and thus CPU port) affinity of a user port is
453
+ permitted, in order to allow dynamic redistribution in response to traffic.
454
+
455
+ Physical DSA masters are allowed to join and leave at any time a LAG interface
456
+ used as a DSA master; however, DSA will reject a LAG interface as a valid
457
+ candidate for being a DSA master unless it has at least one physical DSA master
458
+ as a slave device.
0 commit comments