Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: add ds and index to dsa_port

Add the physical switch instance and port index a DSA port belongs to to
the dsa_port structure.

That can be used later to retrieve information about a physical port
when configuring a switch fabric, or lighten up struct dsa_slave_priv.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vivien Didelot and committed by
David S. Miller
818be848 26895e29

+8
+2
include/net/dsa.h
··· 140 140 }; 141 141 142 142 struct dsa_port { 143 + struct dsa_switch *ds; 144 + unsigned int index; 143 145 struct net_device *netdev; 144 146 struct device_node *dn; 145 147 unsigned int ageing_time;
+6
net/dsa/dsa2.c
··· 670 670 { 671 671 size_t size = sizeof(struct dsa_switch) + n * sizeof(struct dsa_port); 672 672 struct dsa_switch *ds; 673 + int i; 673 674 674 675 ds = devm_kzalloc(dev, size, GFP_KERNEL); 675 676 if (!ds) ··· 678 677 679 678 ds->dev = dev; 680 679 ds->num_ports = n; 680 + 681 + for (i = 0; i < ds->num_ports; ++i) { 682 + ds->ports[i].index = i; 683 + ds->ports[i].ds = ds; 684 + } 681 685 682 686 return ds; 683 687 }