Changeset a35b458 in mainline for uspace/drv/nic/ar9271/htc.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ar9271/htc.c
r3061bc1 ra35b458 70 70 htc_vif_msg_t vif_msg; 71 71 htc_sta_msg_t sta_msg; 72 72 73 73 memset(&vif_msg, 0, sizeof(htc_vif_msg_t)); 74 74 memset(&sta_msg, 0, sizeof(htc_sta_msg_t)); 75 75 76 76 nic_address_t addr; 77 77 nic_t *nic = 78 78 nic_get_from_ddf_dev(ieee80211_get_ddf_dev(htc_device->ieee80211_dev)); 79 79 nic_query_address(nic, &addr); 80 80 81 81 memcpy(&vif_msg.addr, &addr.address, ETH_ADDR); 82 82 memcpy(&sta_msg.addr, &addr.address, ETH_ADDR); 83 83 84 84 ieee80211_operating_mode_t op_mode = 85 85 ieee80211_query_current_op_mode(htc_device->ieee80211_dev); 86 86 87 87 switch (op_mode) { 88 88 case IEEE80211_OPMODE_ADHOC: … … 99 99 break; 100 100 } 101 101 102 102 vif_msg.index = 0; 103 103 vif_msg.rts_thres = host2uint16_t_be(HTC_RTS_THRESHOLD); 104 104 105 105 wmi_send_command(htc_device, WMI_VAP_CREATE, (uint8_t *) &vif_msg, 106 106 sizeof(vif_msg), NULL); 107 107 108 108 sta_msg.is_vif_sta = 1; 109 109 sta_msg.max_ampdu = host2uint16_t_be(0xFFFF); 110 110 sta_msg.sta_index = 0; 111 111 sta_msg.vif_index = 0; 112 112 113 113 wmi_send_command(htc_device, WMI_NODE_CREATE, (uint8_t *) &sta_msg, 114 114 sizeof(sta_msg), NULL); 115 115 116 116 /* Write first 4 bytes of MAC address. */ 117 117 uint32_t id0; … … 119 119 id0 = host2uint32_t_le(id0); 120 120 wmi_reg_write(htc_device, AR9271_STATION_ID0, id0); 121 121 122 122 /* Write last 2 bytes of MAC address (and preserve existing data). */ 123 123 uint32_t id1; 124 124 wmi_reg_read(htc_device, AR9271_STATION_ID1, &id1); 125 125 126 126 uint16_t id1_addr; 127 127 memcpy(&id1_addr, &addr.address[4], 2); 128 128 id1 = (id1 & ~AR9271_STATION_ID1_MASK) | host2uint16_t_le(id1_addr); 129 129 wmi_reg_write(htc_device, AR9271_STATION_ID1, id1); 130 130 131 131 return EOK; 132 132 } … … 136 136 { 137 137 memset(header, 0, sizeof(htc_frame_header_t)); 138 138 139 139 header->endpoint_id = endpoint_id; 140 140 header->payload_length = … … 158 158 htc_config_frame_header((htc_frame_header_t *) buffer, buffer_size, 159 159 endpoint_id); 160 160 161 161 ath_t *ath_device = htc_device->ath_device; 162 162 163 163 return ath_device->ops->send_ctrl_message(ath_device, buffer, 164 164 buffer_size); … … 181 181 htc_config_frame_header((htc_frame_header_t *) buffer, buffer_size, 182 182 endpoint_id); 183 183 184 184 ath_t *ath_device = htc_device->ath_device; 185 185 186 186 return ath_device->ops->send_data_message(ath_device, buffer, 187 187 buffer_size); … … 203 203 { 204 204 ath_t *ath_device = htc_device->ath_device; 205 205 206 206 return ath_device->ops->read_data_message(ath_device, buffer, 207 207 buffer_size, transferred_size); … … 223 223 { 224 224 ath_t *ath_device = htc_device->ath_device; 225 225 226 226 return ath_device->ops->read_ctrl_message(ath_device, buffer, 227 227 buffer_size, transferred_size); … … 246 246 void *buffer = malloc(buffer_size); 247 247 memset(buffer, 0, buffer_size); 248 248 249 249 /* Fill service message structure. */ 250 250 htc_service_msg_t *service_message = (htc_service_msg_t *) … … 259 259 wmi_service_to_upload_pipe(service_id); 260 260 service_message->connection_flags = 0; 261 261 262 262 /* Send HTC message. */ 263 263 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, … … 268 268 return rc; 269 269 } 270 270 271 271 free(buffer); 272 272 273 273 buffer_size = htc_device->ath_device->ctrl_response_length; 274 274 buffer = malloc(buffer_size); 275 275 276 276 /* Read response from device. */ 277 277 rc = htc_read_control_message(htc_device, buffer, buffer_size, NULL); … … 282 282 return rc; 283 283 } 284 284 285 285 htc_service_resp_msg_t *response_message = (htc_service_resp_msg_t *) 286 286 ((void *) buffer + sizeof(htc_frame_header_t)); 287 287 288 288 /* 289 289 * If service was successfully connected, … … 299 299 rc = EINVAL; 300 300 } 301 301 302 302 free(buffer); 303 303 304 304 return rc; 305 305 } … … 319 319 htc_config_msg_t *config_message = (htc_config_msg_t *) 320 320 ((void *) buffer + sizeof(htc_frame_header_t)); 321 321 322 322 config_message->message_id = 323 323 host2uint16_t_be(HTC_MESSAGE_CONFIG); … … 325 325 config_message->credits = 33; 326 326 config_message->pipe_id = 1; 327 327 328 328 /* Send HTC message. */ 329 329 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, … … 335 335 return rc; 336 336 } 337 337 338 338 free(buffer); 339 339 340 340 buffer_size = htc_device->ath_device->ctrl_response_length; 341 341 buffer = malloc(buffer_size); 342 342 343 343 /* Check response from device. */ 344 344 rc = htc_read_control_message(htc_device, buffer, buffer_size, NULL); … … 347 347 "Error: %s\n", str_error_name(rc)); 348 348 } 349 349 350 350 free(buffer); 351 351 352 352 return rc; 353 353 } … … 368 368 (htc_setup_complete_msg_t *) 369 369 ((void *) buffer + sizeof(htc_frame_header_t)); 370 370 371 371 complete_message->message_id = 372 372 host2uint16_t_be(HTC_MESSAGE_SETUP_COMPLETE); 373 373 374 374 /* Send HTC message. */ 375 375 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, … … 378 378 usb_log_error("Failed to send HTC setup complete message. " 379 379 "Error: %s\n", str_error_name(rc)); 380 380 381 381 free(buffer); 382 382 383 383 return rc; 384 384 } … … 398 398 size_t buffer_size = htc_device->ath_device->ctrl_response_length; 399 399 void *buffer = malloc(buffer_size); 400 400 401 401 /* Read response from device. */ 402 402 errno_t rc = htc_read_control_message(htc_device, buffer, buffer_size, … … 408 408 return rc; 409 409 } 410 410 411 411 uint16_t *message_id = (uint16_t *) ((void *) buffer + 412 412 sizeof(htc_frame_header_t)); … … 415 415 else 416 416 rc = EINVAL; 417 417 418 418 free(buffer); 419 419 420 420 return rc; 421 421 } … … 435 435 fibril_mutex_initialize(&htc_device->rx_lock); 436 436 fibril_mutex_initialize(&htc_device->tx_lock); 437 437 438 438 htc_device->endpoints.ctrl_endpoint = 0; 439 439 440 440 htc_device->ath_device = ath_device; 441 441 htc_device->ieee80211_dev = ieee80211_dev; 442 442 443 443 return EOK; 444 444 } … … 460 460 return rc; 461 461 } 462 462 463 463 /* 464 464 * HTC services initialization start. … … 470 470 return rc; 471 471 } 472 472 473 473 rc = htc_connect_service(htc_device, WMI_BEACON_SERVICE, 474 474 &htc_device->endpoints.beacon_endpoint); … … 477 477 return rc; 478 478 } 479 479 480 480 rc = htc_connect_service(htc_device, WMI_CAB_SERVICE, 481 481 &htc_device->endpoints.cab_endpoint); … … 484 484 return rc; 485 485 } 486 486 487 487 rc = htc_connect_service(htc_device, WMI_UAPSD_SERVICE, 488 488 &htc_device->endpoints.uapsd_endpoint); … … 491 491 return rc; 492 492 } 493 493 494 494 rc = htc_connect_service(htc_device, WMI_MGMT_SERVICE, 495 495 &htc_device->endpoints.mgmt_endpoint); … … 498 498 return rc; 499 499 } 500 500 501 501 rc = htc_connect_service(htc_device, WMI_DATA_BE_SERVICE, 502 502 &htc_device->endpoints.data_be_endpoint); … … 506 506 return rc; 507 507 } 508 508 509 509 rc = htc_connect_service(htc_device, WMI_DATA_BK_SERVICE, 510 510 &htc_device->endpoints.data_bk_endpoint); … … 514 514 return rc; 515 515 } 516 516 517 517 rc = htc_connect_service(htc_device, WMI_DATA_VIDEO_SERVICE, 518 518 &htc_device->endpoints.data_video_endpoint); … … 521 521 return rc; 522 522 } 523 523 524 524 rc = htc_connect_service(htc_device, WMI_DATA_VOICE_SERVICE, 525 525 &htc_device->endpoints.data_voice_endpoint); … … 528 528 return rc; 529 529 } 530 530 531 531 /* 532 532 * HTC services initialization end. 533 533 */ 534 534 535 535 /* Credits initialization message. */ 536 536 rc = htc_config_credits(htc_device); … … 539 539 return rc; 540 540 } 541 541 542 542 /* HTC setup complete confirmation message. */ 543 543 rc = htc_complete_setup(htc_device); … … 546 546 return rc; 547 547 } 548 548 549 549 usb_log_info("HTC services initialization finished successfully.\n"); 550 550 551 551 return EOK; 552 552 }
Note:
See TracChangeset
for help on using the changeset viewer.