Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753419AbdLHMsJ (ORCPT ); Fri, 8 Dec 2017 07:48:09 -0500 Received: from mail-bl2nam02on0050.outbound.protection.outlook.com ([104.47.38.50]:47564 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752884AbdLHMsB (ORCPT ); Fri, 8 Dec 2017 07:48:01 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Ioana Radulescu To: CC: , , Subject: [PATCH 1/6] staging: fsl-dpaa2/eth: Fix access to FAS field Date: Fri, 8 Dec 2017 06:47:53 -0600 Message-ID: <20171208124758.2732-2-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171208124758.2732-1-ruxandra.radulescu@nxp.com> References: <20171208124758.2732-1-ruxandra.radulescu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131572108772014503;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(336005)(7966004)(376002)(39860400002)(346002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(105606002)(106466001)(85426001)(68736007)(33646002)(1076002)(356003)(8656006)(36756003)(2906002)(50466002)(48376002)(104016004)(8676002)(6916009)(2950100002)(86362001)(6666003)(305945005)(4326008)(77096006)(54906003)(81156014)(81166006)(76176011)(5660300001)(8936002)(50226002)(97736004)(498600001)(2351001)(16586007)(51416003)(53936002)(47776003)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2692;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD017;1:5HtYJh4TnjJzBeMc/kPHg4U06nRjlXBnt5/0E/ThqKqSGEKqtAFjdudlmjgbb3XnnF1LvpieSVJTo7WKHhu0kDbLZmQykYsw7d6FPqLcUjOMcwsiH4FJnWmkJuA7+plH MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f2a41c8-2cc0-4eda-79a7-08d53e39e82b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603307);SRVR:BN6PR03MB2692; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2692;3:+OqJLnWwQkELPADUI3M0aio2g1T6nMpdQBzpuO6fyNJyhPjI2Un86Mupx0O4IFgmqykK03UtFS7Lj+NWbtjFqSmxS4uD1UOvKFRUIxYKv4zy8TIV3kVORh4lGmwUwpLPZHWc18nbN2hGHuUxw8fGwN1EbJpn00fBjyQiHBeiiKx8KsKk2e4gt2eGhq6F3EM66H6r7nkh5RaXaA5Grb55s9V2H6D2wr7UK5LJRqNI7V71wAB5Ol1hBQuqdet7v+ZVAvQLPK7XRgDZz66bbkzOhtLrCC6ziWqLFbyfRFr/A84j4z36dvVBAkrtgug5VQ3zDGZtVaj6C+Qb1ks+dLoi4Zhn+dst/uCn3X0RmJgx82o=;25:6o7RnxqMnuvTDCSW1nVFtQBilon/2q36a/A8OcliOOYIbjl9mwB7NwfyM7IseV/FqfIv9rlbEca0oygNhS5Jrb7yx4cSMlleCXBzFxvH3KbIqOp2quyfJnQojSLBjY6XVNdVoA8gX0n54JJfHRTg4qQo5gbj3Zr6nEmlBtJiCyl7ovgeHX5xF/Yn3/rVAiDz3mEYEQOzaQbmxvOU9WgWBrlRBZk1TI03Pegj6ytRkt3ufrkTvPLVR1r/fuyuoJ9OWH6fcqyHfLXFxPs7TTs4egF4/709g8/gwVkh7ngSX5FJD9AxST4QUge7DlAfb/pzxpcXgU9PYJD/wFU4p2d+pQ== X-MS-TrafficTypeDiagnostic: BN6PR03MB2692: X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2692;31:qOjmhTfwQbsmo52eS5tnRYLU8VfDZLgKtVu1csySA9HrOgLIceqZ8Hc8wUU3tEErgeXRuA8v2bCp7ldZst2oLPMTGfFujUYNtTO7GyNEoVdGfysH+zgIHG3rFHAHXCqmt6Vk47nb969FBcNzVqzBIK3wLz8JObgMHxL1ErUJvcXzYRWaKrrPnwcJb4g/PsR51okIOHgbQh2idOdo707KvJ6QhxZlBmXtLwuhDHdZYzE=;4:K/gx3bSptX+N8wCZ4uNaLLEpXhvBGGr2z3ugCWeFzsSrq4zuoFl8eeSa1ry2S4i7xRakNOGOxPL8jGJpzXIUi3/f0B7H2f3lhsYtx6OrcGt3hnzMaB3RtctHZKYtKEFK2PDamhiqpFgXBlxWrpwBQC8S3fO9vqc8hfVMD61/vDS9mGym1TLD3Ts+8eIZiikGk4c3YvB0k3ChAc6xNNZn6OcsopcwPgTLdswBhi2SNhLSEOtUhYzNMw7TsYKfMZl31OlQtcAixv8wztRYGrWCuXYuULB3ZAmcVj7HclS6AYc0IRJHJGJxS5Fv24kxTosM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231022)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123563025)(20161123561025)(20161123559100)(20161123565025)(201708071742011);SRVR:BN6PR03MB2692;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:BN6PR03MB2692; X-Forefront-PRVS: 0515208626 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR03MB2692;23:qnUfE6UUIrbh+cAqKCaF47nuFgF8sDwsYjy4bYfGb?= =?us-ascii?Q?8cf0oHiw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3QkvpYu3EUBROf+8xXPerxiamX/vviRYJWYth4V6+U1hT2842uP1IGcbLRRpOGUH+i/6742Dd6zHukUyhXEg/bPfcGckLRXFcsUz2YC+CIMMW0CTPN9geMI2rK/aC+RFg4EVLi/R2 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2017 12:47:57.0142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f2a41c8-2cc0-4eda-79a7-08d53e39e82b X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2692 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3477 Lines: 86 Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers") removes the software annotation (SWA) area from the RX buffer layout, as it's not used by anyone, but fails to update the macros for accessing hardware annotation (HWA) fields, which is right after the SWA in the buffer headroom. This may lead to some frame annotation status fields (e.g. indication if L3/L4 checksum is valid) to be read incorrectly. Turn the accessor macros into inline functions and add a bool param to specify if SWA is present or not. Fixes: 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers") Signed-off-by: Ioana Radulescu --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 8 ++++---- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 0d8ed00..c8a8e3a 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -249,7 +249,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr); dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE); - fas = dpaa2_get_fas(vaddr); + fas = dpaa2_get_fas(vaddr, false); prefetch(fas); buf_data = vaddr + dpaa2_fd_get_offset(fd); prefetch(buf_data); @@ -385,7 +385,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv, * on TX confirmation. We are clearing FAS (Frame Annotation Status) * field from the hardware annotation area */ - fas = dpaa2_get_fas(sgt_buf); + fas = dpaa2_get_fas(sgt_buf, true); memset(fas, 0, DPAA2_FAS_SIZE); sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); @@ -458,7 +458,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, * on TX confirmation. We are clearing FAS (Frame Annotation Status) * field from the hardware annotation area */ - fas = dpaa2_get_fas(buffer_start); + fas = dpaa2_get_fas(buffer_start, true); memset(fas, 0, DPAA2_FAS_SIZE); /* Store a backpointer to the skb at the beginning of the buffer @@ -510,7 +510,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, fd_addr = dpaa2_fd_get_addr(fd); skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr); - fas = dpaa2_get_fas(skbh); + fas = dpaa2_get_fas(skbh, true); if (fd_format == dpaa2_fd_single) { skb = *skbh; diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 5b3ab9f..3a4e939 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -153,10 +153,15 @@ struct dpaa2_fas { #define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas)) /* Accessors for the hardware annotation fields that we use */ -#define dpaa2_get_hwa(buf_addr) \ - ((void *)(buf_addr) + DPAA2_ETH_SWA_SIZE) -#define dpaa2_get_fas(buf_addr) \ - (struct dpaa2_fas *)(dpaa2_get_hwa(buf_addr) + DPAA2_FAS_OFFSET) +static inline void *dpaa2_get_hwa(void *buf_addr, bool swa) +{ + return buf_addr + (swa ? DPAA2_ETH_SWA_SIZE : 0); +} + +static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa) +{ + return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET; +} /* Error and status bits in the frame annotation status word */ /* Debug frame, otherwise supposed to be discarded */ -- 2.7.4