From patchwork Fri Jun 11 20:39:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458517 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1268386jae; Fri, 11 Jun 2021 13:39:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY0YdfCORzsBvIPye4Odlkmh1LuMavYrbrswYLVm0gtFGFoSj4frhmp8swPAqG0zhPSzEt X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr5506260edb.236.1623443995722; Fri, 11 Jun 2021 13:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623443995; cv=none; d=google.com; s=arc-20160816; b=W2+rK0BUBhL5z7qX/9+peFQB2WfJTFfnXewr5GwOUTrfeS1g9ZPerU+I3woTEfkE5y FlBTiSRCHnJGDVk8ngTfRc+cVhO2nqzDqQRpTOw2rtU4X/Ps17JupIERPO6oCX36y0mD FMNzpYxWgvGBOdTQ5AJr5RFe0PgjUyYVB+q+OLOjxu0ZKlnIG/KJPeNnSJN3UEM66VE9 UuELl6e0Zfby32aG7Aq5kwNhTAOIq4XEITuhfEhssO2MdF4tAZq1oAb5njoj0ZF9shAi JsN/EX74/MlGQgi5D3mXdKimWnsSEVN/M9VqVVR7HFI4JgknBxEooNTkTjo9iRIn3BEF +N1A== 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=P7uaYucC+62klUqk+ruT7sASOO838Q3Fy6yssPZtvh4=; b=XWmmmFi2e5hQsn7PmEmzqsC4EO0ctjK+03D4GbQdI4WGwnV8AoVgcMRztN+kvm/swn 3VJLN5L88yDOcTgDUY+VePaLll8RuWkmDBbub8rrkt/+Ys59drrzIcRApWPpdDBumj+b NC33qDyVxHT+Gs28ow8z+aMQ14wHSaAIxgFR/lrPAWCxr7xauF4pe5aZYF4hv25nNm6P SrxI+i/kUUfQBOuqKLW+SvxO+HK6+Nlz3Svx+4mgKliDR4wBv6ENqy3iES6DtBl+5WW2 mrn71NwZUBjrtaNnjbkcatGwX1jhCWW/Qcs+CK9DX5mDBiau/GAjeZb784PCZVP8RxgI xSMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KMCAcHJA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si5385307edq.534.2021.06.11.13.39.55; Fri, 11 Jun 2021 13:39:55 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KMCAcHJA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230406AbhFKUlq (ORCPT + 8 others); Fri, 11 Jun 2021 16:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbhFKUlq (ORCPT ); Fri, 11 Jun 2021 16:41:46 -0400 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 B4D39C061574 for ; Fri, 11 Jun 2021 13:39:47 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id l64so10886482ioa.7 for ; Fri, 11 Jun 2021 13:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P7uaYucC+62klUqk+ruT7sASOO838Q3Fy6yssPZtvh4=; b=KMCAcHJAIMxrgGwUWsIpQ9GXDLNt5lT/NifJxtXW+piGpj/hshXULJfk6G3W/Ce/zI nI+LlP2qDy73Q6Kl8mFbbuzvuIEdchOnRywPShlPUaYjK6KZXxyKEvRQAnwICSDieWVl l1Hns8Xs5uyGYuuVH3+JXO5Z4V0o4luisclY9/O/pkh8WXNujyHC8vWLhRH2JPffbzKZ Tf2+M6anOupoo1HM4OMsUkLyvarGujJIpqKr2YvHZ4rbuTSK7p6g2h6Pc7k8qpl15y8Z xHsqLw9k8/OEVcPjuqC53U8vBbgORFVvjcrxaMuZr7pQtQC5Hwcrv0Gwb7f5QpqHgJPK z4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P7uaYucC+62klUqk+ruT7sASOO838Q3Fy6yssPZtvh4=; b=hhoO4a3nYe43hQP8r8aQkHFGk6+Ox63yrUzST8FRZX/lkkkDUfmno0CzWGsVjAe+kI 44A5BdKAUIbwtVL7zOlXf2XZ0nsU2VJ8JCbzjDQDysA2+ut2uKoOhZU/lsne5xSiKyDA KY3tRvcNvxErG4SQyMaNpn10OQ+ZFPha4PoGU8noRweiD/7yUItsyhzrNQaeLG6hJezQ 6YCzg+HbOMQRrOc2uoLTYHYJOl1PAZ3YVhD6Qt70gb/XUdcrw87btpimyiAzyWOf+bEY CY9JWk9jv1tz9I/mugbMWKmgYZ4Zq3c+vI++BTs7zzL6OWcetLSp32mEwxbPlrOfU6zK e5Xw== X-Gm-Message-State: AOAM5315DULx4abCoQL/2oaHJFOpyZ8jkW0c7fULgOZiDCrP383WUieu Yr2+vrRFG/qUf8V0QShq29aELQ== X-Received: by 2002:a02:354d:: with SMTP id y13mr5524096jae.83.1623443984720; Fri, 11 Jun 2021 13:39:44 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y9sm3761544ilp.58.2021.06.11.13.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:39:44 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: leon@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, aleksander@aleksander.es, ejcaruso@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] net: ipa: make endpoint data validation unconditional Date: Fri, 11 Jun 2021 15:39:38 -0500 Message-Id: <20210611203940.3171057-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611203940.3171057-1-elder@linaro.org> References: <20210611203940.3171057-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The cost of validating the endpoint configuration data is not all that high, so just do it unconditionally, rather than doing so only when IPA_VALIDATAION is defined. Suggested-by: Leon Romanovsky Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 12 ------------ 1 file changed, 12 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 07a81b73306fe..3520852936ed1 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -75,8 +75,6 @@ struct ipa_status { #define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22) #define IPA_STATUS_FLAGS2_TAG_FMASK GENMASK_ULL(63, 16) -#ifdef IPA_VALIDATE - static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count, const struct ipa_gsi_endpoint_data *all_data, const struct ipa_gsi_endpoint_data *data) @@ -225,16 +223,6 @@ static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count, return true; } -#else /* !IPA_VALIDATE */ - -static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count, - const struct ipa_gsi_endpoint_data *data) -{ - return true; -} - -#endif /* !IPA_VALIDATE */ - /* Allocate a transaction to use on a non-command endpoint */ static struct gsi_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint, u32 tre_count) From patchwork Fri Jun 11 20:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458520 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1269527jae; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAOD0RmQrqqUi/iq+QFzww+4q4qbbC2yILgTdvh8ziL8reSxrGlt7hlYsPN28P0d5WAG2g X-Received: by 2002:a50:afe2:: with SMTP id h89mr5679457edd.308.1623444100715; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623444100; cv=none; d=google.com; s=arc-20160816; b=lxkdBZkHT9aIZ2AKj3P9DkpU0HKDaNDsVo7pdpYIoPojHNYiK74f6bFMP1f82WWH2n DcJpCPOX7GSJVutMpYNPZdoE/hO6O+ZPfPtk0idhes3fLKujVsvD8g8gcvWCnjY8i3Wx kVBd0taVbjzdDoOdLneyA6oVpuKnIEC/mU+3XICTj12F+eMCF+3kf9KFrkHwKUGm+WBa GvIq2P6c2PpStcTkSio8huEoxDLkwumNQsL1Qh+57ehnsnjTAbficoDP4kBcPkOjpwLV 2z0+g/ZaGucDvXzbxKrLXiPyc8FJtam480tekvgzE6JTkyEBrxqUdtvmPH4w9DI88BHb 0+8g== 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=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=AuawrbpTlXKjmCdxNmRxAWkdHt7CMTz/yNcFOUYbXgDx0Wd8zgoEB/vdna6pRTjMgV MFOyTNQag9BV87aATxwqmFPE0y+7Mi4ub46WbJew/y/XDIQQe3XLY5PzoHP6GWTuh056 6lUMyyY1u6/1OBRIoAx3ZrihKo8IsOpW0Wy8Ne/smR1xIqt23+/JhIZ8v/KyP1dPT6dM hNKnaKw7SmIu5q3d1ESD4jF8SCkgdJUv+Enkzkq3UK3kfppQtDcxh47hunIw+w3vQFhp enMVhfPTtfAYww0JvOsJz/7isVOKgtpMHP2TMO8xUGTjqj6OyXI7BNY7uwmL6Rt4jVyp X8Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pg6BXOoH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jj27si5502461ejc.580.2021.06.11.13.41.40; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pg6BXOoH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231327AbhFKUm7 (ORCPT + 8 others); Fri, 11 Jun 2021 16:42:59 -0400 Received: from mail-il1-f170.google.com ([209.85.166.170]:41644 "EHLO mail-il1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231265AbhFKUm6 (ORCPT ); Fri, 11 Jun 2021 16:42:58 -0400 Received: by mail-il1-f170.google.com with SMTP id t6so6326739iln.8 for ; Fri, 11 Jun 2021 13:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=Pg6BXOoHn2/9V19Rwq7rqEsrnCWv/wINZ2Crxj6EZOVsyTbEte0oSWJUDUN4QPowsx g/pztumsI5nh1Dlyw2lxMFUZ/l5FXEOB2lDNRBain5Zss2o9hx0B/MLJUxsuDjlsqZDk ADnmLOReBBO+aUnfOmm/jKltU2Z/twUfDG7oWxTMY5y4msmfXk+9ZMyUA3OiuDWFd8h1 CCsvDMF8RCr6lmD6bRUffB1yy9XeSFK3ARQoEEX3fTQKHvBAYH3S6w0jnKS6n50BSD6v zY8OAMEMIF4Qyj+h3b7fYob62Hd6NuT2n2u+fQPFKNLpjveOsHm8zSxxCz6xOfrMVTCn mnnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=tsfkmS1Frw+Zkrr2riKc6BhGPIqtE+ql3ZnCVAsElvMasQzX6Ai3j8OR3rgZAR8+JT 9S9yPZDZXgN43Mp57EBJ0MEWgAQIktNMGGn4PQzTBL+dISV4e7acaT3YnLm6mC3/Y2jI IAHZbJ9tZsoKna7ASRlhv2Rc73AXv51/4VN75+egjqer3346AD6vkBekt/06/z69tiV2 kC35NuB1r0Y8+Xdkv5R06JpgAU37sbjANPenQCa8iXKG6s3CgKWeunKavapGI928XS1M tzzGQivanWgROq6spMdeGFUwKBvhYbAVPIXlR5YrhHzpdSkHn+znxVoqEpPHmCxwj4Lo x9hA== X-Gm-Message-State: AOAM531b096b0yqSmwIcuyY04QyQLfgEJz5vn2fvuTJFbo82n+u+gm4N lJs7icD2bbf6S5smUGFXC9IGAQ== X-Received: by 2002:a05:6e02:1248:: with SMTP id j8mr4603939ilq.217.1623443985751; Fri, 11 Jun 2021 13:39:45 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y9sm3761544ilp.58.2021.06.11.13.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:39:45 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: leon@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, aleksander@aleksander.es, ejcaruso@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] net: ipa: introduce ipa_version_valid() Date: Fri, 11 Jun 2021 15:39:39 -0500 Message-Id: <20210611203940.3171057-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611203940.3171057-1-elder@linaro.org> References: <20210611203940.3171057-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define and use a new function that just validates the version defined in configuration data. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 9915603ed10ba..cbd39e4667a32 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -639,6 +639,27 @@ static void ipa_validate_build(void) #endif /* IPA_VALIDATE */ } +static bool ipa_version_valid(enum ipa_version version) +{ + switch (version) { + case IPA_VERSION_3_0: + case IPA_VERSION_3_1: + case IPA_VERSION_3_5: + case IPA_VERSION_3_5_1: + case IPA_VERSION_4_0: + case IPA_VERSION_4_1: + case IPA_VERSION_4_2: + case IPA_VERSION_4_5: + case IPA_VERSION_4_7: + case IPA_VERSION_4_9: + case IPA_VERSION_4_11: + return true; + + default: + return false; + } +} + /** * ipa_probe() - IPA platform driver probe function * @pdev: Platform device pointer @@ -676,11 +697,15 @@ static int ipa_probe(struct platform_device *pdev) /* Get configuration data early; needed for clock initialization */ data = of_device_get_match_data(dev); if (!data) { - /* This is really IPA_VALIDATE (should never happen) */ dev_err(dev, "matched hardware not supported\n"); return -ENODEV; } + if (!ipa_version_valid(data->version)) { + dev_err(dev, "invalid IPA version\n"); + return -EINVAL; + } + /* If we need Trust Zone, make sure it's available */ modem_init = of_property_read_bool(dev->of_node, "modem-init"); if (!modem_init) From patchwork Fri Jun 11 20:39:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458518 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1268884jae; Fri, 11 Jun 2021 13:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk8VVK4yecrgGldLYNd3RP8xOAcDNaYiGezjfl/tiBO0bVjcGX67OpvgH7iD9AjFoaC/rm X-Received: by 2002:a17:906:a458:: with SMTP id cb24mr5277454ejb.482.1623444051872; Fri, 11 Jun 2021 13:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623444051; cv=none; d=google.com; s=arc-20160816; b=kYRouhMKeI+IIRYXnrT0DNesBCSsxaszGtfAE0DfS+69Wkfjo5j7VxufNEjer6ptQ9 +azzh8CXR04HZY6EsUD+WFSt7QRNMyWt+5ilOyV1YvFJsqlXP20QHhH3zYHn0sBpn4Sx SOxzBl8Yi29SgI4atHuYsDxMDCm2VTNAaBZvCAI80WiC6a2J4ki5RPCiWgvVDjw/bWLN QmdMpqekgmgpGMLSw6CZ/GF62MFVq3mzuvd/c/3D3gSYAZwq62gqcDzKCDRNvmahrNpO ghXVk7RSpdSrzyTSb15vlznpmw3lMFcuN2B7UHKelTV5GEshHnNBkrMhfrgA3lqfpI2M 0jvA== 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=z0A+YtYYWtQRN8MlN4WVvuoWz4M6oSYiKKNYu0qWiDA=; b=ld3YJzDJJUvGciG/la801ZrfojpZsmZ/OlXVVrzevQe2EUVg26yuNkQNFfAm6dKKeY jbxI0Y95WbCaAGfwtid/kIfDCXEg/Ay6fkoZ0Eoz0mgpjnIDw77NPhEvhqjDBGVwcaDe +U7YOBmNArqHPo7ESNKc80duK1jecG1rP8fQ5d8iVrLeIGBCzgmDSCXflQoqcVqcGcZm 7TmHGtqJTyQnEK/TNzs/GOQzdlSLuryhn15qXsgYQyE9EiPF8ivez5iYTUi/30lUgYkJ jTuMPIFNJFLfhJBiSjurW4TlzmNoOfHHbP0F9jZ96hGrttmQ/WEDq6v9OoY89QywZSML fWtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wo9cXYZb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si5426846edw.122.2021.06.11.13.40.51; Fri, 11 Jun 2021 13:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wo9cXYZb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231252AbhFKUmq (ORCPT + 8 others); Fri, 11 Jun 2021 16:42:46 -0400 Received: from mail-io1-f53.google.com ([209.85.166.53]:34401 "EHLO mail-io1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbhFKUmp (ORCPT ); Fri, 11 Jun 2021 16:42:45 -0400 Received: by mail-io1-f53.google.com with SMTP id 5so32537677ioe.1 for ; Fri, 11 Jun 2021 13:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z0A+YtYYWtQRN8MlN4WVvuoWz4M6oSYiKKNYu0qWiDA=; b=wo9cXYZbVuFxh3CDGsdFw8LnYdW3uf+eRWxgzq3HzB968kH2vUe35g5BHDVBgPunE3 tbu3xLi1hKg9vBnHtq28AhNTRpL6kMtIv3b9hADDJhdPjCVPC/s3D3UAYsICETAcDAZT +Qm6nZSIPtPrVUGqn1k7Ev8JplC6B6gv6KsHTLFh1JEbsWwTC3yVGYRayIyFE5fqrwJv V5yj58HUvEY3OxWD40N4AJwBRdi93eXm4LaJmDSNahs2Fl2yLDGaO3b2PgPwKPDPeD66 eRUrpHjsFwlnlpsSaPJh+pzOXRoWl6cHceXrdLnYVaGaZG6xMHWxRSD1agHXTKqM2WeM h8fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z0A+YtYYWtQRN8MlN4WVvuoWz4M6oSYiKKNYu0qWiDA=; b=mcBaeR1L0xgyVAtbZegRZUQGX+Y+NgYt5dski9ZAI3QuXUz8wuwMprkvMBSUcdHLWN QHI3vYEgKxza+uAFNro5l6pjMxQDRul+H/OVWGzkVE2wkgT8zJtCtpRDVx6QUxgiv+Bi LFXHtxSdX1+460yEg33qMjm5xXmFZBeAEBtxGPZjEwV39IUnjUQRrS08DhAeHxgrv1Ch vCkaecrSco8JbmG7Rz8Zb7qKRJCWqYAvOQ10t/PFqzLJaw4BzTi0Fbsms3pbbRgHpQnS ZB0lF/T4rz9DsNvLXlQCYbpRou1h5LUdXkk7uDjCRklwn77Nr2exNHts2FNlsiyZYaER OoBw== X-Gm-Message-State: AOAM533xpgKFRPxMxxIqeJlIu81gGuDuyHnYMFx977pr5zZcByuGi72q RfGMfkiLQpfkQHvZ6+rJxmgcqA== X-Received: by 2002:a02:8784:: with SMTP id t4mr5462367jai.26.1623443986819; Fri, 11 Jun 2021 13:39:46 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y9sm3761544ilp.58.2021.06.11.13.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:39:46 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: leon@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, aleksander@aleksander.es, ejcaruso@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] net: ipa: introduce sysfs code Date: Fri, 11 Jun 2021 15:39:40 -0500 Message-Id: <20210611203940.3171057-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611203940.3171057-1-elder@linaro.org> References: <20210611203940.3171057-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add IPA device attributes to expose information known by the IPA driver about the hardware and its configuration. All pointers used to display these attribute values (i.e., IPA pointer and endpoint pointers) will have been initialized by the time IPA probe has completed, so they may be safely dereferenced. Signed-off-by: Alex Elder --- .../testing/sysfs-devices-platform-soc-ipa | 78 ++++++++++ drivers/net/ipa/Makefile | 3 +- drivers/net/ipa/ipa_main.c | 9 ++ drivers/net/ipa/ipa_sysfs.c | 136 ++++++++++++++++++ drivers/net/ipa/ipa_sysfs.h | 15 ++ drivers/net/ipa/ipa_version.h | 2 + 6 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-platform-soc-ipa create mode 100644 drivers/net/ipa/ipa_sysfs.c create mode 100644 drivers/net/ipa/ipa_sysfs.h -- 2.27.0 diff --git a/Documentation/ABI/testing/sysfs-devices-platform-soc-ipa b/Documentation/ABI/testing/sysfs-devices-platform-soc-ipa new file mode 100644 index 0000000000000..c56dcf15bf29d --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-platform-soc-ipa @@ -0,0 +1,78 @@ +What: /sys/devices/platform/soc@X/XXXXXXX.ipa/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The /sys/devices/platform/soc@X/XXXXXXX.ipa/ directory + contains read-only attributes exposing information about + an IPA device. The X values could vary, but are typically + "soc@0/1e40000.ipa". + +What: .../XXXXXXX.ipa/version +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/version file contains the IPA hardware + version, as a period-separated set of two or three integers + (e.g., "3.5.1" or "4.2"). + +What: .../XXXXXXX.ipa/feature/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/feature/ directory contains a set of + attributes describing features implemented by the IPA + hardware. + +What: .../XXXXXXX.ipa/feature/rx_offload +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/feature/rx_offload file contains a + string indicating the type of receive checksum offload + that is supported by the hardware. The possible values + are "MAPv4" or "MAPv5". + +What: .../XXXXXXX.ipa/feature/tx_offload +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/feature/tx_offload file contains a + string indicating the type of transmit checksum offload + that is supported by the hardware. The possible values + are "MAPv4" or "MAPv5". + +What: .../XXXXXXX.ipa/modem/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/modem/ directory contains a set of + attributes describing properties of the modem execution + environment reachable by the IPA hardware. + +What: .../XXXXXXX.ipa/modem/rx_endpoint_id +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/feature/rx_endpoint_id file contains + the AP endpoint ID that receives packets originating from + the modem execution environment. The "rx" is from the + perspective of the AP; this endpoint is considered an "IPA + producer". An endpoint ID is a small unsigned integer. + +What: .../XXXXXXX.ipa/modem/tx_endpoint_id +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder +Description: + The .../XXXXXXX.ipa/feature/tx_endpoint_id file contains + the AP endpoint ID used to transmit packets destined for + the modem execution environment. The "tx" is from the + perspective of the AP; this endpoint is considered an "IPA + consumer". An endpoint ID is a small unsigned integer. diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile index 1efe1a88104b3..bd34fce8f6e63 100644 --- a/drivers/net/ipa/Makefile +++ b/drivers/net/ipa/Makefile @@ -7,7 +7,8 @@ ipa-y := ipa_main.o ipa_clock.o ipa_reg.o ipa_mem.o \ ipa_table.o ipa_interrupt.o gsi.o gsi_trans.o \ ipa_gsi.o ipa_smp2p.o ipa_uc.o \ ipa_endpoint.o ipa_cmd.o ipa_modem.o \ - ipa_resource.o ipa_qmi.o ipa_qmi_msg.o + ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \ + ipa_sysfs.o ipa-y += ipa_data-v3.5.1.o ipa_data-v4.2.o \ ipa_data-v4.5.o ipa_data-v4.9.o \ diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index cbd39e4667a32..2243e3e5b7ea4 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -31,6 +31,7 @@ #include "ipa_uc.h" #include "ipa_interrupt.h" #include "gsi_trans.h" +#include "ipa_sysfs.h" /** * DOC: The IP Accelerator @@ -906,6 +907,13 @@ static const struct dev_pm_ops ipa_pm_ops = { .resume = ipa_resume, }; +static const struct attribute_group *ipa_attribute_groups[] = { + &ipa_attribute_group, + &ipa_feature_attribute_group, + &ipa_modem_attribute_group, + NULL, +}; + static struct platform_driver ipa_driver = { .probe = ipa_probe, .remove = ipa_remove, @@ -914,6 +922,7 @@ static struct platform_driver ipa_driver = { .name = "ipa", .pm = &ipa_pm_ops, .of_match_table = ipa_match, + .dev_groups = ipa_attribute_groups, }, }; diff --git a/drivers/net/ipa/ipa_sysfs.c b/drivers/net/ipa/ipa_sysfs.c new file mode 100644 index 0000000000000..ff61dbdd70d8c --- /dev/null +++ b/drivers/net/ipa/ipa_sysfs.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Copyright (C) 2021 Linaro Ltd. */ + +#include +#include +#include +#include + +#include "ipa.h" +#include "ipa_version.h" +#include "ipa_sysfs.h" + +static const char *ipa_version_string(struct ipa *ipa) +{ + switch (ipa->version) { + case IPA_VERSION_3_0: + return "3.0"; + case IPA_VERSION_3_1: + return "3.1"; + case IPA_VERSION_3_5: + return "3.5"; + case IPA_VERSION_3_5_1: + return "3.5.1"; + case IPA_VERSION_4_0: + return "4.0"; + case IPA_VERSION_4_1: + return "4.1"; + case IPA_VERSION_4_2: + return "4.2"; + case IPA_VERSION_4_5: + return "4.5"; + case IPA_VERSION_4_7: + return "4.7"; + case IPA_VERSION_4_9: + return "4.9"; + case IPA_VERSION_4_11: + return "4.11"; + default: + return "0.0"; /* Won't happen (checked at probe time) */ + } +} + +static ssize_t +version_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_version_string(ipa)); +} + +static DEVICE_ATTR_RO(version); + +static struct attribute *ipa_attrs[] = { + &dev_attr_version.attr, + NULL +}; + +const struct attribute_group ipa_attribute_group = { + .attrs = ipa_attrs, +}; + +static const char *ipa_offload_string(struct ipa *ipa) +{ + return ipa->version < IPA_VERSION_4_5 ? "MAPv4" : "MAPv5"; +} + +static ssize_t rx_offload_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa)); +} + +static DEVICE_ATTR_RO(rx_offload); + +static ssize_t tx_offload_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa)); +} + +static DEVICE_ATTR_RO(tx_offload); + +static struct attribute *ipa_feature_attrs[] = { + &dev_attr_rx_offload.attr, + &dev_attr_tx_offload.attr, + NULL +}; + +const struct attribute_group ipa_feature_attribute_group = { + .name = "feature", + .attrs = ipa_feature_attrs, +}; + +static ssize_t +ipa_endpoint_id_show(struct ipa *ipa, char *buf, enum ipa_endpoint_name name) +{ + u32 endpoint_id = ipa->name_map[name]->endpoint_id; + + return scnprintf(buf, PAGE_SIZE, "%u\n", endpoint_id); +} + +static ssize_t rx_endpoint_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + return ipa_endpoint_id_show(ipa, buf, IPA_ENDPOINT_AP_MODEM_RX); +} + +static DEVICE_ATTR_RO(rx_endpoint_id); + +static ssize_t tx_endpoint_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + return ipa_endpoint_id_show(ipa, buf, IPA_ENDPOINT_AP_MODEM_TX); +} + +static DEVICE_ATTR_RO(tx_endpoint_id); + +static struct attribute *ipa_modem_attrs[] = { + &dev_attr_rx_endpoint_id.attr, + &dev_attr_tx_endpoint_id.attr, + NULL +}; + +const struct attribute_group ipa_modem_attribute_group = { + .name = "modem", + .attrs = ipa_modem_attrs, +}; diff --git a/drivers/net/ipa/ipa_sysfs.h b/drivers/net/ipa/ipa_sysfs.h new file mode 100644 index 0000000000000..b34e5650bf8cd --- /dev/null +++ b/drivers/net/ipa/ipa_sysfs.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. + * Copyright (C) 2019-2021 Linaro Ltd. + */ +#ifndef _IPA_SYSFS_H_ +#define _IPA_SYSFS_H_ + +struct attribute_group; + +extern const struct attribute_group ipa_attribute_group; +extern const struct attribute_group ipa_feature_attribute_group; +extern const struct attribute_group ipa_modem_attribute_group; + +#endif /* _IPA_SYSFS_H_ */ diff --git a/drivers/net/ipa/ipa_version.h b/drivers/net/ipa/ipa_version.h index ee2b3d02f3cd3..6c16c895d8429 100644 --- a/drivers/net/ipa/ipa_version.h +++ b/drivers/net/ipa/ipa_version.h @@ -21,6 +21,8 @@ * @IPA_VERSION_4_11: IPA version 4.11/GSI version 2.11 (2.1.1) * * Defines the version of IPA (and GSI) hardware present on the platform. + * Please update ipa_version_valid() and ipa_version_string() whenever a + * new version is added. */ enum ipa_version { IPA_VERSION_3_0,