2024-03-28 16:07:49

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v1 8/9] net: dsa: microchip: init predictable IPV to queue mapping for all non KSZ8xxx variants

Init priority to queue mapping in the way as it shown in IEEE 802.1Q
mapping example.

Signed-off-by: Oleksij Rempel <[email protected]>
---
drivers/net/dsa/microchip/ksz_common.c | 53 ++++++++++++++------------
1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 08426f85f7707..78e9610044ea8 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -24,6 +24,7 @@
#include <linux/of_net.h>
#include <linux/micrel_phy.h>
#include <net/dsa.h>
+#include <net/ieee8021q.h>
#include <net/pkt_cls.h>
#include <net/switchdev.h>

@@ -2692,9 +2693,29 @@ static int ksz_port_mdb_del(struct dsa_switch *ds, int port,
return dev->dev_ops->mdb_del(dev, port, mdb, db);
}

+static int ksz_set_default_prio_queue_mapping(struct ksz_device *dev, int port)
+{
+ u32 queue_map = 0;
+ int ipv;
+
+ for (ipv = 0; ipv < dev->info->max_ipvs; ipv++) {
+ int queue;
+
+ /* Traffic Type (TT) is corresponding to the Internal Priority
+ * Value (IPV) in the switch. Traffic Class (TC) is
+ * corresponding to the queue in the switch.
+ */
+ queue = ieee8021q_tt_to_tc(ipv, dev->info->num_tx_queues);
+ queue_map |= queue << (ipv * KSZ9477_PORT_TC_MAP_S);
+ }
+
+ return ksz_pwrite32(dev, port, KSZ9477_PORT_MRI_TC_MAP__4, queue_map);
+}
+
static int ksz_port_setup(struct dsa_switch *ds, int port)
{
struct ksz_device *dev = ds->priv;
+ int ret;

if (!dsa_is_user_port(ds, port))
return 0;
@@ -2702,6 +2723,12 @@ static int ksz_port_setup(struct dsa_switch *ds, int port)
/* setup user port */
dev->dev_ops->port_setup(dev, port, false);

+ if (!is_ksz8(dev)) {
+ ret = ksz_set_default_prio_queue_mapping(dev, port);
+ if (ret)
+ return ret;
+ }
+
/* port_stp_state_set() will be called after to enable the port so
* there is no need to do anything.
*/
@@ -3566,8 +3593,7 @@ static int ksz_tc_ets_add(struct ksz_device *dev, int port,

static int ksz_tc_ets_del(struct ksz_device *dev, int port)
{
- int ret, queue, tc_prio, s;
- u32 queue_map = 0;
+ int ret, queue;

/* To restore the default chip configuration, set all queues to use the
* WRR scheduler with a weight of 1.
@@ -3579,31 +3605,10 @@ static int ksz_tc_ets_del(struct ksz_device *dev, int port)
return ret;
}

- switch (dev->info->num_tx_queues) {
- case 2:
- s = 2;
- break;
- case 4:
- s = 1;
- break;
- case 8:
- s = 0;
- break;
- default:
- return -EINVAL;
- }
-
/* Revert the queue mapping for TC-priority to its default setting on
* the chip.
*/
- for (tc_prio = 0; tc_prio < dev->info->max_ipvs; tc_prio++) {
- int queue;
-
- queue = tc_prio >> s;
- queue_map |= queue << (tc_prio * KSZ9477_PORT_TC_MAP_S);
- }
-
- return ksz_pwrite32(dev, port, KSZ9477_PORT_MRI_TC_MAP__4, queue_map);
+ return ksz_set_default_prio_queue_mapping(dev, port);
}

static int ksz_tc_ets_validate(struct ksz_device *dev, int port,
--
2.39.2



2024-04-02 04:08:02

by Arun Ramadoss

[permalink] [raw]
Subject: Re: [PATCH net-next v1 8/9] net: dsa: microchip: init predictable IPV to queue mapping for all non KSZ8xxx variants

Hi Oleksij,

On Thu, 2024-03-28 at 17:05 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Init priority to queue mapping in the way as it shown in IEEE 802.1Q
> mapping example.
>
> Signed-off-by: Oleksij Rempel <[email protected]>
> ---
> drivers/net/dsa/microchip/ksz_common.c | 53 ++++++++++++++--------
> ----
> 1 file changed, 29 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz_common.c
> b/drivers/net/dsa/microchip/ksz_common.c
> index 08426f85f7707..78e9610044ea8 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -24,6 +24,7 @@
> #include <linux/of_net.h>
> #include <linux/micrel_phy.h>
> #include <net/dsa.h>
> +#include <net/ieee8021q.h>
> #include <net/pkt_cls.h>
> #include <net/switchdev.h>
>
> @@ -2692,9 +2693,29 @@ static int ksz_port_mdb_del(struct dsa_switch
> *ds, int port,
> return dev->dev_ops->mdb_del(dev, port, mdb, db);
> }
>
> +static int ksz_set_default_prio_queue_mapping(struct ksz_device
> *dev, int port)

Since this function is related to KSZ9477 series switch, do we need to
move this function out of ksz_common.c or function name prefixed with
ksz9477_set_default_prio_queue_mapping to differentiate it.

2024-04-02 07:10:12

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH net-next v1 8/9] net: dsa: microchip: init predictable IPV to queue mapping for all non KSZ8xxx variants

Hi Arun,

On Tue, Apr 02, 2024 at 04:07:30AM +0000, [email protected] wrote:
> Hi Oleksij,
>
> On Thu, 2024-03-28 at 17:05 +0100, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> >
> > Init priority to queue mapping in the way as it shown in IEEE 802.1Q
> > mapping example.
> >
> > Signed-off-by: Oleksij Rempel <[email protected]>
> > ---
> > drivers/net/dsa/microchip/ksz_common.c | 53 ++++++++++++++--------
> > ----
> > 1 file changed, 29 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz_common.c
> > b/drivers/net/dsa/microchip/ksz_common.c
> > index 08426f85f7707..78e9610044ea8 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.c
> > +++ b/drivers/net/dsa/microchip/ksz_common.c
> > @@ -24,6 +24,7 @@
> > #include <linux/of_net.h>
> > #include <linux/micrel_phy.h>
> > #include <net/dsa.h>
> > +#include <net/ieee8021q.h>
> > #include <net/pkt_cls.h>
> > #include <net/switchdev.h>
> >
> > @@ -2692,9 +2693,29 @@ static int ksz_port_mdb_del(struct dsa_switch
> > *ds, int port,
> > return dev->dev_ops->mdb_del(dev, port, mdb, db);
> > }
> >
> > +static int ksz_set_default_prio_queue_mapping(struct ksz_device
> > *dev, int port)
>
> Since this function is related to KSZ9477 series switch, do we need to
> move this function out of ksz_common.c or function name prefixed with
> ksz9477_set_default_prio_queue_mapping to differentiate it.

Ack. Sounds good, will update it.

Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |