bus/dpaa: enable set link status
authorRohit Raj <rohit.raj@nxp.com>
Tue, 7 Jul 2020 09:22:29 +0000 (14:52 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:52 +0000 (06:18 +0200)
Enabled set link status API to start/stop phy
device from application.

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/dpaa/base/qbman/process.c
drivers/bus/dpaa/include/process.h
drivers/bus/dpaa/rte_bus_dpaa_version.map
drivers/net/dpaa/dpaa_ethdev.c

index 68b7af2..6f7e379 100644 (file)
@@ -366,3 +366,30 @@ int dpaa_get_link_status(char *if_name)
 
        return args.link_status;
 }
+
+#define DPAA_IOCTL_UPDATE_LINK_STATUS \
+       _IOW(DPAA_IOCTL_MAGIC, 0x11, struct usdpaa_ioctl_update_link_status_args)
+
+int dpaa_update_link_status(char *if_name, int link_status)
+{
+       struct usdpaa_ioctl_update_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
+                       printf("Failed to set link status");
+               return ret;
+       }
+
+       return 0;
+}
index 7305762..f52ea16 100644 (file)
@@ -91,7 +91,18 @@ struct usdpaa_ioctl_link_status_args {
        char    if_name[IF_NAME_MAX_LEN];
        int     link_status;
 };
+
+struct usdpaa_ioctl_update_link_status_args {
+       /* network device node name */
+       char    if_name[IF_NAME_MAX_LEN];
+       /* link status(ETH_LINK_UP/DOWN) */
+       int     link_status;
+};
+
 __rte_internal
 int dpaa_get_link_status(char *if_name);
 
+__rte_internal
+int dpaa_update_link_status(char *if_name, int link_status);
+
 #endif /*  __PROCESS_H */
index 2e8b440..77840a5 100644 (file)
@@ -15,6 +15,7 @@ INTERNAL {
        dpaa_intr_disable;
        dpaa_intr_enable;
        dpaa_svr_family;
+       dpaa_update_link_status;
        fman_dealloc_bufs_mask_hi;
        fman_dealloc_bufs_mask_lo;
        fman_if_add_mac_addr;
index 3f805b2..3a5b319 100644 (file)
@@ -478,18 +478,15 @@ static int dpaa_eth_link_update(struct rte_eth_dev *dev,
                DPAA_PMD_ERR("invalid link_speed: %s, %d",
                             dpaa_intf->name, fif->mac_type);
 
-       ret = dpaa_get_link_status(__fif->node_name);
-       if (ret < 0) {
-               if (ret == -EINVAL) {
-                       DPAA_PMD_DEBUG("Using default link status-No Support");
-                       ret = 1;
-               } else {
-                       DPAA_PMD_ERR("rte_dpaa_get_link_status %d", ret);
+       if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
+               ret = dpaa_get_link_status(__fif->node_name);
+               if (ret < 0)
                        return ret;
-               }
+               link->link_status = ret;
+       } else {
+               link->link_status = dpaa_intf->valid;
        }
 
-       link->link_status = ret;
        link->link_duplex = ETH_LINK_FULL_DUPLEX;
        link->link_autoneg = ETH_LINK_AUTONEG;
 
@@ -985,17 +982,33 @@ 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);
+
+       if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+               dpaa_update_link_status(__fif->node_name, ETH_LINK_DOWN);
+       else
+               dpaa_eth_dev_stop(dev);
        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);
+
+       if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+               dpaa_update_link_status(__fif->node_name, ETH_LINK_UP);
+       else
+               dpaa_eth_dev_start(dev);
        return 0;
 }