net: add macro for MAC address print
[dpdk.git] / drivers / net / dpaa / dpaa_ethdev.c
index 6d27d74..c5739a3 100644 (file)
@@ -29,7 +29,7 @@
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
-#include <rte_ethdev_driver.h>
+#include <ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_ring.h>
 
@@ -49,6 +49,9 @@
 #include <process.h>
 #include <fmlib/fm_ext.h>
 
+#define CHECK_INTERVAL         100  /* 100ms */
+#define MAX_REPEAT_TIME        90   /* 9s (90 * 100ms) in total */
+
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
                DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -184,7 +187,7 @@ dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
                return -EINVAL;
        }
 
-       if (frame_size > RTE_ETHER_MAX_LEN)
+       if (frame_size > DPAA_ETH_MAX_LEN)
                dev->data->dev_conf.rxmode.offloads |=
                                                DEV_RX_OFFLOAD_JUMBO_FRAME;
        else
@@ -415,7 +418,7 @@ static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
        return 0;
 }
 
-static void dpaa_eth_dev_stop(struct rte_eth_dev *dev)
+static int dpaa_eth_dev_stop(struct rte_eth_dev *dev)
 {
        struct fman_if *fif = dev->process_private;
 
@@ -425,6 +428,8 @@ static void dpaa_eth_dev_stop(struct rte_eth_dev *dev)
        if (!fif->is_shared_mac)
                fman_if_disable_rx(fif);
        dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
+
+       return 0;
 }
 
 static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
@@ -437,6 +442,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        struct rte_eth_link *link = &dev->data->dev_link;
        struct dpaa_if *dpaa_intf = dev->data->dev_private;
        int loop;
+       int ret;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -458,7 +464,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        intr_handle = &dpaa_dev->intr_handle;
        __fif = container_of(fif, struct __fman_if, __if);
 
-       dpaa_eth_dev_stop(dev);
+       ret = dpaa_eth_dev_stop(dev);
 
        /* Reset link to autoneg */
        if (link->link_status && !link->link_autoneg)
@@ -480,9 +486,6 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        if (dpaa_intf->cgr_rx) {
                for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
                        qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
-
-               qman_release_cgrid_range(dpaa_intf->cgr_rx[loop].cgrid,
-                                        dpaa_intf->nb_rx_queues);
        }
 
        rte_free(dpaa_intf->cgr_rx);
@@ -491,9 +494,6 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        if (dpaa_intf->cgr_tx) {
                for (loop = 0; loop < MAX_DPAA_CORES; loop++)
                        qman_delete_cgr(&dpaa_intf->cgr_tx[loop]);
-
-               qman_release_cgrid_range(dpaa_intf->cgr_tx[loop].cgrid,
-                                        MAX_DPAA_CORES);
                rte_free(dpaa_intf->cgr_tx);
                dpaa_intf->cgr_tx = NULL;
        }
@@ -504,7 +504,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        rte_free(dpaa_intf->tx_queues);
        dpaa_intf->tx_queues = NULL;
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -532,9 +532,11 @@ dpaa_fw_version_get(struct rte_eth_dev *dev __rte_unused,
 
        ret = snprintf(fw_version, fw_size, "SVR:%x-fman-v%x",
                       svr_ver, fman_ip_rev);
-       ret += 1; /* add the size of '\0' */
+       if (ret < 0)
+               return -EINVAL;
 
-       if (fw_size < (uint32_t)ret)
+       ret += 1; /* add the size of '\0' */
+       if (fw_size < (size_t)ret)
                return ret;
        else
                return 0;
@@ -666,23 +668,30 @@ dpaa_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
 }
 
 static int dpaa_eth_link_update(struct rte_eth_dev *dev,
-                               int wait_to_complete __rte_unused)
+                               int wait_to_complete)
 {
        struct dpaa_if *dpaa_intf = dev->data->dev_private;
        struct rte_eth_link *link = &dev->data->dev_link;
        struct fman_if *fif = dev->process_private;
        struct __fman_if *__fif = container_of(fif, struct __fman_if, __if);
        int ret, ioctl_version;
+       uint8_t count;
 
        PMD_INIT_FUNC_TRACE();
 
        ioctl_version = dpaa_get_ioctl_version_number();
 
-
        if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
-               ret = dpaa_get_link_status(__fif->node_name, link);
-               if (ret)
-                       return ret;
+               for (count = 0; count <= MAX_REPEAT_TIME; count++) {
+                       ret = dpaa_get_link_status(__fif->node_name, link);
+                       if (ret)
+                               return ret;
+                       if (link->link_status == ETH_LINK_DOWN &&
+                           wait_to_complete)
+                               rte_delay_ms(CHECK_INTERVAL);
+                       else
+                               break;
+               }
        } else {
                link->link_status = dpaa_intf->valid;
        }
@@ -962,6 +971,12 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
                }
        }
 
+       if (dpaa_intf->bp_info && dpaa_intf->bp_info->bp &&
+           dpaa_intf->bp_info->mp != mp) {
+               DPAA_PMD_WARN("Multiple pools on same interface not supported");
+               return -EINVAL;
+       }
+
        /* Max packet can fit in single buffer */
        if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= buffsz) {
                ;
@@ -1290,7 +1305,7 @@ static int dpaa_link_down(struct rte_eth_dev *dev)
        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 dpaa_eth_dev_stop(dev);
        return 0;
 }
 
@@ -1508,12 +1523,19 @@ dpaa_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 {
        struct dpaa_if *dpaa_intf = dev->data->dev_private;
        struct qman_fq *rxq;
+       int ret;
 
        rxq = dev->data->rx_queues[queue_id];
 
        qinfo->mp = dpaa_intf->bp_info->mp;
        qinfo->scattered_rx = dev->data->scattered_rx;
        qinfo->nb_desc = rxq->nb_desc;
+
+       /* Report the HW Rx buffer length to user */
+       ret = fman_if_get_maxfrm(dev->process_private);
+       if (ret > 0)
+               qinfo->rx_buf_size = ret;
+
        qinfo->conf.rx_free_thresh = 1;
        qinfo->conf.rx_drop_en = 1;
        qinfo->conf.rx_deferred_start = 0;
@@ -2072,7 +2094,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
        /* copy the primary mac address */
        rte_ether_addr_copy(&fman_intf->mac_addr, &eth_dev->data->mac_addrs[0]);
 
-       RTE_LOG(INFO, PMD, "net: dpaa: %s: %02x:%02x:%02x:%02x:%02x:%02x\n",
+       RTE_LOG(INFO, PMD, "net: dpaa: %s: " RTE_ETHER_ADDR_PRT_FMT "\n",
                dpaa_device->name,
                fman_intf->mac_addr.addr_bytes[0],
                fman_intf->mac_addr.addr_bytes[1],
@@ -2216,6 +2238,8 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
        if (dpaa_drv->drv_flags & RTE_DPAA_DRV_INTR_LSC)
                eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
 
+       eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
        /* Invoke PMD device initialization function */
        diag = dpaa_dev_init(eth_dev);
        if (diag == 0) {
@@ -2287,4 +2311,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
+RTE_LOG_REGISTER_DEFAULT(dpaa_logtype_pmd, NOTICE);