summaryrefslogtreecommitdiffstats
path: root/sys/compat/ndis/ntoskrnl_var.h
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2003-12-23 04:08:22 +0000
committerwpaul <wpaul@FreeBSD.org>2003-12-23 04:08:22 +0000
commita0d9582fee2a30515c17d0859ce268d10a063328 (patch)
treebf9f1f3a9199c4028ebe0d1efac3fa602c1a337f /sys/compat/ndis/ntoskrnl_var.h
parent38f4513fb878dd012fe1ff5438e23e3b846785e4 (diff)
downloadFreeBSD-src-a0d9582fee2a30515c17d0859ce268d10a063328.zip
FreeBSD-src-a0d9582fee2a30515c17d0859ce268d10a063328.tar.gz
Re-do the handling of ndis_buffers. The NDIS_BUFFER structure is
supposed to be opaque to the driver, however it is exposed through several macros which expect certain behavior. In my original implementation, I used the mappedsystemva member of the structure to hold a pointer to the buffer and bytecount to hold the length. It turns out you must use the startva pointer to point to the page containing the start of the buffer and set byteoffset to the offset within the page where the buffer starts. So, for a buffer with address 'baseva,' startva is baseva & ~(PAGE_SIZE -1) and byteoffset is baseva & (PAGE_SIZE -1). We have to maintain this convention everywhere that ndis_buffers are used. Fortunately, Microsoft defines some macros for initializing and manipulating NDIS_BUFFER structures in ntddk.h. I adapted some of them for use here and used them where appropriate. This fixes the discrepancy I observed between how RX'ed packet sizes were being reported in the Broadcom wireless driver and the sample ethernet drivers that I've tested. This should also help the Intel Centrino wireless driver work. Also try to properly initialize the 802.11 BSS and IBSS channels. (Sadly, the channel value is meaningless since there's no way in the existing NDIS API to get/set the channel, but this should take care of any 'invalid channel (NULL)' messages printed on the console.
Diffstat (limited to 'sys/compat/ndis/ntoskrnl_var.h')
-rw-r--r--sys/compat/ndis/ntoskrnl_var.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/compat/ndis/ntoskrnl_var.h b/sys/compat/ndis/ntoskrnl_var.h
index 9447d1b..5d87ff3 100644
--- a/sys/compat/ndis/ntoskrnl_var.h
+++ b/sys/compat/ndis/ntoskrnl_var.h
@@ -40,6 +40,20 @@
#define SPAN_PAGES(ptr, len) \
((uint32_t)((((uintptr_t)(ptr) & (PAGE_SIZE -1)) + \
(len) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
+#define PAGE_ALIGN(ptr) \
+ ((void *)((uintptr_t)(ptr) & ~(PAGE_SIZE - 1)))
+#define BYTE_OFFSET(ptr) \
+ ((uint32_t)((uintptr_t)(ptr) & (PAGE_SIZE - 1)))
+#define MDL_INIT(b, baseva, len) \
+ (b)->nb_next = NULL; \
+ (b)->nb_size = (uint16_t)(sizeof(struct ndis_buffer) + \
+ (sizeof(uint32_t) * SPAN_PAGES((baseva), (len)))); \
+ (b)->nb_flags = 0; \
+ (b)->nb_startva = (void *)PAGE_ALIGN((baseva)); \
+ (b)->nb_byteoffset = BYTE_OFFSET((baseva)); \
+ (b)->nb_bytecount = (uint32_t)(len);
+#define MDL_VA(b) \
+ ((void *)((char *)((b)->nb_startva) + (b)->nb_byteoffset))
typedef uint32_t kspin_lock;
OpenPOWER on IntegriCloud