diff mbox series

[v2,16/37] net/mvpp2: add Tx flow control

Message ID 20210122191925.24308-17-lironh@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers show
Series net/mvpp2: misc updates | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Liron Himi Jan. 22, 2021, 7:19 p.m. UTC
From: Yuri Chipchev <yuric@marvell.com>

Add tx flow control operations.

Signed-off-by: Yuri Chipchev <yuric@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 59 ++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 71a6e8826..ef567d378 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -2039,6 +2039,19 @@  mrvl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 
 	fc_conf->mode = en ? RTE_FC_RX_PAUSE : RTE_FC_NONE;
 
+	ret = pp2_ppio_get_tx_pause(priv->ppio, &en);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to read tx pause state");
+		return ret;
+	}
+
+	if (en) {
+		if (fc_conf->mode == RTE_FC_NONE)
+			fc_conf->mode = RTE_FC_TX_PAUSE;
+		else
+			fc_conf->mode = RTE_FC_FULL;
+	}
+
 	return 0;
 }
 
@@ -2057,6 +2070,9 @@  static int
 mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
+	struct pp2_ppio_tx_pause_params mrvl_pause_params;
+	int ret;
+	int rx_en, tx_en;
 
 	if (!priv)
 		return -EPERM;
@@ -2071,16 +2087,43 @@  mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		return -EINVAL;
 	}
 
-	if (fc_conf->mode == RTE_FC_NONE ||
-	    fc_conf->mode == RTE_FC_RX_PAUSE) {
-		int ret, en;
+	switch (fc_conf->mode) {
+	case RTE_FC_FULL:
+		rx_en = 1;
+		tx_en = 1;
+		break;
+	case RTE_FC_TX_PAUSE:
+		rx_en = 0;
+		tx_en = 1;
+		break;
+	case RTE_FC_RX_PAUSE:
+		rx_en = 1;
+		tx_en = 0;
+		break;
+	case RTE_FC_NONE:
+		rx_en = 0;
+		tx_en = 0;
+		break;
+	default:
+		MRVL_LOG(ERR, "Incorrect Flow control flag (%d)",
+			 fc_conf->mode);
+		return -EINVAL;
+	}
 
-		en = fc_conf->mode == RTE_FC_NONE ? 0 : 1;
-		ret = pp2_ppio_set_rx_pause(priv->ppio, en);
-		if (ret)
-			MRVL_LOG(ERR,
-				"Failed to change flowctrl on RX side");
+	/* Set RX flow control */
+	ret = pp2_ppio_set_rx_pause(priv->ppio, rx_en);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change RX flowctrl");
+		return ret;
+	}
 
+	/* Set TX flow control */
+	mrvl_pause_params.en = tx_en;
+	/* all inqs participate in xon/xoff decision */
+	mrvl_pause_params.use_tc_pause_inqs = 0;
+	ret = pp2_ppio_set_tx_pause(priv->ppio, &mrvl_pause_params);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change TX flowctrl");
 		return ret;
 	}