From patchwork Thu Apr 18 17:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789821 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp696017wrm; Thu, 18 Apr 2024 10:54:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUhy26HX4sQl7lgWVUAaQeVGo9RIwToKKKmQcc4Q8tAVOBWZxa6JLrEfWcqv+tFESGCvffsVDLMTFq3Wy+GJzBt X-Google-Smtp-Source: AGHT+IFKwh0//mzievRr8qFmyNa9e5HsSdV+Il4vUd/kwC6RY3aiyT1PUjQDB0e71zuXGhAfrFsL X-Received: by 2002:a05:6214:5610:b0:699:4c5e:8a9a with SMTP id mg16-20020a056214561000b006994c5e8a9amr3837444qvb.51.1713462865102; Thu, 18 Apr 2024 10:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713462865; cv=none; d=google.com; s=arc-20160816; b=ivQM+crcRYCRTtuya7wgM+pmdy0Ox/uwPZOnxYTI3PNBVit25WmaN2LCu+XDdJTZEi 1tUDZHGZeOU+zyHbOwH6shRxjPx/StO7IsliOkyTDpRfqYPZO5Ab/BAsPNqkHEA1Ctii HPjAw3bW3OFYcJds5+974QSNtjXR1pEiZCzbBDpWclBtxXEPGfU6ioLo4/BV8GZyj/7u ZCB20p/wLpiqNTekFVcfFg3MG2yqmNawRGhg/wo/SwEJ2k771PV66Q90R/qPPTh/6xvy WSle/U9u4Z66MajN6ffAXxZtPwxwEOrt+KR4F+IThVIhfYpRxtzNqA+j4beesL5QHHiv 7/Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=wA+hxFxLpBgP3NG1nmemhWBrgWC8+gkPwTe7jrVF6yk=; fh=m04Zw7Rd3szriI+fwMSRTbsn9jEhMzlDh3fvULRyulY=; b=fqmYfPLPrZr6VQW/AsbzbwRQIouWwWmIQAdoiBOQV+jrrlSIvx2IeINkI4USulGpb0 xO/PZi6dxeFdAi41wcG7W499kzVsWOzedz9Wd9+2R26AsxY6H0uKEYD/AcFvSd8hiIOk 4zK8A13OFk2u6yKCdm99MdwouaeZAP02CcRNOu1lF40HY7VGIF6eP3floofxYLwZ9u1J ucQI4CS+f1ZaZEjDnoLXBVml/i5rdXlrbQkZswf+bGN39GmtoO2jLyOWZOxzsYW4yMXd /oFqfcJyclxbVGhYsDxRylQz3+52/GaN3q0MGmdwiJ4FtSc8hpIYjQGVTjQBfuH1QwkU ftxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 8-20020a05621420a800b0069b5208c37fsi1874055qvd.491.2024.04.18.10.54.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 10:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxVuv-0001kY-C0; Thu, 18 Apr 2024 13:51:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxVum-0001T2-46; Thu, 18 Apr 2024 13:51:16 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxVuj-0007ef-VC; Thu, 18 Apr 2024 13:51:15 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id CB6FA5FD73; Thu, 18 Apr 2024 20:50:03 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 3BE41B934D; Thu, 18 Apr 2024 20:50:01 +0300 (MSK) Received: (nullmailer pid 947860 invoked by uid 1000); Thu, 18 Apr 2024 17:49:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [Stable-8.2.3 106/116] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition Date: Thu, 18 Apr 2024 20:49:36 +0300 Message-Id: <20240418174955.947730-19-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé The magic 2048 is explained in the LAN9211 datasheet (DS00002414A) in chapter 1.4, "10/100 Ethernet MAC": The MAC Interface Layer (MIL), within the MAC, contains a 2K Byte transmit and a 128 Byte receive FIFO which is separate from the TX and RX FIFOs. [...] Note, the use of the constant in lan9118_receive() reveals that our implementation is using the same buffer for both tx and rx. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20240409133801.23503-2-philmd@linaro.org> (cherry picked from commit a45223467e4e185fff1c76a6483784fa379ded77) Signed-off-by: Michael Tokarev diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index cf7b8c897a..f0a8a3fa10 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -150,6 +150,12 @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0) #define GPT_TIMER_EN 0x20000000 +/* + * The MAC Interface Layer (MIL), within the MAC, contains a 2K Byte transmit + * and a 128 Byte receive FIFO which is separate from the TX and RX FIFOs. + */ +#define MIL_TXFIFO_SIZE 2048 + enum tx_state { TX_IDLE, TX_B, @@ -166,7 +172,7 @@ typedef struct { int32_t pad; int32_t fifo_used; int32_t len; - uint8_t data[2048]; + uint8_t data[MIL_TXFIFO_SIZE]; } LAN9118Packet; static const VMStateDescription vmstate_lan9118_packet = { @@ -182,7 +188,7 @@ static const VMStateDescription vmstate_lan9118_packet = { VMSTATE_INT32(pad, LAN9118Packet), VMSTATE_INT32(fifo_used, LAN9118Packet), VMSTATE_INT32(len, LAN9118Packet), - VMSTATE_UINT8_ARRAY(data, LAN9118Packet, 2048), + VMSTATE_UINT8_ARRAY(data, LAN9118Packet, MIL_TXFIFO_SIZE), VMSTATE_END_OF_LIST() } }; @@ -544,7 +550,7 @@ static ssize_t lan9118_receive(NetClientState *nc, const uint8_t *buf, return -1; } - if (size >= 2048 || size < 14) { + if (size >= MIL_TXFIFO_SIZE || size < 14) { return -1; }