From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9CopbLizCH9IrMdu6wuv0IY756NhTEkQZ6TcrFsB1yc=; b=ozvAUEIOpEk1Oi0qQL3o7slylxE4cJkCvCra1DMqU+NaBoLjKcgpDt9wCop/gaKoi5u3OV2VvrBNhfws28TE32PWeiz/6Z9DV+R6nAlT0DVMZT1GfosqBj/yzH/WvBtzOfYKRW084F2cbAbVqB6OtqOjjFZY6Vfkc+Tq2s7QXY8= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3947.eurprd05.prod.outlook.com (52.134.71.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.19; Thu, 1 Nov 2018 17:20:31 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.030; Thu, 1 Nov 2018 17:20:31 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh Thread-Topic: [PATCH v3 1/2] net/mlx5: move device spawn configuration to probing Thread-Index: AQHUcgcxJM26Sntf9UmhtNAi7GsK4g== 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> In-Reply-To: <20181101172019.26195-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR05CA0023.namprd05.prod.outlook.com (2603:10b6:a03:c0::36) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3947; 6:9rdmseweZr1pTYWPZHuNlV+t3ERD5zxvOocswmmOPvJsNZvE8bXK1u2F33LzpbyWuQy7hGY/QHnOKxH3QSdxV11n9ZciTzZbKEgPHSSP6um91wr0rdMU/xxMi/nMXeJHK0Aej7COuIjGG1/BxRSx90nbDlIYbCu3ktp6nA12WMMPlaqpNLn6OGY7MBLFFQdiCgUE1XOloC0uml/J9fn4vdHm03OZQyOOXMRQNdCrlNx3s8y/rW9YmDQ6u6Nd976qqzsiRNka/YqCtMsFKMxeeYMEyzxGotPR87uZVzMMCnTmr/AWi98nCR6SVcA7Jxi3dQtwxZZBF9taTkvsWhAT8mztbdjR7nyUoslX8tyV+q1BNTxSwcTUNbo8yvm+hANYYfcn2WfVmGHjIrcOZ9lFlMs5p5dKAZCFWeCnEVh7d4O8JFwYlRFGsbz36NJS0obxOwKSM79AtU9HuNBdzVo5uQ==; 5:7nVw33/wF1hdTVe0rywWPeA4AxE3cwpCo0IzPzD/jC1Q1B4CV0l9mG6pQhZgtpX1M0aBOmdi3PIhjNuYTZgoFF0wp4BwOgHEc2qHu+Q4ecjyolbEhvYwp0Udev7bCLEULvuD7UgN3TkJ31lzFedz1YwZvVMxzbMx7smcu689MUg=; 7:8slldLiONOmCvwHdrsgj/BRTapPkhUooAZV7A1XCVRpY9HWM6dg58ZibVzUKosHgyJaC4iBY8RELWEfAb72gZnwNBleXes8XZabYLl2Q2MBq648CCvQOrRTcOuDaArkWPfzyET5/NxgUHwyZg17bFg== x-ms-office365-filtering-correlation-id: f4ba5baa-6284-43a2-318f-08d6401e5355 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3947; x-ms-traffictypediagnostic: DB3PR0502MB3947: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3947; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3947; x-forefront-prvs: 0843C17679 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(376002)(346002)(396003)(136003)(366004)(39860400002)(199004)(189003)(14444005)(81166006)(2900100001)(81156014)(68736007)(4326008)(5250100002)(105586002)(106356001)(86362001)(8936002)(8676002)(71200400001)(305945005)(25786009)(256004)(7736002)(97736004)(14454004)(99286004)(478600001)(6862004)(5660300001)(54906003)(107886003)(6436002)(36756003)(52116002)(71190400001)(486006)(66066001)(6636002)(26005)(2616005)(476003)(2906002)(446003)(53936002)(6116002)(11346002)(6486002)(102836004)(186003)(3846002)(1076002)(6512007)(6506007)(386003)(76176011)(316002)(37006003)(309714004)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3947; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: tNihOrrOD6wo3gnhaA4+fEAhuKUYEmuOcJ67hUu6KlNboSm0RlwBXia9yMVFU5ZL23aOqryP72Wd2DFdX4PVNz4s7XuEZpBAu3yVZtMFhDAYvhTBiL0g5Cv8LsQT1MDRmaNbY/2tlSFUyzwyTOSLgbKe5oOBC+XykllaNVzDAT1MhPYQSP0b/WJy4cRjM0FL+hcIFnQnOXHkto5PfNcIuxQx5TSHTZn9w7jt74K5RQp7KC6Nc22xjvyYiwvsiLHL5nBPIwI0qHyK6Q4mA57KPn/OLMVuSvAB7ZgcVN4lD9gUVe+iLj/ccuywTr0tUeP/wiPP/AS7LKUBQFOBOjNCLvMQMf1InjMNWCfvjI7wjKE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4ba5baa-6284-43a2-318f-08d6401e5355 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2018 17:20:31.5765 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3947 Subject: [dpdk-dev] [PATCH v3 1/2] net/mlx5: move device spawn configuration to probing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2018 17:20:33 -0000 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