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: 13116154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46AD5C54EED for ; Wed, 25 Jan 2023 20:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbjAYUpx (ORCPT ); Wed, 25 Jan 2023 15:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236446AbjAYUpw (ORCPT ); Wed, 25 Jan 2023 15:45:52 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211374EC1 for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id u8so3953ilq.13 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=Q+epn3At6VI9iUjTouAwRJ1XT4agsvGXAMADqvq0xl1ezoG0ENKDLvfNO1Y85Ia2nI +AbE3aamA6mNNftQ2kE1UvpgVd9H2dkOiaEhQPNv5ss2M3QAWp8fKS64snFAbFRSnPRd wnzOpasfutsz9FQvShUPNhhJBs81htMrL9DJ/kyiD1yxwlPOL0cZPntCF0YHESYcKhWz Wp7v5CZcSyNK6UQX4XjLGr76gcB5nq/oqd7yxIkD9KNztDz4YnHVMX1G4o1piCcKDTen hQsHD+fE7hgS0nPflPvutgz6cW+EtFxfGjRu5XeFH+LUVgTZum3hSrEK44YO92oPWvop 7EWw== X-Gm-Message-State: AO0yUKWeP1FNJUU06nKLxR11pEoZg9Zjq1Z5OQaIhlpRT6frnl7nVvnr T2blsHogfWdfPuzLdftajJUuig== X-Google-Smtp-Source: AK7set/Vdk2RgNYyVH2sF2H9VvkVLiEXjUAPPdJyUqFQJfP5IbxXFGLB1iaNq0H2KnH8WgaAAJazjA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DBF8C61D97 for ; Wed, 25 Jan 2023 20:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236446AbjAYUpz (ORCPT ); Wed, 25 Jan 2023 15:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236468AbjAYUpw (ORCPT ); Wed, 25 Jan 2023 15:45:52 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5623527E for ; Wed, 25 Jan 2023 12:45:51 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id d10so6030ilc.12 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=4QXdyxh2ntS9DP2PdlAilBHlLDdupo0eMSWdjb4RS8sWqp0vtBviNLFgq0sJQhhUuR XsQ6Vzz6cptvLfdfiyG5EEqLU1YfRwdYcf9Kbhk+i6R61XimoH3CiEU7XexqdX7hUDtg AeGqjD+57p8NluBWOBDlHUe5C/Y98f4LAb9RA2DpRGD3O9lKmcA6GxOz6kYCjxn4llRF Hp2aKjEx0xaJ8/RyCmTeppGnoqrJlLyNHOjfq9wejQvIzWIV88Pl1bj2qZ7G9GpZyZsT 0RHToIKqR7Y1JMbq3bR2qlQkT8ZjqQDh2FZ54gg53kKoobU4OHlho/IvByturHg1+8ON f5hw== X-Gm-Message-State: AO0yUKUV2BwSygXDuL0YD+DISWRVfezeVNvX6xQfrBIm4R7PkK5uJfOi 7v3sJVzGNKbxKjhe5zGHE5wNwA== X-Google-Smtp-Source: AK7set8yUNgrw8GsgLvvmWr/rD62mY/NcoD5S4iNAvSBFMxu3sOi8yEandYnRrpkoKznzMFcuO4+nA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C7ADC27C76 for ; Wed, 25 Jan 2023 20:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236564AbjAYUp6 (ORCPT ); Wed, 25 Jan 2023 15:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236508AbjAYUpy (ORCPT ); Wed, 25 Jan 2023 15:45:54 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD234EC1 for ; Wed, 25 Jan 2023 12:45:53 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id m20so23180ilj.4 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=f0DE1Mp0dprw4tYCJ8rzQXHSE3ZqfF0d6jNW+Hc9jkVv/kHXQipes5qGg1m8vlphPX 23nPYyZaNLkAQz27tWnvAu6IdQLhObgW9KDAckIbpgDqZmHPbtmplJ40yS81ocECT4vJ 3eMIy0G1HQOfdRK7TF6mUTE8AFf9OBKfUJFjbbZ0rOiA/ynkad0D5VLfI87DHiBeg+uL 4ulJMCjJOs7oo6Lk+BwydwWSwehUdY0u3Bt2srZHNVuzzJWd6IJ2/0sSV1FDfh21Rvjs /2VXiVoRW06ZvXalzfcay7JtHGeZzGlTPvLM//f/2kcCJhQjsYD5+DncHNLAmzHLd4ry harg== X-Gm-Message-State: AO0yUKU/utcbRzzewg6WpM4PVBNmvFGJEECL8qjC8VU/6p55gmc2iJ5A uppBoHAqWTz/oay4ISxQIt1jxA== X-Google-Smtp-Source: AK7set8rj6rUV2/lsvjOLQ6lKi2esQROazXF2atha5xsx5FuBP+pm7BXEwXjUCW5Ue2fGNMhWsbWdw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E66AC54E94 for ; Wed, 25 Jan 2023 20:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236474AbjAYUqE (ORCPT ); Wed, 25 Jan 2023 15:46:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236527AbjAYUp4 (ORCPT ); Wed, 25 Jan 2023 15:45:56 -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 A0D095D922 for ; Wed, 25 Jan 2023 12:45:54 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id e204so9024901iof.1 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=hgvv8EIPrXPPq6p1fnwaekVLetDKSTnTpTG3CWMa2sJIIjOliOUJ5S4O534gfviJ3d PTDiGHibR2vUxh7k6HYFJwWAmaPjHIoGJMSdNL8NXw//H6DSn/Ozd+jG6HPbTFpv8amW Jh/g4e7Teq9iagS0wFgpaYuFa5ztUGW8TtbDxvK6zAP5KLIdfFmPWqXoKNxleUhzNN2H JbQZI8F/CwY1/MMtTO21MVNAP84rKK23OviKdQ/6sHk4N+OmjSnG9Ta+HJxYgNLhxDsv NIwmEgq+t2Q7gDj8AY5c6KZPzUGx+X5rX43W/vkhDJAC5bquQTWB5EKC/1a0AMq5e7Q8 c+oQ== X-Gm-Message-State: AFqh2koXYwunM3OiH0X2WHpr279OaKxbzDgafdOpyMGINX8JlZSFSWu1 e2I5KIG9ugNe6jiwAzzdOQ6vVA== X-Google-Smtp-Source: AMrXdXs58SAFuh+dzcoSLgO4zcDzklAbXxGprE1mFbPsIaCzVgLVXLg0ybjfHGmAvjNbAtP1ogkL3A== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E69C54EED for ; Wed, 25 Jan 2023 20:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236509AbjAYUqF (ORCPT ); Wed, 25 Jan 2023 15:46:05 -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 S236541AbjAYUp5 (ORCPT ); Wed, 25 Jan 2023 15:45:57 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E99E5DC21 for ; Wed, 25 Jan 2023 12:45:55 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id s26so9001589ioa.11 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=c9OxX5ktbDWDnOGXv1zlTTMmf+Oy7GHAO8oN+O0z6M1wOLbmC9fMnCxXisySScKEKS hL7Dbb2sCjFzE93ab/d3+/sIPC4UemF45GrONuc2bAV126O0gMitXf0YF4D8gqukT0a7 JwCjHCNmVTkpYh4kW2Hd/FiCi9c0stQdEsVvude84ykW71jXZBs4GDodz39lP8BQwQpz VyC5RdfHZg4nd0/f6aSo2CEGrp4pFw7Offthq4zHFBUl/euDhtt0CqV2ynRKs1PHM5GF QODVHbzZIh1sVbs0ISltScHiUh/I5n4InXFb8Zi+iIzsCcLE1rK7/1kBMg3XCcGYirBN ztAQ== X-Gm-Message-State: AFqh2krQ1Tw7KJNmIkewfR7ulC5BwSI6MIc4pim2m+pXdJa8YK4mczsG bdSAo+IAbDRzgyT5BenTb/XASQ== X-Google-Smtp-Source: AMrXdXsuTb7h1Bqw8S2j7vgNCyDU2boq615Xwy0koE3VBkZlJulR7pKWVEplVw9TeSWTzqtI/UYGmQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B7AAC61DA2 for ; Wed, 25 Jan 2023 20:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236618AbjAYUqH (ORCPT ); Wed, 25 Jan 2023 15:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236572AbjAYUp7 (ORCPT ); Wed, 25 Jan 2023 15:45:59 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79F75E50C for ; Wed, 25 Jan 2023 12:45:56 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id a9so41868ilb.0 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=OXEkQ+HPtqBRlZY96KhA/mYDFbgFTGVEZXkEdGAnp7msyWgsAQT+m1f1SjeFXjPafW Sfzdtzg1UdCIzVk+TYQ3bPnLS7WVcBiiC3BOqwv7IRFAWMIR4iD0J3W4pqnwsxWypTH3 A5swJjkPTTgWDUUgGS+KL98fnPvGEFc8GOGpfLA10kjPKjhRhlO0WsEoomeBWAXJsw4W 5hfwn+B3Mna4Cl3a5ACm+cvMLqOYNc4MIzKVZFmuE+35sYsh0lFFoNnIyPbIXsLwiG3e PDex3Xw9/4MtXJpJtUrdI7pbtFvf9CEkdk0LZiO408Vcj/ves48OqAUy1veuAObxx1BR sEzA== X-Gm-Message-State: AO0yUKU/x0163NDETUYyEzMuxKuBJd7dSAXaDRu7n0kOh2KqxZZKC0AR IFOgADdgqcaSj06wQaob2oKMsw== X-Google-Smtp-Source: AK7set9st4MWDlh7U7AjjbEL+gFLq+4qpbtx3jTqTFLY0kkhr3Xq8lue4Nfl/4KbTdDleWVPQvLzwQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 497BCC27C76 for ; Wed, 25 Jan 2023 20:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236633AbjAYUqZ (ORCPT ); Wed, 25 Jan 2023 15:46:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236593AbjAYUqE (ORCPT ); Wed, 25 Jan 2023 15:46:04 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0185D13C for ; Wed, 25 Jan 2023 12:45:57 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id r71so9019214iod.2 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=H6Tod4iAYodFcOBtT6sIMbR+4Rl9seFrowRvz5wwNqVhmi45jVcTlJnYRHikrOMoGA F8jJV44tWgIEu5gOvYjlsk3Vils3f3hwMJPQn9ygTglETeDSmAybkb4WHL1T5U1Xm63K E8HIJPEnNFp7GIpCx0n99zJE/nfU06prTKrZvjoyhRu9hfpE5iGzogipvomp8hvqz3dN hUsTC41tpRmnXPcF54pm7MgGV1Kcg8uFBbZyrZEyhBIr2oqD4vf5mUsGhlJvpi5mU6iR gRnkUHGu+hPlTh6CkZPzvgqUDNNx2DiIrOWAYeiBdOzfvEKfkc2uiHj93Pp4zjZobylh ymYQ== X-Gm-Message-State: AFqh2kpD7GHrnmbiNEA1gM6NKV2kY+blDQIXXn+zqtyyLq79Di9hdXTO t/i9nfx0Q+C9yYQ/B+7D3wyz8w== X-Google-Smtp-Source: AMrXdXssFJrtYlZ0WeqKmNUE/qQ3IO1uxDtXbkURxiyawtvVLA/DdS8lRhRU13AsvHBJpczO5WMNEg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 13116161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73BBAC54E94 for ; Wed, 25 Jan 2023 20:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236498AbjAYUq1 (ORCPT ); Wed, 25 Jan 2023 15:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236601AbjAYUqE (ORCPT ); Wed, 25 Jan 2023 15:46:04 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A145EF97 for ; Wed, 25 Jan 2023 12:45:58 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id d10so6142ilc.12 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=gCFo+4r+Ff1OVqBbhnnBlbw04tOB6pBmMF7xMxjVk98w9iv6rH57e3ol34G3oTNyic gr5LBuLz+auRm4HQOsSaJGQoYhFOqpZqW+646k0TQrAelCYp/GJdhbuOeOVApTlyxI1P lPOdk+R4e5wf3GbGc63+KC+rg0skGXyRzPFz7SzDpvtCeV+XPcyy+stvq4uJ+f9s2Py3 YDUBNq4P8efPATGtMgMPcwyZGZs4ZYRCL4ugVROxMGzX5d86P671q3Gg1tsOvLSzPwav XerA2VAuJT2hAnUMWciEhQo7hhIdmJO8NrItbJPp4G8RPGGGQN+gRoAG55U3vHTl/mQU Acwg== X-Gm-Message-State: AFqh2koUMoQktPBy37wY2+23vMRXV5PMRx9LmmFTz890RCjmh1qRbyGo xsQjJULfycwvVISBIhMeqetGEcid3mbEDz7P X-Google-Smtp-Source: AMrXdXtkkcBpeGWBz3wEZJm7ZK18N6ZrvtxMBYtkIoUTDsU5u9E+7eq4IHTqEfrZYIcJdwGAP7MsSA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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;