[v5,20/32] net/sssnic: support dev close and reset

Message ID 20230904045658.238185-21-wanry@3snic.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Renyong Wan Sept. 4, 2023, 4:56 a.m. UTC
  From: Renyong Wan <wanry@3snic.com>

Signed-off-by: Steven Song <steven.song@3snic.com>
Signed-off-by: Renyong Wan <wanry@3snic.com>
---
 drivers/net/sssnic/sssnic_ethdev.c | 32 ++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
  

Comments

Ferruh Yigit Sept. 26, 2023, 1:09 p.m. UTC | #1
On 9/4/2023 5:56 AM, wanry@3snic.com wrote:
> From: Renyong Wan <wanry@3snic.com>
> 
> Signed-off-by: Steven Song <steven.song@3snic.com>
> Signed-off-by: Renyong Wan <wanry@3snic.com>
> 

<...>

> +static int
> +sssnic_ethdev_close(struct rte_eth_dev *ethdev)
> +{
> +	sssnic_ethdev_release(ethdev);
> +
>

As close() is mostly empty, I just want to remind that all resources
should be freed in this function.

I am not aware anything missing, but can you please double check all
driver allocated memory is freed in this function?
  

Patch

diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index 8201a1e3c4..b59c4fd3ad 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -13,6 +13,8 @@ 
 #include "sssnic_ethdev_rx.h"
 #include "sssnic_ethdev_tx.h"
 
+static int sssnic_ethdev_init(struct rte_eth_dev *ethdev);
+
 static int
 sssnic_ethdev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *devinfo)
@@ -622,9 +624,39 @@  sssnic_ethdev_stop(struct rte_eth_dev *ethdev)
 	return 0;
 }
 
+static int
+sssnic_ethdev_close(struct rte_eth_dev *ethdev)
+{
+	sssnic_ethdev_release(ethdev);
+
+	PMD_DRV_LOG(INFO, "Port %u is closed", ethdev->data->port_id);
+
+	return 0;
+}
+
+static int
+sssnic_ethdev_reset(struct rte_eth_dev *ethdev)
+{
+	int ret;
+
+	sssnic_ethdev_release(ethdev);
+
+	ret = sssnic_ethdev_init(ethdev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to initialize sssnic ethdev");
+		return ret;
+	}
+
+	PMD_DRV_LOG(INFO, "Port %u is reset", ethdev->data->port_id);
+
+	return 0;
+}
+
 static const struct eth_dev_ops sssnic_ethdev_ops = {
 	.dev_start = sssnic_ethdev_start,
 	.dev_stop = sssnic_ethdev_stop,
+	.dev_close = sssnic_ethdev_close,
+	.dev_reset = sssnic_ethdev_reset,
 	.dev_set_link_up = sssnic_ethdev_set_link_up,
 	.dev_set_link_down = sssnic_ethdev_set_link_down,
 	.link_update = sssnic_ethdev_link_update,