Start importing the basic OFED linux compatibility layer changes made

by dumbbell@ to be able to compile this layer as a dependency module.
Clean up some Makefiles and remove the no longer used OFED define.
Currently only i386 and amd64 targets are supported.

MFC after:		1 month
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2015-01-17 16:36:39 +00:00
parent 84b170d298
commit e982e5c561
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277302
17 changed files with 309 additions and 179 deletions

View File

@ -3571,13 +3571,13 @@ nlm/nlm_prot_svc.c optional nfslockd | nfsd
nlm/nlm_prot_xdr.c optional nfslockd | nfsd
nlm/sm_inter_xdr.c optional nfslockd | nfsd
# Linux Kernel Compatibility API
ofed/include/linux/linux_kmod.c optional ofed | compat_linuxapi
ofed/include/linux/linux_compat.c optional ofed | compat_linuxapi
ofed/include/linux/linux_pci.c optional ofed | compat_linuxapi
ofed/include/linux/linux_idr.c optional ofed | compat_linuxapi
ofed/include/linux/linux_radix.c optional ofed | compat_linuxapi
# OpenFabrics Enterprise Distribution (Infiniband)
ofed/include/linux/linux_compat.c optional ofed \
no-depend compile-with "${OFED_C}"
ofed/include/linux/linux_idr.c optional ofed \
no-depend compile-with "${OFED_C}"
ofed/include/linux/linux_radix.c optional ofed \
no-depend compile-with "${OFED_C}"
ofed/drivers/infiniband/core/addr.c optional ofed \
no-depend \
compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"

View File

@ -85,6 +85,7 @@ COMPAT_FREEBSD6 opt_compat.h
COMPAT_FREEBSD7 opt_compat.h
COMPAT_FREEBSD9 opt_compat.h
COMPAT_FREEBSD10 opt_compat.h
COMPAT_LINUXAPI opt_compat.h
COMPILING_LINT opt_global.h
COMPRESS_USER_CORES opt_core.h
CY_PCI_FASTINTR
@ -907,7 +908,6 @@ FDT opt_platform.h
FDT_DTB_STATIC opt_platform.h
# OFED Infiniband stack
OFED opt_ofed.h
OFED_DEBUG_INIT opt_ofed.h
SDP opt_ofed.h
SDP_DEBUG opt_ofed.h

View File

@ -198,6 +198,7 @@ SUBDIR= \
${_linprocfs} \
${_linsysfs} \
${_linux} \
${_linuxapi} \
lmc \
lpt \
mac_biba \
@ -501,6 +502,7 @@ _ipoib= ipoib
_linprocfs= linprocfs
_linsysfs= linsysfs
_linux= linux
_linuxapi= linuxapi
_ndis= ndis
.if ${MK_CDDL} != "no" || defined(ALL_MODULES)
_opensolaris= opensolaris

View File

@ -2,19 +2,19 @@
.PATH: ${.CURDIR}/../../ofed/drivers/infiniband/core
.PATH: ${.CURDIR}/../../ofed/include/linux
KMOD = ibcore
SRCS = addr.c cm_msgs.h iwcm.c mad_rmpp.h sa_query.c ucma.c uverbs_cmd.c
SRCS+= agent.c local_sa.c iwcm.h multicast.c smi.c ud_header.c uverbs_main.c
SRCS+= agent.h core_priv.h mad.c notice.c smi.h umem.c uverbs_marshall.c
SRCS+= cache.c device.c mad_priv.h packer.c sysfs.c user_mad.c verbs.c
SRCS+= cm.c fmr_pool.c mad_rmpp.c sa.h ucm.c uverbs.h cma.c
SRCS+= linux_compat.c linux_radix.c linux_idr.c
SRCS+= vnode_if.h device_if.h bus_if.h pci_if.h opt_inet.h opt_inet6.h
KMOD= ibcore
SRCS= addr.c iwcm.c sa_query.c ucma.c uverbs_cmd.c \
agent.c local_sa.c multicast.c smi.c ud_header.c uverbs_main.c \
mad.c notice.c umem.c uverbs_marshall.c \
cache.c device.c packer.c sysfs.c user_mad.c verbs.c \
cm.c fmr_pool.c mad_rmpp.c ucm.c cma.c \
vnode_if.h device_if.h bus_if.h pci_if.h \
opt_inet.h opt_inet6.h
CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/core
CFLAGS+= -I${.CURDIR}/../mlx4ib
CFLAGS+= -I${.CURDIR}/../../ofed/include/
CFLAGS+= -DINET6 -DINET -DOFED
CFLAGS+= -DINET6 -DINET
.include <bsd.kmod.mk>

View File

@ -2,15 +2,16 @@
.PATH: ${.CURDIR}/../../ofed/drivers/infiniband/ulp/ipoib
.PATH: ${.CURDIR}/../../ofed/include/linux
KMOD = ipoib
SRCS = device_if.h bus_if.h opt_ofed.h vnode_if.h opt_inet.h opt_inet6.h
SRCS += ipoib_cm.c ipoib_ib.c ipoib_main.c ipoib_multicast.c ipoib_verbs.c ipoib.h
SRCS+= linux_compat.c linux_radix.c linux_idr.c
KMOD= ipoib
SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
opt_inet.h opt_inet6.h opt_ofed.h \
ipoib_cm.c ipoib_ib.c ipoib_main.c \
ipoib_multicast.c ipoib_verbs.c
CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/ulp/ipoib
CFLAGS+= -I${.CURDIR}/../ibcore
CFLAGS+= -I${.CURDIR}/../../ofed/include/
CFLAGS+= -DINET6 -DINET -DOFED
CFLAGS+= -DINET6 -DINET
.include <bsd.kmod.mk>

View File

@ -0,0 +1,18 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../ofed/include/linux
KMOD= linuxapi
SRCS= linux_kmod.c \
linux_compat.c \
linux_pci.c \
linux_radix.c \
linux_idr.c
SRCS+= bus_if.h \
device_if.h \
pci_if.h \
vnode_if.h
CFLAGS+= -I${.CURDIR}/../../ofed/include/
.include <bsd.kmod.mk>

View File

@ -1,10 +1,14 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../ofed/drivers/net/mlx4
.PATH: ${.CURDIR}/../../ofed/include/linux
KMOD = mlx4
SRCS = device_if.h bus_if.h pci_if.h vnode_if.h opt_inet.h opt_inet6.h
SRCS+= alloc.c catas.c cmd.c cq.c eq.c fw.c icm.c intf.c main.c mcg.c mr.c linux_compat.c linux_radix.c linux_idr.c
SRCS+= pd.c port.c profile.c qp.c reset.c sense.c srq.c resource_tracker.c sys_tune.c
KMOD= mlx4
SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
opt_inet.h opt_inet6.h \
alloc.c catas.c cmd.c cq.c eq.c \
fw.c icm.c intf.c main.c mcg.c mr.c \
pd.c port.c profile.c qp.c reset.c sense.c \
srq.c resource_tracker.c sys_tune.c
CFLAGS+= -I${.CURDIR}/../../ofed/drivers/net/mlx4
CFLAGS+= -I${.CURDIR}/../../ofed/include/

View File

@ -2,18 +2,16 @@
.PATH: ${.CURDIR}/../../ofed/drivers/infiniband/hw/mlx4
.PATH: ${.CURDIR}/../../ofed/include/linux
KMOD = mlx4ib
SRCS = device_if.h bus_if.h pci_if.h vnode_if.h
SRCS+= linux_compat.c linux_radix.c linux_idr.c
SRCS+= alias_GUID.c mcg.c sysfs.c ah.c cq.c doorbell.c mad.c main.c mr.c qp.c srq.c wc.c cm.c
SRCS+= opt_inet.h opt_inet6.h
KMOD= mlx4ib
SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
opt_inet.h opt_inet6.h \
alias_GUID.c mcg.c sysfs.c ah.c cq.c \
doorbell.c mad.c main.c mr.c qp.c srq.c wc.c cm.c
#CFLAGS+= -I${.CURDIR}/../../ofed/include/
#CFLAGS+= -I${.CURDIR}/../../../../include
CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/hw/mlx4
CFLAGS+= -I${.CURDIR}/../../ofed/include/
CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
CFLAGS+= -DINET6 -DINET -DOFED
CFLAGS+= -DINET6 -DINET
CFLAGS+= -fms-extensions
.include <bsd.kmod.mk>

View File

@ -768,4 +768,5 @@ static moduledata_t ibcore_mod = {
};
MODULE_VERSION(ibcore, 1);
MODULE_DEPEND(ibcore, linuxapi, 1, 1, 1);
DECLARE_MODULE(ibcore, ibcore_mod, SI_SUB_SMP, SI_ORDER_ANY);

View File

@ -2420,3 +2420,4 @@ static moduledata_t mlx4ib_mod = {
DECLARE_MODULE(mlx4ib, mlx4ib_mod, SI_SUB_OFED_PREINIT, SI_ORDER_ANY);
MODULE_DEPEND(mlx4ib, mlx4, 1, 1, 1);
MODULE_DEPEND(mlx4ib, ibcore, 1, 1, 1);
MODULE_DEPEND(mlx4ib, linuxapi, 1, 1, 1);

View File

@ -1542,4 +1542,4 @@ static moduledata_t ipoib_mod = {
DECLARE_MODULE(ipoib, ipoib_mod, SI_SUB_SMP, SI_ORDER_ANY);
MODULE_DEPEND(ipoib, ibcore, 1, 1, 1);
MODULE_DEPEND(ipoib, linuxapi, 1, 1, 1);

View File

@ -349,3 +349,4 @@ static moduledata_t mlxen_mod = {
};
DECLARE_MODULE(mlxen, mlxen_mod, SI_SUB_OFED_PREINIT, SI_ORDER_ANY);
MODULE_DEPEND(mlxen, mlx4, 1, 1, 1);
MODULE_DEPEND(mlxen, linuxapi, 1, 1, 1);

View File

@ -3796,3 +3796,5 @@ static moduledata_t mlx4_mod = {
};
MODULE_VERSION(mlx4, 1);
DECLARE_MODULE(mlx4, mlx4_mod, SI_SUB_OFED_PREINIT, SI_ORDER_ANY);
MODULE_DEPEND(mlx4, linuxapi, 1, 1, 1);

View File

@ -343,7 +343,8 @@ linux_dev_read(struct cdev *dev, struct uio *uio, int ioflag)
bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
uio->uio_iov->iov_len, &uio->uio_offset);
if (bytes >= 0) {
uio->uio_iov->iov_base += bytes;
uio->uio_iov->iov_base =
((uint8_t *)uio->uio_iov->iov_base) + bytes;
uio->uio_iov->iov_len -= bytes;
uio->uio_resid -= bytes;
} else
@ -377,7 +378,8 @@ linux_dev_write(struct cdev *dev, struct uio *uio, int ioflag)
bytes = filp->f_op->write(filp, uio->uio_iov->iov_base,
uio->uio_iov->iov_len, &uio->uio_offset);
if (bytes >= 0) {
uio->uio_iov->iov_base += bytes;
uio->uio_iov->iov_base =
((uint8_t *)uio->uio_iov->iov_base) + bytes;
uio->uio_iov->iov_len -= bytes;
uio->uio_resid -= bytes;
} else
@ -498,7 +500,8 @@ linux_file_read(struct file *file, struct uio *uio, struct ucred *active_cred,
bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
uio->uio_iov->iov_len, &uio->uio_offset);
if (bytes >= 0) {
uio->uio_iov->iov_base += bytes;
uio->uio_iov->iov_base =
((uint8_t *)uio->uio_iov->iov_base) + bytes;
uio->uio_iov->iov_len -= bytes;
uio->uio_resid -= bytes;
} else
@ -736,7 +739,6 @@ linux_compat_init(void)
for (i = 0; i < VMMAP_HASH_SIZE; i++)
LIST_INIT(&vmmaphead[i]);
}
SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL);
static void

View File

@ -0,0 +1,33 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2015 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/module.h>
MODULE_VERSION(linuxapi, 1);
MODULE_DEPEND(linuxapi, pci, 1, 1, 1);

View File

@ -0,0 +1,206 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2015 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filio.h>
#include <sys/rwlock.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/stdarg.h>
#include <machine/pmap.h>
#include <linux/kobject.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/cdev.h>
#include <linux/file.h>
#include <linux/sysfs.h>
#include <linux/mm.h>
#include <linux/io.h>
#include <linux/vmalloc.h>
#include <linux/pci.h>
static device_probe_t linux_pci_probe;
static device_attach_t linux_pci_attach;
static device_detach_t linux_pci_detach;
static device_method_t pci_methods[] = {
DEVMETHOD(device_probe, linux_pci_probe),
DEVMETHOD(device_attach, linux_pci_attach),
DEVMETHOD(device_detach, linux_pci_detach),
DEVMETHOD_END
};
static struct pci_driver *
linux_pci_find(device_t dev, const struct pci_device_id **idp)
{
const struct pci_device_id *id;
struct pci_driver *pdrv;
uint16_t vendor;
uint16_t device;
vendor = pci_get_vendor(dev);
device = pci_get_device(dev);
spin_lock(&pci_lock);
list_for_each_entry(pdrv, &pci_drivers, links) {
for (id = pdrv->id_table; id->vendor != 0; id++) {
if (vendor == id->vendor && device == id->device) {
*idp = id;
spin_unlock(&pci_lock);
return (pdrv);
}
}
}
spin_unlock(&pci_lock);
return (NULL);
}
static int
linux_pci_probe(device_t dev)
{
const struct pci_device_id *id;
struct pci_driver *pdrv;
if ((pdrv = linux_pci_find(dev, &id)) == NULL)
return (ENXIO);
if (device_get_driver(dev) != &pdrv->driver)
return (ENXIO);
device_set_desc(dev, pdrv->name);
return (0);
}
static int
linux_pci_attach(device_t dev)
{
struct resource_list_entry *rle;
struct pci_dev *pdev;
struct pci_driver *pdrv;
const struct pci_device_id *id;
int error;
pdrv = linux_pci_find(dev, &id);
pdev = device_get_softc(dev);
pdev->dev.parent = &linux_rootdev;
pdev->dev.bsddev = dev;
INIT_LIST_HEAD(&pdev->dev.irqents);
pdev->device = id->device;
pdev->vendor = id->vendor;
pdev->dev.dma_mask = &pdev->dma_mask;
pdev->pdrv = pdrv;
kobject_init(&pdev->dev.kobj, &dev_ktype);
kobject_set_name(&pdev->dev.kobj, device_get_nameunit(dev));
kobject_add(&pdev->dev.kobj, &linux_rootdev.kobj,
kobject_name(&pdev->dev.kobj));
rle = _pci_get_rle(pdev, SYS_RES_IRQ, 0);
if (rle)
pdev->dev.irq = rle->start;
else
pdev->dev.irq = 0;
pdev->irq = pdev->dev.irq;
mtx_unlock(&Giant);
spin_lock(&pci_lock);
list_add(&pdev->links, &pci_devices);
spin_unlock(&pci_lock);
error = pdrv->probe(pdev, id);
mtx_lock(&Giant);
if (error) {
spin_lock(&pci_lock);
list_del(&pdev->links);
spin_unlock(&pci_lock);
put_device(&pdev->dev);
return (-error);
}
return (0);
}
static int
linux_pci_detach(device_t dev)
{
struct pci_dev *pdev;
pdev = device_get_softc(dev);
mtx_unlock(&Giant);
pdev->pdrv->remove(pdev);
mtx_lock(&Giant);
spin_lock(&pci_lock);
list_del(&pdev->links);
spin_unlock(&pci_lock);
put_device(&pdev->dev);
return (0);
}
int
pci_register_driver(struct pci_driver *pdrv)
{
devclass_t bus;
int error = 0;
bus = devclass_find("pci");
spin_lock(&pci_lock);
list_add(&pdrv->links, &pci_drivers);
spin_unlock(&pci_lock);
pdrv->driver.name = pdrv->name;
pdrv->driver.methods = pci_methods;
pdrv->driver.size = sizeof(struct pci_dev);
mtx_lock(&Giant);
if (bus != NULL) {
error = devclass_add_driver(bus, &pdrv->driver, BUS_PASS_DEFAULT,
&pdrv->bsdclass);
}
mtx_unlock(&Giant);
return (-error);
}
void
pci_unregister_driver(struct pci_driver *pdrv)
{
devclass_t bus;
bus = devclass_find("pci");
list_del(&pdrv->links);
mtx_lock(&Giant);
if (bus != NULL)
devclass_delete_driver(bus, &pdrv->driver);
mtx_unlock(&Giant);
}

View File

@ -409,146 +409,8 @@ pci_write_config_dword(struct pci_dev *pdev, int where, u32 val)
return (0);
}
static struct pci_driver *
linux_pci_find(device_t dev, const struct pci_device_id **idp)
{
const struct pci_device_id *id;
struct pci_driver *pdrv;
uint16_t vendor;
uint16_t device;
vendor = pci_get_vendor(dev);
device = pci_get_device(dev);
spin_lock(&pci_lock);
list_for_each_entry(pdrv, &pci_drivers, links) {
for (id = pdrv->id_table; id->vendor != 0; id++) {
if (vendor == id->vendor && device == id->device) {
*idp = id;
spin_unlock(&pci_lock);
return (pdrv);
}
}
}
spin_unlock(&pci_lock);
return (NULL);
}
static inline int
linux_pci_probe(device_t dev)
{
const struct pci_device_id *id;
struct pci_driver *pdrv;
if ((pdrv = linux_pci_find(dev, &id)) == NULL)
return (ENXIO);
if (device_get_driver(dev) != &pdrv->driver)
return (ENXIO);
device_set_desc(dev, pdrv->name);
return (0);
}
static inline int
linux_pci_attach(device_t dev)
{
struct resource_list_entry *rle;
struct pci_dev *pdev;
struct pci_driver *pdrv;
const struct pci_device_id *id;
int error;
pdrv = linux_pci_find(dev, &id);
pdev = device_get_softc(dev);
pdev->dev.parent = &linux_rootdev;
pdev->dev.bsddev = dev;
INIT_LIST_HEAD(&pdev->dev.irqents);
pdev->device = id->device;
pdev->vendor = id->vendor;
pdev->dev.dma_mask = &pdev->dma_mask;
pdev->pdrv = pdrv;
kobject_init(&pdev->dev.kobj, &dev_ktype);
kobject_set_name(&pdev->dev.kobj, device_get_nameunit(dev));
kobject_add(&pdev->dev.kobj, &linux_rootdev.kobj,
kobject_name(&pdev->dev.kobj));
rle = _pci_get_rle(pdev, SYS_RES_IRQ, 0);
if (rle)
pdev->dev.irq = rle->start;
else
pdev->dev.irq = 0;
pdev->irq = pdev->dev.irq;
mtx_unlock(&Giant);
spin_lock(&pci_lock);
list_add(&pdev->links, &pci_devices);
spin_unlock(&pci_lock);
error = pdrv->probe(pdev, id);
mtx_lock(&Giant);
if (error) {
spin_lock(&pci_lock);
list_del(&pdev->links);
spin_unlock(&pci_lock);
put_device(&pdev->dev);
return (-error);
}
return (0);
}
static inline int
linux_pci_detach(device_t dev)
{
struct pci_dev *pdev;
pdev = device_get_softc(dev);
mtx_unlock(&Giant);
pdev->pdrv->remove(pdev);
mtx_lock(&Giant);
spin_lock(&pci_lock);
list_del(&pdev->links);
spin_unlock(&pci_lock);
put_device(&pdev->dev);
return (0);
}
static device_method_t pci_methods[] = {
DEVMETHOD(device_probe, linux_pci_probe),
DEVMETHOD(device_attach, linux_pci_attach),
DEVMETHOD(device_detach, linux_pci_detach),
{0, 0}
};
static inline int
pci_register_driver(struct pci_driver *pdrv)
{
devclass_t bus;
int error;
spin_lock(&pci_lock);
list_add(&pdrv->links, &pci_drivers);
spin_unlock(&pci_lock);
bus = devclass_find("pci");
pdrv->driver.name = pdrv->name;
pdrv->driver.methods = pci_methods;
pdrv->driver.size = sizeof(struct pci_dev);
mtx_lock(&Giant);
error = devclass_add_driver(bus, &pdrv->driver, BUS_PASS_DEFAULT,
&pdrv->bsdclass);
mtx_unlock(&Giant);
if (error)
return (-error);
return (0);
}
static inline void
pci_unregister_driver(struct pci_driver *pdrv)
{
devclass_t bus;
list_del(&pdrv->links);
bus = devclass_find("pci");
mtx_lock(&Giant);
devclass_delete_driver(bus, &pdrv->driver);
mtx_unlock(&Giant);
}
extern int pci_register_driver(struct pci_driver *pdrv);
extern void pci_unregister_driver(struct pci_driver *pdrv);
struct msix_entry {
int entry;
@ -837,5 +699,4 @@ static inline int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 v
return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
}
#endif /* _LINUX_PCI_H_ */