drivers: use PCI registration macro
[dpdk.git] / drivers / net / vmxnet3 / vmxnet3_ethdev.c
index a5c9ba5..f15cda5 100644 (file)
@@ -86,6 +86,8 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev,
                                struct rte_eth_stats *stats);
 static void vmxnet3_dev_info_get(struct rte_eth_dev *dev,
                                struct rte_eth_dev_info *dev_info);
+static const uint32_t *
+vmxnet3_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 static int vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev,
                                       uint16_t vid, int on);
 static void vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
@@ -98,12 +100,11 @@ static void vmxnet3_process_events(struct vmxnet3_hw *);
 /*
  * The set of PCI devices this driver supports
  */
+#define VMWARE_PCI_VENDOR_ID 0x15AD
+#define VMWARE_DEV_ID_VMXNET3 0x07B0
 static const struct rte_pci_id pci_id_vmxnet3_map[] = {
-
-#define RTE_PCI_DEV_ID_DECL_VMXNET3(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
-#include "rte_pci_dev_ids.h"
-
-{ .vendor_id = 0, /* sentinel */ },
+       { RTE_PCI_DEVICE(VMWARE_PCI_VENDOR_ID, VMWARE_DEV_ID_VMXNET3) },
+       { .vendor_id = 0, /* sentinel */ },
 };
 
 static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
@@ -119,6 +120,7 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
        .stats_get            = vmxnet3_dev_stats_get,
        .mac_addr_set         = vmxnet3_mac_addr_set,
        .dev_infos_get        = vmxnet3_dev_info_get,
+       .dev_supported_ptypes_get = vmxnet3_dev_supported_ptypes_get,
        .vlan_filter_set      = vmxnet3_dev_vlan_filter_set,
        .vlan_offload_set     = vmxnet3_dev_vlan_offload_set,
        .rx_queue_setup       = vmxnet3_dev_rx_queue_setup,
@@ -329,26 +331,14 @@ static struct eth_driver rte_vmxnet3_pmd = {
                .name = "rte_vmxnet3_pmd",
                .id_table = pci_id_vmxnet3_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_vmxnet3_dev_init,
        .eth_dev_uninit = eth_vmxnet3_dev_uninit,
        .dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
- */
-static int
-rte_vmxnet3_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_vmxnet3_pmd);
-       return 0;
-}
-
 static int
 vmxnet3_dev_configure(struct rte_eth_dev *dev)
 {
@@ -691,7 +681,6 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
                stats->q_errors[i] = rxStats->pktsRxError;
                stats->ierrors += rxStats->pktsRxError;
-               stats->imcasts += rxStats->mcastPktsRxOK;
                stats->rx_nombuf += rxStats->pktsRxOutOfBuf;
        }
 }
@@ -706,8 +695,7 @@ vmxnet3_dev_info_get(__attribute__((unused))struct rte_eth_dev *dev,
        dev_info->max_rx_pktlen = 16384; /* includes CRC, cf MAXFRS register */
        dev_info->max_mac_addrs = VMXNET3_MAX_MAC_ADDRS;
 
-       dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
-                                               ETH_TXQ_FLAGS_NOOFFLOADS;
+       dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
        dev_info->flow_type_rss_offloads = VMXNET3_RSS_OFFLOAD_ALL;
 
        dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
@@ -734,6 +722,20 @@ vmxnet3_dev_info_get(__attribute__((unused))struct rte_eth_dev *dev,
                DEV_TX_OFFLOAD_TCP_TSO;
 }
 
+static const uint32_t *
+vmxnet3_dev_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+       static const uint32_t ptypes[] = {
+               RTE_PTYPE_L3_IPV4_EXT,
+               RTE_PTYPE_L3_IPV4,
+               RTE_PTYPE_UNKNOWN
+       };
+
+       if (dev->rx_pkt_burst == vmxnet3_recv_pkts)
+               return ptypes;
+       return NULL;
+}
+
 static void
 vmxnet3_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
@@ -760,9 +762,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
        ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
        if (ret & 0x1) {
-               link.link_status = 1;
+               link.link_status = ETH_LINK_UP;
                link.link_duplex = ETH_LINK_FULL_DUPLEX;
-               link.link_speed = ETH_LINK_SPEED_10000;
+               link.link_speed = ETH_SPEED_NUM_10G;
+               link.link_autoneg = ETH_LINK_SPEED_FIXED;
        }
 
        vmxnet3_dev_atomic_write_link_status(dev, &link);
@@ -933,9 +936,5 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 }
 #endif
 
-static struct rte_driver rte_vmxnet3_driver = {
-       .type = PMD_PDEV,
-       .init = rte_vmxnet3_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_vmxnet3_driver);
+DRIVER_REGISTER_PCI(net_vmxnet3, rte_vmxnet3_pmd.pci_drv);
+DRIVER_REGISTER_PCI_TABLE(net_vmxnet3, pci_id_vmxnet3_map);