Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1038888iog; Wed, 15 Jun 2022 19:09:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uH5xlK+ePkmy6psHAftWFuO8D6Df/rHF8vkaRZf5Iatx32JegufbPTduOuVvA4zwWkBD2K X-Received: by 2002:a17:902:d58c:b0:168:af49:4a7f with SMTP id k12-20020a170902d58c00b00168af494a7fmr2259524plh.15.1655345384599; Wed, 15 Jun 2022 19:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655345384; cv=none; d=google.com; s=arc-20160816; b=Tj5WWGRE0wjbY8S11FB9SWunyaIEOvxRETI7oGQzAGUCAOQ0e2OW96zKKEI1YuUneq ai8dOoYvHiewut2+KCFr8Qbh7LrYTI8Y2Psg8VQUfNEdpCaJTD0hfHCGSijeIpk+Fly9 mQqTLfMMC9QSq2vdGfmvDjD/8E72/uwOwU8GSL0niGGnBvbZXSG+JJ6Fa2ffclQPUNlx wxmyLY1Uw2pLFyeWLuPompeo8VvJLCcWl3/H8Z6OzF7XeLUTmr8F50RiH9pyEABg3bq6 f937taMThlnoSDqWuosWtlHT6QTfMKBFXkHofpdbzXp8HyCbM2VS2X7tJsww6dMR0rUX ilbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=WnAUrlvUwfhIO5pMVyiEMyAYxQk5L9UhW0Z7vT9tZiE=; b=HQ9Mt3OX6SJZldYFGT3dWIYbedioPRX65vDVtCqXyAB0VQ2DkBdcw8WI2NpCNP9zpz TTcW90rGxEkAF+KG1AndeQTEWw1GsDz4jR8LalzgUQVZXLfABot5WYJMWPcg2NOv/bni SVjdhA6dCeEXdtJ53CZ8SlNyOufHNGf/kJMyb9FDa8jRUiaXZXFeyAwTtAm/RQUo9FPU R+UX3ZCpJxs5W2xvcBLSklRKjK7ac8av144tUJHIYX27+px8kNvm6LnrSMjaxYbNmLSF Cl1NsLKNki/3zTVOVAVlAEXEdSknucPgal3Hwy6zLLO3ZElemoFKHfS6hS3l2B6Z/dN6 8X+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=LT4gDRw0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb3-20020a17090ae7c300b001e33517868dsi5289395pjb.150.2022.06.15.19.09.29; Wed, 15 Jun 2022 19:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=LT4gDRw0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358585AbiFPCI3 (ORCPT + 99 others); Wed, 15 Jun 2022 22:08:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354878AbiFPCHj (ORCPT ); Wed, 15 Jun 2022 22:07:39 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A02C2643E; Wed, 15 Jun 2022 19:07:37 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1004) id 1B37920C32B2; Wed, 15 Jun 2022 19:07:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1B37920C32B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1655345254; bh=WnAUrlvUwfhIO5pMVyiEMyAYxQk5L9UhW0Z7vT9tZiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=LT4gDRw0YaSfXIOArUaYXexT3nfEwV5lmAWS7fEvHc2crT4cDevN0TYqLYn71N3iY 7bdX9cKFr5NsDZd7TInECCxLkyii1CZmufHOmSGB/6fdDz/NGI0t8QeaavVc89ljK+ UytkW5EjKHTjjgQ8flGcYxhLICO5lA0EBKQG9SZE= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jason Gunthorpe , Leon Romanovsky , edumazet@google.com, shiraz.saleem@intel.com, Ajay Sharma Cc: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Long Li Subject: [Patch v4 10/12] net: mana: Define max values for SGL entries Date: Wed, 15 Jun 2022 19:07:18 -0700 Message-Id: <1655345240-26411-11-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655345240-26411-1-git-send-email-longli@linuxonhyperv.com> References: <1655345240-26411-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li The number of maximum SGl entries should be computed from the maximum WQE size for the intended queue type and the corresponding OOB data size. This guarantees the hardware queue can successfully queue requests up to the queue depth exposed to the upper layer. Signed-off-by: Long Li --- drivers/net/ethernet/microsoft/mana/mana_en.c | 2 +- include/net/mana/gdma.h | 7 +++++++ include/net/mana/mana.h | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 5aab7afc9143..9a976d9b6b6f 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -187,7 +187,7 @@ int mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) pkg.wqe_req.client_data_unit = 0; pkg.wqe_req.num_sge = 1 + skb_shinfo(skb)->nr_frags; - WARN_ON_ONCE(pkg.wqe_req.num_sge > 30); + WARN_ON_ONCE(pkg.wqe_req.num_sge > MAX_TX_WQE_SGL_ENTRIES); if (pkg.wqe_req.num_sge <= ARRAY_SIZE(pkg.sgl_array)) { pkg.wqe_req.sgl = pkg.sgl_array; diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index b1bec8ab5695..ef5de92dd98d 100644 --- a/include/net/mana/gdma.h +++ b/include/net/mana/gdma.h @@ -436,6 +436,13 @@ struct gdma_wqe { #define MAX_TX_WQE_SIZE 512 #define MAX_RX_WQE_SIZE 256 +#define MAX_TX_WQE_SGL_ENTRIES ((GDMA_MAX_SQE_SIZE - \ + sizeof(struct gdma_sge) - INLINE_OOB_SMALL_SIZE) / \ + sizeof(struct gdma_sge)) + +#define MAX_RX_WQE_SGL_ENTRIES ((GDMA_MAX_RQE_SIZE - \ + sizeof(struct gdma_sge)) / sizeof(struct gdma_sge)) + struct gdma_cqe { u32 cqe_data[GDMA_COMP_DATA_SIZE / 4]; diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index aca95c6ba8b3..3a0bc6e0b730 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -264,8 +264,6 @@ struct mana_cq { int budget; }; -#define GDMA_MAX_RQE_SGES 15 - struct mana_recv_buf_oob { /* A valid GDMA work request representing the data buffer. */ struct gdma_wqe_request wqe_req; @@ -275,7 +273,7 @@ struct mana_recv_buf_oob { /* SGL of the buffer going to be sent has part of the work request. */ u32 num_sge; - struct gdma_sge sgl[GDMA_MAX_RQE_SGES]; + struct gdma_sge sgl[MAX_RX_WQE_SGL_ENTRIES]; /* Required to store the result of mana_gd_post_work_request. * gdma_posted_wqe_info.wqe_size_in_bu is required for progressing the -- 2.17.1