From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <rahul.lakkireddy@chelsio.com>
Received: from stargate3.asicdesigners.com (stargate.chelsio.com
 [67.207.112.58]) by dpdk.org (Postfix) with ESMTP id 2304BC602
 for <dev@dpdk.org>; Thu, 18 Jun 2015 14:19:07 +0200 (CEST)
Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94])
 by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id t5ICIQKa029861;
 Thu, 18 Jun 2015 05:18:27 -0700
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Date: Thu, 18 Jun 2015 17:47:10 +0530
Message-Id: <3d907874e087bc5517d6c0c96c29cf3815efe8dd.1434628361.git.rahul.lakkireddy@chelsio.com>
X-Mailer: git-send-email 2.4.1
In-Reply-To: <cover.1434628361.git.rahul.lakkireddy@chelsio.com>
References: <cover.1433164517.git.rahul.lakkireddy@chelsio.com>
 <cover.1434628361.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1434628361.git.rahul.lakkireddy@chelsio.com>
References: <cover.1434628361.git.rahul.lakkireddy@chelsio.com>
Cc: Felix Marti <felix@chelsio.com>, Kumar Sanghvi <kumaras@chelsio.com>,
 Nirranjan Kirubaharan <nirranjan@chelsio.com>
Subject: [dpdk-dev] [PATCH v3 8/9] cxgbe: add flow control functions for
	cxgbe PMD.
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 18 Jun 2015 12:19:10 -0000

Adds flow control related eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe_ethdev.c | 54 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index c0dd5f3..478051a 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -642,6 +642,58 @@ static void cxgbe_dev_stats_reset(struct rte_eth_dev *eth_dev)
 	}
 }
 
+static int cxgbe_flow_ctrl_get(struct rte_eth_dev *eth_dev,
+			       struct rte_eth_fc_conf *fc_conf)
+{
+	struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+	struct link_config *lc = &pi->link_cfg;
+	int rx_pause, tx_pause;
+
+	fc_conf->autoneg = lc->fc & PAUSE_AUTONEG;
+	rx_pause = lc->fc & PAUSE_RX;
+	tx_pause = lc->fc & PAUSE_TX;
+
+	if (rx_pause && tx_pause)
+		fc_conf->mode = RTE_FC_FULL;
+	else if (rx_pause)
+		fc_conf->mode = RTE_FC_RX_PAUSE;
+	else if (tx_pause)
+		fc_conf->mode = RTE_FC_TX_PAUSE;
+	else
+		fc_conf->mode = RTE_FC_NONE;
+	return 0;
+}
+
+static int cxgbe_flow_ctrl_set(struct rte_eth_dev *eth_dev,
+			       struct rte_eth_fc_conf *fc_conf)
+{
+	struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+	struct adapter *adapter = pi->adapter;
+	struct link_config *lc = &pi->link_cfg;
+
+	if (lc->supported & FW_PORT_CAP_ANEG) {
+		if (fc_conf->autoneg)
+			lc->requested_fc |= PAUSE_AUTONEG;
+		else
+			lc->requested_fc &= ~PAUSE_AUTONEG;
+	}
+
+	if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+	    (fc_conf->mode & RTE_FC_RX_PAUSE))
+		lc->requested_fc |= PAUSE_RX;
+	else
+		lc->requested_fc &= ~PAUSE_RX;
+
+	if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+	    (fc_conf->mode & RTE_FC_TX_PAUSE))
+		lc->requested_fc |= PAUSE_TX;
+	else
+		lc->requested_fc &= ~PAUSE_TX;
+
+	return t4_link_l1cfg(adapter, adapter->mbox, pi->tx_chan,
+			     &pi->link_cfg);
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.dev_start		= cxgbe_dev_start,
 	.dev_stop		= cxgbe_dev_stop,
@@ -663,6 +715,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.rx_queue_release	= cxgbe_dev_rx_queue_release,
 	.stats_get		= cxgbe_dev_stats_get,
 	.stats_reset		= cxgbe_dev_stats_reset,
+	.flow_ctrl_get		= cxgbe_flow_ctrl_get,
+	.flow_ctrl_set		= cxgbe_flow_ctrl_set,
 };
 
 /*
-- 
2.4.1