octeontx2-pf: add mqprio bandwidth offload for NIX TX schedulers
Subsystems (4)
Ratheesh Kannoth
maintainerPATCH v4 1/1 octeontx2-pf: add mqprio bandwidth offload for NIX TX schedulers
Add TC_SETUP_QDISC_MQPRIO handling to program per-queue MDQ CIR/PIR shaping after mqprio channel mode setup, widen SMQ allocation when per-queue rate limiting is enabled, and align MDQ parents under that mode. Reuse otx2_convert_rate for bps-to-Mbps, fix sparse register writes when only one of min/max is set, and improve AF txschq map mismatch diagnostics.
Configuration examples:
1) Set up commands
a. ifconfig eth0 xx.xx.xx.xx up
b. tc qdisc add dev eth0 parent root handle 100 mqprio num_tc 4 \
map 0 1 2 3 queues 1@0 1@1 1@2 1@3 hw 1 mode channel shaper \
bw_rlimit \
min_rate 100Mbit 200Mbit 300Mbit 400Mbit \
max_rate 150Mbit 250Mbit 350Mbit 450Mbit
c. iptables -t mangle -A POSTROUTING -p udp -j CLASSIFY --set-class 0:1
This will guarantee max rate as 250Mbits for UDP traffic
2) Tear down mqprio
a. ifconfig eth0 up
b. tc qdisc del dev eth0 root
---
v3 -> v4: Addressed sashiko comments
https://lore.kernel.org/netdev/[email protected]/ v2 -> v3: Addressed sashiko comments https://lore.kernel.org/netdev/amnYX866mYx02cBe@rkannoth-OptiPlex-7090/T/#m67310cbec48b21c7720858ab3a1ea083a0f8dc10 v1 -> v2: Addressed sashiko comments https://lore.kernel.org/netdev/[email protected]/ --- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 6 +- .../marvell/octeontx2/nic/otx2_common.c | 142 +++++++++++++- .../marvell/octeontx2/nic/otx2_common.h | 5 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 3 + .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 180 ++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/qos.c | 12 ++ .../net/ethernet/marvell/octeontx2/nic/qos.h | 1 + 7 files changed, 347 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +5 -1
@@ -331,8 +331,12 @@ static bool is_valid_txschq(struct rvu *rvu, int blkaddr,return true; } -if (map_func != pcifunc) +if (map_func != pcifunc) { +dev_err_ratelimited (rvu->dev, +"pcifunc %x map pcifunc %x not equal, lvl=%u schq=%u\n" , + pcifunc, map_func, lvl, schq);return false; + }return true; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +141 -1
160 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +5 -0
@@ -512,6 +512,7 @@ struct otx2_nic {#define OTX2_FLAG_REP_MODE_ENABLED BIT_ULL(18)#define OTX2_FLAG_PORT_UP BIT_ULL(19)#define OTX2_FLAG_IPSEC_OFFLOAD_ENABLED BIT_ULL(20) +#define OTX2_FLAG_PER_Q_RATE_LIMIT_ENABLED BIT_ULL(21)u64 flags;u64 *cq_op_addr;
@@ -1246,6 +1247,10 @@ dma_addr_t otx2_dma_map_skb_frag(struct otx2_nic *pfvf, struct sk_buff *skb, int seg, int *len);void otx2_dma_unmap_skb_frags (struct otx2_nic *pfvf,struct sg_list *sg);int otx2_read_free_sqe (struct otx2_nic *pfvf,u16 qidx); +int otx2_nix_tm_set_queue_shaper (struct otx2_nic *pfvf,int txq, +u64 minrate,u64 maxrate); +int otx2_nix_tm_clear_queue_shaper (struct otx2_nic *pfvf); +void otx2_mqprio_down (struct otx2_nic *pfvf);void otx2_queue_vf_work (struct mbox *mw,struct workqueue_struct *mbox_wq,int first,int mdevs,u64 intr); int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry,
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3 -0
@@ -2158,6 +2158,9 @@ int otx2_stop(struct net_device *netdev)if (pf->flags &OTX2_FLAG_INTF_DOWN )return 0 ; +/* Mqprio offload is not preserved across stop; user must reconfigure. */ +otx2_mqprio_down (pf); +netif_carrier_off (netdev);netif_tx_stop_all_queues (netdev);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +180 -0
198 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/qos.c +12 -0
@@ -1729,11 +1729,23 @@ void otx2_qos_config_txschq(struct otx2_nic *pfvf)otx2_qos_root_destroy (pfvf); } +bool otx2_qos_htb_active (struct otx2_nic *pfvf) +{ +return otx2_sw_node_find (pfvf,OTX2_QOS_ROOT_CLASSID ); +} +int otx2_setup_tc_htb (struct net_device *ndev,struct tc_htb_qopt_offload *htb) {struct otx2_nic *pfvf =netdev_priv (ndev);int res; +if ((pfvf->flags &OTX2_FLAG_PER_Q_RATE_LIMIT_ENABLED ) && + htb->command !=TC_HTB_DESTROY ) { +NL_SET_ERR_MSG_MOD (htb->extack, +"HTB offload cannot be used with mqprio bandwidth offload active" ); +return -EOPNOTSUPP ; + } +switch (htb->command) {case TC_HTB_CREATE : return otx2_qos_root_add(pfvf, htb->parent_classid,
drivers/net/ethernet/marvell/octeontx2/nic/qos.h +1 -0
@@ -23,6 +23,7 @@ enum qos_smq_operations {u64 otx2_get_txschq_rate_regval (struct otx2_nic *nic,u64 maxrate,u32 burst);int otx2_setup_tc_htb (struct net_device *ndev,struct tc_htb_qopt_offload *htb); +bool otx2_qos_htb_active (struct otx2_nic *pfvf);int otx2_qos_get_qid (struct otx2_nic *pfvf);void otx2_qos_free_qid (struct otx2_nic *pfvf,int qidx);int otx2_qos_enable_sq (struct otx2_nic *pfvf,int qidx);
Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerQuoted 20 lines · Ratheesh Kannoth
Add
TC_SETUP_QDISC_MQPRIOhandling to program per-queue MDQ CIR/PIR shaping after mqprio channel mode setup, widen SMQ allocation when per-queue rate limiting is enabled, and align MDQ parents under that mode. Reuseotx2_convert_ratefor bps-to-Mbps, fix sparse register writes when only one of min/max is set, and improve AF txschq map mismatch diagnostics.Configuration examples:
1) Set up commands
a. ifconfig eth0 xx.xx.xx.xx up
b. tc qdisc add dev eth0 parent root handle 100 mqprionum_tc4 \map 0 1 2 3 queues 1@0 1@1 1@2 1@3 hw 1 mode channel shaper \ bw_rlimit \ min_rate 100Mbit 200Mbit 300Mbit 400Mbit \ max_rate 150Mbit 250Mbit 350Mbit 450Mbitc. iptables -t mangle -A POSTROUTING -p udp -j CLASSIFY --set-class 0:1
Quoted 8 lines
This will guarantee max rate as 250Mbits for UDP traffic
2) Tear down mqprio
a. ifconfig eth0 up
b. tc qdisc del dev eth0 rootSigned-off-by Ratheesh Kannoth <[email protected]>
Will address sashiko comments in v5
pw-bot: changes-requested