From patchwork Tue Oct 25 19:51:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 10961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1189165wru; Tue, 25 Oct 2022 12:58:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7gCnD9jdeM9KtaXKA+w/CfKCMs8b6/ZCOxWibwjkZMQis+XwOkgbkvEoCNzEHcj9sq4fAE X-Received: by 2002:a17:907:7621:b0:741:6656:bd14 with SMTP id jy1-20020a170907762100b007416656bd14mr33841736ejc.298.1666727880506; Tue, 25 Oct 2022 12:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666727880; cv=none; d=google.com; s=arc-20160816; b=rsTeMYYD6Fypvhd25e4EZLpLpuf8/QvGyY1y2t8tqc8ox/nDzhsn6I7H0bt90k/jPx 9e76ad5tGUSQoI6w2PBjUANAoU081KCvB3ZNl/jVyNZ3JciemaHDlVHQ8D/JYIWYR0vP 4pnzuPrc2DczYF8ocJAl+w3lFITsYSwHDLJp6Q75UPaIVXP/tliXgVraG5okvI/UeKss ziQpIbK3wZWknCZSVpz6fSNVJf8szLvWbVTls0bACUlDZMki2Q1Z51bdY9XnqqqQcgtz zfutccJr8vpH0UiTCP8C3eygRmmGeIT0c2TBg0QeZFufimUt7yrZimk0NI/5yOJdxZBO vkiA== 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=l133zv+Dip4+RVfo1hNbK6ZAuTDbPpUv6wOODnCUtFU=; b=SloEzPEB3xuctZTBtdALfUXhJ6hmwtSYeeO0dSs+ObMJaSPzpZ4q+2cd6EjtjAicOs BUHUNECSCWBNNvN/EqIbyPfpW+2/HeDtipcQC+aORhqWhy5y6sM6vtqydYghR/tHqGnv PWo44pdXR/Wo947MMfU2L7wPZDnz9FYA/bc9t9SS7/DcQ6q8NrOx4Al9f+jAERachfVU p6GacBJkrR/F0AU4qR4fnYMsb6GkTAISbwuVq2RZgDtuyXYK4wAKRPWTUduQ3M9AchkT h1V8OP1UtGmmeUXyzrgsmT7wJ/U9Qxgizg50v5y+Vi43vs5WGdY2C9Uw0ykWcEpXOUoB EbBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wtLM9Ns/"; 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 c16-20020a0564021f9000b00456662097dasi3322910edc.69.2022.10.25.12.57.31; Tue, 25 Oct 2022 12:58:00 -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="wtLM9Ns/"; 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 S232528AbiJYTwD (ORCPT + 99 others); Tue, 25 Oct 2022 15:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbiJYTv6 (ORCPT ); Tue, 25 Oct 2022 15:51:58 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F9D106A6C for ; Tue, 25 Oct 2022 12:51:52 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id h203so11439354iof.1 for ; Tue, 25 Oct 2022 12:51:52 -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=l133zv+Dip4+RVfo1hNbK6ZAuTDbPpUv6wOODnCUtFU=; b=wtLM9Ns/jhaQnCQdl/vOr8eYMTtqTnnamG9PlzaLFmyAlerQ7Mnaa6o8H5ozhq/2CU 5z++B95jLsiNl2EAJ3NhGwvdx/TYDMxKs3ewOfFFU+H9qVLPBpqYGVRDl9fIDsGp6/FH tbpRL6KF/OVeAtXYutYcVkb0+0pQTVvU+8T4GrMtYfIebGIHycj9Hikernak6+8FdQai 0fAZJTY4iP/KV7asVxxw4SGWZjQz4YvZYdbQ831Xtbe618HSeAoFGFPvm6S0RC2wNo+d G9hDIDbgPWwy4yk3R+1/H4AxHegL1YTKRDSxcaPa78tDKCPVC5F1gffLa2HXV7l5/FLR hspg== 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=l133zv+Dip4+RVfo1hNbK6ZAuTDbPpUv6wOODnCUtFU=; b=aCVi601RzEdCWFAufTfA5MdGq1Zvg1OIdBm/l9/KW7aLps6F/AKOLwPQKuw2Y3meAg L6zOfvxaptS4YdH+VspOU021MvaZllNRAPnS+hWRBUr2grgqH5HdJk7wklYU6wEfwTru EsSbWO/+GQXwoVNPQMUy70K5jnwyV7TzvF67DC1ZrP6yGu99El7+TACdt8JmJEV/hacJ T8ar5z9KLotekkV1WVQZODPse7dltFCS6A/gyNjyWm975iuK3Xld8gxnjbQkMhbzLniQ eQxLNTKeTcrBmFiTjE2el+gJ2HWBErHgGqLXrgttxRMDqoetD+JKzM9Z0W7KKpbeEs3M 69WA== X-Gm-Message-State: ACrzQf03f+tL+vYWgf295oulmA46biIWSp4stAze1sg4cPA9mMaP0mfi DD2RAvouCz/h4zabB9M0eIIHkg== X-Received: by 2002:a05:6638:35a2:b0:364:451:9969 with SMTP id v34-20020a05663835a200b0036404519969mr26740834jal.245.1666727511779; Tue, 25 Oct 2022 12:51:51 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id y10-20020a056638014a00b00349d2d52f6asm1211719jao.37.2022.10.25.12.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 12:51:50 -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/4] net: ipa: record the route table size in the IPA structure Date: Tue, 25 Oct 2022 14:51:40 -0500 Message-Id: <20221025195143.255934-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221025195143.255934-1-elder@linaro.org> References: <20221025195143.255934-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,URIBL_BLOCKED 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?1747690853827319374?= X-GMAIL-MSGID: =?utf-8?q?1747690853827319374?= The non-hashed routing tables for IPv4 and IPv6 will be the same size. And if supported, the hashed routing tables will be the same size as the non-hashed tables. Record the size (number of entries) of all routing tables in the IPA structure. For now, initialize this field using IPA_ROUTE_TABLE_MAX, and just do so when the first route table is validated. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 2 ++ drivers/net/ipa/ipa_table.c | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 09ead433ec38e..aa39509e209a3 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -39,6 +39,7 @@ struct ipa_interrupt; * @power: IPA power information * @table_addr: DMA address of filter/route table content * @table_virt: Virtual address of filter/route table content + * @route_count: Total number of entries in a routing table * @interrupt: IPA Interrupt information * @uc_powered: true if power is active by proxy for microcontroller * @uc_loaded: true after microcontroller has reported it's ready @@ -84,6 +85,7 @@ struct ipa { dma_addr_t table_addr; __le64 *table_virt; + u32 route_count; struct ipa_interrupt *interrupt; bool uc_powered; diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 58a1a9da3133e..0815c8967e914 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -185,7 +185,7 @@ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) if (!count) return 0; - WARN_ON(count > max_t(u32, IPA_FILTER_COUNT_MAX, IPA_ROUTE_COUNT_MAX)); + WARN_ON(count > max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count)); /* Skip over the zero rule and possibly the filter mask */ skip = filter_mask ? 1 : 2; @@ -302,7 +302,7 @@ static int ipa_route_reset(struct ipa *ipa, bool modem) count = IPA_ROUTE_MODEM_COUNT; } else { first = IPA_ROUTE_MODEM_COUNT; - count = IPA_ROUTE_COUNT_MAX - IPA_ROUTE_MODEM_COUNT; + count = ipa->route_count - IPA_ROUTE_MODEM_COUNT; } ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE); @@ -552,7 +552,7 @@ static void ipa_route_config(struct ipa *ipa, bool modem) if (!ipa_table_hash_support(ipa)) return; - for (route_id = 0; route_id < IPA_ROUTE_COUNT_MAX; route_id++) + for (route_id = 0; route_id < ipa->route_count; route_id++) if (ipa_route_id_modem(route_id) == modem) ipa_route_tuple_zero(ipa, route_id); } @@ -566,7 +566,9 @@ void ipa_table_config(struct ipa *ipa) ipa_route_config(ipa, true); } -/* Zero modem_route_count means filter table memory check */ +/* Verify the sizes of all IPA table filter or routing table memory regions + * are valid. If valid, this records the size of the routing table. + */ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) { bool hash_support = ipa_table_hash_support(ipa); @@ -591,6 +593,10 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) if (mem_ipv4->size != mem_ipv6->size) return false; + /* Record the number of routing table entries */ + if (!filter) + ipa->route_count = IPA_ROUTE_COUNT_MAX; + /* Table offset and size must fit in TABLE_INIT command fields */ if (!ipa_cmd_table_init_valid(ipa, mem_ipv4, !filter)) return false; @@ -671,7 +677,7 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) * | ---- zero rule address | \ * |\ |-------------------| | * | ---- zero rule address | | IPA_FILTER_COUNT_MAX - * | |-------------------| > or IPA_ROUTE_COUNT_MAX, + * | |-------------------| > or IPA route count, * | ... | whichever is greater * \ |-------------------| | * ---- zero rule address | / @@ -679,15 +685,17 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) */ int ipa_table_init(struct ipa *ipa) { - u32 count = max_t(u32, IPA_FILTER_COUNT_MAX, IPA_ROUTE_COUNT_MAX); struct device *dev = &ipa->pdev->dev; dma_addr_t addr; __le64 le_addr; __le64 *virt; size_t size; + u32 count; ipa_table_validate_build(); + count = max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count); + /* The IPA hardware requires route and filter table rules to be * aligned on a 128-byte boundary. We put the "zero rule" at the * base of the table area allocated here. The DMA address returned @@ -722,7 +730,7 @@ int ipa_table_init(struct ipa *ipa) void ipa_table_exit(struct ipa *ipa) { - u32 count = max_t(u32, 1 + IPA_FILTER_COUNT_MAX, IPA_ROUTE_COUNT_MAX); + u32 count = max_t(u32, 1 + IPA_FILTER_COUNT_MAX, ipa->route_count); struct device *dev = &ipa->pdev->dev; size_t size; From patchwork Tue Oct 25 19:51:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 10959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1189001wru; Tue, 25 Oct 2022 12:57:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7eVfk7Ec1wYo/UtcTz45fyACwcBtQydzVcb8I3gqMd2dUfu//e0OYtyfjBcl8i9SfILrYl X-Received: by 2002:a17:907:2cce:b0:77a:6958:5aaa with SMTP id hg14-20020a1709072cce00b0077a69585aaamr32503205ejc.245.1666727854036; Tue, 25 Oct 2022 12:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666727854; cv=none; d=google.com; s=arc-20160816; b=oLn+qh/6DNhuAkeYQwtCPxVM+/Ei9hHmITq4gVnDucYLfHCo+Wx65SHthQUlOfkmbF wZaQMz8YV/KM3im9jmHcF9+Jfusd8pEtI0gVQ8YpFziUqZd2pSkUALaYlk2mpPTY/k1t IegpLP1kL9cv2MJyblSqKzXqVevzt8+aPjz2U0k2ukKB+FVqilSzF/NRwlA00UR2Vc3S xy4bAQuZWzn9gJaEyyfFshU77A53tsYMprnYaksZY/I8u6KGK3fZcSW+JkXJpu1wqiv9 J+7NQ28I5emmO8znO6ig9SFA6CkK3Sc418NrZL7wd7M6ANe0k+YrrvBvjSiq5CXvq4LE LC9A== 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=edo2LzRaJRftF/iqZOQNJxw3dQUUkViR6y/aHrA9w2E=; b=zfyfPKuBS6cCpjvaN/jSTcRMzrZJyTx1CQWd2CyXECIcN8eOPddUK0EuWwPcPQXqNU jdtO+m4cTd4hqVb7m2FCFKPVDQOL7EETWwvpUrJd14B1MwAADef+MwNdEHj+XcHQZ/6D n1Qo0uGklDOCJvG3m3ssFdylyvB/nvWMIIItRrTb7sZNx3LDLCE7AJKRNQE3v3N6R68P TqzdSwAClYaK/3JdNlGsVSRYmzczkXDWf09+vAVQMWOUtX+cabfo453kY+gz+tUyaovl +jQyYLYBZrT0us/gcth9Z3R8UUht1iqat05MMrFhwaTRjpylhj53uR/8/flzBH1MOupe l7xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T6Ycp3vI; 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 dx1-20020a170906a84100b00780e022dfb8si2930891ejb.494.2022.10.25.12.57.10; Tue, 25 Oct 2022 12:57:34 -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=T6Ycp3vI; 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 S232563AbiJYTwF (ORCPT + 99 others); Tue, 25 Oct 2022 15:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbiJYTv6 (ORCPT ); Tue, 25 Oct 2022 15:51:58 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A208106E0E for ; Tue, 25 Oct 2022 12:51:54 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id h203so11439476iof.1 for ; Tue, 25 Oct 2022 12:51:54 -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=edo2LzRaJRftF/iqZOQNJxw3dQUUkViR6y/aHrA9w2E=; b=T6Ycp3vIxUxmes1zXRChfYjP10CvMxnbVcBj1faRsM3tX7dTXttF7H4vVLpGnuqGRi m6X1geF/Jpn95cBDu+WpP/TbghIiZ7NuF5qKs7Ngo/5r4JXsanWFGfURZFhubnks/MaB 9jxiMh/3oEyS0YY5xcLnAHIsaarLphlMBNegeVNdZh3rw8VRAJW5o0d7td8o7cGxEJXh RNf9xZAVllRoQnboHC5PcXU8I8oLo0ZOGXH4Dmybirs03GBZ8xoFqc1YvEvVX17t9jzY XkuVRqblDOYAaPbrZFxm1wR1vOVEsCLRlwQIc7sVNiYL7yLqMJo9naR1q3yllM+KNiS9 GXrw== 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=edo2LzRaJRftF/iqZOQNJxw3dQUUkViR6y/aHrA9w2E=; b=DvBrwW+xmayzrrlwBmOFkyuQz5U4e2iz7nfYqLaCdjZhmctrpv59ueRpcj6F5jjEL7 VtM2pBamKsA9TCQsH08tdPLDqm1MdjHuTZqPTLhRZCCNMZlNp2u2wzNDLvYllmf9Q6pz Jqa4bP07lV8+u/o5lnI2vlgZasu27K7u/3RuGTfG+RUMnq/Ge8KQ/A+NTyWufWQUGx3c EMtu4w7YF1oeymvaEOfZscetLlROcaypNNqH1JvkUL8gO/mx2CYs6OWtbStOrdNzGYwj FQC84PnFBpRlitYgfninSkoCjkdEmC+oUXfFLLG/pFORbkmBttUp2C0o+Nshf0AM/lGs 3GYA== X-Gm-Message-State: ACrzQf0jf7YC/GekKZFtivmgdA8guepHIz2shR5OLp9RXKE1FXxIUUqA WCecBfEtJEagm/6Bawe4N8sLkQ== X-Received: by 2002:a05:6602:491:b0:672:18ce:8189 with SMTP id y17-20020a056602049100b0067218ce8189mr24199288iov.170.1666727514041; Tue, 25 Oct 2022 12:51:54 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id y10-20020a056638014a00b00349d2d52f6asm1211719jao.37.2022.10.25.12.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 12:51:52 -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 2/4] net: ipa: determine route table size from memory region Date: Tue, 25 Oct 2022 14:51:41 -0500 Message-Id: <20221025195143.255934-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221025195143.255934-1-elder@linaro.org> References: <20221025195143.255934-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,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747690826032135159?= X-GMAIL-MSGID: =?utf-8?q?1747690826032135159?= Currently we assume that any routing table contains a fixed number of entries. The number of entries in a routing table can actually vary, depending only on the size of the IPA-local memory region used to hold the table. Stop assuming that a routing table has exactly 15 entries. Instead, determine the number of entries in a routing table by dividing its memory region size by the size of an entry. The number of entries is computed early, when ipa_table_mem_valid() is called by ipa_table_init(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 17 ++++++++--------- drivers/net/ipa/ipa_table.c | 14 +++++--------- drivers/net/ipa/ipa_table.h | 3 --- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index de2cd86aa9e28..08e3f395a9453 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -145,18 +145,15 @@ union ipa_cmd_payload { static void ipa_cmd_validate_build(void) { - /* The sizes of a filter and route tables need to fit into fields - * in the ipa_cmd_hw_ip_fltrt_init structure. Although hashed tables + /* The size of a filter table needs to fit into fields in the + * ipa_cmd_hw_ip_fltrt_init structure. Although hashed tables * might not be used, non-hashed and hashed tables have the same * maximum size. IPv4 and IPv6 filter tables have the same number - * of entries, as and IPv4 and IPv6 route tables have the same number * of entries. */ -#define TABLE_SIZE (TABLE_COUNT_MAX * sizeof(__le64)) -#define TABLE_COUNT_MAX max_t(u32, IPA_ROUTE_COUNT_MAX, IPA_FILTER_COUNT_MAX) +#define TABLE_SIZE (IPA_FILTER_COUNT_MAX * sizeof(__le64)) BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK)); BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK)); -#undef TABLE_COUNT_MAX #undef TABLE_SIZE /* Hashed and non-hashed fields are assumed to be the same size */ @@ -178,12 +175,14 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); const char *table = route ? "route" : "filter"; struct device *dev = &ipa->pdev->dev; + u32 size; + + size = route ? ipa->route_count * sizeof(__le64) : mem->size; /* Size must fit in the immediate command field that holds it */ - if (mem->size > size_max) { + if (size > size_max) { dev_err(dev, "%s table region size too large\n", table); - dev_err(dev, " (0x%04x > 0x%04x)\n", - mem->size, size_max); + dev_err(dev, " (0x%04x > 0x%04x)\n", size, size_max); return false; } diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 0815c8967e914..23d3f081ac8e1 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -130,12 +130,8 @@ static void ipa_table_validate_build(void) */ BUILD_BUG_ON(IPA_ZERO_RULE_SIZE != sizeof(__le64)); - /* Impose a practical limit on the number of routes */ - BUILD_BUG_ON(IPA_ROUTE_COUNT_MAX > 32); /* The modem must be allotted at least one route table entry */ BUILD_BUG_ON(!IPA_ROUTE_MODEM_COUNT); - /* AP must too, but we can't use more than what is available */ - BUILD_BUG_ON(IPA_ROUTE_MODEM_COUNT >= IPA_ROUTE_COUNT_MAX); } static const struct ipa_mem * @@ -593,18 +589,18 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) if (mem_ipv4->size != mem_ipv6->size) return false; - /* Record the number of routing table entries */ + /* Compute the number of entries, and for routing tables, record it */ + count = mem_ipv4->size / sizeof(__le64); + if (count < 2) + return false; if (!filter) - ipa->route_count = IPA_ROUTE_COUNT_MAX; + ipa->route_count = count; /* Table offset and size must fit in TABLE_INIT command fields */ if (!ipa_cmd_table_init_valid(ipa, mem_ipv4, !filter)) return false; /* Make sure the regions are big enough */ - count = mem_ipv4->size / sizeof(__le64); - if (count < 2) - return false; if (filter) { /* Filter tables must able to hold the endpoint bitmap plus * an entry for each endpoint that supports filtering diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 65d96debd3917..31363292dc1db 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -16,9 +16,6 @@ struct ipa; /* The number of route table entries allotted to the modem */ #define IPA_ROUTE_MODEM_COUNT 8 -/* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ -#define IPA_ROUTE_COUNT_MAX 15 - /** * ipa_filter_map_valid() - Validate a filter table endpoint bitmap * @ipa: IPA pointer From patchwork Tue Oct 25 19:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 10963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1189618wru; Tue, 25 Oct 2022 12:59:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QeRO+ZkQhieP/V/VL0902LQJc/xv8w1ABr7UWwo2NayeIJkqrH/EP7Bw29knGFOCKOFny X-Received: by 2002:a63:d008:0:b0:46e:c359:7fa2 with SMTP id z8-20020a63d008000000b0046ec3597fa2mr19651930pgf.285.1666727965362; Tue, 25 Oct 2022 12:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666727965; cv=none; d=google.com; s=arc-20160816; b=wOX14CZuSMFFhBeChR6Yp9/hOPMhF7/xGE8rgteAS1gptSzMg7gVg1Gp/ezy6MP5xE TOhYNGbalDFLG6SPqOS02subhqDr/zikNi9rjatUK2U9Yvd47rqZh/rSsKpvcFHu1X6A qtzixnv9muT3TgVzs1JWG6TDkn16fPTSV5pDwHEtp2F2ZQ26/8Q23P2BFRB8tzIq1KMG c6FIsxwYck+EJ8CF4b9TGOrQWhc6202nuz7PEd+X4/WTtnJdXRC/AoiusvMGFxZd1XCZ cftj3hzSyOd22mNuynv9c/tkpxeD9SQlNBye5ulA9qcifsuVV/+m379rjLdBpanRpMpM 5t2g== 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=7B4T5dUVw6etXvayl+cOcjo1M7wurOEEeDstMQ8ZtZg=; b=MsBaU9n5OrGw7AYqiyPJbHRrj1x4vTDVY5lweDNoo/Xlk26IpTnKmJWPzms8ctpJp9 OzLiHjus0AKYyvd0yTEAl9BLS2nuR7PpiL23sBHmmT+4ocb5zoky+fRdBZmukzcA/otq Pys1wbszgMfoApBuStNV6l2k2UwON0BH0vmklQ3H8wSiDumOnfyhBq3V8T9eC2qGFMxS 5UDE4Tz2DUpRnyj8K8RL9RynPsXABMGwW50CcHdx2mtrWXTkLk6N4IDpNH21Egp2t5uM 6Wag+Lqj0GIK6l76ElkFGtSe7vPmGmQURuQr7iWZPDXBFxJdg5yw7C5CCocZqAOyHmds 5xGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hUaVsWOG; 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 c8-20020a634e08000000b00452a7b4f50bsi5101925pgb.48.2022.10.25.12.59.12; Tue, 25 Oct 2022 12:59:25 -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=hUaVsWOG; 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 S232617AbiJYTwL (ORCPT + 99 others); Tue, 25 Oct 2022 15:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232403AbiJYTv7 (ORCPT ); Tue, 25 Oct 2022 15:51:59 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158FB106E14 for ; Tue, 25 Oct 2022 12:51:57 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id q75so1648608iod.7 for ; Tue, 25 Oct 2022 12:51:57 -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=7B4T5dUVw6etXvayl+cOcjo1M7wurOEEeDstMQ8ZtZg=; b=hUaVsWOGWyaSIosq63z4jw7GX1Bn5s1AHfIlC9ZMChVn0NEjUE3wDtV26cX10TYgd7 dCf1bPomRKPwcqnRyuIiiilrbEwJE6MiHjO7HsQ1RAwZRfRoF9ORG8YYpCfZYErqX2Bs mv2wFmzF+JU3najiQ4H4jaZhHplgRwmIAOG+hPQgTLXbJu362FT+cz3Rqwdm5TvPeLqH ELARFOmsjXAvGAbBA5esRoeRkK+LJt68khYDskA2GTML79dKOk0fzkqWl9/gKqeJ3IKY 16VMFDeoqjEheVnegvtGvymC70FJ8TlfIFG7TT84RPXM3OxvLXL9usIeRaXDACXyYglV 7OGg== 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=7B4T5dUVw6etXvayl+cOcjo1M7wurOEEeDstMQ8ZtZg=; b=GA87z5UtBjTXiJy8Kczn6OGtiswk3c0k0xYCz33rJ6zd8mFAv14KEo82W4EAKzEqlM UrNNFz41eQdnZ89SMQ49JRwia0vY3lYbiBGy9vrYTjAqJBt38A1SVvttR7gLGkdBrnkV bEu+Z3vfGUeSo173Ztwpf4+SZg93zL0v50nRkWZtfDcEg+7/ihWrTx50sdBeNENeOAwV TgX75lu147oGXvslSnZ4thISArtApQSYhkIhevYxmqzNNxUe/yApc3vC+Jc9pW5m3dM/ RJbw0w2cKHSZukWMPUkbCaq+wK6YwoOfVjiju70pfGL2vVivZ/ffm1I4TMYxGxCrVuox /WkA== X-Gm-Message-State: ACrzQf12mB6Ef9plIQD8T1g5YITuy4zgqfD8k0gUTNhzhqvUKc5QeNVN IBCkEGJxvXSprJASo/kou4d2jQ== X-Received: by 2002:a05:6638:144a:b0:364:5a1:d54d with SMTP id l10-20020a056638144a00b0036405a1d54dmr25032063jad.42.1666727516327; Tue, 25 Oct 2022 12:51:56 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id y10-20020a056638014a00b00349d2d52f6asm1211719jao.37.2022.10.25.12.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 12:51:55 -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 3/4] net: ipa: don't assume 8 modem routing table entries Date: Tue, 25 Oct 2022 14:51:42 -0500 Message-Id: <20221025195143.255934-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221025195143.255934-1-elder@linaro.org> References: <20221025195143.255934-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,URIBL_BLOCKED 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?1747690942985594561?= X-GMAIL-MSGID: =?utf-8?q?1747690942985594561?= Currently all platforms are assumed allot 8 routing table entries for use by the modem. Instead, add a new configuration data entry that defines the number of modem routing table entries, and record that in the IPA structure. Signed-off-by: Alex Elder --- drivers/net/ipa/data/ipa_data-v3.1.c | 19 +++++++++--------- drivers/net/ipa/data/ipa_data-v3.5.1.c | 27 +++++++++++++------------- drivers/net/ipa/data/ipa_data-v4.11.c | 17 ++++++++-------- drivers/net/ipa/data/ipa_data-v4.2.c | 17 ++++++++-------- drivers/net/ipa/data/ipa_data-v4.5.c | 17 ++++++++-------- drivers/net/ipa/data/ipa_data-v4.9.c | 17 ++++++++-------- drivers/net/ipa/ipa.h | 2 ++ drivers/net/ipa/ipa_data.h | 2 ++ drivers/net/ipa/ipa_main.c | 6 ++++++ drivers/net/ipa/ipa_mem.c | 4 ++-- drivers/net/ipa/ipa_qmi.c | 9 +++++---- drivers/net/ipa/ipa_table.c | 21 +++++++++----------- drivers/net/ipa/ipa_table.h | 7 ++----- 13 files changed, 88 insertions(+), 77 deletions(-) diff --git a/drivers/net/ipa/data/ipa_data-v3.1.c b/drivers/net/ipa/data/ipa_data-v3.1.c index e0d71f6092729..3380fb3483b2c 100644 --- a/drivers/net/ipa/data/ipa_data-v3.1.c +++ b/drivers/net/ipa/data/ipa_data-v3.1.c @@ -525,13 +525,14 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v3.1 */ const struct ipa_data ipa_data_v3_1 = { - .version = IPA_VERSION_3_1, - .backward_compat = BIT(BCR_CMDQ_L_LACK_ONE_ENTRY), - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .version = IPA_VERSION_3_1, + .backward_compat = BIT(BCR_CMDQ_L_LACK_ONE_ENTRY), + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/data/ipa_data-v3.5.1.c b/drivers/net/ipa/data/ipa_data-v3.5.1.c index 383ef18900654..47591faf8bd62 100644 --- a/drivers/net/ipa/data/ipa_data-v3.5.1.c +++ b/drivers/net/ipa/data/ipa_data-v3.5.1.c @@ -406,17 +406,18 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v3.5.1 */ const struct ipa_data ipa_data_v3_5_1 = { - .version = IPA_VERSION_3_5_1, - .backward_compat = BIT(BCR_CMDQ_L_LACK_ONE_ENTRY) | - BIT(BCR_TX_NOT_USING_BRESP) | - BIT(BCR_SUSPEND_L2_IRQ) | - BIT(BCR_HOLB_DROP_L2_IRQ) | - BIT(BCR_DUAL_TX), - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .version = IPA_VERSION_3_5_1, + .backward_compat = BIT(BCR_CMDQ_L_LACK_ONE_ENTRY) | + BIT(BCR_TX_NOT_USING_BRESP) | + BIT(BCR_SUSPEND_L2_IRQ) | + BIT(BCR_HOLB_DROP_L2_IRQ) | + BIT(BCR_DUAL_TX), + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/data/ipa_data-v4.11.c b/drivers/net/ipa/data/ipa_data-v4.11.c index a204e439c23d3..1b4b52501ee33 100644 --- a/drivers/net/ipa/data/ipa_data-v4.11.c +++ b/drivers/net/ipa/data/ipa_data-v4.11.c @@ -394,12 +394,13 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v4.11 */ const struct ipa_data ipa_data_v4_11 = { - .version = IPA_VERSION_4_11, - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .version = IPA_VERSION_4_11, + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/data/ipa_data-v4.2.c b/drivers/net/ipa/data/ipa_data-v4.2.c index 04f574fe006f0..199ed0ed868b9 100644 --- a/drivers/net/ipa/data/ipa_data-v4.2.c +++ b/drivers/net/ipa/data/ipa_data-v4.2.c @@ -372,13 +372,14 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v4.2 */ const struct ipa_data ipa_data_v4_2 = { - .version = IPA_VERSION_4_2, + .version = IPA_VERSION_4_2, /* backward_compat value is 0 */ - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/data/ipa_data-v4.5.c b/drivers/net/ipa/data/ipa_data-v4.5.c index 684239e71f46a..19b549f2998b8 100644 --- a/drivers/net/ipa/data/ipa_data-v4.5.c +++ b/drivers/net/ipa/data/ipa_data-v4.5.c @@ -450,12 +450,13 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v4.5 */ const struct ipa_data ipa_data_v4_5 = { - .version = IPA_VERSION_4_5, - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .version = IPA_VERSION_4_5, + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/data/ipa_data-v4.9.c b/drivers/net/ipa/data/ipa_data-v4.9.c index 2333e15f95338..d30fc1fe6ca22 100644 --- a/drivers/net/ipa/data/ipa_data-v4.9.c +++ b/drivers/net/ipa/data/ipa_data-v4.9.c @@ -444,12 +444,13 @@ static const struct ipa_power_data ipa_power_data = { /* Configuration data for an SoC having IPA v4.9. */ const struct ipa_data ipa_data_v4_9 = { - .version = IPA_VERSION_4_9, - .qsb_count = ARRAY_SIZE(ipa_qsb_data), - .qsb_data = ipa_qsb_data, - .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), - .endpoint_data = ipa_gsi_endpoint_data, - .resource_data = &ipa_resource_data, - .mem_data = &ipa_mem_data, - .power_data = &ipa_power_data, + .version = IPA_VERSION_4_9, + .qsb_count = ARRAY_SIZE(ipa_qsb_data), + .qsb_data = ipa_qsb_data, + .modem_route_count = 8, + .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data), + .endpoint_data = ipa_gsi_endpoint_data, + .resource_data = &ipa_resource_data, + .mem_data = &ipa_mem_data, + .power_data = &ipa_power_data, }; diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index aa39509e209a3..5c95acc70bb33 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -40,6 +40,7 @@ struct ipa_interrupt; * @table_addr: DMA address of filter/route table content * @table_virt: Virtual address of filter/route table content * @route_count: Total number of entries in a routing table + * @modem_route_count: Number of modem entries in a routing table * @interrupt: IPA Interrupt information * @uc_powered: true if power is active by proxy for microcontroller * @uc_loaded: true after microcontroller has reported it's ready @@ -86,6 +87,7 @@ struct ipa { dma_addr_t table_addr; __le64 *table_virt; u32 route_count; + u32 modem_route_count; struct ipa_interrupt *interrupt; bool uc_powered; diff --git a/drivers/net/ipa/ipa_data.h b/drivers/net/ipa/ipa_data.h index e5a6ce75c7ddd..412edbfac7862 100644 --- a/drivers/net/ipa/ipa_data.h +++ b/drivers/net/ipa/ipa_data.h @@ -222,6 +222,7 @@ struct ipa_power_data { * @backward_compat: BCR register value (prior to IPA v4.5 only) * @qsb_count: number of entries in the qsb_data array * @qsb_data: Qualcomm System Bus configuration data + * @modem_route_count: number of modem entries in a routing table * @endpoint_count: number of entries in the endpoint_data array * @endpoint_data: IPA endpoint/GSI channel data * @resource_data: IPA resource configuration data @@ -233,6 +234,7 @@ struct ipa_data { u32 backward_compat; u32 qsb_count; /* number of entries in qsb_data[] */ const struct ipa_qsb_data *qsb_data; + u32 modem_route_count; u32 endpoint_count; /* number of entries in endpoint_data[] */ const struct ipa_gsi_endpoint_data *endpoint_data; const struct ipa_resource_data *resource_data; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 3461ad3029ab8..ce5eadad671f3 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -739,6 +739,11 @@ static int ipa_probe(struct platform_device *pdev) return -EINVAL; } + if (!data->modem_route_count) { + dev_err(dev, "modem_route_count cannot be zero\n"); + return -EINVAL; + } + /* If we need Trust Zone, make sure it's available */ modem_init = of_property_read_bool(dev->of_node, "modem-init"); if (!modem_init) @@ -763,6 +768,7 @@ static int ipa_probe(struct platform_device *pdev) dev_set_drvdata(dev, ipa); ipa->power = power; ipa->version = data->version; + ipa->modem_route_count = data->modem_route_count; init_completion(&ipa->completion); ret = ipa_reg_init(ipa); diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index a3d2317452ac6..cb95402018394 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -618,9 +618,9 @@ int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) ipa->mem = mem_data->local; /* Check the route and filter table memory regions */ - if (!ipa_table_mem_valid(ipa, 0)) + if (!ipa_table_mem_valid(ipa, false)) return -EINVAL; - if (!ipa_table_mem_valid(ipa, IPA_ROUTE_MODEM_COUNT)) + if (!ipa_table_mem_valid(ipa, true)) return -EINVAL; ret = dma_set_mask_and_coherent(&ipa->pdev->dev, DMA_BIT_MASK(64)); diff --git a/drivers/net/ipa/ipa_qmi.c b/drivers/net/ipa/ipa_qmi.c index 8295fd4b70d16..f70f0a1d1cdac 100644 --- a/drivers/net/ipa/ipa_qmi.c +++ b/drivers/net/ipa/ipa_qmi.c @@ -284,6 +284,7 @@ static const struct ipa_init_modem_driver_req * init_modem_driver_req(struct ipa_qmi *ipa_qmi) { struct ipa *ipa = container_of(ipa_qmi, struct ipa, qmi); + u32 modem_route_count = ipa->modem_route_count; static struct ipa_init_modem_driver_req req; const struct ipa_mem *mem; @@ -308,12 +309,12 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE); req.v4_route_tbl_info_valid = 1; req.v4_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v4_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1; + req.v4_route_tbl_info.end = modem_route_count - 1; mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE); req.v6_route_tbl_info_valid = 1; req.v6_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v6_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1; + req.v6_route_tbl_info.end = modem_route_count - 1; mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER); req.v4_filter_tbl_start_valid = 1; @@ -352,7 +353,7 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v4_hash_route_tbl_info_valid = 1; req.v4_hash_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v4_hash_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1; + req.v4_hash_route_tbl_info.end = modem_route_count - 1; } mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE_HASHED); @@ -360,7 +361,7 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v6_hash_route_tbl_info_valid = 1; req.v6_hash_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v6_hash_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1; + req.v6_hash_route_tbl_info.end = modem_route_count - 1; } mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER_HASHED); diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 23d3f081ac8e1..c9ab6a3fabbc3 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -129,9 +129,6 @@ static void ipa_table_validate_build(void) * assumes that it can be written using a pointer to __le64. */ BUILD_BUG_ON(IPA_ZERO_RULE_SIZE != sizeof(__le64)); - - /* The modem must be allotted at least one route table entry */ - BUILD_BUG_ON(!IPA_ROUTE_MODEM_COUNT); } static const struct ipa_mem * @@ -281,6 +278,7 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem) * */ static int ipa_route_reset(struct ipa *ipa, bool modem) { + u32 modem_route_count = ipa->modem_route_count; struct gsi_trans *trans; u16 first; u16 count; @@ -295,10 +293,10 @@ static int ipa_route_reset(struct ipa *ipa, bool modem) if (modem) { first = 0; - count = IPA_ROUTE_MODEM_COUNT; + count = modem_route_count; } else { - first = IPA_ROUTE_MODEM_COUNT; - count = ipa->route_count - IPA_ROUTE_MODEM_COUNT; + first = modem_route_count; + count = ipa->route_count - modem_route_count; } ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE); @@ -511,9 +509,9 @@ static void ipa_filter_config(struct ipa *ipa, bool modem) } } -static bool ipa_route_id_modem(u32 route_id) +static bool ipa_route_id_modem(struct ipa *ipa, u32 route_id) { - return route_id < IPA_ROUTE_MODEM_COUNT; + return route_id < ipa->modem_route_count; } /** @@ -549,7 +547,7 @@ static void ipa_route_config(struct ipa *ipa, bool modem) return; for (route_id = 0; route_id < ipa->route_count; route_id++) - if (ipa_route_id_modem(route_id) == modem) + if (ipa_route_id_modem(ipa, route_id) == modem) ipa_route_tuple_zero(ipa, route_id); } @@ -565,10 +563,9 @@ void ipa_table_config(struct ipa *ipa) /* Verify the sizes of all IPA table filter or routing table memory regions * are valid. If valid, this records the size of the routing table. */ -bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) +bool ipa_table_mem_valid(struct ipa *ipa, bool filter) { bool hash_support = ipa_table_hash_support(ipa); - bool filter = !modem_route_count; const struct ipa_mem *mem_hashed; const struct ipa_mem *mem_ipv4; const struct ipa_mem *mem_ipv6; @@ -611,7 +608,7 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) /* Routing tables must be able to hold all modem entries, * plus at least one entry for the AP. */ - if (count < modem_route_count + 1) + if (count < ipa->modem_route_count + 1) return false; } diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 31363292dc1db..79583b16f363f 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -13,9 +13,6 @@ struct ipa; /* The maximum number of filter table entries (IPv4, IPv6; hashed or not) */ #define IPA_FILTER_COUNT_MAX 14 -/* The number of route table entries allotted to the modem */ -#define IPA_ROUTE_MODEM_COUNT 8 - /** * ipa_filter_map_valid() - Validate a filter table endpoint bitmap * @ipa: IPA pointer @@ -78,8 +75,8 @@ void ipa_table_exit(struct ipa *ipa); /** * ipa_table_mem_valid() - Validate sizes of table memory regions * @ipa: IPA pointer - * @modem_route_count: Number of modem route table entries + * @filter: Whether to check filter or routing tables */ -bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count); +bool ipa_table_mem_valid(struct ipa *ipa, bool filter); #endif /* _IPA_TABLE_H_ */ From patchwork Tue Oct 25 19:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 10960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1189081wru; Tue, 25 Oct 2022 12:57:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MxPPVT2bvBf5OiwBXyaXxaYlAvwhhfiUaWN11/OZRIyn/tL0JOOrtXPUHG8svZVSStE4g X-Received: by 2002:a17:906:8a48:b0:7a5:a8f5:b870 with SMTP id gx8-20020a1709068a4800b007a5a8f5b870mr12599666ejc.458.1666727867007; Tue, 25 Oct 2022 12:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666727866; cv=none; d=google.com; s=arc-20160816; b=wEC+s5XjXCUNSc6Ifl7lHEuSRTBVNw90NgFrqfnTWfCmPt4WNPipUCWKhW102v28VZ fb8rprfoHpOLJeTDBz3rpLRMR9CO2r6H+0ITcD+bVqRvd6RpFA4gJpOcfI4IC1nkmncS IbQkrtH/SC44r3t9nTJ8JM/SffJLUg8BAnHnfwVm7iLAGUW/hyUht229LIEiLIE8aP36 Y4njh/242y0B/MB0mn8MivV69i0oDlcvSzG+HKiP+eFrLGY/TjGvCCyCNP/uW0T1rnqa uawT3lqsv2+2gU0891Bsti4jxCwQo8O/QSxG9gpKRDDCVbORK0DjxZcHCxwL7C3fsIxK dUpQ== 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=kzxGUpzbXxImm84chnls9JcE5FMkEnfBOo4eTdKEFsk=; b=hyzqgOuPht1nP+Ub1xOTx3Vixkz2Rm0RmazJ7DWMIk/vFVs9fKJouLtx+ArYk8285x UkXANkqTOUAhhaUmLZ7TAxSwtNIsmaMyE1+n/Xw7eQCMAhH1cMUTiX/mYtyCRjkOf9SV Dzu1J+fimL+VE4/cCUwALiNYOPrRDLDJfHb0XkTVAOewWUBCgqrTdVd6LZOqRLa3m9v/ gBbN921qqfYZZcGgQJrhEy7oUs+g49EO+w28LwGGpCdHTGvRWf07XgpVDhshruDGzM/l x414hHEhOoKBtlINb8BnEsFZ7SjpnOI8GqY458dgHK+MkOi9qUPmvN26mrckzUnfKgqf JD+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7vJizje; 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 l10-20020a056402344a00b004591f959c3bsi3028537edc.427.2022.10.25.12.57.22; Tue, 25 Oct 2022 12:57:46 -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=d7vJizje; 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 S232602AbiJYTwO (ORCPT + 99 others); Tue, 25 Oct 2022 15:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbiJYTwF (ORCPT ); Tue, 25 Oct 2022 15:52:05 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540B3106E06 for ; Tue, 25 Oct 2022 12:51:59 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id y80so11430199iof.3 for ; Tue, 25 Oct 2022 12:51:59 -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=kzxGUpzbXxImm84chnls9JcE5FMkEnfBOo4eTdKEFsk=; b=d7vJizjehnoLsN4v+Aizmx7Y1q2iL54jeFUJWrbcm4/2ynOw1RDegLc409znFarKsw HE9OKWnp9eW4nJnTnie9nMmTs+2rO4s2vMBmcmG7yaFlbqIBxdK8pUOh6ygb+d4M6qxy ljle91MMhrF1omsAOxXQJJvBcA7JTAvRMQUrJA0Zpehe7rSrEKQOMGB+6k/TTmxdB5Ox 8rmLW0Q89Ta5FD10PT/GpJOcbdsgBq3IsiTVnIBHyyxDwd7+ulg9orZkRoUh0vhRs4Ke O9B4Xi4a7aBDBFAMagF2rgxg8zYoLO2aPJzKJnxg/RW9/kERYCV+qxKY7wsJrDr5AqE2 kAzw== 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=kzxGUpzbXxImm84chnls9JcE5FMkEnfBOo4eTdKEFsk=; b=WV8WJyuMdOx1oVngnR+90Rh4+PQTTr7+K75KRDbnwaPJnRzWbMAqZWlaX9nk4v9oj+ Z/kR3wAAHVuxmiw21TgCDUZPSTczgpXkmjiCdGaVXYuRn9oxo7Fo9cbdUZk3trHCEVDn bmznz6LTii1+V9ZWInTry6ewvXv5d2gCgX2DZbC8/tLTtColV4PRKeggOglOTX9hDhE6 +cXFB4I5EJ4xadiYdP214nh0J+CNtWONRSehWuYxH6IrYKwi053pi/T5EDhNpKwvUnvS uc3hIx03DKO92sVkiRrZJXW3jBRGVGhyu/Dvj4wh4eqfR5rv0S42gkqH7QQtZGBdIsWH 3f0A== X-Gm-Message-State: ACrzQf3nRv8iD/owE8uJIDO6vXJbxC48fh9sH2rSpykg85Kbr8m+EXUO m83OazrUT1Lu6o1ll1Ij6P/gUQ== X-Received: by 2002:a05:6638:1687:b0:374:fbbd:6617 with SMTP id f7-20020a056638168700b00374fbbd6617mr4754988jat.201.1666727518613; Tue, 25 Oct 2022 12:51:58 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id y10-20020a056638014a00b00349d2d52f6asm1211719jao.37.2022.10.25.12.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 12:51:57 -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 4/4] net: ipa: determine filter table size from memory region Date: Tue, 25 Oct 2022 14:51:43 -0500 Message-Id: <20221025195143.255934-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221025195143.255934-1-elder@linaro.org> References: <20221025195143.255934-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,URIBL_BLOCKED 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?1747690840190135920?= X-GMAIL-MSGID: =?utf-8?q?1747690840190135920?= Currently we assume that any filter table contains a fixed number of entries. Like routing tables, the number of entries in a filter table is limited only by the size of the IPA-local memory region used to hold the table. Stop assuming that a filter table has exactly 14 entries. Instead, determine the number of entries in a routing table by dividing its memory region size by the size of an entry. (Note that the first "entry" in a filter table contains an endpoint bitmap.) Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 2 ++ drivers/net/ipa/ipa_cmd.c | 8 ++------ drivers/net/ipa/ipa_table.c | 20 +++++++++++--------- drivers/net/ipa/ipa_table.h | 3 --- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 5c95acc70bb33..82225316a2e25 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -41,6 +41,7 @@ struct ipa_interrupt; * @table_virt: Virtual address of filter/route table content * @route_count: Total number of entries in a routing table * @modem_route_count: Number of modem entries in a routing table + * @filter_count: Maximum number of entries in a filter table * @interrupt: IPA Interrupt information * @uc_powered: true if power is active by proxy for microcontroller * @uc_loaded: true after microcontroller has reported it's ready @@ -88,6 +89,7 @@ struct ipa { __le64 *table_virt; u32 route_count; u32 modem_route_count; + u32 filter_count; struct ipa_interrupt *interrupt; bool uc_powered; diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 08e3f395a9453..bb3dfa9a2bc81 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -151,11 +151,6 @@ static void ipa_cmd_validate_build(void) * maximum size. IPv4 and IPv6 filter tables have the same number * of entries. */ -#define TABLE_SIZE (IPA_FILTER_COUNT_MAX * sizeof(__le64)) - BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK)); - BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK)); -#undef TABLE_SIZE - /* Hashed and non-hashed fields are assumed to be the same size */ BUILD_BUG_ON(field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK) != field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK)); @@ -177,7 +172,8 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, struct device *dev = &ipa->pdev->dev; u32 size; - size = route ? ipa->route_count * sizeof(__le64) : mem->size; + size = route ? ipa->route_count : ipa->filter_count + 1; + size *= sizeof(__le64); /* Size must fit in the immediate command field that holds it */ if (size > size_max) { diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index c9ab6a3fabbc3..db1992eaafaa9 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -160,9 +160,9 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) } count = hweight32(filter_map); - if (count > IPA_FILTER_COUNT_MAX) { + if (count > ipa->filter_count) { dev_err(dev, "too many filtering endpoints (%u, max %u)\n", - count, IPA_FILTER_COUNT_MAX); + count, ipa->filter_count); return false; } @@ -178,7 +178,7 @@ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) if (!count) return 0; - WARN_ON(count > max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count)); + WARN_ON(count > max_t(u32, ipa->filter_count, ipa->route_count)); /* Skip over the zero rule and possibly the filter mask */ skip = filter_mask ? 1 : 2; @@ -586,11 +586,13 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool filter) if (mem_ipv4->size != mem_ipv6->size) return false; - /* Compute the number of entries, and for routing tables, record it */ + /* Compute and record the number of entries for each table type */ count = mem_ipv4->size / sizeof(__le64); if (count < 2) return false; - if (!filter) + if (filter) + ipa->filter_count = count - 1; /* Filter map in first entry */ + else ipa->route_count = count; /* Table offset and size must fit in TABLE_INIT command fields */ @@ -645,7 +647,7 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool filter) * * The first entry in a filter table contains a bitmap indicating which * endpoints contain entries in the table. In addition to that first entry, - * there are at most IPA_FILTER_COUNT_MAX entries that follow. Filter table + * there is a fixed maximum number of entries that follow. Filter table * entries are 64 bits wide, and (other than the bitmap) contain the DMA * address of a filter rule. A "zero rule" indicates no filtering, and * consists of 64 bits of zeroes. When a filter table is initialized (or @@ -669,7 +671,7 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool filter) * |\ |-------------------| * | ---- zero rule address | \ * |\ |-------------------| | - * | ---- zero rule address | | IPA_FILTER_COUNT_MAX + * | ---- zero rule address | | Max IPA filter count * | |-------------------| > or IPA route count, * | ... | whichever is greater * \ |-------------------| | @@ -687,7 +689,7 @@ int ipa_table_init(struct ipa *ipa) ipa_table_validate_build(); - count = max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count); + count = max_t(u32, ipa->filter_count, ipa->route_count); /* The IPA hardware requires route and filter table rules to be * aligned on a 128-byte boundary. We put the "zero rule" at the @@ -723,7 +725,7 @@ int ipa_table_init(struct ipa *ipa) void ipa_table_exit(struct ipa *ipa) { - u32 count = max_t(u32, 1 + IPA_FILTER_COUNT_MAX, ipa->route_count); + u32 count = max_t(u32, 1 + ipa->filter_count, ipa->route_count); struct device *dev = &ipa->pdev->dev; size_t size; diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 79583b16f363f..8a4dcd7df4c0f 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -10,9 +10,6 @@ struct ipa; -/* The maximum number of filter table entries (IPv4, IPv6; hashed or not) */ -#define IPA_FILTER_COUNT_MAX 14 - /** * ipa_filter_map_valid() - Validate a filter table endpoint bitmap * @ipa: IPA pointer