ixgbe: fix access to last byte of EEPROM
[dpdk.git] / drivers / net / ixgbe / ixgbe_ethdev.c
index 3687ebf..d8d4173 100644 (file)
@@ -190,9 +190,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
                        uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
-#ifdef RTE_NEXT_ABI
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
-#endif
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
@@ -227,14 +225,12 @@ static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
 static void ixgbevf_dev_interrupt_handler(struct rte_intr_handle *handle,
                                          void *param);
-#ifdef RTE_NEXT_ABI
 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
                                            uint16_t queue_id);
 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
                                             uint16_t queue_id);
 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
                                 uint8_t queue, uint8_t msix_vector);
-#endif
 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
 
 /* For Eth VMDQ APIs support */
@@ -252,14 +248,12 @@ static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
                uint8_t rule_id, uint8_t on);
 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
                uint8_t rule_id);
-#ifdef RTE_NEXT_ABI
 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
                                          uint16_t queue_id);
 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
                                           uint16_t queue_id);
 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
                               uint8_t queue, uint8_t msix_vector);
-#endif
 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
 
 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
@@ -335,10 +329,10 @@ static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
-#define UPDATE_VF_STAT(reg, last, cur)                         \
+#define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
        uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-       cur += latest - last;                                   \
+       cur += (latest - last) & UINT_MAX;                      \
        last = latest;                                          \
 }
 
@@ -420,10 +414,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
        .tx_queue_start       = ixgbe_dev_tx_queue_start,
        .tx_queue_stop        = ixgbe_dev_tx_queue_stop,
        .rx_queue_setup       = ixgbe_dev_rx_queue_setup,
-#ifdef RTE_NEXT_ABI
        .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
        .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
-#endif
        .rx_queue_release     = ixgbe_dev_rx_queue_release,
        .rx_queue_count       = ixgbe_dev_rx_queue_count,
        .rx_descriptor_done   = ixgbe_dev_rx_descriptor_done,
@@ -497,10 +489,8 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
        .rx_descriptor_done   = ixgbe_dev_rx_descriptor_done,
        .tx_queue_setup       = ixgbe_dev_tx_queue_setup,
        .tx_queue_release     = ixgbe_dev_tx_queue_release,
-#ifdef RTE_NEXT_ABI
        .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
        .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
-#endif
        .mac_addr_add         = ixgbevf_add_mac_addr,
        .mac_addr_remove      = ixgbevf_remove_mac_addr,
        .set_mc_addr_list     = ixgbe_dev_set_mc_addr_list,
@@ -704,7 +694,7 @@ ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
                (hw->mac.type != ixgbe_mac_X550EM_x))
                return -ENOSYS;
 
-       PMD_INIT_LOG(INFO, "Setting port %d, %s queue_id %d to stat index %d",
+       PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
                     (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
                     queue_id, stat_idx);
 
@@ -730,20 +720,20 @@ ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
        else
                stat_mappings->rqsmr[n] |= qsmr_mask;
 
-       PMD_INIT_LOG(INFO, "Set port %d, %s queue_id %d to stat index %d",
+       PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
                     (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
                     queue_id, stat_idx);
-       PMD_INIT_LOG(INFO, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
+       PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
                     is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
 
        /* Now write the mapping in the appropriate register */
        if (is_rx) {
-               PMD_INIT_LOG(INFO, "Write 0x%x to RX IXGBE stat mapping reg:%d",
+               PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
                             stat_mappings->rqsmr[n], n);
                IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
        }
        else {
-               PMD_INIT_LOG(INFO, "Write 0x%x to TX IXGBE stat mapping reg:%d",
+               PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
                             stat_mappings->tqsm[n], n);
                IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
        }
@@ -887,8 +877,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
                        ixgbe_set_tx_function(eth_dev, txq);
                } else {
                        /* Use default TX function if we get here */
-                       PMD_INIT_LOG(INFO, "No TX queues configured yet. "
-                                          "Using default TX function.");
+                       PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
+                                            "Using default TX function.");
                }
 
                ixgbe_set_rx_function(eth_dev);
@@ -1470,7 +1460,7 @@ ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
 
        if (hw->mac.type == ixgbe_mac_82598EB) {
                /* No queue level support */
-               PMD_INIT_LOG(INFO, "82598EB not support queue level hw strip");
+               PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
                return;
        }
        else {
@@ -1494,7 +1484,7 @@ ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
 
        if (hw->mac.type == ixgbe_mac_82598EB) {
                /* No queue level supported */
-               PMD_INIT_LOG(INFO, "82598EB not support queue level hw strip");
+               PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
                return;
        }
        else {
@@ -1680,9 +1670,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
        struct ixgbe_vf_info *vfinfo =
                *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
        struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
-#ifdef RTE_NEXT_ABI
        uint32_t intr_vector = 0;
-#endif
        int err, link_up = 0, negotiate = 0;
        uint32_t speed = 0;
        int mask = 0;
@@ -1715,7 +1703,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
        /* configure PF module if SRIOV enabled */
        ixgbe_pf_host_configure(dev);
 
-#ifdef RTE_NEXT_ABI
        /* check and configure queue intr-vector mapping */
        if (dev->data->dev_conf.intr_conf.rxq != 0)
                intr_vector = dev->data->nb_rx_queues;
@@ -1734,7 +1721,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
                        return -ENOMEM;
                }
        }
-#endif
 
        /* confiugre msix for sleep until rx interrupt */
        ixgbe_configure_msix(dev);
@@ -1827,11 +1813,9 @@ skip_link_setup:
                                     " no intr multiplex\n");
        }
 
-#ifdef RTE_NEXT_ABI
        /* check if rxq interrupt is enabled */
        if (dev->data->dev_conf.intr_conf.rxq != 0)
                ixgbe_dev_rxq_interrupt_setup(dev);
-#endif
 
        /* enable uio/vfio intr/eventfd mapping */
        rte_intr_enable(intr_handle);
@@ -1942,14 +1926,12 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
        memset(filter_info->fivetuple_mask, 0,
                sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
 
-#ifdef RTE_NEXT_ABI
        /* Clean datapath event and queue/vec mapping */
        rte_intr_efd_disable(intr_handle);
        if (intr_handle->intr_vec != NULL) {
                rte_free(intr_handle->intr_vec);
                intr_handle->intr_vec = NULL;
        }
-#endif
 }
 
 /*
@@ -2057,19 +2039,25 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw, struct ixgbe_hw_stats
                hw_stats->mpc[i] += mp;
                /* Running comprehensive total for stats display */
                *total_missed_rx += hw_stats->mpc[i];
-               if (hw->mac.type == ixgbe_mac_82598EB)
+               if (hw->mac.type == ixgbe_mac_82598EB) {
                        hw_stats->rnbc[i] +=
                            IXGBE_READ_REG(hw, IXGBE_RNBC(i));
+                       hw_stats->pxonrxc[i] +=
+                               IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
+                       hw_stats->pxoffrxc[i] +=
+                               IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
+               } else {
+                       hw_stats->pxonrxc[i] +=
+                               IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
+                       hw_stats->pxoffrxc[i] +=
+                               IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
+                       hw_stats->pxon2offc[i] +=
+                               IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
+               }
                hw_stats->pxontxc[i] +=
                    IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
-               hw_stats->pxonrxc[i] +=
-                   IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
                hw_stats->pxofftxc[i] +=
                    IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
-               hw_stats->pxoffrxc[i] +=
-                   IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
-               hw_stats->pxon2offc[i] +=
-                   IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
        }
        for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
                hw_stats->qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
@@ -2214,6 +2202,7 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        /* Rx Errors */
        stats->ierrors  = hw_stats->crcerrs +
+                         hw_stats->mspdc +
                          hw_stats->rlec +
                          hw_stats->ruc +
                          hw_stats->roc +
@@ -2224,7 +2213,6 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                          hw_stats->mlfc +
                          hw_stats->mrfc +
                          hw_stats->rfc +
-                         hw_stats->rjc +
                          hw_stats->fccrc +
                          hw_stats->fclast;
 
@@ -2444,7 +2432,8 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
                                DEV_TX_OFFLOAD_IPV4_CKSUM  |
                                DEV_TX_OFFLOAD_UDP_CKSUM   |
                                DEV_TX_OFFLOAD_TCP_CKSUM   |
-                               DEV_TX_OFFLOAD_SCTP_CKSUM;
+                               DEV_TX_OFFLOAD_SCTP_CKSUM  |
+                               DEV_TX_OFFLOAD_TCP_TSO;
 
        dev_info->default_rxconf = (struct rte_eth_rxconf) {
                .rx_thresh = {
@@ -2623,7 +2612,6 @@ ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
  *  - On success, zero.
  *  - On failure, a negative value.
  */
-#ifdef RTE_NEXT_ABI
 static int
 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
 {
@@ -2634,7 +2622,6 @@ ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
 
        return 0;
 }
-#endif
 
 /*
  * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
@@ -2659,7 +2646,7 @@ ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
 
        /* read-on-clear nic registers here */
        eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
-       PMD_DRV_LOG(INFO, "eicr %x", eicr);
+       PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
 
        intr->flags = 0;
 
@@ -2724,7 +2711,7 @@ ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
                PMD_INIT_LOG(INFO, " Port %d: Link Down",
                                (int)(dev->data->port_id));
        }
-       PMD_INIT_LOG(INFO, "PCI Address: %04d:%02d:%02d:%d",
+       PMD_INIT_LOG(DEBUG, "PCI Address: %04d:%02d:%02d:%d",
                                dev->pci_dev->addr.domain,
                                dev->pci_dev->addr.bus,
                                dev->pci_dev->addr.devid,
@@ -3410,12 +3397,12 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
         */
 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
        if (!conf->rxmode.hw_strip_crc) {
-               PMD_INIT_LOG(INFO, "VF can't disable HW CRC Strip");
+               PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
                conf->rxmode.hw_strip_crc = 1;
        }
 #else
        if (conf->rxmode.hw_strip_crc) {
-               PMD_INIT_LOG(INFO, "VF can't enable HW CRC Strip");
+               PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
                conf->rxmode.hw_strip_crc = 0;
        }
 #endif
@@ -3435,9 +3422,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
 {
        struct ixgbe_hw *hw =
                IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-#ifdef RTE_NEXT_ABI
        uint32_t intr_vector = 0;
-#endif
        struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
 
        int err, mask = 0;
@@ -3470,7 +3455,6 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
 
        ixgbevf_dev_rxtx_start(dev);
 
-#ifdef RTE_NEXT_ABI
        /* check and configure queue intr-vector mapping */
        if (dev->data->dev_conf.intr_conf.rxq != 0)
                intr_vector = dev->data->nb_rx_queues;
@@ -3488,7 +3472,6 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
                        return -ENOMEM;
                }
        }
-#endif
        ixgbevf_configure_msix(dev);
 
        if (dev->data->dev_conf.intr_conf.lsc != 0) {
@@ -3534,23 +3517,19 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)
        /* disable intr eventfd mapping */
        rte_intr_disable(intr_handle);
 
-#ifdef RTE_NEXT_ABI
        /* Clean datapath event and queue/vec mapping */
        rte_intr_efd_disable(intr_handle);
        if (intr_handle->intr_vec != NULL) {
                rte_free(intr_handle->intr_vec);
                intr_handle->intr_vec = NULL;
        }
-#endif
 }
 
 static void
 ixgbevf_dev_close(struct rte_eth_dev *dev)
 {
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-#ifdef RTE_NEXT_ABI
        struct rte_pci_device *pci_dev;
-#endif
 
        PMD_INIT_FUNC_TRACE();
 
@@ -3563,13 +3542,11 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
        /* reprogram the RAR[0] in case user changed it. */
        ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 
-#ifdef RTE_NEXT_ABI
        pci_dev = dev->pci_dev;
        if (pci_dev->intr_handle.intr_vec) {
                rte_free(pci_dev->intr_handle.intr_vec);
                pci_dev->intr_handle.intr_vec = NULL;
        }
-#endif
 }
 
 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
@@ -4087,7 +4064,6 @@ ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
        return 0;
 }
 
-#ifdef RTE_NEXT_ABI
 static int
 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
@@ -4240,18 +4216,15 @@ ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
                }
        }
 }
-#endif
 
 static void
 ixgbevf_configure_msix(struct rte_eth_dev *dev)
 {
        struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
-#ifdef RTE_NEXT_ABI
        struct ixgbe_hw *hw =
                IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        uint32_t q_idx;
        uint32_t vector_idx = 0;
-#endif
 
        /* won't configure msix register if no mapping is done
         * between intr vector and event fd.
@@ -4259,7 +4232,6 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)
        if (!rte_intr_dp_is_en(intr_handle))
                return;
 
-#ifdef RTE_NEXT_ABI
        /* Configure all RX queues of VF */
        for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
                /* Force all queue use vector 0,
@@ -4271,7 +4243,6 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)
 
        /* Configure VF Rx queue ivar */
        ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
-#endif
 }
 
 /**
@@ -4283,13 +4254,11 @@ static void
 ixgbe_configure_msix(struct rte_eth_dev *dev)
 {
        struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
-#ifdef RTE_NEXT_ABI
        struct ixgbe_hw *hw =
                IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        uint32_t queue_id, vec = 0;
        uint32_t mask;
        uint32_t gpie;
-#endif
 
        /* won't configure msix register if no mapping is done
         * between intr vector and event fd
@@ -4297,7 +4266,6 @@ ixgbe_configure_msix(struct rte_eth_dev *dev)
        if (!rte_intr_dp_is_en(intr_handle))
                return;
 
-#ifdef RTE_NEXT_ABI
        /* setup GPIE for MSI-x mode */
        gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
        gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
@@ -4347,7 +4315,6 @@ ixgbe_configure_msix(struct rte_eth_dev *dev)
                  IXGBE_EIMS_LSC);
 
        IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
-#endif
 }
 
 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
@@ -5484,8 +5451,8 @@ ixgbe_get_eeprom(struct rte_eth_dev *dev,
 
        first = in_eeprom->offset >> 1;
        length = in_eeprom->length >> 1;
-       if ((first >= hw->eeprom.word_size) ||
-           ((first + length) >= hw->eeprom.word_size))
+       if ((first > hw->eeprom.word_size) ||
+           ((first + length) > hw->eeprom.word_size))
                return -EINVAL;
 
        in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
@@ -5504,8 +5471,8 @@ ixgbe_set_eeprom(struct rte_eth_dev *dev,
 
        first = in_eeprom->offset >> 1;
        length = in_eeprom->length >> 1;
-       if ((first >= hw->eeprom.word_size) ||
-           ((first + length) >= hw->eeprom.word_size))
+       if ((first > hw->eeprom.word_size) ||
+           ((first + length) > hw->eeprom.word_size))
                return -EINVAL;
 
        in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);