Skip to contentSkip to conversation

octeontx2-pf: Add egress PFC support

PATCH Superseded Suman Ghosh 2 participants 5 messages Aug 23, 2022 – Aug 24, 2022

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 .../ethernet/marvell/octeontx2/nic/cn10k.c    |   3 +-
 .../marvell/octeontx2/nic/otx2_common.c       | 349 +++++++++++++++++-
 .../marvell/octeontx2/nic/otx2_common.h       |  29 +-
 .../marvell/octeontx2/nic/otx2_dcbnl.c        |  35 ++
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |  56 ++-
 5 files changed, 455 insertions(+), 17 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +1 -2
index fd4f083c699e..826f691de259 100644
@@ -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 +337 -12

405 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +27 -2
index b28029cc4316..eae593f67ddb 100644
@@ -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][NIX_PF_PFC_PRIO_MAX];
+	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,9 +824,15 @@ 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);
+#ifdef CONFIG_DCB
+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
 void otx2_sqb_flush(struct otx2_nic *pfvf);
 int __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
 		      dma_addr_t *dma);
@@ -888,6 +911,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);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c +35 -0
index 723d2506d309..4864794200f3 100644
@@ -7,6 +7,24 @@
 
 #include "otx2_common.h"
 
+static int otx2_check_pfc_config(struct otx2_nic *pfvf)
+{
+	u8 tx_queues = pfvf->hw.tx_queues, prio;
+	u8 pfc_en = pfvf->pfc_en;
+
+	for (prio = 0; prio < NIX_PF_PFC_PRIO_MAX; prio++) {
+		if ((pfc_en & (1 << prio)) &&
+		    prio > tx_queues - 1) {
+			dev_warn(pfvf->dev,
+				 "Increase number of tx queues from %d to %d to support PFC.\n",
+				 tx_queues, prio + 1);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 int otx2_config_priority_flow_ctrl(struct otx2_nic *pfvf)
 {
 	struct cgx_pfc_cfg *req;
@@ -128,6 +146,17 @@ static int otx2_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
 	/* Save PFC configuration to interface */
 	pfvf->pfc_en = pfc->pfc_en;
 
+	if (pfvf->hw.tx_queues >= NIX_PF_PFC_PRIO_MAX)
+		goto process_pfc;
+
+	/* Check if the PFC configuration can be
+	 * supported by the tx queue configuration
+	 */
+	err = otx2_check_pfc_config(pfvf);
+	if (err)
+		return err;
+
+process_pfc:
 	err = otx2_config_priority_flow_ctrl(pfvf);
 	if (err)
 		return err;
@@ -136,6 +165,12 @@ static int otx2_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
 	if (pfc->pfc_en)
 		otx2_nix_config_bp(pfvf, true);
 
+	err = otx2_pfc_txschq_update(pfvf);
+	if (err) {
+		dev_err(pfvf->dev, "%s failed to update TX schedulers\n", __func__);
+		return err;
+	}
+
 	return 0;
 }
 
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
#1 lore raw
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +1 -1
-int otx2_txschq_config(struct otx2_nic *pfvf, int lvl)
+int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for_pfc)
 {
 	struct otx2_hw *hw = &pfvf->hw;
 	struct nix_txschq_config *req;

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 609

Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -1
@@ -602,7 +602,13 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl)
 	req->lvl = lvl;
 	req->num_regs = 1;
 
-	schq = hw->txschq_list[lvl][0];
+#ifdef CONFIG_DCB
+	if (txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
+	else
+#endif

Please could you try to remove as many of these #ifdef CONFIG_DCB as possible. It makes build testing less efficient at finding build problems. Can you do:

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 746

Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +12 -0
+	if (IS_ENABLED(CONFIG_DCB) && txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
 
+#ifdef CONFIG_DCB
+int otx2_pfc_txschq_config(struct otx2_nic *pfvf)
+{
+	u8 pfc_en, pfc_bit_set;
+	int prio, lvl, err;
+
+	pfc_en = pfvf->pfc_en;
+	for (prio = 0; prio < NIX_PF_PFC_PRIO_MAX; prio++) {
+		pfc_bit_set = pfc_en & (1 << prio);
+

Maybe put all of this into a file of its own, and provide stubs for when it is not enabled?

Andrew

#2 lore raw

Please see inline

Regards,
Suman

Quoted 37 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Tuesday, August 23, 2022 9:21 PM
To: Suman Ghosh <[email protected]>
Cc: Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH] octeontx2-pf: Add egress PFC support

External Email

----------------------------------------------------------------------

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int

Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -1
-int otx2_txschq_config(struct otx2_nic *pfvf, int lvl)
+int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool
+txschq_for_pfc)
 {
 	struct otx2_hw *hw = &pfvf->hw;
 	struct nix_txschq_config *req;
@@ -602,7 +602,13 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int

lvl)

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 609

Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -1
 	req->lvl = lvl;
 	req->num_regs = 1;
 
-	schq = hw->txschq_list[lvl][0];
+#ifdef CONFIG_DCB
+	if (txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
+	else
+#endif

Please could you try to remove as many of these #ifdef CONFIG_DCB as possible. It makes build testing less efficient at finding build problems. Can you do:

Quoted 3 lines

Review int otx2_txschq_config(struct otx2_nic *pfvf, int · line 611

Quoted 2 lines
(quoted diff) +2 -0
+	if (IS_ENABLED(CONFIG_DCB) && txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];

[Suman] I will restructured the code. But we cannot use pfvf->pfc_schq_list outside #ifdef CONFIG_DCB as these are defined under the macro in otx2_common.h

Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +4 -0
+#ifdef CONFIG_DCB
+int otx2_pfc_txschq_config(struct otx2_nic *pfvf) {
+	u8 pfc_en, pfc_bit_set;
+	int prio, lvl, err;
Quoted 8 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 746

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -0
+
+	pfc_en = pfvf->pfc_en;
+	for (prio = 0; prio < NIX_PF_PFC_PRIO_MAX; prio++) {
+		pfc_bit_set = pfc_en & (1 << prio);
+

Maybe put all of this into a file of its own, and provide stubs for when it is not enabled?

[Suman] I will move these APIs to otx2_dcbnl.c. This file will be compiled when CONFIG_DCB is enabled.

Quoted 2 lines

Andrew

#3 lore raw
Quoted 11 lines
Quoted 11 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 609

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -1
-	schq = hw->txschq_list[lvl][0];
+#ifdef CONFIG_DCB
+	if (txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
+	else
+#endif

Please could you try to remove as many of these #ifdef CONFIG_DCB as possible. It makes build testing less efficient at finding build problems. Can you do:

Quoted 5 lines
Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (IS_ENABLED(CONFIG_DCB) && txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];

[Suman] I will restructured the code. But we cannot use pfvf->pfc_schq_list outside #ifdef CONFIG_DCB as these are defined under the macro in otx2_common.h

So maybe add a getter and setter in otx2_common.h, which returns -EOPNOTSUPP or similar when CONFIG_DCB is disabled?

Andrew

#4 lore raw
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) · line 609

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -1
-	schq = hw->txschq_list[lvl][0];
+#ifdef CONFIG_DCB
+	if (txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
+	else
+#endif

Please could you try to remove as many of these #ifdef CONFIG_DCB as possible. It makes build testing less efficient at finding build problems. Can you do:

Quoted 2 lines
(quoted diff) +2 -0
+	if (IS_ENABLED(CONFIG_DCB) && txschq_for_pfc)
+		schq = pfvf->pfc_schq_list[lvl][prio];
Quoted 8 lines
Quoted 3 lines

[Suman] I will restructured the code. But we cannot use pfvf->pfc_schq_list outside #ifdef CONFIG_DCB as these are defined under the macro in otx2_common.h

So maybe add a getter and setter in otx2_common.h, which returns - EOPNOTSUPP or similar when CONFIG_DCB is disabled?

Andrew

[Suman] I have updated the patch and using CONFIG_DCB only once in the function. Can you please check if that should be okay?