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 8356E4399F; Tue, 23 Jan 2024 01:17:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D28FB40ED2; Tue, 23 Jan 2024 01:17:25 +0100 (CET) Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by mails.dpdk.org (Postfix) with ESMTP id 585E740E01 for ; Tue, 23 Jan 2024 01:17:22 +0100 (CET) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5ffc7ce3343so27701187b3.1 for ; Mon, 22 Jan 2024 16:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705969042; x=1706573842; darn=dpdk.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WCKstnC17ty7/eBNV8msBbW/c6q/92Lq+HjgBFNy6Y4=; b=algKpLgtrmQpk/Edk66383Yy59CDMNfMsSyUaM8r4s0CInrpoO1GD6blaKBV/eoXf+ Cy1+YHniKaZ0ixc64PizhJ7c5rC1iATLZgdbbW2+PFxG0Y6GihjMOosbKl5QuLF7P2Nz hH6331lVeNlM3Ls9jacJJeSwaQEvreqzZhQmWj0igB3vUhSJJi2qBF35265IBM9hEtbM 3wW62Owq/x7sVcrUTFR2JsXhj+yivxheXvK8zAnV9X8NGefTz+/17wfMvE7CtWCoAxwI Ji+D+M+RjCz7wKu1aWgSR4FrrRcM29WMYKHt0x1ec8NpkFFPNBw9QB/A3HxGbQnypTW8 2Xfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705969042; x=1706573842; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WCKstnC17ty7/eBNV8msBbW/c6q/92Lq+HjgBFNy6Y4=; b=md2XCIWxbs3xojoi61nS6ccyX7dfphbaj5mNPV0s+kJm3d3wgg9DGxFp2wlADA89+o LtUbgLfBDcetIdmd+gQvRGI8T3GuhNzeFVjlzknof4DJjEw8LAF2dL2CzrPHLJS0MxUa cjJp3DT1kSCLrcMhrtnSSZt0r51GlwsNqxVb/oi8ATGb6F4kGkT7iJ6gCH4mrz20wJwA e0DOvzRuK2XT+pUpb4oELn1AvZkWtujzbEob2CjO+OWG4NqOizrQJgCaiMwqwvfA2ypP oyDeqfuryorfpX/TGPNFlJbhzmNX3ce0WJPBukHyK59DGfqFRx84IzBFP9OMKAZ7Kr2H /sSg== X-Gm-Message-State: AOJu0YwBfi+BEUFgvC6Q233geSIQQ8CWP7DkOuh48eYh/YqLDCo9v+Gk SR69CC89i/JzVACb/pB2JP+mDUjIMi2Gco/gNXErUDVSeXIznyYyxJa0jL6v7HpN1q5SF4jkQL9 zcUXrtwvYCg== X-Google-Smtp-Source: AGHT+IFWDxnI2iLJz6e2nTURDwqxdTCcpIELP8cQVgX3Qj4O/IkHjazdpoSHbXuao05/aPT//qMMJWBcYdX/lA== X-Received: from joshwash.sea.corp.google.com ([2620:15c:11c:202:9096:2b97:b7f7:1182]) (user=joshwash job=sendgmr) by 2002:a81:5753:0:b0:5fb:7e5b:b877 with SMTP id l80-20020a815753000000b005fb7e5bb877mr1667315ywb.7.1705969041832; Mon, 22 Jan 2024 16:17:21 -0800 (PST) Date: Mon, 22 Jan 2024 16:16:41 -0800 In-Reply-To: <20240123001645.1507779-1-joshwash@google.com> Mime-Version: 1.0 References: <20240123001645.1507779-1-joshwash@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123001645.1507779-5-joshwash@google.com> Subject: [PATCH 4/7] net/gve: RSS configuration update support From: Joshua Washington To: Junfeng Guo , Jeroen de Borst , Rushil Gupta , Joshua Washington Cc: dev@dpdk.org, Ferruh Yigit Content-Type: text/plain; charset="UTF-8" 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 This patch adds support for updating the RSS hash key and hash fields in the GVE PMD through the implementation of rss_hash_update and rss_hash_conf_get. The RSS hash key for gVNIC is required to be 40 bytes. On initial configuration of the RSS hash key, the RSS redirection table will be set to a static default, using a round-robin approach for all queues. Note, however, that this patch does not include support for setting the redirection table explicitly. In dev_configure, if the static redirection table has been set, it will be updated to reflect the new queue count, if it has changed. The RSS key must be set before any other RSS configuration can happen. As such, an attempt to set the hash types before the key is configured will fail. --- drivers/net/gve/gve_ethdev.c | 132 ++++++++++++++++++++++++++++++++++- drivers/net/gve/gve_ethdev.h | 5 +- 2 files changed, 134 insertions(+), 3 deletions(-) diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index 936ca22cb9..76405120b2 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Intel Corporation + * Copyright(C) 2022-2023 Intel Corporation + * Copyright(C) 2023 Google LLC */ #include "gve_ethdev.h" @@ -8,6 +9,7 @@ #include "base/gve_osdep.h" #include "gve_version.h" #include "rte_ether.h" +#include "gve_rss.h" static void gve_write_version(uint8_t *driver_version_register) @@ -88,12 +90,31 @@ gve_dev_configure(struct rte_eth_dev *dev) { struct gve_priv *priv = dev->data->dev_private; - if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) { dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + priv->rss_config.alg = GVE_RSS_HASH_TOEPLITZ; + } if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) priv->enable_rsc = 1; + // Reset RSS RETA in case number of queues changed. + if (priv->rss_config.indir) { + struct gve_rss_config update_reta_config; + gve_init_rss_config_from_priv(priv, &update_reta_config); + gve_generate_rss_reta(dev, &update_reta_config); + + int err = gve_adminq_configure_rss(priv, &update_reta_config); + if (err) + PMD_DRV_LOG(ERR, + "Could not reconfigure RSS redirection table."); + else + gve_update_priv_rss_config(priv, &update_reta_config); + + gve_free_rss_config(&update_reta_config); + return err; + } + return 0; } @@ -443,6 +464,8 @@ gve_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) }; dev_info->flow_type_rss_offloads = GVE_RTE_RSS_OFFLOAD_ALL; + dev_info->hash_key_size = GVE_RSS_HASH_KEY_SIZE; + dev_info->reta_size = GVE_RSS_INDIR_SIZE; return 0; } @@ -646,6 +669,107 @@ gve_xstats_get_names(struct rte_eth_dev *dev, return count; } + +static int +gve_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct gve_priv *priv = dev->data->dev_private; + struct gve_rss_config gve_rss_conf; + int rss_reta_size; + int err; + + if (gve_validate_rss_hf(rss_conf->rss_hf)) { + PMD_DRV_LOG(ERR, "Unsupported hash function."); + return -EINVAL; + } + + if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_TOEPLITZ && + rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT) { + PMD_DRV_LOG(ERR, "Device only supports Toeplitz algorithm."); + return -EINVAL; + } + + if (rss_conf->rss_key_len) { + if (rss_conf->rss_key_len != GVE_RSS_HASH_KEY_SIZE) { + PMD_DRV_LOG(ERR, + "Invalid hash key size. Only RSS hash key size " + "of %u supported", GVE_RSS_HASH_KEY_SIZE); + return -EINVAL; + } + + if (!rss_conf->rss_key) { + PMD_DRV_LOG(ERR, "RSS key must be non-null."); + return -EINVAL; + } + } else { + if (!priv->rss_config.key_size) { + PMD_DRV_LOG(ERR, "RSS key must be initialized before " + "any other configuration."); + return -EINVAL; + } + rss_conf->rss_key_len = priv->rss_config.key_size; + } + + rss_reta_size = priv->rss_config.indir ? + priv->rss_config.indir_size : + GVE_RSS_INDIR_SIZE; + err = gve_init_rss_config(&gve_rss_conf, rss_conf->rss_key_len, + rss_reta_size); + if (err) + return err; + + gve_rss_conf.alg = GVE_RSS_HASH_TOEPLITZ; + err = gve_update_rss_hash_types(priv, &gve_rss_conf, rss_conf); + if (err) + goto err; + err = gve_update_rss_key(priv, &gve_rss_conf, rss_conf); + if (err) + goto err; + + // Set redirection table to default or preexisting. + if (!priv->rss_config.indir) + gve_generate_rss_reta(dev, &gve_rss_conf); + else + memcpy(gve_rss_conf.indir, priv->rss_config.indir, + gve_rss_conf.indir_size * sizeof(*priv->rss_config.indir)); + + err = gve_adminq_configure_rss(priv, &gve_rss_conf); + if (!err) + gve_update_priv_rss_config(priv, &gve_rss_conf); + +err: + gve_free_rss_config(&gve_rss_conf); + return err; +} + +static int +gve_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct gve_priv *priv = dev->data->dev_private; + + if (!(dev->data->dev_conf.rxmode.offloads & + RTE_ETH_RX_OFFLOAD_RSS_HASH)) { + PMD_DRV_LOG(ERR, "RSS not configured."); + return -ENOTSUP; + } + + + gve_to_rte_rss_hf(priv->rss_config.hash_types, rss_conf); + rss_conf->rss_key_len = priv->rss_config.key_size; + if (rss_conf->rss_key) { + if (!priv->rss_config.key) { + PMD_DRV_LOG(ERR, "Unable to retrieve defualt RSS hash key."); + return -ENOTSUP; + } + memcpy(rss_conf->rss_key, priv->rss_config.key, + rss_conf->rss_key_len * sizeof(*rss_conf->rss_key)); + } + + return 0; +} + static const struct eth_dev_ops gve_eth_dev_ops = { .dev_configure = gve_dev_configure, .dev_start = gve_dev_start, @@ -666,6 +790,8 @@ static const struct eth_dev_ops gve_eth_dev_ops = { .mtu_set = gve_dev_mtu_set, .xstats_get = gve_xstats_get, .xstats_get_names = gve_xstats_get_names, + .rss_hash_update = gve_rss_hash_update, + .rss_hash_conf_get = gve_rss_hash_conf_get, }; static const struct eth_dev_ops gve_eth_dev_ops_dqo = { @@ -688,6 +814,8 @@ static const struct eth_dev_ops gve_eth_dev_ops_dqo = { .mtu_set = gve_dev_mtu_set, .xstats_get = gve_xstats_get, .xstats_get_names = gve_xstats_get_names, + .rss_hash_update = gve_rss_hash_update, + .rss_hash_conf_get = gve_rss_hash_conf_get, }; static void diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h index b5118e737a..a61df9aac5 100644 --- a/drivers/net/gve/gve_ethdev.h +++ b/drivers/net/gve/gve_ethdev.h @@ -29,6 +29,9 @@ #define GVE_RX_MIN_BUF_SIZE_GQI 2048 #define GVE_RX_MAX_BUF_SIZE_GQI 4096 +#define GVE_RSS_HASH_KEY_SIZE 40 +#define GVE_RSS_INDIR_SIZE 128 + #define GVE_TX_CKSUM_OFFLOAD_MASK ( \ RTE_MBUF_F_TX_L4_MASK | \ RTE_MBUF_F_TX_TCP_SEG) @@ -291,7 +294,7 @@ struct gve_priv { uint16_t stats_start_idx; /* start index of array of stats written by NIC */ uint16_t stats_end_idx; /* end index of array of stats written by NIC */ - struct gve_rss_config rss_config; + struct gve_rss_config rss_config; }; static inline bool -- 2.43.0.429.g432eaa2c6b-goog