qdisc RED offload
Subsystems (17)
Jiri Pirko
maintainercover qdisc RED offload
From: Jiri Pirko <[email protected]>
Nogah says:
Add an offload support for RED qdisc for mlxsw driver.
The first patch adds the ability to offload RED qdisc by using ndo_setup_tc. It gives RED three commands, to offload, change or delete the qdisc, to get the qdisc generic stats and to get it's RED xstats. There is no enforcement on a driver to offload or not offload the qdisc and it is up to the driver to decide.
RED qdisc is first being created and only later graft to a parent (unless it is a root qdisc). For that reason the return value of the offload replace command that is called in the init process doesn't reflect actual offload state. The offload state is determined in the dump function so it can be reflected to the user. This function is also responsible for stats update.
The patchses 2-3 change the name of TC_SETUP_MQPRIO & TC_SETUP_CBS to match with the new convention of QDISC prefix.
The rest of the patchset is driver support for the qdisc. Currently only as root qdisc that is being set on the default traffic class. It supports only the following parameters of RED: min, max, probability and ECN mode. Limit and burst size related params are being ignored at this moment.
---v7->v8 internal: (external RFC->v1)
- patch 1/9:
- unite the offload and un-offload functions
- clean the OFFLOAD flag when the qdisc in not offloaded
- patch 2/9:
- minor change to avoid a conflict
- patch 5/9:
- check for bad min/max values
- clean the offloaded qdisc after a bad config call
Nogah Frankel (8):
net_sch: red: Add offload ability to RED qdisc
net_sch: mqprio: Change TC_SETUP_MQPRIO to TC_SETUP_QDISC_MQPRIO
net_sch: cbs: Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS
mlxsw: reg: Add cwtp & cwtpm registers
mlxsw: spectrum: Support RED qdisc offload
mlxsw: spectrum: Collect tclass related stats periodically
mlxsw: spectrum: Support RED xstats
mlxsw: spectrum: Support general qdisc stats
Yuval Mintz (1):
mlxsw: reg: Add ext and tc-cong counter groups
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/igb/igb_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/Makefile | 3 +- drivers/net/ethernet/mellanox/mlxsw/reg.h | 206 +++++++++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 36 +++ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 38 +++ .../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 276 +++++++++++++++++++++ drivers/net/ethernet/sfc/falcon/tx.c | 2 +- drivers/net/ethernet/sfc/tx.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- include/linux/netdevice.h | 5 +- include/net/pkt_cls.h | 30 +++ include/uapi/linux/pkt_sched.h | 1 + net/sched/sch_cbs.c | 4 +- net/sched/sch_mqprio.c | 5 +- net/sched/sch_red.c | 79 ++++++ 25 files changed, 690 insertions(+), 21 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 1/9 net_sch: red: Add offload ability to RED qdisc
From: Nogah Frankel <[email protected]>
Add the ability to offload RED qdisc by using ndo_setup_tc. There are four commands for RED offloading:
* TC_RED_SET: handles set and change.
* TC_RED_DESTROY: handle qdisc destroy.
* TC_RED_STATS: update the qdiscs counters (given as reference)
* TC_RED_XSTAT: returns red xstats.
Whether RED is being offloaded is being determined every time dump action is being called because parent change of this qdisc could change its offload state but doesn't require any RED function to be called.
--- include/linux/netdevice.h | 1 + include/net/pkt_cls.h | 30 ++++++++++++++++ include/uapi/linux/pkt_sched.h | 1 + net/sched/sch_red.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+)
include/linux/netdevice.h +1 -0
@@ -777,6 +777,7 @@ enum tc_setup_type {TC_SETUP_CLSBPF ,TC_SETUP_BLOCK ,TC_SETUP_CBS , + TC_SETUP_QDISC_RED, };/* These structures hold the attributes of bpf state that are being passed
include/net/pkt_cls.h +30 -0
@@ -703,4 +703,34 @@ struct tc_cookie {u8 *data; u32 len; }; + +enum tc_red_command { +TC_RED_REPLACE , +TC_RED_DESTROY , +TC_RED_STATS , +TC_RED_XSTATS , +}; + +struct tc_red_qopt_offload_params { +u32 min; +u32 max; +u32 probability; +bool is_ecn; +}; +struct tc_red_qopt_offload_stats { +struct gnet_stats_basic_packed *bstats; +struct gnet_stats_queue *qstats; +}; + +struct tc_red_qopt_offload { +enum tc_red_command command; +u32 handle; +u32 parent; +union { +struct tc_red_qopt_offload_params set; +struct tc_red_qopt_offload_stats stats; +struct red_stats *xstats; + }; +}; +#endif
include/uapi/linux/pkt_sched.h +1 -0
@@ -256,6 +256,7 @@ struct tc_red_qopt {#define TC_RED_ECN 1#define TC_RED_HARDDROP 2#define TC_RED_ADAPTATIVE 4 +#define TC_RED_OFFLOADED 8 };struct tc_red_xstats {
net/sched/sch_red.c +79 -0
128 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 2/9 net_sch: mqprio: Change TC_SETUP_MQPRIO to TC_SETUP_QDISC_MQPRIO
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Change TC_SETUP_MQPRIO to TC_SETUP_QDISC_MQPRIO to match the new convention.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/sfc/falcon/tx.c | 2 +- drivers/net/ethernet/sfc/tx.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- include/linux/netdevice.h | 2 +- net/sched/sch_mqprio.c | 5 +++-- 15 files changed, 17 insertions(+), 16 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +1 -1
@@ -2206,7 +2206,7 @@ static int xgbe_setup_tc(struct net_device *netdev, enum tc_setup_type type,struct tc_mqprio_qopt *mqprio = type_data;u8 tc; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
@@ -4289,7 +4289,7 @@ int __bnx2x_setup_tc(struct net_device *dev, enum tc_setup_type type, {struct tc_mqprio_qopt *mqprio = type_data; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -7388,7 +7388,7 @@ static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK :return bnxt_setup_tc_block (dev, type_data); -case TC_SETUP_MQPRIO : { +case TC_SETUP_QDISC_MQPRIO : {struct tc_mqprio_qopt *mqprio = type_data; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +1 -1
@@ -351,7 +351,7 @@ static int dpaa_setup_tc(struct net_device *net_dev, enum tc_setup_type type,u8 num_tc;int i; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +1 -1
@@ -1252,7 +1252,7 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)static int hns3_nic_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ;return hns3_setup_tc (dev, type_data);
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +1 -1
@@ -1389,7 +1389,7 @@ static int __fm10k_setup_tc(struct net_device *dev, enum tc_setup_type type, {struct tc_mqprio_qopt *mqprio = type_data; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -7550,7 +7550,7 @@ static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type, void *type_data) {switch (type) { -case TC_SETUP_MQPRIO : +case TC_SETUP_QDISC_MQPRIO :return i40e_setup_tc (netdev, type_data);case TC_SETUP_BLOCK :return i40e_setup_tc_block (netdev, type_data);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
@@ -9431,7 +9431,7 @@ static int __ixgbe_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK :return ixgbe_setup_tc_block (dev, type_data); -case TC_SETUP_MQPRIO : +case TC_SETUP_QDISC_MQPRIO :return ixgbe_setup_tc_mqprio (dev, type_data);default :return -EOPNOTSUPP ;
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
@@ -135,7 +135,7 @@ static int __mlx4_en_setup_tc(struct net_device *dev, enum tc_setup_type type, {struct tc_mqprio_qopt *mqprio = type_data; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ;if (mqprio->num_tc && mqprio->num_tc !=MLX4_EN_NUM_UP_HIGH )
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -3146,7 +3146,7 @@ int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,case TC_SETUP_BLOCK :return mlx5e_setup_tc_block (dev, type_data);#endif -case TC_SETUP_MQPRIO : +case TC_SETUP_QDISC_MQPRIO :return mlx5e_setup_tc_mqprio (dev, type_data);default :return -EOPNOTSUPP ;
drivers/net/ethernet/sfc/falcon/tx.c +1 -1
@@ -435,7 +435,7 @@ int ef4_setup_tc(struct net_device *net_dev, enum tc_setup_type type,unsigned tc, num_tc;int rc; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; num_tc = mqprio->num_tc;
drivers/net/ethernet/sfc/tx.c +1 -1
@@ -663,7 +663,7 @@ int efx_setup_tc(struct net_device *net_dev, enum tc_setup_type type,unsigned tc, num_tc;int rc; -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; num_tc = mqprio->num_tc;
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -1887,7 +1887,7 @@ static int netcp_setup_tc(struct net_device *dev, enum tc_setup_type type,/* setup tc must be called under rtnl lock */ ASSERT_RTNL (); -if (type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
include/linux/netdevice.h +1 -1
@@ -770,7 +770,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, struct sk_buff *skb);enum tc_setup_type { -TC_SETUP_MQPRIO , +TC_SETUP_QDISC_MQPRIO ,TC_SETUP_CLSU32 ,TC_SETUP_CLSFLOWER ,TC_SETUP_CLSMATCHALL ,
net/sched/sch_mqprio.c +3 -2
@@ -50,7 +50,8 @@ static void mqprio_destroy(struct Qdisc *sch)switch (priv->mode) {case TC_MQPRIO_MODE_DCB :case TC_MQPRIO_MODE_CHANNEL : - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , + dev->netdev_ops->ndo_setup_tc (dev, +TC_SETUP_QDISC_MQPRIO , &mqprio);break ;default :
@@ -265,7 +266,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)return -EINVAL ; } err = dev->netdev_ops->ndo_setup_tc (dev, -TC_SETUP_MQPRIO , +TC_SETUP_QDISC_MQPRIO , &mqprio);if (err)return err;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 3/9 net_sch: cbs: Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS to match the new convention..
--- drivers/net/ethernet/intel/igb/igb_main.c | 2 +- include/linux/netdevice.h | 2 +- net/sched/sch_cbs.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +1 -1
@@ -2488,7 +2488,7 @@ static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,struct igb_adapter *adapter =netdev_priv (dev);switch (type) { -case TC_SETUP_CBS : +case TC_SETUP_QDISC_CBS :return igb_offload_cbs (adapter, type_data);default :
include/linux/netdevice.h +1 -1
@@ -776,7 +776,7 @@ enum tc_setup_type {TC_SETUP_CLSMATCHALL ,TC_SETUP_CLSBPF ,TC_SETUP_BLOCK , -TC_SETUP_CBS , +TC_SETUP_QDISC_CBS , TC_SETUP_QDISC_RED, };
net/sched/sch_cbs.c +2 -2
@@ -212,7 +212,7 @@ static void cbs_disable_offload(struct net_device *dev, cbs.queue = q->queue; cbs.enable =0 ; - err = ops->ndo_setup_tc (dev,TC_SETUP_CBS , &cbs); + err = ops->ndo_setup_tc (dev,TC_SETUP_QDISC_CBS , &cbs);if (err <0 )pr_warn ("Couldn't disable CBS offload for queue %d\n" , cbs.queue);
@@ -236,7 +236,7 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q, cbs.idleslope = opt->idleslope; cbs.sendslope = opt->sendslope; - err = ops->ndo_setup_tc (dev,TC_SETUP_CBS , &cbs); + err = ops->ndo_setup_tc (dev,TC_SETUP_QDISC_CBS , &cbs);if (err <0 )return err;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 4/9 mlxsw: reg: Add cwtp & cwtpm registers
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
This patch adds 2 new registers:
- Congestion WRED ECN TClass Profile Register [CWTP]
- Congestion WRED ECN TClass and Pool Mapping Register [CWTPM]
These registers would later be needed to offload RED-related functionality to the HW.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 187 ++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +187 -0
@@ -1758,6 +1758,191 @@ static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port, } } +/* CWTP - Congetion WRED ECN TClass Profile +* ---------------------------------------- +* Configures the profiles for queues of egress port and traffic class +*/ +#define MLXSW_REG_CWTP_ID 0x2802 +#define MLXSW_REG_CWTP_BASE_LEN 0x28 +#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08 +#define MLXSW_REG_CWTP_LEN 0x40 + +MLXSW_REG_DEFINE (cwtp,MLXSW_REG_CWTP_ID ,MLXSW_REG_CWTP_LEN ); + +/* reg_cwtp_local_port +* Local port number +* Not supported for CPU port +* Access: Index +*/ +MLXSW_ITEM32 (reg, cwtp, local_port,0 ,16 ,8 ); + +/* reg_cwtp_traffic_class +* Traffic Class to configure +* Access: Index +*/ +MLXSW_ITEM32 (reg, cwtp, traffic_class,32 ,0 ,8 ); + +/* reg_cwtp_profile_min +* Minimum Average Queue Size of the profile in cells. +* Access: RW +*/ +MLXSW_ITEM32_INDEXED (reg, cwtp, profile_min,MLXSW_REG_CWTP_BASE_LEN , +0 ,20 ,MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN ,0 , false); + +/* reg_cwtp_profile_percent +* Percentage of WRED and ECN marking for maximum Average Queue size +* Range is 0 to 100, units of integer percentage +* Access: RW +*/ +MLXSW_ITEM32_INDEXED (reg, cwtp, profile_percent,MLXSW_REG_CWTP_BASE_LEN , +24 ,7 ,MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN ,4 , false); + +/* reg_cwtp_profile_max +* Maximum Average Queue size of the profile in cells +* Access: RW +*/ +MLXSW_ITEM32_INDEXED (reg, cwtp, profile_max,MLXSW_REG_CWTP_BASE_LEN , +0 ,20 ,MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN ,4 , false); + +#define MLXSW_REG_CWTP_MIN_VALUE 64 +#define MLXSW_REG_CWTP_MAX_PROFILE 2 +#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1 + +static inline void mlxsw_reg_cwtp_pack (char *payload,u8 local_port, +u8 traffic_class) +{ +int i; + +MLXSW_REG_ZERO (cwtp, payload); +mlxsw_reg_cwtp_local_port_set (payload, local_port); +mlxsw_reg_cwtp_traffic_class_set (payload, traffic_class); + +for (i =0 ; i <=MLXSW_REG_CWTP_MAX_PROFILE ; i++) { +mlxsw_reg_cwtp_profile_min_set (payload, i, +MLXSW_REG_CWTP_MIN_VALUE ); +mlxsw_reg_cwtp_profile_max_set (payload, i, +MLXSW_REG_CWTP_MIN_VALUE ); + } +} + +#define MLXSW_REG_CWTP_PROFILE_TO_INDEX (profile) (profile - 1) + +static inline void +mlxsw_reg_cwtp_profile_pack (char *payload,u8 profile,u32 min,u32 max, +u32 probability) +{ +u8 index =MLXSW_REG_CWTP_PROFILE_TO_INDEX (profile); + +mlxsw_reg_cwtp_profile_min_set (payload, index, min); +mlxsw_reg_cwtp_profile_max_set (payload, index, max); +mlxsw_reg_cwtp_profile_percent_set (payload, index, probability); +} + +/* CWTPM - Congestion WRED ECN TClass and Pool Mapping +* --------------------------------------------------- +* The CWTPM register maps each egress port and traffic class to profile num. +*/ +#define MLXSW_REG_CWTPM_ID 0x2803 +#define MLXSW_REG_CWTPM_LEN 0x44 + +MLXSW_REG_DEFINE (cwtpm,MLXSW_REG_CWTPM_ID ,MLXSW_REG_CWTPM_LEN ); + +/* reg_cwtpm_local_port +* Local port number +* Not supported for CPU port +* Access: Index +*/ +MLXSW_ITEM32 (reg, cwtpm, local_port,0 ,16 ,8 ); + +/* reg_cwtpm_traffic_class +* Traffic Class to configure +* Access: Index +*/ +MLXSW_ITEM32 (reg, cwtpm, traffic_class,32 ,0 ,8 ); + +/* reg_cwtpm_ew +* Control enablement of WRED for traffic class: +* 0 - Disable +* 1 - Enable +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, ew,36 ,1 ,1 ); + +/* reg_cwtpm_ee +* Control enablement of ECN for traffic class: +* 0 - Disable +* 1 - Enable +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, ee,36 ,0 ,1 ); + +/* reg_cwtpm_tcp_g +* TCP Green Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, tcp_g,52 ,0 ,2 ); + +/* reg_cwtpm_tcp_y +* TCP Yellow Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, tcp_y,56 ,16 ,2 ); + +/* reg_cwtpm_tcp_r +* TCP Red Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, tcp_r,56 ,0 ,2 ); + +/* reg_cwtpm_ntcp_g +* Non-TCP Green Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, ntcp_g,60 ,0 ,2 ); + +/* reg_cwtpm_ntcp_y +* Non-TCP Yellow Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, ntcp_y,64 ,16 ,2 ); + +/* reg_cwtpm_ntcp_r +* Non-TCP Red Profile. +* Index of the profile within {port, traffic class} to use. +* 0 for disabling both WRED and ECN for this type of traffic. +* Access: RW +*/ +MLXSW_ITEM32 (reg, cwtpm, ntcp_r,64 ,0 ,2 ); + +#define MLXSW_REG_CWTPM_RESET_PROFILE 0 + +static inline void mlxsw_reg_cwtpm_pack (char *payload,u8 local_port, +u8 traffic_class,u8 profile, +bool wred,bool ecn) +{ +MLXSW_REG_ZERO (cwtpm, payload); +mlxsw_reg_cwtpm_local_port_set (payload, local_port); +mlxsw_reg_cwtpm_traffic_class_set (payload, traffic_class); +mlxsw_reg_cwtpm_ew_set (payload, wred); +mlxsw_reg_cwtpm_ee_set (payload, ecn); +mlxsw_reg_cwtpm_tcp_g_set (payload, profile); +mlxsw_reg_cwtpm_tcp_y_set (payload, profile); +mlxsw_reg_cwtpm_tcp_r_set (payload, profile); +mlxsw_reg_cwtpm_ntcp_g_set (payload, profile); +mlxsw_reg_cwtpm_ntcp_y_set (payload, profile); +mlxsw_reg_cwtpm_ntcp_r_set (payload, profile); +} +/* PPBT - Policy-Engine Port Binding Table * --------------------------------------- * This register is used for configuration of the Port Binding Table.
@@ -7405,6 +7590,8 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (svpe),MLXSW_REG (sfmr),MLXSW_REG (spvmlr), +MLXSW_REG (cwtp), +MLXSW_REG (cwtpm),MLXSW_REG (ppbt),MLXSW_REG (pacl), MLXSW_REG(pagt),
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 5/9 mlxsw: spectrum: Support RED qdisc offload
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Add support for ndo_setup_tc with enum tc_setup_type value of TC_SETUP_RED. This call sets RED qdisc on a traffic class.
This patch supports RED qdisc only as a root qdisc and set in on the default tclass. It can be set with or without ECN.
--- drivers/net/ethernet/mellanox/mlxsw/Makefile | 3 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 + drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 15 ++ .../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 174 +++++++++++++++++++++ 4 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
drivers/net/ethernet/mellanox/mlxsw/Makefile +2 -1
@@ -19,7 +19,8 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ spectrum_acl.o spectrum_flower.o \ spectrum_cnt.o spectrum_fid.o \ spectrum_ipip.o spectrum_acl_flex_actions.o \ - spectrum_mr.o spectrum_mr_tcam.o + spectrum_mr.o spectrum_mr_tcam.o \ + spectrum_qdisc.o mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o mlxsw_spectrum-$(CONFIG_NET_DEVLINK) += spectrum_dpipe.o obj-$(CONFIG_MLXSW_MINIMAL) += mlxsw_minimal.o
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -0
@@ -1797,6 +1797,8 @@ static int mlxsw_sp_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK :return mlxsw_sp_setup_tc_block (mlxsw_sp_port, type_data); +case TC_SETUP_QDISC_RED : +return mlxsw_sp_setup_tc_red (mlxsw_sp_port, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +15 -0
@@ -203,6 +203,16 @@ struct mlxsw_sp_port_vlan {struct list_head bridge_vlan_node; }; +enum mlxsw_sp_qdisc_type { +MLXSW_SP_QDISC_NO_QDISC , +MLXSW_SP_QDISC_RED , +}; + +struct mlxsw_sp_qdisc { +u32 handle; +enum mlxsw_sp_qdisc_type type; +}; +struct mlxsw_sp_port {struct net_device *dev;struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
@@ -236,6 +246,7 @@ struct mlxsw_sp_port { } periodic_hw_stats;struct mlxsw_sp_port_sample *sample;struct list_head vlans_list; +struct mlxsw_sp_qdisc root_qdisc; }; static inline bool
@@ -546,6 +557,10 @@ void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,int mlxsw_sp_flower_stats (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress,struct tc_cls_flower_offload *f); +/* spectrum_qdisc.c */ +int mlxsw_sp_setup_tc_red (struct mlxsw_sp_port *mlxsw_sp_port, +struct tc_red_qopt_offload *p); +/* spectrum_fid.c */ int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_flood_type packet_type, u8 local_port,
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 6/9 mlxsw: reg: Add ext and tc-cong counter groups
In reply to Jiri PirkoFrom: Yuval Mintz <[email protected]>
This adds the counter group definitions for 2 new counter groups which are necessary for gaining ECN & wred counters.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +19 -0
@@ -3341,8 +3341,10 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);enum mlxsw_reg_ppcnt_grp {MLXSW_REG_PPCNT_IEEE_8023_CNT =0x0 , +MLXSW_REG_PPCNT_EXT_CNT =0x5 ,MLXSW_REG_PPCNT_PRIO_CNT =0x10 ,MLXSW_REG_PPCNT_TC_CNT =0x11 , +MLXSW_REG_PPCNT_TC_CONG_TC =0x13 , };/* reg_ppcnt_grp
@@ -3358,6 +3360,7 @@ enum mlxsw_reg_ppcnt_grp {* 0x10: Per Priority Counters * 0x11: Per Traffic Class Counters * 0x12: Physical Layer Counters +* 0x13: Per Traffic Class Congestion Counters * Access: Index */ MLXSW_ITEM32 (reg, ppcnt, grp,0x00 ,0 ,6 );
@@ -3496,6 +3499,14 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,MLXSW_ITEM64 (reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,MLXSW_REG_PPCNT_COUNTERS_OFFSET +0x90 ,0 ,64 ); +/* Ethernet Extended Counter Group Counters */ + +/* reg_ppcnt_ecn_marked +* Access: RO +*/ +MLXSW_ITEM64 (reg, ppcnt, ecn_marked, +MLXSW_REG_PPCNT_COUNTERS_OFFSET +0x08 ,0 ,64 ); +/* Ethernet Per Priority Group Counters */ /* reg_ppcnt_rx_octets
@@ -3571,6 +3582,14 @@ MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,MLXSW_ITEM64 (reg, ppcnt, tc_no_buffer_discard_uc,MLXSW_REG_PPCNT_COUNTERS_OFFSET +0x08 ,0 ,64 ); +/* Ethernet Per Traffic Class Congestion Group Counters */ + +/* reg_ppcnt_wred_discard +* Access: RO +*/ +MLXSW_ITEM64 (reg, ppcnt, wred_discard, +MLXSW_REG_PPCNT_COUNTERS_OFFSET +0x00 ,0 ,64 ); +static inline void mlxsw_reg_ppcnt_pack (char *payload,u8 local_port,enum mlxsw_reg_ppcnt_grp grp,u8 prio_tc)
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 7/9 mlxsw: spectrum: Collect tclass related stats periodically
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Add more statistics to be collected from the HW periodically. These stats are tclass based (beside ECN marked packet, that exist only port based). They are needed to expose RED qdisc stats and xstats correctly.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 34 ++++++++++++++++++++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 9 +++++++ 2 files changed, 43 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +34 -0
@@ -1324,6 +1324,38 @@ static int mlxsw_sp_port_get_hw_stats(struct net_device *dev,return err; } +static void +mlxsw_sp_port_get_hw_xstats (struct net_device *dev, +struct mlxsw_sp_port_xstats *xstats) +{ +char ppcnt_pl[MLXSW_REG_PPCNT_LEN ]; +int err, i; + + err =mlxsw_sp_port_get_stats_raw (dev,MLXSW_REG_PPCNT_EXT_CNT ,0 , + ppcnt_pl); +if (!err) + xstats->ecn =mlxsw_reg_ppcnt_ecn_marked_get (ppcnt_pl); + +for (i =0 ; i <TC_MAX_QUEUE ; i++) { + err =mlxsw_sp_port_get_stats_raw (dev, +MLXSW_REG_PPCNT_TC_CONG_TC , + i, ppcnt_pl); +if (!err) + xstats->wred_drop[i] = +mlxsw_reg_ppcnt_wred_discard_get (ppcnt_pl); + + err =mlxsw_sp_port_get_stats_raw (dev,MLXSW_REG_PPCNT_TC_CNT , + i, ppcnt_pl); +if (err) +continue ; + + xstats->backlog[i] = +mlxsw_reg_ppcnt_tc_transmit_queue_get (ppcnt_pl); + xstats->tail_drop[i] = +mlxsw_reg_ppcnt_tc_no_buffer_discard_uc_get (ppcnt_pl); + } +} +static void update_stats_cache (struct work_struct *work) { struct mlxsw_sp_port *mlxsw_sp_port =
@@ -1335,6 +1367,8 @@ static void update_stats_cache(struct work_struct *work)mlxsw_sp_port_get_hw_stats (mlxsw_sp_port->dev, &mlxsw_sp_port->periodic_hw_stats.stats); +mlxsw_sp_port_get_hw_xstats (mlxsw_sp_port->dev, + &mlxsw_sp_port->periodic_hw_stats.xstats); out: mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw,
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +9 -0
@@ -213,6 +213,14 @@ struct mlxsw_sp_qdisc {enum mlxsw_sp_qdisc_type type; }; +/* No need an internal lock; At worse - miss a single periodic iteration */ +struct mlxsw_sp_port_xstats { +u64 ecn; +u64 wred_drop[TC_MAX_QUEUE ]; +u64 tail_drop[TC_MAX_QUEUE ]; +u64 backlog[TC_MAX_QUEUE ]; +}; +struct mlxsw_sp_port {struct net_device *dev;struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
@@ -242,6 +250,7 @@ struct mlxsw_sp_port {struct {#define MLXSW_HW_STATS_UPDATE_TIME HZstruct rtnl_link_stats64 stats; +struct mlxsw_sp_port_xstats xstats;struct delayed_work update_dw; } periodic_hw_stats;struct mlxsw_sp_port_sample *sample;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 8/9 mlxsw: spectrum: Support RED xstats
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Add support for ndo_setup_tc with enum tc_setup_type value of TC_SETUP_RED_XSTATS. This call returns the RED qdisc xstats from the cache if the handle ID that is asked for matching the root qdisc ID and fails otherwise.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 9 ++++ .../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 51 ++++++++++++++++++++++ 2 files changed, 60 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +9 -0
@@ -48,6 +48,7 @@#include <linux/notifier.h> #include <net/psample.h> #include <net/pkt_cls.h> +#include <net/red.h> #include "port.h" #include "core.h"
@@ -211,6 +212,14 @@ enum mlxsw_sp_qdisc_type {struct mlxsw_sp_qdisc {u32 handle;enum mlxsw_sp_qdisc_type type; +struct red_stats xstats_base; +union { +struct { +u64 tail_drop_base; +u64 ecn_base; +u64 wred_drop_base; + } red; + } xstats; };/* No need an internal lock; At worse - miss a single periodic iteration */
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +51 -0
81 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 9/9 mlxsw: spectrum: Support general qdisc stats
In reply to Jiri PirkoFrom: Nogah Frankel <[email protected]>
Add support for ndo_setup_tc with enum tc_setup_type value of TC_SETUP_QDISC_STATS. This call updates the generic qdisc stats from the cache if the handle ID that is asked for matching the root qdisc ID and fails otherwise.
Currently doesn't support qlen and rqueues.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 5 +++ .../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 51 ++++++++++++++++++++++ 2 files changed, 56 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +5 -0
@@ -220,6 +220,11 @@ struct mlxsw_sp_qdisc {u64 wred_drop_base; } red; } xstats; + +u64 tx_bytes; +u64 tx_packets; +u64 drops; +u64 overlimits; };/* No need an internal lock; At worse - miss a single periodic iteration */
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +51 -0
77 lines not on this page · raw message
Signature · 1 line
2.9.5
Re: [patch net-next 1/9] net_sch: red: Add offload ability to RED qdisc
In reply to Jiri PirkoQuoted 9 lines · Jiri Pirko
From: Nogah Frankel <[email protected]>
Add the ability to offload RED qdisc by using
ndo_setup_tc. There are four commands for RED offloading:
*TC_RED_SET: handles set and change.
*TC_RED_DESTROY: handle qdisc destroy.
*TC_RED_STATS: update the qdiscs counters (given as reference)
*TC_RED_XSTAT: returns red xstats.
Quoted 6 lines
Whether RED is being offloaded is being determined every time dump action is being called because parent change of this qdisc could change its offload state but doesn't require any RED function to be called.
Signed-off-by Nogah Frankel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Re: [patch net-next 2/9] net_sch: mqprio: Change TC_SETUP_MQPRIO to TC_SETUP_QDISC_MQPRIO
In reply to Jiri PirkoQuoted 7 lines · Jiri Pirko
From: Nogah Frankel <[email protected]>
Change
TC_SETUP_MQPRIOtoTC_SETUP_QDISC_MQPRIOto match the new convention.Signed-off-by Nogah Frankel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Re: [patch net-next 3/9] net_sch: cbs: Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS
In reply to Jiri PirkoQuoted 6 lines · Jiri Pirko
From: Nogah Frankel <[email protected]>
Change
TC_SETUP_CBStoTC_SETUP_QDISC_CBSto match the new convention..Signed-off-by Nogah Frankel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Re: [patch net-next 3/9] net_sch: cbs: Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS
In reply to Jiri PirkoHi,
Quoted 4 lines · Jiri Pirko
From: Nogah Frankel <[email protected]>
Change
TC_SETUP_CBStoTC_SETUP_QDISC_CBSto match the new convention..
Quoted 8 lines
Signed-off-by Nogah Frankel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 2 +- include/linux/netdevice.h | 2 +- net/sched/sch_cbs.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
Cheers,
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Mon, 6 Nov 2017 07:23:40 +0100
Quoted 17 lines
From: Jiri Pirko <[email protected]>
Nogah says:
Add an offload support for RED qdisc for mlxsw driver.
The first patch adds the ability to offload RED qdisc by usingndo_setup_tc. It gives RED three commands, to offload, change or delete the qdisc, to get the qdisc generic stats and to get it's RED xstats. There is no enforcement on a driver to offload or not offload the qdisc and it is up to the driver to decide.
RED qdisc is first being created and only later graft to a parent (unless it is a root qdisc). For that reason the return value of the offload replace command that is called in the init process doesn't reflect actual offload state. The offload state is determined in the dump function so it can be reflected to the user. This function is also responsible for stats update.
Quoted 6 lines
The patchses 2-3 change the name of
TC_SETUP_MQPRIO&TC_SETUP_CBSto match with the new convention of QDISC prefix.
The rest of the patchset is driver support for the qdisc. Currently only as root qdisc that is being set on the default traffic class. It supports only the following parameters of RED: min, max, probability and ECN mode. Limit and burst size related params are being ignored at this moment.
Series applied, thanks!