From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
xiaoliang.yang_1@nxp.com, po.liu@nxp.com, claudiu.manoil@nxp.com,
alexandru.marginean@nxp.com, vladimir.oltean@nxp.com,
leoyang.li@nxp.com, mingkai.hu@nxp.com, andrew@lunn.ch,
f.fainelli@gmail.com, vivien.didelot@gmail.com,
davem@davemloft.net, jiri@resnulli.us, idosch@idosch.org,
kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, horatiu.vultur@microchip.com,
alexandre.belloni@bootlin.com, allan.nielsen@microchip.com,
joergen.andreasen@microchip.com, UNGLinuxDriver@microchip.com,
nikolay@cumulusnetworks.com, roopa@cumulusnetworks.com,
linux-devel@linux.nxdi.nxp.com
Subject: Re: [PATCH v1 net-next 3/3] net: dsa: felix: add support Credit Based Shaper(CBS) for hardware offload
Date: Mon, 11 May 2020 18:41:49 -0700 [thread overview]
Message-ID: <873686rkte.fsf@intel.com> (raw)
In-Reply-To: <20200511054332.37690-4-xiaoliang.yang_1@nxp.com>
Xiaoliang Yang <xiaoliang.yang_1@nxp.com> writes:
> VSC9959 hardware support the Credit Based Shaper(CBS) which part
> of the IEEE-802.1Qav. This patch support sch_cbs set for VSC9959.
>
> Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
> ---
> drivers/net/dsa/ocelot/felix_vsc9959.c | 52 +++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index ccbd875c7a47..d8d1657ee8ba 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -208,7 +208,7 @@ static const u32 vsc9959_qsys_regmap[] = {
> REG(QSYS_QMAXSDU_CFG_6, 0x00f62c),
> REG(QSYS_QMAXSDU_CFG_7, 0x00f648),
> REG(QSYS_PREEMPTION_CFG, 0x00f664),
> - REG_RESERVED(QSYS_CIR_CFG),
> + REG(QSYS_CIR_CFG, 0x000000),
> REG(QSYS_EIR_CFG, 0x000004),
> REG(QSYS_SE_CFG, 0x000008),
> REG(QSYS_SE_DWRR_CFG, 0x00000c),
> @@ -1354,6 +1354,54 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,
> return ret;
> }
>
> +int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port,
> + struct tc_cbs_qopt_offload *cbs_qopt)
> +{
> + struct ocelot *ocelot = ds->priv;
> + int port_ix = port * 8 + cbs_qopt->queue;
> + u32 cbs = 0;
> + u32 cir = 0;
> +
> + if (cbs_qopt->queue >= ds->num_tx_queues)
> + return -EINVAL;
> +
> + if (!cbs_qopt->enable) {
> + ocelot_write_gix(ocelot, QSYS_CIR_CFG_CIR_RATE(0) |
> + QSYS_CIR_CFG_CIR_BURST(0),
> + QSYS_CIR_CFG, port_ix);
> +
> + ocelot_rmw_gix(ocelot, 0, QSYS_SE_CFG_SE_AVB_ENA,
> + QSYS_SE_CFG, port_ix);
> +
> + return 0;
> + }
> +
> + /* Rate unit is 100 kbps */
> + cir = DIV_ROUND_UP(cbs_qopt->idleslope, 100);
> + cir = (cir ? cir : 1);
> + cir = min_t(u32, GENMASK(14, 0), cir);
Please rename 'cir' to "rate" or "idleslope".
Also consider using clamp_t here and below (I just found out about it).
> + /* Burst unit is 4kB */
> + cbs = DIV_ROUND_UP(cbs_qopt->hicredit, 4096);
> + /* Avoid using zero burst size */
> + cbs = (cbs ? cbs : 1);
> + cbs = min_t(u32, GENMASK(5, 0), cbs);
And please(!) rename 'cbs' to "burst" or "hicredit". Re-using the name
"cbs" with a completely different meaning here is confusing.
> + ocelot_write_gix(ocelot,
> + QSYS_CIR_CFG_CIR_RATE(cir) |
> + QSYS_CIR_CFG_CIR_BURST(cbs),
> + QSYS_CIR_CFG,
> + port_ix);
> +
> + ocelot_rmw_gix(ocelot,
> + QSYS_SE_CFG_SE_FRM_MODE(0) |
> + QSYS_SE_CFG_SE_AVB_ENA,
> + QSYS_SE_CFG_SE_AVB_ENA |
> + QSYS_SE_CFG_SE_FRM_MODE_M,
> + QSYS_SE_CFG,
> + port_ix);
> +
> + return 0;
> +}
> +
> static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port,
> enum tc_setup_type type,
> void *type_data)
> @@ -1363,6 +1411,8 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port,
> switch (type) {
> case TC_SETUP_QDISC_TAPRIO:
> return vsc9959_qos_port_tas_set(ocelot, port, type_data);
> + case TC_SETUP_QDISC_CBS:
> + return vsc9959_qos_port_cbs_set(ds, port, type_data);
> default:
> return -EOPNOTSUPP;
> }
> --
> 2.17.1
>
--
Vinicius
next prev parent reply other threads:[~2020-05-12 1:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 5:43 [PATCH v1 net-next 0/3] net: dsa: felix: tc taprio and CBS offload support Xiaoliang Yang
2020-05-11 5:43 ` [PATCH v1 net-next 1/3] net: dsa: felix: qos classified based on pcp Xiaoliang Yang
2020-05-11 8:19 ` Vladimir Oltean
2020-05-12 6:21 ` [EXT] " Xiaoliang Yang
2020-05-11 5:43 ` [PATCH v1 net-next 2/3] net: dsa: felix: Configure Time-Aware Scheduler via taprio offload Xiaoliang Yang
2020-05-11 23:52 ` David Miller
2020-05-12 0:10 ` Vladimir Oltean
2020-05-11 5:43 ` [PATCH v1 net-next 3/3] net: dsa: felix: add support Credit Based Shaper(CBS) for hardware offload Xiaoliang Yang
2020-05-11 22:34 ` Jakub Kicinski
2020-05-12 6:27 ` [EXT] " Xiaoliang Yang
2020-05-12 1:41 ` Vinicius Costa Gomes [this message]
2020-05-12 9:17 ` Xiaoliang Yang
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=873686rkte.fsf@intel.com \
--to=vinicius.gomes@intel.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.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=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=joergen.andreasen@microchip.com \
--cc=kuba@kernel.org \
--cc=leoyang.li@nxp.com \
--cc=linux-devel@linux.nxdi.nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingkai.hu@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=po.liu@nxp.com \
--cc=roopa@cumulusnetworks.com \
--cc=vivien.didelot@gmail.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoliang.yang_1@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).