Ejemplo n.º 1
0
static nvlist_t *
pci_iov_build_schema(nvlist_t **pf, nvlist_t **vf)
{
	nvlist_t *schema, *pf_driver, *vf_driver;

	/* We always take ownership of the schemas. */
	pf_driver = *pf;
	*pf = NULL;
	vf_driver = *vf;
	*vf = NULL;

	schema = pci_iov_schema_alloc_node();
	if (schema == NULL)
		goto cleanup;

	pci_iov_build_pf_schema(schema, &pf_driver);
	pci_iov_build_vf_schema(schema, &vf_driver);

	if (nvlist_error(schema) != 0)
		goto cleanup;

	return (schema);

cleanup:
	nvlist_destroy(schema);
	nvlist_destroy(pf_driver);
	nvlist_destroy(vf_driver);
	return (NULL);
}
Ejemplo n.º 2
0
static nvlist_t *
pci_iov_get_vf_subsystem_schema(void)
{
	nvlist_t *vf;

	vf = pci_iov_schema_alloc_node();
	if (vf == NULL)
		return (NULL);

	pci_iov_schema_add_bool(vf, "passthrough", IOV_SCHEMA_HASDEFAULT, 0);

	return (vf);
}
Ejemplo n.º 3
0
static nvlist_t *
pci_iov_get_pf_subsystem_schema(void)
{
	nvlist_t *pf;

	pf = pci_iov_schema_alloc_node();
	if (pf == NULL)
		return (NULL);

	pci_iov_schema_add_uint16(pf, "num_vfs", IOV_SCHEMA_REQUIRED, -1);
	pci_iov_schema_add_string(pf, "device", IOV_SCHEMA_REQUIRED, NULL);

	return (pf);
}
Ejemplo n.º 4
0
static int
t4iov_attach_child(device_t dev)
{
	struct t4iov_softc *sc;
#ifdef PCI_IOV
	nvlist_t *pf_schema, *vf_schema;
#endif
	device_t pdev;
	int error;

	sc = device_get_softc(dev);
	MPASS(!sc->sc_attached);

	/*
	 * PF0-3 are associated with a specific port on the NIC (PF0
	 * with port 0, etc.).  Ask the PF4 driver for the device for
	 * this function's associated port to determine if the port is
	 * present.
	 */
	error = T4_READ_PORT_DEVICE(sc->sc_main, pci_get_function(dev), &pdev);
	if (error)
		return (0);

#ifdef PCI_IOV
	pf_schema = pci_iov_schema_alloc_node();
	vf_schema = pci_iov_schema_alloc_node();
	error = pci_iov_attach_name(dev, pf_schema, vf_schema, "%s",
	    device_get_nameunit(pdev));
	if (error) {
		device_printf(dev, "Failed to initialize SR-IOV: %d\n", error);
		return (0);
	}
#endif

	sc->sc_attached = true;
	return (0);
}
Ejemplo n.º 5
0
static void
pci_iov_build_vf_schema(nvlist_t *schema, nvlist_t **driver_schema)
{
	nvlist_t *vf_schema, *iov_schema;

	vf_schema = pci_iov_schema_alloc_node();
	if (vf_schema == NULL) {
		nvlist_set_error(schema, ENOMEM);
		return;
	}

	iov_schema = pci_iov_get_vf_subsystem_schema();

	/*
	 * Note that if either *driver_schema or iov_schema is NULL, then
	 * nvlist_move_nvlist will put the schema in the error state and
	 * SR-IOV will fail to initialize later, so we don't have to explicitly
	 * handle that case.
	 */
	nvlist_move_nvlist(vf_schema, DRIVER_CONFIG_NAME, *driver_schema);
	nvlist_move_nvlist(vf_schema, IOV_CONFIG_NAME, iov_schema);
	nvlist_move_nvlist(schema, VF_SCHEMA_NAME, vf_schema);
	*driver_schema = NULL;
}