Skip to content

Commit 5e6808b

Browse files
Naveen Mamindlapallidavem330
authored andcommitted
octeontx2-pf: Add support for HTB offload
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]> Signed-off-by: David S. Miller <[email protected]>
1 parent cb748a7 commit 5e6808b

File tree

10 files changed

+1507
-14
lines changed

10 files changed

+1507
-14
lines changed

drivers/net/ethernet/marvell/octeontx2/af/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ enum nix_scheduler {
142142

143143
#define TXSCH_RR_QTM_MAX ((1 << 24) - 1)
144144
#define TXSCH_TL1_DFLT_RR_QTM TXSCH_RR_QTM_MAX
145-
#define TXSCH_TL1_DFLT_RR_PRIO (0x1ull)
145+
#define TXSCH_TL1_DFLT_RR_PRIO (0x7ull)
146146
#define CN10K_MAX_DWRR_WEIGHT 16384 /* Weight is 14bit on CN10K */
147147

148148
/* Min/Max packet sizes, excluding FCS */

drivers/net/ethernet/marvell/octeontx2/nic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_OCTEONTX2_VF) += rvu_nicvf.o otx2_ptp.o
88

99
rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \
1010
otx2_flows.o otx2_tc.o cn10k.o otx2_dmac_flt.o \
11-
otx2_devlink.o qos_sq.o
11+
otx2_devlink.o qos_sq.o qos.o
1212
rvu_nicvf-y := otx2_vf.o otx2_devlink.o
1313

1414
rvu_nicpf-$(CONFIG_DCB) += otx2_dcbnl.o

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx)
8989
if (!pfvf->qset.sq)
9090
return 0;
9191

92+
if (qidx >= pfvf->hw.non_qos_queues) {
93+
if (!test_bit(qidx - pfvf->hw.non_qos_queues, pfvf->qos.qos_sq_bmap))
94+
return 0;
95+
}
96+
9297
otx2_nix_sq_op_stats(&sq->stats, pfvf, qidx);
9398
return 1;
9499
}

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,18 @@ static inline void otx2_qos_init(struct otx2_nic *pfvf, int qos_txqs)
10991099
struct otx2_hw *hw = &pfvf->hw;
11001100

11011101
hw->tc_tx_queues = qos_txqs;
1102+
INIT_LIST_HEAD(&pfvf->qos.qos_tree);
1103+
mutex_init(&pfvf->qos.qos_lock);
1104+
}
1105+
1106+
static inline void otx2_shutdown_qos(struct otx2_nic *pfvf)
1107+
{
1108+
mutex_destroy(&pfvf->qos.qos_lock);
11021109
}
11031110

11041111
u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb,
11051112
struct net_device *sb_dev);
1113+
int otx2_get_txq_by_classid(struct otx2_nic *pfvf, u16 classid);
1114+
void otx2_qos_config_txschq(struct otx2_nic *pfvf);
1115+
void otx2_clean_qos_queues(struct otx2_nic *pfvf);
11061116
#endif /* OTX2_COMMON_H */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,9 @@ static void otx2_free_sq_res(struct otx2_nic *pf)
13871387
otx2_sq_free_sqbs(pf);
13881388
for (qidx = 0; qidx < otx2_get_total_tx_queues(pf); qidx++) {
13891389
sq = &qset->sq[qidx];
1390+
/* Skip freeing Qos queues if they are not initialized */
1391+
if (!sq->sqe)
1392+
continue;
13901393
qmem_free(pf->dev, sq->sqe);
13911394
qmem_free(pf->dev, sq->tso_hdrs);
13921395
kfree(sq->sg);
@@ -1566,6 +1569,8 @@ static void otx2_free_hw_resources(struct otx2_nic *pf)
15661569
otx2_pfc_txschq_stop(pf);
15671570
#endif
15681571

1572+
otx2_clean_qos_queues(pf);
1573+
15691574
mutex_lock(&mbox->lock);
15701575
/* Disable backpressure */
15711576
if (!(pf->pcifunc & RVU_PFVF_FUNC_MASK))
@@ -1710,7 +1715,7 @@ int otx2_open(struct net_device *netdev)
17101715
if (!qset->cq)
17111716
goto err_free_mem;
17121717

1713-
qset->sq = kcalloc(pf->hw.non_qos_queues,
1718+
qset->sq = kcalloc(otx2_get_total_tx_queues(pf),
17141719
sizeof(struct otx2_snd_queue), GFP_KERNEL);
17151720
if (!qset->sq)
17161721
goto err_free_mem;
@@ -1833,6 +1838,9 @@ int otx2_open(struct net_device *netdev)
18331838
/* 'intf_down' may be checked on any cpu */
18341839
smp_wmb();
18351840

1841+
/* Enable QoS configuration before starting tx queues */
1842+
otx2_qos_config_txschq(pf);
1843+
18361844
/* we have already received link status notification */
18371845
if (pf->linfo.link_up && !(pf->pcifunc & RVU_PFVF_FUNC_MASK))
18381846
otx2_handle_link_event(pf);
@@ -1986,14 +1994,48 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
19861994
return NETDEV_TX_OK;
19871995
}
19881996

1997+
static int otx2_qos_select_htb_queue(struct otx2_nic *pf, struct sk_buff *skb,
1998+
u16 htb_maj_id)
1999+
{
2000+
u16 classid;
2001+
2002+
if ((TC_H_MAJ(skb->priority) >> 16) == htb_maj_id)
2003+
classid = TC_H_MIN(skb->priority);
2004+
else
2005+
classid = READ_ONCE(pf->qos.defcls);
2006+
2007+
if (!classid)
2008+
return 0;
2009+
2010+
return otx2_get_txq_by_classid(pf, classid);
2011+
}
2012+
19892013
u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb,
19902014
struct net_device *sb_dev)
19912015
{
1992-
#ifdef CONFIG_DCB
19932016
struct otx2_nic *pf = netdev_priv(netdev);
2017+
bool qos_enabled;
2018+
#ifdef CONFIG_DCB
19942019
u8 vlan_prio;
19952020
#endif
2021+
int txq;
2022+
2023+
qos_enabled = (netdev->real_num_tx_queues > pf->hw.tx_queues) ? true : false;
2024+
if (unlikely(qos_enabled)) {
2025+
/* This smp_load_acquire() pairs with smp_store_release() in
2026+
* otx2_qos_root_add() called from htb offload root creation
2027+
*/
2028+
u16 htb_maj_id = smp_load_acquire(&pf->qos.maj_id);
19962029

2030+
if (unlikely(htb_maj_id)) {
2031+
txq = otx2_qos_select_htb_queue(pf, skb, htb_maj_id);
2032+
if (txq > 0)
2033+
return txq;
2034+
goto process_pfc;
2035+
}
2036+
}
2037+
2038+
process_pfc:
19972039
#ifdef CONFIG_DCB
19982040
if (!skb_vlan_tag_present(skb))
19992041
goto pick_tx;
@@ -2007,7 +2049,11 @@ u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb,
20072049

20082050
pick_tx:
20092051
#endif
2010-
return netdev_pick_tx(netdev, skb, NULL);
2052+
txq = netdev_pick_tx(netdev, skb, NULL);
2053+
if (unlikely(qos_enabled))
2054+
return txq % pf->hw.tx_queues;
2055+
2056+
return txq;
20112057
}
20122058
EXPORT_SYMBOL(otx2_select_queue);
20132059

@@ -3121,6 +3167,7 @@ static void otx2_remove(struct pci_dev *pdev)
31213167
otx2_ptp_destroy(pf);
31223168
otx2_mcam_flow_del(pf);
31233169
otx2_shutdown_tc(pf);
3170+
otx2_shutdown_qos(pf);
31243171
otx2_detach_resources(&pf->mbox);
31253172
if (pf->hw.lmt_info)
31263173
free_percpu(pf->hw.lmt_info);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "cn10k.h"
2121
#include "otx2_common.h"
22+
#include "qos.h"
2223

2324
#define CN10K_MAX_BURST_MANTISSA 0x7FFFULL
2425
#define CN10K_MAX_BURST_SIZE 8453888ULL
@@ -132,8 +133,8 @@ static void otx2_get_egress_rate_cfg(u64 maxrate, u32 *exp,
132133
}
133134
}
134135

135-
static u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic,
136-
u64 maxrate, u32 burst)
136+
u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic,
137+
u64 maxrate, u32 burst)
137138
{
138139
u32 burst_exp, burst_mantissa;
139140
u32 exp, mantissa, div_exp;
@@ -1109,6 +1110,8 @@ int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
11091110
switch (type) {
11101111
case TC_SETUP_BLOCK:
11111112
return otx2_setup_tc_block(netdev, type_data);
1113+
case TC_SETUP_QDISC_HTB:
1114+
return otx2_setup_tc_htb(netdev, type_data);
11121115
default:
11131116
return -EOPNOTSUPP;
11141117
}

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ static void otx2vf_remove(struct pci_dev *pdev)
760760
otx2_ptp_destroy(vf);
761761
otx2_mcam_flow_del(vf);
762762
otx2_shutdown_tc(vf);
763+
otx2_shutdown_qos(vf);
763764
otx2vf_disable_mbox_intr(vf);
764765
otx2_detach_resources(&vf->mbox);
765766
free_percpu(vf->hw.lmt_info);

0 commit comments

Comments
 (0)