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 v2 28/32] net/sssnic: support dev firmware version get
Date: Thu, 31 Aug 2023 17:56:46 +0800	[thread overview]
Message-ID: <20230831095650.219964-29-wanry@3snic.com> (raw)
In-Reply-To: <20230831095650.219964-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 | 36 ++++++++++++++++++++++++++++
 drivers/net/sssnic/base/sssnic_api.h |  9 +++++++
 drivers/net/sssnic/base/sssnic_cmd.h |  8 +++++++
 drivers/net/sssnic/sssnic_ethdev.c   | 20 ++++++++++++++++
 5 files changed, 74 insertions(+)

diff --git a/doc/guides/nics/features/sssnic.ini b/doc/guides/nics/features/sssnic.ini
index 020a9e7056..a40b509558 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
+FW version           = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y
diff --git a/drivers/net/sssnic/base/sssnic_api.c b/drivers/net/sssnic/base/sssnic_api.c
index 32b24e841c..12aca16995 100644
--- a/drivers/net/sssnic/base/sssnic_api.c
+++ b/drivers/net/sssnic/base/sssnic_api.c
@@ -1497,3 +1497,39 @@ sssnic_rss_indir_table_get(struct sssnic_hw *hw, uint16_t *entry,
 	sssnic_ctrlq_cmd_destroy(hw, cmd);
 	return ret;
 }
+
+int
+sssnic_fw_version_get(struct sssnic_hw *hw, struct sssnic_fw_version *version)
+{
+	int ret;
+	struct sssnic_msg msg;
+	struct sssnic_fw_version_get_cmd cmd;
+	uint32_t cmdlen = sizeof(cmd);
+	int len;
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.type = 1; /* get MPU firmware version */
+
+	sssnic_msg_init(&msg, (uint8_t *)&cmd, cmdlen,
+		SSSNIC_GET_FW_VERSION_CMD, SSSNIC_MPU_FUNC_IDX,
+		SSSNIC_COMM_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_GET_FW_VERSION_CMD, len=%u, status=%u",
+			cmdlen, cmd.common.status);
+		return -EIO;
+	}
+
+	len = RTE_MIN(sizeof(version->version), sizeof(cmd.version));
+	rte_memcpy(version->version, cmd.version, len);
+	len = RTE_MIN(sizeof(version->time), sizeof(cmd.time));
+	rte_memcpy(version->time, cmd.time, len);
+
+	return 0;
+}
diff --git a/drivers/net/sssnic/base/sssnic_api.h b/drivers/net/sssnic/base/sssnic_api.h
index 1d80b93e38..bd4f01d388 100644
--- a/drivers/net/sssnic/base/sssnic_api.h
+++ b/drivers/net/sssnic/base/sssnic_api.h
@@ -402,6 +402,13 @@ enum sssnic_rss_hash_engine_type {
 	SSSNIC_RSS_HASH_ENGINE_COUNT,
 };
 
+#define SSSNIC_FW_VERSION_LEN 16
+#define SSSNIC_FW_TIME_LEN 20
+struct sssnic_fw_version {
+	char version[SSSNIC_FW_VERSION_LEN];
+	char time[SSSNIC_FW_VERSION_LEN];
+};
+
 int sssnic_msix_attr_get(struct sssnic_hw *hw, uint16_t msix_idx,
 	struct sssnic_msix_attr *attr);
 int sssnic_msix_attr_set(struct sssnic_hw *hw, uint16_t msix_idx,
@@ -456,5 +463,7 @@ int sssnic_rss_indir_table_set(struct sssnic_hw *hw, const uint16_t *entry,
 	uint32_t num_entries);
 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);
 
 #endif /* _SSSNIC_API_H_ */
diff --git a/drivers/net/sssnic/base/sssnic_cmd.h b/drivers/net/sssnic/base/sssnic_cmd.h
index 56818471b6..9da07770b1 100644
--- a/drivers/net/sssnic/base/sssnic_cmd.h
+++ b/drivers/net/sssnic/base/sssnic_cmd.h
@@ -406,4 +406,12 @@ struct sssnic_rss_indir_table_cmd {
 	uint16_t entry[256];
 };
 
+struct sssnic_fw_version_get_cmd {
+	struct sssnic_cmd_common common;
+	uint16_t type;
+	uint16_t resvd;
+	uint8_t version[16];
+	uint8_t time[20];
+};
+
 #endif /* _SSSNIC_CMD_H_ */
diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index bde8d89ddc..cceaa5c8be 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -739,6 +739,25 @@ sssnic_ethdev_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
 	return sssnic_ethdev_tx_max_size_set(ethdev, mtu);
 }
 
+static int
+sssnic_ethdev_fw_version_get(struct rte_eth_dev *ethdev, char *fw_version,
+	size_t fw_size)
+{
+	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+	struct sssnic_fw_version version;
+	int ret;
+
+	ret = sssnic_fw_version_get(hw, &version);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to get firmware version");
+		return ret;
+	}
+
+	snprintf(fw_version, fw_size, "%s", version.version);
+
+	return 0;
+}
+
 static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.dev_start = sssnic_ethdev_start,
 	.dev_stop = sssnic_ethdev_stop,
@@ -779,6 +798,7 @@ static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.mtu_set = sssnic_ethdev_mtu_set,
 	.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,
 };
 
 static int
-- 
2.27.0


  parent reply	other threads:[~2023-08-31 10:01 UTC|newest]

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

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=20230831095650.219964-29-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).