Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libertas: Fix alignment issues in libertas core

Data structures that come over the wire from the WLAN firmware must be packed.
This fixes alignment problems on the blackfin architecture and, reportedly, on
the AVR32.

This is a replacement for the previous version of this patch which had also
explicitly used get_unaligned_ macros. As Johannes Berg pointed out, these
macros were unnecessary.

Signed-off-by: Andrey Yurovsky <andrey@cozybit.com>
Signed-off-by: Colin McCabe <colin@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Andrey Yurovsky and committed by
John W. Linville
d71038c0 b6b50a21

+45 -46
+45 -46
drivers/net/wireless/libertas/hostcmd.h
··· 32 32 u8 pktdelay_2ms; 33 33 /* reserved */ 34 34 u8 reserved1; 35 - }; 35 + } __attribute__ ((packed)); 36 36 37 37 /* RxPD Descriptor */ 38 38 struct rxpd { ··· 63 63 /* Pkt Priority */ 64 64 u8 priority; 65 65 u8 reserved[3]; 66 - }; 66 + } __attribute__ ((packed)); 67 67 68 68 struct cmd_header { 69 69 __le16 command; ··· 97 97 struct lbs_offset_value { 98 98 u32 offset; 99 99 u32 value; 100 - }; 100 + } __attribute__ ((packed)); 101 101 102 102 /* Define general data structure */ 103 103 /* cmd_DS_GEN */ ··· 107 107 __le16 seqnum; 108 108 __le16 result; 109 109 void *cmdresp[0]; 110 - }; 110 + } __attribute__ ((packed)); 111 111 112 112 #define S_DS_GEN sizeof(struct cmd_ds_gen) 113 113 ··· 163 163 * bump this up a bit. 164 164 */ 165 165 uint8_t tlv[128]; 166 - }; 166 + } __attribute__ ((packed)); 167 167 168 168 /* 169 169 * This scan handle Country Information IE(802.11d compliant) ··· 180 180 mrvlietypes_chanlistparamset_t ChanListParamSet; 181 181 mrvlietypes_ratesparamset_t OpRateSet; 182 182 #endif 183 - }; 183 + } __attribute__ ((packed)); 184 184 185 185 struct cmd_ds_802_11_scan_rsp { 186 186 struct cmd_header hdr; ··· 188 188 __le16 bssdescriptsize; 189 189 uint8_t nr_sets; 190 190 uint8_t bssdesc_and_tlvbuffer[0]; 191 - }; 191 + } __attribute__ ((packed)); 192 192 193 193 struct cmd_ds_802_11_get_log { 194 194 struct cmd_header hdr; ··· 206 206 __le32 fcserror; 207 207 __le32 txframe; 208 208 __le32 wepundecryptable; 209 - }; 209 + } __attribute__ ((packed)); 210 210 211 211 struct cmd_ds_mac_control { 212 212 struct cmd_header hdr; 213 213 __le16 action; 214 214 u16 reserved; 215 - }; 215 + } __attribute__ ((packed)); 216 216 217 217 struct cmd_ds_mac_multicast_adr { 218 218 struct cmd_header hdr; 219 219 __le16 action; 220 220 __le16 nr_of_adrs; 221 221 u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE]; 222 - }; 222 + } __attribute__ ((packed)); 223 223 224 224 struct cmd_ds_802_11_authenticate { 225 225 u8 macaddr[ETH_ALEN]; 226 226 u8 authtype; 227 227 u8 reserved[10]; 228 - }; 228 + } __attribute__ ((packed)); 229 229 230 230 struct cmd_ds_802_11_deauthenticate { 231 231 struct cmd_header hdr; 232 232 233 233 u8 macaddr[ETH_ALEN]; 234 234 __le16 reasoncode; 235 - }; 235 + } __attribute__ ((packed)); 236 236 237 237 struct cmd_ds_802_11_associate { 238 238 u8 peerstaaddr[6]; ··· 251 251 252 252 struct cmd_ds_802_11_associate_rsp { 253 253 struct ieeetypes_assocrsp assocRsp; 254 - }; 254 + } __attribute__ ((packed)); 255 255 256 256 struct cmd_ds_802_11_set_wep { 257 257 struct cmd_header hdr; ··· 265 265 /* 40, 128bit or TXWEP */ 266 266 uint8_t keytype[4]; 267 267 uint8_t keymaterial[4][16]; 268 - }; 268 + } __attribute__ ((packed)); 269 269 270 270 struct cmd_ds_802_3_get_stat { 271 271 __le32 xmitok; ··· 274 274 __le32 rcverror; 275 275 __le32 rcvnobuffer; 276 276 __le32 rcvcrcerror; 277 - }; 277 + } __attribute__ ((packed)); 278 278 279 279 struct cmd_ds_802_11_get_stat { 280 280 __le32 txfragmentcnt; ··· 294 294 __le32 txbeacon; 295 295 __le32 rxbeacon; 296 296 __le32 wepundecryptable; 297 - }; 297 + } __attribute__ ((packed)); 298 298 299 299 struct cmd_ds_802_11_snmp_mib { 300 300 struct cmd_header hdr; ··· 303 303 __le16 oid; 304 304 __le16 bufsize; 305 305 u8 value[128]; 306 - }; 306 + } __attribute__ ((packed)); 307 307 308 308 struct cmd_ds_mac_reg_map { 309 309 __le16 buffersize; 310 310 u8 regmap[128]; 311 311 __le16 reserved; 312 - }; 312 + } __attribute__ ((packed)); 313 313 314 314 struct cmd_ds_bbp_reg_map { 315 315 __le16 buffersize; 316 316 u8 regmap[128]; 317 317 __le16 reserved; 318 - }; 318 + } __attribute__ ((packed)); 319 319 320 320 struct cmd_ds_rf_reg_map { 321 321 __le16 buffersize; 322 322 u8 regmap[64]; 323 323 __le16 reserved; 324 - }; 324 + } __attribute__ ((packed)); 325 325 326 326 struct cmd_ds_mac_reg_access { 327 327 __le16 action; 328 328 __le16 offset; 329 329 __le32 value; 330 - }; 330 + } __attribute__ ((packed)); 331 331 332 332 struct cmd_ds_bbp_reg_access { 333 333 __le16 action; 334 334 __le16 offset; 335 335 u8 value; 336 336 u8 reserved[3]; 337 - }; 337 + } __attribute__ ((packed)); 338 338 339 339 struct cmd_ds_rf_reg_access { 340 340 __le16 action; 341 341 __le16 offset; 342 342 u8 value; 343 343 u8 reserved[3]; 344 - }; 344 + } __attribute__ ((packed)); 345 345 346 346 struct cmd_ds_802_11_radio_control { 347 347 struct cmd_header hdr; 348 348 349 349 __le16 action; 350 350 __le16 control; 351 - }; 351 + } __attribute__ ((packed)); 352 352 353 353 struct cmd_ds_802_11_beacon_control { 354 354 __le16 action; 355 355 __le16 beacon_enable; 356 356 __le16 beacon_period; 357 - }; 357 + } __attribute__ ((packed)); 358 358 359 359 struct cmd_ds_802_11_sleep_params { 360 360 struct cmd_header hdr; ··· 379 379 380 380 /* reserved field, should be set to zero */ 381 381 __le16 reserved; 382 - }; 382 + } __attribute__ ((packed)); 383 383 384 384 struct cmd_ds_802_11_inactivity_timeout { 385 385 struct cmd_header hdr; ··· 389 389 390 390 /* Inactivity timeout in msec */ 391 391 __le16 timeout; 392 - }; 392 + } __attribute__ ((packed)); 393 393 394 394 struct cmd_ds_802_11_rf_channel { 395 395 struct cmd_header hdr; ··· 399 399 __le16 rftype; /* unused */ 400 400 __le16 reserved; /* unused */ 401 401 u8 channellist[32]; /* unused */ 402 - }; 402 + } __attribute__ ((packed)); 403 403 404 404 struct cmd_ds_802_11_rssi { 405 405 /* weighting factor */ ··· 408 408 __le16 reserved_0; 409 409 __le16 reserved_1; 410 410 __le16 reserved_2; 411 - }; 411 + } __attribute__ ((packed)); 412 412 413 413 struct cmd_ds_802_11_rssi_rsp { 414 414 __le16 SNR; 415 415 __le16 noisefloor; 416 416 __le16 avgSNR; 417 417 __le16 avgnoisefloor; 418 - }; 418 + } __attribute__ ((packed)); 419 419 420 420 struct cmd_ds_802_11_mac_address { 421 421 struct cmd_header hdr; 422 422 423 423 __le16 action; 424 424 u8 macadd[ETH_ALEN]; 425 - }; 425 + } __attribute__ ((packed)); 426 426 427 427 struct cmd_ds_802_11_rf_tx_power { 428 428 struct cmd_header hdr; ··· 431 431 __le16 curlevel; 432 432 s8 maxlevel; 433 433 s8 minlevel; 434 - }; 434 + } __attribute__ ((packed)); 435 435 436 436 struct cmd_ds_802_11_rf_antenna { 437 437 __le16 action; ··· 439 439 /* Number of antennas or 0xffff(diversity) */ 440 440 __le16 antennamode; 441 441 442 - }; 442 + } __attribute__ ((packed)); 443 443 444 444 struct cmd_ds_802_11_monitor_mode { 445 445 __le16 action; 446 446 __le16 mode; 447 - }; 447 + } __attribute__ ((packed)); 448 448 449 449 struct cmd_ds_set_boot2_ver { 450 450 struct cmd_header hdr; 451 451 452 452 __le16 action; 453 453 __le16 version; 454 - }; 454 + } __attribute__ ((packed)); 455 455 456 456 struct cmd_ds_802_11_fw_wake_method { 457 457 struct cmd_header hdr; 458 458 459 459 __le16 action; 460 460 __le16 method; 461 - }; 461 + } __attribute__ ((packed)); 462 462 463 463 struct cmd_ds_802_11_sleep_period { 464 464 struct cmd_header hdr; 465 465 466 466 __le16 action; 467 467 __le16 period; 468 - }; 468 + } __attribute__ ((packed)); 469 469 470 470 struct cmd_ds_802_11_ps_mode { 471 471 __le16 action; ··· 473 473 __le16 multipledtim; 474 474 __le16 reserved; 475 475 __le16 locallisteninterval; 476 - }; 476 + } __attribute__ ((packed)); 477 477 478 478 struct cmd_confirm_sleep { 479 479 struct cmd_header hdr; ··· 483 483 __le16 multipledtim; 484 484 __le16 reserved; 485 485 __le16 locallisteninterval; 486 - }; 486 + } __attribute__ ((packed)); 487 487 488 488 struct cmd_ds_802_11_data_rate { 489 489 struct cmd_header hdr; ··· 491 491 __le16 action; 492 492 __le16 reserved; 493 493 u8 rates[MAX_RATES]; 494 - }; 494 + } __attribute__ ((packed)); 495 495 496 496 struct cmd_ds_802_11_rate_adapt_rateset { 497 497 struct cmd_header hdr; 498 498 __le16 action; 499 499 __le16 enablehwauto; 500 500 __le16 bitmap; 501 - }; 501 + } __attribute__ ((packed)); 502 502 503 503 struct cmd_ds_802_11_ad_hoc_start { 504 504 struct cmd_header hdr; ··· 520 520 521 521 u8 pad[3]; 522 522 u8 bssid[ETH_ALEN]; 523 - }; 523 + } __attribute__ ((packed)); 524 524 525 525 struct adhoc_bssdesc { 526 526 u8 bssid[ETH_ALEN]; ··· 578 578 579 579 /* key material of size keylen */ 580 580 u8 key[32]; 581 - }; 581 + } __attribute__ ((packed)); 582 582 583 583 #define MAX_WOL_RULES 16 584 584 ··· 590 590 __le16 reserve; 591 591 __be32 sig_mask; 592 592 __be32 signature; 593 - }; 593 + } __attribute__ ((packed)); 594 594 595 595 struct wol_config { 596 596 uint8_t action; ··· 598 598 uint8_t no_rules_in_cmd; 599 599 uint8_t result; 600 600 struct host_wol_rule rule[MAX_WOL_RULES]; 601 - }; 602 - 601 + } __attribute__ ((packed)); 603 602 604 603 struct cmd_ds_host_sleep { 605 604 struct cmd_header hdr;