@@ -157,51 +157,76 @@ typedef enum anyraid_map_entry_type {
157
157
AMET_TYPES
158
158
} anyraid_map_entry_type_t ;
159
159
160
+ #define AME_TYPE_BITS 8
161
+
160
162
/*
161
163
* ==========================================================================
162
164
* Skip entry definitions and functions
163
165
* ==========================================================================
164
166
*/
165
- typedef struct anyraid_map_skip_entry {
166
- union {
167
- uint8_t amse_type ;
168
- uint32_t amse_skip_count ; // tile count to skip ahead
169
- } amse_u ;
170
- } anyraid_map_skip_entry_t ;
167
+ typedef uint32_t anyraid_map_skip_entry_t ;
171
168
172
169
#define AMSE_TILE_BITS 24
173
170
174
171
static inline void
175
172
amse_set_type (anyraid_map_skip_entry_t * amse )
176
173
{
177
- amse -> amse_u .amse_type = AMET_SKIP ;
178
- ASSERT3U (amse -> amse_u .amse_type , = = ,
179
- BF32_GET (amse -> amse_u .amse_type , 0 , 8 ));
174
+ BF32_SET (* amse , 0 , AME_TYPE_BITS , AMET_SKIP );
180
175
}
181
176
182
177
static inline void
183
178
amse_set_skip_count (anyraid_map_skip_entry_t * amse , uint32_t skip_count )
184
179
{
185
- BF32_SET (amse -> amse_u . amse_skip_count , 8 , AMSE_TILE_BITS , skip_count );
180
+ BF32_SET (* amse , AME_TYPE_BITS , AMSE_TILE_BITS , skip_count );
186
181
}
187
182
188
183
static inline uint32_t
189
184
amse_get_skip_count (anyraid_map_skip_entry_t * amse )
190
185
{
191
- return (BF32_GET (amse -> amse_u . amse_skip_count , 8 , AMSE_TILE_BITS ));
186
+ return (BF32_GET (* amse , AME_TYPE_BITS , AMSE_TILE_BITS ));
192
187
}
193
188
194
189
/*
195
190
* ==========================================================================
196
191
* Location entry definitions and functions
197
192
* ==========================================================================
198
193
*/
199
- typedef struct anyraid_map_loc_entry {
200
- uint8_t amle_type ;
201
- uint8_t amle_disk ;
202
- uint16_t amle_offset ;
203
- } anyraid_map_loc_entry_t ;
204
- _Static_assert (sizeof (anyraid_map_loc_entry_t ) == sizeof (uint32_t ), "" );
194
+ typedef uint32_t anyraid_map_loc_entry_t ;
195
+
196
+ #define AMLE_DISK_BITS 8
197
+ #define AMLE_OFFSET_BITS 16
198
+
199
+ static inline void
200
+ amle_set_type (anyraid_map_loc_entry_t * amle )
201
+ {
202
+ BF32_SET (* amle , 0 , AME_TYPE_BITS , AMET_LOC );
203
+ }
204
+
205
+ static inline void
206
+ amle_set_disk (anyraid_map_loc_entry_t * amle , uint8_t disk )
207
+ {
208
+ BF32_SET (* amle , AME_TYPE_BITS , AMLE_DISK_BITS , disk );
209
+ }
210
+
211
+ static inline uint32_t
212
+ amle_get_disk (anyraid_map_loc_entry_t * amle )
213
+ {
214
+ return (BF32_GET (* amle , AME_TYPE_BITS , AMLE_DISK_BITS ));
215
+ }
216
+
217
+ static inline void
218
+ amle_set_offset (anyraid_map_loc_entry_t * amle , uint8_t offset )
219
+ {
220
+ BF32_SET (* amle , (AME_TYPE_BITS + AMLE_DISK_BITS ), AMLE_OFFSET_BITS ,
221
+ offset );
222
+ }
223
+
224
+ static inline uint32_t
225
+ amle_get_offset (anyraid_map_loc_entry_t * amle )
226
+ {
227
+ return (BF32_GET (* amle , (AME_TYPE_BITS + AMLE_DISK_BITS ),
228
+ AMLE_OFFSET_BITS ));
229
+ }
205
230
206
231
/*
207
232
* ==========================================================================
@@ -216,28 +241,10 @@ typedef struct anyraid_map_entry {
216
241
} ame_u ;
217
242
} anyraid_map_entry_t ;
218
243
219
- static inline void
220
- ame_byteswap (anyraid_map_entry_t * ame )
244
+ static inline anyraid_map_entry_type_t
245
+ ame_get_type (anyraid_map_entry_t * ame )
221
246
{
222
- uint8_t type = ame -> ame_u .ame_amle .amle_type ;
223
- switch (type ) {
224
- case AMET_SKIP : {
225
- anyraid_map_skip_entry_t * amse =
226
- & ame -> ame_u .ame_amse ;
227
- amse -> amse_u .amse_skip_count =
228
- BSWAP_32 (amse_get_skip_count (amse )) >> NBBY ;
229
- amse -> amse_u .amse_type = AMET_SKIP ;
230
- break ;
231
- }
232
- case AMET_LOC : {
233
- anyraid_map_loc_entry_t * amle =
234
- & ame -> ame_u .ame_amle ;
235
- amle -> amle_offset = BSWAP_16 (amle -> amle_offset );
236
- break ;
237
- }
238
- default :
239
- PANIC ("Invalid entry type %d" , type );
240
- }
247
+ return (BF32_GET (ame -> ame_u .ame_amle , 0 , AME_TYPE_BITS ));
241
248
}
242
249
243
250
#define VDEV_ANYRAID_MAX_DISKS (1 << 8)
0 commit comments