net/e1000: fix i219 hang on reset/close
[dpdk.git] / drivers / net / e1000 / em_ethdev.c
index cd70f28..20b5406 100644 (file)
@@ -284,12 +284,12 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
        }
 
        /* Allocate memory for storing MAC addresses */
-       eth_dev->data->mac_addrs = rte_zmalloc("e1000", ETHER_ADDR_LEN *
+       eth_dev->data->mac_addrs = rte_zmalloc("e1000", RTE_ETHER_ADDR_LEN *
                        hw->mac.rar_entry_count, 0);
        if (eth_dev->data->mac_addrs == NULL) {
                PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
                        "store MAC addresses",
-                       ETHER_ADDR_LEN * hw->mac.rar_entry_count);
+                       RTE_ETHER_ADDR_LEN * hw->mac.rar_entry_count);
                return -ENOMEM;
        }
 
@@ -352,8 +352,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_em_pmd = {
        .id_table = pci_id_em_map,
-       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
-                    RTE_PCI_DRV_IOVA_AS_VA,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
        .probe = eth_em_pci_probe,
        .remove = eth_em_pci_remove,
 };
@@ -576,7 +575,7 @@ eth_em_start(struct rte_eth_dev *dev)
                return -EIO;
        }
 
-       E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN);
+       E1000_WRITE_REG(hw, E1000_VET, RTE_ETHER_TYPE_VLAN);
 
        /* Configure for OS presence */
        em_init_manageability(hw);
@@ -738,6 +737,11 @@ eth_em_stop(struct rte_eth_dev *dev)
        em_lsc_intr_disable(hw);
 
        e1000_reset_hw(hw);
+
+       /* Flush desc rings for i219 */
+       if (hw->mac.type >= e1000_pch_spt)
+               em_flush_desc_rings(dev);
+
        if (hw->mac.type >= e1000_82544)
                E1000_WRITE_REG(hw, E1000_WUC, 0);
 
@@ -821,7 +825,8 @@ em_hardware_init(struct e1000_hw *hw)
         */
        rx_buf_size = em_get_rx_buffer_size(hw);
 
-       hw->fc.high_water = rx_buf_size - PMD_ROUNDUP(ETHER_MAX_LEN * 2, 1024);
+       hw->fc.high_water = rx_buf_size -
+               PMD_ROUNDUP(RTE_ETHER_MAX_LEN * 2, 1024);
        hw->fc.low_water = hw->fc.high_water - 1500;
 
        if (hw->mac.type == e1000_80003es2lan)
@@ -1000,7 +1005,7 @@ eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue
        struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
        em_rxq_intr_enable(hw);
-       rte_intr_enable(intr_handle);
+       rte_intr_ack(intr_handle);
 
        return 0;
 }
@@ -1037,7 +1042,7 @@ em_get_max_pktlen(struct rte_eth_dev *dev)
                return 0x1000;
        /* Adapters that do not support jumbo frames */
        case e1000_ich8lan:
-               return ETHER_MAX_LEN;
+               return RTE_ETHER_MAX_LEN;
        default:
                return MAX_JUMBO_FRAME_SIZE;
        }
@@ -1567,7 +1572,7 @@ eth_em_interrupt_action(struct rte_eth_dev *dev,
                return -1;
 
        intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
-       rte_intr_enable(intr_handle);
+       rte_intr_ack(intr_handle);
 
        /* set get_link_status to check register later */
        hw->mac.get_link_status = 1;
@@ -1697,7 +1702,7 @@ eth_em_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
        PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
 
        /* At least reserve one Ethernet frame for watermark */
-       max_high_water = rx_buf_size - ETHER_MAX_LEN;
+       max_high_water = rx_buf_size - RTE_ETHER_MAX_LEN;
        if ((fc_conf->high_water > max_high_water) ||
            (fc_conf->high_water < fc_conf->low_water)) {
                PMD_INIT_LOG(ERR, "e1000 incorrect high/low water value");
@@ -1747,7 +1752,7 @@ eth_em_rar_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
 static void
 eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t index)
 {
-       uint8_t addr[ETHER_ADDR_LEN];
+       uint8_t addr[RTE_ETHER_ADDR_LEN];
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        memset(addr, 0, sizeof(addr));
@@ -1773,10 +1778,11 @@ eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
        uint32_t rctl;
 
        eth_em_infos_get(dev, &dev_info);
-       frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE;
+       frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
+               VLAN_TAG_SIZE;
 
        /* check that mtu is within the allowed range */
-       if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
+       if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)
                return -EINVAL;
 
        /* refuse mtu that requires the support of scattered packets when this
@@ -1789,7 +1795,7 @@ eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
        rctl = E1000_READ_REG(hw, E1000_RCTL);
 
        /* switch to jumbo mode if needed */
-       if (frame_size > ETHER_MAX_LEN) {
+       if (frame_size > RTE_ETHER_MAX_LEN) {
                dev->data->dev_conf.rxmode.offloads |=
                        DEV_RX_OFFLOAD_JUMBO_FRAME;
                rctl |= E1000_RCTL_LPE;