MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vlan_capabilities

Function vlan_capabilities

freebsd/net/if_vlan.c:1698–1820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1696}
1697
1698static void
1699vlan_capabilities(struct ifvlan *ifv)
1700{
1701 struct ifnet *p;
1702 struct ifnet *ifp;
1703 struct ifnet_hw_tsomax hw_tsomax;
1704 int cap = 0, ena = 0, mena;
1705 u_long hwa = 0;
1706
1707 NET_EPOCH_ASSERT();
1708 VLAN_SXLOCK_ASSERT();
1709
1710 p = PARENT(ifv);
1711 ifp = ifv->ifv_ifp;
1712
1713 /* Mask parent interface enabled capabilities disabled by user. */
1714 mena = p->if_capenable & ifv->ifv_capenable;
1715
1716 /*
1717 * If the parent interface can do checksum offloading
1718 * on VLANs, then propagate its hardware-assisted
1719 * checksumming flags. Also assert that checksum
1720 * offloading requires hardware VLAN tagging.
1721 */
1722 if (p->if_capabilities & IFCAP_VLAN_HWCSUM)
1723 cap |= p->if_capabilities & (IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6);
1724 if (p->if_capenable & IFCAP_VLAN_HWCSUM &&
1725 p->if_capenable & IFCAP_VLAN_HWTAGGING) {
1726 ena |= mena & (IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6);
1727 if (ena & IFCAP_TXCSUM)
1728 hwa |= p->if_hwassist & (CSUM_IP | CSUM_TCP |
1729 CSUM_UDP | CSUM_SCTP);
1730 if (ena & IFCAP_TXCSUM_IPV6)
1731 hwa |= p->if_hwassist & (CSUM_TCP_IPV6 |
1732 CSUM_UDP_IPV6 | CSUM_SCTP_IPV6);
1733 }
1734
1735 /*
1736 * If the parent interface can do TSO on VLANs then
1737 * propagate the hardware-assisted flag. TSO on VLANs
1738 * does not necessarily require hardware VLAN tagging.
1739 */
1740 memset(&hw_tsomax, 0, sizeof(hw_tsomax));
1741 if_hw_tsomax_common(p, &hw_tsomax);
1742 if_hw_tsomax_update(ifp, &hw_tsomax);
1743 if (p->if_capabilities & IFCAP_VLAN_HWTSO)
1744 cap |= p->if_capabilities & IFCAP_TSO;
1745 if (p->if_capenable & IFCAP_VLAN_HWTSO) {
1746 ena |= mena & IFCAP_TSO;
1747 if (ena & IFCAP_TSO)
1748 hwa |= p->if_hwassist & CSUM_TSO;
1749 }
1750
1751 /*
1752 * If the parent interface can do LRO and checksum offloading on
1753 * VLANs, then guess it may do LRO on VLANs. False positive here
1754 * cost nothing, while false negative may lead to some confusions.
1755 */

Callers 3

vlan_configFunction · 0.85
vlan_trunk_capabilitiesFunction · 0.85
vlan_ioctlFunction · 0.85

Calls 3

memsetFunction · 0.85
if_hw_tsomax_commonFunction · 0.85
if_hw_tsomax_updateFunction · 0.85

Tested by

no test coverage detected