[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree
zrouter-src-freebsd at zrouter.org
zrouter-src-freebsd at zrouter.org
Tue Oct 16 10:36:42 UTC 2012
details: http://zrouter.org/hg/FreeBSD/head//rev/d49f6df4160d
changeset: 538:d49f6df4160d
user: Aleksandr Rybalko <ray at ddteam.net>
date: Tue Oct 16 13:36:10 2012 +0300
description:
* Expose CSUM ability to network stack.
* Tell DMA to start from +2 position on RX
diffstat:
head/sys/mips/atheros/if_arge.c | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)
diffs (90 lines):
diff -r cdfc72b65a60 -r d49f6df4160d head/sys/mips/atheros/if_arge.c
--- a/head/sys/mips/atheros/if_arge.c Tue Sep 25 11:48:54 2012 +0300
+++ b/head/sys/mips/atheros/if_arge.c Tue Oct 16 13:36:10 2012 +0300
@@ -146,7 +146,6 @@
static int arge_dma_alloc(struct arge_softc *);
static void arge_dma_free(struct arge_softc *);
static int arge_newbuf(struct arge_softc *, int);
-static __inline void arge_fixup_rx(struct mbuf *);
static device_method_t arge_methods[] = {
/* Device interface */
@@ -350,6 +349,8 @@
#ifdef DEVICE_POLLING
ifp->if_capabilities |= IFCAP_POLLING;
#endif
+ ifp->if_capabilities |= IFCAP_RXCSUM|IFCAP_TXCSUM;
+ ifp->if_capenable |= IFCAP_RXCSUM|IFCAP_TXCSUM;
is_base_mac_empty = 1;
for (i = 0; i < ETHER_ADDR_LEN; i++) {
@@ -1567,8 +1568,10 @@
desc = rxd->desc;
if (segs[0].ds_addr & 3)
panic("RX packet address unaligned");
- desc->packet_addr = segs[0].ds_addr;
- desc->packet_ctrl = ARGE_DESC_EMPTY | ARGE_DMASIZE(segs[0].ds_len);
+ desc->packet_addr = segs[0].ds_addr + ETHER_ALIGN;
+ desc->packet_ctrl = ARGE_DESC_EMPTY |
+ ARGE_DMASIZE(segs[0].ds_len - ETHER_ALIGN);
+ m->m_data += ETHER_ALIGN;
bus_dmamap_sync(sc->arge_cdata.arge_rx_ring_tag,
sc->arge_cdata.arge_rx_ring_map,
@@ -1577,25 +1580,6 @@
return (0);
}
-static __inline void
-arge_fixup_rx(struct mbuf *m)
-{
- int i;
- uint16_t *src, *dst;
-
- src = mtod(m, uint16_t *);
- dst = src - 1;
-
- for (i = 0; i < m->m_len / sizeof(uint16_t); i++) {
- *dst++ = *src++;
- }
-
- if (m->m_len % sizeof(uint16_t))
- *(uint8_t *)dst = *(uint8_t *)src;
-
- m->m_data -= ETHER_ALIGN;
-}
-
#ifdef DEVICE_POLLING
static int
arge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
@@ -1614,7 +1598,6 @@
}
#endif /* DEVICE_POLLING */
-
static void
arge_tx_locked(struct arge_softc *sc)
{
@@ -1716,13 +1699,21 @@
BUS_DMASYNC_POSTREAD);
m = rxd->rx_m;
- arge_fixup_rx(m);
m->m_pkthdr.rcvif = ifp;
/* Skip 4 bytes of CRC */
m->m_pkthdr.len = m->m_len = packet_len - ETHER_CRC_LEN;
ifp->if_ipackets++;
rx_npkts++;
+ /* check for crc errors */
+ if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) {
+ /*check for valid checksum*/
+ m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
+ m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
+ m->m_pkthdr.csum_flags |= CSUM_DATA_VALID |
+ CSUM_PSEUDO_HDR;
+ m->m_flags &= ~M_HASFCS;
+ }
ARGE_UNLOCK(sc);
(*ifp->if_input)(ifp, m);
ARGE_LOCK(sc);
More information about the Zrouter-src-freebsd
mailing list