summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-05-28 22:01:50 +0000
committerjhb <jhb@FreeBSD.org>2015-05-28 22:01:50 +0000
commita2158a48ce1a105bab12222bc489bdf3416ae2cc (patch)
treea5e7bfbf84ce57b511065c85cc47c6976244f58e /sys
parentdce46f40950ace53058f9271895013fe4fb7fd13 (diff)
downloadFreeBSD-src-a2158a48ce1a105bab12222bc489bdf3416ae2cc.zip
FreeBSD-src-a2158a48ce1a105bab12222bc489bdf3416ae2cc.tar.gz
Create a separate kobj interface for leaf-driver PCI IOV methods.
Leaf drivers should not import the PCI bus interface to add IOV handling. Instead, move the IOV client methods to a separate kobj interface. Differential Revision: https://reviews.freebsd.org/D2584 Reviewed by: rstone
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files1
-rw-r--r--sys/conf/kmod.mk2
-rw-r--r--sys/dev/ixl/if_ixl.c14
-rw-r--r--sys/dev/ixl/ixl.h1
-rw-r--r--sys/dev/pci/pci_if.m17
-rw-r--r--sys/dev/pci/pci_iov.c14
-rw-r--r--sys/dev/pci/pci_iov.h49
-rw-r--r--sys/dev/pci/pci_iov_if.m52
-rw-r--r--sys/dev/pci/pcivar.h15
-rw-r--r--[-rwxr-xr-x]sys/modules/ixl/Makefile2
10 files changed, 119 insertions, 48 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 0a63a1c..5dcb6a4 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -2024,6 +2024,7 @@ dev/pci/isa_pci.c optional pci isa
dev/pci/pci.c optional pci
dev/pci/pci_if.m standard
dev/pci/pci_iov.c optional pci pci_iov
+dev/pci/pci_iov_if.m standard
dev/pci/pci_iov_schema.c optional pci pci_iov
dev/pci/pci_pci.c optional pci
dev/pci/pci_subr.c optional pci
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 0f27113..9009745 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -349,7 +349,7 @@ MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acpi_wmi_if.m \
dev/mbox/mbox_if.m dev/mmc/mmcbr_if.m dev/mmc/mmcbus_if.m \
dev/mii/miibus_if.m dev/mvs/mvs_if.m dev/ofw/ofw_bus_if.m \
dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
- dev/pci/pcib_if.m dev/ppbus/ppbus_if.m \
+ dev/pci/pci_iov_if.m dev/pci/pcib_if.m dev/ppbus/ppbus_if.m \
dev/sdhci/sdhci_if.m dev/smbus/smbus_if.m dev/spibus/spibus_if.m \
dev/sound/pci/hda/hdac_if.m \
dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index de4ee24..026bc9e 100644
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
@@ -199,8 +199,8 @@ static int ixl_sysctl_switch_config(SYSCTL_HANDLER_ARGS);
#ifdef PCI_IOV
static int ixl_adminq_err_to_errno(enum i40e_admin_queue_err err);
-static int ixl_init_iov(device_t dev, uint16_t num_vfs, const nvlist_t*);
-static void ixl_uninit_iov(device_t dev);
+static int ixl_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t*);
+static void ixl_iov_uninit(device_t dev);
static int ixl_add_vf(device_t dev, uint16_t vfnum, const nvlist_t*);
static void ixl_handle_vf_msg(struct ixl_pf *,
@@ -222,9 +222,9 @@ static device_method_t ixl_methods[] = {
DEVMETHOD(device_detach, ixl_detach),
DEVMETHOD(device_shutdown, ixl_shutdown),
#ifdef PCI_IOV
- DEVMETHOD(pci_init_iov, ixl_init_iov),
- DEVMETHOD(pci_uninit_iov, ixl_uninit_iov),
- DEVMETHOD(pci_add_vf, ixl_add_vf),
+ DEVMETHOD(pci_iov_init, ixl_iov_init),
+ DEVMETHOD(pci_iov_uninit, ixl_iov_uninit),
+ DEVMETHOD(pci_iov_add_vf, ixl_add_vf),
#endif
{0, 0}
};
@@ -6456,7 +6456,7 @@ ixl_adminq_err_to_errno(enum i40e_admin_queue_err err)
}
static int
-ixl_init_iov(device_t dev, uint16_t num_vfs, const nvlist_t *params)
+ixl_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *params)
{
struct ixl_pf *pf;
struct i40e_hw *hw;
@@ -6504,7 +6504,7 @@ fail:
}
static void
-ixl_uninit_iov(device_t dev)
+ixl_iov_uninit(device_t dev)
{
struct ixl_pf *pf;
struct i40e_hw *hw;
diff --git a/sys/dev/ixl/ixl.h b/sys/dev/ixl/ixl.h
index 1ddfbca3..3348e1a 100644
--- a/sys/dev/ixl/ixl.h
+++ b/sys/dev/ixl/ixl.h
@@ -93,6 +93,7 @@
#ifdef PCI_IOV
#include <sys/nv.h>
#include <sys/iov_schema.h>
+#include <dev/pci/pci_iov.h>
#endif
#include "i40e_type.h"
diff --git a/sys/dev/pci/pci_if.m b/sys/dev/pci/pci_if.m
index 9f97d9a..aeeff2c 100644
--- a/sys/dev/pci/pci_if.m
+++ b/sys/dev/pci/pci_if.m
@@ -214,22 +214,6 @@ METHOD int iov_detach {
device_t child;
};
-METHOD int init_iov {
- device_t dev;
- uint16_t num_vfs;
- const struct nvlist *config;
-};
-
-METHOD void uninit_iov {
- device_t dev;
-};
-
-METHOD int add_vf {
- device_t dev;
- uint16_t vfnum;
- const struct nvlist *config;
-};
-
METHOD device_t create_iov_child {
device_t bus;
device_t pf;
@@ -237,4 +221,3 @@ METHOD device_t create_iov_child {
uint16_t vid;
uint16_t did;
} DEFAULT null_create_iov_child;
-
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index 4672e55..58e6926 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -53,11 +53,11 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/pci_iov.h>
#include <dev/pci/pci_private.h>
#include <dev/pci/pci_iov_private.h>
#include <dev/pci/schema_private.h>
-#include "pci_if.h"
#include "pcib_if.h"
static MALLOC_DEFINE(M_SRIOV, "sr_iov", "PCI SR-IOV allocations");
@@ -483,13 +483,13 @@ pci_iov_config_page_size(struct pci_devinfo *dinfo)
}
static int
-pci_init_iov(device_t dev, uint16_t num_vfs, const nvlist_t *config)
+pci_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *config)
{
const nvlist_t *device, *driver_config;
device = nvlist_get_nvlist(config, PF_CONFIG_NAME);
driver_config = nvlist_get_nvlist(device, DRIVER_CONFIG_NAME);
- return (PCI_INIT_IOV(dev, num_vfs, driver_config));
+ return (PCI_IOV_INIT(dev, num_vfs, driver_config));
}
static int
@@ -595,7 +595,7 @@ pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config,
pci_iov_add_bars(iov, vfinfo);
- error = PCI_ADD_VF(dev, i, driver_config);
+ error = PCI_IOV_ADD_VF(dev, i, driver_config);
if (error != 0) {
device_printf(dev, "Failed to add VF %d\n", i);
pci_delete_child(bus, vf);
@@ -652,7 +652,7 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg)
if (error != 0)
goto out;
- error = pci_init_iov(dev, num_vfs, config);
+ error = pci_iov_init(dev, num_vfs, config);
if (error != 0)
goto out;
iov_inited = 1;
@@ -700,7 +700,7 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg)
return (0);
out:
if (iov_inited)
- PCI_UNINIT_IOV(dev);
+ PCI_IOV_UNINIT(dev);
for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
if (iov->iov_bar[i].res != NULL) {
@@ -793,7 +793,7 @@ pci_iov_delete(struct cdev *cdev)
if (pci_iov_is_child_vf(iov, vf))
pci_delete_child(bus, vf);
}
- PCI_UNINIT_IOV(dev);
+ PCI_IOV_UNINIT(dev);
iov_ctl = IOV_READ(dinfo, PCIR_SRIOV_CTL, 2);
iov_ctl &= ~(PCIM_SRIOV_VF_EN | PCIM_SRIOV_VF_MSE);
diff --git a/sys/dev/pci/pci_iov.h b/sys/dev/pci/pci_iov.h
new file mode 100644
index 0000000..fd2f8fb
--- /dev/null
+++ b/sys/dev/pci/pci_iov.h
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2013-2015 Sandvine Inc.
+ * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _PCI_IOV_H_
+#define _PCI_IOV_H_
+
+#include "pci_iov_if.h"
+
+struct nvlist;
+
+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));
+}
+
+static __inline int
+pci_iov_detach(device_t dev)
+{
+ return (PCI_IOV_DETACH(device_get_parent(dev), dev));
+}
+
+#endif /* !_PCI_IOV_H_ */
diff --git a/sys/dev/pci/pci_iov_if.m b/sys/dev/pci/pci_iov_if.m
new file mode 100644
index 0000000..3b6796b
--- /dev/null
+++ b/sys/dev/pci/pci_iov_if.m
@@ -0,0 +1,52 @@
+#-
+# Copyright (c) 2013-2015 Sandvine Inc.
+# 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+#
+# $FreeBSD$
+#
+
+#include <sys/bus.h>
+
+INTERFACE pci_iov;
+
+HEADER {
+ struct nvlist;
+}
+
+
+METHOD int init {
+ device_t dev;
+ uint16_t num_vfs;
+ const struct nvlist *config;
+};
+
+METHOD void uninit {
+ device_t dev;
+};
+
+METHOD int add_vf {
+ device_t dev;
+ uint16_t vfnum;
+ const struct nvlist *config;
+};
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index 2fd76b6..7f2e958 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -39,8 +39,6 @@
typedef uint64_t pci_addr_t;
-struct nvlist;
-
/* Config registers for PCI-PCI and PCI-Cardbus bridges. */
struct pcicfg_bridge {
uint8_t br_seclat;
@@ -536,19 +534,6 @@ pci_child_added(device_t dev)
return (PCI_CHILD_ADDED(device_get_parent(dev), dev));
}
-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));
-}
-
-static __inline int
-pci_iov_detach(device_t dev)
-{
- return (PCI_IOV_DETACH(device_get_parent(dev), dev));
-}
-
device_t pci_find_bsf(uint8_t, uint8_t, uint8_t);
device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t);
device_t pci_find_device(uint16_t, uint16_t);
diff --git a/sys/modules/ixl/Makefile b/sys/modules/ixl/Makefile
index 7d2fca9..13be8ab 100755..100644
--- a/sys/modules/ixl/Makefile
+++ b/sys/modules/ixl/Makefile
@@ -3,7 +3,7 @@
.PATH: ${.CURDIR}/../../dev/ixl
KMOD = if_ixl
-SRCS = device_if.h bus_if.h pci_if.h opt_bdg.h
+SRCS = device_if.h bus_if.h pci_if.h pci_iov_if.h opt_bdg.h
SRCS += opt_inet.h opt_inet6.h opt_rss.h
SRCS += if_ixl.c ixl_txrx.c i40e_osdep.c
OpenPOWER on IntegriCloud