From patchwork Mon Sep 18 19:50:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9957561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35A49601E9 for ; Mon, 18 Sep 2017 19:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2821728D6A for ; Mon, 18 Sep 2017 19:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C9EB28D6E; Mon, 18 Sep 2017 19:56:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1600528D6B for ; Mon, 18 Sep 2017 19:56:20 +0000 (UTC) Received: from localhost ([::1]:38630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du29T-0001TB-4U for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Sep 2017 15:56:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du24u-0006pz-CU for qemu-devel@nongnu.org; Mon, 18 Sep 2017 15:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1du24t-0006Ir-DO for qemu-devel@nongnu.org; Mon, 18 Sep 2017 15:51:36 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:34992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1du24r-0006Gs-1T; Mon, 18 Sep 2017 15:51:33 -0400 Received: by mail-pg0-x241.google.com with SMTP id j16so775197pga.2; Mon, 18 Sep 2017 12:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gosmns9ewTlxveN5Eu1UJHKyNHtlDRa4EATGzSoL4Do=; b=Ak+/3gYS5Hi/JBHz/t2OZcadyj1fGAo1yHscBfyCu+TpbomGTu2wg7EVlanoixcYyc W9OzKggA1fHgQZR5QBp0ZoqvPJJN1MU9j1GsB9lF+wNQzyDvpTM9yvXVORpULLAUQIH+ gQGtOhVqFOzV2zEh33tW+ZQ5ZlG8BVFWC0KXBNstOSYtdOO+YB4yTHhM3cOP7l9saNUm bPWgelT1B3IQrIuT9nEMee7t7m4wE7jf+EzCrxVlL1N7fh6sp+7Q4y46HK63GCFL9Np1 kdZR+zL6HDPF5ZnbgU0jotfUGd1sTlWtnJQoBPUoehYyDO7JG3kg+dW2LjUau4/dNRSX nslQ== 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; bh=gosmns9ewTlxveN5Eu1UJHKyNHtlDRa4EATGzSoL4Do=; b=q/nq7rJl+/qnBltduBbMdVWxryVSsggwPqfmCZ4AThnOzlcE8TbNxOxrs+NLrZ45iL 45B3/s/MdLwrO0K7j9Hw8YrjRKROP7p2RoZTjY9hvmqfeXLihFiudJrgWpKZPe/xtyKs 3z5q2ojPTbeE5INRv5EYak9oAKqivTaPkIS5xWgCLJlhyOvUQ+iLxSa4uvClNilPvUWO MfR+wOwFjrih7jzzG3vZtfk1cSGUCB06BanSsbAuSw5hSmgYeO/wlb2f4CsGefEplnSk XH4ZLcpHttxIge1JQFwW3Fa2/wJiYVfHK7EQsjMLYKOy0Z59Qf+ldIclbb1+58WDxW7/ zedQ== X-Gm-Message-State: AHPjjUggZLlgx0cOBfi+iyaw0IDk37zqs6MHVO62aV9tnq+OhzTBgZEH akTrp3iMgvJduYe1vk8= X-Google-Smtp-Source: ADKCNb5zgtJorYeSnDmcyNQoXvc0jzRlTJM3+lqwjno2BXj8kx7Lk9EJae4kuMnJrOglqGK1JYADIA== X-Received: by 10.84.129.193 with SMTP id b59mr36779462plb.88.1505764291848; Mon, 18 Sep 2017 12:51:31 -0700 (PDT) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id d186sm200791pfd.117.2017.09.18.12.51.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2017 12:51:31 -0700 (PDT) From: Andrey Smirnov To: qemu-arm@nongnu.org Date: Mon, 18 Sep 2017 12:50:50 -0700 Message-Id: <20170918195100.17593-8-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170918195100.17593-1-andrew.smirnov@gmail.com> References: <20170918195100.17593-1-andrew.smirnov@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH 07/17] imx_fec: Emulate SHIFT16 in ENETx_RACC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Smirnov , Peter Maydell , Jason Wang , qemu-devel@nongnu.org, yurovsky@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Needed to support latest Linux kernel driver which relies on that functionality. Cc: Peter Maydell Cc: Jason Wang Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Cc: yurovsky@gmail.com Signed-off-by: Andrey Smirnov Reviewed-by: Peter Maydell --- hw/net/imx_fec.c | 23 +++++++++++++++++++++++ include/hw/net/imx_fec.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 8a77136d38..bd62d7a75f 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -1037,6 +1037,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, uint32_t buf_addr; unsigned int buf_len; size_t size = len; + bool shift16 = s->regs[ENET_RACC] & ENET_RACC_SHIFT16; FEC_PRINTF("len %d\n", (int)size); @@ -1049,6 +1050,10 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, /* 4 bytes for the CRC. */ size += 4; + if (shift16) { + size += 2; + } + /* Huge frames are truncted. */ if (size > s->regs[ENET_FTRL]) { size = s->regs[ENET_FTRL]; @@ -1085,6 +1090,24 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, buf_len += size - 4; } buf_addr = bd.data; + + if (shift16) { + /* + * If SHIFT16 bit of ENETx_RACC register is set we need to + * align the payload to 4-byte boundary. + */ + const uint8_t zeros[2] = { 0 }; + + dma_memory_write(&address_space_memory, buf_addr, + zeros, sizeof(zeros)); + + buf_addr += sizeof(zeros); + buf_len -= sizeof(zeros); + + shift16 = false; /* We only do this once per Ethernet + * frame */ + } + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); buf += buf_len; if (size < 4) { diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h index 4bc8f03ec2..20a6aa98b4 100644 --- a/include/hw/net/imx_fec.h +++ b/include/hw/net/imx_fec.h @@ -169,6 +169,8 @@ #define ENET_TWFR_TFWR_LENGTH (6) #define ENET_TWFR_STRFWD (1 << 8) +#define ENET_RACC_SHIFT16 BIT(7) + /* Buffer Descriptor. */ typedef struct { uint16_t length;