From owner-svn-src-head@freebsd.org Wed Mar 18 22:10:51 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3602726EE29; Wed, 18 Mar 2020 22:10:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jPPQ6T9zz4cqm; Wed, 18 Mar 2020 22:10:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64E89ACC; Wed, 18 Mar 2020 22:10:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02IMAoP2049039; Wed, 18 Mar 2020 22:10:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02IMAoG9049036; Wed, 18 Mar 2020 22:10:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202003182210.02IMAoG9049036@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Mar 2020 22:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359096 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 359096 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 22:10:51 -0000 Author: kib Date: Wed Mar 18 22:10:49 2020 New Revision: 359096 URL: https://svnweb.freebsd.org/changeset/base/359096 Log: linuxkpi: Add infrastructure to pass FreeBSD IOV method calls into pci_driver methods. Reviewed by: hselasky Sponsored by: Mellanox Technologies MFC after: 2 weeks Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h head/sys/compat/linuxkpi/common/src/linux_pci.c Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Mar 18 22:09:16 2020 (r359095) +++ head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Mar 18 22:10:49 2020 (r359096) @@ -37,11 +37,13 @@ #include #include +#include #include #include #include #include #include +#include #include @@ -201,6 +203,11 @@ struct pci_driver { struct device_driver driver; const struct pci_error_handlers *err_handler; bool isdrm; + int (*bsd_iov_init)(device_t dev, uint16_t num_vfs, + const nvlist_t *pf_config); + void (*bsd_iov_uninit)(device_t dev); + int (*bsd_iov_add_vf)(device_t dev, uint16_t vfnum, + const nvlist_t *vf_config); }; struct pci_bus { Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Mar 18 22:09:16 2020 (r359095) +++ head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Mar 18 22:10:49 2020 (r359096) @@ -65,6 +65,9 @@ static device_detach_t linux_pci_detach; static device_suspend_t linux_pci_suspend; static device_resume_t linux_pci_resume; static device_shutdown_t linux_pci_shutdown; +static pci_iov_init_t linux_pci_iov_init; +static pci_iov_uninit_t linux_pci_iov_uninit; +static pci_iov_add_vf_t linux_pci_iov_add_vf; static device_method_t pci_methods[] = { DEVMETHOD(device_probe, linux_pci_probe), @@ -73,6 +76,9 @@ static device_method_t pci_methods[] = { DEVMETHOD(device_suspend, linux_pci_suspend), DEVMETHOD(device_resume, linux_pci_resume), DEVMETHOD(device_shutdown, linux_pci_shutdown), + DEVMETHOD(pci_iov_init, linux_pci_iov_init), + DEVMETHOD(pci_iov_uninit, linux_pci_iov_uninit), + DEVMETHOD(pci_iov_add_vf, linux_pci_iov_add_vf), DEVMETHOD_END }; @@ -353,6 +359,47 @@ linux_pci_shutdown(device_t dev) if (pdev->pdrv->shutdown != NULL) pdev->pdrv->shutdown(pdev); return (0); +} + +static int +linux_pci_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *pf_config) +{ + struct pci_dev *pdev; + int error; + + linux_set_current(curthread); + pdev = device_get_softc(dev); + if (pdev->pdrv->bsd_iov_init != NULL) + error = pdev->pdrv->bsd_iov_init(dev, num_vfs, pf_config); + else + error = EINVAL; + return (error); +} + +static void +linux_pci_iov_uninit(device_t dev) +{ + struct pci_dev *pdev; + + linux_set_current(curthread); + pdev = device_get_softc(dev); + if (pdev->pdrv->bsd_iov_uninit != NULL) + pdev->pdrv->bsd_iov_uninit(dev); +} + +static int +linux_pci_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *vf_config) +{ + struct pci_dev *pdev; + int error; + + linux_set_current(curthread); + pdev = device_get_softc(dev); + if (pdev->pdrv->bsd_iov_add_vf != NULL) + error = pdev->pdrv->bsd_iov_add_vf(dev, vfnum, vf_config); + else + error = EINVAL; + return (error); } static int