Message ID | 20230514201029.1867738-5-horatiu.vultur@microchip.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: lan966x: Add support for PCP, DEI, DSCP | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 8 this patch: 8 |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/build_clang | success | Errors and warnings before: 8 this patch: 8 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 8 this patch: 8 |
netdev/checkpatch | warning | WARNING: line length of 86 exceeds 80 columns |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Sun, May 14, 2023 at 10:10:26PM +0200, Horatiu Vultur wrote: > Add support for offloading dscp app entries. The dscp values are global > for all lan966x ports. > > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> > --- > .../ethernet/microchip/lan966x/lan966x_dcb.c | 61 +++++++++++++++++-- > .../ethernet/microchip/lan966x/lan966x_main.h | 8 +++ > .../ethernet/microchip/lan966x/lan966x_port.c | 26 ++++++++ > 3 files changed, 90 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c > index c149f905fe9e3..2b518181b7f08 100644 > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c > @@ -57,19 +57,62 @@ static void lan966x_dcb_app_update(struct net_device *dev) > qos.pcp.map[i] = dcb_getapp(dev, &app_itr); > } > > + /* Get dscp ingress mapping */ > + for (int i = 0; i < ARRAY_SIZE(qos.dscp.map); i++) { > + app_itr.selector = IEEE_8021QAZ_APP_SEL_DSCP; > + app_itr.protocol = i; > + qos.dscp.map[i] = dcb_getapp(dev, &app_itr); > + } > + > /* Enable use of pcp for queue classification */ > if (lan966x_dcb_apptrust_contains(port->chip_port, DCB_APP_SEL_PCP)) > qos.pcp.enable = true; > > + /* Enable use of dscp for queue classification */ > + if (lan966x_dcb_apptrust_contains(port->chip_port, IEEE_8021QAZ_APP_SEL_DSCP)) > + qos.dscp.enable = true; > + > lan966x_port_qos_set(port, &qos); > } > > +/* DSCP mapping is global for all ports, so set and delete app entries are > + * replicated for each port. > + */ > +static int lan966x_dcb_ieee_dscp_setdel(struct net_device *dev, > + struct dcb_app *app, > + int (*setdel)(struct net_device *, > + struct dcb_app *)) > +{ > + struct lan966x_port *port = netdev_priv(dev); > + struct lan966x *lan966x = port->lan966x; > + int err; > + > + for (int i = 0; i < NUM_PHYS_PORTS; i++) { > + port = lan966x->ports[i]; > + if (!port) > + continue; > + > + err = setdel(port->dev, app); > + if (err) > + return err; > + } > + > + return 0; > +} > + > static int lan966x_dcb_app_validate(struct net_device *dev, > const struct dcb_app *app) > { > int err = 0; > > switch (app->selector) { > + /* Dscp checks */ > + case IEEE_8021QAZ_APP_SEL_DSCP: > + if (app->protocol >= LAN966X_PORT_QOS_DSCP_COUNT) > + err = -EINVAL; > + else if (app->priority >= NUM_PRIO_QUEUES) > + err = -ERANGE; > + break; > /* Pcp checks */ > case DCB_APP_SEL_PCP: > if (app->protocol >= LAN966X_PORT_QOS_PCP_DEI_COUNT) > @@ -93,8 +136,12 @@ static int lan966x_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app) > { > int err; > > - err = dcb_ieee_delapp(dev, app); > - if (err < 0) > + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) > + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_delapp); > + else > + err = dcb_ieee_delapp(dev, app); > + > + if (err) > return err; > > lan966x_dcb_app_update(dev); > @@ -117,12 +164,16 @@ static int lan966x_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app) > if (prio) { > app_itr = *app; > app_itr .priority = prio; > - dcb_ieee_delapp(dev, &app_itr); > + lan966x_dcb_ieee_delapp(dev, &app_itr); > } > > - err = dcb_ieee_setapp(dev, app); > + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) > + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_setapp); > + else > + err = dcb_ieee_setapp(dev, app); > + > if (err) > - goto out; > + return err; Looks like you can alco completely remove goto and out, just return err in other cases in this function. > > lan966x_dcb_app_update(dev); > > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h > index b9ca47ab6e8be..8213440e08672 100644 > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h > @@ -109,6 +109,8 @@ > #define LAN966X_PORT_QOS_PCP_DEI_COUNT \ > (LAN966X_PORT_QOS_PCP_COUNT + LAN966X_PORT_QOS_DEI_COUNT) > > +#define LAN966X_PORT_QOS_DSCP_COUNT 64 > + > /* MAC table entry types. > * ENTRYTYPE_NORMAL is subject to aging. > * ENTRYTYPE_LOCKED is not subject to aging. > @@ -402,8 +404,14 @@ struct lan966x_port_qos_pcp { > bool enable; > }; > > +struct lan966x_port_qos_dscp { > + u8 map[LAN966X_PORT_QOS_DSCP_COUNT]; > + bool enable; > +}; > + > struct lan966x_port_qos { > struct lan966x_port_qos_pcp pcp; > + struct lan966x_port_qos_dscp dscp; > }; > > struct lan966x_port { > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c > index 0cee8127c48eb..11c552e87ee44 100644 > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c > @@ -418,10 +418,36 @@ static void lan966x_port_qos_pcp_set(struct lan966x_port *port, > } > } > > +static void lan966x_port_qos_dscp_set(struct lan966x_port *port, > + struct lan966x_port_qos_dscp *qos) > +{ > + struct lan966x *lan966x = port->lan966x; > + > + /* Enable/disable dscp for qos classification. */ > + lan_rmw(ANA_QOS_CFG_QOS_DSCP_ENA_SET(qos->enable), > + ANA_QOS_CFG_QOS_DSCP_ENA, > + lan966x, ANA_QOS_CFG(port->chip_port)); > + > + /* Map each dscp value to priority and dp */ > + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) > + lan_rmw(ANA_DSCP_CFG_DP_DSCP_VAL_SET(0) | > + ANA_DSCP_CFG_QOS_DSCP_VAL_SET(*(qos->map + i)), > + ANA_DSCP_CFG_DP_DSCP_VAL | > + ANA_DSCP_CFG_QOS_DSCP_VAL, > + lan966x, ANA_DSCP_CFG(i)); > + > + /* Set per-dscp trust */ > + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) > + lan_rmw(ANA_DSCP_CFG_DSCP_TRUST_ENA_SET(qos->enable), > + ANA_DSCP_CFG_DSCP_TRUST_ENA, > + lan966x, ANA_DSCP_CFG(i)); > +} > + > void lan966x_port_qos_set(struct lan966x_port *port, > struct lan966x_port_qos *qos) > { > lan966x_port_qos_pcp_set(port, &qos->pcp); > + lan966x_port_qos_dscp_set(port, &qos->dscp); > } > > void lan966x_port_init(struct lan966x_port *port) > -- > 2.38.0 > >
On Sun, 2023-05-14 at 22:10 +0200, Horatiu Vultur wrote: > @@ -117,12 +164,16 @@ static int lan966x_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app) > if (prio) { > app_itr = *app; > app_itr .priority = prio; > - dcb_ieee_delapp(dev, &app_itr); > + lan966x_dcb_ieee_delapp(dev, &app_itr); > } > > - err = dcb_ieee_setapp(dev, app); > + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) > + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_setapp); > + else > + err = dcb_ieee_setapp(dev, app); > + > if (err) > - goto out; > + return err; As Piotr suggested, please drop the out: label altogether, replacing even the other 'goto out;' statement with a plain return. Additionally you can replace the final: return err; in this function with: return 0; Thanks, Paolo
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c index c149f905fe9e3..2b518181b7f08 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c @@ -57,19 +57,62 @@ static void lan966x_dcb_app_update(struct net_device *dev) qos.pcp.map[i] = dcb_getapp(dev, &app_itr); } + /* Get dscp ingress mapping */ + for (int i = 0; i < ARRAY_SIZE(qos.dscp.map); i++) { + app_itr.selector = IEEE_8021QAZ_APP_SEL_DSCP; + app_itr.protocol = i; + qos.dscp.map[i] = dcb_getapp(dev, &app_itr); + } + /* Enable use of pcp for queue classification */ if (lan966x_dcb_apptrust_contains(port->chip_port, DCB_APP_SEL_PCP)) qos.pcp.enable = true; + /* Enable use of dscp for queue classification */ + if (lan966x_dcb_apptrust_contains(port->chip_port, IEEE_8021QAZ_APP_SEL_DSCP)) + qos.dscp.enable = true; + lan966x_port_qos_set(port, &qos); } +/* DSCP mapping is global for all ports, so set and delete app entries are + * replicated for each port. + */ +static int lan966x_dcb_ieee_dscp_setdel(struct net_device *dev, + struct dcb_app *app, + int (*setdel)(struct net_device *, + struct dcb_app *)) +{ + struct lan966x_port *port = netdev_priv(dev); + struct lan966x *lan966x = port->lan966x; + int err; + + for (int i = 0; i < NUM_PHYS_PORTS; i++) { + port = lan966x->ports[i]; + if (!port) + continue; + + err = setdel(port->dev, app); + if (err) + return err; + } + + return 0; +} + static int lan966x_dcb_app_validate(struct net_device *dev, const struct dcb_app *app) { int err = 0; switch (app->selector) { + /* Dscp checks */ + case IEEE_8021QAZ_APP_SEL_DSCP: + if (app->protocol >= LAN966X_PORT_QOS_DSCP_COUNT) + err = -EINVAL; + else if (app->priority >= NUM_PRIO_QUEUES) + err = -ERANGE; + break; /* Pcp checks */ case DCB_APP_SEL_PCP: if (app->protocol >= LAN966X_PORT_QOS_PCP_DEI_COUNT) @@ -93,8 +136,12 @@ static int lan966x_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app) { int err; - err = dcb_ieee_delapp(dev, app); - if (err < 0) + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_delapp); + else + err = dcb_ieee_delapp(dev, app); + + if (err) return err; lan966x_dcb_app_update(dev); @@ -117,12 +164,16 @@ static int lan966x_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app) if (prio) { app_itr = *app; app_itr .priority = prio; - dcb_ieee_delapp(dev, &app_itr); + lan966x_dcb_ieee_delapp(dev, &app_itr); } - err = dcb_ieee_setapp(dev, app); + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_setapp); + else + err = dcb_ieee_setapp(dev, app); + if (err) - goto out; + return err; lan966x_dcb_app_update(dev); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index b9ca47ab6e8be..8213440e08672 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -109,6 +109,8 @@ #define LAN966X_PORT_QOS_PCP_DEI_COUNT \ (LAN966X_PORT_QOS_PCP_COUNT + LAN966X_PORT_QOS_DEI_COUNT) +#define LAN966X_PORT_QOS_DSCP_COUNT 64 + /* MAC table entry types. * ENTRYTYPE_NORMAL is subject to aging. * ENTRYTYPE_LOCKED is not subject to aging. @@ -402,8 +404,14 @@ struct lan966x_port_qos_pcp { bool enable; }; +struct lan966x_port_qos_dscp { + u8 map[LAN966X_PORT_QOS_DSCP_COUNT]; + bool enable; +}; + struct lan966x_port_qos { struct lan966x_port_qos_pcp pcp; + struct lan966x_port_qos_dscp dscp; }; struct lan966x_port { diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c index 0cee8127c48eb..11c552e87ee44 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c @@ -418,10 +418,36 @@ static void lan966x_port_qos_pcp_set(struct lan966x_port *port, } } +static void lan966x_port_qos_dscp_set(struct lan966x_port *port, + struct lan966x_port_qos_dscp *qos) +{ + struct lan966x *lan966x = port->lan966x; + + /* Enable/disable dscp for qos classification. */ + lan_rmw(ANA_QOS_CFG_QOS_DSCP_ENA_SET(qos->enable), + ANA_QOS_CFG_QOS_DSCP_ENA, + lan966x, ANA_QOS_CFG(port->chip_port)); + + /* Map each dscp value to priority and dp */ + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) + lan_rmw(ANA_DSCP_CFG_DP_DSCP_VAL_SET(0) | + ANA_DSCP_CFG_QOS_DSCP_VAL_SET(*(qos->map + i)), + ANA_DSCP_CFG_DP_DSCP_VAL | + ANA_DSCP_CFG_QOS_DSCP_VAL, + lan966x, ANA_DSCP_CFG(i)); + + /* Set per-dscp trust */ + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) + lan_rmw(ANA_DSCP_CFG_DSCP_TRUST_ENA_SET(qos->enable), + ANA_DSCP_CFG_DSCP_TRUST_ENA, + lan966x, ANA_DSCP_CFG(i)); +} + void lan966x_port_qos_set(struct lan966x_port *port, struct lan966x_port_qos *qos) { lan966x_port_qos_pcp_set(port, &qos->pcp); + lan966x_port_qos_dscp_set(port, &qos->dscp); } void lan966x_port_init(struct lan966x_port *port)
Add support for offloading dscp app entries. The dscp values are global for all lan966x ports. Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> --- .../ethernet/microchip/lan966x/lan966x_dcb.c | 61 +++++++++++++++++-- .../ethernet/microchip/lan966x/lan966x_main.h | 8 +++ .../ethernet/microchip/lan966x/lan966x_port.c | 26 ++++++++ 3 files changed, 90 insertions(+), 5 deletions(-)