octeontx2-pf: HTB offload support
Subsystems (8)
v4 cover octeontx2-pf: HTB offload support
octeontx2 silicon and CN10K transmit interface consists of five transmit levels starting from MDQ, TL4 to TL1. Once packets are submitted to MDQ, hardware picks all active MDQs using strict priority, and MDQs having the same priority level are chosen using round robin. Each packet will traverse MDQ, TL4 to TL1 levels. Each level contains an array of queues to support scheduling and shaping.
As HTB supports classful queuing mechanism by supporting rate and ceil and allow the user to control the absolute bandwidth to particular classes of traffic the same can be achieved by configuring shapers and schedulers on different transmit levels.
This series of patches adds support for HTB offload,
Patch1: Allow strict priority parameter in HTB offload mode.
Patch2: defines APIs such that the driver can dynamically initialize/
deinitialize the send queues.
Patch3: Refactors transmit alloc/free calls as preparation for QOS
offload code.
Patch4: Adds actual HTB offload support.
Hariprasad Kelam (1):
octeontx2-pf: Refactor schedular queue alloc/free calls
Naveen Mamindlapalli (2):
sch_htb: Allow HTB priority parameter in offload mode
octeontx2-pf: Add support for HTB offload
Subbaraya Sundeep (1):
octeontx2-pf: qos send queues management
-----
v1 -> v2 :
ensure other drivers won't affect by allowing 'prio' a parameter in htb offload mode.
v2 -> v3 :
1. discard patch supporting devlink to configure TL1 round robin priority
2. replace NL_SET_ERR_MSG with NL_SET_ERR_MSG_MOD
3. use max3 instead of using max couple of times and use a better naming convention in send queue management code.
v3 -> v4:
1. fix sparse warnings.
2. release mutex lock in error conditions.
2. reuse "dev_reset_queue" instead defining new function.
.../ethernet/marvell/octeontx2/af/common.h | 2 +- .../marvell/octeontx2/af/rvu_debugfs.c | 5 + .../ethernet/marvell/octeontx2/af/rvu_nix.c | 45 + .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 113 +- .../marvell/octeontx2/nic/otx2_common.h | 36 +- .../marvell/octeontx2/nic/otx2_ethtool.c | 31 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 102 +- .../ethernet/marvell/octeontx2/nic/otx2_reg.h | 13 + .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 +- .../marvell/octeontx2/nic/otx2_txrx.c | 25 +- .../marvell/octeontx2/nic/otx2_txrx.h | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 13 +- .../net/ethernet/marvell/octeontx2/nic/qos.c | 1541 +++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/qos.h | 71 + .../ethernet/marvell/octeontx2/nic/qos_sq.c | 304 ++++ .../net/ethernet/mellanox/mlx5/core/en/qos.c | 7 +- include/net/pkt_cls.h | 1 + include/net/sch_generic.h | 2 + net/sched/sch_generic.c | 5 +- net/sched/sch_htb.c | 7 +- 21 files changed, 2239 insertions(+), 96 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
--
2.17.1
PATCH v4 1/4 sch_htb: Allow HTB priority parameter in offload mode
From: Naveen Mamindlapalli <[email protected]>
The current implementation of HTB offload returns the EINVAL error for unsupported parameters like prio and quantum. This patch removes the error returning checks for 'prio' parameter and populates its value to tc_htb_qopt_offload structure such that driver can use the same.
Add prio parameter check in mlx5 driver, as mlx5 devices are not capable of supporting the prio parameter when htb offload is used. Report error if prio parameter is set to a non-default value.
--- drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 7 ++++++- include/net/pkt_cls.h | 1 + net/sched/sch_htb.c | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +6 -1
@@ -379,6 +379,12 @@ int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_if (!htb && htb_qopt->command !=TC_HTB_CREATE )return -EINVAL ; +if (htb_qopt->prio) { +NL_SET_ERR_MSG_MOD (htb_qopt->extack, +"prio parameter is not supported by device with HTB offload enabled." ); +return -EINVAL ; + } +switch (htb_qopt->command) {case TC_HTB_CREATE :if (!mlx5_qos_is_supported (priv->mdev)) {
@@ -515,4 +521,3 @@ int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i *hw_id = rl->leaves_id[tc];return 0 ; } -
include/net/pkt_cls.h +1 -0
@@ -854,6 +854,7 @@ struct tc_htb_qopt_offload {u16 qid;u64 rate;u64 ceil; +u8 prio; };#define TC_HTB_CLASSID_ROOT U32_MAX
net/sched/sch_htb.c +3 -4
@@ -1814,10 +1814,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,NL_SET_ERR_MSG (extack,"HTB offload doesn't support the quantum parameter" ); goto failure; } -if (hopt->prio) { -NL_SET_ERR_MSG (extack,"HTB offload doesn't support the prio parameter" ); - goto failure; - } }/* Keeping backward compatible with rate_table based iproute2 tc */
@@ -1913,6 +1909,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, TC_HTB_CLASSID_ROOT, .rate = max_t(u64, hopt->rate.rate, rate64), .ceil = max_t(u64, hopt->ceil.rate, ceil64), + .prio = hopt->prio, .extack = extack, }; err =htb_offload (dev, &offload_opt);
@@ -1933,6 +1930,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, TC_H_MIN(parent->common.classid), .rate = max_t(u64, hopt->rate.rate, rate64), .ceil = max_t(u64, hopt->ceil.rate, ceil64), + .prio = hopt->prio, .extack = extack, }; err =htb_offload (dev, &offload_opt);
@@ -2018,6 +2016,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, .classid = cl->common.classid, .rate = max_t(u64, hopt->rate.rate, rate64), .ceil = max_t(u64, hopt->ceil.rate, ceil64), + .prio = hopt->prio, .extack = extack, }; err =htb_offload (dev, &offload_opt);
Signature · 1 line
2.17.1
Re: [net-next Patch V4 1/4] sch_htb: Allow HTB priority parameter in offload mode
Quoted 28 lines · Hariprasad Kelam
From: Naveen Mamindlapalli <[email protected]>
The current implementation of HTB offload returns the EINVAL error for unsupported parameters like prio and quantum. This patch removes the error returning checks for 'prio' parameter and populates its value to
tc_htb_qopt_offloadstructure such that driver can use the same.Add prio parameter check in mlx5 driver, as mlx5 devices are not capable of supporting the prio parameter when htb offload is used. Report error if prio parameter is set to a non-default value.
Signed-off-by Naveen Mamindlapalli <[email protected]>Co-developed-by Rahul Rameshbabu <[email protected]>Signed-off-by Rahul Rameshbabu <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 7 ++++++- include/net/pkt_cls.h | 1 + net/sched/sch_htb.c | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_ · line 385
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +4
-0@@ -379,6 +379,12 @@ int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_if (!htb && htb_qopt->command !=TC_HTB_CREATE )return -EINVAL ; +if (htb_qopt->prio) { +NL_SET_ERR_MSG_MOD (htb_qopt->extack, +"prio parameter is not supported by device with HTB offload enabled." ); +return -EINVAL ;
I think returning -EOPNOTSUPP would be more appropriate here.
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i · line 518
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +2
-1+ } +switch (htb_qopt->command) {case TC_HTB_CREATE :if (!mlx5_qos_is_supported (priv->mdev)) {@@ -515,4 +521,3 @@ int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i *hw_id = rl->leaves_id[tc];return 0 ; } -
nit: This is a good cleanup. But not strictly related to this patch.
...
Re: [net-next Patch V4 1/4] sch_htb: Allow HTB priority parameter in offload mode
Quoted 35 lines · Hariprasad Kelam
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_htb_setup_tc(struct mlx5e_priv *priv,
Quoted 28 lines
From: Naveen Mamindlapalli <[email protected]>
The current implementation of HTB offload returns the EINVAL error for unsupported parameters like prio and quantum. This patch removes the error returning checks for 'prio' parameter and populates its value to
tc_htb_qopt_offloadstructure such that driver can use the same.Add prio parameter check in mlx5 driver, as mlx5 devices are not capable of supporting the prio parameter when htb offload is used. Report error if prio parameter is set to a non-default value.
Signed-off-by Naveen Mamindlapalli <[email protected]>Co-developed-by Rahul Rameshbabu <[email protected]>Signed-off-by Rahul Rameshbabu <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 7 ++++++- include/net/pkt_cls.h | 1 + net/sched/sch_htb.c | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +0
-0@@ -379,6 +379,12 @@ int mlx5e_htb_setup_tc(struct mlx5e_priv *priv,struct
tc_htb_qopt_offload*htb_Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +0
-0if (!htb && htb_qopt->command !=TC_HTB_CREATE )return -EINVAL ;
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +3
-0+if (htb_qopt->prio) { + NL_SET_ERR_MSG_MOD(htb_qopt->extack, + "prio parameter is not supported by devicewith HTB offload enabled.");
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_ · line 385
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +1
-0+return -EINVAL ;I think returning
-EOPNOTSUPPwould be more appropriate here.
ACK, will fix in next version.
Thanks,
Hariprasad k
Quoted 17 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb_
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +2
-0+ } +switch (htb_qopt->command) {case TC_HTB_CREATE : if (!mlx5_qos_is_supported(priv->mdev)) { @@ -515,4+521,3 @@ int
Quoted 1 line
mlx5e_mqprio_rl_get_node_hw_id(struct
mlx5e_mqprio_rl*rl, int tc, u32
*hw_idrivers/net/ethernet/mellanox/mlx5/core/en/qos.c int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i · line 518
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +0
-1*hw_id = rl->leaves_id[tc];return 0 ; } -nit: This is a good cleanup. But not strictly related to this patch.
...
PATCH v4 2/4 octeontx2-pf: qos send queues management
In reply to Hariprasad KelamFrom: Subbaraya Sundeep <[email protected]>
Current implementation is such that the number of Send queues (SQs) are decided on the device probe which is equal to the number of online cpus. These SQs are allocated and deallocated in interface open and c lose calls respectively.
This patch defines new APIs for initializing and deinitializing Send queues dynamically and allocates more number of transmit queues for QOS feature.
--- .../marvell/octeontx2/af/rvu_debugfs.c | 5 + .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 40 ++- .../marvell/octeontx2/nic/otx2_common.h | 29 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 51 ++- .../marvell/octeontx2/nic/otx2_txrx.c | 25 +- .../marvell/octeontx2/nic/otx2_txrx.h | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 9 +- .../net/ethernet/marvell/octeontx2/nic/qos.h | 19 ++ .../ethernet/marvell/octeontx2/nic/qos_sq.c | 290 ++++++++++++++++++ 10 files changed, 430 insertions(+), 43 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +5 -0
@@ -1224,6 +1224,11 @@ static int rvu_dbg_npa_ctx_display(struct seq_file *m, void *unused, int ctype)for (aura = id; aura < max_id; aura++) { aq_req.aura_id = aura; + +/* Skip if queue is uninitialized */ +if (ctype ==NPA_AQ_CTYPE_POOL && !test_bit (aura, pfvf->pool_bmap)) +continue ; +seq_printf (m,"======%s : %d=======\n" , (ctype ==NPA_AQ_CTYPE_AURA ) ?"AURA" :"POOL" , aq_req.aura_id);
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-$(CONFIG_OCTEONTX2_VF) += rvu_nicvf.o otx2_ptp.o rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ otx2_flows.o otx2_tc.o cn10k.o otx2_dmac_flt.o \ - otx2_devlink.o + otx2_devlink.o qos_sq.o rvu_nicvf-y := otx2_vf.o otx2_devlink.o rvu_nicpf-$(CONFIG_DCB) += otx2_dcbnl.o
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +26 -14
@@ -758,11 +758,15 @@ int otx2_txschq_stop(struct otx2_nic *pfvf)void otx2_sqb_flush (struct otx2_nic *pfvf) {int qidx, sqe_tail, sqe_head; +struct otx2_snd_queue *sq;u64 incr, *ptr, val;int timeout =1000 ; ptr = (u64 *)otx2_get_regaddr (pfvf,NIX_LF_SQ_OP_STATUS ); -for (qidx =0 ; qidx < pfvf->hw.tot_tx_queues; qidx++) { +for (qidx =0 ; qidx <otx2_get_total_tx_queues (pfvf); qidx++) { + sq = &pfvf->qset.sq[qidx]; +if (!sq->sqb_ptrs) +continue ; incr = (u64 )qidx <<32 ;while (timeout) { val =otx2_atomic64_add (incr, ptr);
@@ -862,7 +866,7 @@ int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)return otx2_sync_mbox_msg (&pfvf->mbox); } -static int otx2_sq_init (struct otx2_nic *pfvf,u16 qidx,u16 sqb_aura) +int otx2_sq_init (struct otx2_nic *pfvf,u16 qidx,u16 sqb_aura) {struct otx2_qset *qset = &pfvf->qset;struct otx2_snd_queue *sq;
@@ -935,9 +939,17 @@ static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) cq->cint_idx = qidx - pfvf->hw.rx_queues; cq->cqe_cnt = qset->sqe_cnt; }else { - cq->cq_type =CQ_XDP ; - cq->cint_idx = qidx - non_xdp_queues; - cq->cqe_cnt = qset->sqe_cnt; +if (pfvf->hw.xdp_queues && + qidx < non_xdp_queues + pfvf->hw.xdp_queues) { + cq->cq_type =CQ_XDP ; + cq->cint_idx = qidx - non_xdp_queues; + cq->cqe_cnt = qset->sqe_cnt; + }else { + cq->cq_type =CQ_QOS ; + cq->cint_idx = qidx - non_xdp_queues - + pfvf->hw.xdp_queues; + cq->cqe_cnt = qset->sqe_cnt; + } } cq->cqe_size = pfvf->qset.xqe_size;
@@ -1048,7 +1060,7 @@ int otx2_config_nix_queues(struct otx2_nic *pfvf) }/* Initialize TX queues */ -for (qidx =0 ; qidx < pfvf->hw.tot_tx_queues; qidx++) { +for (qidx =0 ; qidx < pfvf->hw.non_qos_queues; qidx++) {u16 sqb_aura =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx); err =otx2_sq_init (pfvf, qidx, sqb_aura);
@@ -1095,7 +1107,7 @@ int otx2_config_nix(struct otx2_nic *pfvf)/* Set RQ/SQ/CQ counts */ nixlf->rq_cnt = pfvf->hw.rx_queues; - nixlf->sq_cnt = pfvf->hw.tot_tx_queues; + nixlf->sq_cnt =otx2_get_total_tx_queues (pfvf); nixlf->cq_cnt = pfvf->qset.cq_cnt; nixlf->rss_sz =MAX_RSS_INDIR_TBL_SIZE ; nixlf->rss_grps =MAX_RSS_GROUPS ;
@@ -1133,7 +1145,7 @@ void otx2_sq_free_sqbs(struct otx2_nic *pfvf)int sqb, qidx;u64 iova, pa; -for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { +for (qidx =0 ; qidx <otx2_get_total_tx_queues (pfvf); qidx++) { sq = &qset->sq[qidx];if (!sq->sqb_ptrs)continue ;
@@ -1201,8 +1213,8 @@ void otx2_aura_pool_free(struct otx2_nic *pfvf) pfvf->qset.pool =NULL ; } -static int otx2_aura_init (struct otx2_nic *pfvf,int aura_id, -int pool_id,int numptrs) +int otx2_aura_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs) {struct npa_aq_enq_req *aq;struct otx2_pool *pool;
@@ -1278,8 +1290,8 @@ static int otx2_aura_init(struct otx2_nic *pfvf, int aura_id,return 0 ; } -static int otx2_pool_init (struct otx2_nic *pfvf,u16 pool_id, -int stack_pages,int numptrs,int buf_size) +int otx2_pool_init (struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size) {struct npa_aq_enq_req *aq;struct otx2_pool *pool;
@@ -1349,7 +1361,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) stack_pages = (num_sqbs + hw->stack_pg_ptrs -1 ) / hw->stack_pg_ptrs; -for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { +for (qidx =0 ; qidx < hw->non_qos_queues; qidx++) { pool_id =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx);/* Initialize aura context */ err =otx2_aura_init (pfvf, pool_id, pool_id, num_sqbs);
@@ -1369,7 +1381,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) goto fail;/* Allocate pointers and free them to aura/pool */ -for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { +for (qidx =0 ; qidx < hw->non_qos_queues; qidx++) { pool_id =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx); pool = &pfvf->qset.pool[pool_id];
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +27 -2
@@ -27,6 +27,7 @@#include "otx2_txrx.h" #include "otx2_devlink.h" #include <rvu_trace.h> +#include "qos.h" /* IPv4 flag more fragment bit */ #define IPV4_FLAG_MORE 0x20
@@ -189,7 +190,8 @@ struct otx2_hw {u16 rx_queues;u16 tx_queues;u16 xdp_queues; -u16 tot_tx_queues; +u16 tc_tx_queues; +u16 non_qos_queues;/* tx_queues plus xdp_tx_queues */ u16 max_queues;u16 pool_cnt;u16 rqpool_cnt;
@@ -501,6 +503,8 @@ struct otx2_nic {u16 pfc_schq_list[NIX_TXSCH_LVL_CNT ][MAX_TXSCHQ_PER_FUNC ];bool pfc_alloc_status[NIX_PF_PFC_PRIO_MAX ];#endif +/* qos */ +struct otx2_qos qos;/* napi event count. It is needed for adaptive irq coalescing. */ u32 napi_events;
@@ -888,12 +892,24 @@ static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf,static inline u16 otx2_get_smq_idx (struct otx2_nic *pfvf,u16 qidx) { +u16 smq; +#ifdef CONFIG_DCB if (qidx <NIX_PF_PFC_PRIO_MAX && pfvf->pfc_alloc_status[qidx])return pfvf->pfc_schq_list[NIX_TXSCH_LVL_SMQ ][qidx];#endif +/* check if qidx falls under QOS queues */ +if (qidx >= pfvf->hw.non_qos_queues) + smq = pfvf->qos.qid_to_sqmap[qidx - pfvf->hw.non_qos_queues]; +else + smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ ][0 ]; + +return smq; +} -return pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ ][0 ]; +static inline u16 otx2_get_total_tx_queues (struct otx2_nic *pfvf) +{ +return pfvf->hw.non_qos_queues + pfvf->hw.tc_tx_queues; }/* MSI-X APIs */
@@ -928,11 +944,16 @@ int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable);void otx2_ctx_disable (struct mbox *mbox,int type,bool npa);int otx2_nix_config_bp (struct otx2_nic *pfvf,bool enable);void otx2_cleanup_rx_cqes (struct otx2_nic *pfvf,struct otx2_cq_queue *cq); +int otx2_sq_init (struct otx2_nic *pfvf,u16 qidx,u16 sqb_aura);void otx2_cleanup_tx_cqes (struct otx2_nic *pfvf,struct otx2_cq_queue *cq);int otx2_sq_aq_init (void *dev,u16 qidx,u16 sqb_aura);int cn10k_sq_aq_init (void *dev,u16 qidx,u16 sqb_aura);int otx2_alloc_buffer (struct otx2_nic *pfvf,struct otx2_cq_queue *cq,dma_addr_t *dma); +int otx2_pool_init (struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size); +int otx2_aura_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
@@ -1040,4 +1061,8 @@ static inline void cn10k_handle_mcs_event(struct otx2_nic *pfvf, {}#endif /* CONFIG_MACSEC */ +/* qos support */ +void otx2_qos_sq_setup (struct otx2_nic *pfvf,int qos_txqs); +u16 otx2_select_queue (struct net_device *netdev,struct sk_buff *skb, +struct net_device *sb_dev);#endif /* OTX2_COMMON_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +37 -14
167 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +17 -8
@@ -463,12 +463,14 @@ static int otx2_tx_napi_handler(struct otx2_nic *pfvf,break ; } -if (cq->cq_type ==CQ_XDP ) { + qidx = cq->cq_idx - pfvf->hw.rx_queues; + +if (cq->cq_type ==CQ_XDP )otx2_xdp_snd_pkt_handler (pfvf, sq, cqe); - }else { -otx2_snd_pkt_handler (pfvf, cq, sq, cqe, budget, - &tx_pkts, &tx_bytes); - } +else +otx2_snd_pkt_handler (pfvf, cq, &pfvf->qset.sq[qidx], + cqe, budget, &tx_pkts, &tx_bytes); + cqe->hdr.cqe_type =NIX_XQE_TYPE_INVALID ; processed_cqe++;
@@ -485,7 +487,11 @@ static int otx2_tx_napi_handler(struct otx2_nic *pfvf,if (likely (tx_pkts)) {struct netdev_queue *txq; - txq =netdev_get_tx_queue (pfvf->netdev, cq->cint_idx); + qidx = cq->cq_idx - pfvf->hw.rx_queues; + +if (qidx >= pfvf->hw.tx_queues) + qidx -= pfvf->hw.xdp_queues; + txq =netdev_get_tx_queue (pfvf->netdev, qidx);netdev_tx_completed_queue (txq, tx_pkts, tx_bytes);/* Check if queue was stopped earlier due to ring full */ smp_mb ();
@@ -735,7 +741,8 @@ static void otx2_sqe_add_hdr(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, sqe_hdr->aura = sq->aura_id;/* Post a CQE Tx after pkt transmission */ sqe_hdr->pnc =1 ; - sqe_hdr->sq = qidx; + sqe_hdr->sq = (qidx >= pfvf->hw.tx_queues) ? + qidx + pfvf->hw.xdp_queues : qidx; } sqe_hdr->total = skb->len;/* Set SQE identifier which will be used later for freeing SKB */
@@ -1183,8 +1190,10 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)struct nix_cqe_tx_s *cqe;int processed_cqe =0 ;struct sg_list *sg; +int qidx; - sq = &pfvf->qset.sq[cq->cint_idx]; + qidx = cq->cq_idx - pfvf->hw.rx_queues; + sq = &pfvf->qset.sq[qidx];if (otx2_nix_cq_op_status (pfvf, cq) || !cq->pend_cqe)return ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +2 -1
@@ -102,7 +102,8 @@ enum cq_type {CQ_RX ,CQ_TX ,CQ_XDP , - CQS_PER_CINT = 3, /* RQ + SQ + XDP */ +CQ_QOS , + CQS_PER_CINT = 4, /* RQ + SQ + XDP + QOS_SQ */ }; struct otx2_cq_poll {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +6 -3
@@ -479,6 +479,7 @@ static const struct net_device_ops otx2vf_netdev_ops = { .ndo_open = otx2vf_open, .ndo_stop = otx2vf_stop, .ndo_start_xmit = otx2vf_xmit, + .ndo_select_queue = otx2_select_queue, .ndo_set_rx_mode = otx2vf_set_rx_mode, .ndo_set_mac_address = otx2_set_mac_address, .ndo_change_mtu = otx2vf_change_mtu,
@@ -524,10 +525,10 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) {int num_vec =pci_msix_vec_count (pdev);struct device *dev = &pdev->dev; +int err, qcount, qos_txqs;struct net_device *netdev;struct otx2_nic *vf;struct otx2_hw *hw; -int err, qcount; err =pcim_enable_device (pdev);if (err) {
@@ -550,7 +551,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_master (pdev); qcount =num_online_cpus (); - netdev =alloc_etherdev_mqs (sizeof (*vf), qcount, qcount); + qos_txqs =min_t (int, qcount,OTX2_QOS_MAX_LEAF_NODES ); + netdev =alloc_etherdev_mqs (sizeof (*vf), qcount + qos_txqs, qcount);if (!netdev) { err = -ENOMEM ; goto err_release_regions;
@@ -570,7 +572,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) hw->rx_queues = qcount; hw->tx_queues = qcount; hw->max_queues = qcount; - hw->tot_tx_queues = qcount; + hw->non_qos_queues = qcount; hw->rbuf_len =OTX2_DEFAULT_RBUF_LEN ;/* Use CQE of 128 byte descriptor size by default */ hw->xqe_size =128 ;
@@ -699,6 +701,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_shutdown_tc;#endif +otx2_qos_sq_setup (vf, qos_txqs);return 0 ;
drivers/net/ethernet/marvell/octeontx2/nic/qos.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell RVU Ethernet driver +* +* Copyright (C) 2022 Marvell. +* +*/ +#ifndef OTX2_QOS_H +#define OTX2_QOS_H + +#define OTX2_QOS_MAX_LEAF_NODES 16 + +int otx2_qos_enable_sq (struct otx2_nic *pfvf,int qidx,u16 smq); +void otx2_qos_disable_sq (struct otx2_nic *pfvf,int qidx,u16 mdq); + +struct otx2_qos { +u16 qid_to_sqmap[OTX2_QOS_MAX_LEAF_NODES ]; +}; + +#endif
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c new file +290 -0
290 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [net-next Patch V4 2/4] octeontx2-pf: qos send queues management
Quoted 14 lines · Hariprasad Kelam
From: Subbaraya Sundeep <[email protected]>
Current implementation is such that the number of Send queues (SQs) are decided on the device probe which is equal to the number of online cpus. These SQs are allocated and deallocated in interface open and c lose calls respectively.
This patch defines new APIs for initializing and deinitializing Send queues dynamically and allocates more number of transmit queues for QOS feature.
Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>
Quoted 14 lines
--- .../marvell/octeontx2/af/rvu_debugfs.c | 5 + .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 40 ++- .../marvell/octeontx2/nic/otx2_common.h | 29 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 51 ++- .../marvell/octeontx2/nic/otx2_txrx.c | 25 +- .../marvell/octeontx2/nic/otx2_txrx.h | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 9 +- .../net/ethernet/marvell/octeontx2/nic/qos.h | 19 ++ .../ethernet/marvell/octeontx2/nic/qos_sq.c | 290 ++++++++++++++++++ 10 files changed, 430 insertions(+), 43 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
nit: this patch is a little long
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +3
-1@@ -463,12 +463,14 @@ static int otx2_tx_napi_handler(struct otx2_nic *pfvf,break ; } -if (cq->cq_type ==CQ_XDP ) { + qidx = cq->cq_idx - pfvf->hw.rx_queues; + +if (cq->cq_type ==CQ_XDP )
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c static int otx2_tx_napi_handler(struct otx2_nic *pfvf, · line 474
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +4
-4otx2_xdp_snd_pkt_handler (pfvf, sq, cqe); - }else { -otx2_snd_pkt_handler (pfvf, cq, sq, cqe, budget, - &tx_pkts, &tx_bytes); - } + else + otx2_snd_pkt_handler(pfvf, cq, &pfvf->qset.sq[qidx], + cqe, budget, &tx_pkts, &tx_bytes); +
nit: there are now two blank lines here
Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +0
-0cqe->hdr.cqe_type =NIX_XQE_TYPE_INVALID ; processed_cqe++;
Re: [net-next Patch V4 2/4] octeontx2-pf: qos send queues management
Quoted 35 lines
-----Original Message-----
From: Simon Horman <[email protected]>Quoted 28 lines · Hariprasad Kelam
From: Subbaraya Sundeep <[email protected]>
Current implementation is such that the number of Send queues (SQs) are decided on the device probe which is equal to the number of online cpus. These SQs are allocated and deallocated in interface open and c lose calls respectively.
This patch defines new APIs for initializing and deinitializing Send queues dynamically and allocates more number of transmit queues for QOS feature.
Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- .../marvell/octeontx2/af/rvu_debugfs.c | 5 + .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 40 ++- .../marvell/octeontx2/nic/otx2_common.h | 29 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 51 ++- .../marvell/octeontx2/nic/otx2_txrx.c | 25 +- .../marvell/octeontx2/nic/otx2_txrx.h | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 9 +- .../net/ethernet/marvell/octeontx2/nic/qos.h | 19 ++ .../ethernet/marvell/octeontx2/nic/qos_sq.c | 290 ++++++++++++++++++ 10 files changed, 430 insertions(+), 43 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.h create mode 100644Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
Quoted 2 lines
nit: this patch is a little long
ACK, will split this patch.
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c static int otx2_tx_napi_handler(struct otx2_nic
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +0
-0@@ -463,12 +463,14 @@ static int otx2_tx_napi_handler(struct otx2_nic*pfvf,
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +0
-0break ; }
Quoted 16 lines
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +3
-1-if (cq->cq_type ==CQ_XDP ) { + qidx = cq->cq_idx - pfvf->hw.rx_queues; + +if (cq->cq_type ==CQ_XDP )drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c static int otx2_tx_napi_handler(struct otx2_nic *pfvf, · line 474
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +4
-4otx2_xdp_snd_pkt_handler (pfvf, sq, cqe); - }else { -otx2_snd_pkt_handler (pfvf, cq, sq, cqe, budget, - &tx_pkts, &tx_bytes); - } + else + otx2_snd_pkt_handler(pfvf, cq, &pfvf->qset.sq[qidx], + cqe, budget, &tx_pkts, &tx_bytes); +nit: there are now two blank lines here
ACK, will fix in next version.
Thanks,
Hariprasad k
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +0
-0cqe->hdr.cqe_type =NIX_XQE_TYPE_INVALID ; processed_cqe++;
PATCH v4 3/4 octeontx2-pf: Refactor schedular queue alloc/free calls
In reply to Hariprasad KelamMultiple transmit scheduler queues can be configured at different levels to support traffic shaping and scheduling. But on txschq free requests, the transmit schedular config in hardware is not getting reset. This patch adds support to reset the stale config.
The txschq alloc response handler updates the default txschq array which is used to configure the transmit packet path from SMQ to TL2 levels. However, for new features such as QoS offload that requires it's own txschq queues, this handler is still invoked and results in undefined behavior. The code now handles txschq response in the mbox caller function.
--- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 45 +++++++++++++++++++ .../marvell/octeontx2/nic/otx2_common.c | 36 ++++++++------- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 4 -- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 4 -- 4 files changed, 64 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +45 -0
@@ -1677,6 +1677,42 @@ handle_txschq_shaper_update(struct rvu *rvu, int blkaddr, int nixlf,return true; } +static void nix_reset_tx_schedule (struct rvu *rvu,int blkaddr, +int lvl,int schq) +{ +u64 tlx_parent =0 , tlx_schedule =0 ; + +switch (lvl) { +case NIX_TXSCH_LVL_TL2 : + tlx_parent =NIX_AF_TL2X_PARENT (schq); + tlx_schedule =NIX_AF_TL2X_SCHEDULE (schq); +break ; +case NIX_TXSCH_LVL_TL3 : + tlx_parent =NIX_AF_TL3X_PARENT (schq); + tlx_schedule =NIX_AF_TL3X_SCHEDULE (schq); +break ; +case NIX_TXSCH_LVL_TL4 : + tlx_parent =NIX_AF_TL4X_PARENT (schq); + tlx_schedule =NIX_AF_TL4X_SCHEDULE (schq); +break ; +case NIX_TXSCH_LVL_MDQ : +/* no need to reset SMQ_CFG as HW clears this CSR +* on SMQ flush +*/ + tlx_parent =NIX_AF_MDQX_PARENT (schq); + tlx_schedule =NIX_AF_MDQX_SCHEDULE (schq); +break ; +default : +return ; + } + +if (tlx_parent) +rvu_write64 (rvu, blkaddr, tlx_parent,0x0 ); + +if (tlx_schedule) +rvu_write64 (rvu, blkaddr, tlx_schedule,0x0 ); +} +/* Disable shaping of pkts by a scheduler queue * at a given scheduler level. */
@@ -2025,6 +2061,7 @@ int rvu_mbox_handler_nix_txsch_alloc(struct rvu *rvu, pfvf_map[schq] =TXSCH_MAP (pcifunc,0 );nix_reset_tx_linkcfg (rvu, blkaddr, lvl, schq);nix_reset_tx_shaping (rvu, blkaddr, nixlf, lvl, schq); +nix_reset_tx_schedule (rvu, blkaddr, lvl, schq); }for (idx =0 ; idx < req->schq[lvl]; idx++) {
@@ -2034,6 +2071,7 @@ int rvu_mbox_handler_nix_txsch_alloc(struct rvu *rvu, pfvf_map[schq] =TXSCH_MAP (pcifunc,0 );nix_reset_tx_linkcfg (rvu, blkaddr, lvl, schq);nix_reset_tx_shaping (rvu, blkaddr, nixlf, lvl, schq); +nix_reset_tx_schedule (rvu, blkaddr, lvl, schq); } }
@@ -2122,6 +2160,7 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc)continue ;nix_reset_tx_linkcfg (rvu, blkaddr, lvl, schq);nix_clear_tx_xoff (rvu, blkaddr, lvl, schq); +nix_reset_tx_shaping (rvu, blkaddr, nixlf, lvl, schq); } } nix_clear_tx_xoff(rvu, blkaddr, NIX_TXSCH_LVL_TL1,
@@ -2160,6 +2199,7 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc)for (schq =0 ; schq < txsch->schq.max; schq++) {if (TXSCH_MAP_FUNC (txsch->pfvf_map[schq]) != pcifunc)continue ; +nix_reset_tx_schedule (rvu, blkaddr, lvl, schq);rvu_free_rsrc (&txsch->schq, schq); txsch->pfvf_map[schq] =TXSCH_MAP (0 ,NIX_TXSCHQ_FREE ); }
@@ -2219,6 +2259,9 @@ static int nix_txschq_free_one(struct rvu *rvu,*/ nix_clear_tx_xoff (rvu, blkaddr, lvl, schq); +nix_reset_tx_linkcfg (rvu, blkaddr, lvl, schq); +nix_reset_tx_shaping (rvu, blkaddr, nixlf, lvl, schq); +/* Flush if it is a SMQ. Onus of disabling * TL2/3 queue links before SMQ flush is on user */
@@ -2228,6 +2271,8 @@ static int nix_txschq_free_one(struct rvu *rvu, goto err; } +nix_reset_tx_schedule (rvu, blkaddr, lvl, schq); +/* Free the resource */ rvu_free_rsrc (&txsch->schq, schq); txsch->pfvf_map[schq] =TXSCH_MAP (0 ,NIX_TXSCHQ_FREE );
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +19 -17
@@ -716,7 +716,8 @@ EXPORT_SYMBOL(otx2_smq_flush);int otx2_txsch_alloc (struct otx2_nic *pfvf) {struct nix_txsch_alloc_req *req; -int lvl; +struct nix_txsch_alloc_rsp *rsp; +int lvl, schq, rc;/* Get memory to put this msg */ req =otx2_mbox_alloc_msg_nix_txsch_alloc (&pfvf->mbox);
@@ -726,8 +727,24 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)/* Request one schq per level */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) req->schq[lvl] =1 ; + rc =otx2_sync_mbox_msg (&pfvf->mbox); +if (rc) +return rc; -return otx2_sync_mbox_msg (&pfvf->mbox); + rsp = (struct nix_txsch_alloc_rsp *) +otx2_mbox_get_rsp (&pfvf->mbox.mbox,0 , &req->hdr); +if (IS_ERR (rsp)) +return PTR_ERR (rsp); + +/* Setup transmit scheduler list */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) +for (schq =0 ; schq < rsp->schq[lvl]; schq++) + pfvf->hw.txschq_list[lvl][schq] = + rsp->schq_list[lvl][schq]; + + pfvf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl; + +return 0 ; }int otx2_txschq_stop (struct otx2_nic *pfvf)
@@ -1641,21 +1658,6 @@ void mbox_handler_cgx_fec_stats(struct otx2_nic *pfvf, pfvf->hw.cgx_fec_uncorr_blks += rsp->fec_uncorr_blks; } -void mbox_handler_nix_txsch_alloc (struct otx2_nic *pf, -struct nix_txsch_alloc_rsp *rsp) -{ -int lvl, schq; - -/* Setup transmit scheduler list */ -for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) -for (schq =0 ; schq < rsp->schq[lvl]; schq++) - pf->hw.txschq_list[lvl][schq] = - rsp->schq_list[lvl][schq]; - - pf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl; -} -EXPORT_SYMBOL (mbox_handler_nix_txsch_alloc); -void mbox_handler_npa_lf_alloc (struct otx2_nic *pfvf,struct npa_lf_alloc_rsp *rsp) {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0 -4
@@ -792,10 +792,6 @@ static void otx2_process_pfaf_mbox_msg(struct otx2_nic *pf,case MBOX_MSG_NIX_LF_ALLOC :mbox_handler_nix_lf_alloc (pf, (struct nix_lf_alloc_rsp *)msg);break ; -case MBOX_MSG_NIX_TXSCH_ALLOC : -mbox_handler_nix_txsch_alloc (pf, - (struct nix_txsch_alloc_rsp *)msg); -break ;case MBOX_MSG_NIX_BP_ENABLE :mbox_handler_nix_bp_enable (pf, (struct nix_bp_cfg_rsp *)msg);break ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +0 -4
@@ -70,10 +70,6 @@ static void otx2vf_process_vfaf_mbox_msg(struct otx2_nic *vf,case MBOX_MSG_NIX_LF_ALLOC :mbox_handler_nix_lf_alloc (vf, (struct nix_lf_alloc_rsp *)msg);break ; -case MBOX_MSG_NIX_TXSCH_ALLOC : -mbox_handler_nix_txsch_alloc (vf, - (struct nix_txsch_alloc_rsp *)msg); -break ;case MBOX_MSG_NIX_BP_ENABLE :mbox_handler_nix_bp_enable (vf, (struct nix_bp_cfg_rsp *)msg);break ;
Signature · 1 line
2.17.1
Re: [net-next Patch V4 3/4] octeontx2-pf: Refactor schedular queue alloc/free calls
Quoted 21 lines · Hariprasad Kelam
Multiple transmit scheduler queues can be configured at different levels to support traffic shaping and scheduling. But on txschq free requests, the transmit schedular config in hardware is not getting reset. This patch adds support to reset the stale config.
The txschq alloc response handler updates the default txschq array which is used to configure the transmit packet path from SMQ to TL2 levels. However, for new features such as QoS offload that requires it's own txschq queues, this handler is still invoked and results in undefined behavior. The code now handles txschq response in the mbox caller function.
Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 45 +++++++++++++++++++ .../marvell/octeontx2/nic/otx2_common.c | 36 ++++++++------- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 4 -- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 4 -- 4 files changed, 64 insertions(+), 25 deletions(-)
...
Quoted 25 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +7
-2@@ -716,7 +716,8 @@ EXPORT_SYMBOL(otx2_smq_flush);int otx2_txsch_alloc (struct otx2_nic *pfvf) {struct nix_txsch_alloc_req *req; -int lvl; +struct nix_txsch_alloc_rsp *rsp; +int lvl, schq, rc;/* Get memory to put this msg */ req =otx2_mbox_alloc_msg_nix_txsch_alloc (&pfvf->mbox);@@ -726,8 +727,24 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)/* Request one schq per level */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) req->schq[lvl] =1 ; + rc =otx2_sync_mbox_msg (&pfvf->mbox); +if (rc) +return rc; -return otx2_sync_mbox_msg (&pfvf->mbox); + rsp = (struct nix_txsch_alloc_rsp *) +otx2_mbox_get_rsp (&pfvf->mbox.mbox,0 , &req->hdr);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txsch_alloc(struct otx2_nic *pfvf) · line 745
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +10
-0+if (IS_ERR (rsp)) +return PTR_ERR (rsp); + +/* Setup transmit scheduler list */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) +for (schq =0 ; schq < rsp->schq[lvl]; schq++) + pfvf->hw.txschq_list[lvl][schq] = + rsp->schq_list[lvl][schq]; + + pfvf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl;
nit: extra whitespace before '='
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2
-0+ +return 0 ; }
Re: [net-next Patch V4 3/4] octeontx2-pf: Refactor schedular queue alloc/free calls
Quoted 50 lines · Hariprasad Kelam
Quoted 12 lines
Multiple transmit scheduler queues can be configured at different levels to support traffic shaping and scheduling. But on txschq free requests, the transmit schedular config in hardware is not getting reset. This patch adds support to reset the stale config.
The txschq alloc response handler updates the default txschq array which is used to configure the transmit packet path from SMQ to TL2 levels. However, for new features such as QoS offload that requires it's own txschq queues, this handler is still invoked and results in undefined behavior. The code now handles txschq response in the mbox caller function.
Quoted 5 lines
Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 45+++++++++++++++++++
Quoted 4 lines
.../marvell/octeontx2/nic/otx2_common.c | 36 ++++++++------- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 4 -- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 4 -- 4 files changed, 64 insertions(+), 25 deletions(-)...
Quoted 22 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5
-1@@ -716,7 +716,8 @@ EXPORT_SYMBOL(otx2_smq_flush); int otx2_txsch_alloc(struct otx2_nic *pfvf) {struct nix_txsch_alloc_req *req; -int lvl; +struct nix_txsch_alloc_rsp *rsp; +int lvl, schq, rc;/* Get memory to put this msg */ req =otx2_mbox_alloc_msg_nix_txsch_alloc (&pfvf->mbox);@@ -726,8 +727,24 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)/* Request one schq per level */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) req->schq[lvl] =1 ; + rc =otx2_sync_mbox_msg (&pfvf->mbox); +if (rc) +return rc;
Quoted 16 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txsch_alloc(struct otx2_nic *pfvf) · line 745
Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +12
-1-return otx2_sync_mbox_msg (&pfvf->mbox); + rsp = (struct nix_txsch_alloc_rsp *) +otx2_mbox_get_rsp (&pfvf->mbox.mbox,0 , &req->hdr); +if (IS_ERR (rsp)) +return PTR_ERR (rsp); + +/* Setup transmit scheduler list */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) +for (schq =0 ; schq < rsp->schq[lvl]; schq++) + pfvf->hw.txschq_list[lvl][schq] = + rsp->schq_list[lvl][schq]; + + pfvf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl;nit: extra whitespace before '='
ACK , will fix in next version.
Thanks,
Hariprasad k
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2
-0+ +return 0 ; }
PATCH v4 4/4 octeontx2-pf: Add support for HTB offload
In reply to Hariprasad KelamFrom: Naveen Mamindlapalli <[email protected]>
This patch registers callbacks to support HTB offload.
Below are features supported,
- supports traffic shaping on the given class by honoring rate and ceil configuration.
- supports traffic scheduling, which prioritizes different types of traffic based on strict priority values.
- supports the creation of leaf to inner classes such that parent node rate limits apply to all child nodes.
--- .../ethernet/marvell/octeontx2/af/common.h | 2 +- .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 37 +- .../marvell/octeontx2/nic/otx2_common.h | 7 + .../marvell/octeontx2/nic/otx2_ethtool.c | 31 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 47 +- .../ethernet/marvell/octeontx2/nic/otx2_reg.h | 13 + .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 +- .../net/ethernet/marvell/octeontx2/nic/qos.c | 1541 +++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/qos.h | 56 +- .../ethernet/marvell/octeontx2/nic/qos_sq.c | 20 +- include/net/sch_generic.h | 2 + net/sched/sch_generic.c | 5 +- 13 files changed, 1741 insertions(+), 29 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.c
drivers/net/ethernet/marvell/octeontx2/af/common.h +1 -1
@@ -142,7 +142,7 @@ enum nix_scheduler {#define TXSCH_RR_QTM_MAX ((1 << 24) - 1)#define TXSCH_TL1_DFLT_RR_QTM TXSCH_RR_QTM_MAX -#define TXSCH_TL1_DFLT_RR_PRIO (0x1ull) +#define TXSCH_TL1_DFLT_RR_PRIO (0x7ull)#define CN10K_MAX_DWRR_WEIGHT 16384/* Weight is 14bit on CN10K */ /* Min/Max packet sizes, excluding FCS */
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-$(CONFIG_OCTEONTX2_VF) += rvu_nicvf.o otx2_ptp.o rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ otx2_flows.o otx2_tc.o cn10k.o otx2_dmac_flt.o \ - otx2_devlink.o qos_sq.o + otx2_devlink.o qos_sq.o qos.o rvu_nicvf-y := otx2_vf.o otx2_devlink.o rvu_nicpf-$(CONFIG_DCB) += otx2_dcbnl.o
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +31 -6
@@ -89,6 +89,11 @@ int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx)if (!pfvf->qset.sq)return 0 ; +if (qidx >= pfvf->hw.non_qos_queues) { +if (!test_bit (qidx - pfvf->hw.non_qos_queues, pfvf->qos.qos_sq_bmap)) +return 0 ; + } +otx2_nix_sq_op_stats (&sq->stats, pfvf, qidx);return 1 ; }
@@ -747,29 +752,49 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)return 0 ; } -int otx2_txschq_stop (struct otx2_nic *pfvf) +void otx2_txschq_free_one (struct otx2_nic *pfvf,u16 lvl,u16 schq) {struct nix_txsch_free_req *free_req; -int lvl, schq, err; +int err;mutex_lock (&pfvf->mbox.lock); -/* Free the transmit schedulers */ + free_req =otx2_mbox_alloc_msg_nix_txsch_free (&pfvf->mbox);if (!free_req) {mutex_unlock (&pfvf->mbox.lock); -return -ENOMEM ; +netdev_err (pfvf->netdev, +"Failed alloc txschq free req\n" ); +return ; } - free_req->flags =TXSCHQ_FREE_ALL ; + free_req->schq_lvl = lvl; + free_req->schq = schq; + err =otx2_sync_mbox_msg (&pfvf->mbox); +if (err) { +netdev_err (pfvf->netdev, +"Failed stop txschq %d at level %d\n" , lvl, schq); + } +mutex_unlock (&pfvf->mbox.lock); +} + +int otx2_txschq_stop (struct otx2_nic *pfvf) +{ +int lvl, schq; + +/* free non QOS TLx nodes */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) +otx2_txschq_free_one (pfvf, lvl, + pfvf->hw.txschq_list[lvl][0 ]);/* Clear the txschq list */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) {for (schq =0 ; schq <MAX_TXSCHQ_PER_FUNC ; schq++) pfvf->hw.txschq_list[lvl][schq] =0 ; } -return err; + +return 0 ; }void otx2_sqb_flush (struct otx2_nic *pfvf)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +7 -0
@@ -252,6 +252,7 @@ struct otx2_hw {#define CN10K_RPM 3#define CN10K_PTP_ONESTEP 4#define CN10K_HW_MACSEC 5 +#define QOS_CIR_PIR_SUPPORT 6unsigned long cap_flag;#define LMT_LINE_SIZE 128
@@ -586,6 +587,7 @@ static inline void otx2_setup_dev_hw_settings(struct otx2_nic *pfvf)__set_bit (CN10K_LMTST , &hw->cap_flag);__set_bit (CN10K_RPM , &hw->cap_flag);__set_bit (CN10K_PTP_ONESTEP , &hw->cap_flag); +__set_bit (QOS_CIR_PIR_SUPPORT , &hw->cap_flag); }if (is_dev_cn10kb (pfvf->pdev))
@@ -954,6 +956,7 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id, int stack_pages, int numptrs, int buf_size);int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs); +void otx2_txschq_free_one (struct otx2_nic *pfvf,u16 lvl,u16 schq);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
@@ -1065,4 +1068,8 @@ static inline void cn10k_handle_mcs_event(struct otx2_nic *pfvf,void otx2_qos_sq_setup (struct otx2_nic *pfvf,int qos_txqs);u16 otx2_select_queue (struct net_device *netdev,struct sk_buff *skb,struct net_device *sb_dev); +int otx2_get_txq_by_classid (struct otx2_nic *pfvf,u16 classid); +void otx2_qos_config_txschq (struct otx2_nic *pfvf); +int otx2_clean_qos_queues (struct otx2_nic *pfvf); +bool otx2_is_qos_configured (struct otx2_nic *pfvf);#endif /* OTX2_COMMON_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +22 -9
@@ -92,10 +92,16 @@ static void otx2_get_qset_strings(struct otx2_nic *pfvf, u8 **data, int qset) *data +=ETH_GSTRING_LEN ; } } -for (qidx =0 ; qidx < pfvf->hw.tx_queues; qidx++) { + +for (qidx =0 ; qidx <otx2_get_total_tx_queues (pfvf); qidx++) {for (stats =0 ; stats < otx2_n_queue_stats; stats++) { -sprintf (*data,"txq%d: %s" , qidx + start_qidx, - otx2_queue_stats[stats].name); +if (qidx >= pfvf->hw.non_qos_queues) +sprintf (*data,"txq_qos%d: %s" , + qidx + start_qidx - pfvf->hw.non_qos_queues, + otx2_queue_stats[stats].name); +else +sprintf (*data,"txq%d: %s" , qidx + start_qidx, + otx2_queue_stats[stats].name); *data +=ETH_GSTRING_LEN ; } }
@@ -159,7 +165,7 @@ static void otx2_get_qset_stats(struct otx2_nic *pfvf, [otx2_queue_stats[stat].index]; } -for (qidx =0 ; qidx < pfvf->hw.tx_queues; qidx++) { +for (qidx =0 ; qidx <otx2_get_total_tx_queues (pfvf); qidx++) {if (!otx2_update_sq_stats (pfvf, qidx)) {for (stat =0 ; stat < otx2_n_queue_stats; stat++) *((*data)++) =0 ;
@@ -254,7 +260,8 @@ static int otx2_get_sset_count(struct net_device *netdev, int sset)return -EINVAL ; qstats_count = otx2_n_queue_stats * - (pfvf->hw.rx_queues + pfvf->hw.tx_queues); + (pfvf->hw.rx_queues + pfvf->hw.non_qos_queues + + pfvf->hw.tc_tx_queues);if (!test_bit (CN10K_RPM , &pfvf->hw.cap_flag)) mac_stats =CGX_RX_STATS_COUNT +CGX_TX_STATS_COUNT ;otx2_update_lmac_fec_stats (pfvf);
@@ -282,7 +289,7 @@ static int otx2_set_channels(struct net_device *dev, {struct otx2_nic *pfvf =netdev_priv (dev);bool if_up =netif_running (dev); -int err =0 ; +int err =0 , qos_txqs;if (!channel->rx_count || !channel->tx_count)return -EINVAL ;
@@ -296,14 +303,19 @@ static int otx2_set_channels(struct net_device *dev,if (if_up) dev->netdev_ops->ndo_stop (dev); - err =otx2_set_real_num_queues (dev, channel->tx_count, + qos_txqs =bitmap_weight (pfvf->qos.qos_sq_bmap, +OTX2_QOS_MAX_LEAF_NODES ); + + err =otx2_set_real_num_queues (dev, channel->tx_count + qos_txqs, channel->rx_count);if (err)return err; pfvf->hw.rx_queues = channel->rx_count; pfvf->hw.tx_queues = channel->tx_count; - pfvf->qset.cq_cnt = pfvf->hw.tx_queues + pfvf->hw.rx_queues; +if (pfvf->xdp_prog) + pfvf->hw.xdp_queues = channel->rx_count; + pfvf->hw.non_qos_queues = pfvf->hw.tx_queues + pfvf->hw.xdp_queues;if (if_up) err = dev->netdev_ops->ndo_open (dev);
@@ -1405,7 +1417,8 @@ static int otx2vf_get_sset_count(struct net_device *netdev, int sset)return -EINVAL ; qstats_count = otx2_n_queue_stats * - (vf->hw.rx_queues + vf->hw.tx_queues); + (vf->hw.rx_queues + vf->hw.tx_queues + + vf->hw.tc_tx_queues);return otx2_n_dev_stats + otx2_n_drv_stats + qstats_count +1 ; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +45 -2
84 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h +13 -0
@@ -145,12 +145,25 @@#define NIX_AF_TL1X_TOPOLOGY (a) (0xC80 | (a) << 16)#define NIX_AF_TL2X_PARENT (a) (0xE88 | (a) << 16)#define NIX_AF_TL2X_SCHEDULE (a) (0xE00 | (a) << 16) +#define NIX_AF_TL2X_TOPOLOGY (a) (0xE80 | (a) << 16) +#define NIX_AF_TL2X_CIR (a) (0xE20 | (a) << 16) +#define NIX_AF_TL2X_PIR (a) (0xE30 | (a) << 16)#define NIX_AF_TL3X_PARENT (a) (0x1088 | (a) << 16)#define NIX_AF_TL3X_SCHEDULE (a) (0x1000 | (a) << 16) +#define NIX_AF_TL3X_SHAPE (a) (0x1010 | (a) << 16) +#define NIX_AF_TL3X_CIR (a) (0x1020 | (a) << 16) +#define NIX_AF_TL3X_PIR (a) (0x1030 | (a) << 16) +#define NIX_AF_TL3X_TOPOLOGY (a) (0x1080 | (a) << 16)#define NIX_AF_TL4X_PARENT (a) (0x1288 | (a) << 16)#define NIX_AF_TL4X_SCHEDULE (a) (0x1200 | (a) << 16) +#define NIX_AF_TL4X_SHAPE (a) (0x1210 | (a) << 16) +#define NIX_AF_TL4X_CIR (a) (0x1220 | (a) << 16)#define NIX_AF_TL4X_PIR (a) (0x1230 | (a) << 16) +#define NIX_AF_TL4X_TOPOLOGY (a) (0x1280 | (a) << 16)#define NIX_AF_MDQX_SCHEDULE (a) (0x1400 | (a) << 16) +#define NIX_AF_MDQX_SHAPE (a) (0x1410 | (a) << 16) +#define NIX_AF_MDQX_CIR (a) (0x1420 | (a) << 16) +#define NIX_AF_MDQX_PIR (a) (0x1430 | (a) << 16)#define NIX_AF_MDQX_PARENT (a) (0x1480 | (a) << 16)#define NIX_AF_TL3_TL2X_LINKX_CFG (a, b) (0x1700 | (a) << 16 | (b) << 3)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +5 -2
@@ -19,6 +19,7 @@#include "cn10k.h" #include "otx2_common.h" +#include "qos.h" /* Egress rate limiting definitions */ #define MAX_BURST_EXPONENT 0x0FULL
@@ -147,8 +148,8 @@ static void otx2_get_egress_rate_cfg(u64 maxrate, u32 *exp, } } -static u64 otx2_get_txschq_rate_regval (struct otx2_nic *nic, -u64 maxrate,u32 burst) +u64 otx2_get_txschq_rate_regval (struct otx2_nic *nic, +u64 maxrate,u32 burst) {u32 burst_exp, burst_mantissa;u32 exp, mantissa, div_exp;
@@ -1127,6 +1128,8 @@ int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK :return otx2_setup_tc_block (netdev, type_data); +case TC_SETUP_QDISC_HTB : +return otx2_setup_tc_htb (netdev, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +1541 -0
1,541 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +54 -2
67 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c +17 -3
@@ -225,7 +225,22 @@ static int otx2_qos_ctx_disable(struct otx2_nic *pfvf, u16 qidx, int aura_id)return otx2_sync_mbox_msg (&pfvf->mbox); } -int otx2_qos_enable_sq (struct otx2_nic *pfvf,int qidx,u16 smq) +int otx2_qos_get_qid (struct otx2_nic *pfvf) +{ +int qidx; + + qidx =find_first_zero_bit (pfvf->qos.qos_sq_bmap, + pfvf->hw.tc_tx_queues); + +return qidx == pfvf->hw.tc_tx_queues ? -ENOSPC : qidx; +} + +void otx2_qos_free_qid (struct otx2_nic *pfvf,int qidx) +{ +clear_bit (qidx, pfvf->qos.qos_sq_bmap); +} + +int otx2_qos_enable_sq (struct otx2_nic *pfvf,int qidx) {struct otx2_hw *hw = &pfvf->hw;int pool_id, sq_idx, err;
@@ -241,7 +256,6 @@ int otx2_qos_enable_sq(struct otx2_nic *pfvf, int qidx, u16 smq) goto out; pool_id =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , sq_idx); - pfvf->qos.qid_to_sqmap[qidx] = smq; err =otx2_sq_init (pfvf, sq_idx, pool_id);if (err) goto out;
@@ -250,7 +264,7 @@ int otx2_qos_enable_sq(struct otx2_nic *pfvf, int qidx, u16 smq)return err; } -void otx2_qos_disable_sq (struct otx2_nic *pfvf,int qidx,u16 mdq) +void otx2_qos_disable_sq (struct otx2_nic *pfvf,int qidx) {struct otx2_qset *qset = &pfvf->qset;struct otx2_hw *hw = &pfvf->hw;
include/net/sch_generic.h +2 -0
@@ -647,6 +647,8 @@ void dev_shutdown(struct net_device *dev);void dev_activate (struct net_device *dev);void dev_deactivate (struct net_device *dev);void dev_deactivate_many (struct list_head *head); +void dev_reset_queue (struct net_device *dev,struct netdev_queue *dev_queue, +void *_unused);struct Qdisc *dev_graft_qdisc (struct netdev_queue *dev_queue,struct Qdisc *qdisc);void qdisc_reset (struct Qdisc *qdisc);
net/sched/sch_generic.c +2 -3
@@ -1265,9 +1265,8 @@ static void dev_deactivate_queue(struct net_device *dev, } } -static void dev_reset_queue (struct net_device *dev, -struct netdev_queue *dev_queue, -void *_unused) +void dev_reset_queue (struct net_device *dev,struct netdev_queue *dev_queue, +void *_unused) {struct Qdisc *qdisc;bool nolock;
Signature · 1 line
2.17.1
Re: [net-next Patch V4 4/4] octeontx2-pf: Add support for HTB offload
Quoted 18 lines · Hariprasad Kelam
From: Naveen Mamindlapalli <[email protected]>
This patch registers callbacks to support HTB offload.
Below are features supported,
- supports traffic shaping on the given class by honoring rate and ceil configuration.
- supports traffic scheduling, which prioritizes different types of traffic based on strict priority values.
- supports the creation of leaf to inner classes such that parent node rate limits apply to all child nodes.
Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>
Quoted 16 lines
--- .../ethernet/marvell/octeontx2/af/common.h | 2 +- .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 37 +- .../marvell/octeontx2/nic/otx2_common.h | 7 + .../marvell/octeontx2/nic/otx2_ethtool.c | 31 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 47 +- .../ethernet/marvell/octeontx2/nic/otx2_reg.h | 13 + .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 +- .../net/ethernet/marvell/octeontx2/nic/qos.c | 1541 +++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/qos.h | 56 +- .../ethernet/marvell/octeontx2/nic/qos_sq.c | 20 +- include/net/sch_generic.h | 2 + net/sched/sch_generic.c | 5 +- 13 files changed, 1741 insertions(+), 29 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/qos.c
nit: this patch is rather long
...
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +0
-0
...
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +7
-0+int otx2_txschq_stop (struct otx2_nic *pfvf) +{ +int lvl, schq; + +/* free non QOS TLx nodes */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) + otx2_txschq_free_one(pfvf, lvl,
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txsch_alloc(struct otx2_nic *pfvf) · line 797
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +3
-1+ pfvf->hw.txschq_list[lvl][0]);/* Clear the txschq list */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) {for (schq =0 ; schq <MAX_TXSCHQ_PER_FUNC ; schq++) pfvf->hw.txschq_list[lvl][schq] =0 ; } -return err; + +return 0 ;
nit: This function always returns 0. Perhaps it's return value could be null
and the error handling code at the call sites removed.
...
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +0
-0
...
drivers/net/ethernet/marvell/octeontx2/nic/qos.c line 1453
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +10
-0+int otx2_clean_qos_queues (struct otx2_nic *pfvf) +{ +struct otx2_qos_node *root; + + root =otx2_sw_node_find (pfvf,OTX2_QOS_ROOT_CLASSID ); +if (!root) +return 0 ; + +return otx2_qos_update_smq (pfvf, root,QOS_SMQ_FLUSH ); +}
nit: It seems that the return code of this function is always ignored by
callers. Perhaps either the call sites should detect errors, or the return type of this function should be changed to void.
Quoted 23 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +23
-0+ +void otx2_qos_config_txschq (struct otx2_nic *pfvf) +{ +struct otx2_qos_node *root; +int err; + + root =otx2_sw_node_find (pfvf,OTX2_QOS_ROOT_CLASSID ); +if (!root) +return ; + + err =otx2_qos_txschq_config (pfvf, root); +if (err) { +netdev_err (pfvf->netdev,"Error update txschq configuration\n" ); + goto root_destroy; + } + + err =otx2_qos_txschq_push_cfg_tl (pfvf, root,NULL ); +if (err) { +netdev_err (pfvf->netdev,"Error update txschq configuration\n" ); + goto root_destroy; + } + + err =otx2_qos_update_smq (pfvf, root,QOS_CFG_SQ );
drivers/net/ethernet/marvell/octeontx2/nic/qos.c line 1486
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +10
-0+if (err) { +netdev_err (pfvf->netdev,"Error update smq configuration\n" ); + goto root_destroy; + } + +return ; + +root_destroy: +otx2_qos_root_destroy (pfvf); +}
I am curious as to why the root is destroyed here. But such cleanup doesn't apply to other places where otx2_qos_txschq_config() is called.
...
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +0
-0
...
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 45
Quoted 6 lines
struct
otx2_qos{drivers/net/ethernet/marvell/octeontx2/nic/qos.h +4
-0+DECLARE_HASHTABLE (qos_hlist,order_base_2 (OTX2_QOS_MAX_LEAF_NODES )); +DECLARE_BITMAP (qos_sq_bmap,OTX2_QOS_MAX_LEAF_NODES );u16 qid_to_sqmap[OTX2_QOS_MAX_LEAF_NODES ]; +u16 maj_id; +u16 defcls;
On x86_64 there is a 4 byte hole here...
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 48
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+struct list_head qos_tree; +struct mutex qos_lock;/* child list lock */ +u8 link_cfg_lvl;/* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
And link_cfg_lvl is on a cacheline all by itself.
I'm not sure if it makes any difference, but pehraps it makes more sense to place link_cfg_lvl in the hole above.
$ pahole drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.o
...
struct otx2_qos {
struct hlist_head qos_hlist[16]; /* 0 128 */
/* --- cacheline 2 boundary (128 bytes) --- */
long unsigned int qos_sq_bmap[1]; /* 128 8 */
u16 qid_to_sqmap[16]; /* 136 32 */
u16 maj_id; /* 168 2 */
u16 defcls; /* 170 2 */ /* XXX 4 bytes hole, try to pack */
struct list_head qos_tree; /* 176 16 */
/* --- cacheline 3 boundary (192 bytes) --- */
struct mutex qos_lock; /* 192 160 */
/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
u8 link_cfg_lvl; /* 352 1 */
/* size: 360, cachelines: 6, members: 8 */
/* sum members: 349, holes: 1, sum holes: 4 */
/* padding: 7 */
/* last cacheline: 40 bytes */
};...
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 53
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +5
-0+}; + +struct otx2_qos_node { +/* htb params */ +u32 classid;
On x86_64 there is a 4 byte hole here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 58
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +5
-0+u64 rate; +u64 ceil; +u32 prio; +/* hw txschq */ +u8 level;
a one byte hole here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 61
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+u16 schq; +u16 qid; +u16 prio_anchor;
another four byte hole here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 64
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+DECLARE_BITMAP (prio_bmap,OTX2_QOS_MAX_PRIO +1 ); +/* list management */ +struct hlist_node hlist;
the first cacheline ends here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 65
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +1
-0+struct otx2_qos_node *parent;/* parent qos node */
And this is an 8 byte entity.
I'm not sure if it is advantagous,
but I think parent could be moved to the first cacheline.
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 69
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+struct list_head list; +struct list_head child_list; +struct list_head child_schq_list; };
$ pahole drivers/net/ethernet/marvell/octeontx2/nic/qos.o
...
struct otx2_qos_node {
u32 classid; /* 0 4 *//* XXX 4 bytes hole, try to pack */
u64 rate; /* 8 8 */
u64 ceil; /* 16 8 */
u32 prio; /* 24 4 */
u8 level; /* 28 1 */
/* XXX 1 byte hole, try to pack */
u16 schq; /* 30 2 */
u16 qid; /* 32 2 */
u16 prio_anchor; /* 34 2 */
/* XXX 4 bytes hole, try to pack */
long unsigned int prio_bmap[1]; /* 40 8 */
struct hlist_node hlist; /* 48 16 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct otx2_qos_node * parent; /* 64 8 */
struct list_head list; /* 72 16 */
struct list_head child_list; /* 88 16 */
struct list_head child_schq_list; /* 104 16 */
/* size: 120, cachelines: 2, members: 14 */ /* sum members: 111, holes: 3, sum holes: 9 */ /* last cacheline: 56 bytes */
};
...
Re: [net-next Patch V4 4/4] octeontx2-pf: Add support for HTB offload
Please see inline,
Quoted 36 lines · Hariprasad Kelam
Quoted 33 lines
From: Naveen Mamindlapalli <[email protected]>
This patch registers callbacks to support HTB offload.
Below are features supported,
- supports traffic shaping on the given class by honoring rate and ceil configuration.
- supports traffic scheduling, which prioritizes different types of traffic based on strict priority values.
- supports the creation of leaf to inner classes such that parent node rate limits apply to all child nodes.
Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>--- .../ethernet/marvell/octeontx2/af/common.h | 2 +- .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/otx2_common.c | 37 +- .../marvell/octeontx2/nic/otx2_common.h | 7 + .../marvell/octeontx2/nic/otx2_ethtool.c | 31 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 47 +- .../ethernet/marvell/octeontx2/nic/otx2_reg.h | 13 + .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 +- .../net/ethernet/marvell/octeontx2/nic/qos.c | 1541 +++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/qos.h | 56 +- .../ethernet/marvell/octeontx2/nic/qos_sq.c | 20 +- include/net/sch_generic.h | 2 + net/sched/sch_generic.c | 5 +- 13 files changed, 1741 insertions(+), 29 deletions(-) create modeQuoted 1 line
100644
drivers/net/ethernet/marvell/octeontx2/nic/qos.c
Quoted 2 lines
nit: this patch is rather long
Ok, Will try to break the whole patch into two.
Quoted 18 lines
...
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +0
-0...
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +7
-0+int otx2_txschq_stop (struct otx2_nic *pfvf) { +int lvl, schq; + +/* free non QOS TLx nodes */ +for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) +otx2_txschq_free_one (pfvf, lvl, + pfvf->hw.txschq_list[lvl][0 ]);
Quoted 11 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txsch_alloc(struct otx2_nic *pfvf) · line 797
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2
-1/* Clear the txschq list */ for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) {for (schq =0 ; schq <MAX_TXSCHQ_PER_FUNC ; schq++) pfvf->hw.txschq_list[lvl][schq] =0 ; } -return err; + +return 0 ;nit: This function always returns 0. Perhaps it's return value could be null
and the error handling code at the call sites removed.
ACK, the caller is checking for the error, will modify the return value.
Quoted 12 lines
...
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +0
-0...
Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +8
-0+int otx2_clean_qos_queues (struct otx2_nic *pfvf) { +struct otx2_qos_node *root; + + root =otx2_sw_node_find (pfvf,OTX2_QOS_ROOT_CLASSID ); +if (!root) +return 0 ; + +return otx2_qos_update_smq (pfvf, root,QOS_SMQ_FLUSH ); }nit: It seems that the return code of this function is always ignored by
callers. Perhaps either the call sites should detect errors, or the return type of this function should be changed to void.
ACK, will modify the return value.
Quoted 27 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +12
-0+ +void otx2_qos_config_txschq (struct otx2_nic *pfvf) { +struct otx2_qos_node *root; +int err; + + root =otx2_sw_node_find (pfvf,OTX2_QOS_ROOT_CLASSID ); +if (!root) +return ; + + err =otx2_qos_txschq_config (pfvf, root); +if (err) { + netdev_err(pfvf->netdev, "Error update txschqconfiguration\n");
drivers/net/ethernet/marvell/octeontx2/nic/qos.c
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +6
-0+ goto root_destroy; + } + + err =otx2_qos_txschq_push_cfg_tl (pfvf, root,NULL ); +if (err) { + netdev_err(pfvf->netdev, "Error update txschqconfiguration\n");
drivers/net/ethernet/marvell/octeontx2/nic/qos.c
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +6
-0+ goto root_destroy; + } + + err =otx2_qos_update_smq (pfvf, root,QOS_CFG_SQ ); +if (err) { + netdev_err(pfvf->netdev, "Error update smqconfiguration\n");
Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c line 1486
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.c new file +8
-0+ goto root_destroy; + } + +return ; + +root_destroy: +otx2_qos_root_destroy (pfvf); +}I am curious as to why the root is destroyed here. But such cleanup doesn't apply to other places where
otx2_qos_txschq_config()is called.
There are two use cases,
1. otx2_qos_txschq_config is called while creating a new class, on this function fails we are simply returning an error.
2. if QOS commands are installed in the interface down state, " otx2_qos_config_txschq" this function is called during interface UP, To configure the hardware CSRs for all classes.
We are deleting the root if the driver failed to configure the HW. We missed adding message, will add in next version.
Quoted 28 lines
...
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +0
-0...
drivers/net/ethernet/marvell/octeontx2/nic/qos.h
Quoted 2 lines
struct
otx2_qos{drivers/net/ethernet/marvell/octeontx2/nic/qos.h +1
-0+ DECLARE_HASHTABLE(qos_hlist,
order_base_2(OTX2_QOS_MAX_LEAF_NODES));drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 45
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+DECLARE_BITMAP (qos_sq_bmap,OTX2_QOS_MAX_LEAF_NODES );u16 qid_to_sqmap[OTX2_QOS_MAX_LEAF_NODES ]; +u16 maj_id; +u16 defcls;On
x86_64there is a 4 byte hole here...drivers/net/ethernet/marvell/octeontx2/nic/qos.h
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +4
-0+struct list_head qos_tree; +struct mutex qos_lock;/* child list lock */ +u8 link_cfg_lvl;/* LINKX_CFG CSRs mapped to TL3 or TL2's index ? +*/ And
link_cfg_lvlis on a cacheline all by itself.
Quoted 2 lines
I'm not sure if it makes any difference, but pehraps it makes more sense to place
link_cfg_lvlin the hole above.
ACK, will address the suggested below changes in next version.
Thanks,
Hariprasad k
Quoted 98 lines
$ pahole drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.o ... struct otx2_qos { struct hlist_head qos_hlist[16]; /* 0 128 */ /* --- cacheline 2 boundary (128 bytes) --- */ long unsigned int qos_sq_bmap[1]; /* 128 8 */ u16 qid_to_sqmap[16]; /* 136 32 */ u16 maj_id; /* 168 2 */ u16 defcls; /* 170 2 *//* XXX 4 bytes hole, try to pack */ struct list_head qos_tree; /* 176 16 */ /* --- cacheline 3 boundary (192 bytes) --- */ struct mutex qos_lock; /* 192 160 */ /* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */ u8 link_cfg_lvl; /* 352 1 */ /* size: 360, cachelines: 6, members: 8 */ /* sum members: 349, holes: 1, sum holes: 4 */ /* padding: 7 */ /* last cacheline: 40 bytes */ };...
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 53
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +5
-0+}; + +struct otx2_qos_node { +/* htb params */ +u32 classid;On
x86_64there is a 4 byte hole here,drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 58
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +5
-0+u64 rate; +u64 ceil; +u32 prio; +/* hw txschq */ +u8 level;a one byte hole here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 61
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+u16 schq; +u16 qid; +u16 prio_anchor;another four byte hole here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 64
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+DECLARE_BITMAP (prio_bmap,OTX2_QOS_MAX_PRIO +1 ); +/* list management */ +struct hlist_node hlist;the first cacheline ends here,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 65
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +1
-0+struct otx2_qos_node *parent;/* parent qos node */ And this is an 8 byte entity.
I'm not sure if it is advantagous,
but I think parent could be moved to the first cacheline.drivers/net/ethernet/marvell/octeontx2/nic/qos.h line 69
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +3
-0+struct list_head list; +struct list_head child_list; +struct list_head child_schq_list; };$ pahole drivers/net/ethernet/marvell/octeontx2/nic/qos.o ... struct otx2_qos_node { u32 classid; /* 0 4 *//* XXX 4 bytes hole, try to pack */
u64 rate; /* 8 8 */
u64 ceil; /* 16 8 */
u32 prio; /* 24 4 */
u8 level; /* 28 1 *//* XXX 1 byte hole, try to pack */
u16 schq; /* 30 2 */
u16 qid; /* 32 2 */
u16prio_anchor; /* 34 2 *//* XXX 4 bytes hole, try to pack */
long unsigned int prio_bmap[1]; /* 40 8 */
structhlist_nodehlist; /* 48 16 */
/* --- cacheline 1 boundary (64 bytes) --- */
structotx2_qos_node* parent; /* 64 8 */
structlist_headlist; /* 72 16 */
structlist_headchild_list; /* 88 16 */
structlist_headchild_schq_list; /* 104 16 *//* size: 120, cachelines: 2, members: 14 */ /* sum members: 111, holes: 3, sum holes: 9 */ /* last cacheline: 56 bytes */
};
...
Jakub Kicinski
maintainerQuoted 8 lines · On Fri, 10 Feb 2023 16:40:47 +0530 Hariprasad Kelam wrote:
octeontx2 silicon and CN10K transmit interface consists of five transmit levels starting from MDQ, TL4 to TL1. Once packets are submitted to MDQ, hardware picks all active MDQs using strict priority, and MDQs having the same priority level are chosen using round robin. Each packet will traverse MDQ, TL4 to TL1 levels. Each level contains an array of queues to support scheduling and shaping.
Quoted 4 lines
As HTB supports classful queuing mechanism by supporting rate and ceil and allow the user to control the absolute bandwidth to particular classes of traffic the same can be achieved by configuring shapers and schedulers on different transmit levels.
Please provide or link to some user-facing documentation under Documentation/networking/device_drivers/ethernet/marvell/octeon...
Quoted 11 lines · On Fri, 10 Feb 2023 16:40:47 +0530 Hariprasad Kelam wrote:
Quoted 8 lines
octeontx2 silicon and CN10K transmit interface consists of five transmit levels starting from MDQ, TL4 to TL1. Once packets are submitted to MDQ, hardware picks all active MDQs using strict priority, and MDQs having the same priority level are chosen using round robin. Each packet will traverse MDQ, TL4 to TL1 levels. Each level contains an array of queues to support scheduling and shaping.
Quoted 7 lines
Quoted 4 lines
As HTB supports classful queuing mechanism by supporting rate and ceil and allow the user to control the absolute bandwidth to particular classes of traffic the same can be achieved by configuring shapers and schedulers on different transmit levels.
Please provide or link to some user-facing documentation under
Documentation/networking/device_drivers/ethernet/marvell/octeon...
ACK, will add in next version.