From owner-svn-src-stable@freebsd.org Wed Apr 1 17:13:54 2020 Return-Path: Delivered-To: svn-src-stable@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 5C5F4279F12; Wed, 1 Apr 2020 17:13:54 +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 48st8F74h6z3RGx; Wed, 1 Apr 2020 17:13:49 +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 EF3E010C0; Wed, 1 Apr 2020 17:13:43 +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 031HDhW3047913; Wed, 1 Apr 2020 17:13:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 031HDhqV047912; Wed, 1 Apr 2020 17:13:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202004011713.031HDhqV047912@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 1 Apr 2020 17:13:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359525 - in stable/12/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 359525 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 17:13:54 -0000 Author: kib Date: Wed Apr 1 17:13:43 2020 New Revision: 359525 URL: https://svnweb.freebsd.org/changeset/base/359525 Log: MFC r359096, r359165 (by imp): linuxkpi: Add infrastructure to pass FreeBSD IOV method calls into pci_driver methods. Modified: stable/12/sys/compat/linuxkpi/common/include/linux/pci.h stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/pci.h Wed Apr 1 17:09:21 2020 (r359524) +++ stable/12/sys/compat/linuxkpi/common/include/linux/pci.h Wed Apr 1 17:13:43 2020 (r359525) @@ -37,8 +37,10 @@ #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: stable/12/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Wed Apr 1 17:09:21 2020 (r359524) +++ stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Wed Apr 1 17:13:43 2020 (r359525) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -45,6 +46,10 @@ __FBSDID("$FreeBSD$"); #include +#include +#include +#include + #include #include #include @@ -64,6 +69,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), @@ -72,6 +80,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 }; @@ -268,6 +279,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