Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/dev/ic Pull up revision 1.44 (via patch, requested ...
details: https://anonhg.NetBSD.org/src/rev/05ead39c6d94
branches: netbsd-1-6
changeset: 529940:05ead39c6d94
user: he <he%NetBSD.org@localhost>
date: Sun Jan 26 16:36:07 2003 +0000
description:
Pull up revision 1.44 (via patch, requested by bouyer in ticket #1086):
Use a properly zeroed buffer to pad small packets to make
sure the chip doesn't send random data.
diffstat:
sys/dev/ic/rtl81x9.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diffs (92 lines):
diff -r 7ff54832537b -r 05ead39c6d94 sys/dev/ic/rtl81x9.c
--- a/sys/dev/ic/rtl81x9.c Sun Jan 26 16:19:52 2003 +0000
+++ b/sys/dev/ic/rtl81x9.c Sun Jan 26 16:36:07 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtl81x9.c,v 1.40 2001/11/13 13:14:43 lukem Exp $ */
+/* $NetBSD: rtl81x9.c,v 1.40.10.1 2003/01/26 16:36:07 he Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.40 2001/11/13 13:14:43 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.40.10.1 2003/01/26 16:36:07 he Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -171,6 +171,8 @@
CSR_WRITE_1(sc, RTK_EECMD, \
CSR_READ_1(sc, RTK_EECMD) & ~(x))
+#define ETHER_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
+
/*
* Send a read command and address to the EEPROM, check for ACK.
*/
@@ -1292,8 +1294,11 @@
* Load the DMA map. If this fails, the packet didn't
* fit in one DMA segment, and we need to copy. Note,
* the packet must also be aligned.
+ * if the packet is too small, copy it too, so we're sure
+ * so have enouth room for the pad buffer.
*/
if ((mtod(m_head, uintptr_t) & 3) != 0 ||
+ m_head->m_pkthdr.len < ETHER_PAD_LEN ||
bus_dmamap_load_mbuf(sc->sc_dmat, txd->txd_dmamap,
m_head, BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) {
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
@@ -1315,6 +1320,13 @@
mtod(m_new, caddr_t));
m_new->m_pkthdr.len = m_new->m_len =
m_head->m_pkthdr.len;
+ if (m_head->m_pkthdr.len < ETHER_PAD_LEN) {
+ memset(
+ mtod(m_new, caddr_t) + m_head->m_pkthdr.len,
+ 0, ETHER_PAD_LEN - m_head->m_pkthdr.len);
+ m_new->m_pkthdr.len = m_new->m_len =
+ ETHER_PAD_LEN;
+ }
error = bus_dmamap_load_mbuf(sc->sc_dmat,
txd->txd_dmamap, m_new,
BUS_DMA_WRITE|BUS_DMA_NOWAIT);
@@ -1325,6 +1337,14 @@
}
}
IFQ_DEQUEUE(&ifp->if_snd, m_head);
+#if NBPFILTER > 0
+ /*
+ * If there's a BPF listener, bounce a copy of this frame
+ * to him.
+ */
+ if (ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, m_head);
+#endif
if (m_new != NULL) {
m_freem(m_head);
m_head = m_new;
@@ -1334,14 +1354,6 @@
SIMPLEQ_REMOVE_HEAD(&sc->rtk_tx_free, txd, txd_q);
SIMPLEQ_INSERT_TAIL(&sc->rtk_tx_dirty, txd, txd_q);
-#if NBPFILTER > 0
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp->if_bpf, m_head);
-#endif
/*
* Transmit the frame.
*/
@@ -1350,8 +1362,6 @@
BUS_DMASYNC_PREWRITE);
len = txd->txd_dmamap->dm_segs[0].ds_len;
- if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN))
- len = (ETHER_MIN_LEN - ETHER_CRC_LEN);
CSR_WRITE_4(sc, txd->txd_txaddr,
txd->txd_dmamap->dm_segs[0].ds_addr);
Home |
Main Index |
Thread Index |
Old Index