20
20
#ifndef HPSA_CMD_H
21
21
#define HPSA_CMD_H
22
22
23
+ #include <linux/compiler.h>
24
+
25
+ #include <linux/build_bug.h> /* static_assert */
26
+ #include <linux/stddef.h> /* offsetof */
27
+
23
28
/* general boundary defintions */
24
29
#define SENSEINFOBYTES 32 /* may vary between hbas */
25
30
#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
@@ -200,12 +205,10 @@ union u64bit {
200
205
MAX_EXT_TARGETS + 1) /* + 1 is for the controller itself */
201
206
202
207
/* SCSI-3 Commands */
203
- #pragma pack(1)
204
-
205
208
#define HPSA_INQUIRY 0x12
206
209
struct InquiryData {
207
210
u8 data_byte [36 ];
208
- };
211
+ } __packed ;
209
212
210
213
#define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
211
214
#define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
@@ -221,7 +224,7 @@ struct raid_map_disk_data {
221
224
u8 xor_mult [2 ]; /**< XOR multipliers for this position,
222
225
* valid for data disks only */
223
226
u8 reserved [2 ];
224
- };
227
+ } __packed ;
225
228
226
229
struct raid_map_data {
227
230
__le32 structure_size ; /* Size of entire structure in bytes */
@@ -247,14 +250,14 @@ struct raid_map_data {
247
250
__le16 dekindex ; /* Data encryption key index. */
248
251
u8 reserved [16 ];
249
252
struct raid_map_disk_data data [RAID_MAP_MAX_ENTRIES ];
250
- };
253
+ } __packed ;
251
254
252
255
struct ReportLUNdata {
253
256
u8 LUNListLength [4 ];
254
257
u8 extended_response_flag ;
255
258
u8 reserved [3 ];
256
259
u8 LUN [HPSA_MAX_LUN ][8 ];
257
- };
260
+ } __packed ;
258
261
259
262
struct ext_report_lun_entry {
260
263
u8 lunid [8 ];
@@ -269,20 +272,20 @@ struct ext_report_lun_entry {
269
272
u8 lun_count ; /* multi-lun device, how many luns */
270
273
u8 redundant_paths ;
271
274
u32 ioaccel_handle ; /* ioaccel1 only uses lower 16 bits */
272
- };
275
+ } __packed ;
273
276
274
277
struct ReportExtendedLUNdata {
275
278
u8 LUNListLength [4 ];
276
279
u8 extended_response_flag ;
277
280
u8 reserved [3 ];
278
281
struct ext_report_lun_entry LUN [HPSA_MAX_PHYS_LUN ];
279
- };
282
+ } __packed ;
280
283
281
284
struct SenseSubsystem_info {
282
285
u8 reserved [36 ];
283
286
u8 portname [8 ];
284
287
u8 reserved1 [1108 ];
285
- };
288
+ } __packed ;
286
289
287
290
/* BMIC commands */
288
291
#define BMIC_READ 0x26
@@ -317,36 +320,36 @@ union SCSI3Addr {
317
320
u8 Targ :6 ;
318
321
u8 Mode :2 ; /* b10 */
319
322
} LogUnit ;
320
- };
323
+ } __packed ;
321
324
322
325
struct PhysDevAddr {
323
326
u32 TargetId :24 ;
324
327
u32 Bus :6 ;
325
328
u32 Mode :2 ;
326
329
/* 2 level target device addr */
327
330
union SCSI3Addr Target [2 ];
328
- };
331
+ } __packed ;
329
332
330
333
struct LogDevAddr {
331
334
u32 VolId :30 ;
332
335
u32 Mode :2 ;
333
336
u8 reserved [4 ];
334
- };
337
+ } __packed ;
335
338
336
339
union LUNAddr {
337
340
u8 LunAddrBytes [8 ];
338
341
union SCSI3Addr SCSI3Lun [4 ];
339
342
struct PhysDevAddr PhysDev ;
340
343
struct LogDevAddr LogDev ;
341
- };
344
+ } __packed ;
342
345
343
346
struct CommandListHeader {
344
347
u8 ReplyQueue ;
345
348
u8 SGList ;
346
349
__le16 SGTotal ;
347
350
__le64 tag ;
348
351
union LUNAddr LUN ;
349
- };
352
+ } __packed ;
350
353
351
354
struct RequestBlock {
352
355
u8 CDBLen ;
@@ -365,18 +368,18 @@ struct RequestBlock {
365
368
#define GET_DIR (tad ) (((tad) >> 6) & 0x03)
366
369
u16 Timeout ;
367
370
u8 CDB [16 ];
368
- };
371
+ } __packed ;
369
372
370
373
struct ErrDescriptor {
371
374
__le64 Addr ;
372
375
__le32 Len ;
373
- };
376
+ } __packed ;
374
377
375
378
struct SGDescriptor {
376
379
__le64 Addr ;
377
380
__le32 Len ;
378
381
__le32 Ext ;
379
- };
382
+ } __packed ;
380
383
381
384
union MoreErrInfo {
382
385
struct {
@@ -390,15 +393,16 @@ union MoreErrInfo {
390
393
u8 offense_num ; /* byte # of offense 0-base */
391
394
u32 offense_value ;
392
395
} Invalid_Cmd ;
393
- };
396
+ } __packed ;
397
+
394
398
struct ErrorInfo {
395
399
u8 ScsiStatus ;
396
400
u8 SenseLen ;
397
401
u16 CommandStatus ;
398
402
u32 ResidualCnt ;
399
403
union MoreErrInfo MoreErrInfo ;
400
404
u8 SenseInfo [SENSEINFOBYTES ];
401
- };
405
+ } __packed ;
402
406
/* Command types */
403
407
#define CMD_IOCTL_PEND 0x01
404
408
#define CMD_SCSI 0x03
@@ -453,6 +457,15 @@ struct CommandList {
453
457
atomic_t refcount ; /* Must be last to avoid memset in hpsa_cmd_init() */
454
458
} __aligned (COMMANDLIST_ALIGNMENT );
455
459
460
+ /*
461
+ * Make sure our embedded atomic variable is aligned. Otherwise we break atomic
462
+ * operations on architectures that don't support unaligned atomics like IA64.
463
+ *
464
+ * The assert guards against reintroductin against unwanted __packed to
465
+ * the struct CommandList.
466
+ */
467
+ static_assert (offsetof(struct CommandList , refcount ) % __alignof__(atomic_t ) == 0 );
468
+
456
469
/* Max S/G elements in I/O accelerator command */
457
470
#define IOACCEL1_MAXSGENTRIES 24
458
471
#define IOACCEL2_MAXSGENTRIES 28
@@ -489,7 +502,7 @@ struct io_accel1_cmd {
489
502
__le64 host_addr ; /* 0x70 - 0x77 */
490
503
u8 CISS_LUN [8 ]; /* 0x78 - 0x7F */
491
504
struct SGDescriptor SG [IOACCEL1_MAXSGENTRIES ];
492
- } __aligned (IOACCEL1_COMMANDLIST_ALIGNMENT );
505
+ } __packed __aligned (IOACCEL1_COMMANDLIST_ALIGNMENT );
493
506
494
507
#define IOACCEL1_FUNCTION_SCSIIO 0x00
495
508
#define IOACCEL1_SGLOFFSET 32
@@ -519,7 +532,7 @@ struct ioaccel2_sg_element {
519
532
u8 chain_indicator ;
520
533
#define IOACCEL2_CHAIN 0x80
521
534
#define IOACCEL2_LAST_SG 0x40
522
- };
535
+ } __packed ;
523
536
524
537
/*
525
538
* SCSI Response Format structure for IO Accelerator Mode 2
@@ -559,7 +572,7 @@ struct io_accel2_scsi_response {
559
572
u8 sense_data_len ; /* sense/response data length */
560
573
u8 resid_cnt [4 ]; /* residual count */
561
574
u8 sense_data_buff [32 ]; /* sense/response data buffer */
562
- };
575
+ } __packed ;
563
576
564
577
/*
565
578
* Structure for I/O accelerator (mode 2 or m2) commands.
@@ -592,7 +605,7 @@ struct io_accel2_cmd {
592
605
__le32 tweak_upper ; /* Encryption tweak, upper 4 bytes */
593
606
struct ioaccel2_sg_element sg [IOACCEL2_MAXSGENTRIES ];
594
607
struct io_accel2_scsi_response error_data ;
595
- } __aligned (IOACCEL2_COMMANDLIST_ALIGNMENT );
608
+ } __packed __aligned (IOACCEL2_COMMANDLIST_ALIGNMENT );
596
609
597
610
/*
598
611
* defines for Mode 2 command struct
@@ -618,15 +631,15 @@ struct hpsa_tmf_struct {
618
631
__le64 abort_tag ; /* cciss tag of SCSI cmd or TMF to abort */
619
632
__le64 error_ptr ; /* Error Pointer */
620
633
__le32 error_len ; /* Error Length */
621
- } __aligned (IOACCEL2_COMMANDLIST_ALIGNMENT );
634
+ } __packed __aligned (IOACCEL2_COMMANDLIST_ALIGNMENT );
622
635
623
636
/* Configuration Table Structure */
624
637
struct HostWrite {
625
638
__le32 TransportRequest ;
626
639
__le32 command_pool_addr_hi ;
627
640
__le32 CoalIntDelay ;
628
641
__le32 CoalIntCount ;
629
- };
642
+ } __packed ;
630
643
631
644
#define SIMPLE_MODE 0x02
632
645
#define PERFORMANT_MODE 0x04
@@ -675,7 +688,7 @@ struct CfgTable {
675
688
#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE (1 << 30)
676
689
#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE (1 << 31)
677
690
__le32 clear_event_notify ;
678
- };
691
+ } __packed ;
679
692
680
693
#define NUM_BLOCKFETCH_ENTRIES 8
681
694
struct TransTable_struct {
@@ -686,14 +699,14 @@ struct TransTable_struct {
686
699
__le32 RepQCtrAddrHigh32 ;
687
700
#define MAX_REPLY_QUEUES 64
688
701
struct vals32 RepQAddr [MAX_REPLY_QUEUES ];
689
- };
702
+ } __packed ;
690
703
691
704
struct hpsa_pci_info {
692
705
unsigned char bus ;
693
706
unsigned char dev_fn ;
694
707
unsigned short domain ;
695
708
u32 board_id ;
696
- };
709
+ } __packed ;
697
710
698
711
struct bmic_identify_controller {
699
712
u8 configured_logical_drive_count ; /* offset 0 */
@@ -702,7 +715,7 @@ struct bmic_identify_controller {
702
715
u8 pad2 [136 ];
703
716
u8 controller_mode ; /* offset 292 */
704
717
u8 pad3 [32 ];
705
- };
718
+ } __packed ;
706
719
707
720
708
721
struct bmic_identify_physical_device {
@@ -845,7 +858,7 @@ struct bmic_identify_physical_device {
845
858
u8 max_link_rate [256 ];
846
859
u8 neg_phys_link_rate [256 ];
847
860
u8 box_conn_name [8 ];
848
- } __attribute((aligned (512 )));
861
+ } __packed __attribute((aligned (512 )));
849
862
850
863
struct bmic_sense_subsystem_info {
851
864
u8 primary_slot_number ;
@@ -858,7 +871,7 @@ struct bmic_sense_subsystem_info {
858
871
u8 secondary_array_serial_number [32 ];
859
872
u8 secondary_cache_serial_number [32 ];
860
873
u8 pad [332 ];
861
- };
874
+ } __packed ;
862
875
863
876
struct bmic_sense_storage_box_params {
864
877
u8 reserved [36 ];
@@ -870,7 +883,6 @@ struct bmic_sense_storage_box_params {
870
883
u8 reserver_3 [84 ];
871
884
u8 phys_connector [2 ];
872
885
u8 reserved_4 [296 ];
873
- };
886
+ } __packed ;
874
887
875
- #pragma pack()
876
888
#endif /* HPSA_CMD_H */
0 commit comments