diff --git a/iavf_ethtool.c b/iavf_ethtool.c index 74a1e9f..cea2d82 100644 --- a/iavf_ethtool.c +++ b/iavf_ethtool.c @@ -1650,7 +1650,7 @@ static void iavf_get_channels(struct net_device *netdev, struct iavf_adapter *adapter = netdev_priv(netdev); /* Report maximum channels */ - ch->max_combined = adapter->vsi_res->num_queue_pairs; + ch->max_combined = IAVF_MAX_REQ_QUEUES; ch->max_other = NONQ_VECS; ch->other_count = NONQ_VECS; @@ -1683,7 +1683,7 @@ static int iavf_set_channels(struct net_device *netdev, /* All of these should have already been checked by ethtool before this * even gets to us, but just to be sure. */ - if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs) + if (num_req <= 0 || num_req > IAVF_MAX_REQ_QUEUES) return -EINVAL; if (num_req == adapter->num_active_queues) @@ -1693,14 +1693,7 @@ static int iavf_set_channels(struct net_device *netdev, return -EINVAL; adapter->num_req_queues = num_req; - adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED; - iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); - - ret = iavf_wait_for_reset(adapter); - if (ret) - netdev_warn(netdev, "Changing channel count timeout or interrupted waiting for reset"); - - return ret; + return iavf_request_queues(adapter, num_req); } /** diff --git a/iavf_virtchnl.c b/iavf_virtchnl.c index 7e810b6..fb3286d 100644 --- a/iavf_virtchnl.c +++ b/iavf_virtchnl.c @@ -426,6 +426,33 @@ void iavf_map_queues(struct iavf_adapter *adapter) kfree(vimi); } +/** + * iavf_request_queues + * @adapter: adapter structure + * @num: number of requested queues + * + * We get a default number of queues from the PF. This enables us to request a + * different number. Returns 0 on success, negative on failure + **/ +int iavf_request_queues(struct iavf_adapter *adapter, int num) +{ + struct virtchnl_vf_res_request vfres; + + if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) { + /* bail because we already have a command pending */ + dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n", + adapter->current_op); + return -EBUSY; + } + + vfres.num_queue_pairs = min_t(int, num, num_online_cpus()); + + adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES; + adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED; + return iavf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES, + (u8 *)&vfres, sizeof(vfres)); +} + /** * iavf_set_mac_addr_type - Set the correct request type from the filter type * @virtchnl_ether_addr: pointer to requested list element