Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/if_ixl.c
Show First 20 Lines • Show All 721 Lines • ▼ Show 20 Lines | ifx->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, | ||||
ixl_unregister_vlan, ifx, EVENTHANDLER_PRI_FIRST); | ixl_unregister_vlan, ifx, EVENTHANDLER_PRI_FIRST); | ||||
#ifdef PCI_IOV | #ifdef PCI_IOV | ||||
/* SR-IOV is only supported when MSI-X is in use. */ | /* SR-IOV is only supported when MSI-X is in use. */ | ||||
if (pf->msix > 1) { | if (pf->msix > 1) { | ||||
pf_schema = pci_iov_schema_alloc_node(); | pf_schema = pci_iov_schema_alloc_node(); | ||||
vf_schema = pci_iov_schema_alloc_node(); | vf_schema = pci_iov_schema_alloc_node(); | ||||
pci_iov_schema_add_unicast_mac(vf_schema, "mac-addr", 0, NULL); | pci_iov_schema_add_unicast_mac(vf_schema, "mac-addr", 0, NULL); | ||||
pci_iov_schema_add_bool(vf_schema, "mac-anti-spoof", | |||||
IOV_SCHEMA_HASDEFAULT, TRUE); | |||||
pci_iov_schema_add_bool(vf_schema, "allow-set-mac", | |||||
IOV_SCHEMA_HASDEFAULT, FALSE); | |||||
pci_iov_schema_add_bool(vf_schema, "allow-promisc", | |||||
IOV_SCHEMA_HASDEFAULT, FALSE); | |||||
iov_error = pci_iov_attach(dev, pf_schema, vf_schema); | iov_error = pci_iov_attach(dev, pf_schema, vf_schema); | ||||
if (iov_error != 0) | if (iov_error != 0) | ||||
device_printf(dev, | device_printf(dev, | ||||
"Failed to initialize SR-IOV (error=%d)\n", | "Failed to initialize SR-IOV (error=%d)\n", | ||||
iov_error); | iov_error); | ||||
} | } | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 4,489 Lines • ▼ Show 20 Lines | ixl_vf_alloc_vsi(struct ixl_pf *pf, struct ixl_vf *vf) | ||||
vsi_ctx.vf_num = hw->func_caps.vf_base_id + vf->vf_num; | vsi_ctx.vf_num = hw->func_caps.vf_base_id + vf->vf_num; | ||||
vsi_ctx.flags = I40E_AQ_VSI_TYPE_VF; | vsi_ctx.flags = I40E_AQ_VSI_TYPE_VF; | ||||
bzero(&vsi_ctx.info, sizeof(vsi_ctx.info)); | bzero(&vsi_ctx.info, sizeof(vsi_ctx.info)); | ||||
vsi_ctx.info.valid_sections = htole16(I40E_AQ_VSI_PROP_SWITCH_VALID); | vsi_ctx.info.valid_sections = htole16(I40E_AQ_VSI_PROP_SWITCH_VALID); | ||||
vsi_ctx.info.switch_id = htole16(0); | vsi_ctx.info.switch_id = htole16(0); | ||||
/* TODO: security: optionally enable vlan/mac anti-spoof. */ | |||||
vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_SECURITY_VALID); | vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_SECURITY_VALID); | ||||
vsi_ctx.info.sec_flags = 0; | vsi_ctx.info.sec_flags = 0; | ||||
if (vf->vf_flags & VF_FLAG_MAC_ANTI_SPOOF) | |||||
vsi_ctx.info.sec_flags |= I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK; | |||||
vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_VLAN_VALID); | vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_VLAN_VALID); | ||||
vsi_ctx.info.port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL | | vsi_ctx.info.port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL | | ||||
I40E_AQ_VSI_PVLAN_EMOD_NOTHING; | I40E_AQ_VSI_PVLAN_EMOD_NOTHING; | ||||
vsi_ctx.info.valid_sections |= | vsi_ctx.info.valid_sections |= | ||||
htole16(I40E_AQ_VSI_PROP_QUEUE_MAP_VALID); | htole16(I40E_AQ_VSI_PROP_QUEUE_MAP_VALID); | ||||
vsi_ctx.info.mapping_flags = htole16(I40E_AQ_VSI_QUE_MAP_NONCONTIG); | vsi_ctx.info.mapping_flags = htole16(I40E_AQ_VSI_QUE_MAP_NONCONTIG); | ||||
▲ Show 20 Lines • Show All 1,403 Lines • ▼ Show 20 Lines | ixl_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *params) | ||||
error = ixl_vf_setup_vsi(pf, vf); | error = ixl_vf_setup_vsi(pf, vf); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
if (nvlist_exists_binary(params, "mac-addr")) { | if (nvlist_exists_binary(params, "mac-addr")) { | ||||
mac = nvlist_get_binary(params, "mac-addr", &size); | mac = nvlist_get_binary(params, "mac-addr", &size); | ||||
bcopy(mac, vf->mac, ETHER_ADDR_LEN); | bcopy(mac, vf->mac, ETHER_ADDR_LEN); | ||||
if (nvlist_get_bool(params, "allow-set-mac")) | |||||
vf->vf_flags |= VF_FLAG_SET_MAC_CAP; | |||||
} else | } else | ||||
/* | |||||
* If the administrator has not specified a MAC address then | |||||
* we must allow the VF to choose one. | |||||
*/ | |||||
vf->vf_flags |= VF_FLAG_SET_MAC_CAP; | vf->vf_flags |= VF_FLAG_SET_MAC_CAP; | ||||
if (nvlist_get_bool(params, "mac-anti-spoof")) | |||||
vf->vf_flags |= VF_FLAG_MAC_ANTI_SPOOF; | |||||
if (nvlist_get_bool(params, "allow-promisc")) | |||||
vf->vf_flags |= VF_FLAG_PROMISC_CAP; | |||||
vf->vf_flags |= VF_FLAG_VLAN_CAP; | vf->vf_flags |= VF_FLAG_VLAN_CAP; | ||||
ixl_reset_vf(pf, vf); | ixl_reset_vf(pf, vf); | ||||
out: | out: | ||||
IXL_PF_UNLOCK(pf); | IXL_PF_UNLOCK(pf); | ||||
if (error == 0) { | if (error == 0) { | ||||
snprintf(sysctl_name, sizeof(sysctl_name), "vf%d", vfnum); | snprintf(sysctl_name, sizeof(sysctl_name), "vf%d", vfnum); | ||||
ixl_add_vsi_sysctls(pf, &vf->vsi, &vf->ctx, sysctl_name); | ixl_add_vsi_sysctls(pf, &vf->vsi, &vf->ctx, sysctl_name); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* PCI_IOV */ | #endif /* PCI_IOV */ |