From nobody Tue Dec 16 06:52:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530193832955369.3502095372495; Thu, 28 Jun 2018 06:50:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28E023082153; Thu, 28 Jun 2018 13:50:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C55098A8AE; Thu, 28 Jun 2018 13:50:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 667CB18037F0; Thu, 28 Jun 2018 13:50:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5SDOCdK021039 for ; Thu, 28 Jun 2018 09:24:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62F2D308BDB8; Thu, 28 Jun 2018 13:24:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55DB4308BDB9 for ; Thu, 28 Jun 2018 13:24:06 +0000 (UTC) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0056.outbound.protection.outlook.com [104.47.32.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B34C356DF for ; Thu, 28 Jun 2018 13:24:04 +0000 (UTC) Received: from hyd1jrana-dt.caveonetworks.com (115.113.156.2) by CY4PR0701MB3747.namprd07.prod.outlook.com (2603:10b6:910:94::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.23; Thu, 28 Jun 2018 13:24:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fYiWJRln54UL0au3i8mFnCzOM1ciQtIUck6kH5FdEGo=; b=OVwKW9pL1bhRCV3RyA4KdmE/3aIDTJAOz4kxovBzBZ0rEN4OHq10BjgqQZzE7bsxJPjAJ0D1baBRMyYr7ZTCGSs+oGV2XTnhmfKvtmrT4c2HrWscdtukltIhUkrLf5m/rggtK48g/PRG41I5+3w/AbRy9YuKBCdcZ0of6FMJLsM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=JaiSingh.Rana@cavium.com; From: Jai Singh Rana To: libvir-list@redhat.com Date: Thu, 28 Jun 2018 18:52:34 +0530 Message-Id: <20180628132237.11811-4-JaiSingh.Rana@cavium.com> In-Reply-To: <20180628132237.11811-1-JaiSingh.Rana@cavium.com> References: <20180628132237.11811-1-JaiSingh.Rana@cavium.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: MA1PR0101CA0066.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::28) To CY4PR0701MB3747.namprd07.prod.outlook.com (2603:10b6:910:94::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31815f10-3284-4dc9-21e3-08d5dcfa6aaf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3747; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3747; 3:TQFdTV5hPImpWMcFQKoXZLGCcD/rqSvgFI8iHyOlOe1bq/Qsr11DCfBgVDw0ygzdDBoQ3Kh8OfNO+0k+zrJhavmEKSJ4o8EI3RFkhBcmGLJOr44TCs4MmiOFRF7zPpG2+j0mtGYztuzvJW8bJ25LjPd/1VQR9kIZ5ylxKnMxwxSRPpqbp+k2EwODdN9TOdNiQd3YgLENpqBSGUSgmGMt1aeoaAMY0P7wmsKmR1jFMki/zYaEEM/0kRt7YopDpfXv; 25:d/8D04iYAnKpq4HASX276ApMBwNupl1h/5Lskqr1rfBtSyhL6q6DFBs8c/3f2voYs7OPcHATeWoMnefuiQDLGsVpnuBErjvsVRnoZskn+BdcXD6gkv22uAd4u2I8pEM0aPYCY3ri+OC56/LSC0tBw0FqJ4U8xpZdVd6Lv1Vl4P16ou4o0f9p6g5zte7xNwLU1L1PSJnX+dGJP2CmwRUL/Qyz1mws7V1bBPXYyj2E8XvIsRUuzxPVMYy5JkipvB05AyaOi0SaPQv3ytBzMscRtYv058Ra8G5Ef/S+E4zyUWsPtGUq31Q1T5bu/ASAGMVNba1fxTcllzVx+BsAJO+huA==; 31:Zt4BH3/NMLmOcMrQewDRHktfIcpo8nbgSWHQ2ADXqHxNFoTzvGDb6K54J9Ej+0pBblxAKH0soJ8IE1LQj2hVp43qtKaq/KkmOLqG65x6PjZzNuL1cce2rJ8IJirWp9HnuA/J/1dRc6IGi4lR2cDus99YYaleaNXFAFjqxFqWJuOrr0Sltc5iaxZUxunr9hUfELWgua1jFNOMLrusY6X6omIIywbWwlAw1j9sqjDPZ4s= X-MS-TrafficTypeDiagnostic: CY4PR0701MB3747: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3747; 20:1/TeZZWqy859LODFdpW2J9tEzzFNCNsJfhaoUgu7wM7iaf6zrp68rVFEbmbkfGR9cWn/UjxG1zy6mJDbfEtasqq1WL8gV0yZQfJuC8EqKEKMyw0U65iv30U6ehOVKAFMhoj7H0Xn8MCaPrpgXS8yOAx1ZJRIw4TK4eBn3GP6yL20b4j2N4Dk1NjyDavvku4qOjfO8SomhYUJRjBYTN0eopf9oY4ZVI75CR4K6G9CNb0+cesMxdeIdbusIE+1fdqRK2ZCrLxtEfz3hHXefLE/NAxZVLGWFJhVY6BdGIUwGJYM+/um08HFK/8/e8m/YsoQZ0eWPp8QBWn7TAMSq8p7dpDpIAhAQ6o1yeHvtgEhBfWfTT+DykK7T1f7QRWXdB8QsKTCgQ0/Pg/v4f33hutSp8UxlJqTc8CxfIfge57seDb+ZrZ+5Y0fubXWKtqD9Gx6PmXC1s4vbF/ecJQeCx+HdNMxqL1XgZXR0ZsawKK49DGIP6UdCFu6/xhSx+HOP12v; 4:cVEXc5SFzXE0yPgrpI0RNDhDH9ir/wjjOmsb372wEF4ECYFtuozBcaAUsP/uHJZtQ9PeCIOOBTYhttBjpSZNdNG0ocDV4SVMcjDN6NKvQz0bYj1jNeWHI554CXkpaRHggawDB1+sh0l4V+3OCbzJaIcaDxyDCtifpC3tiySPV9Gfxmchiad/w6EJYPyVc4H21wESvfenifdHI3iSpLUv9T0x79SoxPmCx3stnrVDanVohezcPi04+tMxUPOUjhQMUiaJ2RapYnug5JovLxfg0TzlBvYtlIUaTzRYZZrd8F995in+gAeI6Ua/w2msDoETqYHwVGebqrU2RPBa4pF5G3KGBHAZ6GkxVMHpJO3wLxA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:CY4PR0701MB3747; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3747; X-Forefront-PRVS: 0717E25089 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(136003)(366004)(396003)(39860400002)(189003)(199004)(26005)(16526019)(6506007)(446003)(386003)(5660300001)(10710500007)(39060400002)(316002)(486006)(50226002)(3846002)(186003)(2351001)(11346002)(76176011)(51416003)(52116002)(6116002)(6512007)(25786009)(6666003)(6916009)(81166006)(2906002)(2420400007)(6306002)(81156014)(16586007)(8676002)(86362001)(305945005)(55236004)(7736002)(68736007)(14444005)(476003)(956004)(7110500001)(15650500001)(2616005)(4326008)(8936002)(53936002)(105586002)(106356001)(107886003)(6486002)(36756003)(2361001)(97736004)(72206003)(478600001)(66066001)(48376002)(69596002)(1076002)(53416004)(50466002)(47776003)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3747; H:hyd1jrana-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3747; 23:3mnnxc4Z25DV2ZP6oPRbVzw9NHtUnGIVEgcruhu?= =?us-ascii?Q?gxHkcsgQzfVOSrmcZQMMKWPhHyt4CFIRs714ALfBLWR+f2mU6EZSJhoTJUC4?= =?us-ascii?Q?yzX8fOKZABOZ7aaCkOGp+ktF3A52Lvw8OHNePomCf0Fm23GiMfqAELU1eUfX?= =?us-ascii?Q?u8Dzoqp3aBJNw6tlFdH6UR2IZH53ZYWrkJLOa5LS7Zf4qghVzkT4ka6KsDFQ?= =?us-ascii?Q?HtwUjVSPrmZo3mfakpO8IaTXYANCJmMoTdcvtn1UvKATdfkTnrj5YKIvk5uJ?= =?us-ascii?Q?5gxOnpwJtlYBtEXT3PGJJvvRy1a3vNY16C5GMzz6XVnl17tZ+XJ2cUMNZS1U?= =?us-ascii?Q?F3X9vBH7w3qE9hXmZ4RWKvCYoBJ2jmZSy5PX0ExYveCb451ivclFhxBm0vQj?= =?us-ascii?Q?HKjboiF/bfA0yZ96v+9Z2XZfLcSbbyYwl5i4V/vtazjAg0l9L7QvH48n/H1I?= =?us-ascii?Q?UKSObiCedZPh1LURD+SEA9xbQRuluZeY7/lt1K6X2tEwUCZdHcELLI9zVa3t?= =?us-ascii?Q?7NR9GP9Ycwgb710RwNzATtPgJWsaFFQH30E0X5Aquue1wiMDL5JaHflbfF19?= =?us-ascii?Q?6DbqSIwFXgq060gJEmKCNT5UU8897eMoe3h2p8eaWJbRi1ZUYd8lsoRskWe5?= =?us-ascii?Q?621VYi1gx0Lsw59LQ8k616ZwoqIpVEtX25KxipoxBvYMkIpqOtbx6iET/fQT?= =?us-ascii?Q?1gg3wR1+N4tEWPYZpoA4hpONlawq8OfE1TrQ7k0ROTC9gAgQnqX+9lABx4A0?= =?us-ascii?Q?x/Qkdq+a7glnbR19kxPiS1OvTw83WevfDLegGF010rWI6kL5rUQolNfeJ/Fe?= =?us-ascii?Q?PqFoEuIKY6pKFmGRRcImu8TS/amLMlKF4DKL+4rQncK0KxfsJ+Q1jKhmBIxe?= =?us-ascii?Q?KgsOKjxXupVtbBnXFjueMssOwjSDyiKUp5GYgWojrk3SicP1/pQIbjETSFck?= =?us-ascii?Q?Y6GX8X67zAPRrMtOw2hqzHZa+Y6SdQGUFb7jQ803JChuxQdEbgAUz4kn4GOA?= =?us-ascii?Q?xOc8DdDKGU8Tu3bm+8jTcOQl5h9VrpkpB2KtszTsSs/J2BMgNYgFBJK5YMFm?= =?us-ascii?Q?6yk6WDdf25zIJZvS/+9/rQvXTgzkNQPpMLt9G/Yq2o5ySTDqKaTzGoRgQHBT?= =?us-ascii?Q?wyjcV1hqg7SISt1CAzlwImaawNu9jEFy968Ej/9yXOIjdiy2oAOZ9lR+5A1D?= =?us-ascii?Q?TNvO7hmE/S+IzTqluQEtyCSbIeupq6g3GQzP6UxNAA3dfvViM8kZxkW74WOW?= =?us-ascii?Q?LFy1WqicqxIIhm4omBMzJbd3E3Gga9PMv6+OXe0oKe9f0BVNNyOhaKx9Nvz3?= =?us-ascii?Q?92J2SFQMZmhQwiGuv4uT6ZQckyAuIe4fj0IE5Q03C+tnxxIm+aoyjJSmnaxI?= =?us-ascii?Q?yduluDMXhyHuflUuX7s+v4Drax9iqfk4zdbDo3Eugr53Dlj3NUyAR3zAfCgj?= =?us-ascii?Q?PLF76UqEyTNytqJ5wtkiGtWN4aUrboQ/aA9NbybaY5ULq68Ps7RyxAmapYTc?= =?us-ascii?Q?1fkh4a6UetDifygPjs01ekz/TB+7roNHJSXboN664jj9QA1mJpR65nORE?= X-Microsoft-Antispam-Message-Info: SfHUrq496l4u9ZE99p2k2uRsuEiZ8IPu+35iFoXORWKyEIzSKjLcCrtJlw475SR/1pIvIfSxHJTUqLrepKNs8WFENbjLetnLkC+4TY/OLfkIvahGRv8H5IOU+Nomi52/jvRc2mdSVQFkaNM5v/Q01o2haCJrBDfqy0sQoi8//t2SCzHjGfIR0i+eoHFBEZDSV7Fq0En6bEa+7ngzBjVLxIsv9ObtlMwBJ9IF3TDurP0Kfr2xLYawPmzPJsX3qSkHaJGtEkpD0BLDWtUikJlnHgmzfj4vMSkAJcawctLEIi5Pwqd+NaDTxs2ihUOU1moSCfkb9zxCvRFUkDl0BlhYJ2VRjmnp02hKhIELupGNqzc= X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3747; 6:qz+m22jMadfegmDlgMdFa/YAaVWmP8aNE3T/x/nOah5Aiq432SKZ5UrMQmbRudwIjGKvC+Wkfo8366E2SbtX3hnRqnUOy3vFuQaIiZQCLs1kPfwJnBy8pe0ykoJoB3JrNQpjoQCI68gKzLgVgKm0QV+Xg18ijO0+9kWLRkGc7RtTGMLYZeS1jUB0qMGLtGN4v2VqjO5ugSbcMmMB0DlZRcwvCj1xTcu6aT7/j6fwNbuHPqkwgm+waUnTtzcjS/SkrCopLwEf9cb+1pyZuRWHNuLK74zDGbHfl+em7PQyTdg9+v4OZ5yHni3+8Hvu+Ynq/q7gpPlZzaO9T4YAg1nqgmvHw8HXK9bk4nQXxjLVGOZX7lF1mS3UaxmtRtpX8JMZNDuC3I5SV/Fc1LPV2/6AeGJrbGrDa3mnp0p37qTiugWw6JuvfdcBZHPYlAAojINA/xgDiddZ9NcRxQ26FpFJJA==; 5:/8EewpzTADF/ClH4GmvOEFRA1LYUiDtNAyHHumpl5hpapTvqbGCSwRyEFUUxePS8NpShLqTnH8dZx3EOYz6Jsg4Gb4hnX5MHiV+ExDChcfnhIRB1EpwCLG2VN8mxKzWJQgk5XLQlAzVC9CqQ6ohRm0zUM/FIvTtX0n1QIS+Mn+g=; 24:auEntALvvDHyiTEvVgmD8QZPMo7H+6MC62bM9vcBLZaEA4GHpDgEBwCt+nhT13r/qULegqyrNeNF2JytZWMtSuzffoFHwKe0qkKyiGkQSFc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3747; 7:IQQUZH4JnQ2jQDu1qDFqQOfcy3p8ubVUblsiZyiaZdGVF3S48mEe6j6XGg0kOSaKXoApo9ygqAZH0E72WrfQFucxZYQTACZmSaahab0bXSgSddrcIpRFjlFjzBDcuUgUh1fi0U2Mx52vRB16yMx2PpKhjVwKob3EpQvVa1NnX89iG10T/tyoENC32UwgIxmkAjRh7/037pS+w8rTWWeG3xgBEjOzMzu0tJ0VQW7RRwWldJhsjYVs4wwMy41PV3dO X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2018 13:24:01.9300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31815f10-3284-4dc9-21e3-08d5dcfa6aaf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3747 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 28 Jun 2018 13:24:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 28 Jun 2018 13:24:04 +0000 (UTC) for IP:'104.47.32.56' DOMAIN:'mail-sn1nam01on0056.outbound.protection.outlook.com' HELO:'NAM01-SN1-obe.outbound.protection.outlook.com' FROM:'JaiSingh.Rana@cavium.com' RCPT:'' X-RedHat-Spam-Score: -0.022 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_DKIMWL_WL_MED) 104.47.32.56 mail-sn1nam01on0056.outbound.protection.outlook.com 104.47.32.56 mail-sn1nam01on0056.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 28 Jun 2018 09:50:20 -0400 Cc: jai.rana@gmail.com, Jai Singh Rana Subject: [libvirt] [PATCH v4 3/6] util: Add helper APIs to get/verify VF Representor name X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 28 Jun 2018 13:50:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Introduce new APIs virNetdevHostdevGetVFRIfName and virNetdevHostdevCheckVFRIfName to fetch/verify VF Representor name according to switch model for network devices in linux. Switchdev VF representor interface name on host is queried based on Bus:Device:Function information of pci SR-IOV device in Domain's hostdev def and subsequently verifying the required net sysfs directory and file entries of VF representor. Signed-off-by: Jai Singh Rana --- po/POTFILES | 1 + src/libvirt_private.syms | 7 ++ src/util/Makefile.inc.am | 2 + src/util/virhostdev.c | 2 +- src/util/virhostdev.h | 8 ++ src/util/virnetdevhostdev.c | 300 ++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virnetdevhostdev.h | 34 +++++ 7 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 src/util/virnetdevhostdev.c create mode 100644 src/util/virnetdevhostdev.h diff --git a/po/POTFILES b/po/POTFILES index be2874487c..3f8731f342 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -235,6 +235,7 @@ src/util/virmdev.c src/util/virnetdev.c src/util/virnetdevbandwidth.c src/util/virnetdevbridge.c +src/util/virnetdevhostdev.c src/util/virnetdevip.c src/util/virnetdevmacvlan.c src/util/virnetdevmidonet.c diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0ba8cd2a14..5aa8f7ed64 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1968,6 +1968,7 @@ virHostdevFindUSBDevice; virHostdevIsMdevDevice; virHostdevIsSCSIDevice; virHostdevManagerGetDefault; +virHostdevNetDevice; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; virHostdevPCINodeDeviceReset; @@ -2356,6 +2357,12 @@ virNetDevBridgeSetSTPDelay; virNetDevBridgeSetVlanFiltering; =20 =20 +# util/virnetdevhostdev.h +virNetdevHostdevCheckVFRIfName; +virNetdevHostdevGetVFRIfName; +virNetdevHostdevVFRIfStats; + + # util/virnetdevip.h virNetDevIPAddrAdd; virNetDevIPAddrDel; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index a22265606c..0846a8e025 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -108,6 +108,8 @@ UTIL_SOURCES =3D \ util/virnetdevbandwidth.h \ util/virnetdevbridge.c \ util/virnetdevbridge.h \ + util/virnetdevhostdev.c \ + util/virnetdevhostdev.h \ util/virnetdevip.c \ util/virnetdevip.h \ util/virnetdevmacvlan.c \ diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index f4bd19df64..c6ee725860 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -303,7 +303,7 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr host= dev) } =20 =20 -static int +int virHostdevNetDevice(virDomainHostdevDefPtr hostdev, int pfNetDevIdx, char **linkdev, diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 8f77c00221..7412a20aa9 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -60,6 +60,14 @@ struct _virHostdevManager { }; =20 virHostdevManagerPtr virHostdevManagerGetDefault(void); + +int +virHostdevNetDevice(virDomainHostdevDefPtr hostdev, + int pfNetDevIdx, + char **linkdev, + int *vf) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); + int virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr, const char *drv_name, diff --git a/src/util/virnetdevhostdev.c b/src/util/virnetdevhostdev.c new file mode 100644 index 0000000000..2d3e46c81f --- /dev/null +++ b/src/util/virnetdevhostdev.c @@ -0,0 +1,300 @@ +/* + * virnetdevhostdev.c: utilities to get/verify Switchdev VF Representor + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include +#include +#include +#include + +#include "virhostdev.h" +#include "virnetdev.h" +#include "virnetdevhostdev.h" +#include "viralloc.h" +#include "virstring.h" +#include "virfile.h" +#include "virerror.h" +#include "virlog.h" +#include "c-ctype.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("util.netdevhostdev"); + +#ifndef IFNAMSIZ +# define IFNAMSIZ 16 +#endif + +#define IFSWITCHIDSIZ 20 + +#ifdef __linux__ +/** + * virNetdevHostdevNetSysfsPath + * + * @pf_name: netdev name of the physical function (PF) + * @vf: virtual function (VF) number for the device of interest + * @vf_ifname: name of the VF representor interface + * + * Finds the VF representor name of VF# @vf of SRIOV PF @pfname, + * and puts it in @vf_ifname. The caller must free @vf_ifname + * when it's finished with it + * + * Returns 1 on success, 0 for no switchdev support for @pfname device + */ +static int +virNetdevHostdevNetSysfsPath(char *pf_name, + int vf, + char **vf_ifname) +{ + size_t i; + char *pf_switch_id =3D NULL; + char *pf_switch_id_file =3D NULL; + char *pf_subsystem_device_file =3D NULL; + char *pf_subsystem_device_switch_id =3D NULL; + char *pf_subsystem_device_port_name_file =3D NULL; + char *pf_subsystem_dir =3D NULL; + char *vf_rep_ifname =3D NULL; + int vf_rep_num; + const char *vf_num_str; + DIR *dirp =3D NULL; + struct dirent *dp; + int ret =3D 0; + + if (virAsprintf(&pf_switch_id_file, SYSFS_NET_DIR "%s/phys_switch_id", + pf_name) < 0) + goto cleanup; + + if (!virFileExists(pf_switch_id_file)) + goto cleanup; + + /* If file exists, failure to read or if it's an empty file just means + * that driver doesn't support phys_switch_id, therefore ignoring the = error + * from virFileReadAllQuiet(). + */ + if (virFileReadAllQuiet(pf_switch_id_file, IFSWITCHIDSIZ, + &pf_switch_id) <=3D 0) + goto cleanup; + + if (virAsprintf(&pf_subsystem_dir, SYSFS_NET_DIR "%s/subsystem", + pf_name) < 0) + goto cleanup; + + if (virDirOpen(&dirp, pf_subsystem_dir) < 0) + goto cleanup; + + /* Iterate over the PFs subsystem devices to find entry with matching + * switch_id with that of PF. + */ + while (virDirRead(dirp, &dp, pf_subsystem_dir) > 0) { + if (STREQ(dp->d_name, pf_name)) + continue; + + VIR_FREE(pf_subsystem_device_file); + if (virAsprintf(&pf_subsystem_device_file, "%s/%s/phys_switch_id", + pf_subsystem_dir, dp->d_name) < 0) + goto cleanup; + + if (!virFileExists(pf_subsystem_device_file)) + goto cleanup; + + /* If file exists, failure to read or if it's an empty file just m= eans + * the driver doesn't support the entry being probed for current + * device in subsystem dir, therefore ignoring the error in the + * following calls to virFileReadAllQuiet() and continue the loop + * to find device which supports this and is a match. + */ + VIR_FREE(pf_subsystem_device_switch_id); + if (virFileReadAllQuiet(pf_subsystem_device_file, IFSWITCHIDSIZ, + &pf_subsystem_device_switch_id) > 0) { + if (STRNEQ(pf_switch_id, pf_subsystem_device_switch_id)) + continue; + } + else + continue; + + VIR_FREE(pf_subsystem_device_port_name_file); + if (virAsprintf(&pf_subsystem_device_port_name_file, + "%s/%s/phys_port_name", pf_subsystem_dir, + dp->d_name) < 0) + goto cleanup; + + if (!virFileExists(pf_subsystem_device_port_name_file)) + goto cleanup; + + VIR_FREE(vf_rep_ifname); + if (virFileReadAllQuiet + (pf_subsystem_device_port_name_file, IFNAMSIZ, + &vf_rep_ifname) <=3D 0) + continue; + + /* phys_port_name may contain just VF number or string in format + * as pf'X'vf'Y' or vf'Y', where X and Y are PF and VF numbers. + * As at this point, we are already with correct PF, just need + * to verify VF number which is always at the end. + */ + + /* vf_rep_ifname read from file may contain new line,replace with = '\0' + for string comparison below */ + i =3D strlen(vf_rep_ifname); + if (c_isspace(vf_rep_ifname[i-1])) { + vf_rep_ifname[i-1] =3D '\0'; + i -=3D 1; + } + + /* Locating the start of numeric portion of VF in the string */ + while (c_isdigit(vf_rep_ifname[i-1])) + i -=3D 1; + + vf_num_str =3D vf_rep_ifname + i; + vf_rep_num =3D virParseNumber(&vf_num_str); + + if (vf_rep_num =3D=3D vf) { + if (VIR_STRDUP(*vf_ifname, dp->d_name) < 0) + goto cleanup; + ret =3D 1; + break; + } + } + + cleanup: + VIR_DIR_CLOSE(dirp); + VIR_FREE(pf_switch_id); + VIR_FREE(pf_switch_id_file); + VIR_FREE(pf_subsystem_dir); + VIR_FREE(pf_subsystem_device_file); + VIR_FREE(pf_subsystem_device_switch_id); + VIR_FREE(pf_subsystem_device_port_name_file); + VIR_FREE(vf_rep_ifname); + return ret; +} + + +/** + * virNetdevHostdevGetVFRepIFName + * + * @hostdev: host device to check + * + * Returns VF string with VF representor name upon success else NULL + */ +char * +virNetdevHostdevGetVFRIfName(virDomainHostdevDefPtr hostdev) +{ + char *linkdev =3D NULL; + char *ifname =3D NULL; + char *vf_ifname =3D NULL; + int vf =3D -1; + + if (virHostdevNetDevice(hostdev, -1, &linkdev, &vf) < 0) + goto cleanup; + + if (!virNetdevHostdevNetSysfsPath(linkdev, vf, &vf_ifname)) { + virResetLastError(); + goto cleanup; + } + + ignore_value(VIR_STRDUP(ifname, vf_ifname)); + + cleanup: + VIR_FREE(linkdev); + VIR_FREE(vf_ifname); + return ifname; +} + + +/** + * virNetdevHostdevCheckVFRepIFName + * + * @hostdev: host device to check + * @ifname : VF representor name to verify + * + * Returns true on success, false on failure + */ +bool +virNetdevHostdevCheckVFRIfName(virDomainHostdevDefPtr hostdev, + const char *ifname) +{ + char *linkdev =3D NULL; + char *vf_ifname =3D NULL; + int vf =3D -1; + bool ret =3D false; + + if (virHostdevNetDevice(hostdev, -1, &linkdev, &vf) < 0) + goto cleanup; + + if (!virNetdevHostdevNetSysfsPath(linkdev, vf, &vf_ifname)) { + virResetLastError(); + goto cleanup; + } + + if (STREQ(ifname, vf_ifname)) + ret =3D true; + + cleanup: + VIR_FREE(linkdev); + VIR_FREE(vf_ifname); + return ret; +} + + +/** + * virNetdevHostdevVFRepInterfaceStats: + * @ifname: interface + * @stats: where to store statistics + * @swapped: whether to swap RX/TX fields + * + * Returns 0 on success, -1 otherwise (with error reported). + */ +int +virNetdevHostdevVFRIfStats(const char *ifname, + virDomainInterfaceStatsPtr stats, + bool swapped) +{ + return virNetDevGetProcNetdevStats(ifname, stats, swapped); +} +#else +static const char *unsupported =3D N_("not supported on non-linux platform= s"); + + +char * +virNetdevHostdevGetVFRIfName(virDomainHostdevDefPtr hostdev ATTRIBUTE_UNUS= ED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return NULL; +} + + +bool +virNetdevHostdevCheckVFRIfName(virDomainHostdevDefPtr hostdev ATTRIBUTE_UN= USED, + const char *ifname ATTRIBUTE_UNUSED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return false; +} + + +int +virNetdevHostdevVFRIfStats(const char *ifname ATTRIBUTE_UNUSED, + virDomainInterfaceStatsPtr stats ATTRIBUTE_UNUS= ED, + bool swapped ATTRIBUTE_UNUSED) +{ + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("interface stats not implemented on this platform")); + return -1; +} +#endif diff --git a/src/util/virnetdevhostdev.h b/src/util/virnetdevhostdev.h new file mode 100644 index 0000000000..5fb846fad5 --- /dev/null +++ b/src/util/virnetdevhostdev.h @@ -0,0 +1,34 @@ +/* + * virnetdevhostdev.h: utilities to get/verify Switchdev VF Representor + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_NETDEV_HOSTDEV_H__ +# define __VIR_NETDEV_HOSTDEV_H__ + +char * virNetdevHostdevGetVFRIfName(virDomainHostdevDefPtr hostdev) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; + +bool virNetdevHostdevCheckVFRIfName(virDomainHostdevDefPtr hostdev, + const char *ifname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int virNetdevHostdevVFRIfStats(const char *ifname, + virDomainInterfaceStatsPtr stats, + bool swapped) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; +#endif /* __VIR_NETDEV_HOSTDEV_H__ */ --=20 2.13.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list