net/cxgbe: parse and validate flows
[dpdk.git] / drivers / net / cxgbe / cxgbe_ethdev.c
index 14011bb..1adb8e4 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "cxgbe.h"
 #include "cxgbe_pfvf.h"
+#include "cxgbe_flow.h"
 
 /*
  * Macros needed to support the PCI Device ID Table ...
@@ -204,19 +205,18 @@ int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
        struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
        struct adapter *adapter = pi->adapter;
        struct sge *s = &adapter->sge;
-       struct rte_eth_link *old_link = &eth_dev->data->dev_link;
+       struct rte_eth_link new_link = { 0 };
        unsigned int work_done, budget = 4;
 
        cxgbe_poll(&s->fw_evtq, NULL, budget, &work_done);
-       if (old_link->link_status == pi->link_cfg.link_ok)
-               return -1;  /* link not changed */
 
-       eth_dev->data->dev_link.link_status = pi->link_cfg.link_ok;
-       eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-       eth_dev->data->dev_link.link_speed = pi->link_cfg.speed;
+       new_link.link_status = force_linkup(adapter) ?
+                              ETH_LINK_UP : pi->link_cfg.link_ok;
+       new_link.link_autoneg = pi->link_cfg.autoneg;
+       new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+       new_link.link_speed = pi->link_cfg.speed;
 
-       /* link has changed */
-       return 0;
+       return rte_eth_linkstatus_set(eth_dev, &new_link);
 }
 
 int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
@@ -256,7 +256,6 @@ void cxgbe_dev_close(struct rte_eth_dev *eth_dev)
 {
        struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
        struct adapter *adapter = pi->adapter;
-       int i, dev_down = 0;
 
        CXGBE_FUNC_TRACE();
 
@@ -270,22 +269,6 @@ void cxgbe_dev_close(struct rte_eth_dev *eth_dev)
         *  have been disabled
         */
        t4_sge_eth_clear_queues(pi);
-
-       /*  See if all ports are down */
-       for_each_port(adapter, i) {
-               pi = adap2pinfo(adapter, i);
-               /*
-                * Skip first port of the adapter since it will be closed
-                * by DPDK
-                */
-               if (i == 0)
-                       continue;
-               dev_down += (pi->eth_dev->data->dev_started == 0) ? 1 : 0;
-       }
-
-       /* If rest of the ports are stopped, then free up resources */
-       if (dev_down == (adapter->params.nports - 1))
-               cxgbe_close(adapter);
 }
 
 /* Start the device.
@@ -1054,6 +1037,7 @@ static const struct eth_dev_ops cxgbe_eth_dev_ops = {
        .rx_queue_start         = cxgbe_dev_rx_queue_start,
        .rx_queue_stop          = cxgbe_dev_rx_queue_stop,
        .rx_queue_release       = cxgbe_dev_rx_queue_release,
+       .filter_ctrl            = cxgbe_dev_filter_ctrl,
        .stats_get              = cxgbe_dev_stats_get,
        .stats_reset            = cxgbe_dev_stats_reset,
        .flow_ctrl_get          = cxgbe_flow_ctrl_get,
@@ -1143,6 +1127,16 @@ out_free_adapter:
        return err;
 }
 
+static int eth_cxgbe_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+       struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+       struct adapter *adap = pi->adapter;
+
+       /* Free up other ports and all resources */
+       cxgbe_close(adap);
+       return 0;
+}
+
 static int eth_cxgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
        struct rte_pci_device *pci_dev)
 {
@@ -1152,7 +1146,7 @@ static int eth_cxgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 static int eth_cxgbe_pci_remove(struct rte_pci_device *pci_dev)
 {
-       return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
+       return rte_eth_dev_pci_generic_remove(pci_dev, eth_cxgbe_dev_uninit);
 }
 
 static struct rte_pci_driver rte_cxgbe_pmd = {
@@ -1165,3 +1159,6 @@ static struct rte_pci_driver rte_cxgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_cxgbe, rte_cxgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_cxgbe, cxgb4_pci_tbl);
 RTE_PMD_REGISTER_KMOD_DEP(net_cxgbe, "* igb_uio | uio_pci_generic | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
+                             CXGBE_DEVARG_KEEP_OVLAN "=<0|1> "
+                             CXGBE_DEVARG_FORCE_LINK_UP "=<0|1> ");