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;