octeontx2-pf: Add egress PFC support
PATCH v5 1/1 octeontx2-pf: Add egress PFC support
As of now all transmit queues transmit packets out of same scheduler queue hierarchy. Due to this PFC frames sent by peer are not handled properly, either all transmit queues are backpressured or none. To fix this when user enables PFC for a given priority map relavant transmit queue to a different scheduler queue hierarcy, so that backpressure is applied only to the traffic egressing out of that TXQ.
---
Changes since v4:
- Fixed compilation issue for rvu_nicvf.ko
.../ethernet/marvell/octeontx2/nic/cn10k.c | 3 +- .../marvell/octeontx2/nic/otx2_common.c | 59 +++- .../marvell/octeontx2/nic/otx2_common.h | 28 +- .../marvell/octeontx2/nic/otx2_dcbnl.c | 300 ++++++++++++++++++ .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 56 +++- 5 files changed, 429 insertions(+), 17 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +1 -2
@@ -86,8 +86,7 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura) aq->sq.max_sqe_size =NIX_MAXSQESZ_W16 ;/* 128 byte */ aq->sq.cq_ena =1 ; aq->sq.ena =1 ; -/* Only one SMQ is allocated, map all SQ's to that SMQ */ - aq->sq.smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ ][0 ]; + aq->sq.smq =otx2_get_smq_idx (pfvf, qidx); aq->sq.smq_rr_weight =mtu_to_dwrr_weight (pfvf, pfvf->tx_max_pktlen); aq->sq.default_chan = pfvf->hw.tx_chan_base; aq->sq.sqe_stype =NIX_STYPE_STF ;/* Cache SQB */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +47 -12
116 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +26 -2
@@ -40,6 +40,11 @@#define NAME_SIZE 32 +#ifdef CONFIG_DCB +/* Max priority supported for PFC */ +#define NIX_PF_PFC_PRIO_MAX 8 +#endif +enum arua_mapped_qtypes {AURA_NIX_RQ ,AURA_NIX_SQ ,
@@ -196,7 +201,7 @@ struct otx2_hw {/* NIX */ u8 txschq_link_cfg_lvl; -u16 txschq_list[NIX_TXSCH_LVL_CNT ][MAX_TXSCHQ_PER_FUNC ]; +u16 txschq_list[NIX_TXSCH_LVL_CNT ][MAX_TXSCHQ_PER_FUNC ];u16 matchall_ipolicer;u32 dwrr_mtu;
@@ -415,6 +420,8 @@ struct otx2_nic {/* PFC */ u8 pfc_en;u8 *queue_to_pfc_map; +u16 pfc_schq_list[NIX_TXSCH_LVL_CNT ][MAX_TXSCHQ_PER_FUNC ]; +bool pfc_alloc_status[NIX_PF_PFC_PRIO_MAX ];#endif /* napi event count. It is needed for adaptive irq coalescing. */
@@ -785,6 +792,16 @@ static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf, dir, DMA_ATTR_SKIP_CPU_SYNC); } +static inline u16 otx2_get_smq_idx (struct otx2_nic *pfvf,u16 qidx) +{ +#ifdef CONFIG_DCB +if (pfvf->pfc_alloc_status[qidx]) +return pfvf->pfc_schq_list[NIX_TXSCH_LVL_SMQ ][qidx]; +#endif + +return pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ ][0 ]; +} +/* MSI-X APIs */ void otx2_free_cints (struct otx2_nic *pfvf,int n);void otx2_set_cints_affinity (struct otx2_nic *pfvf);
@@ -807,7 +824,7 @@ void otx2_free_aura_ptr(struct otx2_nic *pfvf, int type);void otx2_sq_free_sqbs (struct otx2_nic *pfvf);int otx2_config_nix (struct otx2_nic *pfvf);int otx2_config_nix_queues (struct otx2_nic *pfvf); -int otx2_txschq_config (struct otx2_nic *pfvf,int lvl); +int otx2_txschq_config (struct otx2_nic *pfvf,int lvl,int prio,bool pfc_en);int otx2_txsch_alloc (struct otx2_nic *pfvf);int otx2_txschq_stop (struct otx2_nic *pfvf);void otx2_sqb_flush (struct otx2_nic *pfvf);
@@ -888,6 +905,8 @@ bool otx2_xdp_sq_append_pkt(struct otx2_nic *pfvf, u64 iova, int len, u16 qidx);u16 otx2_get_max_mtu (struct otx2_nic *pfvf);int otx2_handle_ntuple_tc_features (struct net_device *netdev,netdev_features_t features); +int otx2_smq_flush (struct otx2_nic *pfvf,int smq); +/* tc support */ int otx2_init_tc (struct otx2_nic *nic);void otx2_shutdown_tc (struct otx2_nic *nic);
@@ -907,5 +926,10 @@ void otx2_dmacflt_update_pfmac_flow(struct otx2_nic *pfvf);void otx2_update_bpid_in_rqctx (struct otx2_nic *pfvf,int vlan_prio,int qidx,bool pfc_enable);int otx2_config_priority_flow_ctrl (struct otx2_nic *pfvf);int otx2_dcbnl_set_ops (struct net_device *dev); +/* PFC support */ +int otx2_pfc_txschq_config (struct otx2_nic *pfvf); +int otx2_pfc_txschq_alloc (struct otx2_nic *pfvf); +int otx2_pfc_txschq_update (struct otx2_nic *pfvf); +int otx2_pfc_txschq_stop (struct otx2_nic *pfvf);#endif #endif /* OTX2_COMMON_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c +300 -0
318 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +55 -1
91 lines not on this page · raw message
Signature · 1 line
2.25.1
Paolo Abeni
maintainerHello,
Just a couple of minor nit, see below.
On Fri, 2022-08-26 at 13:27 +0530, Suman Ghosh wrote:
[...]
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c line 208
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c +5
-0+int otx2_pfc_txschq_update (struct otx2_nic *pfvf) +{ +u8 pfc_en = pfvf->pfc_en, pfc_bit_set; +struct mbox *mbox = &pfvf->mbox; +bool if_up =netif_running (pfvf->netdev);
please, respect the reverse x-mas tree in variables declaration.
[...]
Quoted 18 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +14
-0@@ -1853,6 +1880,32 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)return NETDEV_TX_OK ; } +static u16 otx2_select_queue (struct net_device *netdev,struct sk_buff *skb, +struct net_device *sb_dev) +{ +struct otx2_nic *pf =netdev_priv (netdev); +#ifdef CONFIG_DCB +u8 vlan_prio; +#endif +int txq; + +#ifdef CONFIG_DCB +if (!skb->vlan_present) + goto pick_tx; + + vlan_prio = skb->vlan_tci >>13 ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev) · line 1906
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +10
-0+if ((vlan_prio > pf->hw.tx_queues -1 ) || + !pf->pfc_alloc_status[vlan_prio]) + goto pick_tx; + +return vlan_prio; + +pick_tx: +#endif + txq =netdev_pick_tx (netdev, skb,NULL ); +return txq;
You can just
return netdev_pick_tx(netdev, skb, NULL);
and avoid declaring txq.
Cheers,
Paolo
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c line 208
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c +4
-0+int otx2_pfc_txschq_update (struct otx2_nic *pfvf) { +u8 pfc_en = pfvf->pfc_en, pfc_bit_set; +struct mbox *mbox = &pfvf->mbox; +bool if_up =netif_running (pfvf->netdev);please, respect the reverse x-mas tree in variables declaration.
[Suman] Done
Quoted 33 lines
[...]
Review static netdev_tx_t otx2_xmit(struct sk_buff
Quoted 1 line
(quoted diff) +0
-0@@ -1853,6 +1880,32 @@ static netdev_tx_t otx2_xmit(struct sk_buff*skb, struct
net_device*netdev)drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1
-0return NETDEV_TX_OK ; } +static u16 otx2_select_queue(struct net_device *netdev, struct
sk_buff*skb,Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +12
-0+ struct net_device *sb_dev) +{ +struct otx2_nic *pf =netdev_priv (netdev);#ifdef CONFIG_DCB +u8 vlan_prio; +#endif +int txq; + +#ifdef CONFIG_DCB +if (!skb->vlan_present) + goto pick_tx; + + vlan_prio = skb->vlan_tci >>13 ;drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev) · line 1906
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +10
-0+if ((vlan_prio > pf->hw.tx_queues -1 ) || + !pf->pfc_alloc_status[vlan_prio]) + goto pick_tx; + +return vlan_prio; + +pick_tx: +#endif + txq =netdev_pick_tx (netdev, skb,NULL ); +return txq;You can just
Quoted 3 lines
return netdev_pick_tx(netdev, skb, NULL);and avoid declaring txq.
[Suman] Done
Quoted 4 lines
Cheers,
Paolo