drivers/net: accept removing device without any port
[dpdk.git] / drivers / net / netvsc / hn_ethdev.c
index b890fa3..19a9eb6 100644 (file)
@@ -45,9 +45,6 @@
                            DEV_RX_OFFLOAD_VLAN_STRIP | \
                            DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
        char name[RTE_ETH_XSTATS_NAME_SIZE];
        unsigned int offset;
@@ -58,6 +55,7 @@ static const struct hn_xstats_name_off hn_stat_strings[] = {
        { "good_bytes",             offsetof(struct hn_stats, bytes) },
        { "errors",                 offsetof(struct hn_stats, errors) },
        { "ring full",              offsetof(struct hn_stats, ring_full) },
+       { "channel full",           offsetof(struct hn_stats, channel_full) },
        { "multicast_packets",      offsetof(struct hn_stats, multicast) },
        { "broadcast_packets",      offsetof(struct hn_stats, broadcast) },
        { "undersize_packets",      offsetof(struct hn_stats, size_bins[0]) },
@@ -125,9 +123,6 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)
        eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
        eth_dev->intr_handle = &dev->intr_handle;
 
-       /* allow ethdev to remove on close */
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
-
        return eth_dev;
 }
 
@@ -201,7 +196,7 @@ static int hn_parse_args(const struct rte_eth_dev *dev)
  */
 int
 hn_dev_link_update(struct rte_eth_dev *dev,
-                  int wait_to_complete)
+                  int wait_to_complete __rte_unused)
 {
        struct hn_data *hv = dev->data->dev_private;
        struct rte_eth_link link, old;
@@ -215,8 +210,6 @@ hn_dev_link_update(struct rte_eth_dev *dev,
 
        hn_rndis_get_linkspeed(hv);
 
-       hn_vf_link_update(dev, wait_to_complete);
-
        link = (struct rte_eth_link) {
                .link_duplex = ETH_LINK_FULL_DUPLEX,
                .link_autoneg = ETH_LINK_SPEED_FIXED,
@@ -845,13 +838,15 @@ hn_dev_stop(struct rte_eth_dev *dev)
        hn_vf_stop(dev);
 }
 
-static void
+static int
 hn_dev_close(struct rte_eth_dev *dev)
 {
        PMD_INIT_FUNC_TRACE();
 
        hn_vf_close(dev);
        hn_dev_free_queues(dev);
+
+       return 0;
 }
 
 static const struct eth_dev_ops hn_eth_dev_ops = {
@@ -937,6 +932,9 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 
        vmbus = container_of(device, struct rte_vmbus_device, device);
        eth_dev->dev_ops = &hn_eth_dev_ops;
+       eth_dev->rx_queue_count = hn_dev_rx_queue_count;
+       eth_dev->rx_descriptor_status = hn_dev_rx_queue_status;
+       eth_dev->tx_descriptor_status = hn_dev_tx_descriptor_status;
        eth_dev->tx_pkt_burst = &hn_xmit_pkts;
        eth_dev->rx_pkt_burst = &hn_recv_pkts;
 
@@ -1094,7 +1092,7 @@ static int eth_hn_remove(struct rte_vmbus_device *dev)
 
        eth_dev = rte_eth_dev_allocated(dev->device.name);
        if (!eth_dev)
-               return -ENODEV;
+               return 0; /* port already released */
 
        ret = eth_hn_dev_uninit(eth_dev);
        if (ret)
@@ -1119,13 +1117,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-       hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-       if (hn_logtype_init >= 0)
-               rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-       hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-       if (hn_logtype_driver >= 0)
-               rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);