ring: guarantee load/load order in enqueue and dequeue
[dpdk.git] / drivers / net / liquidio / lio_ethdev.c
index a17fba5..84b8a32 100644 (file)
@@ -311,7 +311,7 @@ lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
 }
 
 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
-static void
+static int
 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
                  struct rte_eth_stats *stats)
 {
@@ -359,6 +359,8 @@ lio_dev_stats_get(struct rte_eth_dev *eth_dev,
        stats->ibytes = bytes;
        stats->ipackets = pkts;
        stats->ierrors = drop;
+
+       return 0;
 }
 
 static void
@@ -403,6 +405,10 @@ lio_dev_info_get(struct rte_eth_dev *eth_dev,
        /* CN23xx 10G cards */
        case PCI_SUBSYS_DEV_ID_CN2350_210:
        case PCI_SUBSYS_DEV_ID_CN2360_210:
+       case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
+       case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
+       case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
+       case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
                devinfo->speed_capa = ETH_LINK_SPEED_10G;
                break;
        /* CN23xx 25G cards */
@@ -411,8 +417,9 @@ lio_dev_info_get(struct rte_eth_dev *eth_dev,
                devinfo->speed_capa = ETH_LINK_SPEED_25G;
                break;
        default:
+               devinfo->speed_capa = ETH_LINK_SPEED_10G;
                lio_dev_err(lio_dev,
-                           "Unknown CN23XX subsystem device id. Not setting speed capability.\n");
+                           "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
        }
 
        devinfo->max_rx_queues = lio_dev->max_rx_queues;
@@ -974,6 +981,7 @@ lio_dev_link_update(struct rte_eth_dev *eth_dev,
        link.link_status = ETH_LINK_DOWN;
        link.link_speed = ETH_SPEED_NUM_NONE;
        link.link_duplex = ETH_LINK_HALF_DUPLEX;
+       link.link_autoneg = ETH_LINK_AUTONEG;
        memset(&old, 0, sizeof(old));
 
        /* Return what we found */
@@ -1045,6 +1053,48 @@ lio_change_dev_flag(struct rte_eth_dev *eth_dev)
                lio_dev_err(lio_dev, "Change dev flag command timed out\n");
 }
 
+static void
+lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+       struct lio_device *lio_dev = LIO_DEV(eth_dev);
+
+       if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
+               lio_dev_err(lio_dev, "Require firmware version >= %s\n",
+                           LIO_VF_TRUST_MIN_VERSION);
+               return;
+       }
+
+       if (!lio_dev->intf_open) {
+               lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
+                           lio_dev->port_id);
+               return;
+       }
+
+       lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
+       lio_change_dev_flag(eth_dev);
+}
+
+static void
+lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+       struct lio_device *lio_dev = LIO_DEV(eth_dev);
+
+       if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
+               lio_dev_err(lio_dev, "Require firmware version >= %s\n",
+                           LIO_VF_TRUST_MIN_VERSION);
+               return;
+       }
+
+       if (!lio_dev->intf_open) {
+               lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
+                           lio_dev->port_id);
+               return;
+       }
+
+       lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
+       lio_change_dev_flag(eth_dev);
+}
+
 static void
 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
 {
@@ -1586,6 +1636,11 @@ lio_dev_close(struct rte_eth_dev *eth_dev)
                rte_write32(pkt_count, droq->pkts_sent_reg);
        }
 
+       if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
+               cn23xx_vf_ask_pf_to_do_flr(lio_dev);
+               rte_delay_ms(LIO_PCI_FLR_WAIT);
+       }
+
        /* lio_free_mbox */
        lio_dev->fn_list.free_mbox(lio_dev);
 
@@ -1745,6 +1800,9 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev)
                goto nic_config_fail;
        }
 
+       snprintf(lio_dev->firmware_version, LIO_FW_VERSION_LENGTH, "%s",
+                resp->cfg_info.lio_firmware_version);
+
        lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
                         sizeof(struct octeon_if_cfg_info) >> 3);
 
@@ -1848,6 +1906,8 @@ static const struct eth_dev_ops liovf_eth_dev_ops = {
        .dev_set_link_up        = lio_dev_set_link_up,
        .dev_set_link_down      = lio_dev_set_link_down,
        .dev_close              = lio_dev_close,
+       .promiscuous_enable     = lio_dev_promiscuous_enable,
+       .promiscuous_disable    = lio_dev_promiscuous_disable,
        .allmulticast_enable    = lio_dev_allmulticast_enable,
        .allmulticast_disable   = lio_dev_allmulticast_disable,
        .link_update            = lio_dev_link_update,
@@ -1954,6 +2014,13 @@ lio_first_time_init(struct lio_device *lio_dev,
        if (cn23xx_pfvf_handshake(lio_dev))
                goto error;
 
+       /* Request and wait for device reset. */
+       if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
+               cn23xx_vf_ask_pf_to_do_flr(lio_dev);
+               /* FLR wait time doubled as a precaution. */
+               rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
+       }
+
        if (cn23xx_vf_set_io_queues_off(lio_dev)) {
                lio_dev_err(lio_dev, "Setting io queues off failed\n");
                goto error;
@@ -2029,7 +2096,6 @@ lio_eth_dev_init(struct rte_eth_dev *eth_dev)
                return 0;
 
        rte_eth_copy_pci_info(eth_dev, pdev);
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        if (pdev->mem_resource[0].addr) {
                lio_dev->hw_addr = pdev->mem_resource[0].addr;