mbox series

[net-next,v2,00/16] net: dsa: turn arrays of ports into a list

Message ID 20191021205130.304149-1-vivien.didelot@gmail.com
Headers show
Series net: dsa: turn arrays of ports into a list | expand

Message

Vivien Didelot Oct. 21, 2019, 8:51 p.m. UTC
The dsa_switch structure represents the physical switch device itself,
and is allocated by the driver. The dsa_switch_tree and dsa_port structures
represent the logical switch fabric (eventually composed of multiple switch
devices) and its ports, and are allocated by the DSA core.

This branch lists the logical ports directly in the fabric which simplifies
the iteration over all ports when assigning the default CPU port or configuring
the D in DSA in drivers like mv88e6xxx.

This also removes the unique dst->cpu_dp pointer and is a first step towards
supporting multiple CPU ports and dropping the DSA_MAX_PORTS limitation.

Because the dsa_port structures are not tight to the dsa_switch structure
anymore, we do not need to provide an helper for the drivers to allocate a
switch structure. Like in many other subsystems, drivers can now embed their
dsa_switch structure as they wish into their private structure. This will
be particularly interesting for the Broadcom drivers which were currently
limited by the dynamically allocated array of DSA ports.

The series implements the list of dsa_port structures, makes use of it,
then drops dst->cpu_dp and the dsa_switch_alloc helper.

Changes in v2:
  - use list_add_tail instead of list_add to respect ports order
  - use a single return statement for dsa_to_port
  - remove pr_info messages
  - put comments under appropriate branches
  - add Git tags from reviewers


Vivien Didelot (16):
  net: dsa: use dsa_to_port helper everywhere
  net: dsa: add ports list in the switch fabric
  net: dsa: use ports list in dsa_to_port
  net: dsa: use ports list to find slave
  net: dsa: use ports list to setup switches
  net: dsa: use ports list for routing table setup
  net: dsa: use ports list to find a port by node
  net: dsa: use ports list to setup multiple master devices
  net: dsa: use ports list to find first CPU port
  net: dsa: use ports list to setup default CPU port
  net: dsa: mv88e6xxx: silently skip PVT ops
  net: dsa: mv88e6xxx: use ports list to map port VLAN
  net: dsa: mv88e6xxx: use ports list to map bridge
  net: dsa: sja1105: register switch before assigning port private data
  net: dsa: allocate ports on touch
  net: dsa: remove dsa_switch_alloc helper

 drivers/net/dsa/b53/b53_common.c       |  11 +-
 drivers/net/dsa/bcm_sf2.c              |   8 +-
 drivers/net/dsa/bcm_sf2_cfp.c          |   6 +-
 drivers/net/dsa/dsa_loop.c             |   5 +-
 drivers/net/dsa/lan9303-core.c         |   4 +-
 drivers/net/dsa/lantiq_gswip.c         |   4 +-
 drivers/net/dsa/microchip/ksz_common.c |   5 +-
 drivers/net/dsa/mt7530.c               |  17 +-
 drivers/net/dsa/mv88e6060.c            |   4 +-
 drivers/net/dsa/mv88e6xxx/chip.c       |  90 ++++----
 drivers/net/dsa/qca8k.c                |   7 +-
 drivers/net/dsa/realtek-smi-core.c     |   5 +-
 drivers/net/dsa/sja1105/sja1105_main.c |  37 ++--
 drivers/net/dsa/vitesse-vsc73xx-core.c |   5 +-
 include/net/dsa.h                      |  26 ++-
 net/dsa/dsa.c                          |   8 +-
 net/dsa/dsa2.c                         | 274 +++++++++++++------------
 net/dsa/dsa_priv.h                     |  23 +--
 net/dsa/switch.c                       |   4 +-
 net/dsa/tag_8021q.c                    |   6 +-
 20 files changed, 292 insertions(+), 257 deletions(-)

Comments

Florian Fainelli Oct. 21, 2019, 10:34 p.m. UTC | #1
On 10/21/19 1:51 PM, Vivien Didelot wrote:
> The dsa_switch structure represents the physical switch device itself,
> and is allocated by the driver. The dsa_switch_tree and dsa_port structures
> represent the logical switch fabric (eventually composed of multiple switch
> devices) and its ports, and are allocated by the DSA core.
> 
> This branch lists the logical ports directly in the fabric which simplifies
> the iteration over all ports when assigning the default CPU port or configuring
> the D in DSA in drivers like mv88e6xxx.
> 
> This also removes the unique dst->cpu_dp pointer and is a first step towards
> supporting multiple CPU ports and dropping the DSA_MAX_PORTS limitation.
> 
> Because the dsa_port structures are not tight to the dsa_switch structure
> anymore, we do not need to provide an helper for the drivers to allocate a
> switch structure. Like in many other subsystems, drivers can now embed their
> dsa_switch structure as they wish into their private structure. This will
> be particularly interesting for the Broadcom drivers which were currently
> limited by the dynamically allocated array of DSA ports.
> 
> The series implements the list of dsa_port structures, makes use of it,
> then drops dst->cpu_dp and the dsa_switch_alloc helper.

For the entire series:

Tested-by: Florian Fainelli <f.fainelli@gmail.com>

On a BCM7278 with two CPU ports (one at 5, one at 8), and things are
working as they used to before your patch series, thanks!
Michal Vokáč Oct. 22, 2019, 11:43 a.m. UTC | #2
On 21. 10. 19 22:51, Vivien Didelot wrote:
> The dsa_switch structure represents the physical switch device itself,
> and is allocated by the driver. The dsa_switch_tree and dsa_port structures
> represent the logical switch fabric (eventually composed of multiple switch
> devices) and its ports, and are allocated by the DSA core.
> 
> This branch lists the logical ports directly in the fabric which simplifies
> the iteration over all ports when assigning the default CPU port or configuring
> the D in DSA in drivers like mv88e6xxx.
> 
> This also removes the unique dst->cpu_dp pointer and is a first step towards
> supporting multiple CPU ports and dropping the DSA_MAX_PORTS limitation.
> 
> Because the dsa_port structures are not tight to the dsa_switch structure
> anymore, we do not need to provide an helper for the drivers to allocate a
> switch structure. Like in many other subsystems, drivers can now embed their
> dsa_switch structure as they wish into their private structure. This will
> be particularly interesting for the Broadcom drivers which were currently
> limited by the dynamically allocated array of DSA ports.
> 
> The series implements the list of dsa_port structures, makes use of it,
> then drops dst->cpu_dp and the dsa_switch_alloc helper.

I just tried the whole series on our imx6dl-yapp4-hydra with QCA8334
switch and did not notice any problems as well. Thank you.

Tested-by: Michal Vokáč <michal.vokac@ysoft.com>
Jakub Kicinski Oct. 22, 2019, 7:41 p.m. UTC | #3
On Mon, 21 Oct 2019 16:51:14 -0400, Vivien Didelot wrote:
> The dsa_switch structure represents the physical switch device itself,
> and is allocated by the driver. The dsa_switch_tree and dsa_port structures
> represent the logical switch fabric (eventually composed of multiple switch
> devices) and its ports, and are allocated by the DSA core.
> 
> This branch lists the logical ports directly in the fabric which simplifies
> the iteration over all ports when assigning the default CPU port or configuring
> the D in DSA in drivers like mv88e6xxx.
> 
> This also removes the unique dst->cpu_dp pointer and is a first step towards
> supporting multiple CPU ports and dropping the DSA_MAX_PORTS limitation.
> 
> Because the dsa_port structures are not tight to the dsa_switch structure
> anymore, we do not need to provide an helper for the drivers to allocate a
> switch structure. Like in many other subsystems, drivers can now embed their
> dsa_switch structure as they wish into their private structure. This will
> be particularly interesting for the Broadcom drivers which were currently
> limited by the dynamically allocated array of DSA ports.
> 
> The series implements the list of dsa_port structures, makes use of it,
> then drops dst->cpu_dp and the dsa_switch_alloc helper.

Applied, thanks!