From patchwork Thu Apr 18 20:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789859 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp748099wrm; Thu, 18 Apr 2024 13:05:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXM7ssukhdwNk3rC8XIUooywwZlJb4V10qd8GtA+FViTjesqHiME7cEGmfcpFEvijcf88WG8UaAlFltDL1TOJJy X-Google-Smtp-Source: AGHT+IFQDGBLNbPEOdAlvqaVAMuPtkibCAzIVMLAlAIQGqRciW3fJkA48U055iT4wZE4S5fjOMW3 X-Received: by 2002:a05:6358:1902:b0:186:1805:c6c2 with SMTP id w2-20020a056358190200b001861805c6c2mr397673rwm.0.1713470727359; Thu, 18 Apr 2024 13:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713470727; cv=none; d=google.com; s=arc-20160816; b=ssrTxtD8IlkUTcMwsdBUpWG9MkhmXJlfBgEZxS+uhonnKtCvjwUQDquUDVKI9sjrOV wCVTe8jNLMr5LesAITmKcuP0Vi30soC2+9aXDRDjwjFMV+A9iAJfpvWrD5z/+uC5SbLo jkSG6QnkpAa/wBZJEVXkiUbECnU9W41YHgW2vTf2//qAOFXhcXWFBgtJU9wUYy60eAwH veOV6oaZrIp8GMpNCHm+oDR98z2lmF6zbm9CrmGEwwqowSGqCwzE7Y8whE6/Ca8Y+1SI 44tG0U5YLfdqQEXWXFP/+Y6w4bK0za4NJI5EWv0UYjAONpvg+L1ZJrZjpbgFwAe5LAEz hShA== 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=1tzZTrBEzsoBY4O0+LL4pDGANfHz8watBAaqbKbs4UA=; fh=m04Zw7Rd3szriI+fwMSRTbsn9jEhMzlDh3fvULRyulY=; b=1KGhKFurilRxdXObytkoP8v2sRZRFydpNBzuNMj/Q1WezFspqNp31EtCEv38qcZmIW hQ1SVBNwSTd0duRHq5RKRqSLqmz9pwz9SYTf8J/XcGjnEu1buQFAw31NJsfDzSRIyMcW 0IPWl5GIUoqgdKPbFxxYuqaYjyy4pq2na15iu3bZgCV2Mw/Z/Lk28ICs4zhdPhcRjmku RJthKM9bMPm6DufpbaaFPg8+ppIRM4cSQHhhoU8rN6p3cqYdbifIgUMkVoA+sbq1yMXR ulcVSHFrI6MjZkPvLYQKn4hSYMuVaC7V/rSGC185G170ct1Prft8RCKvtnHV2X8rUYdY Om6g==; 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 gc12-20020a056214230c00b0069b55db0afdsi2186752qvb.442.2024.04.18.13.05.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 13:05:27 -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 1rxXyj-0001qV-8W; Thu, 18 Apr 2024 16:03:29 -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 1rxXyg-0001p5-Ei; Thu, 18 Apr 2024 16:03:26 -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 1rxXye-0005R2-Qf; Thu, 18 Apr 2024 16:03:26 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 285545FE16; Thu, 18 Apr 2024 23:02:28 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 894A2B93FC; Thu, 18 Apr 2024 23:02:25 +0300 (MSK) Received: (nullmailer pid 952882 invoked by uid 1000); Thu, 18 Apr 2024 20:02:24 -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-7.2.11 55/59] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition Date: Thu, 18 Apr 2024 23:02:15 +0300 Message-Id: <20240418200224.952785-14-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 bf81c84984..f269d72d9e 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -155,6 +155,12 @@ do { fprintf(stderr, "lan9118: error: " 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, @@ -171,7 +177,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 = { @@ -187,7 +193,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() } }; @@ -549,7 +555,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; }