summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2004-01-02 04:31:06 +0000
committerwpaul <wpaul@FreeBSD.org>2004-01-02 04:31:06 +0000
commit29f66743387caea20d00f8ca18fe77dbdc30b467 (patch)
tree8c44e4408f2ae6f2841d0e28fa3468e45f244a6e /sys/compat
parentd20e44e98c5c75d9defbaa665dce5fd51b9fa1ce (diff)
downloadFreeBSD-src-29f66743387caea20d00f8ca18fe77dbdc30b467.zip
FreeBSD-src-29f66743387caea20d00f8ca18fe77dbdc30b467.tar.gz
Clean up ndiscvt a bit (leaving out the -i flag didn't work) and add
copyrights to the inf parser files. Add a -n flag to ndiscvt to allow the user to override the default device name of NDIS devices. Instead of "ndis0, ndis1, etc..." you can have "foo0, foo1, etc..." This allows you to have more than one kind of NDIS device in the kernel at the same time. Convert from printf() to device_printf() in if_ndis.c, kern_ndis.c and subr_ndis.c. Create UMA zones for ndis_packet and ndis_buffer structs allocated on transmit. The zones are created and destroyed in the modevent handler in kern_ndis.c. printf() and UMA changes submitted by green@freebsd.org
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/ndis/kern_ndis.c63
-rw-r--r--sys/compat/ndis/subr_ndis.c9
2 files changed, 54 insertions, 18 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 53bfa77..3ab391a 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/rman.h>
+#include <vm/uma.h>
+
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
@@ -82,6 +84,8 @@ __stdcall static void ndis_setdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_getdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
+static uma_zone_t ndis_packet_zone, ndis_buffer_zone;
+
/*
* This allows us to export our symbols to other modules.
* Note that we call ourselves 'ndisapi' to avoid a namespace
@@ -91,7 +95,28 @@ __stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
static int
ndis_modevent(module_t mod, int cmd, void *arg)
{
- return(0);
+ int error = 0;
+
+ switch (cmd) {
+ case MOD_LOAD:
+ ndis_packet_zone = uma_zcreate("NDIS packet",
+ sizeof(ndis_packet), NULL, NULL, NULL,
+ NULL, UMA_ALIGN_PTR, 0);
+ ndis_buffer_zone = uma_zcreate("NDIS buffer",
+ sizeof(ndis_buffer), NULL, NULL, NULL,
+ NULL, UMA_ALIGN_PTR, 0);
+ break;
+ case MOD_UNLOAD:
+ case MOD_SHUTDOWN:
+ uma_zdestroy(ndis_packet_zone);
+ uma_zdestroy(ndis_buffer_zone);
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ return(error);
}
DEV_MODULE(ndisapi, ndis_modevent, NULL);
MODULE_VERSION(ndisapi, 1);
@@ -104,7 +129,10 @@ ndis_status_func(adapter, status, sbuf, slen)
void *sbuf;
uint32_t slen;
{
- printf ("status: %x\n", status);
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "status: %x\n", status);
return;
}
@@ -112,7 +140,10 @@ __stdcall static void
ndis_statusdone_func(adapter)
ndis_handle adapter;
{
- printf ("status complete\n");
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "status complete\n");
return;
}
@@ -148,7 +179,10 @@ ndis_resetdone_func(adapter, status, addressingreset)
ndis_status status;
uint8_t addressingreset;
{
- printf ("reset done...\n");
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "reset done...\n");
return;
}
@@ -170,8 +204,8 @@ ndis_alloc_amem(arg)
&rid, 0UL, ~0UL, 0x1000, RF_ACTIVE);
if (sc->ndis_res_am == NULL) {
- printf("ndis%d: failed to allocate attribute memory\n",
- sc->ndis_unit);
+ device_printf(sc->ndis_dev,
+ "failed to allocate attribute memory\n");
return(ENXIO);
}
@@ -179,8 +213,8 @@ ndis_alloc_amem(arg)
sc->ndis_dev, rid, 0, NULL);
if (error) {
- printf("ndis%d: CARD_SET_MEMORY_OFFSET() returned 0x%x\n",
- sc->ndis_unit, error);
+ device_printf(sc->ndis_dev,
+ "CARD_SET_MEMORY_OFFSET() returned 0x%x\n", error);
return(error);
}
@@ -188,8 +222,8 @@ ndis_alloc_amem(arg)
sc->ndis_dev, SYS_RES_MEMORY, rid, PCCARD_A_MEM_ATTR);
if (error) {
- printf("ndis%d: CARD_SET_RES_FLAGS() returned 0x%x\n",
- sc->ndis_unit, error);
+ device_printf(sc->ndis_dev,
+ "CARD_SET_RES_FLAGS() returned 0x%x\n", error);
return(error);
}
@@ -369,7 +403,7 @@ ndis_free_bufs(b0)
while(b0 != NULL) {
next = b0->nb_next;
- free (b0, M_DEVBUF);
+ uma_zfree (ndis_buffer_zone, b0);
b0 = next;
}
@@ -384,7 +418,7 @@ ndis_free_packet(p)
return;
ndis_free_bufs(p->np_private.npp_head);
- free(p, M_DEVBUF);
+ uma_zfree(ndis_packet_zone, p);
return;
}
@@ -538,7 +572,7 @@ ndis_mtop(m0, p)
/* If caller didn't supply a packet, make one. */
if (*p == NULL) {
- *p = malloc(sizeof(ndis_packet), M_DEVBUF, M_NOWAIT|M_ZERO);
+ *p = uma_zalloc(ndis_packet_zone, M_NOWAIT|M_ZERO);
if (*p == NULL)
return(ENOMEM);
@@ -551,7 +585,7 @@ ndis_mtop(m0, p)
for (m = m0; m != NULL; m = m->m_next) {
if (m->m_len == 0)
continue;
- buf = malloc(sizeof(ndis_buffer), M_DEVBUF, M_NOWAIT|M_ZERO);
+ buf = uma_zalloc(ndis_buffer_zone, M_NOWAIT | M_ZERO);
if (buf == NULL) {
ndis_free_packet(*p);
*p = NULL;
@@ -567,6 +601,7 @@ ndis_mtop(m0, p)
}
priv->npp_tail = buf;
+ priv->npp_totlen = m0->m_pkthdr.len;
return(0);
}
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index d93822e..975e6ee 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -769,12 +769,13 @@ ndis_syslog(ndis_handle adapter, ndis_error_code code,
block = (ndis_miniport_block *)adapter;
- printf ("NDIS ERROR: %x\n", code);
- printf ("NDIS NUMERRORS: %x\n", numerrors);
+ device_printf (block->nmb_dev, "NDIS ERROR: %x\n", code);
+ device_printf (block->nmb_dev, "NDIS NUMERRORS: %x\n", numerrors);
va_start(ap, numerrors);
for (i = 0; i < numerrors; i++)
- printf ("argptr: %p\n", va_arg(ap, void *));
+ device_printf (block->nmb_dev, "argptr: %p\n",
+ va_arg(ap, void *));
va_end(ap);
return;
@@ -1829,7 +1830,7 @@ ndis_assign_pcirsrc(adapter, slot, list)
block = (ndis_miniport_block *)adapter;
*list = block->nmb_rlist;
- printf ("assign PCI resources...\n");
+ device_printf (block->nmb_dev, "assign PCI resources...\n");
return (NDIS_STATUS_SUCCESS);
}
OpenPOWER on IntegriCloud