From patchwork Sun Oct 30 00:18:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1566981wru; Sat, 29 Oct 2022 17:19:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40i7cMcelGZOzHK8324h6kkg/Iupw9zkIHAwoeOi6cVOxHKs+f5uXI+oBFN/GSCbz8lgQr X-Received: by 2002:a05:6a00:189f:b0:56b:b192:cda with SMTP id x31-20020a056a00189f00b0056bb1920cdamr6713359pfh.2.1667089173518; Sat, 29 Oct 2022 17:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089173; cv=none; d=google.com; s=arc-20160816; b=a3XkOke+1ciAEnn+9ilf5nnPYxsTvJbt+illDmymy2grZPXy98absIIUzqznEMUh87 nXL6IEb87vBwX9rvn2NFYoAWx2Aknq6hJd9yaLoOuyKl7X4xtPC6rqEKFw6gBlsU1VDe ctogfXgwY7FvRvG/WPtsZhYC/eGROsgYSH2RP47Nk2YYvL1V2lo5iaFiwhCSTo17r3qX CBVuhTeKFXMt1u3cHHWsA56OR0PZomkaMRgpUelbCjZQJSktzEyx76NTpS37XysygWj0 bhPcT2ZkiWpuhZv12gvTzEUK+zSxsuwhpEXUUedLlmhkHYXhaMTDaKpAIrZ+OIfWn2aw tpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=Uqe94PHTpVW+vRMvVc4xWrol6W9nU0dyAP4+XvVD/IZu2PnX2bF0RdaSCrQQ8DngWe Bh5TjEuUq/AmUS1hg/0AryhZQiOQfWGh/7p4B7nnlxeCZyvgHijBYry59jCCoiBtpERy V3x3aqWKhz8D1cCJnYCIP99eCCnO10EU/d5tU7qR+DFjEAOkqvziq0rX3IABu+c8juU8 +UVK83KGAOiwMssIP2iUoYJ2UX1bOci5rLWSkYPmk/amFvc5m56J+TTjl6i9ge7Uv/W1 XgQJm1KVyGEpOnx026hhHdTQB6MdBZUGUV4bBY9mDDo0IJ3zhlKb1CKpM5RV2Ir3sS7x q4nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mFRjU8Vy; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a056a0023c800b0056b345b7f5dsi4058587pfc.26.2022.10.29.17.19.21; Sat, 29 Oct 2022 17:19:33 -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=@linaro.org header.s=google header.b=mFRjU8Vy; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiJ3ASn (ORCPT + 99 others); Sat, 29 Oct 2022 20:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiJ3ASj (ORCPT ); Sat, 29 Oct 2022 20:18:39 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82C3F24F0E for ; Sat, 29 Oct 2022 17:18:37 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id c65so4043704iof.1 for ; Sat, 29 Oct 2022 17:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=mFRjU8VyCMQFZRCnmc4mwYxK+EmqfjHKvJdfbxtCfqCmyc+cIS3KWFHcrPH9Gr4zK0 DQDAVd2KM4lAPKzPybAPi5GZSKCtvMUo6o58yZNMtZG4puUEOEH+JgBPlkmXk4F9jDCE EMt1/tsIpvz8pma7RpR3XB3zCKSFUxSO5lAaFaFmpk7WvjBzzfr1TfXflvLlX7UZ5Uv6 /IMjXQyjDlVFjJaagS28/wvIbhFgYjEvaMDKqGJqCWolf8oNCR+WeLPRHPwgIZvnjKNj ++L4cmYnzIJpm1i7Tf2P0a7QqO7ErkomGkoBqCRjTt9dZn4R+nYFMzE0/sMBwQ+HVedp PSGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=4wXIlpOOJGMZAKZAMvkXg1j7HsHiq7382j//gp6Ol0YUmvtuJct7V3A3C3cyO1F/xk 7HqSX1Ss1GGydQhQujP+6kSrNXhy3SRZTbfmS7+t6UHqwG8c3Vl13SOYAtJfcOLYqPp2 h29oaZnmVOj6ad7u0EU3Xe6JW2Dn+lBF0wdnUtHvSDmvAF+It2brYLfbL71MVT99Rqc6 5PvK+DzkyDb22eILR6VUYzgcK/w5PynIEnxTKV7aLPtP0jneOaOJ+ZO2hCGTYkn0qoTH 2LIBbBHAd0ddW+ieu/nZzDy7Nv7Jl1mZYTBJkgBjhoq0MSoNOedPNYZPLwGJ+5YLozOp sFIg== X-Gm-Message-State: ACrzQf2g5uER5Wl3iM/yea9M+jFDdm1vGMhYoO0y32/MPp9L0n5F5oBJ /S7IhwOv6ek7zVPSLNfNxRfkUw== X-Received: by 2002:a6b:3ec5:0:b0:6ce:16bf:2e8e with SMTP id l188-20020a6b3ec5000000b006ce16bf2e8emr777958ioa.160.1667089116799; Sat, 29 Oct 2022 17:18:36 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18:36 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/9] net: ipa: reduce arguments to ipa_table_init_add() Date: Sat, 29 Oct 2022 19:18:20 -0500 Message-Id: <20221030001828.754010-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069697523846869?= X-GMAIL-MSGID: =?utf-8?q?1748069697523846869?= Recently ipa_table_mem() was added as a way to look up one of 8 possible memory regions by indicating whether it was a filter or route table, hashed or not, and IPv6 or not. We can simplify the interface to ipa_table_init_add() by passing two flags to it instead of the opcode and both hashed and non-hashed memory region IDs. The "filter" and "ipv6" flags are sufficient to determine the opcode to use, and with ipa_table_mem() can look up the correct memory region as well. It's possible to not have hashed tables, but we already verify the number of entries in a filter or routing table is nonzero. Stop assuming a hashed table entry exists in ipa_table_init_add(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index cf3a3de239dc3..94bb7611e574b 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -376,14 +376,12 @@ int ipa_table_hash_flush(struct ipa *ipa) return 0; } -static void ipa_table_init_add(struct gsi_trans *trans, bool filter, - enum ipa_cmd_opcode opcode, - enum ipa_mem_id mem_id, - enum ipa_mem_id hash_mem_id) +static void ipa_table_init_add(struct gsi_trans *trans, bool filter, bool ipv6) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *hash_mem = ipa_mem_find(ipa, hash_mem_id); - const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); + const struct ipa_mem *hash_mem; + enum ipa_cmd_opcode opcode; + const struct ipa_mem *mem; dma_addr_t hash_addr; dma_addr_t addr; u32 zero_offset; @@ -393,6 +391,14 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, u16 count; u16 size; + opcode = filter ? ipv6 ? IPA_CMD_IP_V6_FILTER_INIT + : IPA_CMD_IP_V4_FILTER_INIT + : ipv6 ? IPA_CMD_IP_V6_ROUTING_INIT + : IPA_CMD_IP_V4_ROUTING_INIT; + + mem = ipa_table_mem(ipa, filter, false, ipv6); + hash_mem = ipa_table_mem(ipa, filter, true, ipv6); + /* Compute the number of table entries to initialize */ if (filter) { /* The number of filtering endpoints determines number of @@ -401,13 +407,13 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, * table is either the same as the non-hashed one, or zero. */ count = 1 + hweight32(ipa->filter_map); - hash_count = hash_mem->size ? count : 0; + hash_count = hash_mem && hash_mem->size ? count : 0; } else { /* The size of a route table region determines the number * of entries it has. */ count = mem->size / sizeof(__le64); - hash_count = hash_mem->size / sizeof(__le64); + hash_count = hash_mem && hash_mem->size / sizeof(__le64); } size = count * sizeof(__le64); hash_size = hash_count * sizeof(__le64); @@ -458,17 +464,10 @@ int ipa_table_setup(struct ipa *ipa) return -EBUSY; } - ipa_table_init_add(trans, false, IPA_CMD_IP_V4_ROUTING_INIT, - IPA_MEM_V4_ROUTE, IPA_MEM_V4_ROUTE_HASHED); - - ipa_table_init_add(trans, false, IPA_CMD_IP_V6_ROUTING_INIT, - IPA_MEM_V6_ROUTE, IPA_MEM_V6_ROUTE_HASHED); - - ipa_table_init_add(trans, true, IPA_CMD_IP_V4_FILTER_INIT, - IPA_MEM_V4_FILTER, IPA_MEM_V4_FILTER_HASHED); - - ipa_table_init_add(trans, true, IPA_CMD_IP_V6_FILTER_INIT, - IPA_MEM_V6_FILTER, IPA_MEM_V6_FILTER_HASHED); + ipa_table_init_add(trans, false, false); + ipa_table_init_add(trans, false, true); + ipa_table_init_add(trans, true, false); + ipa_table_init_add(trans, true, true); gsi_trans_commit_wait(trans);