vhost: promote vDPA API as stable
[dpdk.git] / drivers / net / mvpp2 / mrvl_ethdev.c
index 810a703..a230a96 100644 (file)
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
        const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
        int idx;
@@ -816,7 +814,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev)
        unsigned int core_id = rte_lcore_id();
 
        if (core_id == LCORE_ID_ANY)
-               core_id = 0;
+               core_id = rte_get_master_lcore();
 
        hif = mrvl_get_hif(priv, core_id);
 
@@ -857,12 +855,15 @@ mrvl_dev_stop(struct rte_eth_dev *dev)
  * @param dev
  *   Pointer to Ethernet device structure.
  */
-static void
+static int
 mrvl_dev_close(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        size_t i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        mrvl_flush_rx_queues(dev);
        mrvl_flush_tx_shadow_queues(dev);
        mrvl_flow_deinit(dev);
@@ -917,6 +918,8 @@ mrvl_dev_close(struct rte_eth_dev *dev)
                mrvl_deinit_pp2();
                rte_mvep_deinit(MVEP_MOD_T_PP2);
        }
+
+       return 0;
 }
 
 /**
@@ -994,22 +997,29 @@ mrvl_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_promiscuous_enable(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        if (priv->isolated)
-               return;
+               return 0;
 
        ret = pp2_ppio_set_promisc(priv->ppio, 1);
-       if (ret)
+       if (ret) {
                MRVL_LOG(ERR, "Failed to enable promiscuous mode");
+               return -EAGAIN;
+       }
+
+       return 0;
 }
 
 /**
@@ -1017,22 +1027,29 @@ mrvl_promiscuous_enable(struct rte_eth_dev *dev)
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_allmulticast_enable(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        if (priv->isolated)
-               return;
+               return 0;
 
        ret = pp2_ppio_set_mc_promisc(priv->ppio, 1);
-       if (ret)
+       if (ret) {
                MRVL_LOG(ERR, "Failed enable all-multicast mode");
+               return -EAGAIN;
+       }
+
+       return 0;
 }
 
 /**
@@ -1040,19 +1057,26 @@ mrvl_allmulticast_enable(struct rte_eth_dev *dev)
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_promiscuous_disable(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        ret = pp2_ppio_set_promisc(priv->ppio, 0);
-       if (ret)
+       if (ret) {
                MRVL_LOG(ERR, "Failed to disable promiscuous mode");
+               return -EAGAIN;
+       }
+
+       return 0;
 }
 
 /**
@@ -1060,19 +1084,26 @@ mrvl_promiscuous_disable(struct rte_eth_dev *dev)
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_allmulticast_disable(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        ret = pp2_ppio_set_mc_promisc(priv->ppio, 0);
-       if (ret)
+       if (ret) {
                MRVL_LOG(ERR, "Failed to disable all-multicast mode");
+               return -EAGAIN;
+       }
+
+       return 0;
 }
 
 /**
@@ -1301,15 +1332,18 @@ mrvl_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_stats_reset(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int i;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        for (i = 0; i < dev->data->nb_rx_queues; i++) {
                struct mrvl_rxq *rxq = dev->data->rx_queues[i];
@@ -1327,7 +1361,7 @@ mrvl_stats_reset(struct rte_eth_dev *dev)
                txq->bytes_sent = 0;
        }
 
-       pp2_ppio_get_statistics(priv->ppio, NULL, 1);
+       return pp2_ppio_get_statistics(priv->ppio, NULL, 1);
 }
 
 /**
@@ -1378,11 +1412,14 @@ mrvl_xstats_get(struct rte_eth_dev *dev,
  *
  * @param dev
  *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_xstats_reset(struct rte_eth_dev *dev)
 {
-       mrvl_stats_reset(dev);
+       return mrvl_stats_reset(dev);
 }
 
 /**
@@ -1422,7 +1459,7 @@ mrvl_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
  * @param info
  *   Info structure output buffer.
  */
-static void
+static int
 mrvl_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
                   struct rte_eth_dev_info *info)
 {
@@ -1457,6 +1494,8 @@ mrvl_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
        info->default_rxconf.rx_drop_en = 1;
 
        info->max_rx_pktlen = MRVL_PKT_SIZE_MAX;
+
+       return 0;
 }
 
 /**
@@ -1584,7 +1623,7 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)
 
        core_id = rte_lcore_id();
        if (core_id == LCORE_ID_ANY)
-               core_id = 0;
+               core_id = rte_get_master_lcore();
 
        hif = mrvl_get_hif(rxq->priv, core_id);
        if (!hif)
@@ -1734,7 +1773,7 @@ mrvl_rx_queue_release(void *rxq)
        unsigned int core_id = rte_lcore_id();
 
        if (core_id == LCORE_ID_ANY)
-               core_id = 0;
+               core_id = rte_get_master_lcore();
 
        if (!q)
                return;
@@ -2822,15 +2861,11 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
        memcpy(eth_dev->data->mac_addrs[0].addr_bytes,
               req.ifr_addr.sa_data, RTE_ETHER_ADDR_LEN);
 
-       eth_dev->data->kdrv = RTE_KDRV_NONE;
        eth_dev->device = &vdev->device;
        eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
        mrvl_set_tx_function(eth_dev);
        eth_dev->dev_ops = &mrvl_ops;
 
-       /* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
-
        rte_eth_dev_probing_finish(eth_dev);
        return 0;
 out_free:
@@ -3004,10 +3039,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-       mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-       if (mrvl_logtype >= 0)
-               rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);