get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/82458/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 82458,
    "url": "https://patches.dpdk.org/api/patches/82458/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20201027232335.31427-59-ophirmu@nvidia.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20201027232335.31427-59-ophirmu@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20201027232335.31427-59-ophirmu@nvidia.com",
    "date": "2020-10-27T23:23:21",
    "name": "[v1,58/72] net/mlx5/windws: spawn eth devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "23cf64caa338ccbe043f78a5e7ceba3e5315545e",
    "submitter": {
        "id": 1908,
        "url": "https://patches.dpdk.org/api/people/1908/?format=api",
        "name": "Ophir Munk",
        "email": "ophirmu@nvidia.com"
    },
    "delegate": {
        "id": 3268,
        "url": "https://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20201027232335.31427-59-ophirmu@nvidia.com/mbox/",
    "series": [
        {
            "id": 13395,
            "url": "https://patches.dpdk.org/api/series/13395/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=13395",
            "date": "2020-10-27T23:22:23",
            "name": "mlx5 Windows support - part #5",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/13395/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/82458/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/82458/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E824CA04B5;\n\tWed, 28 Oct 2020 00:46:00 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B8557C958;\n\tWed, 28 Oct 2020 00:25:58 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id C550D4C95\n for <dev@dpdk.org>; Wed, 28 Oct 2020 00:24:03 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:58 +0200",
            "from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrsA026642;\n Wed, 28 Oct 2020 01:23:58 +0200"
        ],
        "From": "Ophir Munk <ophirmu@nvidia.com>",
        "To": "dev@dpdk.org, Raslan Darawsheh <rasland@nvidia.com>",
        "Cc": "Ophir Munk <ophirmu@nvidia.com>, Matan Azrad <matan@nvidia.com>,\n Tal Shnaiderman <talshn@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>",
        "Date": "Tue, 27 Oct 2020 23:23:21 +0000",
        "Message-Id": "<20201027232335.31427-59-ophirmu@nvidia.com>",
        "X-Mailer": "git-send-email 2.8.4",
        "In-Reply-To": "<20201027232335.31427-1-ophirmu@nvidia.com>",
        "References": "<20201027232335.31427-1-ophirmu@nvidia.com>",
        "Subject": "[dpdk-dev] [PATCH v1 58/72] net/mlx5/windws: spawn eth devices",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This commit implements mlx5_dev_spawn() API which allocates an eth\ndevice (struct rte_eth_dev) for each PCI device. When working with\nrepresentors virtual functions (as in Linux), one PCI device may spawn\nseveral eth devices: the master device for the main physical function\n(PF) and several representors for the virtual functions (VFs).  However,\ncurrently Windows does not work in switch dev mode, therefore, no VFs\nare created and no representors are spawned. In this case one eth device\nis created per one PCI main port.  In addition to device creation - the\ndevice configuration must be correctly set. The device arguments\n(devargs - set by the user) are parsed but they may be overridden by\nWindows limitations or hardware configurations. Some associated network\nparameters are stored in eth device (e.g. ifindex, MAC address, MTU) and\nsome callback (e.g. burst functions) are set.\n\nSigned-off-by: Ophir Munk <ophirmu@nvidia.com>\n---\n drivers/common/mlx5/windows/mlx5_win_defs.h |   6 +\n drivers/net/mlx5/windows/mlx5_os.c          | 481 +++++++++++++++++++++++++++-\n 2 files changed, 482 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/drivers/common/mlx5/windows/mlx5_win_defs.h b/drivers/common/mlx5/windows/mlx5_win_defs.h\nindex e9569e4..d8f2099 100644\n--- a/drivers/common/mlx5/windows/mlx5_win_defs.h\n+++ b/drivers/common/mlx5/windows/mlx5_win_defs.h\n@@ -163,4 +163,10 @@ struct mlx5_wqe_data_seg {\n \trte_be32_t\t\tlkey;\n \trte_be64_t\t\taddr;\n };\n+\n+#define MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP\t(1 << 4)\n+#define IBV_DEVICE_RAW_IP_CSUM\t\t\t(1 << 26)\n+#define IBV_RAW_PACKET_CAP_CVLAN_STRIPPING\t(1 << 0)\n+#define IBV_RAW_PACKET_CAP_SCATTER_FCS\t\t(1 << 1)\n+#define IBV_QPT_RAW_PACKET\t\t\t8\n #endif /* __MLX5_WIN_DEFS_H__ */\ndiff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c\nindex a3e9a6a..f9b469f 100644\n--- a/drivers/net/mlx5/windows/mlx5_os.c\n+++ b/drivers/net/mlx5/windows/mlx5_os.c\n@@ -26,6 +26,9 @@\n #include \"mlx5_autoconf.h\"\n #include \"mlx5_mr.h\"\n #include \"mlx5_flow.h\"\n+#include \"mlx5_devx.h\"\n+\n+#define MLX5_TAGS_HLIST_ARRAY_SIZE 8192\n \n static const char *MZ_MLX5_PMD_SHARED_DATA = \"mlx5_pmd_shared_data\";\n \n@@ -158,6 +161,43 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)\n }\n \n /**\n+ * Initialize DR related data within private structure.\n+ * Routine checks the reference counter and does actual\n+ * resources creation/initialization only if counter is zero.\n+ *\n+ * @param[in] priv\n+ *   Pointer to the private device data structure.\n+ *\n+ * @return\n+ *   Zero on success, positive error code otherwise.\n+ */\n+static int\n+mlx5_alloc_shared_dr(struct mlx5_priv *priv)\n+{\n+\tstruct mlx5_dev_ctx_shared *sh = priv->sh;\n+\tchar s[MLX5_HLIST_NAMESIZE];\n+\tint err = 0;\n+\n+\tif (!sh->flow_tbls)\n+\t\terr = mlx5_alloc_table_hash_list(priv);\n+\telse\n+\t\tDRV_LOG(DEBUG, \"sh->flow_tbls[%p] already created, reuse\\n\",\n+\t\t\t(void *)sh->flow_tbls);\n+\treturn err;\n+}\n+/**\n+ * Destroy DR related data within private structure.\n+ *\n+ * @param[in] priv\n+ *   Pointer to the private device data structure.\n+ */\n+void\n+mlx5_os_free_shared_dr(struct mlx5_priv *priv)\n+{\n+\tmlx5_free_table_hash_list(priv);\n+}\n+\n+/**\n  * Set the completion channel file descriptor interrupt as non-blocking.\n  * Currently it has no support under Windows.\n  *\n@@ -221,6 +261,45 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,\n }\n \n /**\n+ * DV flow counter mode detect and config.\n+ *\n+ * @param dev\n+ *   Pointer to rte_eth_dev structure.\n+ *\n+ */\n+static void\n+mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)\n+{\n+#ifdef HAVE_IBV_FLOW_DV_SUPPORT\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_dev_ctx_shared *sh = priv->sh;\n+\tbool fallback;\n+\n+#ifndef HAVE_IBV_DEVX_ASYNC\n+\tfallback = true;\n+#else\n+\tfallback = false;\n+\tif (!priv->config.devx || !priv->config.dv_flow_en ||\n+\t    !priv->config.hca_attr.flow_counters_dump ||\n+\t    !(priv->config.hca_attr.flow_counter_bulk_alloc_bitmap & 0x4) ||\n+\t    (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP))\n+\t\tfallback = true;\n+#endif\n+\tif (fallback)\n+\t\tDRV_LOG(INFO, \"Use fall-back DV counter management. Flow \"\n+\t\t\t\"counter dump:%d, bulk_alloc_bitmap:0x%hhx.\",\n+\t\t\tpriv->config.hca_attr.flow_counters_dump,\n+\t\t\tpriv->config.hca_attr.flow_counter_bulk_alloc_bitmap);\n+\t/* Initialize fallback mode only on the port initializes sh. */\n+\tif (sh->refcnt == 1)\n+\t\tsh->cmng.counter_fallback = fallback;\n+\telse if (fallback != sh->cmng.counter_fallback)\n+\t\tDRV_LOG(WARNING, \"Port %d in sh has different fallback mode \"\n+\t\t\t\"with others:%d.\", PORT_ID(priv), fallback);\n+#endif\n+}\n+\n+/**\n  * Spawn an Ethernet device from Verbs information.\n  *\n  * @param dpdk_dev\n@@ -231,17 +310,409 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,\n  *   Device configuration parameters.\n  *\n  * @return\n- *   NULL pointer. Operation is not supported and rte_errno is set to ENOTSUP.\n+ *   A valid Ethernet device object on success, NULL otherwise and rte_errno\n+ *   is set. The following errors are defined:\n+ *\n+ *   EEXIST: device is already spawned\n  */\n static struct rte_eth_dev *\n mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t       struct mlx5_dev_spawn_data *spawn,\n \t       struct mlx5_dev_config *config)\n {\n-\t(void)dpdk_dev;\n-\t(void)spawn;\n-\t(void)config;\n-\trte_errno = -ENOTSUP;\n+\tconst struct mlx5_switch_info *switch_info = &spawn->info;\n+\tstruct mlx5_dev_ctx_shared *sh = NULL;\n+\tstruct mlx5_dev_attr device_attr;\n+\tstruct rte_eth_dev *eth_dev = NULL;\n+\tstruct mlx5_priv *priv = NULL;\n+\tint err = 0;\n+\tunsigned int cqe_comp;\n+\tunsigned int cqe_pad = 0;\n+\tstruct rte_ether_addr mac;\n+\tchar name[RTE_ETH_NAME_MAX_LEN];\n+\tint own_domain_id = 0;\n+\tuint16_t port_id;\n+\n+\t/* Build device name. */\n+\tstrlcpy(name, dpdk_dev->name, sizeof(name));\n+\t/* check if the device is already spawned */\n+\tif (rte_eth_dev_get_port_by_name(name, &port_id) == 0) {\n+\t\trte_errno = EEXIST;\n+\t\treturn NULL;\n+\t}\n+\tDRV_LOG(DEBUG, \"naming Ethernet device \\\"%s\\\"\", name);\n+\t/*\n+\t * Some parameters are needed in advance to create device context. We\n+\t * process the devargs here to get ones, and later process devargs\n+\t * again to override some hardware settings.\n+\t */\n+\terr = mlx5_args(config, dpdk_dev->devargs);\n+\tif (err) {\n+\t\terr = rte_errno;\n+\t\tDRV_LOG(ERR, \"failed to process device arguments: %s\",\n+\t\t\tstrerror(rte_errno));\n+\t\tgoto error;\n+\t}\n+\tmlx5_malloc_mem_select(config->sys_mem_en);\n+\tsh = mlx5_alloc_shared_dev_ctx(spawn, config);\n+\tif (!sh)\n+\t\treturn NULL;\n+\tconfig->devx = sh->devx;\n+\t/* Initialize the shutdown event in mlx5_dev_spawn to\n+\t * support mlx5_is_removed for Windows.\n+\t */\n+\terr = mlx5_glue->devx_init_showdown_event(sh->ctx);\n+\tif (err) {\n+\t\tDRV_LOG(ERR, \"failed to init showdown event: %s\",\n+\t\t\tstrerror(errno));\n+\t\tgoto error;\n+\t}\n+\tDRV_LOG(DEBUG, \"MPW isn't supported\");\n+\tmlx5_os_get_dev_attr(sh->ctx, &device_attr);\n+\tconfig->swp = 0;\n+\tconfig->ind_table_max_size =\n+\t\tsh->device_attr.max_rwq_indirection_table_size;\n+\tif (RTE_CACHE_LINE_SIZE == 128 &&\n+\t    !(device_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))\n+\t\tcqe_comp = 0;\n+\telse\n+\t\tcqe_comp = 1;\n+\tconfig->cqe_comp = cqe_comp;\n+\tDRV_LOG(DEBUG, \"tunnel offloading is not supported\");\n+\tconfig->tunnel_en = 0;\n+\tDRV_LOG(DEBUG, \"MPLS over GRE/UDP tunnel offloading is no supported\");\n+\tconfig->mpls_en = 0;\n+\t/* Allocate private eth device data. */\n+\tpriv = mlx5_malloc(MLX5_MEM_ZERO | MLX5_MEM_RTE,\n+\t\t\t   sizeof(*priv),\n+\t\t\t   RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);\n+\tif (priv == NULL) {\n+\t\tDRV_LOG(ERR, \"priv allocation failure\");\n+\t\terr = ENOMEM;\n+\t\tgoto error;\n+\t}\n+\tpriv->sh = sh;\n+\tpriv->dev_port = spawn->phys_port;\n+\tpriv->pci_dev = spawn->pci_dev;\n+\tpriv->mtu = RTE_ETHER_MTU;\n+\tpriv->mp_id.port_id = port_id;\n+\tstrlcpy(priv->mp_id.name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);\n+\tpriv->representor = !!switch_info->representor;\n+\tpriv->master = !!switch_info->master;\n+\tpriv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;\n+\tpriv->vport_meta_tag = 0;\n+\tpriv->vport_meta_mask = 0;\n+\tpriv->pf_bond = spawn->pf_bond;\n+\tpriv->vport_id = -1;\n+\t/* representor_id field keeps the unmodified VF index. */\n+\tpriv->representor_id = -1;\n+\t/*\n+\t * Look for sibling devices in order to reuse their switch domain\n+\t * if any, otherwise allocate one.\n+\t */\n+\tMLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {\n+\t\tconst struct mlx5_priv *opriv =\n+\t\t\trte_eth_devices[port_id].data->dev_private;\n+\n+\t\tif (!opriv ||\n+\t\t    opriv->sh != priv->sh ||\n+\t\t\topriv->domain_id ==\n+\t\t\tRTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID)\n+\t\t\tcontinue;\n+\t\tpriv->domain_id = opriv->domain_id;\n+\t\tbreak;\n+\t}\n+\tif (priv->domain_id == RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) {\n+\t\terr = rte_eth_switch_domain_alloc(&priv->domain_id);\n+\t\tif (err) {\n+\t\t\terr = rte_errno;\n+\t\t\tDRV_LOG(ERR, \"unable to allocate switch domain: %s\",\n+\t\t\t\tstrerror(rte_errno));\n+\t\t\tgoto error;\n+\t\t}\n+\t\town_domain_id = 1;\n+\t}\n+\t/* Override some values set by hardware configuration. */\n+\tmlx5_args(config, dpdk_dev->devargs);\n+\terr = mlx5_dev_check_sibling_config(priv, config);\n+\tif (err)\n+\t\tgoto error;\n+\tconfig->hw_csum = !!(sh->device_attr.device_cap_flags_ex &\n+\t\t\t    IBV_DEVICE_RAW_IP_CSUM);\n+\tDRV_LOG(DEBUG, \"checksum offloading is %ssupported\",\n+\t\t(config->hw_csum ? \"\" : \"not \"));\n+\tDRV_LOG(DEBUG, \"counters are not supported\");\n+\tconfig->ind_table_max_size =\n+\t\tsh->device_attr.max_rwq_indirection_table_size;\n+\t/*\n+\t * Remove this check once DPDK supports larger/variable\n+\t * indirection tables.\n+\t */\n+\tif (config->ind_table_max_size > (unsigned int)ETH_RSS_RETA_SIZE_512)\n+\t\tconfig->ind_table_max_size = ETH_RSS_RETA_SIZE_512;\n+\tDRV_LOG(DEBUG, \"maximum Rx indirection table size is %u\",\n+\t\tconfig->ind_table_max_size);\n+\tconfig->hw_vlan_strip = !!(sh->device_attr.raw_packet_caps &\n+\t\t\t\t  IBV_RAW_PACKET_CAP_CVLAN_STRIPPING);\n+\tDRV_LOG(DEBUG, \"VLAN stripping is %ssupported\",\n+\t\t(config->hw_vlan_strip ? \"\" : \"not \"));\n+\tconfig->hw_fcs_strip = !!(sh->device_attr.raw_packet_caps &\n+\t\t\t\t IBV_RAW_PACKET_CAP_SCATTER_FCS);\n+\tif (config->hw_padding) {\n+\t\tDRV_LOG(DEBUG, \"Rx end alignment padding isn't supported\");\n+\t\tconfig->hw_padding = 0;\n+\t}\n+\tconfig->tso = (sh->device_attr.max_tso > 0 &&\n+\t\t      (sh->device_attr.tso_supported_qpts &\n+\t\t       (1 << IBV_QPT_RAW_PACKET)));\n+\tif (config->tso)\n+\t\tconfig->tso_max_payload_sz = sh->device_attr.max_tso;\n+\tDRV_LOG(DEBUG, \"%sMPS is %s\",\n+\t\tconfig->mps == MLX5_MPW_ENHANCED ? \"enhanced \" :\n+\t\tconfig->mps == MLX5_MPW ? \"legacy \" : \"\",\n+\t\tconfig->mps != MLX5_MPW_DISABLED ? \"enabled\" : \"disabled\");\n+\tif (config->cqe_comp && !cqe_comp) {\n+\t\tDRV_LOG(WARNING, \"Rx CQE compression isn't supported\");\n+\t\tconfig->cqe_comp = 0;\n+\t}\n+\tif (config->cqe_pad && !cqe_pad) {\n+\t\tDRV_LOG(WARNING, \"Rx CQE padding isn't supported\");\n+\t\tconfig->cqe_pad = 0;\n+\t} else if (config->cqe_pad) {\n+\t\tDRV_LOG(INFO, \"Rx CQE padding is enabled\");\n+\t}\n+\tif (config->devx) {\n+\t\terr = mlx5_devx_cmd_query_hca_attr(sh->ctx, &config->hca_attr);\n+\t\tif (err) {\n+\t\t\terr = -err;\n+\t\t\tgoto error;\n+\t\t}\n+\t\t/* Check relax ordering support. */\n+\t\tsh->cmng.relaxed_ordering_read = 0;\n+\t\tsh->cmng.relaxed_ordering_write = 0;\n+\t\tif (!haswell_broadwell_cpu) {\n+\t\t\tsh->cmng.relaxed_ordering_write =\n+\t\t\t\tconfig->hca_attr.relaxed_ordering_write;\n+\t\t\tsh->cmng.relaxed_ordering_read =\n+\t\t\t\tconfig->hca_attr.relaxed_ordering_read;\n+\t\t}\n+\t}\n+\tif (config->devx) {\n+\t\tuint32_t reg[MLX5_ST_SZ_DW(register_mtutc)];\n+\n+\t\terr = config->hca_attr.access_register_user ?\n+\t\t\tmlx5_devx_cmd_register_read\n+\t\t\t\t(sh->ctx, MLX5_REGISTER_ID_MTUTC, 0,\n+\t\t\t\treg, MLX5_ST_SZ_DW(register_mtutc)) : ENOTSUP;\n+\t\tif (!err) {\n+\t\t\tuint32_t ts_mode;\n+\n+\t\t\t/* MTUTC register is read successfully. */\n+\t\t\tts_mode = MLX5_GET(register_mtutc, reg,\n+\t\t\t\t\t   time_stamp_mode);\n+\t\t\tif (ts_mode == MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME)\n+\t\t\t\tconfig->rt_timestamp = 1;\n+\t\t} else {\n+\t\t\t/* Kernel does not support register reading. */\n+\t\t\tif (config->hca_attr.dev_freq_khz ==\n+\t\t\t\t\t\t (NS_PER_S / MS_PER_S))\n+\t\t\t\tconfig->rt_timestamp = 1;\n+\t\t}\n+\t}\n+\tif (config->mprq.enabled) {\n+\t\tDRV_LOG(WARNING, \"Multi-Packet RQ isn't supported\");\n+\t\tconfig->mprq.enabled = 0;\n+\t}\n+\tif (config->max_dump_files_num == 0)\n+\t\tconfig->max_dump_files_num = 128;\n+\teth_dev = rte_eth_dev_allocate(name);\n+\tif (eth_dev == NULL) {\n+\t\tDRV_LOG(ERR, \"can not allocate rte ethdev\");\n+\t\terr = ENOMEM;\n+\t\tgoto error;\n+\t}\n+\tif (priv->representor) {\n+\t\teth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;\n+\t\teth_dev->data->representor_id = priv->representor_id;\n+\t}\n+\t/*\n+\t * Store associated network device interface index. This index\n+\t * is permanent throughout the lifetime of device. So, we may store\n+\t * the ifindex here and use the cached value further.\n+\t */\n+\tMLX5_ASSERT(spawn->ifindex);\n+\tpriv->if_index = spawn->ifindex;\n+\teth_dev->data->dev_private = priv;\n+\tpriv->dev_data = eth_dev->data;\n+\teth_dev->data->mac_addrs = priv->mac;\n+\teth_dev->device = dpdk_dev;\n+\teth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;\n+\t/* Configure the first MAC address by default. */\n+\tif (mlx5_get_mac(eth_dev, &mac.addr_bytes)) {\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"port %u cannot get MAC address, is mlx5_en\"\n+\t\t\t\" loaded? (errno: %s)\",\n+\t\t\teth_dev->data->port_id, strerror(rte_errno));\n+\t\terr = ENODEV;\n+\t\tgoto error;\n+\t}\n+\tDRV_LOG(INFO,\n+\t\t\"port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x\",\n+\t\teth_dev->data->port_id,\n+\t\tmac.addr_bytes[0], mac.addr_bytes[1],\n+\t\tmac.addr_bytes[2], mac.addr_bytes[3],\n+\t\tmac.addr_bytes[4], mac.addr_bytes[5]);\n+#ifdef RTE_LIBRTE_MLX5_DEBUG\n+\t{\n+\t\tchar ifname[IF_NAMESIZE];\n+\n+\t\tif (mlx5_get_ifname(eth_dev, &ifname) == 0)\n+\t\t\tDRV_LOG(DEBUG, \"port %u ifname is \\\"%s\\\"\",\n+\t\t\t\teth_dev->data->port_id, ifname);\n+\t\telse\n+\t\t\tDRV_LOG(DEBUG, \"port %u ifname is unknown\",\n+\t\t\t\teth_dev->data->port_id);\n+\t}\n+#endif\n+\t/* Get actual MTU if possible. */\n+\terr = mlx5_get_mtu(eth_dev, &priv->mtu);\n+\tif (err) {\n+\t\terr = rte_errno;\n+\t\tgoto error;\n+\t}\n+\tDRV_LOG(DEBUG, \"port %u MTU is %u\", eth_dev->data->port_id,\n+\t\tpriv->mtu);\n+\t/* Initialize burst functions to prevent crashes before link-up. */\n+\teth_dev->rx_pkt_burst = removed_rx_burst;\n+\teth_dev->tx_pkt_burst = removed_tx_burst;\n+\teth_dev->dev_ops = &mlx5_os_dev_ops;\n+\teth_dev->rx_descriptor_status = mlx5_rx_descriptor_status;\n+\teth_dev->tx_descriptor_status = mlx5_tx_descriptor_status;\n+\teth_dev->rx_queue_count = mlx5_rx_queue_count;\n+\t/* Register MAC address. */\n+\tclaim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0));\n+\tpriv->flows = 0;\n+\tpriv->ctrl_flows = 0;\n+\tTAILQ_INIT(&priv->flow_meters);\n+\tTAILQ_INIT(&priv->flow_meter_profiles);\n+\t/* Bring Ethernet device up. */\n+\tDRV_LOG(DEBUG, \"port %u forcing Ethernet interface up\",\n+\t\teth_dev->data->port_id);\n+\tmlx5_set_link_up(eth_dev);\n+\t/*\n+\t * Even though the interrupt handler is not installed yet,\n+\t * interrupts will still trigger on the async_fd from\n+\t * Verbs context returned by ibv_open_device().\n+\t */\n+\tmlx5_link_update(eth_dev, 0);\n+\tconfig->dv_esw_en = 0;\n+\t/* Detect minimal data bytes to inline. */\n+\tmlx5_set_min_inline(spawn, config);\n+\t/* Store device configuration on private structure. */\n+\tpriv->config = *config;\n+\t/* Create context for virtual machine VLAN workaround. */\n+\tpriv->vmwa_context = NULL;\n+\tif (config->dv_flow_en) {\n+\t\terr = mlx5_alloc_shared_dr(priv);\n+\t\tif (err)\n+\t\t\tgoto error;\n+\t\t/*\n+\t\t * RSS id is shared with meter flow id. Meter flow id can only\n+\t\t * use the 24 MSB of the register.\n+\t\t */\n+\t\tpriv->qrss_id_pool = mlx5_flow_id_pool_alloc(UINT32_MAX >>\n+\t\t\t\t     MLX5_MTR_COLOR_BITS);\n+\t\tif (!priv->qrss_id_pool) {\n+\t\t\tDRV_LOG(ERR, \"can't create flow id pool\");\n+\t\t\terr = ENOMEM;\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\t/* No supported flow priority number detection. */\n+\tpriv->config.flow_prio = -1;\n+\tif (!priv->config.dv_esw_en &&\n+\t    priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {\n+\t\tDRV_LOG(WARNING, \"metadata mode %u is not supported \"\n+\t\t\t\t \"(no E-Switch)\", priv->config.dv_xmeta_en);\n+\t\tpriv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;\n+\t}\n+\tmlx5_set_metadata_mask(eth_dev);\n+\tif (priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY &&\n+\t    !priv->sh->dv_regc0_mask) {\n+\t\tDRV_LOG(ERR, \"metadata mode %u is not supported \"\n+\t\t\t     \"(no metadata reg_c[0] is available)\",\n+\t\t\t     priv->config.dv_xmeta_en);\n+\t\t\terr = ENOTSUP;\n+\t\t\tgoto error;\n+\t}\n+\t/*\n+\t * Allocate the buffer for flow creating, just once.\n+\t * The allocation must be done before any flow creating.\n+\t */\n+\tmlx5_flow_alloc_intermediate(eth_dev);\n+\t/* Query availability of metadata reg_c's. */\n+\terr = mlx5_flow_discover_mreg_c(eth_dev);\n+\tif (err < 0) {\n+\t\terr = -err;\n+\t\tgoto error;\n+\t}\n+\tif (!mlx5_flow_ext_mreg_supported(eth_dev)) {\n+\t\tDRV_LOG(DEBUG,\n+\t\t\t\"port %u extensive metadata register is not supported\",\n+\t\t\teth_dev->data->port_id);\n+\t\tif (priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {\n+\t\t\tDRV_LOG(ERR, \"metadata mode %u is not supported \"\n+\t\t\t\t     \"(no metadata registers available)\",\n+\t\t\t\t     priv->config.dv_xmeta_en);\n+\t\t\terr = ENOTSUP;\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\tif (priv->config.dv_flow_en &&\n+\t    priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY &&\n+\t    mlx5_flow_ext_mreg_supported(eth_dev) &&\n+\t    priv->sh->dv_regc0_mask) {\n+\t\tpriv->mreg_cp_tbl = mlx5_hlist_create(MLX5_FLOW_MREG_HNAME,\n+\t\t\t\t\t\t      MLX5_FLOW_MREG_HTABLE_SZ);\n+\t\tif (!priv->mreg_cp_tbl) {\n+\t\t\terr = ENOMEM;\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\tif (config->devx && config->dv_flow_en) {\n+\t\tpriv->obj_ops = devx_obj_ops;\n+\t} else {\n+\t\tDRV_LOG(ERR, \"Flow mode %u is not supported \"\n+\t\t\t\t\"(Windows flow must be DevX with DV flow enabled)\",\n+\t\t\t\tpriv->config.dv_flow_en);\n+\t\terr = ENOTSUP;\n+\t\tgoto error;\n+\t}\n+\tmlx5_flow_counter_mode_config(eth_dev);\n+\treturn eth_dev;\n+error:\n+\tif (priv) {\n+\t\tif (priv->mreg_cp_tbl)\n+\t\t\tmlx5_hlist_destroy(priv->mreg_cp_tbl, NULL, NULL);\n+\t\tif (priv->qrss_id_pool)\n+\t\t\tmlx5_flow_id_pool_release(priv->qrss_id_pool);\n+\t\tif (own_domain_id)\n+\t\t\tclaim_zero(rte_eth_switch_domain_free(priv->domain_id));\n+\t\tmlx5_free(priv);\n+\t\tif (eth_dev != NULL)\n+\t\t\teth_dev->data->dev_private = NULL;\n+\t}\n+\tif (eth_dev != NULL) {\n+\t\t/* mac_addrs must not be freed alone because part of\n+\t\t * dev_private\n+\t\t **/\n+\t\teth_dev->data->mac_addrs = NULL;\n+\t\trte_eth_dev_release_port(eth_dev);\n+\t}\n+\tif (sh)\n+\t\tmlx5_free_shared_dev_ctx(sh);\n+\tMLX5_ASSERT(err > 0);\n+\trte_errno = err;\n \treturn NULL;\n }\n \n",
    "prefixes": [
        "v1",
        "58/72"
    ]
}