ethdev: allow returning error on VLAN offload ops
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index 7756c4e..19c1191 100644 (file)
@@ -162,7 +162,7 @@ dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
        return ret;
 }
 
-static void
+static int
 dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
        struct dpaa2_dev_priv *priv = dev->data->dev_private;
@@ -188,6 +188,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask)
                        RTE_LOG(INFO, PMD,
                                "VLAN extend offload not supported\n");
        }
+
+       return 0;
 }
 
 static int
@@ -426,8 +428,8 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 
        PMD_INIT_FUNC_TRACE();
 
-       PMD_INIT_LOG(DEBUG, "dev =%p, queue =%d, pool = %p, conf =%p",
-                    dev, rx_queue_id, mb_pool, rx_conf);
+       PMD_DRV_LOG(DEBUG, "dev =%p, queue =%d, pool = %p, conf =%p",
+                   dev, rx_queue_id, mb_pool, rx_conf);
 
        if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
                bpid = mempool_to_bpid(mb_pool);
@@ -476,8 +478,8 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
                taildrop.threshold = CONG_THRESHOLD_RX_Q;
                taildrop.units = DPNI_CONGESTION_UNIT_BYTES;
                taildrop.oal = CONG_RX_OAL;
-               PMD_INIT_LOG(DEBUG, "Enabling Early Drop on queue = %d",
-                            rx_queue_id);
+               PMD_DRV_LOG(DEBUG, "Enabling Early Drop on queue = %d",
+                           rx_queue_id);
                ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
                                        DPNI_CP_QUEUE, DPNI_QUEUE_RX,
                                        dpaa2_q->tc_index, flow_id, &taildrop);
@@ -754,8 +756,15 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
                return ret;
        }
        /* VLAN Offload Settings */
-       if (priv->max_vlan_filters)
-               dpaa2_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK);
+       if (priv->max_vlan_filters) {
+               ret = dpaa2_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK);
+               if (ret) {
+                       PMD_INIT_LOG(ERR, "Error to dpaa2_vlan_offload_set:"
+                                    "code = %d\n", ret);
+                       return ret;
+               }
+       }
+
 
        /* if the interrupts were configured on this devices*/
        if (intr_handle && (intr_handle->fd) &&
@@ -983,7 +992,7 @@ dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
                PMD_DRV_LOG(ERR, "setting the max frame length failed");
                return -1;
        }
-       PMD_DRV_LOG(INFO, "MTU is configured %d for the device\n", mtu);
+       PMD_DRV_LOG(INFO, "MTU is configured %d for the device", mtu);
        return 0;
 }
 
@@ -1061,7 +1070,7 @@ dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
                        "error: Setting the MAC ADDR failed %d\n", ret);
 }
 static
-void dpaa2_dev_stats_get(struct rte_eth_dev *dev,
+int dpaa2_dev_stats_get(struct rte_eth_dev *dev,
                         struct rte_eth_stats *stats)
 {
        struct dpaa2_dev_priv *priv = dev->data->dev_private;
@@ -1076,12 +1085,12 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev,
 
        if (!dpni) {
                RTE_LOG(ERR, PMD, "dpni is NULL\n");
-               return;
+               return -EINVAL;
        }
 
        if (!stats) {
                RTE_LOG(ERR, PMD, "stats is NULL\n");
-               return;
+               return -EINVAL;
        }
 
        /*Get Counters from page_0*/
@@ -1116,11 +1125,11 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev,
        stats->oerrors = value.page_2.egress_discarded_frames;
        stats->imissed = value.page_2.ingress_nobuffer_discards;
 
-       return;
+       return 0;
 
 err:
        RTE_LOG(ERR, PMD, "Operation not completed:Error Code = %d\n", retcode);
-       return;
+       return retcode;
 };
 
 static int
@@ -1634,6 +1643,68 @@ dpaa2_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
        return 0;
 }
 
+int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
+               int eth_rx_queue_id,
+               uint16_t dpcon_id,
+               const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
+{
+       struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)eth_priv->hw;
+       struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
+       uint8_t flow_id = dpaa2_ethq->flow_id;
+       struct dpni_queue cfg;
+       uint8_t options;
+       int ret;
+
+       if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_PARALLEL)
+               dpaa2_ethq->cb = dpaa2_dev_process_parallel_event;
+       else
+               return -EINVAL;
+
+       memset(&cfg, 0, sizeof(struct dpni_queue));
+       options = DPNI_QUEUE_OPT_DEST;
+       cfg.destination.type = DPNI_DEST_DPCON;
+       cfg.destination.id = dpcon_id;
+       cfg.destination.priority = queue_conf->ev.priority;
+
+       options |= DPNI_QUEUE_OPT_USER_CTX;
+       cfg.user_context = (uint64_t)(dpaa2_ethq);
+
+       ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX,
+                            dpaa2_ethq->tc_index, flow_id, options, &cfg);
+       if (ret) {
+               RTE_LOG(ERR, PMD, "Error in dpni_set_queue: ret: %d\n", ret);
+               return ret;
+       }
+
+       memcpy(&dpaa2_ethq->ev, &queue_conf->ev, sizeof(struct rte_event));
+
+       return 0;
+}
+
+int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev,
+               int eth_rx_queue_id)
+{
+       struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)eth_priv->hw;
+       struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
+       uint8_t flow_id = dpaa2_ethq->flow_id;
+       struct dpni_queue cfg;
+       uint8_t options;
+       int ret;
+
+       memset(&cfg, 0, sizeof(struct dpni_queue));
+       options = DPNI_QUEUE_OPT_DEST;
+       cfg.destination.type = DPNI_DEST_NONE;
+
+       ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX,
+                            dpaa2_ethq->tc_index, flow_id, options, &cfg);
+       if (ret)
+               RTE_LOG(ERR, PMD, "Error in dpni_set_queue: ret: %d\n", ret);
+
+       return ret;
+}
+
 static struct eth_dev_ops dpaa2_ethdev_ops = {
        .dev_configure    = dpaa2_eth_dev_configure,
        .dev_start            = dpaa2_dev_start,
@@ -1738,7 +1809,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        priv->nb_tx_queues = attr.num_tx_tcs;
 
        PMD_DRV_LOG(DEBUG, "RX-TC= %d, nb_rx_queues= %d, nb_tx_queues=%d",
-                   priv->num_tc, priv->nb_rx_queues, priv->nb_tx_queues);
+                   priv->num_rx_tc, priv->nb_rx_queues, priv->nb_tx_queues);
 
        priv->hw = dpni_dev;
        priv->hw_id = hw_id;
@@ -1805,6 +1876,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->tx_pkt_burst = dpaa2_dev_tx;
        rte_fslmc_vfio_dmamap();
 
+       RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name);
        return 0;
 init_err:
        dpaa2_dev_uninit(eth_dev);
@@ -1865,6 +1937,7 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
        eth_dev->rx_pkt_burst = NULL;
        eth_dev->tx_pkt_burst = NULL;
 
+       RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name);
        return 0;
 }