i40e: move to drivers/net/
[dpdk.git] / lib / librte_pmd_ixgbe / ixgbe_ethdev.c
index ad903d4..5f9a1cf 100644 (file)
@@ -52,7 +52,6 @@
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
-#include <rte_tailq.h>
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
 
 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
 
-static int eth_ixgbe_dev_init(struct eth_driver *eth_drv,
-               struct rte_eth_dev *eth_dev);
+static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int  ixgbe_dev_configure(struct rte_eth_dev *dev);
 static int  ixgbe_dev_start(struct rte_eth_dev *dev);
 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
@@ -184,8 +182,7 @@ static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
 static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_config);
 
 /* For Virtual Function support */
-static int eth_ixgbevf_dev_init(struct eth_driver *eth_drv,
-               struct rte_eth_dev *eth_dev);
+static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
 static int  ixgbevf_dev_configure(struct rte_eth_dev *dev);
 static int  ixgbevf_dev_start(struct rte_eth_dev *dev);
 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
@@ -300,7 +297,7 @@ static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 /*
  * The set of PCI devices this driver supports
  */
-static struct rte_pci_id pci_id_ixgbe_map[] = {
+static const struct rte_pci_id pci_id_ixgbe_map[] = {
 
 #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -312,7 +309,7 @@ static struct rte_pci_id pci_id_ixgbe_map[] = {
 /*
  * The set of PCI devices this driver supports (for 82599 VF)
  */
-static struct rte_pci_id pci_id_ixgbevf_map[] = {
+static const struct rte_pci_id pci_id_ixgbevf_map[] = {
 
 #define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -320,7 +317,7 @@ static struct rte_pci_id pci_id_ixgbevf_map[] = {
 
 };
 
-static struct eth_dev_ops ixgbe_eth_dev_ops = {
+static const struct eth_dev_ops ixgbe_eth_dev_ops = {
        .dev_configure        = ixgbe_dev_configure,
        .dev_start            = ixgbe_dev_start,
        .dev_stop             = ixgbe_dev_stop,
@@ -390,8 +387,7 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
  * dev_ops for virtual function, bare necessities for basic vf
  * operation have been implemented
  */
-static struct eth_dev_ops ixgbevf_eth_dev_ops = {
-
+static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
        .dev_configure        = ixgbevf_dev_configure,
        .dev_start            = ixgbevf_dev_start,
        .dev_stop             = ixgbevf_dev_stop,
@@ -718,8 +714,7 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
  * It returns 0 on success.
  */
 static int
-eth_ixgbe_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
-                    struct rte_eth_dev *eth_dev)
+eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
 {
        struct rte_pci_device *pci_dev;
        struct ixgbe_hw *hw =
@@ -748,20 +743,20 @@ eth_ixgbe_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
         * RX and TX function.
         */
        if (rte_eal_process_type() != RTE_PROC_PRIMARY){
-               struct igb_tx_queue *txq;
+               struct ixgbe_tx_queue *txq;
                /* TX queue function in primary, set by last queue initialized
                 * Tx queue may not initialized by primary process */
                if (eth_dev->data->tx_queues) {
                        txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
-                       set_tx_function(eth_dev, txq);
+                       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.");
                }
 
-               if (eth_dev->data->scattered_rx)
-                       eth_dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+               ixgbe_set_rx_function(eth_dev);
+
                return 0;
        }
        pci_dev = eth_dev->pci_dev;
@@ -967,8 +962,7 @@ generate_random_mac_addr(struct ether_addr *mac_addr)
  * Virtual Function device init
  */
 static int
-eth_ixgbevf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
-                    struct rte_eth_dev *eth_dev)
+eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 {
        int diag;
        uint32_t tc, tcs;
@@ -992,7 +986,7 @@ eth_ixgbevf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
         * RX function */
        if (rte_eal_process_type() != RTE_PROC_PRIMARY){
                if (eth_dev->data->scattered_rx)
-                       eth_dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+                       eth_dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
                return 0;
        }
 
@@ -1434,12 +1428,21 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 {
        struct ixgbe_interrupt *intr =
                IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+       struct ixgbe_adapter *adapter =
+               (struct ixgbe_adapter *)dev->data->dev_private;
 
        PMD_INIT_FUNC_TRACE();
 
        /* set flag to update link status after init */
        intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
+       /*
+        * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
+        * allocation or vector Rx preconditions we will reset it.
+        */
+       adapter->rx_bulk_alloc_allowed = true;
+       adapter->rx_vec_allowed = true;
+
        return 0;
 }
 
@@ -1641,6 +1644,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
 
        /* Clear stored conf */
        dev->data->scattered_rx = 0;
+       dev->data->lro = 0;
 
        /* Clear recorded link status */
        memset(&link, 0, sizeof(link));
@@ -2009,6 +2013,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                DEV_RX_OFFLOAD_IPV4_CKSUM |
                DEV_RX_OFFLOAD_UDP_CKSUM  |
                DEV_RX_OFFLOAD_TCP_CKSUM;
+
+       /*
+        * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
+        * mode.
+        */
+       if ((hw->mac.type == ixgbe_mac_82599EB ||
+            hw->mac.type == ixgbe_mac_X540) &&
+           !RTE_ETH_DEV_SRIOV(dev).active)
+               dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
+
        dev_info->tx_offload_capa =
                DEV_TX_OFFLOAD_VLAN_INSERT |
                DEV_TX_OFFLOAD_IPV4_CKSUM  |
@@ -2039,6 +2053,7 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                                ETH_TXQ_FLAGS_NOOFFLOADS,
        };
        dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
+       dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
 }
 
 static void
@@ -3809,19 +3824,6 @@ convert_protocol_type(uint8_t protocol_value)
                return IXGBE_FILTER_PROTOCOL_NONE;
 }
 
-static inline uint8_t
-revert_protocol_type(enum ixgbe_5tuple_protocol protocol)
-{
-       if (protocol == IXGBE_FILTER_PROTOCOL_TCP)
-               return IPPROTO_TCP;
-       else if (protocol == IXGBE_FILTER_PROTOCOL_UDP)
-               return IPPROTO_UDP;
-       else if (protocol == IXGBE_FILTER_PROTOCOL_SCTP)
-               return IPPROTO_SCTP;
-       else
-               return 0;
-}
-
 /*
  * add a 5tuple filter
  *
@@ -3890,10 +3892,10 @@ ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
        ftqf |= IXGBE_FTQF_POOL_MASK_EN;
        ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
 
-       IXGBE_WRITE_REG(hw, IXGBE_DAQF(idx), filter->filter_info.dst_ip);
-       IXGBE_WRITE_REG(hw, IXGBE_SAQF(idx), filter->filter_info.src_ip);
-       IXGBE_WRITE_REG(hw, IXGBE_SDPQF(idx), sdpqf);
-       IXGBE_WRITE_REG(hw, IXGBE_FTQF(idx), ftqf);
+       IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
+       IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
+       IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
+       IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
 
        l34timir |= IXGBE_L34T_IMIR_RESERVE;
        l34timir |= (uint32_t)(filter->queue <<