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 498DF4399F; Tue, 23 Jan 2024 01:17:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C06640A8A; Tue, 23 Jan 2024 01:17:20 +0100 (CET) Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by mails.dpdk.org (Postfix) with ESMTP id 82C6640A6B for ; Tue, 23 Jan 2024 01:17:18 +0100 (CET) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5eba564eb3fso61250257b3.1 for ; Mon, 22 Jan 2024 16:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705969038; x=1706573838; 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=Mv2BC8BpxV+NZYlfEJUKr7DJqBdQ9cHZxwN96eTsG2k=; b=L9fN+iy7UaTb10MfWMJLAK0Z1ZCN+zWkk+KOJQVSoUPv54ULj68rA3ZBkh4Zhlv+oK WBhIZKv9EGxBEjA3swFox6gBnfWXTE1+JchxJHoZ4ipOZF7pVidqc1XqeAIWWvNjTPWa MStLkKG7leN97jlPtsfVvZKdoaQgelaEphCyYhpm6Oc+qU7sOeklIExT5QfMDyxKnfhb 3YytANtakNivPQ6QUwmkldmQMEX1hxqXdOA6xGO3ylfftSmI3JtjvxlPuL3gExk8ilU5 WMIA1LU5X9h1MMaxU6ce2wZztF3AvGibgKUgkqIiRTpN0dHYs5QVS/tlmJw1S43a0YRK H8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705969038; x=1706573838; 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=Mv2BC8BpxV+NZYlfEJUKr7DJqBdQ9cHZxwN96eTsG2k=; b=YWsvx4J/RMXjYDhzd+N+aMccnzAwjA5BIQfRiqWVuKUZ6Or5UGLJUUrqevtcp+/Htp 4+ZlRprSLqrv3Zjlnt9choe8nOCt5HCwqWRzPCKDRiKR8IFvSJkEyvY1XP4SN0GPzBfB 9h3vC8H23GSqtS9xF8bolhQnZZVt6855+Df/GhU0Mk4YzpJ7YQQWQxikskfoth8+u9jr a5pB/APOcwOiCwpxz3lqs9wTDW8JN9zVf8Gv2WCsXHrzd8Oqa0dQij23BUd+pAaKoS4U S08ypM/pUzshIxtm8OzkMxCxs2fB+FB1dJ0fHMXQTbepwEXcNAteOmhLqPHVnHeHXqbD 8pNQ== X-Gm-Message-State: AOJu0Yw6LYgl3r9/wZeDeKuJMwfTMOb4bjdw2dIMLiCn+nxHqIPO57A9 HEXxza/HFE6IaO8+zptXjgfMHfXNxyTOswhThv/afwdZsJeQ7ZaUAUzOrfTQ/TD+TegghmlPlM0 LVOyBOni83w== X-Google-Smtp-Source: AGHT+IHMUr6EKGgCHuDNnhFuFi7w9Zjp6s5jnffBoodxPUW4LxJKrM0TqiRtOH+tPQEqIr1fZRa1ensUjspXDw== X-Received: from joshwash.sea.corp.google.com ([2620:15c:11c:202:9096:2b97:b7f7:1182]) (user=joshwash job=sendgmr) by 2002:a81:9ad5:0:b0:5fb:7e5b:b87f with SMTP id r204-20020a819ad5000000b005fb7e5bb87fmr2504054ywg.1.1705969037859; Mon, 22 Jan 2024 16:17:17 -0800 (PST) Date: Mon, 22 Jan 2024 16:16:39 -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-3-joshwash@google.com> Subject: [PATCH 2/7] net/gve: RSS adminq command changes 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 change introduces admin queue changes that enable the configuration of RSS parameters for the GVE driver. --- drivers/net/gve/base/gve.h | 15 ++++++++ drivers/net/gve/base/gve_adminq.c | 59 +++++++++++++++++++++++++++++++ drivers/net/gve/base/gve_adminq.h | 29 +++++++++++++++ drivers/net/gve/gve_ethdev.h | 6 +++- 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/drivers/net/gve/base/gve.h b/drivers/net/gve/base/gve.h index f7b297e759..9c58fc4238 100644 --- a/drivers/net/gve/base/gve.h +++ b/drivers/net/gve/base/gve.h @@ -51,4 +51,19 @@ enum gve_state_flags_bit { GVE_PRIV_FLAGS_NAPI_ENABLED = 4, }; +enum gve_rss_hash_algorithm { + GVE_RSS_HASH_UNDEFINED = 0, + GVE_RSS_HASH_TOEPLITZ = 1, +}; + +struct gve_rss_config { + uint16_t hash_types; + enum gve_rss_hash_algorithm alg; + uint16_t key_size; + uint16_t indir_size; + uint8_t *key; + uint32_t *indir; +}; + + #endif /* _GVE_H_ */ diff --git a/drivers/net/gve/base/gve_adminq.c b/drivers/net/gve/base/gve_adminq.c index 343bd13d67..897c3dce03 100644 --- a/drivers/net/gve/base/gve_adminq.c +++ b/drivers/net/gve/base/gve_adminq.c @@ -389,6 +389,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv, case GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES: priv->adminq_dcfg_device_resources_cnt++; break; + case GVE_ADMINQ_CONFIGURE_RSS: + priv->adminq_cfg_rss_cnt++; + break; case GVE_ADMINQ_SET_DRIVER_PARAMETER: priv->adminq_set_driver_parameter_cnt++; break; @@ -938,3 +941,59 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv, gve_free_dma_mem(&ptype_map_dma_mem); return err; } + +int gve_adminq_configure_rss(struct gve_priv *priv, + struct gve_rss_config *rss_config) +{ + struct gve_dma_mem indirection_table_dma_mem; + struct gve_dma_mem rss_key_dma_mem; + union gve_adminq_command cmd; + __be32 *indir = NULL; + u8 *key = NULL; + int err = 0; + int i; + + if (rss_config->indir_size) { + indir = gve_alloc_dma_mem(&indirection_table_dma_mem, + rss_config->indir_size * + sizeof(*rss_config->indir)); + if (!indir) { + err = -ENOMEM; + goto out; + } + for (i = 0; i < rss_config->indir_size; i++) + indir[i] = cpu_to_be32(rss_config->indir[i]); + } + + if (rss_config->key_size) { + key = gve_alloc_dma_mem(&rss_key_dma_mem, + rss_config->key_size * + sizeof(*rss_config->key)); + if (!key) { + err = -ENOMEM; + goto out; + } + memcpy(key, rss_config->key, rss_config->key_size); + } + + memset(&cmd, 0, sizeof(cmd)); + cmd.opcode = cpu_to_be32(GVE_ADMINQ_CONFIGURE_RSS); + cmd.configure_rss = (struct gve_adminq_configure_rss) { + .hash_types = cpu_to_be16(rss_config->hash_types), + .halg = rss_config->alg, + .hkey_len = cpu_to_be16(rss_config->key_size), + .indir_len = cpu_to_be16(rss_config->indir_size), + .hkey_addr = cpu_to_be64(rss_key_dma_mem.pa), + .indir_addr = cpu_to_be64(indirection_table_dma_mem.pa), + }; + + err = gve_adminq_execute_cmd(priv, &cmd); + +out: + if (indir) + gve_free_dma_mem(&indirection_table_dma_mem); + if (key) + gve_free_dma_mem(&rss_key_dma_mem); + return err; +} + diff --git a/drivers/net/gve/base/gve_adminq.h b/drivers/net/gve/base/gve_adminq.h index f05362f85f..95f4960561 100644 --- a/drivers/net/gve/base/gve_adminq.h +++ b/drivers/net/gve/base/gve_adminq.h @@ -19,6 +19,7 @@ enum gve_adminq_opcodes { GVE_ADMINQ_DESTROY_TX_QUEUE = 0x7, GVE_ADMINQ_DESTROY_RX_QUEUE = 0x8, GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES = 0x9, + GVE_ADMINQ_CONFIGURE_RSS = 0xA, GVE_ADMINQ_SET_DRIVER_PARAMETER = 0xB, GVE_ADMINQ_REPORT_STATS = 0xC, GVE_ADMINQ_REPORT_LINK_SPEED = 0xD, @@ -377,6 +378,27 @@ struct gve_adminq_get_ptype_map { __be64 ptype_map_addr; }; +#define GVE_RSS_HASH_IPV4 BIT(0) +#define GVE_RSS_HASH_TCPV4 BIT(1) +#define GVE_RSS_HASH_IPV6 BIT(2) +#define GVE_RSS_HASH_IPV6_EX BIT(3) +#define GVE_RSS_HASH_TCPV6 BIT(4) +#define GVE_RSS_HASH_TCPV6_EX BIT(5) +#define GVE_RSS_HASH_UDPV4 BIT(6) +#define GVE_RSS_HASH_UDPV6 BIT(7) +#define GVE_RSS_HASH_UDPV6_EX BIT(8) + +/* RSS configuration command */ +struct gve_adminq_configure_rss { + __be16 hash_types; + u8 halg; /* hash algorithm */ + u8 reserved; + __be16 hkey_len; + __be16 indir_len; + __be64 hkey_addr; + __be64 indir_addr; +}; + union gve_adminq_command { struct { __be32 opcode; @@ -391,6 +413,7 @@ union gve_adminq_command { struct gve_adminq_describe_device describe_device; struct gve_adminq_register_page_list reg_page_list; struct gve_adminq_unregister_page_list unreg_page_list; + struct gve_adminq_configure_rss configure_rss; struct gve_adminq_set_driver_parameter set_driver_param; struct gve_adminq_report_stats report_stats; struct gve_adminq_report_link_speed report_link_speed; @@ -404,6 +427,8 @@ union gve_adminq_command { GVE_CHECK_UNION_LEN(64, gve_adminq_command); +struct gve_priv; +struct gve_queue_page_list; int gve_adminq_alloc(struct gve_priv *priv); void gve_adminq_free(struct gve_priv *priv); void gve_adminq_release(struct gve_priv *priv); @@ -433,4 +458,8 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv, int gve_adminq_verify_driver_compatibility(struct gve_priv *priv, u64 driver_info_len, dma_addr_t driver_info_addr); + +int gve_adminq_configure_rss(struct gve_priv *priv, + struct gve_rss_config *rss_config); + #endif /* _GVE_ADMINQ_H */ diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h index 14c72ec91a..aa8291f235 100644 --- a/drivers/net/gve/gve_ethdev.h +++ b/drivers/net/gve/gve_ethdev.h @@ -39,7 +39,10 @@ RTE_ETH_RSS_IPV6 | \ RTE_ETH_RSS_IPV6_EX | \ RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ - RTE_ETH_RSS_IPV6_TCP_EX) + RTE_ETH_RSS_IPV6_TCP_EX | \ + RTE_ETH_RSS_NONFRAG_IPV4_UDP | \ + RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ + RTE_ETH_RSS_IPV6_UDP_EX) /* A list of pages registered with the device during setup and used by a queue * as buffers @@ -264,6 +267,7 @@ struct gve_priv { uint32_t adminq_destroy_tx_queue_cnt; uint32_t adminq_destroy_rx_queue_cnt; uint32_t adminq_dcfg_device_resources_cnt; + uint32_t adminq_cfg_rss_cnt; uint32_t adminq_set_driver_parameter_cnt; uint32_t adminq_report_stats_cnt; uint32_t adminq_report_link_speed_cnt; -- 2.43.0.429.g432eaa2c6b-goog