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

staging: wfx: fix endianness of hif API

The chip expects little endian in all structs it sends/receives. This
patch fixes the hif API to reflect this fact. Sparse should now report
meaningful errors.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200406111756.154086-7-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jérôme Pouiller and committed by
Greg Kroah-Hartman
31db18cc a3d96828

+150 -150
+60 -60
drivers/staging/wfx/hif_api_cmd.h
··· 94 94 } __packed; 95 95 96 96 struct hif_req_read_mib { 97 - u16 mib_id; 98 - u16 reserved; 97 + __le16 mib_id; 98 + __le16 reserved; 99 99 } __packed; 100 100 101 101 struct hif_cnf_read_mib { 102 - u32 status; 103 - u16 mib_id; 104 - u16 length; 102 + __le32 status; 103 + __le16 mib_id; 104 + __le16 length; 105 105 u8 mib_data[]; 106 106 } __packed; 107 107 108 108 struct hif_req_write_mib { 109 - u16 mib_id; 110 - u16 length; 109 + __le16 mib_id; 110 + __le16 length; 111 111 u8 mib_data[]; 112 112 } __packed; 113 113 114 114 struct hif_cnf_write_mib { 115 - u32 status; 115 + __le32 status; 116 116 } __packed; 117 117 118 118 struct hif_ie_flags { ··· 131 131 132 132 struct hif_req_update_ie { 133 133 struct hif_ie_flags ie_flags; 134 - u16 num_ies; 134 + __le16 num_ies; 135 135 struct hif_ie_tlv ie[]; 136 136 } __packed; 137 137 138 138 struct hif_cnf_update_ie { 139 - u32 status; 139 + __le32 status; 140 140 } __packed; 141 141 142 142 struct hif_scan_type { ··· 153 153 } __packed; 154 154 155 155 struct hif_auto_scan_param { 156 - u16 interval; 156 + __le16 interval; 157 157 u8 reserved; 158 158 s8 rssi_thr; 159 159 } __packed; 160 160 161 161 struct hif_ssid_def { 162 - u32 ssid_length; 162 + __le32 ssid_length; 163 163 u8 ssid[HIF_API_SSID_SIZE]; 164 164 } __packed; 165 165 ··· 176 176 u8 probe_delay; 177 177 u8 num_of_ssids; 178 178 u8 num_of_channels; 179 - u32 min_channel_time; 180 - u32 max_channel_time; 181 - s32 tx_power_level; 179 + __le32 min_channel_time; 180 + __le32 max_channel_time; 181 + __le32 tx_power_level; // signed value 182 182 struct hif_ssid_def ssid_def[HIF_API_MAX_NB_SSIDS]; 183 183 u8 channel_list[]; 184 184 } __packed; 185 185 186 186 struct hif_cnf_start_scan { 187 - u32 status; 187 + __le32 status; 188 188 } __packed; 189 189 190 190 struct hif_cnf_stop_scan { 191 - u32 status; 191 + __le32 status; 192 192 } __packed; 193 193 194 194 enum hif_pm_mode_status { ··· 198 198 }; 199 199 200 200 struct hif_ind_scan_cmpl { 201 - u32 status; 201 + __le32 status; 202 202 u8 pm_mode; 203 203 u8 num_channels_completed; 204 - u16 reserved; 204 + __le16 reserved; 205 205 } __packed; 206 206 207 207 enum hif_queue_id { ··· 254 254 } __packed; 255 255 256 256 struct hif_req_tx { 257 - u32 packet_id; 257 + __le32 packet_id; 258 258 u8 max_tx_rate; 259 259 struct hif_queue queue_id; 260 260 struct hif_data_flags data_flags; 261 261 struct hif_tx_flags tx_flags; 262 - u32 reserved; 263 - u32 expire_time; 262 + __le32 reserved; 263 + __le32 expire_time; 264 264 struct hif_ht_tx_parameters ht_tx_parameters; 265 265 u8 frame[]; 266 266 } __packed; ··· 282 282 } __packed; 283 283 284 284 struct hif_cnf_tx { 285 - u32 status; 286 - u32 packet_id; 285 + __le32 status; 286 + __le32 packet_id; 287 287 u8 txed_rate; 288 288 u8 ack_failures; 289 289 struct hif_tx_result_flags tx_result_flags; 290 - u32 media_delay; 291 - u32 tx_queue_delay; 290 + __le32 media_delay; 291 + __le32 tx_queue_delay; 292 292 } __packed; 293 293 294 294 struct hif_cnf_multi_transmit { 295 - u32 num_tx_confs; 295 + __le32 num_tx_confs; 296 296 struct hif_cnf_tx tx_conf_payload[]; 297 297 } __packed; 298 298 ··· 331 331 } __packed; 332 332 333 333 struct hif_ind_rx { 334 - u32 status; 335 - u16 channel_number; 334 + __le32 status; 335 + __le16 channel_number; 336 336 u8 rxed_rate; 337 337 u8 rcpi_rssi; 338 338 struct hif_rx_flags rx_flags; ··· 345 345 u8 reserved1; 346 346 u8 aifsn; 347 347 u8 reserved2; 348 - u16 cw_min; 349 - u16 cw_max; 350 - u16 tx_op_limit; 351 - u16 allowed_medium_time; 352 - u32 reserved3; 348 + __le16 cw_min; 349 + __le16 cw_max; 350 + __le16 tx_op_limit; 351 + __le16 allowed_medium_time; 352 + __le32 reserved3; 353 353 } __packed; 354 354 355 355 struct hif_cnf_edca_queue_params { 356 - u32 status; 356 + __le32 status; 357 357 } __packed; 358 358 359 359 struct hif_join_flags { ··· 367 367 u8 infrastructure_bss_mode:1; 368 368 u8 reserved1:7; 369 369 u8 band; 370 - u16 channel_number; 370 + __le16 channel_number; 371 371 u8 bssid[ETH_ALEN]; 372 - u16 atim_window; 372 + __le16 atim_window; 373 373 u8 short_preamble:1; 374 374 u8 reserved2:7; 375 375 u8 probe_for_join; 376 376 u8 reserved3; 377 377 struct hif_join_flags join_flags; 378 - u32 ssid_length; 378 + __le32 ssid_length; 379 379 u8 ssid[HIF_API_SSID_SIZE]; 380 - u32 beacon_interval; 381 - u32 basic_rate_set; 380 + __le32 beacon_interval; 381 + __le32 basic_rate_set; 382 382 } __packed; 383 383 384 384 struct hif_cnf_join { 385 - u32 status; 385 + __le32 status; 386 386 } __packed; 387 387 388 388 struct hif_ind_join_complete { 389 - u32 status; 389 + __le32 status; 390 390 } __packed; 391 391 392 392 struct hif_bss_flags { ··· 397 397 struct hif_req_set_bss_params { 398 398 struct hif_bss_flags bss_flags; 399 399 u8 beacon_lost_count; 400 - u16 aid; 401 - u32 operational_rate_set; 400 + __le16 aid; 401 + __le32 operational_rate_set; 402 402 } __packed; 403 403 404 404 struct hif_cnf_set_bss_params { 405 - u32 status; 405 + __le32 status; 406 406 } __packed; 407 407 408 408 struct hif_pm_mode { ··· 419 419 } __packed; 420 420 421 421 struct hif_cnf_set_pm_mode { 422 - u32 status; 422 + __le32 status; 423 423 } __packed; 424 424 425 425 struct hif_ind_set_pm_mode_cmpl { 426 - u32 status; 426 + __le32 status; 427 427 u8 pm_mode; 428 428 u8 reserved[3]; 429 429 } __packed; ··· 432 432 struct hif_req_start { 433 433 u8 mode; 434 434 u8 band; 435 - u16 channel_number; 436 - u32 reserved1; 437 - u32 beacon_interval; 435 + __le16 channel_number; 436 + __le32 reserved1; 437 + __le32 beacon_interval; 438 438 u8 dtim_period; 439 439 u8 short_preamble:1; 440 440 u8 reserved2:7; 441 441 u8 reserved3; 442 442 u8 ssid_length; 443 443 u8 ssid[HIF_API_SSID_SIZE]; 444 - u32 basic_rate_set; 444 + __le32 basic_rate_set; 445 445 } __packed; 446 446 447 447 struct hif_cnf_start { 448 - u32 status; 448 + __le32 status; 449 449 } __packed; 450 450 451 451 enum hif_beacon { ··· 459 459 } __packed; 460 460 461 461 struct hif_cnf_beacon_transmit { 462 - u32 status; 462 + __le32 status; 463 463 } __packed; 464 464 465 465 #define HIF_LINK_ID_MAX 14 ··· 483 483 } __packed; 484 484 485 485 struct hif_cnf_map_link { 486 - u32 status; 486 + __le32 status; 487 487 } __packed; 488 488 489 489 struct hif_suspend_resume_flags { ··· 496 496 497 497 struct hif_ind_suspend_resume_tx { 498 498 struct hif_suspend_resume_flags suspend_resume_flags; 499 - u16 peer_sta_set; 499 + __le16 peer_sta_set; 500 500 } __packed; 501 501 502 502 ··· 612 612 } __packed; 613 613 614 614 struct hif_cnf_add_key { 615 - u32 status; 615 + __le32 status; 616 616 } __packed; 617 617 618 618 struct hif_req_remove_key { ··· 621 621 } __packed; 622 622 623 623 struct hif_cnf_remove_key { 624 - u32 status; 624 + __le32 status; 625 625 } __packed; 626 626 627 627 enum hif_event_ind { ··· 642 642 643 643 union hif_event_data { 644 644 u8 rcpi_rssi; 645 - u32 ps_mode_error; 646 - u32 peer_sta_set; 645 + __le32 ps_mode_error; 646 + __le32 peer_sta_set; 647 647 }; 648 648 649 649 struct hif_ind_event { 650 - u32 event_id; 650 + __le32 event_id; 651 651 union hif_event_data event_data; 652 652 } __packed; 653 653
+28 -28
drivers/staging/wfx/hif_api_general.h
··· 23 23 #define HIF_COUNTER_MAX 7 24 24 25 25 struct hif_msg { 26 - u16 len; 26 + __le16 len; 27 27 u8 id; 28 28 u8 reserved:1; 29 29 u8 interface:2; ··· 136 136 } __packed; 137 137 138 138 struct hif_ind_startup { 139 - u32 status; 140 - u16 hardware_id; 139 + __le32 status; 140 + __le16 hardware_id; 141 141 u8 opn[14]; 142 142 u8 uid[8]; 143 - u16 num_inp_ch_bufs; 144 - u16 size_inp_ch_buf; 143 + __le16 num_inp_ch_bufs; 144 + __le16 size_inp_ch_buf; 145 145 u8 num_links_ap; 146 146 u8 num_interfaces; 147 147 u8 mac_addr[2][ETH_ALEN]; ··· 155 155 u8 disabled_channel_list[2]; 156 156 struct hif_otp_regul_sel_mode_info regul_sel_mode_info; 157 157 struct hif_otp_phy_info otp_phy_info; 158 - u32 supported_rate_mask; 158 + __le32 supported_rate_mask; 159 159 u8 firmware_label[128]; 160 160 } __packed; 161 161 ··· 163 163 } __packed; 164 164 165 165 struct hif_req_configuration { 166 - u16 length; 166 + __le16 length; 167 167 u8 pds_data[]; 168 168 } __packed; 169 169 170 170 struct hif_cnf_configuration { 171 - u32 status; 171 + __le32 status; 172 172 } __packed; 173 173 174 174 enum hif_gpio_mode { ··· 187 187 } __packed; 188 188 189 189 struct hif_cnf_control_gpio { 190 - u32 status; 191 - u32 value; 190 + __le32 status; 191 + __le32 value; 192 192 } __packed; 193 193 194 194 enum hif_generic_indication_type { ··· 198 198 }; 199 199 200 200 struct hif_rx_stats { 201 - u32 nb_rx_frame; 202 - u32 nb_crc_frame; 203 - u32 per_total; 204 - u32 throughput; 205 - u32 nb_rx_by_rate[API_RATE_NUM_ENTRIES]; 206 - u16 per[API_RATE_NUM_ENTRIES]; 207 - s16 snr[API_RATE_NUM_ENTRIES]; 208 - s16 rssi[API_RATE_NUM_ENTRIES]; 209 - s16 cfo[API_RATE_NUM_ENTRIES]; 210 - u32 date; 211 - u32 pwr_clk_freq; 201 + __le32 nb_rx_frame; 202 + __le32 nb_crc_frame; 203 + __le32 per_total; 204 + __le32 throughput; 205 + __le32 nb_rx_by_rate[API_RATE_NUM_ENTRIES]; 206 + __le16 per[API_RATE_NUM_ENTRIES]; 207 + __le16 snr[API_RATE_NUM_ENTRIES]; // signed value 208 + __le16 rssi[API_RATE_NUM_ENTRIES]; // signed value 209 + __le16 cfo[API_RATE_NUM_ENTRIES]; // signed value 210 + __le32 date; 211 + __le32 pwr_clk_freq; 212 212 u8 is_ext_pwr_clk; 213 213 s8 current_temp; 214 214 } __packed; ··· 219 219 }; 220 220 221 221 struct hif_ind_generic { 222 - u32 indication_type; 222 + __le32 indication_type; 223 223 union hif_indication_data indication_data; 224 224 } __packed; 225 225 ··· 244 244 }; 245 245 246 246 struct hif_ind_error { 247 - u32 type; 247 + __le32 type; 248 248 u8 data[]; 249 249 } __packed; 250 250 ··· 269 269 270 270 struct hif_sl_msg { 271 271 struct hif_sl_msg_hdr hdr; 272 - u16 len; 272 + __le16 len; 273 273 u8 payload[]; 274 274 } __packed; 275 275 ··· 292 292 } __packed; 293 293 294 294 struct hif_cnf_set_sl_mac_key { 295 - u32 status; 295 + __le32 status; 296 296 } __packed; 297 297 298 298 enum hif_sl_session_key_alg { ··· 312 312 } __packed; 313 313 314 314 struct hif_cnf_sl_exchange_pub_keys { 315 - u32 status; 315 + __le32 status; 316 316 } __packed; 317 317 318 318 #define API_NCP_PUB_KEY_SIZE 32 319 319 #define API_NCP_PUB_KEY_MAC_SIZE 64 320 320 321 321 struct hif_ind_sl_exchange_pub_keys { 322 - u32 status; 322 + __le32 status; 323 323 u8 ncp_pub_key[API_NCP_PUB_KEY_SIZE]; 324 324 u8 ncp_pub_key_mac[API_NCP_PUB_KEY_MAC_SIZE]; 325 325 } __packed; ··· 332 332 } __packed; 333 333 334 334 struct hif_cnf_sl_configure { 335 - u32 status; 335 + __le32 status; 336 336 } __packed; 337 337 338 338 #endif
+62 -62
drivers/staging/wfx/hif_api_mib.h
··· 161 161 } __packed; 162 162 163 163 struct hif_mib_bcn_filter_table { 164 - u32 num_of_info_elmts; 164 + __le32 num_of_info_elmts; 165 165 struct hif_ie_table_entry ie_table[]; 166 166 } __packed; 167 167 ··· 172 172 }; 173 173 174 174 struct hif_mib_bcn_filter_enable { 175 - u32 enable; 176 - u32 bcn_count; 175 + __le32 enable; 176 + __le32 bcn_count; 177 177 } __packed; 178 178 179 179 struct hif_mib_extended_count_table { 180 - u32 count_plcp_errors; 181 - u32 count_fcs_errors; 182 - u32 count_tx_packets; 183 - u32 count_rx_packets; 184 - u32 count_rx_packet_errors; 185 - u32 count_rx_decryption_failures; 186 - u32 count_rx_mic_failures; 187 - u32 count_rx_no_key_failures; 188 - u32 count_tx_multicast_frames; 189 - u32 count_tx_frames_success; 190 - u32 count_tx_frame_failures; 191 - u32 count_tx_frames_retried; 192 - u32 count_tx_frames_multi_retried; 193 - u32 count_rx_frame_duplicates; 194 - u32 count_rts_success; 195 - u32 count_rts_failures; 196 - u32 count_ack_failures; 197 - u32 count_rx_multicast_frames; 198 - u32 count_rx_frames_success; 199 - u32 count_rx_cmacicv_errors; 200 - u32 count_rx_cmac_replays; 201 - u32 count_rx_mgmt_ccmp_replays; 202 - u32 count_rx_bipmic_errors; 203 - u32 count_rx_beacon; 204 - u32 count_miss_beacon; 205 - u32 reserved[15]; 180 + __le32 count_plcp_errors; 181 + __le32 count_fcs_errors; 182 + __le32 count_tx_packets; 183 + __le32 count_rx_packets; 184 + __le32 count_rx_packet_errors; 185 + __le32 count_rx_decryption_failures; 186 + __le32 count_rx_mic_failures; 187 + __le32 count_rx_no_key_failures; 188 + __le32 count_tx_multicast_frames; 189 + __le32 count_tx_frames_success; 190 + __le32 count_tx_frame_failures; 191 + __le32 count_tx_frames_retried; 192 + __le32 count_tx_frames_multi_retried; 193 + __le32 count_rx_frame_duplicates; 194 + __le32 count_rts_success; 195 + __le32 count_rts_failures; 196 + __le32 count_ack_failures; 197 + __le32 count_rx_multicast_frames; 198 + __le32 count_rx_frames_success; 199 + __le32 count_rx_cmacicv_errors; 200 + __le32 count_rx_cmac_replays; 201 + __le32 count_rx_mgmt_ccmp_replays; 202 + __le32 count_rx_bipmic_errors; 203 + __le32 count_rx_beacon; 204 + __le32 count_miss_beacon; 205 + __le32 reserved[15]; 206 206 } __packed; 207 207 208 208 struct hif_mib_count_table { 209 - u32 count_plcp_errors; 210 - u32 count_fcs_errors; 211 - u32 count_tx_packets; 212 - u32 count_rx_packets; 213 - u32 count_rx_packet_errors; 214 - u32 count_rx_decryption_failures; 215 - u32 count_rx_mic_failures; 216 - u32 count_rx_no_key_failures; 217 - u32 count_tx_multicast_frames; 218 - u32 count_tx_frames_success; 219 - u32 count_tx_frame_failures; 220 - u32 count_tx_frames_retried; 221 - u32 count_tx_frames_multi_retried; 222 - u32 count_rx_frame_duplicates; 223 - u32 count_rts_success; 224 - u32 count_rts_failures; 225 - u32 count_ack_failures; 226 - u32 count_rx_multicast_frames; 227 - u32 count_rx_frames_success; 228 - u32 count_rx_cmacicv_errors; 229 - u32 count_rx_cmac_replays; 230 - u32 count_rx_mgmt_ccmp_replays; 231 - u32 count_rx_bipmic_errors; 209 + __le32 count_plcp_errors; 210 + __le32 count_fcs_errors; 211 + __le32 count_tx_packets; 212 + __le32 count_rx_packets; 213 + __le32 count_rx_packet_errors; 214 + __le32 count_rx_decryption_failures; 215 + __le32 count_rx_mic_failures; 216 + __le32 count_rx_no_key_failures; 217 + __le32 count_tx_multicast_frames; 218 + __le32 count_tx_frames_success; 219 + __le32 count_tx_frame_failures; 220 + __le32 count_tx_frames_retried; 221 + __le32 count_tx_frames_multi_retried; 222 + __le32 count_rx_frame_duplicates; 223 + __le32 count_rts_success; 224 + __le32 count_rts_failures; 225 + __le32 count_ack_failures; 226 + __le32 count_rx_multicast_frames; 227 + __le32 count_rx_frames_success; 228 + __le32 count_rx_cmacicv_errors; 229 + __le32 count_rx_cmac_replays; 230 + __le32 count_rx_mgmt_ccmp_replays; 231 + __le32 count_rx_bipmic_errors; 232 232 } __packed; 233 233 234 234 struct hif_mib_mac_address { 235 235 u8 mac_addr[ETH_ALEN]; 236 - u16 reserved; 236 + __le16 reserved; 237 237 } __packed; 238 238 239 239 struct hif_mib_wep_default_key_id { ··· 242 242 } __packed; 243 243 244 244 struct hif_mib_dot11_rts_threshold { 245 - u32 threshold; 245 + __le32 threshold; 246 246 } __packed; 247 247 248 248 struct hif_mib_slot_time { 249 - u32 slot_time; 249 + __le32 slot_time; 250 250 } __packed; 251 251 252 252 struct hif_mib_current_tx_power_level { 253 - s32 power_level; 253 + __le32 power_level; // signed value 254 254 } __packed; 255 255 256 256 struct hif_mib_non_erp_protection { ··· 274 274 u8 frame_type; 275 275 u8 init_rate:7; 276 276 u8 mode:1; 277 - u16 frame_length; 277 + __le16 frame_length; 278 278 u8 frame[700]; 279 279 } __packed; 280 280 ··· 328 328 u8 greenfield:1; 329 329 u8 reserved3:7; 330 330 u8 mpdu_start_spacing; 331 - u32 basic_rate_set; 331 + __le32 basic_rate_set; 332 332 } __packed; 333 333 334 334 struct hif_mib_set_uapsd_information { ··· 342 342 u8 deliv_video:1; 343 343 u8 deliv_voice:1; 344 344 u8 reserved2:4; 345 - u16 min_auto_trigger_interval; 346 - u16 max_auto_trigger_interval; 347 - u16 auto_trigger_step; 345 + __le16 min_auto_trigger_interval; 346 + __le16 max_auto_trigger_interval; 347 + __le16 auto_trigger_step; 348 348 } __packed; 349 349 350 350 struct hif_mib_tx_rate_retry_policy { ··· 384 384 } __packed; 385 385 386 386 struct hif_mib_keep_alive_period { 387 - u16 keep_alive_period; 387 + __le16 keep_alive_period; 388 388 u8 reserved[2]; 389 389 } __packed; 390 390