netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>,
	andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net,
	jakub.kicinski@netronome.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/3] net: dsa: sja1105: Implement the port MTU callbacks
Date: Sat, 23 Nov 2019 12:30:13 -0800	[thread overview]
Message-ID: <6bb2b2cb-361f-69bc-0299-26abcb09882f@gmail.com> (raw)
In-Reply-To: <20191123194844.9508-3-olteanv@gmail.com>



On 11/23/2019 11:48 AM, Vladimir Oltean wrote:
> On this switch, the frame length enforcements are performed by the
> ingress policers. There are 2 types of those: regular L2 (also called
> best-effort) and Virtual Link policers (an ARINC664/AFDX concept for
> defining L2 streams with certain QoS abilities). To avoid future
> confusion, I prefer to call the reset reason "Best-effort policers",
> even though the VL policers are not yet supported.
> 
> We also need to change the setup of the initial static config, such that
> DSA calls to .change_mtu (which are expensive) become no-ops and don't
> reset the switch 5 times.
> 
> A driver-level decision is to unconditionally allow single VLAN-tagged
> traffic on all ports. The CPU port must accept an additional VLAN header
> for the DSA tag, which is again a driver-level decision.
> 
> The policers actually count bytes not only from the SDU, but also from
> the Ethernet header and FCS, so those need to be accounted for as well.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> ---
>  drivers/net/dsa/sja1105/sja1105.h      |  1 +
>  drivers/net/dsa/sja1105/sja1105_main.c | 48 +++++++++++++++++++++++---
>  2 files changed, 45 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
> index d801fc204d19..3a5c8acb6e2a 100644
> --- a/drivers/net/dsa/sja1105/sja1105.h
> +++ b/drivers/net/dsa/sja1105/sja1105.h
> @@ -122,6 +122,7 @@ enum sja1105_reset_reason {
>  	SJA1105_RX_HWTSTAMPING,
>  	SJA1105_AGEING_TIME,
>  	SJA1105_SCHEDULING,
> +	SJA1105_BEST_EFFORT_POLICING,
>  };
>  
>  int sja1105_static_config_reload(struct sja1105_private *priv,
> diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
> index b60224c55244..3d55dd3c7e83 100644
> --- a/drivers/net/dsa/sja1105/sja1105_main.c
> +++ b/drivers/net/dsa/sja1105/sja1105_main.c
> @@ -459,12 +459,12 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
>  #define SJA1105_RATE_MBPS(speed) (((speed) * 64000) / 1000)
>  
>  static void sja1105_setup_policer(struct sja1105_l2_policing_entry *policing,
> -				  int index)
> +				  int index, int mtu)
>  {
>  	policing[index].sharindx = index;
>  	policing[index].smax = 65535; /* Burst size in bytes */
>  	policing[index].rate = SJA1105_RATE_MBPS(1000);
> -	policing[index].maxlen = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
> +	policing[index].maxlen = mtu;
>  	policing[index].partition = 0;
>  }
>  
> @@ -496,12 +496,16 @@ static int sja1105_init_l2_policing(struct sja1105_private *priv)
>  	 */
>  	for (i = 0, k = 0; i < SJA1105_NUM_PORTS; i++) {
>  		int bcast = (SJA1105_NUM_PORTS * SJA1105_NUM_TC) + i;
> +		int mtu = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
> +
> +		if (dsa_is_cpu_port(priv->ds, i))
> +			mtu += VLAN_HLEN;

That really seems like a layering violation it so happens that you use
DSA_TAG_8021Q which is why you need VLAN_ETH_HLEN, but you should not
assume that from with your driver, even if this one is special on so
many counts. How about using use dsa_port(port)->tag_ops->overhead +
ETH_HLEN here?
>  
>  		for (j = 0; j < SJA1105_NUM_TC; j++, k++)
> -			sja1105_setup_policer(policing, k);
> +			sja1105_setup_policer(policing, k, mtu);
>  
>  		/* Set up this port's policer for broadcast traffic */
> -		sja1105_setup_policer(policing, bcast);
> +		sja1105_setup_policer(policing, bcast, mtu);
>  	}
>  	return 0;
>  }
> @@ -1346,6 +1350,7 @@ static const char * const sja1105_reset_reasons[] = {
>  	[SJA1105_RX_HWTSTAMPING] = "RX timestamping",
>  	[SJA1105_AGEING_TIME] = "Ageing time",
>  	[SJA1105_SCHEDULING] = "Time-aware scheduling",
> +	[SJA1105_BEST_EFFORT_POLICING] = "Best-effort policing",
>  };
>  
>  /* For situations where we need to change a setting at runtime that is only
> @@ -1886,6 +1891,39 @@ static int sja1105_set_ageing_time(struct dsa_switch *ds,
>  	return sja1105_static_config_reload(priv, SJA1105_AGEING_TIME);
>  }
>  
> +static int sja1105_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> +{
> +	int bcast = (SJA1105_NUM_PORTS * SJA1105_NUM_TC) + port;
> +	struct sja1105_l2_policing_entry *policing;
> +	struct sja1105_private *priv = ds->priv;
> +	int tc;
> +
> +	new_mtu += VLAN_ETH_HLEN + ETH_FCS_LEN;

Likewise
-- 
Florian

  reply	other threads:[~2019-11-23 20:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 19:48 [PATCH net-next 0/3] Configure the MTU on DSA switches Vladimir Oltean
2019-11-23 19:48 ` [PATCH net-next 1/3] net: dsa: Configure the MTU for switch ports Vladimir Oltean
2019-11-23 20:27   ` Florian Fainelli
2019-11-23 20:46     ` Vladimir Oltean
2019-11-23 21:14       ` Florian Fainelli
2019-11-23 21:29         ` Vladimir Oltean
2019-11-23 21:47           ` Florian Fainelli
2019-11-23 21:54             ` Vladimir Oltean
2019-11-24 22:43       ` Andrew Lunn
2019-11-23 20:51     ` Vladimir Oltean
2019-11-23 21:09       ` Florian Fainelli
2019-11-24 22:48   ` Andrew Lunn
2019-11-23 19:48 ` [PATCH net-next 2/3] net: dsa: sja1105: Implement the port MTU callbacks Vladimir Oltean
2019-11-23 20:30   ` Florian Fainelli [this message]
2019-11-23 20:48     ` Vladimir Oltean
2019-11-23 19:48 ` [PATCH net-next 3/3] net: dsa: vsc73xx: Make the MTU configurable Vladimir Oltean

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=6bb2b2cb-361f-69bc-0299-26abcb09882f@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).