From patchwork Tue Jan 2 19:36:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10141275 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 64B266035E for ; Tue, 2 Jan 2018 19:41:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52DC528E0D for ; Tue, 2 Jan 2018 19:41:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45D3528E1C; Tue, 2 Jan 2018 19:41:33 +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 AF89528E0D for ; Tue, 2 Jan 2018 19:41:32 +0000 (UTC) Received: from localhost ([::1]:52937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWSRI-0007HN-0Z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Jan 2018 14:41:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWSMe-0003Hb-Bc for qemu-devel@nongnu.org; Tue, 02 Jan 2018 14:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWSMd-0000MT-9M for qemu-devel@nongnu.org; Tue, 02 Jan 2018 14:36:44 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40889) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWSMa-0000Iq-7u; Tue, 02 Jan 2018 14:36:40 -0500 Received: by mail-pf0-x242.google.com with SMTP id v26so26019699pfl.7; Tue, 02 Jan 2018 11:36:40 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=kMa8TkEq3z2Qro3C9PTAL2M+BRkC3wXbaQ/oArzF9YE=; b=gLlZpOjvZ0dsWOlw6ifphKR698mV7MyfhRQlEQbgtx1hOBy6t947PHLQNzW08QcjHK sh1zO7ykRwQdk1S3mEZvy+89vgyK8dmOPcOPSrEZcvGcqFN+iZnw7QoqrWkpAmpAQOVe lFYiz/8MGURmuzq9c01qdfbP0S53mjbsyE8T41uxXimS3sp2AqKbNw9YRMb1ws2Fen8s pEqWLmK7mEIOy9SWx4WTEKfMebEFvtozZU+T/fhyEk6EJAkNc9ZN0slF2f2n58UQUpuK KWMsZvWmTfVtohWHv0qi34Yamo0WgwaTzEXHNJFXg94PtH+tzBFs7WGWAIdvXlnABFlQ YIgA== 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=kMa8TkEq3z2Qro3C9PTAL2M+BRkC3wXbaQ/oArzF9YE=; b=EfdEVbFcUPF1RbDxAR/6leM477KJ1GWlPb7C6ukYIl+el4wwJGb4O0xs+rFHZxs+Q7 xmDWNfbEBrGwEkwiZ43PXZWwabqf8DUxFZZNat7kxdEu2Ovv3Kozgt6GsCQPuL9Wub1i 69ZJdaGw2OdjAIov4ibVRXCfnt+Bx3X+LfJ3UOXFba268h7LUHbZw9MM4kTtfk4jOqgA XXfkv20qaiMJJ2b3knlHJpjQW3RfY9tD1lT5CUxa8DTGQ5OXTmAOhfTZJPzjBJney4q4 Hs7CAg0VFPMVPyd8zrbvm/tUz8rdtmgYx+3m7Cfl6GUKDS6msb06BsR/1dLnYtBAwI4s M6CA== X-Gm-Message-State: AKGB3mI5WDgQnQWyZaMIgKUJXi5a4xje9DaHPJ6Rw4vdJ7o0iX7IIzY5 CIGw5QNOY5FPAqjWA356ZvOMesTINQA= X-Google-Smtp-Source: ACJfBouwCCoSojcL0luzl/hxJPv73XO6C+ePw6T8JSaSEHf64oOWv1HYmrqT9qBfFwZ39qo7zg39gQ== X-Received: by 10.98.78.204 with SMTP id c195mr46812931pfb.51.1514921799087; Tue, 02 Jan 2018 11:36:39 -0800 (PST) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id g9sm97905951pfk.0.2018.01.02.11.36.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jan 2018 11:36:38 -0800 (PST) From: Andrey Smirnov To: qemu-arm@nongnu.org Date: Tue, 2 Jan 2018 11:36:16 -0800 Message-Id: <20180102193622.27215-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180102193622.27215-1-andrew.smirnov@gmail.com> References: <20180102193622.27215-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 05/11] imx_fec: Use ENET_FTRL to determine truncation length 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: Peter Maydell , Andrey Smirnov , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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 Frame truncation length, TRUNC_FL, is determined by the contents of ENET_FTRL register, so convert the code to use it instead of a hardcoded constant. To avoid the case where TRUNC_FL is greater that ENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K. Cc: Peter Maydell Cc: Jason Wang Cc: Philippe Mathieu-Daudé 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 | 4 ++-- include/hw/net/imx_fec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 56cb72273c..50da91bf9e 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -1052,8 +1052,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc_ptr = (uint8_t *) &crc; /* Huge frames are truncted. */ - if (size > ENET_MAX_FRAME_SIZE) { - size = ENET_MAX_FRAME_SIZE; + if (size > s->regs[ENET_FTRL]) { + size = s->regs[ENET_FTRL]; flags |= ENET_BD_TR | ENET_BD_LG; } diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h index 67993870a2..a390d704a6 100644 --- a/include/hw/net/imx_fec.h +++ b/include/hw/net/imx_fec.h @@ -86,7 +86,6 @@ #define ENET_TCCR3 393 #define ENET_MAX 400 -#define ENET_MAX_FRAME_SIZE 2032 /* EIR and EIMR */ #define ENET_INT_HB (1 << 31) @@ -155,6 +154,8 @@ #define ENET_RCR_NLC (1 << 30) #define ENET_RCR_GRS (1 << 31) +#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH) + /* TCR */ #define ENET_TCR_GTS (1 << 0) #define ENET_TCR_FDEN (1 << 2)