From patchwork Wed Jan 25 20:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp477947wrn; Wed, 25 Jan 2023 12:47:18 -0800 (PST) X-Google-Smtp-Source: AK7set8gcydp2d+OqXb0ytgrVbeP3TbF6mP51zmAIuKVsTQelSQLhC2E7N4rA+kf4FrEuGJGIUBM X-Received: by 2002:a17:907:7856:b0:878:4cdb:cb42 with SMTP id lb22-20020a170907785600b008784cdbcb42mr1104815ejc.60.1674679638674; Wed, 25 Jan 2023 12:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679638; cv=none; d=google.com; s=arc-20160816; b=U/usM5g0/zMpc6ValrdVHHjuAs4UspuAVlUeK2BL/Fhiu5+IewKTsX4fbhkNczgRjE 5n1tdQ6UHKVPKP5uOS+x5fRfFF7qUzS/Snyan1SpPd9prPJGXyJkVNpXolzMTRuqpYtj EQRL+aldj2N0IP5j7XbEOwbiPd4727ZVRpiSVVG2SKNm31ILaGqu6SgK+B+4YgfPCLES X1uvmtRtMlRwWhskjkvGXEjmcF/wQM3jIYblrzKhaEBUeTJrLp2jSK7xeACf08RIIBrG xnQFG+vzjbm4577zN5UmbdQMHkeshgxzgNFv/uQOWJKfoJV2HakdVfya2HumlFmTPDAU eMsg== 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=xOIF99BwsdUg6KBge/yH/xVHzhlMOjGxPJj8j07xdBQ=; b=CyzNG9N6t7rJZ6fuMlPBEMd68VhDyZ+7Oq2LmvGsAoE2W35trkCEOwNZGYWD4TyCL7 babTlEqL7J+SPmKOA0zWvu+RPaSL6+7/MWxws4QvgEeomaLxrsmZmB+3beM3OGtAAXaL LmgB5/yskG8vWaf7uTjnYvjO8QBob70n26lVOSoDuWcgjSuvfhr3D0BEsfBmZW05vC5w UfZyrUZWK3pmqXPkd7BWEGHS0cjnaHXwsLPlJcGkoQd17kCOixeohua4aR02IWXLPWA4 4x30DjXWEQgoUMatAjQTIq+RTYsGdS/0b26l/JkvcK+g2fDf1KpBj4Pc4entUnlO1L+Y cJww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hxtvZim2; 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 gc4-20020a1709072b0400b00878561c0885si408503ejc.450.2023.01.25.12.46.25; Wed, 25 Jan 2023 12:47:18 -0800 (PST) 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=hxtvZim2; 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 S236548AbjAYUp5 (ORCPT + 99 others); Wed, 25 Jan 2023 15:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236135AbjAYUpw (ORCPT ); Wed, 25 Jan 2023 15:45:52 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1D83C1B for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id m8so16771ili.7 for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) 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=xOIF99BwsdUg6KBge/yH/xVHzhlMOjGxPJj8j07xdBQ=; b=hxtvZim2wjo5p0oljRrnhU09J/FXl/q3kMFv0xI8VeVBra8h2ZKrR2LsZ8KJPtusTo +1ZcRlQkP5swxG+FSy8ovUgfE5gGZzSTT3Ugf1DjHXTkpXigrHn841Jyw1/acZSTuM/x aUC0w9yr4OC23P+ZZBmZOpllNplBV90+WqFDE/6yWPmj+G/tvsqeI+/Hc50U8JRJ57aM P/tOvpVcvZ6wV4eSHp3CXT2lPh592SdHNza2386wrU2+HGZabj7v8nHsG7MFEgfNX7Rn 2WfvRMKlj0/sfmGg4T5JVwlRDrm+Bcu/q5bYr1ACoJbrGIX2oOLbrCeC91ob2RiqZkRH rQvw== 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=xOIF99BwsdUg6KBge/yH/xVHzhlMOjGxPJj8j07xdBQ=; b=SWTH5n1H3rgnFlcW3fFOPZgz6lNRxpICkDJ4ZIxda/2sGdC5t74I2GuQRww8x4yFNu 1/5IhnxJMLl5qLMW4dOwkGRgolXcwmpDFpgH+cQ6rDl3SbgxDz266JzAcfgohBAl5AYK jNQOyiitWdQdhBtPOFxpSlZYdWa9tjUphMN3ZsE6WVGKfYOAvICkQWL+Jv9zlNr2d1xJ AB/45v2qTNqxMFqoG16oT9FrM8BCsfr9oDBJwQjsP98wjnPuJ7OGecBITxcShI527LIH 1CWiC71MbV3BdoyCuxEdDcxegj3C4DFLmhnxMclZknOzK0Zr5rWet7DxbeMcl0/PAhv/ yPiA== X-Gm-Message-State: AO0yUKVicKviisMpdvwo5zfqCaWEtxAWiCpn8xcOPeXZiXh23LhOlUZ5 CVbjcbuDyUIL+2K7w1x/NVTJcw== X-Received: by 2002:a05:6e02:19ce:b0:310:a8c9:e0bd with SMTP id r14-20020a056e0219ce00b00310a8c9e0bdmr2162564ill.26.1674679550440; Wed, 25 Jan 2023 12:45:50 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:50 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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/8] net: ipa: refactor status buffer parsing Date: Wed, 25 Jan 2023 14:45:38 -0600 Message-Id: <20230125204545.3788155-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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=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?1756028877043165033?= X-GMAIL-MSGID: =?utf-8?q?1756028877043165033?= The packet length encoded in an IPA packet status buffer is computed more than once in ipa_endpoint_status_parse(). It is also checked again in ipa_endpoint_status_skip(), which that function calls. Compute the length once, and use that computed value later rather than recomputing it. Check for it being zero in the parse function rather than in ipa_endpoint_status_skip(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 136932464261c..3756ce5f3f310 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1325,8 +1325,7 @@ static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, if (!ipa_status_format_packet(status->opcode)) return true; - if (!status->pkt_len) - return true; + endpoint_id = u8_get_bits(status->endp_dst_idx, IPA_STATUS_DST_IDX_FMASK); if (endpoint_id != endpoint->endpoint_id) @@ -1394,6 +1393,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, while (resid) { const struct ipa_status *status = data; + u32 length; u32 align; u32 len; @@ -1405,7 +1405,8 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, } /* Skip over status packets that lack packet data */ - if (ipa_endpoint_status_skip(endpoint, status)) { + length = le16_to_cpu(status->pkt_len); + if (!length || ipa_endpoint_status_skip(endpoint, status)) { data += sizeof(*status); resid -= sizeof(*status); continue; @@ -1418,19 +1419,16 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, * computed checksum information will be appended. */ align = endpoint->config.rx.pad_align ? : 1; - len = le16_to_cpu(status->pkt_len); - len = sizeof(*status) + ALIGN(len, align); + len = sizeof(*status) + ALIGN(length, align); if (endpoint->config.checksum) len += sizeof(struct rmnet_map_dl_csum_trailer); if (!ipa_endpoint_status_drop(endpoint, status)) { void *data2; u32 extra; - u32 len2; /* Client receives only packet data (no status) */ data2 = data + sizeof(*status); - len2 = le16_to_cpu(status->pkt_len); /* Have the true size reflect the extra unused space in * the original receive buffer. Distribute the "cost" @@ -1438,7 +1436,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, * buffer. */ extra = DIV_ROUND_CLOSEST(unused * len, total_len); - ipa_endpoint_skb_copy(endpoint, data2, len2, extra); + ipa_endpoint_skb_copy(endpoint, data2, length, extra); } /* Consume status and the full packet it describes */ From patchwork Wed Jan 25 20:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp477953wrn; Wed, 25 Jan 2023 12:47:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXue5TQVZx8S5fozA2FTiSnMOJZ9Tm/pOZvU7Bar4fem3llsEgdDV8/1Aj0zm+CG9K4BvZ/A X-Received: by 2002:a17:906:762a:b0:7c0:be5d:59a9 with SMTP id c10-20020a170906762a00b007c0be5d59a9mr43589798ejn.20.1674679640271; Wed, 25 Jan 2023 12:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679640; cv=none; d=google.com; s=arc-20160816; b=Ier95lPzgygjeEapxJ5ZU5GWlPRp2zBYwB9epVe0bWAl3TvYWW4qyLvwJATZx3tnrj u/+aJ1ikvKQtyCo5ClG4Y1Eq3MGI6BNJ4x7j1LNsxQ0GZryMeVtGSpAiiJ7TTJSyhmSa GCcUIJViaZxqTORVVYeANybibX8UqUUgxhUV/NYH0553hk4R66pesBIPX2ixQD6QgTSs J4YnsB0f2ZzcQQtsmf/CX0vqf+ha42E/FP588W+Rag+IUDN/j/BzWrPtPAyCXbWNgsgE DaeZwnxZ7M+e7vJlZ/Z16no1LSfexc+uvTSwFPE4htooSrTq8jIe9nRFxJtazJ+nLvuz en+g== 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=g9R16wmdsFSlARpIkw628eYGQEzi5HtCrjZCjEhr1Wc=; b=n30VRAgj67/hBZ/tsf9JZKsGb07acq2dxh3qagInTyxJUXlGD4Ofa+JCOutJWDtFm2 9nyjrixScilCYpl0WqCvhLtZMP/xtaoLcDq7KugQ0seoGRfLk3/7XpYNCUC+LeBtR8no pY56+vxaLcxTJncwJVS6Pr32dW33/wNCfFWk0uqDgma7MFFegoE3P5wZX2nyUOVhVARm 0vZBx7LdRSLzheSpDXELW4OJIa18FrRPoNgpxkVHzIW6mVDH+NKnjXAQAJ6k3T3TQio8 0CyspQ+HQSeSixMl+HRXZtxXM9XlJZpT7C13xqLLparYEFwd4aTlRq3NBvNPmnVC5acC quaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QM7n20Ib; 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 e12-20020a170906748c00b008736461efe7si8253356ejl.643.2023.01.25.12.46.33; Wed, 25 Jan 2023 12:47:20 -0800 (PST) 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=QM7n20Ib; 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 S236516AbjAYUqA (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236471AbjAYUpw (ORCPT ); Wed, 25 Jan 2023 15:45:52 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9D94126EF for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id p12so9998ilq.10 for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) 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=g9R16wmdsFSlARpIkw628eYGQEzi5HtCrjZCjEhr1Wc=; b=QM7n20Ibckf+f+Vc+/CdeIjOQ+T1RMhNd67UeASRLILDWRJ2vZBlJWqhxN28dMTUDi 3CbYo20udJjfxR+Uhtk96FVqnb6UPt90X2R6GQhThkyghuTYLZ29BdSAx6H9Sy2q7Lwh E/t3E0FNJ+olmtndhbIJZ8BimzIdQ67wAByLZj1DblQILaggcX+vonHbSY/jHhod6HQo +4tjZ0W8OQmJDANnd0ML08Vl8DLl6LR0bD9afrCMmYuVVfF99iiE2TFMG/7e0sWmOb+k Azd42vcc/O/Z5EzZUopnqG9vYUlO0tWJS0o5CPqTQwZpj1O4m1VXrFVJm4UmdM251P06 2Tjg== 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=g9R16wmdsFSlARpIkw628eYGQEzi5HtCrjZCjEhr1Wc=; b=a8ON50WH3787Q4dGrNKRbws7ggT8LHEDVH8W+lGuwKIY3n/hkxJKKT52y8WvI9i9ey wMwyQH6Wy3J2hq+Sh9PtTlool1YfFeYsGlj9T4mbzt+HXB7uNmSROAmlV2QpH9P+2m7C jF0BOlEmo1yAGjmknA02ghnzXptStoO3wMuFkSSVroNxQRqaSa324QKemXh75mM6a26e W1W5kNWHT7Lg9sRrNwOKEjV5S2rmyXCwNrmzTZgiscyrAu2YbaeG+Cg/TKtBF1eLM5VE t920jw5FWTrK7aFylk7Q292jkAi5uqINurO9pYMLFXpsZDKo0qu/rs4NzCYdgWfa3DN7 w6jA== X-Gm-Message-State: AO0yUKWw3Lw3SdioFBis05DuJmmB6KfUXQsK23TZ7ufkyqxxvZrrgbHS F/uKaGzilGaLkBX/sWQv55WAhA== X-Received: by 2002:a05:6e02:1d06:b0:310:7c6c:8660 with SMTP id i6-20020a056e021d0600b003107c6c8660mr7037503ila.4.1674679551501; Wed, 25 Jan 2023 12:45:51 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:51 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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/8] net: ipa: stop using sizeof(status) Date: Wed, 25 Jan 2023 14:45:39 -0600 Message-Id: <20230125204545.3788155-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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?1756028878445700797?= X-GMAIL-MSGID: =?utf-8?q?1756028878445700797?= The IPA packet status structure changes in IPA v5.0 in ways that are difficult to represent cleanly. As a small step toward redefining it as a parsed block of data, use a constant to define its size, rather than the size of the IPA status structure type. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 3756ce5f3f310..dd4b2b073aae9 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -70,6 +70,9 @@ struct ipa_status { #define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22) #define IPA_STATUS_FLAGS2_TAG_FMASK GENMASK_ULL(63, 16) +/* Size in bytes of an IPA packet status structure */ +#define IPA_STATUS_SIZE sizeof(__le32[4]) + /* Compute the aggregation size value to use for a given buffer size */ static u32 ipa_aggr_size_kb(u32 rx_buffer_size, bool aggr_hard_limit) { @@ -1397,18 +1400,18 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, u32 align; u32 len; - if (resid < sizeof(*status)) { + if (resid < IPA_STATUS_SIZE) { dev_err(&endpoint->ipa->pdev->dev, "short message (%u bytes < %zu byte status)\n", - resid, sizeof(*status)); + resid, IPA_STATUS_SIZE); break; } /* Skip over status packets that lack packet data */ length = le16_to_cpu(status->pkt_len); if (!length || ipa_endpoint_status_skip(endpoint, status)) { - data += sizeof(*status); - resid -= sizeof(*status); + data += IPA_STATUS_SIZE; + resid -= IPA_STATUS_SIZE; continue; } @@ -1419,7 +1422,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, * computed checksum information will be appended. */ align = endpoint->config.rx.pad_align ? : 1; - len = sizeof(*status) + ALIGN(length, align); + len = IPA_STATUS_SIZE + ALIGN(length, align); if (endpoint->config.checksum) len += sizeof(struct rmnet_map_dl_csum_trailer); @@ -1428,7 +1431,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, u32 extra; /* Client receives only packet data (no status) */ - data2 = data + sizeof(*status); + data2 = data + IPA_STATUS_SIZE; /* Have the true size reflect the extra unused space in * the original receive buffer. Distribute the "cost" From patchwork Wed Jan 25 20:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478356wrn; Wed, 25 Jan 2023 12:48:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSYINUaO3EZ1xQvAbx+hW82360HmPk6ZvIPeModZaHPRLvLC+0FgEajBvQp5S3x2OY2iQc X-Received: by 2002:a17:906:2c45:b0:84d:4b8f:b34c with SMTP id f5-20020a1709062c4500b0084d4b8fb34cmr35527694ejh.66.1674679720879; Wed, 25 Jan 2023 12:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679720; cv=none; d=google.com; s=arc-20160816; b=jTbSmKV/++nInTxJRu4VU2JJqZ3SziYfklCH1W1RXCimickrMg286HA/TJ2XHbkCaE MVbmD8EC5qXd8RZHRVL0d3pOVSfCQ3LrTVHTMqFZEiwQt31jVSdCwE3EVROspYaOKs0k kLCN6aC28DukZXK/4hgV6N0y8zDnoWQeXRgOsGfYuNIcS3qgdJMhd1QasJU/Ee9Wfb3r oh1IKQhc5CZRtrJeqeI+fmu7d80kObxoZVupDXq+4Kd8xqMG3l7O4d+Ot7IwsGdHD6TB JTnFBNq3+zVTAtiCOVNgBHucS4sHEZ8QrTXcdZ+dPy7GZiFgL/9LXdeJJH0ufKNwhqxB er/w== 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=RjjPa5eXz2MKX1ckJw/qBJ/DxwniIRJxEckC8kdtjaw=; b=HpFCjJnS9JrpGZ8ZF5ekPQ6Ii95AixDl1PvyhvY/Ci62dO6JnPMe9KaMIie6gyPOxl /91CH16hiE5w+SwexRbRJbgah2QQKSyiVJKDoB4mqwrdD2KidH51QHLPr1YRywsEHaoJ OWNllUCpk8XtLhKAOBadLYyYVZul38HXUtcr08kyDYbpE4M9Pd+oV4AGZCCtWqM2sWPK ov+q3nU0tODmT5W+/rjqwlUbp5N7bnKes+Zo74mS6JKEWFKt5ONJHPMZht9wex1rV4Rs y5V/XrxRRLyqNOvwqYBOsommIfasxpNbCUoNxKzU1ARewjCEuXTSIK4T5gWKCtdFfjtG l7lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4IFVqmH; 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 wc12-20020a170907124c00b007ba713e241dsi7072101ejb.894.2023.01.25.12.48.17; Wed, 25 Jan 2023 12:48:40 -0800 (PST) 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=Q4IFVqmH; 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 S236587AbjAYUqE (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236509AbjAYUpy (ORCPT ); Wed, 25 Jan 2023 15:45:54 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F13C527E for ; Wed, 25 Jan 2023 12:45:53 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id b15so8231ils.11 for ; Wed, 25 Jan 2023 12:45:53 -0800 (PST) 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=RjjPa5eXz2MKX1ckJw/qBJ/DxwniIRJxEckC8kdtjaw=; b=Q4IFVqmH0X1HduLYAg4tXY0n8p80rTfmieraR4ARmeEp93dT1VZIYMwlx7O3gE4Z54 v+dOguu1HJLsb2lr+0ptPwUoMKII7+OOSEWRWsqc+E7IKEv0GeZaTvBDI/1b+PLy2OsU Q6yrvmQBbCpwCXlAJ8+GwiBLJURSI1pE3nNBY+k8j81/5Vr9csvqLFMA9aoSJDiqrafW R3NfyoiAdz6rkEb+yJBbTuagKzcHh+FJo88qrDst5g4vkFtsXUR3bL+RNXaLiBDLQuWR /D0TSe1okjwNNWfpJEnspOyYTuIb5jyBLYEUrXhqD1MWOfE6cqo2wQPlRxyPzDzzUOdm YMTQ== 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=RjjPa5eXz2MKX1ckJw/qBJ/DxwniIRJxEckC8kdtjaw=; b=cAq9u1KlsPN0wjSjNua3QO2CxTi3G6aEfw3O5scD6+Ffamsk5Me2kfi+hbgD/Wn9Gk N7TV6rMuGhzfiNnLhyDIYUu6y3+Guyr1KXHq+tWGq0aJvFv2uZwctPvOuzCyIw+U6ion SBfcL0+5XXUHsClge5HFxqRqCd3/lW2kPq9iANWvDmn4uK3gf56rrfjIfc/3L7FrBhQa 7ke2sdq1VkURDQlGKXGOo+KgcQvPtIavnkMN4dsPPUCDNciCU3VssyRZZpafqmiqtBC7 XQo55VmNdir9vhf6OfGkC5DshJ3czseFDroOmc1b2CkkzcGUqARHnn6dR5uLwVovFyTW 2Ysg== X-Gm-Message-State: AO0yUKUbOcORNg15wpiv7TaDVqAV4dtwrjcCm/UwvBvvwBpDSlW5AhEj 5ftyvGRUYU7QJCzxLUisFQPTJw== X-Received: by 2002:a05:6e02:1c02:b0:310:a195:5cb with SMTP id l2-20020a056e021c0200b00310a19505cbmr2873468ilh.17.1674679552653; Wed, 25 Jan 2023 12:45:52 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:52 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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/8] net: ipa: define all IPA status mask bits Date: Wed, 25 Jan 2023 14:45:40 -0600 Message-Id: <20230125204545.3788155-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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?1756028962729911519?= X-GMAIL-MSGID: =?utf-8?q?1756028962729911519?= There is a 16 bit status mask defined in the IPA packet status structure, of which only one (TAG_VALID) is currently used. Define all other IPA status mask values in an enumerated type whose numeric values are bit mask values (in CPU byte order) in the status mask. Use the TAG_VALID value from that type rather than defining a separate field mask. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index dd4b2b073aae9..5cf3ac2b5c85a 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -48,11 +48,31 @@ enum ipa_status_exception { IPA_STATUS_EXCEPTION_DEAGGR = 0x01, }; +/** enum ipa_status_mask - IPA status mask field bitmask hardware values */ +enum ipa_status_mask { + IPA_STATUS_MASK_FRAG_PROCESS = BIT(0), + IPA_STATUS_MASK_FILT_PROCESS = BIT(1), + IPA_STATUS_MASK_NAT_PROCESS = BIT(2), + IPA_STATUS_MASK_ROUTE_PROCESS = BIT(3), + IPA_STATUS_MASK_TAG_VALID = BIT(4), + IPA_STATUS_MASK_FRAGMENT = BIT(5), + IPA_STATUS_MASK_FIRST_FRAGMENT = BIT(6), + IPA_STATUS_MASK_V4 = BIT(7), + IPA_STATUS_MASK_CKSUM_PROCESS = BIT(8), + IPA_STATUS_MASK_AGGR_PROCESS = BIT(9), + IPA_STATUS_MASK_DEST_EOT = BIT(10), + IPA_STATUS_MASK_DEAGGR_PROCESS = BIT(11), + IPA_STATUS_MASK_DEAGG_FIRST = BIT(12), + IPA_STATUS_MASK_SRC_EOT = BIT(13), + IPA_STATUS_MASK_PREV_EOT = BIT(14), + IPA_STATUS_MASK_BYTE_LIMIT = BIT(15), +}; + /* Status element provided by hardware */ struct ipa_status { u8 opcode; /* enum ipa_status_opcode */ u8 exception; /* enum ipa_status_exception */ - __le16 mask; + __le16 mask; /* enum ipa_status_bit (bitmask) */ __le16 pkt_len; u8 endp_src_idx; u8 endp_dst_idx; @@ -64,7 +84,6 @@ struct ipa_status { }; /* Field masks for struct ipa_status structure fields */ -#define IPA_STATUS_MASK_TAG_VALID_FMASK GENMASK(4, 4) #define IPA_STATUS_SRC_IDX_FMASK GENMASK(4, 0) #define IPA_STATUS_DST_IDX_FMASK GENMASK(4, 0) #define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22) @@ -1344,7 +1363,7 @@ static bool ipa_endpoint_status_tag(struct ipa_endpoint *endpoint, struct ipa *ipa = endpoint->ipa; u32 endpoint_id; - if (!le16_get_bits(status->mask, IPA_STATUS_MASK_TAG_VALID_FMASK)) + if (!le16_get_bits(status->mask, IPA_STATUS_MASK_TAG_VALID)) return false; /* No valid tag */ /* The status contains a valid tag. We know the packet was sent to From patchwork Wed Jan 25 20:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478124wrn; Wed, 25 Jan 2023 12:47:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXskeajUgpIGIhSVdHkWwpQJ5TClmr64u2RU8SJcZqy8DTRAHH092uQefY8gLS9bfcpjYfRx X-Received: by 2002:a17:906:8298:b0:86d:be0:607d with SMTP id h24-20020a170906829800b0086d0be0607dmr36131967ejx.70.1674679673105; Wed, 25 Jan 2023 12:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679673; cv=none; d=google.com; s=arc-20160816; b=ER5VWaLq9YeX6u5My/i1IBHziHMpxVtX3zS0D2IAKppj0LTwJz5e0eeg3XFQ/wdDoh vTFXyzBdllpSJUSZl7swBD3tOK+tMdfTYKxaaxF3c+XhVQTfqiDbhAcLsnr0AEwwnFCZ Fw+rNSU4HYHg5poX/RnLN3oN6R2eCp3l2CjFo1vhGN2tPrKfGraWya30ZjVrMfvy5EBT U8lGxYR84Fm+6H8lYphjgXYTlq+z6MZ5Dor4OY82fesplcDbyBAHip5dpMwueKcLKM/g 8V2zh+lpVBsg6JHCKhqrpSDDHO7uUgFW/E+W1hMjC1RTZOTj5NH47n4ChJbkfBJLSHQx eglA== 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=iO/DlijeKlIU6w5Axu0X1q3Z8gOHm4UH5Qr0chFaDYE=; b=O/Fbp3nWbKJu94Jb545bZWy057adSwpKXqUQo667Yrnj/g7SySXSZXTiLxUOoZGkig /HNxl6ErqOuPMA4p6d7VnvKy9cLYZciAB6KGU2avqkoTezAZ5RAxp623MNtCM7B7JcEg Z7a2uKVdfJOpzSdxf+Z9lM28MGuS3kwdOs4obe26uF9MrgN7DcwgY8bao/QW7LxjSoTm PRIjcOUPnHSBDXCfr3TZIH1LwV4mbKwCQoMf1n++3XAFHnx2nqGK2jhA9xoSLs/i2HKK rMbxTbNlBhpxHIT/TdpDnEFxUtb3/AyFSswB08n++itede9C2+WN9o3xjdH7XlShXj/h bQ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xOIrFh2y; 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 gk5-20020a17090790c500b008650ce2977bsi6523743ejb.641.2023.01.25.12.47.28; Wed, 25 Jan 2023 12:47:53 -0800 (PST) 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=xOIrFh2y; 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 S236615AbjAYUqG (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236515AbjAYUpz (ORCPT ); Wed, 25 Jan 2023 15:45:55 -0500 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 A0C335D91F for ; Wed, 25 Jan 2023 12:45:54 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id q130so9020257iod.4 for ; Wed, 25 Jan 2023 12:45:54 -0800 (PST) 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=iO/DlijeKlIU6w5Axu0X1q3Z8gOHm4UH5Qr0chFaDYE=; b=xOIrFh2ybWVr5oX0yKbxF/vMXdmutKagcSVWcGSJEbIllZn/ol5s2OB7YhRaSUMCUL xrOCiVt6fb8d6xDh2/Ll4/hRPHqXV8Ed6Ii490FIE3+drwgs6CsFXXyI4V5cf5E/iY+4 ofOjR0/1o0jk5YFyXd1eICud0VRURtQAi6Yk8eyF3EM/mC39xJ8ME0tdPwir8N6lC/in uyMVlAknI+qgLP8v0ZBkEYmo7sKDz+yCceYPanhHPxHbxkWTligbNgDfS5+KeOlfpqwH tOfir8KkaZHp8uEXdIbb1nDN6lUk/DaPiz41Or+8aNHHiIDNdYOW9hg0QrZfhkNZksFD CB+w== 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=iO/DlijeKlIU6w5Axu0X1q3Z8gOHm4UH5Qr0chFaDYE=; b=inlHC1h/mWuMCHqgUZrqIQRARIqoXLrlUyaNFteD3Zoo+NDFithGVn1p7FIVFz/0w7 dxuGoHtYxkaE4A9wanqZmDvJ1wKTgFbtmYLoYojoz3kfpvpqM1kwfrPssd1vmExdF0mF 8+6nE0nf1P34BfAKKVXUtLFjH7tzcXCFBRN+pKAyL/eMULDFFqmCSRzk7YvByfUqXAFt xreOwHU4dySGdkmCDO4V3ttPRW+eosAZH+Q27vabcUG4mYIG/qMPs2e/b4hYUNDbqMJQ qXhyWy3dBXvbmpaeLOync7uYMvFGAEspU+O6RsbQcZg0ifLetGEZkWnsCf1Kf4Qs8PQ5 XsUw== X-Gm-Message-State: AFqh2kpKJ7bIGr9rE7KVOhKSYSlEPqS5MRHDDPYDPNOjJER2AKVCGrh8 3//nXnwTX49z6SVpERqRCbQuZg== X-Received: by 2002:a05:6602:2588:b0:707:82c8:d45e with SMTP id p8-20020a056602258800b0070782c8d45emr15343876ioo.4.1674679553772; Wed, 25 Jan 2023 12:45:53 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:53 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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/8] net: ipa: rename the NAT enumerated type Date: Wed, 25 Jan 2023 14:45:41 -0600 Message-Id: <20230125204545.3788155-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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=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?1756028912833717070?= X-GMAIL-MSGID: =?utf-8?q?1756028912833717070?= Rename the ipa_nat_en enumerated type to be ipa_nat_type, and rename its symbols accordingly. Add a comment indicating those values are also used in the IPA status nat_type field. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 4 +++- drivers/net/ipa/ipa_reg.h | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 5cf3ac2b5c85a..178934f131be5 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -68,6 +68,8 @@ enum ipa_status_mask { IPA_STATUS_MASK_BYTE_LIMIT = BIT(15), }; +/** The IPA status nat_type field uses enum ipa_nat_type hardware values */ + /* Status element provided by hardware */ struct ipa_status { u8 opcode; /* enum ipa_status_opcode */ @@ -570,7 +572,7 @@ static void ipa_endpoint_init_nat(struct ipa_endpoint *endpoint) return; reg = ipa_reg(ipa, ENDP_INIT_NAT); - val = ipa_reg_encode(reg, NAT_EN, IPA_NAT_BYPASS); + val = ipa_reg_encode(reg, NAT_EN, IPA_NAT_TYPE_BYPASS); iowrite32(val, ipa->reg_virt + ipa_reg_n_offset(reg, endpoint_id)); } diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index ff64b19a4df8b..b1a3c2c7e1674 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -382,11 +382,11 @@ enum ipa_reg_endp_init_nat_field_id { NAT_EN, }; -/** enum ipa_nat_en - ENDP_INIT_NAT register NAT_EN field value */ -enum ipa_nat_en { - IPA_NAT_BYPASS = 0x0, - IPA_NAT_SRC = 0x1, - IPA_NAT_DST = 0x2, +/** enum ipa_nat_type - ENDP_INIT_NAT register NAT_EN field value */ +enum ipa_nat_type { + IPA_NAT_TYPE_BYPASS = 0, + IPA_NAT_TYPE_SRC = 1, + IPA_NAT_TYPE_DST = 2, }; /* ENDP_INIT_HDR register */ From patchwork Wed Jan 25 20:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478714wrn; Wed, 25 Jan 2023 12:49:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGH43TAAAtVbST3hQFZo1wMyjkul0RY6prf7KkPkjtErYm/VDuzmM3LuKYgRBauf9h6QZU X-Received: by 2002:a05:6402:524f:b0:491:3a5c:6e5 with SMTP id t15-20020a056402524f00b004913a5c06e5mr48096526edd.1.1674679782832; Wed, 25 Jan 2023 12:49:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679782; cv=none; d=google.com; s=arc-20160816; b=aXmQHyTDJUhGSxdGLfdLxoXEFTFtHhsDg4jwrNy2w8JUPsImrBj2NLXAn66Z8VvRiG vc2io1RXnuOVsQ9ApkJ4kXmefdkUeYvEBZKwZK9UFV+Th/TpELlgW8pYQ4BicFin1d03 CJcYvcRVpNkTY7ZCm7McSMUtfdQvKShhS8lvtvW8KfHBVE2noQ0BmCD8SffZ4wLJ/kJY VDOHRvcVOIMXfgNqz+WVHH9yn4QZMNLy8ViewmX/+rbjit3ZngDex/4590RGZeNL2Pfa 4sT1GAydLuB2c4bs+00btJ0mFR3J9mtKbtkuos74miAcR/M3T3+XuGX6UkqOrerqVy5s Zqdw== 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=dwc/7+BF+Bdkf3+X8cSWATZteUuUtFlSqW/LGNAknug=; b=rLhXbkvYpsu7uIlCEPNt35ixFHRRAASV9D2sdv4JtQEfTXXPu1I1sEhWodRZFlWNUR MjDyDqS6CU3h8Fbneh2qfCitfrPuyEEqH3G4hhVwtVTOIhT+pK27ahu4EEHURoIVd8Z4 IB7CNI2tz2buhnvNm2sb4aXNLYNSe2ziecTT1HyxIA2JGnwes1pGSn2WzdjnWqzvv+F2 vuPrKutHidi2730+LMo7eFnnOOcthT2eDKfKduwwuJqnj5YyJD+xj4iURXKKXUVUSnB4 bg79udYilIwYRMGyLyZw2oRY3i0cClshAFV9LgkUB4NR8tBwNb+EwxAOewenpsIrBBWY 55QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zmT4HI/O"; 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 l22-20020aa7c316000000b004676034f552si7913142edq.45.2023.01.25.12.49.03; Wed, 25 Jan 2023 12:49:42 -0800 (PST) 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="zmT4HI/O"; 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 S236622AbjAYUqJ (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236534AbjAYUp5 (ORCPT ); Wed, 25 Jan 2023 15:45:57 -0500 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 910C45DC25 for ; Wed, 25 Jan 2023 12:45:55 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id h184so8999839iof.9 for ; Wed, 25 Jan 2023 12:45:55 -0800 (PST) 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=dwc/7+BF+Bdkf3+X8cSWATZteUuUtFlSqW/LGNAknug=; b=zmT4HI/OTixN9d27Nn8lmhh7KPUqTTBNaEdY6WgMJMogIG3+jETUBr3vYYc52FG5Pe zpa4B8JcHJjMe7FIHf62bOb8PAHQhCp6fOREdPaVfKuTOPlx0Hn+ATwGmrti6xh11t0g qHpboZBHWtC1YmgDU7mtWjVeACOB4RZ4WXlouYPwRFs1s3QJjeHciHMgZmBOtck38Gd9 ukHaHy2tIvkhjIGkJ91rgXyPtmJZJ6S7O3wGhVe0aZ/rGwzAmz5xAXoDEI5tqhM71A/u q+Dgbxw/SUezTOGSWjdlC+6OwQTfIL9JvJ1u2tnBLGmxJkelchEU612+V68E7dJz5VwW fKgQ== 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=dwc/7+BF+Bdkf3+X8cSWATZteUuUtFlSqW/LGNAknug=; b=mMwHPS1pOtjBCkBeyVlzbQNyUhaFnoGvOcT/ZtFmK8oILlSHOjucBHZXcWjPCGzDU3 0U6uepHdhtXbDGO1RQkcCwrMJyYxWpQGb5emjNJGR5lRJIGWU+xvuwOgvdHGXRuZRgXS lAY6VCWYPKk2tDXdM0DM+Zj8gT6AgPakoT22nuWSLO6vZr9/wc4kpGOjzqv1PcQ5hm/w IYTGt7LS7tpXi5311nCXD4mH/LHHPQoOtASCQ1DvXDYa8J/j57CUZMsNn+xzqHjqtviq zlIZB1vqyh6eRXK3bsxWtdiU1Ik5K3iLff0iaYRSEgJ8pcXtJyU8h4SJL7mlMP+ACR1Y Jkbw== X-Gm-Message-State: AFqh2krXNjDRolzctSbQ8UdxUHZ4n382ieT1oE9N2MJK1PjSTiHKxDHk 3asb4aumijUPRs0BuIBDlkSEwQ== X-Received: by 2002:a6b:6019:0:b0:704:cd00:ae4e with SMTP id r25-20020a6b6019000000b00704cd00ae4emr25777719iog.0.1674679554876; Wed, 25 Jan 2023 12:45:54 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:54 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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 5/8] net: ipa: define remaining IPA status field values Date: Wed, 25 Jan 2023 14:45:42 -0600 Message-Id: <20230125204545.3788155-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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?1756029027997522718?= X-GMAIL-MSGID: =?utf-8?q?1756029027997522718?= Define the remaining values for opcode and exception fields in the IPA packet status structure. Most of these values are powers-of-2, suggesting they are meant to be used as bitmasks, but that is not the case. Add comments to be clear about this, and express the values in decimal format. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 178934f131be5..ee3c29b1efea9 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -34,18 +34,31 @@ #define IPA_ENDPOINT_RESET_AGGR_RETRY_MAX 3 -/** enum ipa_status_opcode - status element opcode hardware values */ -enum ipa_status_opcode { - IPA_STATUS_OPCODE_PACKET = 0x01, - IPA_STATUS_OPCODE_DROPPED_PACKET = 0x04, - IPA_STATUS_OPCODE_SUSPENDED_PACKET = 0x08, - IPA_STATUS_OPCODE_PACKET_2ND_PASS = 0x40, +/** enum ipa_status_opcode - IPA status opcode field hardware values */ +enum ipa_status_opcode { /* *Not* a bitmask */ + IPA_STATUS_OPCODE_PACKET = 1, + IPA_STATUS_OPCODE_NEW_RULE_PACKET = 2, + IPA_STATUS_OPCODE_DROPPED_PACKET = 4, + IPA_STATUS_OPCODE_SUSPENDED_PACKET = 8, + IPA_STATUS_OPCODE_LOG = 16, + IPA_STATUS_OPCODE_DCMP = 32, + IPA_STATUS_OPCODE_PACKET_2ND_PASS = 64, }; -/** enum ipa_status_exception - status element exception type */ -enum ipa_status_exception { +/** enum ipa_status_exception - IPA status exception field hardware values */ +enum ipa_status_exception { /* *Not* a bitmask */ /* 0 means no exception */ - IPA_STATUS_EXCEPTION_DEAGGR = 0x01, + IPA_STATUS_EXCEPTION_DEAGGR = 1, + IPA_STATUS_EXCEPTION_IPTYPE = 4, + IPA_STATUS_EXCEPTION_PACKET_LENGTH = 8, + IPA_STATUS_EXCEPTION_FRAG_RULE_MISS = 16, + IPA_STATUS_EXCEPTION_SW_FILTER = 32, + IPA_STATUS_EXCEPTION_NAT = 64, /* IPv4 */ + IPA_STATUS_EXCEPTION_IPV6_CONN_TRACK = 64, /* IPv6 */ + IPA_STATUS_EXCEPTION_UC = 128, + IPA_STATUS_EXCEPTION_INVALID_ENDPOINT = 129, + IPA_STATUS_EXCEPTION_HEADER_INSERT = 136, + IPA_STATUS_EXCEPTION_CHEKCSUM = 229, }; /** enum ipa_status_mask - IPA status mask field bitmask hardware values */ From patchwork Wed Jan 25 20:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478715wrn; Wed, 25 Jan 2023 12:49:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXukehzN3xbjUuFeEM1CLVIyCeMXOZh75mZWyGmMDrLhqkqVJhCC990rf54yQRvgBNdcSYUN X-Received: by 2002:a17:906:3518:b0:7c1:962e:cf23 with SMTP id r24-20020a170906351800b007c1962ecf23mr32878603eja.37.1674679782928; Wed, 25 Jan 2023 12:49:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679782; cv=none; d=google.com; s=arc-20160816; b=q23v78VmS2DDLWS1/4261feQZ2osi3n+bBR1J6u8/izyDlWFlV3mPxcp43Zzhk7WPs KdyXvgVfdEUEKTbe4KivQC17C+4IJM07rpZVexZauBP9X7WY68JGIpclwvmCpBzZup3u PTC8H3C131Zr2TI2J4L5orheftzkgSE0zp6l3QiAi+639Efa42d5YqPzp8uTZChYyXUi nkuBHX4O0qhmPEZHlam7AyE5kf/ydd64d8Nogap8RsHpf0p/B27lhkE2QeLdpEl4nCf9 glgWViQ6ySDFk4HZjMiGfUB+pS5+z3RPPsBYqyPXbgC7t0da5TbP5qQDcnpYfgKDPEk9 kzXA== 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=C2aF4dRRxXYWgXxbaJpBxk8mqsz625P0c71KwZ9Suks=; b=cibVljvDBWsa6iUEXqwO0jPscnnoJUxwkn+aeVpBRiEpMi6xbaAd9IdLv0mZQlA9mf zhNvkR6+aQrOUoaYBygZW9+qlVhjLR1rOxtX9mbbGBdd/22Jv3Q+PuBzRy9chaOiRNDQ GK+0tvSJozszw45in58msfVpNGR302I1tvdu3VnPCAByQsAyIDeHucuAZAUPT5omr5P+ 7vJXsqyNU9GQ8HjNtpLOitjpmK3KIDrspmYj6TW1D6q9fJO3R0yFZPHXHBTkGGigla0u G0850KrKFdKOtw4zjTwirid2q5IXoTFtxqIGhhxU5QQGbawRI0bb3m0GaSL7huE+BQQD ppdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aAw5L9Ry; 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 uo28-20020a170907cc1c00b0087859b6c546si202350ejc.634.2023.01.25.12.49.13; Wed, 25 Jan 2023 12:49:42 -0800 (PST) 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=aAw5L9Ry; 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 S236641AbjAYUq0 (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236589AbjAYUqE (ORCPT ); Wed, 25 Jan 2023 15:46:04 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68AD65DC39 for ; Wed, 25 Jan 2023 12:45:56 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id p12so10067ilq.10 for ; Wed, 25 Jan 2023 12:45:56 -0800 (PST) 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=C2aF4dRRxXYWgXxbaJpBxk8mqsz625P0c71KwZ9Suks=; b=aAw5L9RyrOP8c+CWms4LOllqpd14csq3QWj37+enc7FPuxwgZAk6M+WW8EOGT7bEFS 14a9Y/8zKWkGuAHcQuoPMozbKHolxqU5BHvMVWe7BgdW2+HxZi5P+GpKqa2kbSos1jlf vKvFYSRP1Ebqq0h2VM+aZXROo3rgiRlGxhISiPW4gZIDHlOypX3AkGd0LjGv4IZ0db6c viDsY+FrT99rTMtv6d7Z483CZChE1S9fb2OICmSSa/WaPQMhwEBJ6dN6tSDKdQyo2LbP tq4RuCXhH7KBze1Cc6XE8gIJHciau060X/BBAsU7eu+B8SqrNqyUc4pUdnZMw2YQG0jm aMtg== 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=C2aF4dRRxXYWgXxbaJpBxk8mqsz625P0c71KwZ9Suks=; b=FjvQ/OaECMlWSkYpzCh+fTfbu7fPB0gsiRaLQLCW5JB0rIBHq1vthOXc+a41slmTcu EUxWsz7HUjywYrRfye3C5ypHbWSRZ5mh3ywyuJXgRwjDnbmtbxY35Tz7jImlL78fhS0K d+C9veZxXCGt46ppQIMvVHGTVSyCD7nozUy/ej3359gOTz83ymZJYKO3D/5uleriXsVa GZqXAq35bTGww4s/DI7fJyiFdd9l1lqLUNXwnYgh4zuKx0eKcwp/+D8O83ZmGCNrsix+ 63yXWHSjX4f8LfbigpSPNmbrXYr1EfDtVKQIPemr3D66Q4omQRrtz+aXzXjVeEG6FuCf 3leA== X-Gm-Message-State: AO0yUKWpt7EJYU6zz143peqVHw4jVEilsyfiO+4pFrqir2or0u2MXpP5 lzpjtZa2fsUaMCfSjtBw6XeIsg== X-Received: by 2002:a05:6e02:1c06:b0:310:a923:772e with SMTP id l6-20020a056e021c0600b00310a923772emr2091606ilh.21.1674679555972; Wed, 25 Jan 2023 12:45:55 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:55 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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 6/8] net: ipa: IPA status preparatory cleanups Date: Wed, 25 Jan 2023 14:45:43 -0600 Message-Id: <20230125204545.3788155-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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=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?1756029028355654054?= X-GMAIL-MSGID: =?utf-8?q?1756029028355654054?= The next patch reworks how the IPA packet status structure is interpreted. This patch does some preparatory work, to make it easier to see the effect of that change: - Change a few functions that access fields in a IPA packet status structure to store field values in local variables with names related to the field. - Pass a void pointer rather than an (equivalent) status pointer to two functions called by ipa_endpoint_status_parse(). - Use "rule" rather than "val" as the name of a variable that holds a routing rule ID. - Consistently use "IPA packet status" rather than "status element" when referring to this data structure. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index ee3c29b1efea9..5097eb1bbadb0 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1182,8 +1182,8 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint) val |= ipa_reg_encode(reg, STATUS_ENDP, status_endpoint_id); } - /* STATUS_LOCATION is 0, meaning status element precedes - * packet (not present for IPA v4.5+) + /* STATUS_LOCATION is 0, meaning IPA packet status + * precedes the packet (not present for IPA v4.5+) */ /* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v4.0+) */ } @@ -1339,8 +1339,8 @@ static bool ipa_endpoint_skb_build(struct ipa_endpoint *endpoint, return skb != NULL; } -/* The format of a packet status element is the same for several status - * types (opcodes). Other types aren't currently supported. + /* The format of an IPA packet status structure is the same for several + * status types (opcodes). Other types aren't currently supported. */ static bool ipa_status_format_packet(enum ipa_status_opcode opcode) { @@ -1358,9 +1358,11 @@ static bool ipa_status_format_packet(enum ipa_status_opcode opcode) static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, const struct ipa_status *status) { + enum ipa_status_opcode opcode; u32 endpoint_id; - if (!ipa_status_format_packet(status->opcode)) + opcode = status->opcode; + if (!ipa_status_format_packet(opcode)) return true; endpoint_id = u8_get_bits(status->endp_dst_idx, @@ -1371,14 +1373,16 @@ static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, return false; /* Don't skip this packet, process it */ } -static bool ipa_endpoint_status_tag(struct ipa_endpoint *endpoint, - const struct ipa_status *status) +static bool ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, + const struct ipa_status *status) { struct ipa_endpoint *command_endpoint; + enum ipa_status_mask status_mask; struct ipa *ipa = endpoint->ipa; u32 endpoint_id; - if (!le16_get_bits(status->mask, IPA_STATUS_MASK_TAG_VALID)) + status_mask = le16_get_bits(status->mask, IPA_STATUS_MASK_TAG_VALID); + if (!status_mask) return false; /* No valid tag */ /* The status contains a valid tag. We know the packet was sent to @@ -1404,20 +1408,23 @@ static bool ipa_endpoint_status_tag(struct ipa_endpoint *endpoint, static bool ipa_endpoint_status_drop(struct ipa_endpoint *endpoint, const struct ipa_status *status) { - u32 val; + enum ipa_status_exception exception; + u32 rule; /* If the status indicates a tagged transfer, we'll drop the packet */ - if (ipa_endpoint_status_tag(endpoint, status)) + if (ipa_endpoint_status_tag_valid(endpoint, status)) return true; /* Deaggregation exceptions we drop; all other types we consume */ - if (status->exception) - return status->exception == IPA_STATUS_EXCEPTION_DEAGGR; + exception = status->exception; + if (exception) + return exception == IPA_STATUS_EXCEPTION_DEAGGR; /* Drop the packet if it fails to match a routing rule; otherwise no */ - val = le32_get_bits(status->flags1, IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); + rule = le32_get_bits(status->flags1, + IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); - return val == field_max(IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); + return rule == field_max(IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); } static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, @@ -1443,15 +1450,15 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, /* Skip over status packets that lack packet data */ length = le16_to_cpu(status->pkt_len); - if (!length || ipa_endpoint_status_skip(endpoint, status)) { + if (!length || ipa_endpoint_status_skip(endpoint, data)) { data += IPA_STATUS_SIZE; resid -= IPA_STATUS_SIZE; continue; } /* Compute the amount of buffer space consumed by the packet, - * including the status element. If the hardware is configured - * to pad packet data to an aligned boundary, account for that. + * including the status. If the hardware is configured to + * pad packet data to an aligned boundary, account for that. * And if checksum offload is enabled a trailer containing * computed checksum information will be appended. */ @@ -1460,7 +1467,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, if (endpoint->config.checksum) len += sizeof(struct rmnet_map_dl_csum_trailer); - if (!ipa_endpoint_status_drop(endpoint, status)) { + if (!ipa_endpoint_status_drop(endpoint, data)) { void *data2; u32 extra; From patchwork Wed Jan 25 20:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478742wrn; Wed, 25 Jan 2023 12:49:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXuX4AsRuuKPNh5E6t8XMwGyI6C68HhmKxJ291pqWv5WiBPnJDZgykHnWp4jG2/7rsAY0cFV X-Received: by 2002:a17:907:d15:b0:862:e612:effe with SMTP id gn21-20020a1709070d1500b00862e612effemr50110295ejc.14.1674679786781; Wed, 25 Jan 2023 12:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679786; cv=none; d=google.com; s=arc-20160816; b=FiPQYKQ6IE4tDxpFKrpqRrT5qSITyJWWX3tnZDY+/+ri9IXJVJgIGFsoZd5CwQ9vcY 2PoX3vyFeS0JR3wpGaT69yWQ60yQi1wbqidbkcQrOpdAacdLQ+lrQcmO2eeHq/uc1dt8 fQVB9Pf5haRvNaSRrnZuA7b0AgmFeVm5pkZ4yUxBdwqS9GlJn9LcvYOgevHo/VaPNXq/ J3Vlf1uTWQlk/rY7VBFCAhnjsH60wpP0GYq9l9GrLbAq6YFxILo02jxTTG/d4H38jQbM q8VnaVOi+FjrixoeJGN4QObn7dOI+8wuHNNb3eWwRCyxWCkeEL/MbYnDfRCW4PrNyS6f l7HA== 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=cZyimMjWLBBkvjzcnu+BPtGS7EzWyaqySans44hxkOg=; b=n/dkZ40eEUj7hE0/zJQr88APIMnVj5wWxE4sYYz0gY7FOCxt4KGlqgt7tRslPKRPzX XJrDhutN4h2PHnTx47MuTRRg3B8qZXspUP3rUdeVogvEbdGe9uir3vtnSbSwof9d+hsz GQQewD0CGNl5WuRKFUduKy0vzZOdThzAopEXJv9Nsw42bqfBkrpJyGbAyqtpP62r4M8Y 0tWSmMO0rS/RXYxuYIQi8EqawywQei3LE/ySHoyXinMloMURFslH4UMJ1epvAWvUBZ4W JaSYr1P2XKSNl/nTocPQMVa4rq9qDWrRcnqzKbiFUU+PJigoBOoH4BvIVLtaPqCeloAo keYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FLgRhBeY; 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 fm19-20020a1709072ad300b0086eb408a888si7186071ejc.131.2023.01.25.12.49.21; Wed, 25 Jan 2023 12:49:46 -0800 (PST) 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=FLgRhBeY; 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 S236655AbjAYUqa (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236596AbjAYUqE (ORCPT ); Wed, 25 Jan 2023 15:46:04 -0500 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 96D364EC1 for ; Wed, 25 Jan 2023 12:45:57 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id q130so9020299iod.4 for ; Wed, 25 Jan 2023 12:45:57 -0800 (PST) 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=cZyimMjWLBBkvjzcnu+BPtGS7EzWyaqySans44hxkOg=; b=FLgRhBeYcoqGPMK6MXbu4YkNjJwnqzL27ahPn1lJ8jo7ERfRcexSP7PsXfB7Yqx3Rk +NWGE8AmJRGV51vjHJ8i2Ul/jhYwYhSSOx514+ymrL/fNKe9fbMvFys/zBa5fCmeo8j/ s8dy33mqtmGVAlbh3lX0XEPsW/fZJaMRjaTdACr62YR1bK/1jVLPalVYinSGVwAR0wA2 k86GJajTXcXPTvaW/K7wDZb6iot+rTct5FQFpG+vptrcW4WvS8BUoljGCgvz2ZKzsphy k9DFQDaomtxPPoNhKlVfm+ZMKYgujVZqklBC4MynuCkEITz5J6poZz9fnhCUW3O8hTMm FGvA== 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=cZyimMjWLBBkvjzcnu+BPtGS7EzWyaqySans44hxkOg=; b=caowKDTlIEcwDf49e+S7efLeEZ0GgYzxCkijud4YMXF3bofFFY+cZ799ZkXvhzmLN6 Jl3o5zRzBuAP6yDDp4XO51YVn35FcFMn7pJrVUDTSMmshWIj632juwsTzun4M8L4bQ1s ufd/3NcMim1QSx3Hpb1CDoW310U4QM/CSq7j8uq6llrHDz5oC1D4pfB96lQu+l4RYPqv dDHFyxw+1P8x5t+HUe/dVLLIXGUEpDPzHdinqMNoIoVUyF2k/WL0CELfvpwlRV9vMDqV EiXwKmDJsgk+hYX+1dtiCQ+5KGPJ+3a4OHnLjXHSqHZAKYVzlTnfIMC/nmSFFUL31mcj kGLA== X-Gm-Message-State: AFqh2ko3gjJQv5Cg5BHr+xAgbPTYAPB92ij0F6aprHrfi3XLzkyDOsoA pke2cSR5CpxlmZ7Sm9YCvinmMA== X-Received: by 2002:a5e:c910:0:b0:707:a4ff:aca4 with SMTP id z16-20020a5ec910000000b00707a4ffaca4mr14481904iol.1.1674679557136; Wed, 25 Jan 2023 12:45:57 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:56 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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 7/8] net: ipa: introduce generalized status decoder Date: Wed, 25 Jan 2023 14:45:44 -0600 Message-Id: <20230125204545.3788155-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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=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?1756029031956678938?= X-GMAIL-MSGID: =?utf-8?q?1756029031956678938?= Stop assuming the IPA packet status has a fixed format (defined by a C structure). Instead, use a function to extract each field from a block of data interpreted as an IPA packet status. Define an enumerated type that identifies the fields that can be extracted. The current function extracts fields based on the existing ipa_status structure format (which is no longer used). Define IPA_STATUS_RULE_MISS, to replace the calls to field_max() to represent that condition; those depended on the knowing the width of a filter or router rule in the IPA packet status structure. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 158 +++++++++++++++++++++++++-------- 1 file changed, 120 insertions(+), 38 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 5097eb1bbadb0..3f6c3e2b6ec95 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -81,32 +81,118 @@ enum ipa_status_mask { IPA_STATUS_MASK_BYTE_LIMIT = BIT(15), }; +/* Special IPA filter/router rule field value indicating "rule miss" */ +#define IPA_STATUS_RULE_MISS 0x3ff /* 10-bit filter/router rule fields */ + /** The IPA status nat_type field uses enum ipa_nat_type hardware values */ -/* Status element provided by hardware */ -struct ipa_status { - u8 opcode; /* enum ipa_status_opcode */ - u8 exception; /* enum ipa_status_exception */ - __le16 mask; /* enum ipa_status_bit (bitmask) */ - __le16 pkt_len; - u8 endp_src_idx; - u8 endp_dst_idx; - __le32 metadata; - __le32 flags1; - __le64 flags2; - __le32 flags3; - __le32 flags4; +/* enum ipa_status_field_id - IPA packet status structure field identifiers */ +enum ipa_status_field_id { + STATUS_OPCODE, /* enum ipa_status_opcode */ + STATUS_EXCEPTION, /* enum ipa_status_exception */ + STATUS_MASK, /* enum ipa_status_mask (bitmask) */ + STATUS_LENGTH, + STATUS_SRC_ENDPOINT, + STATUS_DST_ENDPOINT, + STATUS_METADATA, + STATUS_FILTER_LOCAL, /* Boolean */ + STATUS_FILTER_HASH, /* Boolean */ + STATUS_FILTER_GLOBAL, /* Boolean */ + STATUS_FILTER_RETAIN, /* Boolean */ + STATUS_FILTER_RULE_INDEX, + STATUS_ROUTER_LOCAL, /* Boolean */ + STATUS_ROUTER_HASH, /* Boolean */ + STATUS_UCP, /* Boolean */ + STATUS_ROUTER_TABLE, + STATUS_ROUTER_RULE_INDEX, + STATUS_NAT_HIT, /* Boolean */ + STATUS_NAT_INDEX, + STATUS_NAT_TYPE, /* enum ipa_nat_type */ + STATUS_TAG_LOW32, /* Low-order 32 bits of 48-bit tag */ + STATUS_TAG_HIGH16, /* High-order 16 bits of 48-bit tag */ + STATUS_SEQUENCE, + STATUS_TIME_OF_DAY, + STATUS_HEADER_LOCAL, /* Boolean */ + STATUS_HEADER_OFFSET, + STATUS_FRAG_HIT, /* Boolean */ + STATUS_FRAG_RULE_INDEX, }; -/* Field masks for struct ipa_status structure fields */ -#define IPA_STATUS_SRC_IDX_FMASK GENMASK(4, 0) -#define IPA_STATUS_DST_IDX_FMASK GENMASK(4, 0) -#define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22) -#define IPA_STATUS_FLAGS2_TAG_FMASK GENMASK_ULL(63, 16) - /* Size in bytes of an IPA packet status structure */ #define IPA_STATUS_SIZE sizeof(__le32[4]) +/* IPA status structure decoder; looks up field values for a structure */ +static u32 ipa_status_extract(const void *data, enum ipa_status_field_id field) +{ + const __le32 *word = data; + + switch (field) { + case STATUS_OPCODE: + return le32_get_bits(word[0], GENMASK(7, 0)); + case STATUS_EXCEPTION: + return le32_get_bits(word[0], GENMASK(15, 8)); + case STATUS_MASK: + return le32_get_bits(word[0], GENMASK(31, 16)); + case STATUS_LENGTH: + return le32_get_bits(word[1], GENMASK(15, 0)); + case STATUS_SRC_ENDPOINT: + return le32_get_bits(word[1], GENMASK(20, 16)); + /* Status word 1, bits 21-23 are reserved */ + case STATUS_DST_ENDPOINT: + return le32_get_bits(word[1], GENMASK(28, 24)); + /* Status word 1, bits 29-31 are reserved */ + case STATUS_METADATA: + return le32_to_cpu(word[2]); + case STATUS_FILTER_LOCAL: + return le32_get_bits(word[3], GENMASK(0, 0)); + case STATUS_FILTER_HASH: + return le32_get_bits(word[3], GENMASK(1, 1)); + case STATUS_FILTER_GLOBAL: + return le32_get_bits(word[3], GENMASK(2, 2)); + case STATUS_FILTER_RETAIN: + return le32_get_bits(word[3], GENMASK(3, 3)); + case STATUS_FILTER_RULE_INDEX: + return le32_get_bits(word[3], GENMASK(13, 4)); + case STATUS_ROUTER_LOCAL: + return le32_get_bits(word[3], GENMASK(14, 14)); + case STATUS_ROUTER_HASH: + return le32_get_bits(word[3], GENMASK(15, 15)); + case STATUS_UCP: + return le32_get_bits(word[3], GENMASK(16, 16)); + case STATUS_ROUTER_TABLE: + return le32_get_bits(word[3], GENMASK(21, 17)); + case STATUS_ROUTER_RULE_INDEX: + return le32_get_bits(word[3], GENMASK(31, 22)); + case STATUS_NAT_HIT: + return le32_get_bits(word[4], GENMASK(0, 0)); + case STATUS_NAT_INDEX: + return le32_get_bits(word[4], GENMASK(13, 1)); + case STATUS_NAT_TYPE: + return le32_get_bits(word[4], GENMASK(15, 14)); + case STATUS_TAG_LOW32: + return le32_get_bits(word[4], GENMASK(31, 16)) | + (le32_get_bits(word[5], GENMASK(15, 0)) << 16); + case STATUS_TAG_HIGH16: + return le32_get_bits(word[5], GENMASK(31, 16)); + case STATUS_SEQUENCE: + return le32_get_bits(word[6], GENMASK(7, 0)); + case STATUS_TIME_OF_DAY: + return le32_get_bits(word[6], GENMASK(31, 8)); + case STATUS_HEADER_LOCAL: + return le32_get_bits(word[7], GENMASK(0, 0)); + case STATUS_HEADER_OFFSET: + return le32_get_bits(word[7], GENMASK(10, 1)); + case STATUS_FRAG_HIT: + return le32_get_bits(word[7], GENMASK(11, 11)); + case STATUS_FRAG_RULE_INDEX: + return le32_get_bits(word[7], GENMASK(15, 12)); + /* Status word 7, bits 16-31 are reserved */ + default: + WARN(true, "%s: bad field_id %u\n", __func__, field); + return 0; + } +} + /* Compute the aggregation size value to use for a given buffer size */ static u32 ipa_aggr_size_kb(u32 rx_buffer_size, bool aggr_hard_limit) { @@ -1355,33 +1441,32 @@ static bool ipa_status_format_packet(enum ipa_status_opcode opcode) } } -static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, - const struct ipa_status *status) +static bool +ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, const void *data) { enum ipa_status_opcode opcode; u32 endpoint_id; - opcode = status->opcode; + opcode = ipa_status_extract(data, STATUS_OPCODE); if (!ipa_status_format_packet(opcode)) return true; - endpoint_id = u8_get_bits(status->endp_dst_idx, - IPA_STATUS_DST_IDX_FMASK); + endpoint_id = ipa_status_extract(data, STATUS_DST_ENDPOINT); if (endpoint_id != endpoint->endpoint_id) return true; return false; /* Don't skip this packet, process it */ } -static bool ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, - const struct ipa_status *status) +static bool +ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, const void *data) { struct ipa_endpoint *command_endpoint; enum ipa_status_mask status_mask; struct ipa *ipa = endpoint->ipa; u32 endpoint_id; - status_mask = le16_get_bits(status->mask, IPA_STATUS_MASK_TAG_VALID); + status_mask = ipa_status_extract(data, STATUS_MASK); if (!status_mask) return false; /* No valid tag */ @@ -1390,8 +1475,7 @@ static bool ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, * If the packet came from the AP->command TX endpoint we know * this packet was sent as part of the pipeline clear process. */ - endpoint_id = u8_get_bits(status->endp_src_idx, - IPA_STATUS_SRC_IDX_FMASK); + endpoint_id = ipa_status_extract(data, STATUS_SRC_ENDPOINT); command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; if (endpoint_id == command_endpoint->endpoint_id) { complete(&ipa->completion); @@ -1405,26 +1489,25 @@ static bool ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, } /* Return whether the status indicates the packet should be dropped */ -static bool ipa_endpoint_status_drop(struct ipa_endpoint *endpoint, - const struct ipa_status *status) +static bool +ipa_endpoint_status_drop(struct ipa_endpoint *endpoint, const void *data) { enum ipa_status_exception exception; u32 rule; /* If the status indicates a tagged transfer, we'll drop the packet */ - if (ipa_endpoint_status_tag_valid(endpoint, status)) + if (ipa_endpoint_status_tag_valid(endpoint, data)) return true; /* Deaggregation exceptions we drop; all other types we consume */ - exception = status->exception; + exception = ipa_status_extract(data, STATUS_EXCEPTION); if (exception) return exception == IPA_STATUS_EXCEPTION_DEAGGR; /* Drop the packet if it fails to match a routing rule; otherwise no */ - rule = le32_get_bits(status->flags1, - IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); + rule = ipa_status_extract(data, STATUS_ROUTER_RULE_INDEX); - return rule == field_max(IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK); + return rule == IPA_STATUS_RULE_MISS; } static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, @@ -1436,7 +1519,6 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, u32 resid = total_len; while (resid) { - const struct ipa_status *status = data; u32 length; u32 align; u32 len; @@ -1449,7 +1531,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, } /* Skip over status packets that lack packet data */ - length = le16_to_cpu(status->pkt_len); + length = ipa_status_extract(data, STATUS_LENGTH); if (!length || ipa_endpoint_status_skip(endpoint, data)) { data += IPA_STATUS_SIZE; resid -= IPA_STATUS_SIZE; From patchwork Wed Jan 25 20:45:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 48341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp478803wrn; Wed, 25 Jan 2023 12:50:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/ouUQ93kujPQ1Fd44nRaYCfR3GB73pSNaxf/CaYPJBW6xa9qDq6jbdOL7C0SQfthzGKcl X-Received: by 2002:a17:906:ecb9:b0:874:9ac1:40e with SMTP id qh25-20020a170906ecb900b008749ac1040emr32752313ejb.19.1674679802211; Wed, 25 Jan 2023 12:50:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674679802; cv=none; d=google.com; s=arc-20160816; b=eK9yHBTrbu/Rr/bXS44jAo6S4b8MLZqDaDrzJXBQgFc3BYe4ams7HX0fjHCMzylXeb yW3hgQ7rrzbM2TbDA8mZgAeRMQNMSm3piy9G0ascGQ5vD8wrf+k6MoHzpadWUKjfm34Q TtG8qvCS61o6SUyKzCApCRId4tEE5pEpKFbAr6XEvZsC6qlwX7LFyoxxnVIjNZaCzglZ aEjUBioVt7VLMVERaXmoP6AmbUXqRBXVJ7PNNgFyHZHp9E7vJXuIij8t9/+tMiH4ZBlP NKDFYjZnQAjj3cDPhH7yKhoRvQcmSIGoLpujc6nKjdTrgUmLEBcxocHt4LKdnXgOT4NU Cd/Q== 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=YJZAdhZu9Kc85spjoXNYXOlKgf8rIiOctQJ+s3Nz2ig=; b=gmdezWD9lBgbjdm6vJ1cP74ds/NbyQWz4zm+mFPgfQso8CeoBDCWJtFvuiWYKPgnck 3AKd/xGBaQO1645N1zKAEYGi2GgLt7tLocfxr4CNnknxPwozjeDUYxftKbZIUDexClXf Ng+JyxYRx/EHNHbtyHcv8PeE80dUze2GmpjOsSIbxWN/dnm3mRteSZzcCxyoadMcOFJZ G0r0uG4sNiXWtpuvb1S3eBwdsbkrxZTbFCMKMbpQ+tEBHk24KljkYLeMZBGn+wCOZf+r WyvVIXZc9JN16mLnqfGavfM9r3gUdxD6YZRfuo3hJ35DcNzU4WPgtk8Re8OShvINJYyj r56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i8il3nE9; 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 15-20020a170906018f00b008776d86c787si7200646ejb.166.2023.01.25.12.49.36; Wed, 25 Jan 2023 12:50:02 -0800 (PST) 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=i8il3nE9; 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 S235962AbjAYUqd (ORCPT + 99 others); Wed, 25 Jan 2023 15:46:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236604AbjAYUqF (ORCPT ); Wed, 25 Jan 2023 15:46:05 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F8D5DC3C for ; Wed, 25 Jan 2023 12:45:58 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id m15so26670ilq.2 for ; Wed, 25 Jan 2023 12:45:58 -0800 (PST) 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=YJZAdhZu9Kc85spjoXNYXOlKgf8rIiOctQJ+s3Nz2ig=; b=i8il3nE9OWdDb6H7w7iJfr8m/h+OjScnmTUlxZmt0IwIdDRytGc51rEEhL19tzZuaq kAKlm2K1JGv6uVpx7zqydljUVLqldOScg3OBrd8hdsjOqM7SWf8Y4Wx14FpoG+JvUWK4 rGhqupA1ApmKs6sQpprsV15cMrw/y6wRnIBJIEOUeFylNMcjpfV3nbUkvyFnNm9u9zJ6 cDbhi0aV0ES7aHm8xv+hVh0CtJEmuJFzFtsZQuA4AYIrVSAnSfy81/Ueb3lbfvQnTqfT gre9ZvDGP3LytsibcxLFtu8kYm2G0gNZBonbhaZT0xdxWBaRkt0EaMdSeW1sIIWmcpbC wkkQ== 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=YJZAdhZu9Kc85spjoXNYXOlKgf8rIiOctQJ+s3Nz2ig=; b=6RqM3zwvGx7umIWNIcqzZpGDHc+d4ExxSVgjolp4ONswCPlU6qahN93+R7nl01YmrB O04JUk7bf/CVujkO+erVOtdE6j/GMW/hzhdc6CQ3KwR2U/O6PDxhETelESYI4D76cKPs ozMQ5B62W+0eJ91T3bEbe2TxTpYGSVouh3WODPsKvlQ4nyFzn3CQB6Ofo+NODXamAHe6 bAMb04m4WoYiRYoz/Fw/xuQqS52slpVtPpWiIkUvXIlj1QzGoqaYP3dIBSrjd3mg2MSA MayU3EnH9xrm2UKWneunc43FUyjamnSbumbxw+EZ+jJCsgmYsXcSHMV2JvFsIgTqrNuY eftg== X-Gm-Message-State: AFqh2koPxgxg/mAQJuztLOb073Y+FtquPPj+DAiYGtEsrlkXHhC6ckbS d5NiUv9k7NF4XW6BsBCEKht/DQ== X-Received: by 2002:a05:6e02:12e8:b0:305:ef92:6480 with SMTP id l8-20020a056e0212e800b00305ef926480mr27927418iln.27.1674679558220; Wed, 25 Jan 2023 12:45:58 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w14-20020a02968e000000b00389c2fe0f9dsm1960696jai.85.2023.01.25.12.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 12:45:57 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, 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 8/8] net: ipa: add IPA v5.0 packet status support Date: Wed, 25 Jan 2023 14:45:45 -0600 Message-Id: <20230125204545.3788155-9-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125204545.3788155-1-elder@linaro.org> References: <20230125204545.3788155-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=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?1756029048210808679?= X-GMAIL-MSGID: =?utf-8?q?1756029048210808679?= Update ipa_status_extract() to support IPA v5.0 and beyond. Because the format of the IPA packet status depends on the version, pass an IPA pointer to the function. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 52 +++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 3f6c3e2b6ec95..ce7f2d6e447ed 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -122,8 +122,10 @@ enum ipa_status_field_id { #define IPA_STATUS_SIZE sizeof(__le32[4]) /* IPA status structure decoder; looks up field values for a structure */ -static u32 ipa_status_extract(const void *data, enum ipa_status_field_id field) +static u32 ipa_status_extract(struct ipa *ipa, const void *data, + enum ipa_status_field_id field) { + enum ipa_version version = ipa->version; const __le32 *word = data; switch (field) { @@ -136,10 +138,15 @@ static u32 ipa_status_extract(const void *data, enum ipa_status_field_id field) case STATUS_LENGTH: return le32_get_bits(word[1], GENMASK(15, 0)); case STATUS_SRC_ENDPOINT: - return le32_get_bits(word[1], GENMASK(20, 16)); - /* Status word 1, bits 21-23 are reserved */ + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[1], GENMASK(20, 16)); + return le32_get_bits(word[1], GENMASK(23, 16)); + /* Status word 1, bits 21-23 are reserved (not IPA v5.0+) */ + /* Status word 1, bits 24-26 are reserved (IPA v5.0+) */ case STATUS_DST_ENDPOINT: - return le32_get_bits(word[1], GENMASK(28, 24)); + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[1], GENMASK(28, 24)); + return le32_get_bits(word[7], GENMASK(23, 16)); /* Status word 1, bits 29-31 are reserved */ case STATUS_METADATA: return le32_to_cpu(word[2]); @@ -153,14 +160,23 @@ static u32 ipa_status_extract(const void *data, enum ipa_status_field_id field) return le32_get_bits(word[3], GENMASK(3, 3)); case STATUS_FILTER_RULE_INDEX: return le32_get_bits(word[3], GENMASK(13, 4)); + /* ROUTER_TABLE is in word 3, bits 14-21 (IPA v5.0+) */ case STATUS_ROUTER_LOCAL: - return le32_get_bits(word[3], GENMASK(14, 14)); + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[3], GENMASK(14, 14)); + return le32_get_bits(word[1], GENMASK(27, 27)); case STATUS_ROUTER_HASH: - return le32_get_bits(word[3], GENMASK(15, 15)); + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[3], GENMASK(15, 15)); + return le32_get_bits(word[1], GENMASK(28, 28)); case STATUS_UCP: - return le32_get_bits(word[3], GENMASK(16, 16)); + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[3], GENMASK(16, 16)); + return le32_get_bits(word[7], GENMASK(31, 31)); case STATUS_ROUTER_TABLE: - return le32_get_bits(word[3], GENMASK(21, 17)); + if (version < IPA_VERSION_5_0) + return le32_get_bits(word[3], GENMASK(21, 17)); + return le32_get_bits(word[3], GENMASK(21, 14)); case STATUS_ROUTER_RULE_INDEX: return le32_get_bits(word[3], GENMASK(31, 22)); case STATUS_NAT_HIT: @@ -186,7 +202,8 @@ static u32 ipa_status_extract(const void *data, enum ipa_status_field_id field) return le32_get_bits(word[7], GENMASK(11, 11)); case STATUS_FRAG_RULE_INDEX: return le32_get_bits(word[7], GENMASK(15, 12)); - /* Status word 7, bits 16-31 are reserved */ + /* Status word 7, bits 16-30 are reserved */ + /* Status word 7, bit 31 is reserved (not IPA v5.0+) */ default: WARN(true, "%s: bad field_id %u\n", __func__, field); return 0; @@ -1444,14 +1461,15 @@ static bool ipa_status_format_packet(enum ipa_status_opcode opcode) static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint, const void *data) { + struct ipa *ipa = endpoint->ipa; enum ipa_status_opcode opcode; u32 endpoint_id; - opcode = ipa_status_extract(data, STATUS_OPCODE); + opcode = ipa_status_extract(ipa, data, STATUS_OPCODE); if (!ipa_status_format_packet(opcode)) return true; - endpoint_id = ipa_status_extract(data, STATUS_DST_ENDPOINT); + endpoint_id = ipa_status_extract(ipa, data, STATUS_DST_ENDPOINT); if (endpoint_id != endpoint->endpoint_id) return true; @@ -1466,7 +1484,7 @@ ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, const void *data) struct ipa *ipa = endpoint->ipa; u32 endpoint_id; - status_mask = ipa_status_extract(data, STATUS_MASK); + status_mask = ipa_status_extract(ipa, data, STATUS_MASK); if (!status_mask) return false; /* No valid tag */ @@ -1475,7 +1493,7 @@ ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, const void *data) * If the packet came from the AP->command TX endpoint we know * this packet was sent as part of the pipeline clear process. */ - endpoint_id = ipa_status_extract(data, STATUS_SRC_ENDPOINT); + endpoint_id = ipa_status_extract(ipa, data, STATUS_SRC_ENDPOINT); command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; if (endpoint_id == command_endpoint->endpoint_id) { complete(&ipa->completion); @@ -1493,6 +1511,7 @@ static bool ipa_endpoint_status_drop(struct ipa_endpoint *endpoint, const void *data) { enum ipa_status_exception exception; + struct ipa *ipa = endpoint->ipa; u32 rule; /* If the status indicates a tagged transfer, we'll drop the packet */ @@ -1500,12 +1519,12 @@ ipa_endpoint_status_drop(struct ipa_endpoint *endpoint, const void *data) return true; /* Deaggregation exceptions we drop; all other types we consume */ - exception = ipa_status_extract(data, STATUS_EXCEPTION); + exception = ipa_status_extract(ipa, data, STATUS_EXCEPTION); if (exception) return exception == IPA_STATUS_EXCEPTION_DEAGGR; /* Drop the packet if it fails to match a routing rule; otherwise no */ - rule = ipa_status_extract(data, STATUS_ROUTER_RULE_INDEX); + rule = ipa_status_extract(ipa, data, STATUS_ROUTER_RULE_INDEX); return rule == IPA_STATUS_RULE_MISS; } @@ -1516,6 +1535,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, u32 buffer_size = endpoint->config.rx.buffer_size; void *data = page_address(page) + NET_SKB_PAD; u32 unused = buffer_size - total_len; + struct ipa *ipa = endpoint->ipa; u32 resid = total_len; while (resid) { @@ -1531,7 +1551,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint, } /* Skip over status packets that lack packet data */ - length = ipa_status_extract(data, STATUS_LENGTH); + length = ipa_status_extract(ipa, data, STATUS_LENGTH); if (!length || ipa_endpoint_status_skip(endpoint, data)) { data += IPA_STATUS_SIZE; resid -= IPA_STATUS_SIZE;