| 600 | } |
| 601 | |
| 602 | int txgbevf_get_queues(struct txgbe_hw *hw, unsigned int *num_tcs, |
| 603 | unsigned int *default_tc) |
| 604 | { |
| 605 | int err, i; |
| 606 | u32 msg[5]; |
| 607 | |
| 608 | /* do nothing if API doesn't support txgbevf_get_queues */ |
| 609 | switch (hw->api_version) { |
| 610 | case txgbe_mbox_api_11: |
| 611 | case txgbe_mbox_api_12: |
| 612 | case txgbe_mbox_api_13: |
| 613 | break; |
| 614 | default: |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | /* Fetch queue configuration from the PF */ |
| 619 | msg[0] = TXGBE_VF_GET_QUEUES; |
| 620 | for (i = 1; i < 5; i++) |
| 621 | msg[i] = 0; |
| 622 | |
| 623 | err = txgbevf_write_msg_read_ack(hw, msg, msg, 5); |
| 624 | if (!err) { |
| 625 | msg[0] &= ~TXGBE_VT_MSGTYPE_CTS; |
| 626 | |
| 627 | /* |
| 628 | * if we didn't get an ACK there must have been |
| 629 | * some sort of mailbox error so we should treat it |
| 630 | * as such |
| 631 | */ |
| 632 | if (msg[0] != (TXGBE_VF_GET_QUEUES | TXGBE_VT_MSGTYPE_ACK)) |
| 633 | return TXGBE_ERR_MBX; |
| 634 | |
| 635 | /* record and validate values from message */ |
| 636 | hw->mac.max_tx_queues = msg[TXGBE_VF_TX_QUEUES]; |
| 637 | if (hw->mac.max_tx_queues == 0 || |
| 638 | hw->mac.max_tx_queues > TXGBE_VF_MAX_TX_QUEUES) |
| 639 | hw->mac.max_tx_queues = TXGBE_VF_MAX_TX_QUEUES; |
| 640 | |
| 641 | hw->mac.max_rx_queues = msg[TXGBE_VF_RX_QUEUES]; |
| 642 | if (hw->mac.max_rx_queues == 0 || |
| 643 | hw->mac.max_rx_queues > TXGBE_VF_MAX_RX_QUEUES) |
| 644 | hw->mac.max_rx_queues = TXGBE_VF_MAX_RX_QUEUES; |
| 645 | |
| 646 | *num_tcs = msg[TXGBE_VF_TRANS_VLAN]; |
| 647 | /* in case of unknown state assume we cannot tag frames */ |
| 648 | if (*num_tcs > hw->mac.max_rx_queues) |
| 649 | *num_tcs = 1; |
| 650 | |
| 651 | *default_tc = msg[TXGBE_VF_DEF_QUEUE]; |
| 652 | /* default to queue 0 on out-of-bounds queue number */ |
| 653 | if (*default_tc >= hw->mac.max_tx_queues) |
| 654 | *default_tc = 0; |
| 655 | } |
| 656 | |
| 657 | return err; |
| 658 | } |
no test coverage detected