svn commit: r306461 - in stable/11: share/man/man9 sys/dev/pci
John Baldwin
jhb at FreeBSD.org
Thu Sep 29 22:52:26 UTC 2016
Author: jhb
Date: Thu Sep 29 22:52:24 2016
New Revision: 306461
URL: https://svnweb.freebsd.org/changeset/base/306461
Log:
MFC 303721: Permit the name of the /dev/iov entry to be set by the driver.
The PCI_IOV option creates character devices in /dev/iov for each PF
device driver that registers support for creating VFs. By default the
character device is named after the PF device (e.g. /dev/iov/foo0).
This change adds a variant of pci_iov_attach() called pci_iov_attach_name()
that allows the name of the /dev/iov entry to be specified by the
driver.
To preserve the ABI, this version does not modify the existing
PCI_IOV_ATTACH kobj method as was done in HEAD. Instead, a new
PCI_IOV_ATTACH_NAME method has been added that accepts the name as an
additional parameter. The PCI bus driver now provides an implementation
of PCI_IOV_ATTACH_NAME. A default implementation of PCI_IOV_ATTACH is
provided that calls PCI_IOV_ATTACH_NAME passing 'device_get_nameunit(dev)'
as the name.
Sponsored by: Chelsio Communications
Modified:
stable/11/share/man/man9/Makefile
stable/11/share/man/man9/pci.9
stable/11/sys/dev/pci/pci.c
stable/11/sys/dev/pci/pci_if.m
stable/11/sys/dev/pci/pci_iov.c
stable/11/sys/dev/pci/pci_iov.h
stable/11/sys/dev/pci/pci_private.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/share/man/man9/Makefile
==============================================================================
--- stable/11/share/man/man9/Makefile Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/share/man/man9/Makefile Thu Sep 29 22:52:24 2016 (r306461)
@@ -1303,6 +1303,7 @@ MLINKS+=pci.9 pci_alloc_msi.9 \
pci.9 pci_get_vpd_ident.9 \
pci.9 pci_get_vpd_readonly.9 \
pci.9 pci_iov_attach.9 \
+ pci.9 pci_iov_attach_name.9 \
pci.9 pci_iov_detach.9 \
pci.9 pci_msi_count.9 \
pci.9 pci_msix_count.9 \
Modified: stable/11/share/man/man9/pci.9
==============================================================================
--- stable/11/share/man/man9/pci.9 Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/share/man/man9/pci.9 Thu Sep 29 22:52:24 2016 (r306461)
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 24, 2016
+.Dd August 3, 2016
.Dt PCI 9
.Os
.Sh NAME
@@ -50,6 +50,7 @@
.Nm pci_get_vpd_ident ,
.Nm pci_get_vpd_readonly ,
.Nm pci_iov_attach ,
+.Nm pci_iov_attach_name ,
.Nm pci_iov_detach ,
.Nm pci_msi_count ,
.Nm pci_msix_count ,
@@ -152,6 +153,14 @@
.Ft int
.Fn pci_iov_attach "device_t dev" "nvlist_t *pf_schema" "nvlist_t *vf_schema"
.Ft int
+.Fo pci_iov_attach_name
+.Fa "device_t dev"
+.Fa "nvlist_t *pf_schema"
+.Fa "nvlist_t *vf_schema"
+.Fa "const char *fmt"
+.Fa "..."
+.Fc
+.Ft int
.Fn pci_iov_detach "device_t dev"
.Sh DESCRIPTION
The
@@ -595,6 +604,20 @@ and is responsible for freeing them.
The driver must never free the schemas itself.
.Pp
The
+.Fn pci_iov_attach_name
+function is a variant of
+.Fn pci_iov_attach
+that allows the name of the associated character device in
+.Pa /dev/iov
+to be specified by
+.Fa fmt .
+The
+.Fn pci_iov_attach
+function uses the name of
+.Fa dev
+as the device name.
+.Pp
+The
.Fn pci_iov_detach
function is used to advise the SR-IOV infrastructure that the driver for the
given device is attempting to detach and that all SR-IOV resources for the
Modified: stable/11/sys/dev/pci/pci.c
==============================================================================
--- stable/11/sys/dev/pci/pci.c Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/sys/dev/pci/pci.c Thu Sep 29 22:52:24 2016 (r306461)
@@ -195,7 +195,7 @@ static device_method_t pci_methods[] = {
DEVMETHOD(pci_alloc_devinfo, pci_alloc_devinfo_method),
DEVMETHOD(pci_child_added, pci_child_added_method),
#ifdef PCI_IOV
- DEVMETHOD(pci_iov_attach, pci_iov_attach_method),
+ DEVMETHOD(pci_iov_attach_name, pci_iov_attach_method),
DEVMETHOD(pci_iov_detach, pci_iov_detach_method),
DEVMETHOD(pci_create_iov_child, pci_create_iov_child_method),
#endif
Modified: stable/11/sys/dev/pci/pci_if.m
==============================================================================
--- stable/11/sys/dev/pci/pci_if.m Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/sys/dev/pci/pci_if.m Thu Sep 29 22:52:24 2016 (r306461)
@@ -51,6 +51,14 @@ CODE {
device_printf(bus, "PCI_IOV not implemented on this bus.\n");
return (NULL);
}
+
+ static int
+ compat_iov_attach(device_t bus, device_t dev, struct nvlist *pf_schema,
+ struct nvlist *vf_schema)
+ {
+ return (PCI_IOV_ATTACH_NAME(bus, dev, pf_schema, vf_schema,
+ device_get_nameunit(dev)));
+ }
};
HEADER {
@@ -235,6 +243,14 @@ METHOD int iov_attach {
device_t child;
struct nvlist *pf_schema;
struct nvlist *vf_schema;
+} DEFAULT compat_iov_attach;
+
+METHOD int iov_attach_name {
+ device_t dev;
+ device_t child;
+ struct nvlist *pf_schema;
+ struct nvlist *vf_schema;
+ const char *name;
};
METHOD int iov_detach {
Modified: stable/11/sys/dev/pci/pci_iov.c
==============================================================================
--- stable/11/sys/dev/pci/pci_iov.c Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/sys/dev/pci/pci_iov.c Thu Sep 29 22:52:24 2016 (r306461)
@@ -98,8 +98,22 @@ static nvlist_t *pci_iov_get_pf_subsyste
static nvlist_t *pci_iov_get_vf_subsystem_schema(void);
int
+pci_iov_attach_name(device_t dev, struct nvlist *pf_schema,
+ struct nvlist *vf_schema, const char *fmt, ...)
+{
+ char buf[NAME_MAX + 1];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return (PCI_IOV_ATTACH_NAME(device_get_parent(dev), dev, pf_schema,
+ vf_schema, buf));
+}
+
+int
pci_iov_attach_method(device_t bus, device_t dev, nvlist_t *pf_schema,
- nvlist_t *vf_schema)
+ nvlist_t *vf_schema, const char *name)
{
device_t pcib;
struct pci_devinfo *dinfo;
@@ -149,7 +163,7 @@ pci_iov_attach_method(device_t bus, devi
iov->iov_schema = schema;
iov->iov_cdev = make_dev(&iov_cdevsw, device_get_unit(dev),
- UID_ROOT, GID_WHEEL, 0600, "iov/%s", device_get_nameunit(dev));
+ UID_ROOT, GID_WHEEL, 0600, "iov/%s", name);
if (iov->iov_cdev == NULL) {
error = ENOMEM;
Modified: stable/11/sys/dev/pci/pci_iov.h
==============================================================================
--- stable/11/sys/dev/pci/pci_iov.h Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/sys/dev/pci/pci_iov.h Thu Sep 29 22:52:24 2016 (r306461)
@@ -33,11 +33,14 @@
struct nvlist;
+int pci_iov_attach_name(device_t dev, struct nvlist *pf_schema,
+ struct nvlist *vf_schema, const char *fmt, ...) __printflike(4, 5);
+
static __inline int
pci_iov_attach(device_t dev, struct nvlist *pf_schema, struct nvlist *vf_schema)
{
- return (PCI_IOV_ATTACH(device_get_parent(dev), dev, pf_schema,
- vf_schema));
+ return (PCI_IOV_ATTACH_NAME(device_get_parent(dev), dev, pf_schema,
+ vf_schema, device_get_nameunit(dev)));
}
static __inline int
Modified: stable/11/sys/dev/pci/pci_private.h
==============================================================================
--- stable/11/sys/dev/pci/pci_private.h Thu Sep 29 22:01:09 2016 (r306460)
+++ stable/11/sys/dev/pci/pci_private.h Thu Sep 29 22:52:24 2016 (r306461)
@@ -158,7 +158,8 @@ struct resource *pci_alloc_multi_resourc
rman_res_t count, u_long num, u_int flags);
int pci_iov_attach_method(device_t bus, device_t dev,
- struct nvlist *pf_schema, struct nvlist *vf_schema);
+ struct nvlist *pf_schema, struct nvlist *vf_schema,
+ const char *name);
int pci_iov_detach_method(device_t bus, device_t dev);
device_t pci_create_iov_child_method(device_t bus, device_t pf,
More information about the svn-src-stable-11
mailing list