net: add rte prefix to ether structures
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index 08a95a1..ae4d7e1 100644 (file)
@@ -17,6 +17,7 @@
 #include <rte_kvargs.h>
 #include <rte_dev.h>
 #include <rte_fslmc.h>
+#include <rte_flow_driver.h>
 
 #include "dpaa2_pmd_logs.h"
 #include <fslmc_vfio.h>
@@ -27,7 +28,7 @@
 #include "dpaa2_ethdev.h"
 #include <fsl_qbman_debug.h>
 
-#define DRIVER_LOOPBACK_MODE "drv_looback"
+#define DRIVER_LOOPBACK_MODE "drv_loopback"
 
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
@@ -83,6 +84,14 @@ static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = {
        {"egress_confirmed_frames", 2, 4},
 };
 
+static const enum rte_filter_op dpaa2_supported_filter_ops[] = {
+       RTE_ETH_FILTER_ADD,
+       RTE_ETH_FILTER_DELETE,
+       RTE_ETH_FILTER_UPDATE,
+       RTE_ETH_FILTER_FLUSH,
+       RTE_ETH_FILTER_GET
+};
+
 static struct rte_dpaa2_driver rte_dpaa2_pmd;
 static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev);
 static int dpaa2_dev_link_update(struct rte_eth_dev *dev,
@@ -656,6 +665,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
                                         DPNI_CONG_OPT_WRITE_MEM_ON_ENTER |
                                         DPNI_CONG_OPT_WRITE_MEM_ON_EXIT |
                                         DPNI_CONG_OPT_COHERENT_WRITE;
+               cong_notif_cfg.cg_point = DPNI_CP_QUEUE;
 
                ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW,
                                                       priv->token,
@@ -870,6 +880,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
 
        /*checksum errors, send them to normal path and set it in annotation */
        err_cfg.errors = DPNI_ERROR_L3CE | DPNI_ERROR_L4CE;
+       err_cfg.errors |= DPNI_ERROR_PHE;
 
        err_cfg.error_action = DPNI_ERROR_ACTION_CONTINUE;
        err_cfg.set_frame_annotation = true;
@@ -961,6 +972,8 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
 
        PMD_INIT_FUNC_TRACE();
 
+       dpaa2_flow_clean(dev);
+
        /* Clean the device first */
        ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
        if (ret) {
@@ -1111,7 +1124,7 @@ dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 
 static int
 dpaa2_dev_add_mac_addr(struct rte_eth_dev *dev,
-                      struct ether_addr *addr,
+                      struct rte_ether_addr *addr,
                       __rte_unused uint32_t index,
                       __rte_unused uint32_t pool)
 {
@@ -1142,7 +1155,7 @@ dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev,
        struct dpaa2_dev_priv *priv = dev->data->dev_private;
        struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
        struct rte_eth_dev_data *data = dev->data;
-       struct ether_addr *macaddr;
+       struct rte_ether_addr *macaddr;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -1162,7 +1175,7 @@ dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev,
 
 static int
 dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
-                      struct ether_addr *addr)
+                      struct rte_ether_addr *addr)
 {
        int ret;
        struct dpaa2_dev_priv *priv = dev->data->dev_private;
@@ -1322,10 +1335,9 @@ dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
        if (xstats_names != NULL)
                for (i = 0; i < stat_cnt; i++)
-                       snprintf(xstats_names[i].name,
-                                sizeof(xstats_names[i].name),
-                                "%s",
-                                dpaa2_xstats_strings[i].name);
+                       strlcpy(xstats_names[i].name,
+                               dpaa2_xstats_strings[i].name,
+                               sizeof(xstats_names[i].name));
 
        return stat_cnt;
 }
@@ -1892,6 +1904,47 @@ int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev,
        return ret;
 }
 
+static inline int
+dpaa2_dev_verify_filter_ops(enum rte_filter_op filter_op)
+{
+       unsigned int i;
+
+       for (i = 0; i < RTE_DIM(dpaa2_supported_filter_ops); i++) {
+               if (dpaa2_supported_filter_ops[i] == filter_op)
+                       return 0;
+       }
+       return -ENOTSUP;
+}
+
+static int
+dpaa2_dev_flow_ctrl(struct rte_eth_dev *dev,
+                   enum rte_filter_type filter_type,
+                                enum rte_filter_op filter_op,
+                                void *arg)
+{
+       int ret = 0;
+
+       if (!dev)
+               return -ENODEV;
+
+       switch (filter_type) {
+       case RTE_ETH_FILTER_GENERIC:
+               if (dpaa2_dev_verify_filter_ops(filter_op) < 0) {
+                       ret = -ENOTSUP;
+                       break;
+               }
+               *(const void **)arg = &dpaa2_flow_ops;
+               dpaa2_filter_type |= filter_type;
+               break;
+       default:
+               RTE_LOG(ERR, PMD, "Filter type (%d) not supported",
+                       filter_type);
+               ret = -ENOTSUP;
+               break;
+       }
+       return ret;
+}
+
 static struct eth_dev_ops dpaa2_ethdev_ops = {
        .dev_configure    = dpaa2_eth_dev_configure,
        .dev_start            = dpaa2_dev_start,
@@ -1930,6 +1983,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
        .mac_addr_set         = dpaa2_dev_set_mac_addr,
        .rss_hash_update      = dpaa2_dev_rss_hash_update,
        .rss_hash_conf_get    = dpaa2_dev_rss_hash_conf_get,
+       .filter_ctrl          = dpaa2_dev_flow_ctrl,
 };
 
 /* Populate the mac address from physically available (u-boot/firmware) and/or
@@ -1938,13 +1992,13 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
  */
 static int
 populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv,
-                 struct ether_addr *mac_entry)
+                 struct rte_ether_addr *mac_entry)
 {
        int ret;
-       struct ether_addr phy_mac, prime_mac;
+       struct rte_ether_addr phy_mac, prime_mac;
 
-       memset(&phy_mac, 0, sizeof(struct ether_addr));
-       memset(&prime_mac, 0, sizeof(struct ether_addr));
+       memset(&phy_mac, 0, sizeof(struct rte_ether_addr));
+       memset(&prime_mac, 0, sizeof(struct rte_ether_addr));
 
        /* Get the physical device MAC address */
        ret = dpni_get_port_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token,
@@ -1978,7 +2032,8 @@ populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv,
                                              ret);
                                goto cleanup;
                        }
-                       memcpy(&prime_mac, &phy_mac, sizeof(struct ether_addr));
+                       memcpy(&prime_mac, &phy_mac,
+                               sizeof(struct rte_ether_addr));
                }
        } else if (is_zero_ether_addr(&prime_mac)) {
                /* In case phys and prime, both are zero, create random MAC */
@@ -1993,7 +2048,7 @@ populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv,
        }
 
        /* prime_mac the final MAC address */
-       memcpy(mac_entry, &prime_mac, sizeof(struct ether_addr));
+       memcpy(mac_entry, &prime_mac, sizeof(struct rte_ether_addr));
        return 0;
 
 cleanup:
@@ -2046,7 +2101,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        struct dpni_attr attr;
        struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
        struct dpni_buffer_layout layout;
-       int ret, hw_id;
+       int ret, hw_id, i;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -2102,11 +2157,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
        priv->num_rx_tc = attr.num_rx_tcs;
 
-       /* Resetting the "num_rx_queues" to equal number of queues in first TC
-        * as only one TC is supported on Rx Side. Once Multiple TCs will be
-        * in use for Rx processing then this will be changed or removed.
-        */
-       priv->nb_rx_queues = attr.num_queues;
+       for (i = 0; i < attr.num_rx_tcs; i++)
+               priv->nb_rx_queues += attr.num_queues;
 
        /* Using number of TX queues as number of TX TCs */
        priv->nb_tx_queues = attr.num_tx_tcs;
@@ -2184,6 +2236,26 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        }
        eth_dev->tx_pkt_burst = dpaa2_dev_tx;
 
+       /*Init fields w.r.t. classficaition*/
+       memset(&priv->extract.qos_key_cfg, 0, sizeof(struct dpkg_profile_cfg));
+       priv->extract.qos_extract_param = (size_t)rte_malloc(NULL, 256, 64);
+       if (!priv->extract.qos_extract_param) {
+               DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow "
+                           " classificaiton ", ret);
+               goto init_err;
+       }
+       for (i = 0; i < MAX_TCS; i++) {
+               memset(&priv->extract.fs_key_cfg[i], 0,
+                       sizeof(struct dpkg_profile_cfg));
+               priv->extract.fs_extract_param[i] =
+                       (size_t)rte_malloc(NULL, 256, 64);
+               if (!priv->extract.fs_extract_param[i]) {
+                       DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow classificaiton",
+                                    ret);
+                       goto init_err;
+               }
+       }
+
        RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name);
        return 0;
 init_err:
@@ -2196,7 +2268,7 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
 {
        struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
        struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
-       int ret;
+       int i, ret;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -2224,6 +2296,14 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
        priv->hw = NULL;
        rte_free(dpni);
 
+       for (i = 0; i < MAX_TCS; i++) {
+               if (priv->extract.fs_extract_param[i])
+                       rte_free((void *)(size_t)priv->extract.fs_extract_param[i]);
+       }
+
+       if (priv->extract.qos_extract_param)
+               rte_free((void *)(size_t)priv->extract.qos_extract_param);
+
        eth_dev->dev_ops = NULL;
        eth_dev->rx_pkt_burst = NULL;
        eth_dev->tx_pkt_burst = NULL;