ethdev: allow returning error on VLAN offload ops
[dpdk.git] / drivers / net / vmxnet3 / vmxnet3_ethdev.c
index 72ec67c..6328464 100644 (file)
@@ -57,7 +57,6 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ethdev_pci.h>
-#include <rte_atomic.h>
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
@@ -88,7 +87,7 @@ static int __vmxnet3_dev_link_update(struct rte_eth_dev *dev,
 static int vmxnet3_dev_link_update(struct rte_eth_dev *dev,
                                   int wait_to_complete);
 static void vmxnet3_hw_stats_save(struct vmxnet3_hw *hw);
-static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev,
+static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev,
                                  struct rte_eth_stats *stats);
 static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev,
                                        struct rte_eth_xstat_name *xstats,
@@ -101,7 +100,7 @@ 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);
+static int vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
                                 struct ether_addr *mac_addr);
 static void vmxnet3_interrupt_handler(void *param);
@@ -310,7 +309,6 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
                return 0;
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        /* Vendor and Device ID need to be set before init of shared code */
        hw->device_id = pci_dev->id.device_id;
@@ -538,10 +536,10 @@ vmxnet3_write_mac(struct vmxnet3_hw *hw, const uint8_t *addr)
                     addr[0], addr[1], addr[2],
                     addr[3], addr[4], addr[5]);
 
-       val = *(const uint32_t *)addr;
+       memcpy(&val, addr, 4);
        VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, val);
 
-       val = (addr[5] << 8) | addr[4];
+       memcpy(&val, addr + 4, 2);
        VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACH, val);
 }
 
@@ -731,8 +729,10 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
                devRead->rssConfDesc.confPA  = hw->rss_confPA;
        }
 
-       vmxnet3_dev_vlan_offload_set(dev,
-                                    ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK);
+       ret = vmxnet3_dev_vlan_offload_set(dev,
+                       ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK);
+       if (ret)
+               return ret;
 
        vmxnet3_write_mac(hw, dev->data->mac_addrs->addr_bytes);
 
@@ -1035,7 +1035,7 @@ vmxnet3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        return count;
 }
 
-static void
+static int
 vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
        unsigned int i;
@@ -1081,6 +1081,8 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                stats->ierrors += rxStats.pktsRxError;
                stats->rx_nombuf += rxStats.pktsRxOutOfBuf;
        }
+
+       return 0;
 }
 
 static void
@@ -1145,6 +1147,8 @@ vmxnet3_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
        struct vmxnet3_hw *hw = dev->data->dev_private;
 
+       ether_addr_copy(mac_addr, (struct ether_addr *)(hw->perm_addr));
+       ether_addr_copy(mac_addr, &dev->data->mac_addrs[0]);
        vmxnet3_write_mac(hw, mac_addr->addr_bytes);
 }
 
@@ -1220,7 +1224,10 @@ vmxnet3_dev_promiscuous_disable(struct rte_eth_dev *dev)
        struct vmxnet3_hw *hw = dev->data->dev_private;
        uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
 
-       memcpy(vf_table, hw->shadow_vfta, VMXNET3_VFT_TABLE_SIZE);
+       if (dev->data->dev_conf.rxmode.hw_vlan_filter)
+               memcpy(vf_table, hw->shadow_vfta, VMXNET3_VFT_TABLE_SIZE);
+       else
+               memset(vf_table, 0xff, VMXNET3_VFT_TABLE_SIZE);
        vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_PROMISC, 0);
        VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
                               VMXNET3_CMD_UPDATE_VLAN_FILTERS);
@@ -1273,7 +1280,7 @@ vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vid, int on)
        return 0;
 }
 
-static void
+static int
 vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
        struct vmxnet3_hw *hw = dev->data->dev_private;
@@ -1299,6 +1306,8 @@ vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask)
                VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
                                       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
        }
+
+       return 0;
 }
 
 static void