mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Support checksum offloading for TCP/IPV6 and UDP/IPV6.
Support SCTP checksum offloading for SCTP/IPV6. Support SCTP checksum offloading on all controllers except 82575. Reviewed by: sbruno@, erj@ MFC after: 4 weeks Differential Revision: D5193
This commit is contained in:
parent
9e9a7326dd
commit
e180827abc
2 changed files with 53 additions and 7 deletions
|
|
@ -1184,10 +1184,27 @@ igb_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#if __FreeBSD_version >= 1000000
|
||||
/* HW cannot turn these on/off separately */
|
||||
if (mask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
|
||||
ifp->if_capenable ^= IFCAP_RXCSUM;
|
||||
ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
|
||||
reinit = 1;
|
||||
}
|
||||
if (mask & IFCAP_TXCSUM) {
|
||||
ifp->if_capenable ^= IFCAP_TXCSUM;
|
||||
reinit = 1;
|
||||
}
|
||||
if (mask & IFCAP_TXCSUM_IPV6) {
|
||||
ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
|
||||
reinit = 1;
|
||||
}
|
||||
#else
|
||||
if (mask & IFCAP_HWCSUM) {
|
||||
ifp->if_capenable ^= IFCAP_HWCSUM;
|
||||
reinit = 1;
|
||||
}
|
||||
#endif
|
||||
if (mask & IFCAP_TSO4) {
|
||||
ifp->if_capenable ^= IFCAP_TSO4;
|
||||
reinit = 1;
|
||||
|
|
@ -1266,14 +1283,26 @@ igb_init_locked(struct adapter *adapter)
|
|||
/* Set hardware offload abilities */
|
||||
ifp->if_hwassist = 0;
|
||||
if (ifp->if_capenable & IFCAP_TXCSUM) {
|
||||
#if __FreeBSD_version >= 1000000
|
||||
ifp->if_hwassist |= (CSUM_IP_TCP | CSUM_IP_UDP);
|
||||
if (adapter->hw.mac.type != e1000_82575)
|
||||
ifp->if_hwassist |= CSUM_IP_SCTP;
|
||||
#else
|
||||
ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
|
||||
#if __FreeBSD_version >= 800000
|
||||
if ((adapter->hw.mac.type == e1000_82576) ||
|
||||
(adapter->hw.mac.type == e1000_82580))
|
||||
if (adapter->hw.mac.type != e1000_82575)
|
||||
ifp->if_hwassist |= CSUM_SCTP;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 1000000
|
||||
if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) {
|
||||
ifp->if_hwassist |= (CSUM_IP6_TCP | CSUM_IP6_UDP);
|
||||
if (adapter->hw.mac.type != e1000_82575)
|
||||
ifp->if_hwassist |= CSUM_IP6_SCTP;
|
||||
}
|
||||
#endif
|
||||
if (ifp->if_capenable & IFCAP_TSO)
|
||||
ifp->if_hwassist |= CSUM_TSO;
|
||||
|
||||
|
|
@ -3160,6 +3189,9 @@ igb_setup_interface(device_t dev, struct adapter *adapter)
|
|||
ifp->if_capabilities = ifp->if_capenable = 0;
|
||||
|
||||
ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
|
||||
#if __FreeBSD_version >= 1000000
|
||||
ifp->if_capabilities |= IFCAP_HWCSUM_IPV6;
|
||||
#endif
|
||||
ifp->if_capabilities |= IFCAP_TSO;
|
||||
ifp->if_capabilities |= IFCAP_JUMBO_MTU;
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
|
|
@ -3933,17 +3965,29 @@ igb_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp,
|
|||
|
||||
switch (ipproto) {
|
||||
case IPPROTO_TCP:
|
||||
#if __FreeBSD_version >= 1000000
|
||||
if (mp->m_pkthdr.csum_flags & (CSUM_IP_TCP | CSUM_IP6_TCP))
|
||||
#else
|
||||
if (mp->m_pkthdr.csum_flags & CSUM_TCP)
|
||||
#endif
|
||||
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP;
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
#if __FreeBSD_version >= 1000000
|
||||
if (mp->m_pkthdr.csum_flags & (CSUM_IP_UDP | CSUM_IP6_UDP))
|
||||
#else
|
||||
if (mp->m_pkthdr.csum_flags & CSUM_UDP)
|
||||
#endif
|
||||
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_UDP;
|
||||
break;
|
||||
|
||||
#if __FreeBSD_version >= 800000
|
||||
case IPPROTO_SCTP:
|
||||
#if __FreeBSD_version >= 1000000
|
||||
if (mp->m_pkthdr.csum_flags & (CSUM_IP_SCTP | CSUM_IP6_SCTP))
|
||||
#else
|
||||
if (mp->m_pkthdr.csum_flags & CSUM_SCTP)
|
||||
#endif
|
||||
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_SCTP;
|
||||
break;
|
||||
#endif
|
||||
|
|
@ -4701,8 +4745,7 @@ igb_initialize_receive_units(struct adapter *adapter)
|
|||
rxcsum |= E1000_RXCSUM_PCSD;
|
||||
#if __FreeBSD_version >= 800000
|
||||
/* For SCTP Offload */
|
||||
if (((hw->mac.type == e1000_82576) ||
|
||||
(hw->mac.type == e1000_82580)) &&
|
||||
if ((hw->mac.type != e1000_82575) &&
|
||||
(ifp->if_capenable & IFCAP_RXCSUM))
|
||||
rxcsum |= E1000_RXCSUM_CRCOFL;
|
||||
#endif
|
||||
|
|
@ -4711,8 +4754,7 @@ igb_initialize_receive_units(struct adapter *adapter)
|
|||
if (ifp->if_capenable & IFCAP_RXCSUM) {
|
||||
rxcsum |= E1000_RXCSUM_IPPCSE;
|
||||
#if __FreeBSD_version >= 800000
|
||||
if ((adapter->hw.mac.type == e1000_82576) ||
|
||||
(adapter->hw.mac.type == e1000_82580))
|
||||
if (adapter->hw.mac.type != e1000_82575)
|
||||
rxcsum |= E1000_RXCSUM_CRCOFL;
|
||||
#endif
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -291,7 +291,11 @@
|
|||
#define ETH_ADDR_LEN 6
|
||||
|
||||
/* Offload bits in mbuf flag */
|
||||
#if __FreeBSD_version >= 800000
|
||||
#if __FreeBSD_version >= 1000000
|
||||
#define CSUM_OFFLOAD_IPV4 (CSUM_IP|CSUM_IP_TCP|CSUM_IP_UDP|CSUM_IP_SCTP)
|
||||
#define CSUM_OFFLOAD_IPV6 (CSUM_IP6_TCP|CSUM_IP6_UDP|CSUM_IP6_SCTP)
|
||||
#define CSUM_OFFLOAD (CSUM_OFFLOAD_IPV4|CSUM_OFFLOAD_IPV6)
|
||||
#elif __FreeBSD_version >= 800000
|
||||
#define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP)
|
||||
#else
|
||||
#define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP)
|
||||
|
|
|
|||
Loading…
Reference in a new issue