DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"amorenoz@redhat.com" <amorenoz@redhat.com>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	"andrew.rybchenko@oktetlabs.ru" <andrew.rybchenko@oktetlabs.ru>,
	"Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"michaelba@nvidia.com" <michaelba@nvidia.com>,
	"viacheslavo@nvidia.com" <viacheslavo@nvidia.com>,
	"Li, Xiaoyun" <xiaoyun.li@intel.com>
Cc: "nelio.laranjeiro@6wind.com" <nelio.laranjeiro@6wind.com>,
	"yvugenfi@redhat.com" <yvugenfi@redhat.com>,
	"ybendito@redhat.com" <ybendito@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/5] net/virtio: add initial RSS support
Date: Mon, 11 Oct 2021 08:47:55 +0000	[thread overview]
Message-ID: <SN6PR11MB35042F66CDD2F12F776925189CB59@SN6PR11MB3504.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20211004143017.51488-2-maxime.coquelin@redhat.com>

Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, October 4, 2021 10:30 PM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; amorenoz@redhat.com;
> david.marchand@redhat.com; andrew.rybchenko@oktetlabs.ru; Yigit, Ferruh
> <ferruh.yigit@intel.com>; michaelba@nvidia.com; viacheslavo@nvidia.com; Li,
> Xiaoyun <xiaoyun.li@intel.com>
> Cc: nelio.laranjeiro@6wind.com; yvugenfi@redhat.com; ybendito@redhat.com;
> Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v4 1/5] net/virtio: add initial RSS support
> 
> Provide the capability to update the hash key, hash types
> and RETA table on the fly (without needing to stop/start
> the device). However, the key length and the number of RETA
> entries are fixed to 40B and 128 entries respectively. This
> is done in order to simplify the design, but may be
> revisited later as the Virtio spec provides this
> flexibility.
> 
> Note that only VIRTIO_NET_F_RSS support is implemented,
> VIRTIO_NET_F_HASH_REPORT, which would enable reporting the
> packet RSS hash calculated by the device into mbuf.rss, is
> not yet supported.
> 
> Regarding the default RSS configuration, it has been
> chosen to use the default Intel ixgbe key as default key,
> and default RETA is a simple modulo between the hash and
> the number of Rx queues.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---

[...]

> +static int
> +virtio_dev_get_rss_config(struct virtio_hw *hw, uint32_t *rss_hash_types)
> +{
> +	struct virtio_net_config local_config;
> +	struct virtio_net_config *config = &local_config;
> +
> +	virtio_read_dev_config(hw,
> +			offsetof(struct virtio_net_config, rss_max_key_size),
> +			&config->rss_max_key_size,
> +			sizeof(config->rss_max_key_size));
> +	if (config->rss_max_key_size < VIRTIO_NET_RSS_KEY_SIZE) {
> +		PMD_INIT_LOG(ERR, "Invalid device RSS max key size (%u)",
> +				config->rss_max_key_size);
> +		return -EINVAL;
> +	}
> +
> +	virtio_read_dev_config(hw,
> +			offsetof(struct virtio_net_config,
> +				rss_max_indirection_table_length),
> +			&config->rss_max_indirection_table_length,
> +			sizeof(config->rss_max_indirection_table_length));
> +	if (config->rss_max_indirection_table_length < VIRTIO_NET_RSS_RETA_SIZE)
> {
> +		PMD_INIT_LOG(ERR, "Invalid device RSS max reta size (%u)",
> +				config->rss_max_indirection_table_length);
> +		return -EINVAL;
> +	}
> +
> +	virtio_read_dev_config(hw,
> +			offsetof(struct virtio_net_config, supported_hash_types),
> +			&config->supported_hash_types,
> +			sizeof(config->supported_hash_types));
> +	if ((config->supported_hash_types & VIRTIO_NET_HASH_TYPE_MASK) == 0) {
> +		PMD_INIT_LOG(ERR, "Invalid device RSS hash types (%u)",

Better use 0x%x to be more user friendly

> +				config->supported_hash_types);
> +		return -EINVAL;
> +	}
> +
> +	*rss_hash_types = config->supported_hash_types &
> VIRTIO_NET_HASH_TYPE_MASK;
> +
> +	PMD_INIT_LOG(DEBUG, "Device RSS config:");
> +	PMD_INIT_LOG(DEBUG, "\t-Max key size: %u", config->rss_max_key_size);
> +	PMD_INIT_LOG(DEBUG, "\t-Max reta size: %u", config-
> >rss_max_indirection_table_length);
> +	PMD_INIT_LOG(DEBUG, "\t-Supported hash types: 0x%x", *rss_hash_types);
> +
> +	return 0;
> +}
> +
> +static int
> +virtio_dev_rss_hash_update(struct rte_eth_dev *dev,
> +		struct rte_eth_rss_conf *rss_conf)
> +{
> +	struct virtio_hw *hw = dev->data->dev_private;
> +	uint16_t nb_queues;
> +
> +	if (!virtio_with_feature(hw, VIRTIO_NET_F_RSS))
> +		return -ENOTSUP;
> +
> +	if (rss_conf->rss_hf &
> ~virtio_to_ethdev_rss_offloads(VIRTIO_NET_HASH_TYPE_MASK))
> +		return -EINVAL;
> +
> +	hw->rss_hash_types = ethdev_to_virtio_rss_offloads(rss_conf->rss_hf);
> +
> +	if (rss_conf->rss_key && rss_conf->rss_key_len) {
> +		if (rss_conf->rss_key_len != VIRTIO_NET_RSS_KEY_SIZE) {
> +			PMD_INIT_LOG(ERR, "Driver only supports %u RSS key length",
> +					VIRTIO_NET_RSS_KEY_SIZE);
> +			return -EINVAL;
> +		}
> +		memcpy(hw->rss_key, rss_conf->rss_key, VIRTIO_NET_RSS_KEY_SIZE);
> +	}
> +
> +	nb_queues = RTE_MAX(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
> +	return virtio_set_multiple_queues_rss(dev, nb_queues);
> +}
> +
> +static int
> +virtio_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
> +		struct rte_eth_rss_conf *rss_conf)
> +{
> +	struct virtio_hw *hw = dev->data->dev_private;
> +
> +	if (!virtio_with_feature(hw, VIRTIO_NET_F_RSS))
> +		return -ENOTSUP;
> +
> +	if (rss_conf->rss_key && rss_conf->rss_key_len >=
> VIRTIO_NET_RSS_KEY_SIZE)
> +		memcpy(rss_conf->rss_key, hw->rss_key, VIRTIO_NET_RSS_KEY_SIZE);
> +	rss_conf->rss_key_len = VIRTIO_NET_RSS_KEY_SIZE;
> +	rss_conf->rss_hf = virtio_to_ethdev_rss_offloads(hw->rss_hash_types);
> +
> +	return 0;
> +}
> +
> +static int virtio_dev_rss_reta_update(struct rte_eth_dev *dev,
> +			 struct rte_eth_rss_reta_entry64 *reta_conf,
> +			 uint16_t reta_size)
> +{
> +	struct virtio_hw *hw = dev->data->dev_private;
> +	uint16_t nb_queues;
> +	int idx, pos, i;
> +
> +	if (!virtio_with_feature(hw, VIRTIO_NET_F_RSS))
> +		return -ENOTSUP;
> +
> +	if (reta_size != VIRTIO_NET_RSS_RETA_SIZE)
> +		return -EINVAL;
> +
> +	for (idx = 0, i = 0; i < reta_size; i++) {

idx is calculated every time. No need to do 'idx = 0'.

> +		idx = i / RTE_RETA_GROUP_SIZE;
> +		pos = i % RTE_RETA_GROUP_SIZE;
> +
> +		if (((reta_conf[idx].mask >> pos) & 0x1) == 0)
> +			continue;
> +
> +		hw->rss_reta[i] = reta_conf[idx].reta[pos];
> +	}
> +
> +	nb_queues = RTE_MAX(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
> +	return virtio_set_multiple_queues_rss(dev, nb_queues);
> +}
> +
> +static int virtio_dev_rss_reta_query(struct rte_eth_dev *dev,
> +			 struct rte_eth_rss_reta_entry64 *reta_conf,
> +			 uint16_t reta_size)
> +{
> +	struct virtio_hw *hw = dev->data->dev_private;
> +	int idx, i;
> +
> +	if (!virtio_with_feature(hw, VIRTIO_NET_F_RSS))
> +		return -ENOTSUP;
> +
> +	if (reta_size != VIRTIO_NET_RSS_RETA_SIZE)
> +		return -EINVAL;
> +
> +	for (idx = 0, i = 0; i < reta_size; i++) {

Ditto

> +		idx = i / RTE_RETA_GROUP_SIZE;
> +		reta_conf[idx].reta[i % RTE_RETA_GROUP_SIZE] = hw->rss_reta[i];
> +	}
> +
> +	return 0;
> +}
> +
> +/*

[...]

> +/**
> + * RSS control
> + *
> + * The RSS feature <todo>
> + */
> +#define VIRTIO_NET_RSS_RETA_SIZE 128
> +#define VIRTIO_NET_RSS_KEY_SIZE       40

Forgot to align the numbers? :)

Thanks,
Chenbo

> +
> +struct virtio_net_ctrl_rss {
> +	uint32_t hash_types;
> +	uint16_t indirection_table_mask;
> +	uint16_t unclassified_queue;
> +	uint16_t indirection_table[VIRTIO_NET_RSS_RETA_SIZE];
> +	uint16_t max_tx_vq;
> +	uint8_t hash_key_length;
> +	uint8_t hash_key_data[VIRTIO_NET_RSS_KEY_SIZE];
> +};
> +
>  /*
>   * Control link announce acknowledgement
>   *
> @@ -292,7 +310,10 @@ struct virtqueue {
> 
>  /* If multiqueue is provided by host, then we suppport it. */
>  #define VIRTIO_NET_CTRL_MQ   4
> +
>  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
> +#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
> +
>  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
>  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
> 
> --
> 2.31.1


  reply	other threads:[~2021-10-11  8:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 14:30 [dpdk-dev] [PATCH v4 0/5] Virtio PMD RSS support & RSS fixes Maxime Coquelin
2021-10-04 14:30 ` [dpdk-dev] [PATCH v4 1/5] net/virtio: add initial RSS support Maxime Coquelin
2021-10-11  8:47   ` Xia, Chenbo [this message]
2021-10-11  8:51     ` Maxime Coquelin
2021-10-04 14:30 ` [dpdk-dev] [PATCH v4 2/5] app/testpmd: fix RSS key length Maxime Coquelin
2021-10-04 14:30 ` [dpdk-dev] [PATCH v4 3/5] app/testpmd: fix RSS type display Maxime Coquelin
2021-10-04 14:30 ` [dpdk-dev] [PATCH v4 4/5] net/mlx5: fix RSS RETA update Maxime Coquelin
2021-10-04 14:30 ` [dpdk-dev] [PATCH v4 5/5] app/testpmd: add missing flow types in port info Maxime Coquelin
2021-10-08  2:01   ` Li, Xiaoyun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SN6PR11MB35042F66CDD2F12F776925189CB59@SN6PR11MB3504.namprd11.prod.outlook.com \
    --to=chenbo.xia@intel.com \
    --cc=amorenoz@redhat.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=michaelba@nvidia.com \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=viacheslavo@nvidia.com \
    --cc=xiaoyun.li@intel.com \
    --cc=ybendito@redhat.com \
    --cc=yvugenfi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).