Re: [PATCH iwl-next v2 5/5] iavf: Add VIRTCHNL Opcodes Support for Queue bw Setting

Brett Creeley
2023-08-16T17:33:13Z

On 8/7/2023 6:57 PM, Wenjun Wu wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> From: Jun Zhang <xuejun.zhang@intel.com>
>
> iavf rate tree with root node and queue nodes is created and registered
> with devlink rate when iavf adapter is configured.
>
> User can configure the tx_max and tx_share of each queue. If any one of
> the queues have been fully updated by user, i.e. both tx_max and
> tx_share have been updated for that queue, VIRTCHNL opcodes of
> VIRTCHNL_OP_CONFIG_QUEUE_BW and VIRTCHNL_OP_CONFIG_QUANTA will be sent
> to PF to configure queues allocated to VF if PF indicates support of
> VIRTCHNL_VF_OFFLOAD_QOS through VF Resource / Capability Exchange.
>
> Signed-off-by: Jun Zhang <xuejun.zhang@intel.com>
> ---
> drivers/net/ethernet/intel/iavf/iavf.h | 14 ++
> .../net/ethernet/intel/iavf/iavf_devlink.c | 29 +++
> .../net/ethernet/intel/iavf/iavf_devlink.h | 1 +
> drivers/net/ethernet/intel/iavf/iavf_main.c | 45 +++-
> .../net/ethernet/intel/iavf/iavf_virtchnl.c | 228 +++++++++++++++++-
> 5 files changed, 313 insertions(+), 4 deletions(-)
>

[...]

> +/**
> + * iavf_set_tc_queue_bw - set bw of allocated tc/queues
> + * @adapter: iavf adapter struct instance
> + *
> + * This function requests PF to set queue bw of multiple tc(s)
> + */
> +static void iavf_set_tc_queue_bw(struct iavf_adapter *adapter)
> +{
> + struct iavf_devlink *dl_priv = devlink_priv(adapter->devlink);
> + struct virtchnl_queues_bw_cfg *queues_bw_cfg;
> + struct iavf_dev_rate_node *queue_rate;
> + u16 queue_to_tc[256];
> + size_t len;
> + int q_idx;
> + int i, j;

> + u16 tc;
> +
> + if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
> + /* bail because we already have a command pending */
> + dev_err(&adapter->pdev->dev,
> + "Cannot set tc queue bw, command %d pending\n",
> + adapter->current_op);
> + return;
> + }
> +
> + len = struct_size(queues_bw_cfg, cfg, adapter->num_active_queues);
> + queues_bw_cfg = kzalloc(len, GFP_KERNEL);
> + if (!queues_bw_cfg)
> + return;
> +
> + queue_rate = dl_priv->queue_nodes;
> + queues_bw_cfg->vsi_id = adapter->vsi.id;
> + queues_bw_cfg->num_queues = adapter->ch_config.total_qps;
> +
> + /* build tc[queue] */
> + for (i = 0; i < adapter->num_tc; i++) {

Nit, the scope of q_idx and j can have their scope reduced to this for loop.

> + for (j = 0; j < adapter->ch_config.ch_info[i].count; ++j) {
> + q_idx = j + adapter->ch_config.ch_info[i].offset;
> + queue_to_tc[q_idx] = i;
> + }
> + }
> +
> + for (i = 0; i < queues_bw_cfg->num_queues; i++) {
> + tc = queue_to_tc[i];
> + queues_bw_cfg->cfg[i].queue_id = i;
> + queues_bw_cfg->cfg[i].shaper.peak = queue_rate[i].tx_max;
> + queues_bw_cfg->cfg[i].shaper.committed =
> + queue_rate[i].tx_share;
> + queues_bw_cfg->cfg[i].tc = tc;
> + }
> +
> + adapter->current_op = VIRTCHNL_OP_CONFIG_QUEUE_BW;
> + adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW;
> + iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_QUEUE_BW,
> + (u8 *)queues_bw_cfg, len);
> + kfree(queues_bw_cfg);
> +}
> + …