DPDK patches and discussions
 help / color / mirror / Atom feed
From: <wanry@3snic.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, Renyong Wan <wanry@3snic.com>,
	Steven Song <steven.song@3snic.com>
Subject: [PATCH v5 29/32] net/sssnic: add dev flow control ops
Date: Mon, 4 Sep 2023 12:56:55 +0800	[thread overview]
Message-ID: <20230904045658.238185-30-wanry@3snic.com> (raw)
In-Reply-To: <20230904045658.238185-1-wanry@3snic.com>

From: Renyong Wan <wanry@3snic.com>

Signed-off-by: Steven Song <steven.song@3snic.com>
Signed-off-by: Renyong Wan <wanry@3snic.com>
---
 doc/guides/nics/features/sssnic.ini  |  1 +
 drivers/net/sssnic/base/sssnic_api.c | 68 ++++++++++++++++++++++++++++
 drivers/net/sssnic/base/sssnic_api.h |  4 ++
 drivers/net/sssnic/base/sssnic_cmd.h | 11 +++++
 drivers/net/sssnic/sssnic_ethdev.c   | 65 ++++++++++++++++++++++++++
 5 files changed, 149 insertions(+)

diff --git a/doc/guides/nics/features/sssnic.ini b/doc/guides/nics/features/sssnic.ini
index a40b509558..9bf05cb968 100644
--- a/doc/guides/nics/features/sssnic.ini
+++ b/doc/guides/nics/features/sssnic.ini
@@ -26,6 +26,7 @@ Inner L4 checksum    = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+Flow control         = P
 FW version           = Y
 Linux                = Y
 ARMv8                = Y
diff --git a/drivers/net/sssnic/base/sssnic_api.c b/drivers/net/sssnic/base/sssnic_api.c
index 12aca16995..d91896cdd2 100644
--- a/drivers/net/sssnic/base/sssnic_api.c
+++ b/drivers/net/sssnic/base/sssnic_api.c
@@ -1533,3 +1533,71 @@ sssnic_fw_version_get(struct sssnic_hw *hw, struct sssnic_fw_version *version)
 
 	return 0;
 }
+
+int
+sssnic_flow_ctrl_set(struct sssnic_hw *hw, bool autoneg, bool rx_en, bool tx_en)
+{
+	int ret;
+	struct sssnic_msg msg;
+	struct sssnic_flow_ctrl_cmd cmd;
+	uint32_t cmdlen = sizeof(cmd);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.auto_neg = autoneg ? 1 : 0;
+	cmd.rx_en = rx_en ? 1 : 0;
+	cmd.tx_en = tx_en ? 1 : 0;
+	cmd.opcode = SSSNIC_CMD_OPCODE_SET;
+
+	sssnic_msg_init(&msg, (uint8_t *)&cmd, cmdlen,
+		SSSNIC_PORT_FLOW_CTRL_CMD, SSSNIC_MPU_FUNC_IDX,
+		SSSNIC_LAN_MODULE, SSSNIC_MSG_TYPE_REQ);
+	ret = sssnic_mbox_send(hw, &msg, (uint8_t *)&cmd, &cmdlen, 0);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to send mbox message, ret=%d", ret);
+		return ret;
+	}
+
+	if (cmdlen == 0 || cmd.common.status != 0) {
+		PMD_DRV_LOG(ERR,
+			"Bad response to SSSNIC_PORT_FLOW_CTRL_CMD, len=%u, status=%u",
+			cmdlen, cmd.common.status);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+int
+sssnic_flow_ctrl_get(struct sssnic_hw *hw, bool *autoneg, bool *rx_en,
+	bool *tx_en)
+{
+	int ret;
+	struct sssnic_msg msg;
+	struct sssnic_flow_ctrl_cmd cmd;
+	uint32_t cmdlen = sizeof(cmd);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.opcode = SSSNIC_CMD_OPCODE_GET;
+
+	sssnic_msg_init(&msg, (uint8_t *)&cmd, cmdlen,
+		SSSNIC_PORT_FLOW_CTRL_CMD, SSSNIC_MPU_FUNC_IDX,
+		SSSNIC_LAN_MODULE, SSSNIC_MSG_TYPE_REQ);
+	ret = sssnic_mbox_send(hw, &msg, (uint8_t *)&cmd, &cmdlen, 0);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to send mbox message, ret=%d", ret);
+		return ret;
+	}
+
+	if (cmdlen == 0 || cmd.common.status != 0) {
+		PMD_DRV_LOG(ERR,
+			"Bad response to SSSNIC_PORT_FLOW_CTRL_CMD, len=%u, status=%u",
+			cmdlen, cmd.common.status);
+		return -EIO;
+	}
+
+	*autoneg = cmd.auto_neg;
+	*rx_en = cmd.rx_en;
+	*tx_en = cmd.tx_en;
+
+	return 0;
+}
diff --git a/drivers/net/sssnic/base/sssnic_api.h b/drivers/net/sssnic/base/sssnic_api.h
index bd4f01d388..36544a5dc3 100644
--- a/drivers/net/sssnic/base/sssnic_api.h
+++ b/drivers/net/sssnic/base/sssnic_api.h
@@ -465,5 +465,9 @@ int sssnic_rss_indir_table_get(struct sssnic_hw *hw, uint16_t *entry,
 	uint32_t num_entries);
 int sssnic_fw_version_get(struct sssnic_hw *hw,
 	struct sssnic_fw_version *version);
+int sssnic_flow_ctrl_set(struct sssnic_hw *hw, bool autoneg, bool rx_en,
+	bool tx_en);
+int sssnic_flow_ctrl_get(struct sssnic_hw *hw, bool *autoneg, bool *rx_en,
+	bool *tx_en);
 
 #endif /* _SSSNIC_API_H_ */
diff --git a/drivers/net/sssnic/base/sssnic_cmd.h b/drivers/net/sssnic/base/sssnic_cmd.h
index 9da07770b1..d2054fad5a 100644
--- a/drivers/net/sssnic/base/sssnic_cmd.h
+++ b/drivers/net/sssnic/base/sssnic_cmd.h
@@ -414,4 +414,15 @@ struct sssnic_fw_version_get_cmd {
 	uint8_t time[20];
 };
 
+struct sssnic_flow_ctrl_cmd {
+	struct sssnic_cmd_common common;
+	uint8_t port;
+	uint8_t opcode;
+	uint16_t resvd0;
+	uint8_t auto_neg;
+	uint8_t rx_en;
+	uint8_t tx_en;
+	uint8_t resvd1[5];
+};
+
 #endif /* _SSSNIC_CMD_H_ */
diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index cceaa5c8be..8999693027 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -758,6 +758,69 @@ sssnic_ethdev_fw_version_get(struct rte_eth_dev *ethdev, char *fw_version,
 	return 0;
 }
 
+static int
+sssnic_ethdev_flow_ctrl_set(struct rte_eth_dev *ethdev,
+	struct rte_eth_fc_conf *fc_conf)
+{
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+	bool autoneg, rx_en, tx_en;
+	int ret;
+
+	if (fc_conf->autoneg != 0)
+		autoneg = true;
+	else
+		autoneg = false;
+
+	if (fc_conf->mode == RTE_ETH_FC_FULL ||
+		fc_conf->mode == RTE_ETH_FC_RX_PAUSE)
+		rx_en = true;
+	else
+		rx_en = false;
+
+	if (fc_conf->mode == RTE_ETH_FC_FULL ||
+		fc_conf->mode == RTE_ETH_FC_TX_PAUSE)
+		tx_en = true;
+	else
+		tx_en = false;
+
+	ret = sssnic_flow_ctrl_set(hw, autoneg, rx_en, tx_en);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to set flow conctrol");
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+sssnic_ethdev_flow_ctrl_get(struct rte_eth_dev *ethdev,
+	struct rte_eth_fc_conf *fc_conf)
+{
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+	bool autoneg, rx_en, tx_en;
+	int ret;
+
+	ret = sssnic_flow_ctrl_get(hw, &autoneg, &rx_en, &tx_en);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to get flow conctrol");
+		return ret;
+	}
+
+	if (autoneg)
+		fc_conf->autoneg = true;
+
+	if (rx_en && tx_en)
+		fc_conf->mode = RTE_ETH_FC_FULL;
+	else if (rx_en)
+		fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
+	else if (tx_en)
+		fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
+	else
+		fc_conf->mode = RTE_ETH_FC_NONE;
+
+	return 0;
+}
+
 static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.dev_start = sssnic_ethdev_start,
 	.dev_stop = sssnic_ethdev_stop,
@@ -799,6 +862,8 @@ static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.rxq_info_get = sssnic_ethdev_rx_queue_info_get,
 	.txq_info_get = sssnic_ethdev_tx_queue_info_get,
 	.fw_version_get = sssnic_ethdev_fw_version_get,
+	.flow_ctrl_set = sssnic_ethdev_flow_ctrl_set,
+	.flow_ctrl_get = sssnic_ethdev_flow_ctrl_get,
 };
 
 static int
-- 
2.27.0


  parent reply	other threads:[~2023-09-04  5:00 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  4:56 [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters wanry
2023-09-04  4:56 ` [PATCH v5 01/32] net/sssnic: add build and doc infrastructure wanry
2023-09-26 13:06   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 02/32] net/sssnic: add log type and log macros wanry
2023-09-04  4:56 ` [PATCH v5 03/32] net/sssnic: support probe and remove wanry
2023-09-18 16:08   ` Stephen Hemminger
2023-09-19  2:00     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 04/32] net/sssnic: initialize hardware base wanry
2023-09-18  2:28   ` Stephen Hemminger
2023-09-18  4:47     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 05/32] net/sssnic: add event queue wanry
2023-09-04  4:56 ` [PATCH v5 06/32] net/sssnic/base: add message definition and utility wanry
2023-09-18  2:31   ` Stephen Hemminger
2023-09-18  5:08     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 07/32] net/sssnic/base: add mailbox support wanry
2023-09-18  2:32   ` Stephen Hemminger
2023-09-18  5:10     ` Renyong Wan
2023-09-26 13:13   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 08/32] net/sssnic/base: add work queue wanry
2023-09-18  2:33   ` Stephen Hemminger
2023-09-18  5:11     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 09/32] net/sssnic/base: add control queue wanry
2023-09-18  2:36   ` Stephen Hemminger
2023-09-18  5:22     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 10/32] net/sssnic: add dev configure and infos get wanry
2023-09-04  4:56 ` [PATCH v5 11/32] net/sssnic: add dev MAC ops wanry
2023-09-26 13:07   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 12/32] net/sssnic: support dev link status wanry
2023-09-04  4:56 ` [PATCH v5 13/32] net/sssnic: support link status event wanry
2023-09-26 13:08   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 14/32] net/sssnic: support Rx queue setup and release wanry
2023-09-04  4:56 ` [PATCH v5 15/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` [PATCH v5 16/32] net/sssnic: support Rx queue start and stop wanry
2023-09-04  4:56 ` [PATCH v5 17/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` [PATCH v5 18/32] net/sssnic: add Rx interrupt support wanry
2023-09-04  4:56 ` [PATCH v5 19/32] net/sssnic: support dev start and stop wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 20/32] net/sssnic: support dev close and reset wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 21/32] net/sssnic: add allmulticast and promiscuous ops wanry
2023-09-04  4:56 ` [PATCH v5 22/32] net/sssnic: add basic and extended stats ops wanry
2023-09-04  4:56 ` [PATCH v5 23/32] net/sssnic: support Rx packet burst wanry
2023-09-04  4:56 ` [PATCH v5 24/32] net/sssnic: support Tx " wanry
2023-09-26 13:10   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 25/32] net/sssnic: add RSS support wanry
2023-09-04  4:56 ` [PATCH v5 26/32] net/sssnic: support dev MTU set wanry
2023-09-04  4:56 ` [PATCH v5 27/32] net/sssnic: support dev queue info get wanry
2023-09-04  4:56 ` [PATCH v5 28/32] net/sssnic: support dev firmware version get wanry
2023-09-04  4:56 ` wanry [this message]
2023-09-26 13:12   ` [PATCH v5 29/32] net/sssnic: add dev flow control ops Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 30/32] net/sssnic: support VLAN offload and filter wanry
2023-09-04  4:56 ` [PATCH v5 31/32] net/sssnic: add generic flow ops wanry
2023-09-04  4:56 ` [PATCH v5 32/32] net/sssnic: add VF dev support wanry
2023-09-26 13:11   ` Ferruh Yigit
2023-09-18  2:37 ` [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters Stephen Hemminger
2023-09-18  3:23   ` Renyong Wan
2023-09-19  3:19 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:21 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:23 ` Stephen Hemminger
2023-09-19  5:19   ` Renyong Wan
2023-09-19 15:24 ` Stephen Hemminger
2023-09-26 13:13 ` Ferruh Yigit
2024-03-29 11:32   ` Ferruh Yigit
2024-07-31 17:32     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230904045658.238185-30-wanry@3snic.com \
    --to=wanry@3snic.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=steven.song@3snic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).