net/dpaa2: add API for event Rx adapter
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index 1ac607c..14d79b9 100644 (file)
@@ -1634,6 +1634,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,