diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-02-27 22:39:40 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-02-27 22:39:40 +0000 |
commit | f96396f4809801c6a2c6cac49790b3bbe1c079bc (patch) | |
tree | dd78db4b4892676a7ac9b1670e6152574db40c3b | |
parent | a133e84287086d2a5b18417eb76ab76328ce7b12 (diff) |
Enable HW Tx checksum offloading and VLAN tag insertion. From brad@.
-rw-r--r-- | sys/dev/pci/if_xge.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/if_xgereg.h | 5 |
2 files changed, 28 insertions, 8 deletions
diff --git a/sys/dev/pci/if_xge.c b/sys/dev/pci/if_xge.c index d96a188d9c9..6966dc2f546 100644 --- a/sys/dev/pci/if_xge.c +++ b/sys/dev/pci/if_xge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xge.c,v 1.36 2007/02/27 22:18:53 kettenis Exp $ */ +/* $OpenBSD: if_xge.c,v 1.37 2007/02/27 22:39:39 kettenis Exp $ */ /* $NetBSD: if_xge.c,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -645,7 +645,12 @@ xge_attach(struct device *parent, struct device *self, void *aux) IFQ_SET_MAXLEN(&ifp->if_snd, NTXDESCS - 1); IFQ_SET_READY(&ifp->if_snd); - ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 | + IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4; + +#if NVLAN > 0 + ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; +#endif /* * Attach the interface. @@ -1103,6 +1108,9 @@ xge_start(struct ifnet *ifp) struct mbuf *m; uint64_t par, lcr; int nexttx = 0, ntxd, error, i; +#if NVLAN > 0 + struct ifvlan *ifv = NULL; +#endif if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING) return; @@ -1145,14 +1153,23 @@ xge_start(struct ifnet *ifp) txd->txd_control1 |= TXD_CTL1_OWN|TXD_CTL1_GCF; txd->txd_control2 = TXD_CTL2_UTIL; -#ifdef XGE_CKSUM - if (m->m_pkthdr.csum_flags & M_CSUM_IPv4) +#if NVLAN > 0 + if ((m->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) && + m->m_pkthdr.rcvif != NULL) { + ifv = m->m_pkthdr.rcvif->if_softc; + + txd->txd_control2 |= TXD_CTL2_VLANE; + txd->txd_control2 |= TXD_CTL2_VLANT(ifv->ifv_tag); + } +#endif + + if (m->m_pkthdr.csum_flags & M_IPV4_CSUM_OUT) txd->txd_control2 |= TXD_CTL2_CIPv4; - if (m->m_pkthdr.csum_flags & M_CSUM_TCPv4) + if (m->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT) txd->txd_control2 |= TXD_CTL2_CTCP; - if (m->m_pkthdr.csum_flags & M_CSUM_UDPv4) + if (m->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT) txd->txd_control2 |= TXD_CTL2_CUDP; -#endif + txd[ntxd].txd_control1 |= TXD_CTL1_GCL; bus_dmamap_sync(sc->sc_dmat, dmp, 0, dmp->dm_mapsize, diff --git a/sys/dev/pci/if_xgereg.h b/sys/dev/pci/if_xgereg.h index 176acd1cfac..0744a30889a 100644 --- a/sys/dev/pci/if_xgereg.h +++ b/sys/dev/pci/if_xgereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xgereg.h,v 1.3 2007/02/27 22:18:53 kettenis Exp $ */ +/* $OpenBSD: if_xgereg.h,v 1.4 2007/02/27 22:39:39 kettenis Exp $ */ /* $NetBSD: if_xgereg.h,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -235,6 +235,9 @@ struct txd { #define TXD_CTL2_CIPv4 (1ULL << 58) /* Calculate IPv4 header checksum */ #define TXD_CTL2_CTCP (1ULL << 57) /* Calculate TCP checksum */ #define TXD_CTL2_CUDP (1ULL << 56) /* Calculate UDP checksum */ +#define TXD_CTL2_VLANE (1ULL << 48) /* Enable VLAN tag insertion */ +#define TXD_CTL2_VLANT(x) ((uint64_t)(x) << 32) + /* * Receive DMA registers */ |