From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DA31AA034F; Mon, 11 Oct 2021 10:52:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97593410E6; Mon, 11 Oct 2021 10:52:02 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 2BF56410DC for ; Mon, 11 Oct 2021 10:52:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633942320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MWJmSd/jMFJi74I7XqU29IQS1KdsXcE2zBl6uW7j+vE=; b=D5EABMHDE72kYdAA8SHRedeWfYtWT3LDEBaZG4Pj5BZgufdsoJR9LtdbNsdwySSb2ifaXn c4H4TK1mBLdUj7Mef8cJJmjGzEWEl7KL8i+WepxS27WN5WFuzuf3T2Z+0J09JKlhgg5lP/ B+jJx6YjV2WW4W1xXVuazpyYgvnpL0g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-nQ-f9xGTNIW-RAbTTQ0P7A-1; Mon, 11 Oct 2021 04:51:55 -0400 X-MC-Unique: nQ-f9xGTNIW-RAbTTQ0P7A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3D891018720; Mon, 11 Oct 2021 08:51:53 +0000 (UTC) Received: from [10.39.208.17] (unknown [10.39.208.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77AB55D6CF; Mon, 11 Oct 2021 08:51:45 +0000 (UTC) Message-ID: <0c0f46d2-7b84-c062-387b-aa665993715f@redhat.com> Date: Mon, 11 Oct 2021 10:51:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: "Xia, Chenbo" , "dev@dpdk.org" , "amorenoz@redhat.com" , "david.marchand@redhat.com" , "andrew.rybchenko@oktetlabs.ru" , "Yigit, Ferruh" , "michaelba@nvidia.com" , "viacheslavo@nvidia.com" , "Li, Xiaoyun" Cc: "nelio.laranjeiro@6wind.com" , "yvugenfi@redhat.com" , "ybendito@redhat.com" References: <20211004143017.51488-1-maxime.coquelin@redhat.com> <20211004143017.51488-2-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 1/5] net/virtio: add initial RSS support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 10/11/21 10:47, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, October 4, 2021 10:30 PM >> To: dev@dpdk.org; Xia, Chenbo ; amorenoz@redhat.com; >> david.marchand@redhat.com; andrew.rybchenko@oktetlabs.ru; Yigit, Ferruh >> ; michaelba@nvidia.com; viacheslavo@nvidia.com; Li, >> Xiaoyun >> Cc: nelio.laranjeiro@6wind.com; yvugenfi@redhat.com; ybendito@redhat.com; >> Maxime Coquelin >> 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 >> --- > > [...] > >> +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 Right! > >> + 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'. That is indeed not necessary, I'll remove it here and below. >> + 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 >> + */ >> +#define VIRTIO_NET_RSS_RETA_SIZE 128 >> +#define VIRTIO_NET_RSS_KEY_SIZE 40 > > Forgot to align the numbers? :) Yes, I forgot it. Thanks, Maxime > 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 >