summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2004-01-04 03:00:21 +0000
committerwpaul <wpaul@FreeBSD.org>2004-01-04 03:00:21 +0000
commitcc0f677dae73816e334103ecca82ca9875ad0e48 (patch)
tree49035d218617c9b9af8310dc80d66593acb5a288
parentb872c27d4a11b75c02c4c2615bc9a86aa35611ff (diff)
downloadFreeBSD-src-cc0f677dae73816e334103ecca82ca9875ad0e48.zip
FreeBSD-src-cc0f677dae73816e334103ecca82ca9875ad0e48.tar.gz
In ndis_attach(), report the NDIS API level that the Windows miniport
driver was compiled with. Remove debug printf from ndis_assicn_pcirsc(). It doesn't serve much purpose. Implement NdisMIndicateStatus() and NdisMIndicateStatusComplete() as functions in subr_ndis.c. In NDIS 4.0, they were functions. In NDIS 5.0 and later, they're just macros. Allocate a few extra packets/buffers beyond what the driver asks for since sometimes it seems they can lie about how many they really need, and some extra stupid ones don't check to see if NdisAllocatePacket() and/or NdisAllocateBuffer() actually succeed.
-rw-r--r--sys/compat/ndis/subr_ndis.c61
-rw-r--r--sys/dev/if_ndis/if_ndis.c5
2 files changed, 61 insertions, 5 deletions
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index 5e4c033..1109e09 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -248,8 +248,20 @@ __stdcall static void ndis_map_file(ndis_status *, void **, ndis_handle);
__stdcall static void ndis_unmap_file(ndis_handle);
__stdcall static void ndis_close_file(ndis_handle);
__stdcall static u_int8_t ndis_cpu_cnt(void);
+__stdcall static void ndis_ind_statusdone(ndis_handle);
+__stdcall static void ndis_ind_status(ndis_handle, ndis_status,
+ void *, uint32_t);
__stdcall static void dummy(void);
+/*
+ * Some really old drivers do not properly check the return value
+ * from NdisAllocatePacket() and NdisAllocateBuffer() and will
+ * sometimes allocate few more buffers/packets that they originally
+ * requested when they created the pool. To prevent this from being
+ * a problem, we allocate a few extra buffers/packets beyond what
+ * the driver asks for. This #define controls how many.
+ */
+#define NDIS_POOL_EXTRA 16
int
ndis_libinit()
@@ -1441,7 +1453,8 @@ ndis_alloc_packetpool(status, pool, descnum, protrsvdlen)
ndis_packet *cur;
int i;
- *pool = malloc(sizeof(ndis_packet) * (descnum + 1),
+ *pool = malloc(sizeof(ndis_packet) *
+ ((descnum + NDIS_POOL_EXTRA) + 1),
M_DEVBUF, M_NOWAIT|M_ZERO);
if (pool == NULL) {
@@ -1451,7 +1464,7 @@ ndis_alloc_packetpool(status, pool, descnum, protrsvdlen)
cur = (ndis_packet *)*pool;
cur->np_private.npp_flags = 0x1; /* mark the head of the list */
- for (i = 0; i < descnum; i++) {
+ for (i = 0; i < (descnum + NDIS_POOL_EXTRA); i++) {
cur->np_private.npp_head = (ndis_handle)(cur + 1);
cur++;
}
@@ -1623,7 +1636,8 @@ ndis_alloc_bufpool(status, pool, descnum)
ndis_buffer *cur;
int i;
- *pool = malloc(sizeof(ndis_buffer) * (descnum + 1),
+ *pool = malloc(sizeof(ndis_buffer) *
+ ((descnum + NDIS_POOL_EXTRA) + 1),
M_DEVBUF, M_NOWAIT|M_ZERO);
if (pool == NULL) {
@@ -1633,7 +1647,7 @@ ndis_alloc_bufpool(status, pool, descnum)
cur = (ndis_buffer *)*pool;
cur->nb_flags = 0x1; /* mark the head of the list */
- for (i = 0; i < descnum; i++) {
+ for (i = 0; i < (descnum + NDIS_POOL_EXTRA); i++) {
cur->nb_next = cur + 1;
cur++;
}
@@ -1877,7 +1891,6 @@ ndis_assign_pcirsrc(adapter, slot, list)
block = (ndis_miniport_block *)adapter;
*list = block->nmb_rlist;
- device_printf (block->nmb_dev, "assign PCI resources...\n");
return (NDIS_STATUS_SUCCESS);
}
@@ -2166,6 +2179,7 @@ ndis_init_string(dst, src)
ndis_unicode_string *u;
u = dst;
+ u->nus_buf = NULL;
if (ndis_ascii_to_unicode(src, &u->nus_buf))
return;
u->nus_len = u->nus_maxlen = strlen(src) * 2;
@@ -2340,6 +2354,41 @@ ndis_cpu_cnt()
#endif
};
+typedef void (*ndis_statusdone_handler)(ndis_handle);
+typedef void (*ndis_status_handler)(ndis_handle, ndis_status,
+ void *, uint32_t);
+
+__stdcall static void
+ndis_ind_statusdone(adapter)
+ ndis_handle adapter;
+{
+ ndis_miniport_block *block;
+ __stdcall ndis_statusdone_handler statusdonefunc;
+
+ block = (ndis_miniport_block *)adapter;
+ statusdonefunc = block->nmb_statusdone_func;
+
+ statusdonefunc(adapter);
+ return;
+}
+
+__stdcall static void
+ndis_ind_status(adapter, status, sbuf, slen)
+ ndis_handle adapter;
+ ndis_status status;
+ void *sbuf;
+ uint32_t slen;
+{
+ ndis_miniport_block *block;
+ __stdcall ndis_status_handler statusfunc;
+
+ block = (ndis_miniport_block *)adapter;
+ statusfunc = block->nmb_status_func;
+
+ statusfunc(adapter, status, sbuf, slen);
+ return;
+}
+
__stdcall static void
dummy()
{
@@ -2348,6 +2397,8 @@ dummy()
}
image_patch_table ndis_functbl[] = {
+ { "NdisMIndicateStatusComplete", (FUNC)ndis_ind_statusdone },
+ { "NdisMIndicateStatus", (FUNC)ndis_ind_status },
{ "NdisSystemProcessorCount", (FUNC)ndis_cpu_cnt },
{ "NdisUnchainBufferAtBack", (FUNC)ndis_unchain_tailbuf, },
{ "NdisGetFirstBufferFromPacket", (FUNC)ndis_firstbuf },
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 67a1a1b..96dd832 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -381,6 +381,11 @@ ndis_attach(dev)
/* Set up driver image in memory. */
ndis_load_driver((vm_offset_t)img, sc);
+ /* Tell the user what version of the API the driver is using. */
+ device_printf(dev, "NDIS API version: %d.%d\n",
+ sc->ndis_chars.nmc_version_major,
+ sc->ndis_chars.nmc_version_minor);
+
/* Do resource conversion. */
ndis_convert_res(sc);
OpenPOWER on IntegriCloud