diff mbox series

[v1,32/38] net/mvpp2: apply flow-ctrl after port init

Message ID 20201202101212.4717-33-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 Dec. 2, 2020, 10:12 a.m. UTC
From: Liron Himi <lironh@marvell.com>

in case ppio was not initialized yet (only at 'start' function)
the flow-ctrl setting should be saved for later stage.

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 26 +++++++++++++++++++++-----
 drivers/net/mvpp2/mrvl_ethdev.h |  2 ++
 2 files changed, 23 insertions(+), 5 deletions(-)

Comments

Michael Shamis Dec. 23, 2020, 9:30 a.m. UTC | #1
Reviewed-by: Michael Shamis <michaelsh@marvell.com>

-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of lironh@marvell.com
Sent: Wednesday, December 2, 2020 12:12 PM
To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Cc: dev@dpdk.org; Liron Himi <lironh@marvell.com>
Subject: [dpdk-dev] [PATCH v1 32/38] net/mvpp2: apply flow-ctrl after port init

From: Liron Himi <lironh@marvell.com>

in case ppio was not initialized yet (only at 'start' function) the flow-ctrl setting should be saved for later stage.

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 26 +++++++++++++++++++++-----  drivers/net/mvpp2/mrvl_ethdev.h |  2 ++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index d388fde96..fe5fd90ef 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -164,6 +164,8 @@ static int
 mrvl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);  static int mrvl_promiscuous_enable(struct rte_eth_dev *dev);  static int mrvl_allmulticast_enable(struct rte_eth_dev *dev);
+static int
+mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf 
+*fc_conf);
 
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
 	#name, offsetof(struct pp2_ppio_statistics, name),	\
@@ -912,6 +914,15 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->promiscuous == 1)
 		mrvl_promiscuous_enable(dev);
 
+	if (priv->flow_ctrl) {
+		ret = mrvl_flow_ctrl_set(dev, &priv->fc_conf);
+		if (ret) {
+			MRVL_LOG(ERR, "Failed to configure flow control");
+			goto out;
+		}
+		priv->flow_ctrl = 0;
+	}
+
 	if (dev->data->dev_link.link_status == ETH_LINK_UP) {
 		ret = mrvl_dev_set_link_up(dev);
 		if (ret) {
@@ -2147,8 +2158,10 @@ mrvl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	int ret, en;
 
-	if (!priv)
-		return -EPERM;
+	if (!priv->ppio) {
+		memcpy(fc_conf, &priv->fc_conf, sizeof(struct rte_eth_fc_conf));
+		return 0;
+	}
 
 	fc_conf->autoneg = 1;
 	ret = pp2_ppio_get_rx_pause(priv->ppio, &en); @@ -2194,9 +2207,6 @@ mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	int ret;
 	int rx_en, tx_en;
 
-	if (!priv)
-		return -EPERM;
-
 	if (fc_conf->high_water ||
 	    fc_conf->low_water ||
 	    fc_conf->pause_time ||
@@ -2211,6 +2221,12 @@ mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		return -EINVAL;
 	}
 
+	if (!priv->ppio) {
+		memcpy(&priv->fc_conf, fc_conf, sizeof(struct rte_eth_fc_conf));
+		priv->flow_ctrl = 1;
+		return 0;
+	}
+
 	switch (fc_conf->mode) {
 	case RTE_FC_FULL:
 		rx_en = 1;
diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index ada2c51b2..148f2acba 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.h
+++ b/drivers/net/mvpp2/mrvl_ethdev.h
@@ -161,6 +161,8 @@ struct mrvl_priv {
 	uint8_t isolated;
 	uint8_t multiseg;
 	uint16_t max_mtu;
+	uint8_t	flow_ctrl;
+	struct rte_eth_fc_conf fc_conf;
 
 	struct pp2_ppio_params ppio_params;
 	struct pp2_cls_qos_tbl_params qos_tbl_params;
--
2.28.0
diff mbox series

Patch

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index d388fde96..fe5fd90ef 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -164,6 +164,8 @@  static int
 mrvl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 static int mrvl_promiscuous_enable(struct rte_eth_dev *dev);
 static int mrvl_allmulticast_enable(struct rte_eth_dev *dev);
+static int
+mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
 
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
 	#name, offsetof(struct pp2_ppio_statistics, name),	\
@@ -912,6 +914,15 @@  mrvl_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->promiscuous == 1)
 		mrvl_promiscuous_enable(dev);
 
+	if (priv->flow_ctrl) {
+		ret = mrvl_flow_ctrl_set(dev, &priv->fc_conf);
+		if (ret) {
+			MRVL_LOG(ERR, "Failed to configure flow control");
+			goto out;
+		}
+		priv->flow_ctrl = 0;
+	}
+
 	if (dev->data->dev_link.link_status == ETH_LINK_UP) {
 		ret = mrvl_dev_set_link_up(dev);
 		if (ret) {
@@ -2147,8 +2158,10 @@  mrvl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	int ret, en;
 
-	if (!priv)
-		return -EPERM;
+	if (!priv->ppio) {
+		memcpy(fc_conf, &priv->fc_conf, sizeof(struct rte_eth_fc_conf));
+		return 0;
+	}
 
 	fc_conf->autoneg = 1;
 	ret = pp2_ppio_get_rx_pause(priv->ppio, &en);
@@ -2194,9 +2207,6 @@  mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	int ret;
 	int rx_en, tx_en;
 
-	if (!priv)
-		return -EPERM;
-
 	if (fc_conf->high_water ||
 	    fc_conf->low_water ||
 	    fc_conf->pause_time ||
@@ -2211,6 +2221,12 @@  mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		return -EINVAL;
 	}
 
+	if (!priv->ppio) {
+		memcpy(&priv->fc_conf, fc_conf, sizeof(struct rte_eth_fc_conf));
+		priv->flow_ctrl = 1;
+		return 0;
+	}
+
 	switch (fc_conf->mode) {
 	case RTE_FC_FULL:
 		rx_en = 1;
diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h
index ada2c51b2..148f2acba 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.h
+++ b/drivers/net/mvpp2/mrvl_ethdev.h
@@ -161,6 +161,8 @@  struct mrvl_priv {
 	uint8_t isolated;
 	uint8_t multiseg;
 	uint16_t max_mtu;
+	uint8_t	flow_ctrl;
+	struct rte_eth_fc_conf fc_conf;
 
 	struct pp2_ppio_params ppio_params;
 	struct pp2_cls_qos_tbl_params qos_tbl_params;