Tue Dec 20 21:27:29 2011 UTC ()
Mark all of the Rx descriptor fields 'volatile' so that the compiler
will not re-order accesses.  Some versions of GCC (such as one in NetBSD
5.x) definitely do re-order reads from these fields if they're not
marked volatile.


(dyoung)
diff -r1.45 -r1.46 src/sys/dev/pci/if_wmreg.h

cvs diff -r1.45 -r1.46 src/sys/dev/pci/if_wmreg.h (expand / switch to unified diff)

--- src/sys/dev/pci/if_wmreg.h 2011/05/20 01:51:36 1.45
+++ src/sys/dev/pci/if_wmreg.h 2011/12/20 21:27:29 1.46
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wmreg.h,v 1.45 2011/05/20 01:51:36 msaitoh Exp $ */ 1/* $NetBSD: if_wmreg.h,v 1.46 2011/12/20 21:27:29 dyoung Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Wasabi Systems, Inc. 4 * Copyright (c) 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -47,34 +47,34 @@ @@ -47,34 +47,34 @@
47 */ 47 */
48typedef struct wiseman_addr { 48typedef struct wiseman_addr {
49 uint32_t wa_low; /* low-order 32 bits */ 49 uint32_t wa_low; /* low-order 32 bits */
50 uint32_t wa_high; /* high-order 32 bits */ 50 uint32_t wa_high; /* high-order 32 bits */
51} __packed wiseman_addr_t; 51} __packed wiseman_addr_t;
52 52
53/* 53/*
54 * The Wiseman receive descriptor. 54 * The Wiseman receive descriptor.
55 * 55 *
56 * The receive descriptor ring must be aligned to a 4K boundary, 56 * The receive descriptor ring must be aligned to a 4K boundary,
57 * and there must be an even multiple of 8 descriptors in the ring. 57 * and there must be an even multiple of 8 descriptors in the ring.
58 */ 58 */
59typedef struct wiseman_rxdesc { 59typedef struct wiseman_rxdesc {
60 wiseman_addr_t wrx_addr; /* buffer address */ 60 volatile wiseman_addr_t wrx_addr; /* buffer address */
61 61
62 uint16_t wrx_len; /* buffer length */ 62 volatile uint16_t wrx_len; /* buffer length */
63 uint16_t wrx_cksum; /* checksum (starting at PCSS) */ 63 volatile uint16_t wrx_cksum; /* checksum (starting at PCSS)*/
64 64
65 uint8_t wrx_status; /* Rx status */ 65 volatile uint8_t wrx_status; /* Rx status */
66 uint8_t wrx_errors; /* Rx errors */ 66 volatile uint8_t wrx_errors; /* Rx errors */
67 uint16_t wrx_special; /* special field (VLAN, etc.) */ 67 volatile uint16_t wrx_special; /* special field (VLAN, etc.) */
68} __packed wiseman_rxdesc_t; 68} __packed wiseman_rxdesc_t;
69 69
70/* wrx_status bits */ 70/* wrx_status bits */
71#define WRX_ST_DD (1U << 0) /* descriptor done */ 71#define WRX_ST_DD (1U << 0) /* descriptor done */
72#define WRX_ST_EOP (1U << 1) /* end of packet */ 72#define WRX_ST_EOP (1U << 1) /* end of packet */
73#define WRX_ST_IXSM (1U << 2) /* ignore checksum indication */ 73#define WRX_ST_IXSM (1U << 2) /* ignore checksum indication */
74#define WRX_ST_VP (1U << 3) /* VLAN packet */ 74#define WRX_ST_VP (1U << 3) /* VLAN packet */
75#define WRX_ST_BPDU (1U << 4) /* ??? */ 75#define WRX_ST_BPDU (1U << 4) /* ??? */
76#define WRX_ST_TCPCS (1U << 5) /* TCP checksum performed */ 76#define WRX_ST_TCPCS (1U << 5) /* TCP checksum performed */
77#define WRX_ST_IPCS (1U << 6) /* IP checksum performed */ 77#define WRX_ST_IPCS (1U << 6) /* IP checksum performed */
78#define WRX_ST_PIF (1U << 7) /* passed in-exact filter */ 78#define WRX_ST_PIF (1U << 7) /* passed in-exact filter */
79 79
80/* wrx_error bits */ 80/* wrx_error bits */