net/txgbe: support OEM subsystem vendor ID
[dpdk.git] / drivers / net / txgbe / txgbe_ethdev.c
index 04afc61..dc8c3c7 100644 (file)
@@ -376,7 +376,7 @@ txgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
        if (hw->mac.type != txgbe_mac_raptor)
                return -ENOSYS;
 
-       if (stat_idx & !QMAP_FIELD_RESERVED_BITS_MASK)
+       if (stat_idx & ~QMAP_FIELD_RESERVED_BITS_MASK)
                return -EIO;
 
        PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
@@ -594,6 +594,19 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
        /* Vendor and Device ID need to be set before init of shared code */
        hw->device_id = pci_dev->id.device_id;
        hw->vendor_id = pci_dev->id.vendor_id;
+       if (pci_dev->id.subsystem_vendor_id == PCI_VENDOR_ID_WANGXUN) {
+               hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
+       } else {
+               u32 ssid;
+
+               ssid = txgbe_flash_read_dword(hw, 0xFFFDC);
+               if (ssid == 0x1) {
+                       PMD_INIT_LOG(ERR,
+                               "Read of internal subsystem device id failed\n");
+                       return -ENODEV;
+               }
+               hw->subsystem_device_id = (u16)ssid >> 8 | (u16)ssid << 8;
+       }
        hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
        hw->allow_unsupported_sfp = 1;
 
@@ -821,10 +834,8 @@ static int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
        struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
        struct txgbe_fdir_filter *fdir_filter;
 
-       if (fdir_info->hash_map)
-               rte_free(fdir_info->hash_map);
-       if (fdir_info->hash_handle)
-               rte_hash_free(fdir_info->hash_handle);
+       rte_free(fdir_info->hash_map);
+       rte_hash_free(fdir_info->hash_handle);
 
        while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
                TAILQ_REMOVE(&fdir_info->fdir_list,
@@ -841,10 +852,8 @@ static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
        struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
        struct txgbe_l2_tn_filter *l2_tn_filter;
 
-       if (l2_tn_info->hash_map)
-               rte_free(l2_tn_info->hash_map);
-       if (l2_tn_info->hash_handle)
-               rte_hash_free(l2_tn_info->hash_handle);
+       rte_free(l2_tn_info->hash_map);
+       rte_hash_free(l2_tn_info->hash_handle);
 
        while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
                TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
@@ -1678,7 +1687,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
                        return -ENOMEM;
                }
        }
-       /* confiugre msix for sleep until rx interrupt */
+       /* configure msix for sleep until rx interrupt */
        txgbe_configure_msix(dev);
 
        /* initialize transmission unit */
@@ -1937,6 +1946,7 @@ txgbe_dev_set_link_up(struct rte_eth_dev *dev)
        } else {
                /* Turn on the laser */
                hw->mac.enable_tx_laser(hw);
+               hw->dev_start = true;
                txgbe_dev_link_update(dev, 0);
        }
 
@@ -1957,6 +1967,7 @@ txgbe_dev_set_link_down(struct rte_eth_dev *dev)
        } else {
                /* Turn off the laser */
                hw->mac.disable_tx_laser(hw);
+               hw->dev_start = false;
                txgbe_dev_link_update(dev, 0);
        }
 
@@ -2034,6 +2045,7 @@ txgbe_dev_close(struct rte_eth_dev *dev)
 
 #ifdef RTE_LIB_SECURITY
        rte_free(dev->security_ctx);
+       dev->security_ctx = NULL;
 #endif
 
        return ret;
@@ -3166,7 +3178,7 @@ txgbe_dev_led_on(struct rte_eth_dev *dev)
        struct txgbe_hw *hw;
 
        hw = TXGBE_DEV_HW(dev);
-       return txgbe_led_on(hw, 4) == 0 ? 0 : -ENOTSUP;
+       return txgbe_led_on(hw, TXGBE_LEDCTL_ACTIVE) == 0 ? 0 : -ENOTSUP;
 }
 
 static int
@@ -3175,7 +3187,7 @@ txgbe_dev_led_off(struct rte_eth_dev *dev)
        struct txgbe_hw *hw;
 
        hw = TXGBE_DEV_HW(dev);
-       return txgbe_led_off(hw, 4) == 0 ? 0 : -ENOTSUP;
+       return txgbe_led_off(hw, TXGBE_LEDCTL_ACTIVE) == 0 ? 0 : -ENOTSUP;
 }
 
 static int
@@ -3461,7 +3473,7 @@ txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
         * scattered packets when this feature has not been enabled before.
         */
        if (dev_data->dev_started && !dev_data->scattered_rx &&
-           (frame_size + 2 * TXGBE_VLAN_TAG_SIZE >
+           (frame_size + 2 * RTE_VLAN_HLEN >
             dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
                PMD_INIT_LOG(ERR, "Stop port first.");
                return -EINVAL;
@@ -3682,7 +3694,7 @@ txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
                wr32(hw, TXGBE_IVARMISC, tmp);
        } else {
                /* rx or tx causes */
-               /* Workround for ICR lost */
+               /* Workaround for ICR lost */
                idx = ((16 * (queue & 1)) + (8 * direction));
                tmp = rd32(hw, TXGBE_IVAR(queue >> 1));
                tmp &= ~(0xFF << idx);
@@ -4387,7 +4399,7 @@ txgbe_timesync_disable(struct rte_eth_dev *dev)
        /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
        wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588), 0);
 
-       /* Stop incrementating the System Time registers. */
+       /* Stop incrementing the System Time registers. */
        wr32(hw, TXGBE_TSTIMEINC, 0);
 
        return 0;