From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yongseok Koh Subject: [PATCH v3 1/2] net/mlx5: move device spawn configuration to probing Date: Thu, 1 Nov 2018 17:20:31 +0000 Message-ID: <20181101172019.26195-2-yskoh@mellanox.com> References: <20181029231509.39886-1-yskoh@mellanox.com> <20181101172019.26195-1-yskoh@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , Yongseok Koh To: Shahaf Shuler Return-path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50054.outbound.protection.outlook.com [40.107.5.54]) by dpdk.org (Postfix) with ESMTP id C5A911B101 for ; Thu, 1 Nov 2018 18:20:32 +0100 (CET) In-Reply-To: <20181101172019.26195-1-yskoh@mellanox.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When a device is spawned, it does make more sense that the configuration parameters are passed by callee. Furthermore, setting default value for some configuration would need PCIe device ID which can be found in the probe function. Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5.c | 54 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index ec6a482a9a..629f03da99 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -704,8 +704,8 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev) * Backing DPDK device. * @param ibv_dev * Verbs device. - * @param vf - * If nonzero, enable VF-specific features. + * @param config + * Device configuration parameters. * @param[in] switch_info * Switch properties of Ethernet device. * @@ -719,7 +719,7 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev) static struct rte_eth_dev * mlx5_dev_spawn(struct rte_device *dpdk_dev, struct ibv_device *ibv_dev, - int vf, + struct mlx5_dev_config config, const struct mlx5_switch_info *switch_info) { struct ibv_context *ctx; @@ -727,24 +727,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, struct ibv_port_attr port_attr; struct ibv_pd *pd =3D NULL; struct mlx5dv_context dv_attr =3D { .comp_mask =3D 0 }; - struct mlx5_dev_config config =3D { - .vf =3D !!vf, - .cqe_pad =3D 0, - .mps =3D MLX5_ARG_UNSET, - .tx_vec_en =3D 1, - .rx_vec_en =3D 1, - .mpw_hdr_dseg =3D 0, - .txq_inline =3D MLX5_ARG_UNSET, - .txqs_inline =3D MLX5_ARG_UNSET, - .inline_max_packet_sz =3D MLX5_ARG_UNSET, - .vf_nl_en =3D 1, - .mprq =3D { - .enabled =3D 0, - .stride_num_n =3D MLX5_MPRQ_STRIDE_NUM_N, - .max_memcpy_len =3D MLX5_MPRQ_MEMCPY_DEFAULT_LEN, - .min_rxqs_num =3D MLX5_MPRQ_MIN_RXQS, - }, - }; struct rte_eth_dev *eth_dev =3D NULL; struct priv *priv =3D NULL; int err =3D 0; @@ -1176,7 +1158,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, eth_dev->dev_ops =3D &mlx5_dev_ops; /* Register MAC address. */ claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0)); - if (vf && config.vf_nl_en) + if (config.vf && config.vf_nl_en) mlx5_nl_mac_addr_sync(eth_dev); priv->tcf_context =3D mlx5_flow_tcf_context_create(); if (!priv->tcf_context) { @@ -1345,7 +1327,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_u= nused, { struct ibv_device **ibv_list; unsigned int n =3D 0; - int vf; + struct mlx5_dev_config dev_config; int ret; =20 assert(pci_drv =3D=3D &mlx5_driver); @@ -1443,21 +1425,39 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte= _unused, */ if (n) qsort(list, n, sizeof(*list), mlx5_dev_spawn_data_cmp); + /* Default configuration. */ + dev_config =3D (struct mlx5_dev_config){ + .mps =3D MLX5_ARG_UNSET, + .tx_vec_en =3D 1, + .rx_vec_en =3D 1, + .txq_inline =3D MLX5_ARG_UNSET, + .txqs_inline =3D MLX5_ARG_UNSET, + .inline_max_packet_sz =3D MLX5_ARG_UNSET, + .vf_nl_en =3D 1, + .mprq =3D { + .enabled =3D 0, /* Disabled by default. */ + .stride_num_n =3D MLX5_MPRQ_STRIDE_NUM_N, + .max_memcpy_len =3D MLX5_MPRQ_MEMCPY_DEFAULT_LEN, + .min_rxqs_num =3D MLX5_MPRQ_MIN_RXQS, + }, + }; + /* Device speicific configuration. */ switch (pci_dev->id.device_id) { case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF: case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF: case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF: case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF: - vf =3D 1; + dev_config.vf =3D 1; break; default: - vf =3D 0; + break; } for (i =3D 0; i !=3D n; ++i) { uint32_t restore; =20 - list[i].eth_dev =3D mlx5_dev_spawn - (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); + list[i].eth_dev =3D mlx5_dev_spawn(&pci_dev->device, + list[i].ibv_dev, dev_config, + &list[i].info); if (!list[i].eth_dev) { if (rte_errno !=3D EBUSY && rte_errno !=3D EEXIST) break; --=20 2.11.0