* i40e_init_asq - main initialization routine for ASQ * @hw: pointer to the hardware structure * * This is the main initialization routine for the Admin Send Queue * Prior to calling this function, drivers *MUST* set the following fields * in the hw->aq structure: * - hw->aq.num_asq_entries * - hw->aq.arq_buf_size * * Do *NOT* hold the lock when calling this as the memory al
| 373 | * called are not going to be atomic context safe |
| 374 | **/ |
| 375 | enum i40e_status_code i40e_init_asq(struct i40e_hw *hw) |
| 376 | { |
| 377 | enum i40e_status_code ret_code = I40E_SUCCESS; |
| 378 | |
| 379 | if (hw->aq.asq.count > 0) { |
| 380 | /* queue already initialized */ |
| 381 | ret_code = I40E_ERR_NOT_READY; |
| 382 | goto init_adminq_exit; |
| 383 | } |
| 384 | |
| 385 | /* verify input for valid configuration */ |
| 386 | if ((hw->aq.num_asq_entries == 0) || |
| 387 | (hw->aq.asq_buf_size == 0)) { |
| 388 | ret_code = I40E_ERR_CONFIG; |
| 389 | goto init_adminq_exit; |
| 390 | } |
| 391 | |
| 392 | hw->aq.asq.next_to_use = 0; |
| 393 | hw->aq.asq.next_to_clean = 0; |
| 394 | |
| 395 | /* allocate the ring memory */ |
| 396 | ret_code = i40e_alloc_adminq_asq_ring(hw); |
| 397 | if (ret_code != I40E_SUCCESS) |
| 398 | goto init_adminq_exit; |
| 399 | |
| 400 | /* allocate buffers in the rings */ |
| 401 | ret_code = i40e_alloc_asq_bufs(hw); |
| 402 | if (ret_code != I40E_SUCCESS) |
| 403 | goto init_adminq_free_rings; |
| 404 | |
| 405 | /* initialize base registers */ |
| 406 | ret_code = i40e_config_asq_regs(hw); |
| 407 | if (ret_code != I40E_SUCCESS) |
| 408 | goto init_config_regs; |
| 409 | |
| 410 | /* success! */ |
| 411 | hw->aq.asq.count = hw->aq.num_asq_entries; |
| 412 | goto init_adminq_exit; |
| 413 | |
| 414 | init_adminq_free_rings: |
| 415 | i40e_free_adminq_asq(hw); |
| 416 | return ret_code; |
| 417 | |
| 418 | init_config_regs: |
| 419 | i40e_free_asq_bufs(hw); |
| 420 | |
| 421 | init_adminq_exit: |
| 422 | return ret_code; |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * i40e_init_arq - initialize ARQ |
no test coverage detected