Commit 96b029b0 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller
Browse files

net: mscc: ocelot: introduce macros for iterating over PGIDs



The current iterators are impossible to understand at first glance
without switching back and forth between the definitions and their
actual use in the for loops.

So introduce some convenience names to help readability.

Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 209edf95
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1064,10 +1064,10 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot)
	int i, port, lag;
	int i, port, lag;


	/* Reset destination and aggregation PGIDS */
	/* Reset destination and aggregation PGIDS */
	for (port = 0; port < ocelot->num_phys_ports; port++)
	for_each_unicast_dest_pgid(ocelot, port)
		ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port);
		ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port);


	for (i = PGID_AGGR; i < PGID_SRC; i++)
	for_each_aggr_pgid(ocelot, i)
		ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0),
		ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0),
				 ANA_PGID_PGID, i);
				 ANA_PGID_PGID, i);


@@ -1089,7 +1089,7 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot)
			aggr_count++;
			aggr_count++;
		}
		}


		for (i = PGID_AGGR; i < PGID_SRC; i++) {
		for_each_aggr_pgid(ocelot, i) {
			u32 ac;
			u32 ac;


			ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i);
			ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i);
@@ -1451,7 +1451,7 @@ int ocelot_init(struct ocelot *ocelot)
	}
	}


	/* Allow broadcast MAC frames. */
	/* Allow broadcast MAC frames. */
	for (i = ocelot->num_phys_ports + 1; i < PGID_CPU; i++) {
	for_each_nonreserved_multicast_dest_pgid(ocelot, i) {
		u32 val = ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports - 1, 0));
		u32 val = ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports - 1, 0));


		ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);
		ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);
+1 −1
Original line number Original line Diff line number Diff line
@@ -422,7 +422,7 @@ static void ocelot_set_rx_mode(struct net_device *dev)
	 * forwarded to the CPU port.
	 * forwarded to the CPU port.
	 */
	 */
	val = GENMASK(ocelot->num_phys_ports - 1, 0);
	val = GENMASK(ocelot->num_phys_ports - 1, 0);
	for (i = ocelot->num_phys_ports + 1; i < PGID_CPU; i++)
	for_each_nonreserved_multicast_dest_pgid(ocelot, i)
		ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);
		ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);


	__dev_mc_sync(dev, ocelot_mc_sync, ocelot_mc_unsync);
	__dev_mc_sync(dev, ocelot_mc_sync, ocelot_mc_unsync);
+15 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,21 @@
#define PGID_MCIPV4			62
#define PGID_MCIPV4			62
#define PGID_MCIPV6			63
#define PGID_MCIPV6			63


#define for_each_unicast_dest_pgid(ocelot, pgid)		\
	for ((pgid) = 0;					\
	     (pgid) < (ocelot)->num_phys_ports;			\
	     (pgid)++)

#define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid)	\
	for ((pgid) = (ocelot)->num_phys_ports + 1;		\
	     (pgid) < PGID_CPU;					\
	     (pgid)++)

#define for_each_aggr_pgid(ocelot, pgid)			\
	for ((pgid) = PGID_AGGR;				\
	     (pgid) < PGID_SRC;					\
	     (pgid)++)

/* Aggregation PGIDs, one per Link Aggregation Code */
/* Aggregation PGIDs, one per Link Aggregation Code */
#define PGID_AGGR			64
#define PGID_AGGR			64