iPXE
nx_bitops.h File Reference

NetXen bit operations. More...

Go to the source code of this file.

Macros

#define NX_PSEUDO_BIT_STRUCT(_structure)
 Wrapper structure for pseudo_bit_t structures.
#define NX_PSEUDO_STRUCT(_ptr)
 Get pseudo_bit_t structure type from wrapper structure pointer.
#define NX_BIT_OFFSET(_ptr, _field)
 Bit offset of a field within a pseudo_bit_t structure.
#define NX_BIT_WIDTH(_ptr, _field)
 Bit width of a field within a pseudo_bit_t structure.
#define NX_QWORD_OFFSET(_ptr, _field)
 Qword offset of a field within a pseudo_bit_t structure.
#define NX_QWORD_BIT_OFFSET(_ptr, _index, _field)
 Qword bit offset of a field within a pseudo_bit_t structure.
#define NX_BIT_MASK(_ptr, _field)
 Bit mask for a field within a pseudo_bit_t structure.
#define NX_ASSEMBLE_1(_ptr, _index, _field, _value)
#define NX_ASSEMBLE_2(_ptr, _index, _field, _value, ...)
#define NX_ASSEMBLE_3(_ptr, _index, _field, _value, ...)
#define NX_ASSEMBLE_4(_ptr, _index, _field, _value, ...)
#define NX_ASSEMBLE_5(_ptr, _index, _field, _value, ...)
#define NX_ASSEMBLE_6(_ptr, _index, _field, _value, ...)
#define NX_ASSEMBLE_7(_ptr, _index, _field, _value, ...)
#define NX_MASK_1(_ptr, _index, _field)
#define NX_MASK_2(_ptr, _index, _field, ...)
#define NX_MASK_3(_ptr, _index, _field, ...)
#define NX_MASK_4(_ptr, _index, _field, ...)
#define NX_MASK_5(_ptr, _index, _field, ...)
#define NX_MASK_6(_ptr, _index, _field, ...)
#define NX_MASK_7(_ptr, _index, _field, ...)
#define NX_FILL(_ptr, _index, _assembled)
#define NX_FILL_1(_ptr, _index, ...)
#define NX_FILL_2(_ptr, _index, ...)
#define NX_FILL_3(_ptr, _index, ...)
#define NX_FILL_4(_ptr, _index, ...)
#define NX_FILL_5(_ptr, _index, ...)
#define NX_FILL_6(_ptr, _index, ...)
#define NX_FILL_7(_ptr, _index, ...)
#define NX_GET64(_ptr, _field)
 Extract value of named field.
#define NX_GET(_ptr, _field)
 Extract value of named field (for fields up to the size of a long)

Typedefs

typedef unsigned char pseudo_bit_t
 Datatype used to represent a bit in the pseudo-structures.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)

Detailed Description

NetXen bit operations.

Definition in file nx_bitops.h.

Macro Definition Documentation

◆ NX_PSEUDO_BIT_STRUCT

#define NX_PSEUDO_BIT_STRUCT ( _structure)
Value:
union { \
uint8_t bytes[ sizeof ( _structure ) / 8 ]; \
uint64_t qwords[ sizeof ( _structure ) / 64 ]; \
_structure *dummy[0]; \
} u;
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
union @104331263140136355135267063077374276003064103115 u
uint8_t bytes[64]
Definition ib_mad.h:5

Wrapper structure for pseudo_bit_t structures.

This structure provides a wrapper around pseudo_bit_t structures. It has the correct size, and also encapsulates type information about the underlying pseudo_bit_t-based structure, which allows the NX_FILL etc. macros to work without requiring explicit type information.

Definition at line 48 of file nx_bitops.h.

48#define NX_PSEUDO_BIT_STRUCT( _structure ) \
49 union { \
50 uint8_t bytes[ sizeof ( _structure ) / 8 ]; \
51 uint64_t qwords[ sizeof ( _structure ) / 64 ]; \
52 _structure *dummy[0]; \
53 } u;

◆ NX_PSEUDO_STRUCT

#define NX_PSEUDO_STRUCT ( _ptr)
Value:
typeof ( *((_ptr)->u.dummy[0]) )
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48

Get pseudo_bit_t structure type from wrapper structure pointer.

Definition at line 56 of file nx_bitops.h.

56#define NX_PSEUDO_STRUCT( _ptr ) \
57 typeof ( *((_ptr)->u.dummy[0]) )

◆ NX_BIT_OFFSET

#define NX_BIT_OFFSET ( _ptr,
_field )
Value:
offsetof ( NX_PSEUDO_STRUCT ( _ptr ), _field )
#define NX_PSEUDO_STRUCT(_ptr)
Get pseudo_bit_t structure type from wrapper structure pointer.
Definition nx_bitops.h:56
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25

Bit offset of a field within a pseudo_bit_t structure.

Definition at line 60 of file nx_bitops.h.

60#define NX_BIT_OFFSET( _ptr, _field ) \
61 offsetof ( NX_PSEUDO_STRUCT ( _ptr ), _field )

◆ NX_BIT_WIDTH

#define NX_BIT_WIDTH ( _ptr,
_field )
Value:
sizeof ( ( ( NX_PSEUDO_STRUCT ( _ptr ) * ) NULL )->_field )
#define NULL
NULL pointer (VOID *)
Definition Base.h:322

Bit width of a field within a pseudo_bit_t structure.

Definition at line 64 of file nx_bitops.h.

64#define NX_BIT_WIDTH( _ptr, _field ) \
65 sizeof ( ( ( NX_PSEUDO_STRUCT ( _ptr ) * ) NULL )->_field )

◆ NX_QWORD_OFFSET

#define NX_QWORD_OFFSET ( _ptr,
_field )
Value:
( NX_BIT_OFFSET ( _ptr, _field ) / 64 )
#define NX_BIT_OFFSET(_ptr, _field)
Bit offset of a field within a pseudo_bit_t structure.
Definition nx_bitops.h:60

Qword offset of a field within a pseudo_bit_t structure.

Definition at line 68 of file nx_bitops.h.

68#define NX_QWORD_OFFSET( _ptr, _field ) \
69 ( NX_BIT_OFFSET ( _ptr, _field ) / 64 )

◆ NX_QWORD_BIT_OFFSET

#define NX_QWORD_BIT_OFFSET ( _ptr,
_index,
_field )
Value:
( NX_BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) )

Qword bit offset of a field within a pseudo_bit_t structure.

Yes, using mod-64 would work, but would lose the check for the error of specifying a mismatched field name and qword index.

Definition at line 76 of file nx_bitops.h.

76#define NX_QWORD_BIT_OFFSET( _ptr, _index, _field ) \
77 ( NX_BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) )

◆ NX_BIT_MASK

#define NX_BIT_MASK ( _ptr,
_field )
Value:
( ( ~( ( uint64_t ) 0 ) ) >> \
( 64 - NX_BIT_WIDTH ( _ptr, _field ) ) )
#define NX_BIT_WIDTH(_ptr, _field)
Bit width of a field within a pseudo_bit_t structure.
Definition nx_bitops.h:64

Bit mask for a field within a pseudo_bit_t structure.

Definition at line 80 of file nx_bitops.h.

80#define NX_BIT_MASK( _ptr, _field ) \
81 ( ( ~( ( uint64_t ) 0 ) ) >> \
82 ( 64 - NX_BIT_WIDTH ( _ptr, _field ) ) )

◆ NX_ASSEMBLE_1

#define NX_ASSEMBLE_1 ( _ptr,
_index,
_field,
_value )
Value:
( ( ( uint64_t) (_value) ) << \
NX_QWORD_BIT_OFFSET ( _ptr, _index, _field ) )

Definition at line 89 of file nx_bitops.h.

89#define NX_ASSEMBLE_1( _ptr, _index, _field, _value ) \
90 ( ( ( uint64_t) (_value) ) << \
91 NX_QWORD_BIT_OFFSET ( _ptr, _index, _field ) )

◆ NX_ASSEMBLE_2

#define NX_ASSEMBLE_2 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_1(_ptr, _index, _field, _value)
Definition nx_bitops.h:89

Definition at line 93 of file nx_bitops.h.

93#define NX_ASSEMBLE_2( _ptr, _index, _field, _value, ... ) \
94 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
95 NX_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_ASSEMBLE_3

#define NX_ASSEMBLE_3 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 97 of file nx_bitops.h.

97#define NX_ASSEMBLE_3( _ptr, _index, _field, _value, ... ) \
98 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
99 NX_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_ASSEMBLE_4

#define NX_ASSEMBLE_4 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 101 of file nx_bitops.h.

101#define NX_ASSEMBLE_4( _ptr, _index, _field, _value, ... ) \
102 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
103 NX_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_ASSEMBLE_5

#define NX_ASSEMBLE_5 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 105 of file nx_bitops.h.

105#define NX_ASSEMBLE_5( _ptr, _index, _field, _value, ... ) \
106 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
107 NX_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_ASSEMBLE_6

#define NX_ASSEMBLE_6 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 109 of file nx_bitops.h.

109#define NX_ASSEMBLE_6( _ptr, _index, _field, _value, ... ) \
110 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
111 NX_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_ASSEMBLE_7

#define NX_ASSEMBLE_7 ( _ptr,
_index,
_field,
_value,
... )
Value:
( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
NX_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 113 of file nx_bitops.h.

113#define NX_ASSEMBLE_7( _ptr, _index, _field, _value, ... ) \
114 ( NX_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \
115 NX_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_1

#define NX_MASK_1 ( _ptr,
_index,
_field )
Value:
( NX_BIT_MASK ( _ptr, _field ) << \
NX_QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
#define NX_BIT_MASK(_ptr, _field)
Bit mask for a field within a pseudo_bit_t structure.
Definition nx_bitops.h:80

Definition at line 122 of file nx_bitops.h.

122#define NX_MASK_1( _ptr, _index, _field ) \
123 ( NX_BIT_MASK ( _ptr, _field ) << \
124 NX_QWORD_BIT_OFFSET ( _ptr, _index, _field ) )

◆ NX_MASK_2

#define NX_MASK_2 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_1 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_MASK_1(_ptr, _index, _field)
Definition nx_bitops.h:122

Definition at line 126 of file nx_bitops.h.

126#define NX_MASK_2( _ptr, _index, _field, ... ) \
127 ( NX_MASK_1 ( _ptr, _index, _field ) | \
128 NX_MASK_1 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_3

#define NX_MASK_3 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_2 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 130 of file nx_bitops.h.

130#define NX_MASK_3( _ptr, _index, _field, ... ) \
131 ( NX_MASK_1 ( _ptr, _index, _field ) | \
132 NX_MASK_2 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_4

#define NX_MASK_4 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_3 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 134 of file nx_bitops.h.

134#define NX_MASK_4( _ptr, _index, _field, ... ) \
135 ( NX_MASK_1 ( _ptr, _index, _field ) | \
136 NX_MASK_3 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_5

#define NX_MASK_5 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_4 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 138 of file nx_bitops.h.

138#define NX_MASK_5( _ptr, _index, _field, ... ) \
139 ( NX_MASK_1 ( _ptr, _index, _field ) | \
140 NX_MASK_4 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_6

#define NX_MASK_6 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_5 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 142 of file nx_bitops.h.

142#define NX_MASK_6( _ptr, _index, _field, ... ) \
143 ( NX_MASK_1 ( _ptr, _index, _field ) | \
144 NX_MASK_5 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_MASK_7

#define NX_MASK_7 ( _ptr,
_index,
_field,
... )
Value:
( NX_MASK_1 ( _ptr, _index, _field ) | \
NX_MASK_6 ( _ptr, _index, __VA_ARGS__ ) )

Definition at line 146 of file nx_bitops.h.

146#define NX_MASK_7( _ptr, _index, _field, ... ) \
147 ( NX_MASK_1 ( _ptr, _index, _field ) | \
148 NX_MASK_6 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_FILL

#define NX_FILL ( _ptr,
_index,
_assembled )
Value:
do { \
uint64_t *__ptr = &(_ptr)->u.qwords[(_index)]; \
uint64_t __assembled = (_assembled); \
*__ptr = cpu_to_le64 ( __assembled ); \
} while ( 0 )
#define cpu_to_le64(value)
Definition byteswap.h:109

Definition at line 155 of file nx_bitops.h.

155#define NX_FILL( _ptr, _index, _assembled ) \
156 do { \
157 uint64_t *__ptr = &(_ptr)->u.qwords[(_index)]; \
158 uint64_t __assembled = (_assembled); \
159 *__ptr = cpu_to_le64 ( __assembled ); \
160 } while ( 0 )

◆ NX_FILL_1

#define NX_FILL_1 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_FILL(_ptr, _index, _assembled)
Definition nx_bitops.h:155

Definition at line 162 of file nx_bitops.h.

162#define NX_FILL_1( _ptr, _index, ... ) \
163 NX_FILL ( _ptr, _index, NX_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )

Referenced by phantom_refill_rx_ring(), phantom_transmit(), and phantom_update_macaddr().

◆ NX_FILL_2

#define NX_FILL_2 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_2(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:93

Definition at line 165 of file nx_bitops.h.

165#define NX_FILL_2( _ptr, _index, ... ) \
166 NX_FILL ( _ptr, _index, NX_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )

Referenced by phantom_refill_rx_ring(), phantom_transmit(), and phantom_update_macaddr().

◆ NX_FILL_3

#define NX_FILL_3 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_3(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:97

Definition at line 168 of file nx_bitops.h.

168#define NX_FILL_3( _ptr, _index, ... ) \
169 NX_FILL ( _ptr, _index, NX_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )

Referenced by phantom_transmit().

◆ NX_FILL_4

#define NX_FILL_4 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_4(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:101

Definition at line 171 of file nx_bitops.h.

171#define NX_FILL_4( _ptr, _index, ... ) \
172 NX_FILL ( _ptr, _index, NX_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_FILL_5

#define NX_FILL_5 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_5(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:105

Definition at line 174 of file nx_bitops.h.

174#define NX_FILL_5( _ptr, _index, ... ) \
175 NX_FILL ( _ptr, _index, NX_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_FILL_6

#define NX_FILL_6 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_6(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:109

Definition at line 177 of file nx_bitops.h.

177#define NX_FILL_6( _ptr, _index, ... ) \
178 NX_FILL ( _ptr, _index, NX_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )

◆ NX_FILL_7

#define NX_FILL_7 ( _ptr,
_index,
... )
Value:
NX_FILL ( _ptr, _index, NX_ASSEMBLE_7 ( _ptr, _index, __VA_ARGS__ ) )
#define NX_ASSEMBLE_7(_ptr, _index, _field, _value,...)
Definition nx_bitops.h:113

Definition at line 180 of file nx_bitops.h.

180#define NX_FILL_7( _ptr, _index, ... ) \
181 NX_FILL ( _ptr, _index, NX_ASSEMBLE_7 ( _ptr, _index, __VA_ARGS__ ) )

Referenced by phantom_update_macaddr().

◆ NX_GET64

#define NX_GET64 ( _ptr,
_field )
Value:
( { \
unsigned int __index = NX_QWORD_OFFSET ( _ptr, _field ); \
uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \
uint64_t __value = le64_to_cpu ( *__ptr ); \
__value >>= \
NX_QWORD_BIT_OFFSET ( _ptr, __index, _field ); \
__value &= NX_BIT_MASK ( _ptr, _field ); \
__value; \
} )
#define le64_to_cpu(value)
Definition byteswap.h:115
#define NX_QWORD_OFFSET(_ptr, _field)
Qword offset of a field within a pseudo_bit_t structure.
Definition nx_bitops.h:68

Extract value of named field.

Definition at line 184 of file nx_bitops.h.

184#define NX_GET64( _ptr, _field ) \
185 ( { \
186 unsigned int __index = NX_QWORD_OFFSET ( _ptr, _field ); \
187 uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \
188 uint64_t __value = le64_to_cpu ( *__ptr ); \
189 __value >>= \
190 NX_QWORD_BIT_OFFSET ( _ptr, __index, _field ); \
191 __value &= NX_BIT_MASK ( _ptr, _field ); \
192 __value; \
193 } )

◆ NX_GET

#define NX_GET ( _ptr,
_field )
Value:
( ( unsigned long ) NX_GET64 ( _ptr, _field ) )
#define NX_GET64(_ptr, _field)
Extract value of named field.
Definition nx_bitops.h:184

Extract value of named field (for fields up to the size of a long)

Definition at line 196 of file nx_bitops.h.

196#define NX_GET( _ptr, _field ) \
197 ( ( unsigned long ) NX_GET64 ( _ptr, _field ) )

Referenced by phantom_poll(), and phantom_post_rds().

Typedef Documentation

◆ pseudo_bit_t

typedef unsigned char pseudo_bit_t

Datatype used to represent a bit in the pseudo-structures.

Definition at line 37 of file nx_bitops.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )