netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com,
	vivien.didelot@gmail.com, horatiu.vultur@microchip.com,
	joergen.andreasen@microchip.com, allan.nielsen@microchip.com,
	alexandru.marginean@nxp.com, claudiu.manoil@nxp.com,
	netdev@vger.kernel.org, UNGLinuxDriver@microchip.com
Subject: Re: [RFC PATCH net-next 01/14] net: mscc: ocelot: introduce a new ocelot_target_{read,write} API
Date: Fri, 25 Sep 2020 15:51:21 +0200	[thread overview]
Message-ID: <20200925135121.GA9675@piout.net> (raw)
In-Reply-To: <20200925121855.370863-2-vladimir.oltean@nxp.com>

On 25/09/2020 15:18:42+0300, Vladimir Oltean wrote:
> There are some targets (register blocks) in the Ocelot switch that are
> instantiated more than once. For example, the VCAP IS1, IS2 and ES0
> blocks all share the same register layout for interacting with the cache
> for the TCAM and the action RAM.
> 
> For the VCAPs, the procedure for servicing them is actually common. We
> just need an API specifying which VCAP we are talking to, and we do that
> via these raw ocelot_target_read and ocelot_target_write accessors.
> 
> In plain ocelot_read, the target is encoded into the register enum
> itself:
> 
> 	u16 target = reg >> TARGET_OFFSET;
> 
> For the VCAPs, the registers are currently defined like this:
> 
> 	enum ocelot_reg {
> 	[...]
> 		S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET,
> 		S2_CORE_MV_CFG,
> 		S2_CACHE_ENTRY_DAT,
> 		S2_CACHE_MASK_DAT,
> 		S2_CACHE_ACTION_DAT,
> 		S2_CACHE_CNT_DAT,
> 		S2_CACHE_TG_DAT,
> 	[...]
> 	};
> 
> which is precisely what we want to avoid, because we'd have to duplicate
> the same register map for S1 and for S0, and then figure out how to pass
> VCAP instance-specific registers to the ocelot_read calls (basically
> another lookup table that undoes the effect of shifting with
> TARGET_OFFSET).
> 
> So for some targets, propose a more raw API, similar to what is
> currently done with ocelot_port_readl and ocelot_port_writel. Those
> targets can only be accessed with ocelot_target_{read,write} and not
> with ocelot_{read,write} after the conversion, which is fine.
> 
> The VCAP registers are not actually modified to use this new API as of
> this patch. They will be modified in the next one.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/net/ethernet/mscc/ocelot_io.c | 17 +++++++++++++++++
>  include/soc/mscc/ocelot.h             | 14 ++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mscc/ocelot_io.c b/drivers/net/ethernet/mscc/ocelot_io.c
> index d22711282183..0acb45948418 100644
> --- a/drivers/net/ethernet/mscc/ocelot_io.c
> +++ b/drivers/net/ethernet/mscc/ocelot_io.c
> @@ -71,6 +71,23 @@ void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg)
>  }
>  EXPORT_SYMBOL(ocelot_port_writel);
>  
> +u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
> +			    u32 reg, u32 offset)
> +{
> +	u32 val;
> +
> +	regmap_read(ocelot->targets[target],
> +		    ocelot->map[target][reg] + offset, &val);
> +	return val;
> +}
> +
> +void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
> +			      u32 val, u32 reg, u32 offset)
> +{
> +	regmap_write(ocelot->targets[target],
> +		     ocelot->map[target][reg] + offset, val);
> +}
> +
>  int ocelot_regfields_init(struct ocelot *ocelot,
>  			  const struct reg_field *const regfields)
>  {
> diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
> index 7e52e6ee09d8..a71ea217da70 100644
> --- a/include/soc/mscc/ocelot.h
> +++ b/include/soc/mscc/ocelot.h
> @@ -662,6 +662,16 @@ struct ocelot_policer {
>  #define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
>  #define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
>  
> +#define ocelot_target_read_ix(ocelot, target, reg, gi, ri) __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
> +#define ocelot_target_read_gix(ocelot, target, reg, gi) __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi))
> +#define ocelot_target_read_rix(ocelot, target, reg, ri) __ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri))
> +#define ocelot_target_read(ocelot, target, reg) __ocelot_target_read_ix(ocelot, target, reg, 0)
> +
> +#define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
> +#define ocelot_target_write_gix(ocelot, target, val, reg, gi) __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi))
> +#define ocelot_target_write_rix(ocelot, target, val, reg, ri) __ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri))
> +#define ocelot_target_write(ocelot, target, val, reg) __ocelot_target_write_ix(ocelot, target, val, reg, 0)
> +
>  /* I/O */
>  u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
>  void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
> @@ -669,6 +679,10 @@ u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
>  void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
>  void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
>  		     u32 offset);
> +u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
> +			    u32 reg, u32 offset);
> +void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
> +			      u32 val, u32 reg, u32 offset);
>  
>  /* Hardware initialization */
>  int ocelot_regfields_init(struct ocelot *ocelot,
> -- 
> 2.25.1
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2020-09-25 13:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 12:18 [RFC PATCH net-next 00/14] Offload tc-flower using VCAP chains Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 01/14] net: mscc: ocelot: introduce a new ocelot_target_{read,write} API Vladimir Oltean
2020-09-25 13:51   ` Alexandre Belloni [this message]
2020-09-25 12:18 ` [RFC PATCH net-next 02/14] net: mscc: ocelot: generalize existing code for VCAP Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 03/14] net: mscc: ocelot: offload multiple tc-flower actions in same rule Vladimir Oltean
2020-09-26 11:50   ` Horatiu Vultur
2020-09-25 12:18 ` [RFC PATCH net-next 04/14] net: mscc: ocelot: change vcap to be compatible with full and quad entry Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 05/14] net: mscc: ocelot: add a new ocelot_vcap_block_find_filter_by_id function Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 06/14] net: mscc: ocelot: look up the filters in flower_stats() and flower_destroy() Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 07/14] net: mscc: ocelot: introduce conversion helpers between port and netdev Vladimir Oltean
2020-09-25 13:53   ` Alexandre Belloni
2020-09-25 12:18 ` [RFC PATCH net-next 08/14] net: mscc: ocelot: create TCAM skeleton from tc filter chains Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 09/14] net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 10/14] net: mscc: ocelot: offload egress VLAN rewriting to VCAP ES0 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 11/14] net: mscc: ocelot: only install TCAM entries into a specific lookup and PAG Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 12/14] net: mscc: ocelot: relax ocelot_exclusive_mac_etype_filter_rules() Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 13/14] net: mscc: ocelot: offload redirect action to VCAP IS2 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 14/14] selftests: ocelot: add some example VCAP IS1, IS2 and ES0 tc offloads 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=20200925135121.GA9675@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joergen.andreasen@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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).