From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0071.outbound.protection.outlook.com [104.47.42.71]) by dpdk.org (Postfix) with ESMTP id DBA75FA39 for ; Sun, 4 Dec 2016 13:44:11 +0100 (CET) Received: from CY4PR03CA0016.namprd03.prod.outlook.com (10.168.162.26) by MWHPR03MB2479.namprd03.prod.outlook.com (10.169.200.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Sun, 4 Dec 2016 12:44:09 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::182) by CY4PR03CA0016.outlook.office365.com (2603:10b6:903:33::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13 via Frontend Transport; Sun, 4 Dec 2016 12:44:09 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Sun, 4 Dec 2016 12:44:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:718; Count:10 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uB4ChXbF032240; Sun, 4 Dec 2016 05:44:06 -0700 From: Hemant Agrawal To: CC: , , , Hemant Agrawal Date: Sun, 4 Dec 2016 23:47:07 +0530 Message-ID: <1480875447-23680-13-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131253290493972430; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(336004)(199003)(189002)(189998001)(81166006)(81156014)(2906002)(8936002)(86362001)(4326007)(50466002)(50986999)(48376002)(47776003)(76176999)(105606002)(8676002)(2351001)(39450400002)(68736007)(39400400001)(39380400001)(39410400001)(92566002)(106466001)(38730400001)(104016004)(77096006)(5660300001)(6916009)(2950100002)(110136003)(356003)(36756003)(8666005)(626004)(305945005)(33646002)(7846002)(5003940100001)(50226002)(97736004)(85426001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2479; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:uCadXZR4SAJ70C20PdfToEudWV9onciTUGOLh++F+lQS2AxNF2j2JOa7sdX4R71Qg2kbx5hNGMEf6/TPnwJwUwAoND8XR+YCXuO+wkE2Ak2PzJUhTHP1KO8XwikjXDJM6XB8BMsf8wZ+mVj2PJLfRasV8GakjLDIh/cTizVUigaoEG0Mj1oyZIF2+Y0lkY7fSOlkQbQC5fmsjJieVENs0ldUO77JwNxFJj8B0ajmtKtH/aqJETKrrroHyDCLziABmFzquONEV/X2fWQpCZICfyfoLjKnfX0y8izPjiolvtTjVFUOI7X3ULb4GnC6wYp3P0GFcWRdS76TwGWuRVJ9qP+00bDA2jt+2BNuK4/v3BxqSD9lPyLM/HOMpcd4CXcwtne6FWyWaoyfi72NK0Bx0WKBWOnJkcZtCPkdx6mN7HcOdd4abwDtv4X5X6sfISFvlc/qQCsLb6ZNITUwgnMRbq5am9tGyqiy/YsoVOJOavFxAG7sSAJ68+F3CCug0bQW+N4bRkZTSciseQFcUzqoLmSgy8ope1qSNLwU8B3DUi3uY5DL3qaImFon6kl2FjRy2RxSq+iF7vmZsvllJ4ogq0sh269BhSE18f6LHc7UR6S6dsnQtpqEroLnImuHkYASMKwRO8LzZ1yTx+StNARb/HC0BaK54KEMSrkJ6tBK8veF8b9wVLD7a+fDmwvI2zpTIW8Th2lxwSAAncRtkT8dNixuPPaeSDCKx5upGz5y7S6ZBV4pja0nChGR8EHD8zQIBzPCvxJrT+pmiflqbwWKjA== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2d4ad2d7-5d62-4d43-8fce-08d41c433df5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR03MB2479; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2479; 3:YPgfY6QL3UF2opJjQSHq5OixD3Y6jr7nsjGCD+RoVBllrWzNE8ZtVt2iXAJizLrt2nMyKiZST1JeiQYEpzq5t9WdfHTgtRsY9ml5kPfA25KSLPDquxBRk88YV2b5idvjgTbNjUsp+lXf+H9RW0abMZRbPfO3tYIDDOKRX5+lB4pk1RpIEVPwN5Pwq1cDVgoiwKnPHxiSpbtGp9FxwhrKweC5pWiS/LoOJq9BldUb0SDI3IIA9K9BbbNSOqxnvMEBN14khbgCMzq76uutAXI2PSutw25vvLDNs4CKlTjcoUu3mQG7C/phxKhSo57KlYrlhdL8igNb82A6sKPnLIVvHnUfwmFnc2rv60tsbvxxF9I6Q1ExXP9QUWCJcW1ATwU1; 25:QyEfVYkCNDkXDDr6FLgkfVD8Ri/mfBSlxBpcMX6Ndv1qjhmy3CQQfEdqecjQsPi+uRcPcx6CYMQAavBma1dzSnzCFDQaJxacn7mdPVoznsBlPOlJfEGom4tQ65P+otRrWSs1TpOFGqP1uXM17ZSMoWWAmxRDAPVhWmGpNS4SBmfqfWecT7T/kcNXFI2Qm84/vwEv3GssNYTr/Bq9eFZWenUWyZWOfsNxee4l+tQdekePaYaCa+Je0PLjFIKi/nV5XTk70t9Xr2PNRfpHEv4920vQWO4cH8XvuFE35W0ZwjxMZYNB2xairoKeOe9saZmgjUeRw3KG93rnKLYOP7Shrk8opojdDjLkyWm//J18rD1gprmXcggCL1yjehynGIyDy3N9wBCSeDhKffpZkPra8xhTGm53IW1N5JWYz8dOu3ZhkqvYZpEbo95k4+vnNdK+6GF5cYsE4nKIm4DfkQF1+g== X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2479; 31:/XtArR6vulakUQHsr2zIGZYUI63Cb5EVD5iLun70Z0mzju8nGjtYlVdsnHKyLT22oBdJJ30fcCpqLI09NTgx/Vf2C8VH9o6qCxIP9eYMZdFdlGXoRMt2LgK9STdsr/9BzWebhNmtXpUxHRpKK1aO0pB+RIIFbPH3uDs36g8KBwq+eSJ+GivloU6Bg2Y2T6PI2M54JFW5ypCjYdpDYHflpsQ9OlwNmR4ULYoHmvf+JdkeEh+gl08jeXdy6jHeJGxCZFA+26F7uCb5W1rUBk8Kynjzc+2xlkKet6DTLzHlpyo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13024025)(13023025)(13018025)(13017025)(13015025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123563025)(20161123556025)(20161123561025)(20161123559025); SRVR:MWHPR03MB2479; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2479; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2479; 4:ZfeL7lvlblcE8Ctr49KCHhUoDfEmks+JBP4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5H2UztGYycWjEnAr0s1tXV2STliPID83koRhNoV2AQ+XhxSOhywPYlvZjK0DewAVdtNYaRFNBO1mOOrNaEbxr03SutPR816SxMkkaETz9UbKXlGWK4awDcZ1upjV8RVrgmJeKibjgrSmbWW0sE+4ylXvNvAZu+6soIDPjC9wqhTLPnbctn6U9VFxXDlwotG6KPzKveKDp9tFR7lUo78t/zHESqyPBBcd5ebsr2JDdxUAKV3VP3RoJwbwNCJxDuAajP15AecaqVIK0MC00GFBNQLVGUsQxPiP7vXuM8xdoohX3/M7Kb3vslYlwwGOE3B+wS/+Zv90cX5rGQmvziUDAUKeVLmlotzEm0oLm5WauOzU7qTjkOs9r3spgeP/HkGeff2uL0gGWFl3pmJmM6lm0/9Cyg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 12:44:09.2256 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2479 Subject: [dpdk-dev] [PATCH 12/32] net/dpaa2: vfio scan for net and sec device 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: Sun, 04 Dec 2016 12:44:12 -0000 Signed-off-by: Hemant Agrawal --- drivers/net/dpaa2/dpaa2_vfio.c | 68 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_vfio.c b/drivers/net/dpaa2/dpaa2_vfio.c index e7e33d3..58c77c9 100644 --- a/drivers/net/dpaa2/dpaa2_vfio.c +++ b/drivers/net/dpaa2/dpaa2_vfio.c @@ -188,15 +188,58 @@ static int64_t vfio_map_mcp_obj(struct dpaa2_vfio_group *group, char *mcp_obj) return v_addr; } +static inline int +dpaa2_compare_dpaa2_dev(const struct rte_dpaa2_device *dev, + const struct rte_dpaa2_device *dev2) +{ + /*not the same family device */ + if (dev->dev_type != dev2->dev_type) + return -1; + + if (dev->object_id == dev2->object_id) + return 0; + else + return 1; +} + +static void +dpaa2_bus_add_device(struct rte_bus *bus, struct rte_dpaa2_device *dev) +{ + /* device is valid, add in list (sorted) */ + if (TAILQ_EMPTY(&bus->device_list)) { + rte_eal_device_insert(&dev->device); + rte_eal_bus_add_device(bus, &dev->device); + } else { + struct rte_dpaa2_device *dev2; + struct rte_device *r_dev2; + int ret; + + TAILQ_FOREACH(r_dev2, &bus->device_list, next) { + dev2 = container_of(r_dev2, struct rte_dpaa2_device, + device); + ret = dpaa2_compare_dpaa2_dev(dev, dev2); + if (ret <= 0) + continue; + + rte_eal_bus_insert_device(bus, &dev2->device, + &dev->device); + rte_eal_device_insert(&dev->device); + return; + } + rte_eal_device_insert(&dev->device); + rte_eal_bus_add_device(bus, &dev->device); + } +} + /* Following function shall fetch total available list of MC devices * from VFIO container & populate private list of devices and other * data structures */ -int dpaa2_vfio_process_group(struct rte_bus *bus __rte_unused) +int dpaa2_vfio_process_group(struct rte_bus *bus) { struct dpaa2_vfio_device *vdev; struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; - char *temp_obj, *object_type __rte_unused, *mcp_obj, *dev_name; + char *temp_obj, *object_type, *mcp_obj, *dev_name; int32_t object_id, i, dev_fd; DIR *d; struct dirent *dir; @@ -327,6 +370,25 @@ int dpaa2_vfio_process_group(struct rte_bus *bus __rte_unused) DPAA2_VFIO_LOG(ERR, "DPAA2 VFIO_DEVICE_GET_INFO fail"); goto FAILURE; } + if (!strcmp(object_type, "dpni") || + !strcmp(object_type, "dpseci")) { + struct rte_dpaa2_device *dev; + + dev = malloc(sizeof(struct rte_dpaa2_device)); + if (dev == NULL) + return -1; + + memset(dev, 0, sizeof(*dev)); + /* store hw_id of dpni/dpseci device */ + dev->object_id = object_id; + dev->dev_type = (strcmp(object_type, "dpseci")) ? + DPAA2_MC_DPNI_DEVID : DPAA2_MC_DPSECI_DEVID; + + RTE_LOG(INFO, PMD, "DPAA2: Added [%s-%d]\n", + object_type, object_id); + + dpaa2_bus_add_device(bus, dev); + } } closedir(d); @@ -367,7 +429,7 @@ int dpaa2_vfio_setup_group(void) /* Check whether fsl-mc container exists or not */ DPAA2_VFIO_LOG(DEBUG, " container device path = %s", path); if (stat(path, &st) < 0) { - DPAA2_VFIO_LOG(ERR, "vfio: Error (%d) getting FSL-MC device (%s)", + DPAA2_VFIO_LOG(ERR, "vfio: Error (%d) getting FSL-MC dev (%s)", errno, path); return -errno; } -- 1.9.1