summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2003-12-25 06:04:40 +0000
committerwpaul <wpaul@FreeBSD.org>2003-12-25 06:04:40 +0000
commit41facc2cd68777079dd8e655f83ed4cce3538f91 (patch)
treebb19c8c3f36fb73d2988fb6a4f982f2dd595413d
parent088a25112c830fb17d05924c0aac145ac6bcaa5c (diff)
downloadFreeBSD-src-41facc2cd68777079dd8e655f83ed4cce3538f91.zip
FreeBSD-src-41facc2cd68777079dd8e655f83ed4cce3538f91.tar.gz
Avoid using any of the ndis_packet/ndis_packet_private fields for
mbuf<->packet housekeeping. Instead, add a couple of extra fields to the end of ndis_packet. These should be invisible to the Windows driver module. This also lets me get rid of a little bit of evil from ndis_ptom() (frobbing of the ext_buf field instead of relying on the MEXTADD() macro).
-rw-r--r--sys/compat/ndis/kern_ndis.c25
-rw-r--r--sys/compat/ndis/ndis_var.h8
-rw-r--r--sys/dev/if_ndis/if_ndis.c14
3 files changed, 24 insertions, 23 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 6606b45..3186d8b 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -328,8 +328,8 @@ ndis_flush_sysctls(arg)
}
void
-ndis_return_packet(packet, arg)
- void *packet;
+ndis_return_packet(buf, arg)
+ void *buf; /* not used */
void *arg;
{
struct ndis_softc *sc;
@@ -337,25 +337,25 @@ ndis_return_packet(packet, arg)
ndis_packet *p;
__stdcall ndis_return_handler returnfunc;
- if (arg == NULL || packet == NULL)
+ if (arg == NULL)
return;
- p = packet;
+ p = arg;
/* Decrement refcount. */
- p->np_private.npp_count--;
+ p->np_refcnt--;
/* Release packet when refcount hits zero, otherwise return. */
- if (p->np_private.npp_count)
+ if (p->np_refcnt)
return;
- sc = arg;
+ sc = p->np_softc;
returnfunc = sc->ndis_chars.nmc_return_packet_func;
adapter = sc->ndis_block.nmb_miniportadapterctx;
if (returnfunc == NULL)
- ndis_free_packet((ndis_packet *)packet);
+ ndis_free_packet(p);
else
- returnfunc(adapter, (ndis_packet *)packet);
+ returnfunc(adapter, p);
return;
}
@@ -474,7 +474,7 @@ ndis_ptom(m0, p)
priv = &p->np_private;
buf = priv->npp_head;
- priv->npp_count = 0;
+ p->np_refcnt = 0;
for (buf = priv->npp_head; buf != NULL; buf = buf->nb_next) {
if (buf == priv->npp_head)
@@ -489,9 +489,8 @@ ndis_ptom(m0, p)
m->m_len = buf->nb_bytecount;
m->m_data = MDL_VA(buf);
MEXTADD(m, m->m_data, m->m_len, ndis_return_packet,
- p->np_rsvd[0], 0, EXT_NDIS);
- m->m_ext.ext_buf = (void *)p; /* XXX */
- priv->npp_count++;
+ p, 0, EXT_NDIS);
+ p->np_refcnt++;
totlen += m->m_len;
if (m->m_flags & MT_HEADER)
*m0 = m;
diff --git a/sys/compat/ndis/ndis_var.h b/sys/compat/ndis/ndis_var.h
index 7296065..353069a 100644
--- a/sys/compat/ndis/ndis_var.h
+++ b/sys/compat/ndis/ndis_var.h
@@ -829,7 +829,6 @@ struct ndis_packet {
} np_macrsvd;
} u;
uint32_t *np_rsvd[2];
- uint8_t np_proto_rsvd[1];
/*
* This next part is probably wrong, but we need some place
@@ -838,6 +837,13 @@ struct ndis_packet {
ndis_packet_oob np_oob;
ndis_packet_extension np_ext;
ndis_sc_list np_sclist;
+
+ /* BSD-specific stuff which should be invisible to drivers. */
+
+ uint32_t np_refcnt;
+ void *np_softc;
+ void *np_m0;
+ int np_txidx;
};
typedef struct ndis_packet ndis_packet;
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 79db5e9..e199567 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -651,7 +651,7 @@ ndis_rxeof(adapter, packets, pktcnt)
for (i = 0; i < pktcnt; i++) {
p = packets[i];
/* Stash the softc here so ptom can use it. */
- p->np_rsvd[0] = (uint32_t *)sc;
+ p->np_softc = sc;
if (ndis_ptom(&m0, p)) {
printf ("ndis%d: ptom failed\n", sc->ndis_unit);
ndis_return_packet(sc, p);
@@ -686,13 +686,10 @@ ndis_txeof(adapter, packet, status)
sc = (struct ndis_softc *)block->nmb_ifp;
ifp = block->nmb_ifp;
- if (packet->np_rsvd[1] == NULL)
- panic("NDIS driver corrupted reserved packet fields");
-
NDIS_LOCK(sc);
- m = (struct mbuf *)packet->np_rsvd[1];
- idx = (int)packet->np_rsvd[0];
+ m = packet->np_m0;
+ idx = packet->np_txidx;
ifp->if_opackets++;
if (sc->ndis_sc)
bus_dmamap_unload(sc->ndis_ttag, sc->ndis_tmaps[idx]);
@@ -900,9 +897,8 @@ ndis_start(ifp)
* so we can free it later.
*/
- (sc->ndis_txarray[sc->ndis_txidx])->np_rsvd[0] =
- (uint32_t *)sc->ndis_txidx;
- (sc->ndis_txarray[sc->ndis_txidx])->np_rsvd[1] = (uint32_t *)m;
+ (sc->ndis_txarray[sc->ndis_txidx])->np_txidx = sc->ndis_txidx;
+ (sc->ndis_txarray[sc->ndis_txidx])->np_m0 = m;
/*
* Do scatter/gather processing, if driver requested it.
OpenPOWER on IntegriCloud