diff mbox series

[15/16] bus/dpaa: enable set link status

Message ID 20200302145829.27808-16-hemant.agrawal@nxp.com
State Superseded
Headers show
Series NXP DPAAx fixes and enhancements | expand

Commit Message

Hemant Agrawal March 2, 2020, 2:58 p.m. UTC
From: Rohit Raj <rohit.raj@nxp.com>


Enabled set link status API to start/stop phy
device from application.

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>

---
 drivers/bus/dpaa/base/qbman/process.c     | 35 ++++++++++++++++++++---
 drivers/bus/dpaa/include/process.h        |  3 ++
 drivers/bus/dpaa/rte_bus_dpaa_version.map |  1 +
 drivers/net/dpaa/dpaa_ethdev.c            | 14 +++++++--
 4 files changed, 47 insertions(+), 6 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 598b10661..8ab57f105 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -317,7 +317,7 @@  int rte_dpaa_intr_enable(char *if_name, int efd)
 
 	ret = ioctl(fd, DPAA_IOCTL_ENABLE_LINK_STATUS_INTERRUPT, &args);
 	if (ret) {
-		perror("Failed to enable interrupt\n");
+		printf("Failed to enable interrupt: Not Supported\n");
 		return ret;
 	}
 
@@ -333,7 +333,7 @@  int rte_dpaa_intr_disable(char *if_name)
 
 	ret = ioctl(fd, DPAA_IOCTL_DISABLE_LINK_STATUS_INTERRUPT, &if_name);
 	if (ret) {
-		perror("Failed to disable interrupt\n");
+		printf("Failed to disable interrupt: Not Supported\n");
 		return ret;
 	}
 
@@ -356,9 +356,36 @@  int rte_dpaa_get_link_status(char *if_name)
 
 	ret = ioctl(fd, DPAA_IOCTL_GET_LINK_STATUS, &args);
 	if (ret) {
-		perror("Failed to get link status\n");
-		return ret;
+		printf("Failed to get link status: Not Supported\n");
+		return -errno;
 	}
 
 	return args.link_status;
 }
+
+#define DPAA_IOCTL_UPDATE_LINK_STATUS \
+	_IOW(DPAA_IOCTL_MAGIC, 0x11, struct usdpaa_ioctl_link_status_args)
+
+int rte_dpaa_update_link_status(char *if_name, int link_status)
+{
+	struct usdpaa_ioctl_link_status_args args;
+	int ret;
+
+	ret = check_fd();
+	if (ret)
+		return ret;
+
+	strcpy(args.if_name, if_name);
+	args.link_status = link_status;
+
+	ret = ioctl(fd, DPAA_IOCTL_UPDATE_LINK_STATUS, &args);
+	if (ret) {
+		if (errno == EINVAL)
+			printf("Failed to set link status: Not Supported\n");
+		else
+			perror("Failed to set link status");
+		return ret;
+	}
+
+	return 0;
+}
diff --git a/drivers/bus/dpaa/include/process.h b/drivers/bus/dpaa/include/process.h
index 312da1245..9f8c85895 100644
--- a/drivers/bus/dpaa/include/process.h
+++ b/drivers/bus/dpaa/include/process.h
@@ -94,4 +94,7 @@  struct usdpaa_ioctl_link_status_args {
 __rte_experimental
 int rte_dpaa_get_link_status(char *if_name);
 
+__rte_experimental
+int rte_dpaa_update_link_status(char *if_name, int link_status);
+
 #endif	/*  __PROCESS_H */
diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map
index e8fa8f569..3eac85429 100644
--- a/drivers/bus/dpaa/rte_bus_dpaa_version.map
+++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map
@@ -103,4 +103,5 @@  EXPERIMENTAL {
 	rte_dpaa_get_link_status;
 	rte_dpaa_intr_disable;
 	rte_dpaa_intr_enable;
+	rte_dpaa_update_link_status;
 };
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 28c6b1c17..c0a96dd47 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -972,17 +972,27 @@  dpaa_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 
 static int dpaa_link_down(struct rte_eth_dev *dev)
 {
+	struct fman_if *fif = dev->process_private;
+	struct __fman_if *__fif;
+
 	PMD_INIT_FUNC_TRACE();
 
-	dpaa_eth_dev_stop(dev);
+	__fif = container_of(fif, struct __fman_if, __if);
+
+	rte_dpaa_update_link_status(__fif->node_name, ETH_LINK_DOWN);
 	return 0;
 }
 
 static int dpaa_link_up(struct rte_eth_dev *dev)
 {
+	struct fman_if *fif = dev->process_private;
+	struct __fman_if *__fif;
+
 	PMD_INIT_FUNC_TRACE();
 
-	dpaa_eth_dev_start(dev);
+	__fif = container_of(fif, struct __fman_if, __if);
+
+	rte_dpaa_update_link_status(__fif->node_name, ETH_LINK_UP);
 	return 0;
 }