All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next 5/9] net: dsa: mv88e6xxx: rework in-chip bridging
Date: Thu, 30 Mar 2017 15:57:30 +0200	[thread overview]
Message-ID: <20170330135730.GE17879@lunn.ch> (raw)
In-Reply-To: <20170329203020.27042-6-vivien.didelot@savoirfairelinux.com>

On Wed, Mar 29, 2017 at 04:30:16PM -0400, Vivien Didelot wrote:
> All ports -- internal and external, for chips featuring a PVT -- have a
> mask restricting to which internal ports a frame is allowed to egress.
> 
> Now that DSA exposes the number of ports and their bridge devices, it is
> possible to extract the code generating the VLAN map and make it generic
> so that it can be shared later with the cross-chip bridging code.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

> +static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
> +{
> +	struct dsa_switch *ds = NULL;
> +	struct net_device *br;
> +	u16 pvlan;
> +	int i;
> +
> +	if (dev < DSA_MAX_SWITCHES)
> +		ds = chip->ds->dst->ds[dev];
> +
> +	/* Prevent frames from unknown switch or port */
> +	if (!ds || port >= ds->num_ports)
> +		return 0;
> +
> +	/* Frames from DSA links and CPU ports can egress any local port */
> +	if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
> +		return mv88e6xxx_port_mask(chip);
> +
> +	br = ds->ports[port].bridge_dev;
> +	pvlan = 0;

You could do this where you define the variable, but having it here,
close to where it is used also has its merits.

> +
> +	/* Frames from user ports can egress any local DSA links and CPU ports,
> +	 * as well as any local member of their bridge group.
> +	 */
> +	for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
> +		if (dsa_is_cpu_port(chip->ds, i) ||
> +		    dsa_is_dsa_port(chip->ds, i) ||
> +		    (br && chip->ds->ports[i].bridge_dev == br))
> +			pvlan |= BIT(i);
> +
> +	return pvlan;

  Andrew

  reply	other threads:[~2017-03-30 13:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 20:30 [PATCH net-next 0/9] net: dsa: mv88e6xxx: program cross-chip bridging Vivien Didelot
2017-03-29 20:30 ` [PATCH net-next 1/9] net: dsa: mv88e6xxx: move PVT description in info Vivien Didelot
2017-03-30 13:31   ` Andrew Lunn
2017-03-29 20:30 ` [PATCH net-next 2/9] net: dsa: mv88e6xxx: use 4-bit port for PVT data Vivien Didelot
2017-03-30 13:34   ` Andrew Lunn
2017-03-29 20:30 ` [PATCH net-next 3/9] net: dsa: mv88e6xxx: program the PVT with all ones Vivien Didelot
2017-03-30 13:45   ` Andrew Lunn
2017-03-30 14:16     ` Vivien Didelot
2017-03-29 20:30 ` [PATCH net-next 4/9] net: dsa: mv88e6xxx: allocate the number of ports Vivien Didelot
2017-03-30 13:50   ` Andrew Lunn
2017-03-30 14:06     ` Vivien Didelot
2017-03-29 20:30 ` [PATCH net-next 5/9] net: dsa: mv88e6xxx: rework in-chip bridging Vivien Didelot
2017-03-30 13:57   ` Andrew Lunn [this message]
2017-03-29 20:30 ` [PATCH net-next 6/9] net: dsa: mv88e6xxx: factorize in-chip bridge map Vivien Didelot
2017-03-30 14:04   ` Andrew Lunn
2017-03-29 20:30 ` [PATCH net-next 7/9] net: dsa: mv88e6xxx: remap existing bridge members Vivien Didelot
2017-03-30 14:07   ` Andrew Lunn
2017-03-29 20:30 ` [PATCH net-next 8/9] net: dsa: add cross-chip bridging operations Vivien Didelot
2017-03-29 20:30 ` [PATCH net-next 9/9] net: dsa: mv88e6xxx: add cross-chip bridging Vivien Didelot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170330135730.GE17879@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.