|
@@ -38,19 +38,21 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
38
|
38
|
|
39
|
39
|
/* Endianness selection.
|
40
|
40
|
*
|
41
|
|
- * This is a property of the NIC, not a property of the host CPU.
|
|
41
|
+ * This is a property of the device, not a property of the host CPU.
|
42
|
42
|
*/
|
43
|
43
|
#ifdef BITOPS_LITTLE_ENDIAN
|
44
|
44
|
#define cpu_to_BIT64 cpu_to_le64
|
45
|
45
|
#define cpu_to_BIT32 cpu_to_le32
|
46
|
46
|
#define BIT64_to_cpu le64_to_cpu
|
47
|
47
|
#define BIT32_to_cpu le32_to_cpu
|
|
48
|
+#define QWORD_SHIFT( offset, width ) (offset)
|
48
|
49
|
#endif
|
49
|
50
|
#ifdef BITOPS_BIG_ENDIAN
|
50
|
51
|
#define cpu_to_BIT64 cpu_to_be64
|
51
|
52
|
#define cpu_to_BIT32 cpu_to_be32
|
52
|
53
|
#define BIT64_to_cpu be64_to_cpu
|
53
|
54
|
#define BIT32_to_cpu be32_to_cpu
|
|
55
|
+#define QWORD_SHIFT( offset, width ) ( 64 - (offset) - (width) )
|
54
|
56
|
#endif
|
55
|
57
|
|
56
|
58
|
/** Datatype used to represent a bit in the pseudo-structures */
|
|
@@ -93,6 +95,11 @@ typedef unsigned char pseudo_bit_t;
|
93
|
95
|
#define QWORD_BIT_OFFSET( _ptr, _index, _field ) \
|
94
|
96
|
( BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) )
|
95
|
97
|
|
|
98
|
+/** Qword bit shift for a field within a pseudo_bit_t structure */
|
|
99
|
+#define QWORD_BIT_SHIFT( _ptr, _index, _field ) \
|
|
100
|
+ QWORD_SHIFT ( QWORD_BIT_OFFSET ( _ptr, _index, _field ), \
|
|
101
|
+ BIT_WIDTH ( _ptr, _field ) )
|
|
102
|
+
|
96
|
103
|
/** Bit mask for a field within a pseudo_bit_t structure */
|
97
|
104
|
#define BIT_MASK( _ptr, _field ) \
|
98
|
105
|
( ( ~( ( uint64_t ) 0 ) ) >> \
|
|
@@ -105,7 +112,7 @@ typedef unsigned char pseudo_bit_t;
|
105
|
112
|
|
106
|
113
|
#define BIT_ASSEMBLE_1( _ptr, _index, _field, _value ) \
|
107
|
114
|
( ( ( uint64_t) (_value) ) << \
|
108
|
|
- QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
|
|
115
|
+ QWORD_BIT_SHIFT ( _ptr, _index, _field ) )
|
109
|
116
|
|
110
|
117
|
#define BIT_ASSEMBLE_2( _ptr, _index, _field, _value, ... ) \
|
111
|
118
|
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
|
|
@@ -138,7 +145,7 @@ typedef unsigned char pseudo_bit_t;
|
138
|
145
|
|
139
|
146
|
#define BIT_MASK_1( _ptr, _index, _field ) \
|
140
|
147
|
( BIT_MASK ( _ptr, _field ) << \
|
141
|
|
- QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
|
|
148
|
+ QWORD_BIT_SHIFT ( _ptr, _index, _field ) )
|
142
|
149
|
|
143
|
150
|
#define BIT_MASK_2( _ptr, _index, _field, ... ) \
|
144
|
151
|
( BIT_MASK_1 ( _ptr, _index, _field ) | \
|
|
@@ -165,7 +172,7 @@ typedef unsigned char pseudo_bit_t;
|
165
|
172
|
BIT_MASK_6 ( _ptr, _index, __VA_ARGS__ ) )
|
166
|
173
|
|
167
|
174
|
/*
|
168
|
|
- * Populate little-endian qwords from named fields and values
|
|
175
|
+ * Populate device-endian qwords from named fields and values
|
169
|
176
|
*
|
170
|
177
|
*/
|
171
|
178
|
|
|
@@ -212,7 +219,7 @@ typedef unsigned char pseudo_bit_t;
|
212
|
219
|
uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \
|
213
|
220
|
uint64_t __value = BIT64_to_cpu ( *__ptr ); \
|
214
|
221
|
__value >>= \
|
215
|
|
- QWORD_BIT_OFFSET ( _ptr, __index, _field ); \
|
|
222
|
+ QWORD_BIT_SHIFT ( _ptr, __index, _field ); \
|
216
|
223
|
__value &= BIT_MASK ( _ptr, _field ); \
|
217
|
224
|
__value; \
|
218
|
225
|
} )
|
|
@@ -225,7 +232,7 @@ typedef unsigned char pseudo_bit_t;
|
225
|
232
|
unsigned int __index = QWORD_OFFSET ( _ptr, _field ); \
|
226
|
233
|
uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \
|
227
|
234
|
unsigned int __shift = \
|
228
|
|
- QWORD_BIT_OFFSET ( _ptr, __index, _field ); \
|
|
235
|
+ QWORD_BIT_SHIFT ( _ptr, __index, _field ); \
|
229
|
236
|
uint64_t __value = (_value); \
|
230
|
237
|
*__ptr &= cpu_to_BIT64 ( ~( BIT_MASK ( _ptr, _field ) << \
|
231
|
238
|
__shift ) ); \
|