net: add macro for MAC address print
[dpdk.git] / drivers / net / mlx5 / windows / mlx5_os.c
index 95e4e1e..c2e4665 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdlib.h>
 
 #include <rte_windows.h>
-#include <rte_ethdev_pci.h>
+#include <ethdev_pci.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include "mlx5_common_os.h"
 #include "mlx5_utils.h"
 #include "mlx5_rxtx.h"
+#include "mlx5_rx.h"
+#include "mlx5_tx.h"
 #include "mlx5_autoconf.h"
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
 #include "mlx5_devx.h"
 
-#define MLX5_TAGS_HLIST_ARRAY_SIZE 8192
-
 static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
 
 /* Spinlock for mlx5_shared_data allocation. */
 static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 
+/* rte flow indexed pool configuration. */
+static struct mlx5_indexed_pool_config icfg[] = {
+       {
+               .size = sizeof(struct rte_flow),
+               .trunk_size = 64,
+               .need_lock = 1,
+               .release_mem_en = 0,
+               .malloc = mlx5_malloc,
+               .free = mlx5_free,
+               .per_core_cache = 0,
+               .type = "ctl_flow_ipool",
+       },
+       {
+               .size = sizeof(struct rte_flow),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 1,
+               .release_mem_en = 0,
+               .malloc = mlx5_malloc,
+               .free = mlx5_free,
+               .per_core_cache = 1 << 14,
+               .type = "rte_flow_ipool",
+       },
+       {
+               .size = sizeof(struct rte_flow),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 1,
+               .release_mem_en = 0,
+               .malloc = mlx5_malloc,
+               .free = mlx5_free,
+               .per_core_cache = 0,
+               .type = "mcp_flow_ipool",
+       },
+};
+
 /**
  * Initialize shared data between primary and secondary process.
  *
@@ -165,7 +203,7 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
        if (!sh->flow_tbls)
                err = mlx5_alloc_table_hash_list(priv);
        else
-               DRV_LOG(DEBUG, "sh->flow_tbls[%p] already created, reuse\n",
+               DRV_LOG(DEBUG, "sh->flow_tbls[%p] already created, reuse",
                        (void *)sh->flow_tbls);
        return err;
 }
@@ -313,11 +351,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        struct mlx5_priv *priv = NULL;
        int err = 0;
        unsigned int cqe_comp;
-       unsigned int cqe_pad = 0;
        struct rte_ether_addr mac;
        char name[RTE_ETH_NAME_MAX_LEN];
        int own_domain_id = 0;
        uint16_t port_id;
+       int i;
 
        /* Build device name. */
        strlcpy(name, dpdk_dev->name, sizeof(name));
@@ -358,11 +396,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        config->swp = 0;
        config->ind_table_max_size =
                sh->device_attr.max_rwq_indirection_table_size;
-       if (RTE_CACHE_LINE_SIZE == 128 &&
-           !(device_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
-               cqe_comp = 0;
-       else
-               cqe_comp = 1;
+       cqe_comp = 0;
        config->cqe_comp = cqe_comp;
        DRV_LOG(DEBUG, "tunnel offloading is not supported");
        config->tunnel_en = 0;
@@ -396,7 +430,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
         * Look for sibling devices in order to reuse their switch domain
         * if any, otherwise allocate one.
         */
-       MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
+       MLX5_ETH_FOREACH_DEV(port_id, dpdk_dev) {
                const struct mlx5_priv *opriv =
                        rte_eth_devices[port_id].data->dev_private;
 
@@ -420,13 +454,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        }
        /* Override some values set by hardware configuration. */
        mlx5_args(config, dpdk_dev->devargs);
-       err = mlx5_dev_check_sibling_config(priv, config);
+       err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev);
        if (err)
                goto error;
-       config->hw_csum = !!(sh->device_attr.device_cap_flags_ex &
-                           IBV_DEVICE_RAW_IP_CSUM);
-       DRV_LOG(DEBUG, "checksum offloading is %ssupported",
-               (config->hw_csum ? "" : "not "));
        DRV_LOG(DEBUG, "counters are not supported");
        config->ind_table_max_size =
                sh->device_attr.max_rwq_indirection_table_size;
@@ -438,19 +468,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                config->ind_table_max_size = ETH_RSS_RETA_SIZE_512;
        DRV_LOG(DEBUG, "maximum Rx indirection table size is %u",
                config->ind_table_max_size);
-       config->hw_vlan_strip = !!(sh->device_attr.raw_packet_caps &
-                                 IBV_RAW_PACKET_CAP_CVLAN_STRIPPING);
        DRV_LOG(DEBUG, "VLAN stripping is %ssupported",
                (config->hw_vlan_strip ? "" : "not "));
-       config->hw_fcs_strip = !!(sh->device_attr.raw_packet_caps &
-                                IBV_RAW_PACKET_CAP_SCATTER_FCS);
        if (config->hw_padding) {
                DRV_LOG(DEBUG, "Rx end alignment padding isn't supported");
                config->hw_padding = 0;
        }
-       config->tso = (sh->device_attr.max_tso > 0 &&
-                     (sh->device_attr.tso_supported_qpts &
-                      (1 << IBV_QPT_RAW_PACKET)));
        if (config->tso)
                config->tso_max_payload_sz = sh->device_attr.max_tso;
        DRV_LOG(DEBUG, "%sMPS is %s.",
@@ -461,12 +484,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                DRV_LOG(WARNING, "Rx CQE compression isn't supported.");
                config->cqe_comp = 0;
        }
-       if (config->cqe_pad && !cqe_pad) {
-               DRV_LOG(WARNING, "Rx CQE padding isn't supported.");
-               config->cqe_pad = 0;
-       } else if (config->cqe_pad) {
-               DRV_LOG(INFO, "Rx CQE padding is enabled.");
-       }
        if (config->devx) {
                err = mlx5_devx_cmd_query_hca_attr(sh->ctx, &config->hca_attr);
                if (err) {
@@ -482,6 +499,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                        sh->cmng.relaxed_ordering_read =
                                config->hca_attr.relaxed_ordering_read;
                }
+               config->hw_csum = config->hca_attr.csum_cap;
+               DRV_LOG(DEBUG, "checksum offloading is %ssupported",
+                   (config->hw_csum ? "" : "not "));
        }
        if (config->devx) {
                uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)];
@@ -504,6 +524,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                                                 (NS_PER_S / MS_PER_S))
                                config->rt_timestamp = 1;
                }
+               sh->rq_ts_format = config->hca_attr.rq_ts_format;
+               sh->sq_ts_format = config->hca_attr.sq_ts_format;
+               sh->qp_ts_format = config->hca_attr.qp_ts_format;
        }
        if (config->mprq.enabled) {
                DRV_LOG(WARNING, "Multi-Packet RQ isn't supported");
@@ -543,14 +566,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                goto error;
        }
        DRV_LOG(INFO,
-               "port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
+               "port %u MAC address is " RTE_ETHER_ADDR_PRT_FMT,
                eth_dev->data->port_id,
                mac.addr_bytes[0], mac.addr_bytes[1],
                mac.addr_bytes[2], mac.addr_bytes[3],
                mac.addr_bytes[4], mac.addr_bytes[5]);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        {
-               char ifname[IF_NAMESIZE];
+               char ifname[MLX5_NAMESIZE];
 
                if (mlx5_get_ifname(eth_dev, &ifname) == 0)
                        DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
@@ -571,16 +594,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        /* Initialize burst functions to prevent crashes before link-up. */
        eth_dev->rx_pkt_burst = removed_rx_burst;
        eth_dev->tx_pkt_burst = removed_tx_burst;
-       eth_dev->dev_ops = &mlx5_os_dev_ops;
+       eth_dev->dev_ops = &mlx5_dev_ops;
        eth_dev->rx_descriptor_status = mlx5_rx_descriptor_status;
        eth_dev->tx_descriptor_status = mlx5_tx_descriptor_status;
        eth_dev->rx_queue_count = mlx5_rx_queue_count;
        /* Register MAC address. */
        claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0));
-       priv->flows = 0;
        priv->ctrl_flows = 0;
        TAILQ_INIT(&priv->flow_meters);
-       TAILQ_INIT(&priv->flow_meter_profiles);
+       priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
+       if (!priv->mtr_profile_tbl)
+               goto error;
        /* Bring Ethernet device up. */
        DRV_LOG(DEBUG, "port %u forcing Ethernet interface up.",
                eth_dev->data->port_id);
@@ -599,6 +623,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        mlx5_set_min_inline(spawn, config);
        /* Store device configuration on private structure. */
        priv->config = *config;
+       for (i = 0; i < MLX5_FLOW_TYPE_MAXI; i++) {
+               icfg[i].release_mem_en = !!config->reclaim_mode;
+               if (config->reclaim_mode)
+                       icfg[i].per_core_cache = 0;
+               priv->flows[i] = mlx5_ipool_create(&icfg[i]);
+               if (!priv->flows[i])
+                       goto error;
+       }
        /* Create context for virtual machine VLAN workaround. */
        priv->vmwa_context = NULL;
        if (config->dv_flow_en) {
@@ -623,10 +655,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                        err = ENOTSUP;
                        goto error;
        }
-       mlx5_cache_list_init(&priv->hrxqs, "hrxq", 0, eth_dev,
-                            mlx5_hrxq_create_cb,
-                            mlx5_hrxq_match_cb,
-                            mlx5_hrxq_remove_cb);
+       priv->hrxqs = mlx5_list_create("hrxq", eth_dev, true,
+               mlx5_hrxq_create_cb, mlx5_hrxq_match_cb,
+               mlx5_hrxq_remove_cb, mlx5_hrxq_clone_cb,
+               mlx5_hrxq_clone_free_cb);
        /* Query availability of metadata reg_c's. */
        err = mlx5_flow_discover_mreg_c(eth_dev);
        if (err < 0) {
@@ -658,6 +690,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
        return eth_dev;
 error:
        if (priv) {
+               if (priv->mtr_profile_tbl)
+                       mlx5_l3t_destroy(priv->mtr_profile_tbl);
                if (own_domain_id)
                        claim_zero(rte_eth_switch_domain_free(priv->domain_id));
                mlx5_free(priv);
@@ -935,20 +969,18 @@ mlx5_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf,
 /**
  * DPDK callback to register a PCI device.
  *
- * This function spawns Ethernet devices out of a given PCI device.
+ * This function spawns Ethernet devices out of a given device.
  *
- * @param[in] pci_drv
- *   PCI driver structure (mlx5_driver).
- * @param[in] pci_dev
- *   PCI device information.
+ * @param[in] dev
+ *   Pointer to the generic device.
  *
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-                 struct rte_pci_device *pci_dev)
+mlx5_os_net_probe(struct rte_device *dev)
 {
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
        struct devx_device_bdf *devx_bdf_devs, *orig_devx_bdf_devs;
        /*
         * Number of found IB Devices matching with requested PCI BDF.
@@ -1093,6 +1125,7 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
        dev_config.dv_flow_en = 1;
        dev_config.decap_en = 0;
        dev_config.log_hp_size = MLX5_ARG_UNSET;
+       list[ns].numa_node = pci_dev->device.numa_node;
        list[ns].eth_dev = mlx5_dev_spawn(&pci_dev->device,
                                          &list[ns],
                                          &dev_config);
@@ -1156,111 +1189,3 @@ mlx5_os_get_pdn(void *pd, uint32_t *pdn)
 }
 
 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
-
-const struct eth_dev_ops mlx5_os_dev_ops = {
-       .dev_configure = mlx5_dev_configure,
-       .dev_start = mlx5_dev_start,
-       .dev_stop = mlx5_dev_stop,
-       .dev_close = mlx5_dev_close,
-       .mtu_set = mlx5_dev_set_mtu,
-       .link_update = mlx5_link_update,
-       .stats_get = mlx5_stats_get,
-       .stats_reset = mlx5_stats_reset,
-       .dev_infos_get = mlx5_dev_infos_get,
-       .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
-       .promiscuous_enable = mlx5_promiscuous_enable,
-       .promiscuous_disable = mlx5_promiscuous_disable,
-       .allmulticast_enable = mlx5_allmulticast_enable,
-       .allmulticast_disable = mlx5_allmulticast_disable,
-       .xstats_get = mlx5_xstats_get,
-       .xstats_reset = mlx5_xstats_reset,
-       .xstats_get_names = mlx5_xstats_get_names,
-       .fw_version_get = mlx5_fw_version_get,
-       .read_clock = mlx5_read_clock,
-       .vlan_filter_set = mlx5_vlan_filter_set,
-       .rx_queue_setup = mlx5_rx_queue_setup,
-       .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
-       .tx_queue_setup = mlx5_tx_queue_setup,
-       .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
-       .rx_queue_release = mlx5_rx_queue_release,
-       .tx_queue_release = mlx5_tx_queue_release,
-       .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
-       .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
-       .mac_addr_remove = mlx5_mac_addr_remove,
-       .mac_addr_add = mlx5_mac_addr_add,
-       .mac_addr_set = mlx5_mac_addr_set,
-       .set_mc_addr_list = mlx5_set_mc_addr_list,
-       .vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
-       .vlan_offload_set = mlx5_vlan_offload_set,
-       .reta_update = mlx5_dev_rss_reta_update,
-       .reta_query = mlx5_dev_rss_reta_query,
-       .rss_hash_update = mlx5_rss_hash_update,
-       .rss_hash_conf_get = mlx5_rss_hash_conf_get,
-       .filter_ctrl = mlx5_dev_filter_ctrl,
-       .rxq_info_get = mlx5_rxq_info_get,
-       .txq_info_get = mlx5_txq_info_get,
-       .rx_burst_mode_get = mlx5_rx_burst_mode_get,
-       .tx_burst_mode_get = mlx5_tx_burst_mode_get,
-       .rx_queue_intr_enable = mlx5_rx_intr_enable,
-       .rx_queue_intr_disable = mlx5_rx_intr_disable,
-       .is_removed = mlx5_is_removed,
-       .udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
-       .get_module_info = mlx5_get_module_info,
-       .get_module_eeprom = mlx5_get_module_eeprom,
-       .hairpin_cap_get = mlx5_hairpin_cap_get,
-       .mtr_ops_get = mlx5_flow_meter_ops_get,
-};
-
-/* Available operations from secondary process. */
-const struct eth_dev_ops mlx5_os_dev_sec_ops = {0};
-
-/* Available operations in flow isolated mode. */
-const struct eth_dev_ops mlx5_os_dev_ops_isolate = {
-       .dev_configure = mlx5_dev_configure,
-       .dev_start = mlx5_dev_start,
-       .dev_stop = mlx5_dev_stop,
-       .dev_close = mlx5_dev_close,
-       .mtu_set = mlx5_dev_set_mtu,
-       .link_update = mlx5_link_update,
-       .stats_get = mlx5_stats_get,
-       .stats_reset = mlx5_stats_reset,
-       .dev_infos_get = mlx5_dev_infos_get,
-       .dev_set_link_down = mlx5_set_link_down,
-       .dev_set_link_up = mlx5_set_link_up,
-       .promiscuous_enable = mlx5_promiscuous_enable,
-       .promiscuous_disable = mlx5_promiscuous_disable,
-       .allmulticast_enable = mlx5_allmulticast_enable,
-       .allmulticast_disable = mlx5_allmulticast_disable,
-       .xstats_get = mlx5_xstats_get,
-       .xstats_reset = mlx5_xstats_reset,
-       .xstats_get_names = mlx5_xstats_get_names,
-       .fw_version_get = mlx5_fw_version_get,
-       .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
-       .vlan_filter_set = mlx5_vlan_filter_set,
-       .rx_queue_setup = mlx5_rx_queue_setup,
-       .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
-       .tx_queue_setup = mlx5_tx_queue_setup,
-       .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
-       .rx_queue_release = mlx5_rx_queue_release,
-       .tx_queue_release = mlx5_tx_queue_release,
-       .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
-       .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
-       .mac_addr_remove = mlx5_mac_addr_remove,
-       .mac_addr_add = mlx5_mac_addr_add,
-       .mac_addr_set = mlx5_mac_addr_set,
-       .set_mc_addr_list = mlx5_set_mc_addr_list,
-       .vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
-       .vlan_offload_set = mlx5_vlan_offload_set,
-       .filter_ctrl = mlx5_dev_filter_ctrl,
-       .rxq_info_get = mlx5_rxq_info_get,
-       .txq_info_get = mlx5_txq_info_get,
-       .rx_burst_mode_get = mlx5_rx_burst_mode_get,
-       .tx_burst_mode_get = mlx5_tx_burst_mode_get,
-       .rx_queue_intr_enable = mlx5_rx_intr_enable,
-       .rx_queue_intr_disable = mlx5_rx_intr_disable,
-       .is_removed = mlx5_is_removed,
-       .get_module_info = mlx5_get_module_info,
-       .get_module_eeprom = mlx5_get_module_eeprom,
-       .hairpin_cap_get = mlx5_hairpin_cap_get,
-       .mtr_ops_get = mlx5_flow_meter_ops_get,
-};