* i40e_init_adminq - main initialization routine for Admin Queue * @hw: pointer to the hardware structure * * Prior to calling this function, drivers *MUST* set the following fields * in the hw->aq structure: * - hw->aq.num_asq_entries * - hw->aq.num_arq_entries * - hw->aq.arq_buf_size * - hw->aq.asq_buf_size **/
| 649 | * - hw->aq.asq_buf_size |
| 650 | **/ |
| 651 | enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw) |
| 652 | { |
| 653 | struct i40e_adminq_info *aq = &hw->aq; |
| 654 | enum i40e_status_code ret_code; |
| 655 | u16 oem_hi = 0, oem_lo = 0; |
| 656 | u16 eetrack_hi = 0; |
| 657 | u16 eetrack_lo = 0; |
| 658 | u16 cfg_ptr = 0; |
| 659 | int retry = 0; |
| 660 | |
| 661 | /* verify input for valid configuration */ |
| 662 | if (aq->num_arq_entries == 0 || |
| 663 | aq->num_asq_entries == 0 || |
| 664 | aq->arq_buf_size == 0 || |
| 665 | aq->asq_buf_size == 0) { |
| 666 | ret_code = I40E_ERR_CONFIG; |
| 667 | goto init_adminq_exit; |
| 668 | } |
| 669 | i40e_init_spinlock(&aq->asq_spinlock); |
| 670 | i40e_init_spinlock(&aq->arq_spinlock); |
| 671 | |
| 672 | /* Set up register offsets */ |
| 673 | i40e_adminq_init_regs(hw); |
| 674 | |
| 675 | /* setup ASQ command write back timeout */ |
| 676 | hw->aq.asq_cmd_timeout = I40E_ASQ_CMD_TIMEOUT; |
| 677 | |
| 678 | /* allocate the ASQ */ |
| 679 | ret_code = i40e_init_asq(hw); |
| 680 | if (ret_code != I40E_SUCCESS) |
| 681 | goto init_adminq_destroy_spinlocks; |
| 682 | |
| 683 | /* allocate the ARQ */ |
| 684 | ret_code = i40e_init_arq(hw); |
| 685 | if (ret_code != I40E_SUCCESS) |
| 686 | goto init_adminq_free_asq; |
| 687 | |
| 688 | /* VF has no need of firmware */ |
| 689 | if (i40e_is_vf(hw)) |
| 690 | goto init_adminq_exit; |
| 691 | |
| 692 | /* There are some cases where the firmware may not be quite ready |
| 693 | * for AdminQ operations, so we retry the AdminQ setup a few times |
| 694 | * if we see timeouts in this first AQ call. |
| 695 | */ |
| 696 | do { |
| 697 | ret_code = i40e_aq_get_firmware_version(hw, |
| 698 | &aq->fw_maj_ver, |
| 699 | &aq->fw_min_ver, |
| 700 | &aq->fw_build, |
| 701 | &aq->api_maj_ver, |
| 702 | &aq->api_min_ver, |
| 703 | NULL); |
| 704 | if (ret_code != I40E_ERR_ADMIN_QUEUE_TIMEOUT) |
| 705 | break; |
| 706 | retry++; |
| 707 | i40e_msec_delay(100); |
| 708 | i40e_resume_aq(hw); |
no test coverage detected