Add new PCP and APPTRUST attributes to dcbnl
Subsystems (3)
Daniel Machon
maintainerv6 cover Add new PCP and APPTRUST attributes to dcbnl
This patch series adds new extension attributes to dcbnl, to support PCP prioritization (and thereby hw offloadable pcp-based queue classification) and per-selector trust and trust order. Additionally, the microchip sparx5 driver has been dcb-enabled to make use of the new attributes to offload PCP, DSCP and Default prio to the switch, and implement trust order of selectors.
For pre-RFC discussion see:
https://lore.kernel.org/netdev/Yv9VO1DYAxNduw6A@DEN-LT-70577/
For RFC series see:
https://lore.kernel.org/netdev/[email protected]/
In summary: there currently exist no convenient way to offload per-port PCP-based queue classification to hardware. The DCB subsystem offers different ways to prioritize through its APP table, but lacks an option for PCP. Similarly, there is no way to indicate the notion of trust for APP table selectors. This patch series addresses both topics.
PCP based queue classification:
- 8021Q standardizes the Priority Code Point table (see 6.9.3 of IEEE Std 802.1Q-2018). This patch series makes it possible, to offload the PCP classification to said table. The new PCP selector is not a standard part of the APP managed object, therefore it is encapsulated in a new non-std extension attribute.
Selector trust:
- ASIC's often has the notion of trust DSCP and trust PCP. The new attribute makes it possible to specify a trust order of app selectors, which drivers can then react on.
DCB-enable sparx5 driver:
- Now supports offloading of DSCP, PCP and default priority. Only one mapping of protocol:priority is allowed. Consecutive mappings of the same protocol to some new priority, will overwrite the previous. This is to keep a consistent view of the app table and the hardware.
- Now supports dscp and pcp trust, by use of the introduced dcbnl_set/getapptrust ops. Sparx5 supports trust orders: [], [dscp], [pcp] and [dscp, pcp]. For now, only DSCP and PCP selectors are supported by the driver, everything else is bounced.
Patch #1 introduces a new PCP selector to the APP object, which makes it possible to encode PCP and DEI in the app triplet and offload it to the PCP table of the ASIC.
Patch #2 Introduces the new extension attributes DCB_ATTR_DCB_APP_TRUST_TABLE and DCB_ATTR_DCB_APP_TRUST. Trusted selectors are passed in the nested DCB_ATTR_DCB_APP_TRUST_TABLE attribute, and assembled into an array of selectors:
u8 selectors[256];
where lower indexes has higher precedence. In the array, selectors are stored consecutively, starting from index zero. With a maximum number of 256 unique selectors, the list has the same maximum size.
Patch #3 Sets up the dcbnl ops hook, and adds support for offloading pcp app entries, to the PCP table of the switch.
Patch #4 Makes use of the dcbnl_set/getapptrust ops, to set a per-port trust order.
Patch #5 Adds support for offloading dscp app entries to the DSCP table of the switch.
Patch #6 Adds support for offloading default prio app entries to the switch.
================================================================================
RFC v1:
https://lore.kernel.org/netdev/[email protected]/
RFC v1 -> RFC v2:
- Added new nested attribute type DCB_ATTR_DCB_APP_TRUST_TABLE.
- Renamed attributes from DCB_ATTR_IEEE_* to DCB_ATTR_DCB_*.
- Renamed ieee_set/getapptrust to dcbnl_set/getapptrust.
- Added -EOPNOTSUPP if dcbnl_setapptrust is not set.
- Added sanitization of selector array, before passing to driver.
RFC v2 -> (non-RFC) v1:
- Added additional check for selector validity.
- Fixed a few style errors.
- using nla_start_nest() instead of nla_start_nest_no_flag().
- Moved DCB_ATTR_DCB_APP_TRUST into new enum.
- Added new DCB_ATTR_DCB_APP extension attribute, for non-std selector values.
- Added support for offloading dscp, pcp and default prio in the sparx5 driver.
- Added support for per-selector trust and trust order in the sparx5 driver.
v1 -> v2:
- Fixed compiler and kdoc warning
v2 -> v3:
- Moved back to 255 as PCP selector value.
- Fixed return value in dcbnl_app_attr_type_get() to enum.
- Modified in dcbnl_app_attr_type_get() dcbnl_app_attr_type_validate() to return directly.
- Added nselector check in sparx5_dcb_apptrust_validate().
- Added const qualifier to "names" variable in struct sparx5_dcb_apptrust.
- Added new SPARX5_DCB config. Fixes issues reported by kernel test robot.
v3 -> v4:
- Added new dcbnl_app_attr_selector_validate() function to validate that app selectors are sent in correct attribute e.g IEEE selectors in DCB_ATTR_IEEE and non-std selectors in DCB_ATTR_DCB.
- Modified handling of dcbnl_getapptrust() return value, so that an error is ignored. Instead, added error check on nla_put_u8() and cancelling nest in case of an error.
v4 -> v5:
- Rebased on net-next and fixed sparx5 conflicts
v5 -> v6:
- Fix check of return value from app to apptrust.
- Refactor dcbnl_app_attr_selector_validate().
- Add attr type check and selector check to apptrust.
- Rename a few variables to contain "sparx5" and define symbols for constants in sparx5_dcb.c.
Daniel Machon (6):
net: dcb: add new pcp selector to app object
net: dcb: add new apptrust attribute
net: microchip: sparx5: add support for offloading pcp table
net: microchip: sparx5: add support for apptrust
net: microchip: sparx5: add support for offloading dscp table
net: microchip: sparx5: add support for offloading default prio
drivers/net/ethernet/microchip/sparx5/Kconfig | 10 + .../net/ethernet/microchip/sparx5/Makefile | 2 + .../ethernet/microchip/sparx5/sparx5_dcb.c | 293 ++++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_main.h | 11 + .../microchip/sparx5/sparx5_main_regs.h | 127 +++++++- .../ethernet/microchip/sparx5/sparx5_port.c | 99 ++++++ .../ethernet/microchip/sparx5/sparx5_port.h | 37 +++ .../ethernet/microchip/sparx5/sparx5_qos.c | 4 + include/net/dcbnl.h | 4 + include/uapi/linux/dcbnl.h | 16 + net/dcb/dcbnl.c | 151 ++++++++- 11 files changed, 746 insertions(+), 8 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
--
2.34.1
Daniel Machon
maintainerPATCH v6 1/6 net: dcb: add new pcp selector to app object
Add new PCP selector for the 8021Qaz APP managed object.
As the PCP selector is not part of the 8021Qaz standard, a new non-std extension attribute DCB_ATTR_DCB_APP has been introduced. Also two helper functions to translate between selector and app attribute type has been added. The new selector has been given a value of 255, to minimize the risk of future overlap of std- and non-std attributes.
The new DCB_ATTR_DCB_APP is sent alongside the ieee std attribute in the app table. This means that the dcb_app struct can now both contain std- and non-std app attributes. Currently there is no overlap between the selector values of the two attributes.
The purpose of adding the PCP selector, is to be able to offload PCP-based queue classification to the 8021Q Priority Code Point table, see 6.9.3 of IEEE Std 802.1Q-2018.
PCP and DEI is encoded in the protocol field as 8*dei+pcp, so that a mapping of PCP 2 and DEI 1 to priority 3 is encoded as {255, 10, 3}.
--- include/uapi/linux/dcbnl.h | 6 ++++ net/dcb/dcbnl.c | 58 +++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 4 deletions(-)
include/uapi/linux/dcbnl.h +6 -0
@@ -218,6 +218,9 @@ struct cee_pfc {#define IEEE_8021QAZ_APP_SEL_ANY 4#define IEEE_8021QAZ_APP_SEL_DSCP 5 +/* Non-std selector values */ +#define DCB_APP_SEL_PCP 255 +/* This structure contains the IEEE 802.1Qaz APP managed object. This * object is also used for the CEE std as well. *
@@ -247,6 +250,8 @@ struct dcb_app {__u16 protocol; }; +#define IEEE_8021QAZ_APP_SEL_MAX 255 +/** * struct dcb_peer_app_info - APP feature information sent by the peer *
@@ -425,6 +430,7 @@ enum ieee_attrs {enum ieee_attrs_app {DCB_ATTR_IEEE_APP_UNSPEC ,DCB_ATTR_IEEE_APP , +DCB_ATTR_DCB_APP , __DCB_ATTR_IEEE_APP_MAX };#define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
net/dcb/dcbnl.c +54 -4
94 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH net-next v6 1/6] net: dcb: add new pcp selector to app object
Quoted 13 lines · Daniel Machon
Add new PCP selector for the 8021Qaz APP managed object.
As the PCP selector is not part of the 8021Qaz standard, a new non-std extension attribute
DCB_ATTR_DCB_APPhas been introduced. Also two helper functions to translate between selector and app attribute type has been added. The new selector has been given a value of 255, to minimize the risk of future overlap of std- and non-std attributes.The new
DCB_ATTR_DCB_APPis sent alongside the ieee std attribute in the app table. This means that thedcb_appstruct can now both contain std- and non-std app attributes. Currently there is no overlap between the selector values of the two attributes.
Quoted 8 lines
The purpose of adding the PCP selector, is to be able to offload PCP-based queue classification to the 8021Q Priority Code Point table, see 6.9.3 of IEEE Std 802.1Q-2018.
PCP and DEI is encoded in the protocol field as 8*dei+pcp, so that a mapping of PCP 2 and DEI 1 to priority 3 is encoded as {255, 10, 3}.
Signed-off-by Daniel Machon <[email protected]>
Daniel Machon
maintainerPATCH v6 2/6 net: dcb: add new apptrust attribute
In reply to Daniel MachonAdd new apptrust extension attributes to the 8021Qaz APP managed object.
Two new attributes, DCB_ATTR_DCB_APP_TRUST_TABLE and DCB_ATTR_DCB_APP_TRUST, has been added. Trusted selectors are passed in the nested attribute DCB_ATTR_DCB_APP_TRUST, in order of precedence.
The new attributes are meant to allow drivers, whose hw supports the notion of trust, to be able to set whether a particular app selector is trusted - and in which order.
--- include/net/dcbnl.h | 4 ++ include/uapi/linux/dcbnl.h | 2 + net/dcb/dcbnl.c | 76 +++++++++++++++++++++++++++++++++++++- 3 files changed, 80 insertions(+), 2 deletions(-)
include/net/dcbnl.h +4 -0
@@ -109,6 +109,10 @@ struct dcbnl_rtnl_ops {/* buffer settings */ int (*dcbnl_getbuffer)(struct net_device *,struct dcbnl_buffer *);int (*dcbnl_setbuffer)(struct net_device *,struct dcbnl_buffer *); + +/* apptrust */ +int (*dcbnl_setapptrust)(struct net_device *,u8 *,int ); + int (*dcbnl_getapptrust)(struct net_device *, u8 *, int *); };#endif /* __NET_DCBNL_H__ */
include/uapi/linux/dcbnl.h +2 -0
@@ -410,6 +410,7 @@ enum dcbnl_attrs {* @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only * @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only * @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only +* @DCB_ATTR_DCB_APP_TRUST_TABLE: selector trust table */ enum ieee_attrs {DCB_ATTR_IEEE_UNSPEC ,
@@ -423,6 +424,7 @@ enum ieee_attrs {DCB_ATTR_IEEE_QCN ,DCB_ATTR_IEEE_QCN_STATS ,DCB_ATTR_DCB_BUFFER , +DCB_ATTR_DCB_APP_TRUST_TABLE , __DCB_ATTR_IEEE_MAX };#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
net/dcb/dcbnl.c +74 -2
101 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH net-next v6 2/6] net: dcb: add new apptrust attribute
Quoted 11 lines · Daniel Machon
Add new apptrust extension attributes to the 8021Qaz APP managed object.
Two new attributes,
DCB_ATTR_DCB_APP_TRUST_TABLEandDCB_ATTR_DCB_APP_TRUST, has been added. Trusted selectors are passed in the nested attributeDCB_ATTR_DCB_APP_TRUST, in order of precedence.The new attributes are meant to allow drivers, whose hw supports the notion of trust, to be able to set whether a particular app selector is trusted - and in which order.
Signed-off-by Daniel Machon <[email protected]>
Daniel Machon
maintainerPATCH v6 3/6 net: microchip: sparx5: add support for offloading pcp table
In reply to Daniel MachonAdd new registers and functions to support offload of pcp app entries.
--- drivers/net/ethernet/microchip/sparx5/Kconfig | 11 ++ .../net/ethernet/microchip/sparx5/Makefile | 2 + .../ethernet/microchip/sparx5/sparx5_dcb.c | 116 ++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_main.h | 11 ++ .../microchip/sparx5/sparx5_main_regs.h | 127 +++++++++++++++++- .../ethernet/microchip/sparx5/sparx5_port.c | 37 +++++ .../ethernet/microchip/sparx5/sparx5_port.h | 21 +++ .../ethernet/microchip/sparx5/sparx5_qos.c | 4 + 8 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
drivers/net/ethernet/microchip/sparx5/Kconfig +11 -0
@@ -12,3 +12,14 @@ config SPARX5_SWITCH select VCAP help This driver supports the Sparx5 network switch device. + +config SPARX5_DCB + bool "Data Center Bridging (DCB) support" + depends on SPARX5_SWITCH && DCB + default y + help + Say Y here if you want to use Data Center Bridging (DCB) in the + driver. This can be used to assign priority to traffic, based on + DSCP and PCP. + + If unsure, set to Y.
drivers/net/ethernet/microchip/sparx5/Makefile +2 -0
@@ -11,5 +11,7 @@ sparx5-switch-y := sparx5_main.o sparx5_packet.o \ sparx5_ptp.o sparx5_pgid.o sparx5_tc.o sparx5_qos.o \ sparx5_vcap_impl.o sparx5_vcap_ag_api.o sparx5_tc_flower.o +sparx5-switch-$(CONFIG_SPARX5_DCB) += sparx5_dcb.o + # Provide include files ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c new file +116 -0
116 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +11 -0
@@ -359,6 +359,16 @@ int sparx5_config_dsm_calendar(struct sparx5 *sparx5);void sparx5_get_stats64 (struct net_device *ndev,struct rtnl_link_stats64 *stats);int sparx_stats_init (struct sparx5 *sparx5); +/* sparx5_dcb.c */ +#ifdef CONFIG_SPARX5_DCB +int sparx5_dcb_init (struct sparx5 *sparx5); +#else +static inline int sparx5_dcb_init (struct sparx5 *sparx5) +{ +return 0 ; +} +#endif +/* sparx5_netdev.c */ void sparx5_set_port_ifh_timestamp (void *ifh_hdr,u64 timestamp);void sparx5_set_port_ifh_rew_op (void *ifh_hdr,u32 rew_op);
@@ -424,6 +434,7 @@ static inline bool sparx5_is_baser(phy_interface_t interface)extern const struct phylink_mac_ops sparx5_phylink_mac_ops;extern const struct phylink_pcs_ops sparx5_phylink_pcs_ops;extern const struct ethtool_ops sparx5_ethtool_ops; +extern const struct dcbnl_rtnl_ops sparx5_dcbnl_ops;/* Calculate raw offset */ static inline __pure int spx5_offset(int id, int tinst, int tcnt,
drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h +125 -2
145 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_port.c +37 -0
@@ -6,6 +6,7 @@#include <linux/module.h> #include <linux/phy/phy.h> +#include <net/dcbnl.h> #include "sparx5_main_regs.h" #include "sparx5_main.h"
@@ -1144,3 +1145,39 @@ void sparx5_port_enable(struct sparx5_port *port, bool enable) sparx5, QFWD_SWITCH_PORT_MODE(port->portno)); } + +int sparx5_port_qos_set (struct sparx5_port *port, +struct sparx5_port_qos *qos) +{ +sparx5_port_qos_pcp_set (port, &qos->pcp); + +return 0 ; +} + +int sparx5_port_qos_pcp_set (const struct sparx5_port *port, +struct sparx5_port_qos_pcp *qos) +{ +struct sparx5 *sparx5 = port->sparx5; +u8 *pcp_itr = qos->map.map; +u8 pcp, dp; +int i; + +/* Enable/disable pcp and dp for qos classification. */ +spx5_rmw (ANA_CL_QOS_CFG_PCP_DEI_QOS_ENA_SET (1 ) | +ANA_CL_QOS_CFG_PCP_DEI_DP_ENA_SET (1 ), +ANA_CL_QOS_CFG_PCP_DEI_QOS_ENA |ANA_CL_QOS_CFG_PCP_DEI_DP_ENA , + sparx5,ANA_CL_QOS_CFG (port->portno)); + +/* Map each pcp and dei value to priority and dp */ +for (i =0 ; i <ARRAY_SIZE (qos->map.map); i++) { + pcp = *(pcp_itr + i); + dp = (i <SPARX5_PORT_QOS_PCP_COUNT ) ?0 :1 ; +spx5_rmw (ANA_CL_PCP_DEI_MAP_CFG_PCP_DEI_QOS_VAL_SET (pcp) | +ANA_CL_PCP_DEI_MAP_CFG_PCP_DEI_DP_VAL_SET (dp), +ANA_CL_PCP_DEI_MAP_CFG_PCP_DEI_QOS_VAL | +ANA_CL_PCP_DEI_MAP_CFG_PCP_DEI_DP_VAL , sparx5, +ANA_CL_PCP_DEI_MAP_CFG (port->portno, i)); + } + +return 0 ; +}
drivers/net/ethernet/microchip/sparx5/sparx5_port.h +21 -0
@@ -91,4 +91,25 @@ int sparx5_get_port_status(struct sparx5 *sparx5,void sparx5_port_enable (struct sparx5_port *port,bool enable);int sparx5_port_fwd_urg (struct sparx5 *sparx5,u32 speed); +#define SPARX5_PORT_QOS_PCP_COUNT 8 +#define SPARX5_PORT_QOS_DEI_COUNT 8 +#define SPARX5_PORT_QOS_PCP_DEI_COUNT \ + (SPARX5_PORT_QOS_PCP_COUNT + SPARX5_PORT_QOS_DEI_COUNT) +struct sparx5_port_qos_pcp_map { +u8 map[SPARX5_PORT_QOS_PCP_DEI_COUNT ]; +}; + +struct sparx5_port_qos_pcp { +struct sparx5_port_qos_pcp_map map; +}; + +struct sparx5_port_qos { +struct sparx5_port_qos_pcp pcp; +}; + +int sparx5_port_qos_set (struct sparx5_port *port,struct sparx5_port_qos *qos); + +int sparx5_port_qos_pcp_set (const struct sparx5_port *port, +struct sparx5_port_qos_pcp *qos); +#endif /* __SPARX5_PORT_H__ */
drivers/net/ethernet/microchip/sparx5/sparx5_qos.c +4 -0
@@ -389,6 +389,10 @@ int sparx5_qos_init(struct sparx5 *sparx5)if (ret <0 )return ret; + ret =sparx5_dcb_init (sparx5); +if (ret <0 ) +return ret; +return 0 ; }
Signature · 1 line
2.34.1
Daniel Machon
maintainerPATCH v6 4/6 net: microchip: sparx5: add support for apptrust
In reply to Daniel MachonMake use of set/getapptrust() to implement per-selector trust and trust order.
--- .../ethernet/microchip/sparx5/sparx5_dcb.c | 122 ++++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_port.c | 4 +- .../ethernet/microchip/sparx5/sparx5_port.h | 2 + 3 files changed, 126 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c +122 -0
@@ -8,6 +8,37 @@#include "sparx5_port.h" +enum sparx5_dcb_apptrust_values { +SPARX5_DCB_APPTRUST_EMPTY , +SPARX5_DCB_APPTRUST_DSCP , +SPARX5_DCB_APPTRUST_PCP , +SPARX5_DCB_APPTRUST_DSCP_PCP , + __SPARX5_DCB_APPTRUST_MAX +}; + +static const struct sparx5_dcb_apptrust { +u8 selectors[IEEE_8021QAZ_APP_SEL_MAX +1 ]; +int nselectors; +} *sparx5_port_apptrust[SPX5_PORTS ]; + +static const char *sparx5_dcb_apptrust_names[__SPARX5_DCB_APPTRUST_MAX] = { + [SPARX5_DCB_APPTRUST_EMPTY ] ="empty" , + [SPARX5_DCB_APPTRUST_DSCP ] ="dscp" , + [SPARX5_DCB_APPTRUST_PCP ] ="pcp" , + [SPARX5_DCB_APPTRUST_DSCP_PCP ] ="dscp pcp" +}; + +/* Sparx5 supported apptrust policies */ +static const struct sparx5_dcb_apptrust + sparx5_dcb_apptrust_policies[__SPARX5_DCB_APPTRUST_MAX] = { +/* Empty *must* be first */ + [SPARX5_DCB_APPTRUST_EMPTY ] = { {0 },0 }, + [SPARX5_DCB_APPTRUST_DSCP ] = { {IEEE_8021QAZ_APP_SEL_DSCP },1 }, + [SPARX5_DCB_APPTRUST_PCP ] = { {DCB_APP_SEL_PCP },1 }, + [SPARX5_DCB_APPTRUST_DSCP_PCP ] = { {IEEE_8021QAZ_APP_SEL_DSCP , +DCB_APP_SEL_PCP },2 }, +}; +/* Validate app entry. * * Check for valid selectors and valid protocol and priority ranges.
@@ -37,12 +68,62 @@ static int sparx5_dcb_app_validate(struct net_device *dev,return err; } +/* Validate apptrust configuration. +* +* Return index of supported apptrust configuration if valid, otherwise return +* error. +*/ +static int sparx5_dcb_apptrust_validate (struct net_device *dev,u8 *selectors, +int nselectors,int *err) +{ +bool match; +int i, ii; + +for (i =0 ; i <ARRAY_SIZE (sparx5_dcb_apptrust_policies); i++) { +if (sparx5_dcb_apptrust_policies[i].nselectors != nselectors) +continue ; + match = true; +for (ii =0 ; ii < nselectors; ii++) { +if (sparx5_dcb_apptrust_policies[i].selectors[ii] != + *(selectors + ii)) { + match = false; +break ; + } + } +if (match) +break ; + } + +/* Requested trust configuration is not supported */ +if (!match) { +netdev_err (dev,"Valid apptrust configurations are:\n" ); +for (i =0 ; i <ARRAY_SIZE (sparx5_dcb_apptrust_names); i++) +pr_info ("order: %s\n" , sparx5_dcb_apptrust_names[i]); + *err = -EOPNOTSUPP ; + } + +return i; +} + +static bool sparx5_dcb_apptrust_contains (int portno,u8 selector) +{ +const struct sparx5_dcb_apptrust *conf = sparx5_port_apptrust[portno]; +int i; + +for (i =0 ; i < conf->nselectors; i++) +if (conf->selectors[i] == selector) +return true; + +return false; +} +static int sparx5_dcb_app_update (struct net_device *dev) {struct dcb_app app_itr = { .selector =DCB_APP_SEL_PCP };struct sparx5_port *port =netdev_priv (dev);struct sparx5_port_qos_pcp_map *pcp_map;struct sparx5_port_qos qos = {0 }; +int portno = port->portno;int i; pcp_map = &qos.pcp.map;
@@ -53,6 +134,12 @@ static int sparx5_dcb_app_update(struct net_device *dev) pcp_map->map[i] =dcb_getapp (dev, &app_itr); } +/* Enable use of pcp for queue classification ? */ +if (sparx5_dcb_apptrust_contains (portno,DCB_APP_SEL_PCP )) { + qos.pcp.qos_enable = true; + qos.pcp.dp_enable = qos.pcp.qos_enable; + } +return sparx5_port_qos_set (port, &qos); }
@@ -95,9 +182,40 @@ static int sparx5_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app)return sparx5_dcb_app_update (dev); } +static int sparx5_dcb_setapptrust (struct net_device *dev,u8 *selectors, +int nselectors) +{ +struct sparx5_port *port =netdev_priv (dev); +int err =0 , idx; + + idx =sparx5_dcb_apptrust_validate (dev, selectors, nselectors, &err); +if (err <0 ) +return err; + + sparx5_port_apptrust[port->portno] = &sparx5_dcb_apptrust_policies[idx]; + +return sparx5_dcb_app_update (dev); +} + +static int sparx5_dcb_getapptrust (struct net_device *dev,u8 *selectors, +int *nselectors) +{ +struct sparx5_port *port =netdev_priv (dev); +const struct sparx5_dcb_apptrust *trust; + + trust = sparx5_port_apptrust[port->portno]; + +memcpy (selectors, trust->selectors, trust->nselectors); + *nselectors = trust->nselectors; + +return 0 ; +} +const struct dcbnl_rtnl_ops sparx5_dcbnl_ops = { .ieee_setapp = sparx5_dcb_ieee_setapp, .ieee_delapp = sparx5_dcb_ieee_delapp, + .dcbnl_setapptrust = sparx5_dcb_setapptrust, + .dcbnl_getapptrust = sparx5_dcb_getapptrust, };int sparx5_dcb_init (struct sparx5 *sparx5)
@@ -110,6 +228,10 @@ int sparx5_dcb_init(struct sparx5 *sparx5)if (!port)continue ; port->ndev->dcbnl_ops = &sparx5_dcbnl_ops; +/* Initialize [dscp, pcp] default trust */ + sparx5_port_apptrust[port->portno] = + &sparx5_dcb_apptrust_policies + [SPARX5_DCB_APPTRUST_DSCP_PCP ]; }return 0 ;
drivers/net/ethernet/microchip/sparx5/sparx5_port.c +2 -2
@@ -1163,8 +1163,8 @@ int sparx5_port_qos_pcp_set(const struct sparx5_port *port,int i;/* Enable/disable pcp and dp for qos classification. */ -spx5_rmw (ANA_CL_QOS_CFG_PCP_DEI_QOS_ENA_SET (1 ) | -ANA_CL_QOS_CFG_PCP_DEI_DP_ENA_SET (1 ), +spx5_rmw (ANA_CL_QOS_CFG_PCP_DEI_QOS_ENA_SET (qos->qos_enable) | +ANA_CL_QOS_CFG_PCP_DEI_DP_ENA_SET (qos->dp_enable),ANA_CL_QOS_CFG_PCP_DEI_QOS_ENA |ANA_CL_QOS_CFG_PCP_DEI_DP_ENA , sparx5,ANA_CL_QOS_CFG (port->portno));
drivers/net/ethernet/microchip/sparx5/sparx5_port.h +2 -0
@@ -101,6 +101,8 @@ struct sparx5_port_qos_pcp_map {struct sparx5_port_qos_pcp {struct sparx5_port_qos_pcp_map map; +bool qos_enable; +bool dp_enable; };struct sparx5_port_qos {
Signature · 1 line
2.34.1
Daniel Machon
maintainerPATCH v6 5/6 net: microchip: sparx5: add support for offloading dscp table
In reply to Daniel MachonAdd support for offloading dscp app entries. Dscp values are global for all ports on the sparx5 switch. Therefore, we replicate each dscp app entry per-port.
--- .../ethernet/microchip/sparx5/sparx5_dcb.c | 66 ++++++++++++++++++- .../ethernet/microchip/sparx5/sparx5_port.c | 39 +++++++++++ .../ethernet/microchip/sparx5/sparx5_port.h | 14 ++++ 3 files changed, 116 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c +63 -3
@@ -49,6 +49,13 @@ static int sparx5_dcb_app_validate(struct net_device *dev,int err =0 ;switch (app->selector) { +/* Dscp checks */ +case IEEE_8021QAZ_APP_SEL_DSCP : +if (app->protocol >=SPARX5_PORT_QOS_DSCP_COUNT ) + err = -EINVAL ; +else if (app->priority >=SPX5_PRIOS ) + err = -ERANGE ; +break ;/* Pcp checks */ case DCB_APP_SEL_PCP :if (app->protocol >=SPARX5_PORT_QOS_PCP_DEI_COUNT )
@@ -119,17 +126,27 @@ static bool sparx5_dcb_apptrust_contains(int portno, u8 selector)static int sparx5_dcb_app_update (struct net_device *dev) { -struct dcb_app app_itr = { .selector =DCB_APP_SEL_PCP };struct sparx5_port *port =netdev_priv (dev); +struct sparx5_port_qos_dscp_map *dscp_map;struct sparx5_port_qos_pcp_map *pcp_map;struct sparx5_port_qos qos = {0 }; +struct dcb_app app_itr = {0 };int portno = port->portno;int i; + dscp_map = &qos.dscp.map; pcp_map = &qos.pcp.map; +/* Get dscp ingress mapping */ +for (i =0 ; i <ARRAY_SIZE (dscp_map->map); i++) { + app_itr.selector =IEEE_8021QAZ_APP_SEL_DSCP ; + app_itr.protocol = i; + dscp_map->map[i] =dcb_getapp (dev, &app_itr); + } +/* Get pcp ingress mapping */ for (i =0 ; i <ARRAY_SIZE (pcp_map->map); i++) { + app_itr.selector =DCB_APP_SEL_PCP ; app_itr.protocol = i; pcp_map->map[i] =dcb_getapp (dev, &app_itr); }
@@ -140,9 +157,44 @@ static int sparx5_dcb_app_update(struct net_device *dev) qos.pcp.dp_enable = qos.pcp.qos_enable; } +/* Enable use of dscp for queue classification ? */ +if (sparx5_dcb_apptrust_contains (portno,IEEE_8021QAZ_APP_SEL_DSCP )) { + qos.dscp.qos_enable = true; + qos.dscp.dp_enable = qos.dscp.qos_enable; + } +return sparx5_port_qos_set (port, &qos); } +/* Set or delete dscp app entry. +* +* Dscp mapping is global for all ports, so set and delete app entries are +* replicated for each port. +*/ +static int sparx5_dcb_ieee_dscp_setdel_app (struct net_device *dev, +struct dcb_app *app,bool del) +{ +struct sparx5_port *port =netdev_priv (dev); +struct dcb_app apps[SPX5_PORTS ]; +struct sparx5_port *port_itr; +int err, i; + +for (i =0 ; i <SPX5_PORTS ; i++) { + port_itr = port->sparx5->ports[i]; +if (!port_itr) +continue ; +memcpy (&apps[i], app,sizeof (struct dcb_app )); +if (del) + err =dcb_ieee_delapp (port_itr->ndev, &apps[i]); +else + err =dcb_ieee_setapp (port_itr->ndev, &apps[i]); +if (err) +return err; + } + +return 0 ; +} +static int sparx5_dcb_ieee_setapp (struct net_device *dev,struct dcb_app *app) {struct dcb_app app_itr;
@@ -161,7 +213,11 @@ static int sparx5_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app)dcb_ieee_delapp (dev, &app_itr); } - err =dcb_ieee_setapp (dev, app); +if (app->selector ==IEEE_8021QAZ_APP_SEL_DSCP ) + err =sparx5_dcb_ieee_dscp_setdel_app (dev, app, false); +else + err =dcb_ieee_setapp (dev, app); +if (err) goto out;
@@ -175,7 +231,11 @@ static int sparx5_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app) {int err; - err =dcb_ieee_delapp (dev, app); +if (app->selector ==IEEE_8021QAZ_APP_SEL_DSCP ) + err =sparx5_dcb_ieee_dscp_setdel_app (dev, app, true); +else + err =dcb_ieee_delapp (dev, app); +if (err <0 )return err;
drivers/net/ethernet/microchip/sparx5/sparx5_port.c +39 -0
@@ -1149,6 +1149,7 @@ void sparx5_port_enable(struct sparx5_port *port, bool enable)int sparx5_port_qos_set (struct sparx5_port *port,struct sparx5_port_qos *qos) { +sparx5_port_qos_dscp_set (port, &qos->dscp);sparx5_port_qos_pcp_set (port, &qos->pcp);return 0 ;
@@ -1181,3 +1182,41 @@ int sparx5_port_qos_pcp_set(const struct sparx5_port *port,return 0 ; } + +int sparx5_port_qos_dscp_set (const struct sparx5_port *port, +struct sparx5_port_qos_dscp *qos) +{ +struct sparx5 *sparx5 = port->sparx5; +u8 *dscp = qos->map.map; +int i; + +/* Enable/disable dscp and dp for qos classification. +* Disable rewrite of dscp values for now. +*/ +spx5_rmw (ANA_CL_QOS_CFG_DSCP_QOS_ENA_SET (qos->qos_enable) | +ANA_CL_QOS_CFG_DSCP_DP_ENA_SET (qos->dp_enable) | +ANA_CL_QOS_CFG_DSCP_KEEP_ENA_SET (1 ), +ANA_CL_QOS_CFG_DSCP_QOS_ENA |ANA_CL_QOS_CFG_DSCP_DP_ENA | +ANA_CL_QOS_CFG_DSCP_KEEP_ENA , sparx5, +ANA_CL_QOS_CFG (port->portno)); + +/* Map each dscp value to priority and dp */ +for (i =0 ; i <ARRAY_SIZE (qos->map.map); i++) { +spx5_rmw (ANA_CL_DSCP_CFG_DSCP_QOS_VAL_SET (*(dscp + i)) | +ANA_CL_DSCP_CFG_DSCP_DP_VAL_SET (0 ), +ANA_CL_DSCP_CFG_DSCP_QOS_VAL | +ANA_CL_DSCP_CFG_DSCP_DP_VAL , sparx5, +ANA_CL_DSCP_CFG (i)); + } + +/* Set per-dscp trust */ +for (i =0 ; i <ARRAY_SIZE (qos->map.map); i++) { +if (qos->qos_enable) { +spx5_rmw (ANA_CL_DSCP_CFG_DSCP_TRUST_ENA_SET (1 ), +ANA_CL_DSCP_CFG_DSCP_TRUST_ENA , sparx5, +ANA_CL_DSCP_CFG (i)); + } + } + +return 0 ; +}
drivers/net/ethernet/microchip/sparx5/sparx5_port.h +14 -0
@@ -99,14 +99,26 @@ struct sparx5_port_qos_pcp_map {u8 map[SPARX5_PORT_QOS_PCP_DEI_COUNT ]; }; +#define SPARX5_PORT_QOS_DSCP_COUNT 64 +struct sparx5_port_qos_dscp_map { +u8 map[SPARX5_PORT_QOS_DSCP_COUNT ]; +}; +struct sparx5_port_qos_pcp {struct sparx5_port_qos_pcp_map map;bool qos_enable;bool dp_enable; }; +struct sparx5_port_qos_dscp { +struct sparx5_port_qos_dscp_map map; +bool qos_enable; +bool dp_enable; +}; +struct sparx5_port_qos {struct sparx5_port_qos_pcp pcp; +struct sparx5_port_qos_dscp dscp; };int sparx5_port_qos_set (struct sparx5_port *port,struct sparx5_port_qos *qos);
@@ -114,4 +126,6 @@ int sparx5_port_qos_set(struct sparx5_port *port, struct sparx5_port_qos *qos);int sparx5_port_qos_pcp_set (const struct sparx5_port *port,struct sparx5_port_qos_pcp *qos); +int sparx5_port_qos_dscp_set (const struct sparx5_port *port, +struct sparx5_port_qos_dscp *qos);#endif /* __SPARX5_PORT_H__ */
Signature · 1 line
2.34.1
Daniel Machon
maintainerPATCH v6 6/6 net: microchip: sparx5: add support for offloading default prio
In reply to Daniel MachonAdd support for offloading default prio {ETHERTYPE, 0, prio}.
--- .../ethernet/microchip/sparx5/sparx5_dcb.c | 12 ++++++++++ .../ethernet/microchip/sparx5/sparx5_port.c | 23 +++++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_port.h | 5 ++++ 3 files changed, 40 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c +12 -0
@@ -49,6 +49,13 @@ static int sparx5_dcb_app_validate(struct net_device *dev,int err =0 ;switch (app->selector) { +/* Default priority checks */ +case IEEE_8021QAZ_APP_SEL_ETHERTYPE : +if (app->protocol !=0 ) + err = -EINVAL ; +else if (app->priority >=SPX5_PRIOS ) + err = -ERANGE ; +break ;/* Dscp checks */ case IEEE_8021QAZ_APP_SEL_DSCP :if (app->protocol >=SPARX5_PORT_QOS_DSCP_COUNT )
@@ -137,6 +144,11 @@ static int sparx5_dcb_app_update(struct net_device *dev) dscp_map = &qos.dscp.map; pcp_map = &qos.pcp.map; +/* Get default prio. */ + qos.default_prio =dcb_ieee_getapp_default_prio_mask (dev); +if (qos.default_prio) + qos.default_prio =fls (qos.default_prio) -1 ; +/* Get dscp ingress mapping */ for (i =0 ; i <ARRAY_SIZE (dscp_map->map); i++) { app_itr.selector =IEEE_8021QAZ_APP_SEL_DSCP ;
drivers/net/ethernet/microchip/sparx5/sparx5_port.c +23 -0
@@ -1151,6 +1151,7 @@ int sparx5_port_qos_set(struct sparx5_port *port, {sparx5_port_qos_dscp_set (port, &qos->dscp);sparx5_port_qos_pcp_set (port, &qos->pcp); +sparx5_port_qos_default_set (port, qos);return 0 ; }
@@ -1220,3 +1221,25 @@ int sparx5_port_qos_dscp_set(const struct sparx5_port *port,return 0 ; } + +int sparx5_port_qos_default_set (const struct sparx5_port *port, +const struct sparx5_port_qos *qos) +{ +struct sparx5 *sparx5 = port->sparx5; + +/* Set default prio and dp level */ +spx5_rmw (ANA_CL_QOS_CFG_DEFAULT_QOS_VAL_SET (qos->default_prio) | +ANA_CL_QOS_CFG_DEFAULT_DP_VAL_SET (0 ), +ANA_CL_QOS_CFG_DEFAULT_QOS_VAL | +ANA_CL_QOS_CFG_DEFAULT_DP_VAL , + sparx5,ANA_CL_QOS_CFG (port->portno)); + +/* Set default pcp and dei for untagged frames */ +spx5_rmw (ANA_CL_VLAN_CTRL_PORT_PCP_SET (0 ) | +ANA_CL_VLAN_CTRL_PORT_DEI_SET (0 ), +ANA_CL_VLAN_CTRL_PORT_PCP | +ANA_CL_VLAN_CTRL_PORT_DEI , + sparx5,ANA_CL_VLAN_CTRL (port->portno)); + +return 0 ; +}
drivers/net/ethernet/microchip/sparx5/sparx5_port.h +5 -0
@@ -119,6 +119,7 @@ struct sparx5_port_qos_dscp {struct sparx5_port_qos {struct sparx5_port_qos_pcp pcp;struct sparx5_port_qos_dscp dscp; +u8 default_prio; };int sparx5_port_qos_set (struct sparx5_port *port,struct sparx5_port_qos *qos);
@@ -128,4 +129,8 @@ int sparx5_port_qos_pcp_set(const struct sparx5_port *port,int sparx5_port_qos_dscp_set (const struct sparx5_port *port,struct sparx5_port_qos_dscp *qos); + +int sparx5_port_qos_default_set (const struct sparx5_port *port, +const struct sparx5_port_qos *qos); +#endif /* __SPARX5_PORT_H__ */
Signature · 1 line
2.34.1
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Tue, 1 Nov 2022 10:48:28 +0100 you wrote:
This patch series adds new extension attributes to dcbnl, to support PCP prioritization (and thereby hw offloadable pcp-based queue classification) and per-selector trust and trust order. Additionally, the microchip sparx5 driver has been dcb-enabled to make use of the new attributes to offload PCP, DSCP and Default prio to the switch, and implement trust order of selectors.
[...]
Here is the summary with links:
- [net-next,v6,1/6] net: dcb: add new pcp selector to app object
https://git.kernel.org/netdev/net-next/c/ec32c0c42d0a - [net-next,v6,2/6] net: dcb: add new apptrust attribute https://git.kernel.org/netdev/net-next/c/6182d5875c33 - [net-next,v6,3/6] net: microchip: sparx5: add support for offloading pcp table https://git.kernel.org/netdev/net-next/c/92ef3d011e17 - [net-next,v6,4/6] net: microchip: sparx5: add support for apptrust https://git.kernel.org/netdev/net-next/c/23f8382cd95d - [net-next,v6,5/6] net: microchip: sparx5: add support for offloading dscp table https://git.kernel.org/netdev/net-next/c/8dcf69a64118 - [net-next,v6,6/6] net: microchip: sparx5: add support for offloading default prio https://git.kernel.org/netdev/net-next/c/c58ff3ed432d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html