net/ice: rework for generic flow enabling
[dpdk.git] / drivers / net / ice / ice_ethdev.c
index c126d96..b433ba8 100644 (file)
 #include "base/ice_dcb.h"
 #include "ice_ethdev.h"
 #include "ice_rxtx.h"
-#include "ice_switch_filter.h"
+#include "ice_generic_flow.h"
 
 /* devargs */
 #define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support"
+#define ICE_PIPELINE_MODE_SUPPORT_ARG  "pipeline-mode-support"
 #define ICE_PROTO_XTR_ARG         "proto_xtr"
 
 static const char * const ice_valid_args[] = {
        ICE_SAFE_MODE_SUPPORT_ARG,
+       ICE_PIPELINE_MODE_SUPPORT_ARG,
        ICE_PROTO_XTR_ARG,
        NULL
 };
@@ -41,6 +43,15 @@ static const char * const ice_valid_args[] = {
 
 int ice_logtype_init;
 int ice_logtype_driver;
+#ifdef RTE_LIBRTE_ICE_DEBUG_RX
+int ice_logtype_rx;
+#endif
+#ifdef RTE_LIBRTE_ICE_DEBUG_TX
+int ice_logtype_tx;
+#endif
+#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
+int ice_logtype_tx_free;
+#endif
 
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
@@ -158,6 +169,8 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
        .vlan_pvid_set                = ice_vlan_pvid_set,
        .rxq_info_get                 = ice_rxq_info_get,
        .txq_info_get                 = ice_txq_info_get,
+       .rx_burst_mode_get            = ice_rx_burst_mode_get,
+       .tx_burst_mode_get            = ice_tx_burst_mode_get,
        .get_eeprom_length            = ice_get_eeprom_length,
        .get_eeprom                   = ice_get_eeprom,
        .rx_queue_count               = ice_rx_queue_count,
@@ -419,8 +432,7 @@ parse_queue_proto_xtr(const char *queues, struct ice_devargs *devargs)
                if (xtr_type < 0)
                        return -1;
 
-               memset(devargs->proto_xtr, xtr_type,
-                      sizeof(devargs->proto_xtr));
+               devargs->proto_xtr_dflt = xtr_type;
 
                return 0;
        }
@@ -1360,12 +1372,36 @@ done:
        rte_intr_ack(dev->intr_handle);
 }
 
+static void
+ice_init_proto_xtr(struct rte_eth_dev *dev)
+{
+       struct ice_adapter *ad =
+                       ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+       struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+       struct ice_hw *hw = ICE_PF_TO_HW(pf);
+       uint16_t i;
+
+       if (!ice_proto_xtr_support(hw)) {
+               PMD_DRV_LOG(NOTICE, "Protocol extraction is not supported");
+               return;
+       }
+
+       pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
+       if (unlikely(pf->proto_xtr == NULL)) {
+               PMD_DRV_LOG(ERR, "No memory for setting up protocol extraction table");
+               return;
+       }
+
+       for (i = 0; i < pf->lan_nb_qps; i++)
+               pf->proto_xtr[i] = ad->devargs.proto_xtr[i] != PROTO_XTR_NONE ?
+                                  ad->devargs.proto_xtr[i] :
+                                  ad->devargs.proto_xtr_dflt;
+}
+
 /*  Initialize SW parameters of PF */
 static int
 ice_pf_sw_init(struct rte_eth_dev *dev)
 {
-       struct ice_adapter *ad =
-                       ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct ice_hw *hw = ICE_PF_TO_HW(pf);
 
@@ -1375,15 +1411,7 @@ ice_pf_sw_init(struct rte_eth_dev *dev)
 
        pf->lan_nb_qps = pf->lan_nb_qp_max;
 
-       if (ice_proto_xtr_support(hw))
-               pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
-
-       if (pf->proto_xtr != NULL)
-               rte_memcpy(pf->proto_xtr, ad->devargs.proto_xtr,
-                          RTE_MIN((size_t)pf->lan_nb_qps,
-                                  sizeof(ad->devargs.proto_xtr)));
-       else
-               PMD_DRV_LOG(NOTICE, "Protocol extraction is disabled");
+       ice_init_proto_xtr(dev);
 
        return 0;
 }
@@ -1796,6 +1824,7 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
                return -EINVAL;
        }
 
+       ad->devargs.proto_xtr_dflt = PROTO_XTR_NONE;
        memset(ad->devargs.proto_xtr, PROTO_XTR_NONE,
               sizeof(ad->devargs.proto_xtr));
 
@@ -1806,6 +1835,11 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 
        ret = rte_kvargs_process(kvlist, ICE_SAFE_MODE_SUPPORT_ARG,
                                 &parse_bool, &ad->devargs.safe_mode_support);
+       if (ret)
+               goto bail;
+
+       ret = rte_kvargs_process(kvlist, ICE_PIPELINE_MODE_SUPPORT_ARG,
+                                &parse_bool, &ad->devargs.pipe_mode_support);
 
 bail:
        rte_kvargs_free(kvlist);
@@ -1924,6 +1958,11 @@ ice_dev_init(struct rte_eth_dev *dev)
                goto err_init_mac;
        }
 
+       /* Pass the information to the rte_eth_dev_close() that it should also
+        * release the private port resources.
+        */
+       dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
        ret = ice_res_pool_init(&pf->msix_pool, 1,
                                hw->func_caps.common_cap.num_msix_vectors - 1);
        if (ret) {
@@ -1970,7 +2009,11 @@ ice_dev_init(struct rte_eth_dev *dev)
        /* get base queue pairs index  in the device */
        ice_base_queue_get(pf);
 
-       TAILQ_INIT(&pf->flow_list);
+       ret = ice_flow_init(ad);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Failed to initialize flow");
+               return ret;
+       }
 
        return 0;
 
@@ -2090,6 +2133,10 @@ ice_dev_close(struct rte_eth_dev *dev)
 {
        struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct ice_adapter *ad =
+               ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
        /* Since stop will make link down, then the link event will be
         * triggered, disable the irq firstly to avoid the port_infoe etc
@@ -2100,6 +2147,8 @@ ice_dev_close(struct rte_eth_dev *dev)
 
        ice_dev_stop(dev);
 
+       ice_flow_uninit(ad);
+
        /* release all queue resource */
        ice_free_queues(dev);
 
@@ -2111,20 +2160,6 @@ ice_dev_close(struct rte_eth_dev *dev)
        ice_shutdown_all_ctrlq(hw);
        rte_free(pf->proto_xtr);
        pf->proto_xtr = NULL;
-}
-
-static int
-ice_dev_uninit(struct rte_eth_dev *dev)
-{
-       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
-       struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-       struct rte_flow *p_flow;
-
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
-
-       ice_dev_close(dev);
 
        dev->dev_ops = NULL;
        dev->rx_pkt_burst = NULL;
@@ -2139,13 +2174,12 @@ ice_dev_uninit(struct rte_eth_dev *dev)
        /* unregister callback func from eal lib */
        rte_intr_callback_unregister(intr_handle,
                                     ice_interrupt_handler, dev);
+}
 
-       /* Remove all flows */
-       while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
-               TAILQ_REMOVE(&pf->flow_list, p_flow, node);
-               ice_free_switch_filter_rule(p_flow->rule);
-               rte_free(p_flow);
-       }
+static int
+ice_dev_uninit(struct rte_eth_dev *dev)
+{
+       ice_dev_close(dev);
 
        return 0;
 }
@@ -3176,8 +3210,8 @@ ice_get_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size)
                return -EINVAL;
 
        if (pf->flags & ICE_FLAG_RSS_AQ_CAPABLE) {
-               ret = ice_aq_get_rss_lut(hw, vsi->idx, TRUE,
-                                        lut, lut_size);
+               ret = ice_aq_get_rss_lut(hw, vsi->idx,
+                       ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF, lut, lut_size);
                if (ret) {
                        PMD_DRV_LOG(ERR, "Failed to get RSS lookup table");
                        return -EINVAL;
@@ -3207,8 +3241,8 @@ ice_set_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size)
        hw = ICE_VSI_TO_HW(vsi);
 
        if (pf->flags & ICE_FLAG_RSS_AQ_CAPABLE) {
-               ret = ice_aq_set_rss_lut(hw, vsi->idx, TRUE,
-                                        lut, lut_size);
+               ret = ice_aq_set_rss_lut(hw, vsi->idx,
+                       ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF, lut, lut_size);
                if (ret) {
                        PMD_DRV_LOG(ERR, "Failed to set RSS lookup table");
                        return -EINVAL;
@@ -4271,7 +4305,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_ice, pci_id_ice_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ice,
                              ICE_PROTO_XTR_ARG "=[queue:]<vlan|ipv4|ipv6|ipv6_flow|tcp>"
-                             ICE_SAFE_MODE_SUPPORT_ARG "=<0|1>");
+                             ICE_SAFE_MODE_SUPPORT_ARG "=<0|1>"
+                             ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>");
 
 RTE_INIT(ice_init_log)
 {
@@ -4281,4 +4316,22 @@ RTE_INIT(ice_init_log)
        ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
        if (ice_logtype_driver >= 0)
                rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
+
+#ifdef RTE_LIBRTE_ICE_DEBUG_RX
+       ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
+       if (ice_logtype_rx >= 0)
+               rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+#endif
+
+#ifdef RTE_LIBRTE_ICE_DEBUG_TX
+       ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
+       if (ice_logtype_tx >= 0)
+               rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+#endif
+
+#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
+       ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
+       if (ice_logtype_tx_free >= 0)
+               rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+#endif
 }