From patchwork Tue Apr 9 13:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787200 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221506wrs; Tue, 9 Apr 2024 06:39:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV3dfloCEHTvTpE+kVawB6mI+B3UPKRT7I06bgvI2sfarWnqjl2a1kH9U3Pg77eMz1BdC1sHWWlKjHHD2NVPrmd X-Google-Smtp-Source: AGHT+IFEuj+whL0TP8EoJOEir7goyeUvMM8eGdEJRWbAh+3if2626BlZig3bCURCNSCzOe9khVRR X-Received: by 2002:a05:620a:6d1a:b0:78d:7368:4152 with SMTP id ul26-20020a05620a6d1a00b0078d73684152mr1418417qkn.38.1712669943588; Tue, 09 Apr 2024 06:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669943; cv=none; d=google.com; s=arc-20160816; b=NBlCfsKe6NBS8Qy63JjybbFZUOf15XxTbIZNEI+c+aOgd4HHyYpcYsvRilW/We9W3d jt57cD/mC9g5EU1tnHYAPoOu79FRATQcXg77xNbFoTkTrfwk5uBA4ahtl5ekcNUVnDKX dvoIbxnFMFjjvG5ozD76GjpTvVz+e0gTGyTxEsztk9s8Sdts8VWd5A7mUPwjrORTx/91 VqDMu+d+Dlek9y9VIF85mq7WVe9CFCfTLmF6u4jbNrGM489xdNV2q7NNlwc8uF4HO9f8 m8j4OvvbnkrGP2fdtLXtwUAj9KxtRvzUHMQNUrNPu7zTxLJXMlridOVJRglzYgu5x6xx MOmQ== 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:dkim-signature; bh=EZB+SBD3c6Tl2ilo7C5/8FmcEWLXBUIeUjZwCbvwe1A=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=GWJ/CmBxv8lJX61p8bPWUcxv+5758cv6nuhlrkQoPayjIqeey+jCCEzlomzn/WgwAf uGrWCN41om1uBcX9jhKzQZbgYVcoeb79eIctPKGtOWkLm2v1ctJe+b49rbvB3P9Knnon BFq990lfKadSqao7pW11BrMyKh0QkYiKQOz4D0pEK8n8W5H4c3Kz26fTdOJelAavo2zL iIyL5KfdjeYbv1iyijkdXCHEobcEznXfCWQ0kh9NG9xj/f7T+CA4Mlr0rKpvBZAqQHzw 1HGtA2KK3Z/ia03iVhm+HAhxfO95om1s3n6LzqCIJ4bbrscu8t0efg5E2ymZl84/LA/z eohA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RRetPFKy; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u13-20020a05620a120d00b0078d6e2a14b4si1525098qkj.456.2024.04.09.06.39.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:03 -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; dkim=pass header.i=@linaro.org header.s=google header.b=RRetPFKy; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBfx-0005nn-M7; Tue, 09 Apr 2024 09:38:13 -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 1ruBfw-0005nT-M4 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:12 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBfv-0008B9-0Q for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:12 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-41550858cabso38549225e9.2 for ; Tue, 09 Apr 2024 06:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669889; x=1713274689; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EZB+SBD3c6Tl2ilo7C5/8FmcEWLXBUIeUjZwCbvwe1A=; b=RRetPFKy65vGiYnCsjFXIO0bxwFMbkXL39j00xg/mLDey/hfLYhelWEMfz9Efvacib yFuzEi3btgzt7kbQoVKkL2yMs4hp5/4hrmezaEW2RmG7l2/4WfGX1y1/SJmKFvHEVCkD xl82goS4h+Cb6Fso9HdjXxa8ZX5IrX5qjX3LivBzSOIL3jhfvDeiiJPuSfVbk2G/TEnt oZTIbSXiJ2WTU0LVBv9CCt+pEHiQH1sKzV5qnJQp3YxfG1NZh86HK0fhpcA0mc8cBaQe /gDg42BW4ZzUCp6lCtghtEDPtghqYnLaFDtZ4C/lWrAC055erQmgKJQpbb/HMONys0VR lLEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669889; x=1713274689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EZB+SBD3c6Tl2ilo7C5/8FmcEWLXBUIeUjZwCbvwe1A=; b=nkmQQaXIuyJ7HD1NevmsfyYtff/Od7nFEbQLvxyDHHaB1+4JZ+o5NRB69S+NKLfwS/ x1Gd44vQQRiRtJ7YxJfBUCNhJLnVGG7R9Ik8wceCbysEV7+/AlsQHs4v7xjHBNsIkwUD oVLdudhbhCEKAWWiGGKs/EonMMfRKM4nnhVkV0WHHXvsL3aobfsBaa7+F7alCPkzsK1W Y7TAWWdL6XRju3vS0bSqwNIPIH6FeF4E6PUoKPJ0ipH0maCoj3jP7xhpL8ZRQKDZtH+L oJXDFJU+LGSQMrdIjwOGr3S+Ldmex32TdzOD19m/59ASxywrEY9zgvzBxrb2SDw6AKC+ dQ2g== X-Gm-Message-State: AOJu0YxzhnmRaQXKFyjprREHm75AGIeguwA+ZZwke4cKNvqbF5NFtOuy 4w/b9cq9cA45bB8b4yGTVf6F4IO6ElZNS0Cx+jPCT31fgZFER49Qc1HIyDJGP6o1lRoYHEc1Rmh m X-Received: by 2002:a05:600c:1913:b0:416:2471:e102 with SMTP id j19-20020a05600c191300b004162471e102mr9168921wmq.37.1712669889014; Tue, 09 Apr 2024 06:38:09 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id s11-20020a05600c45cb00b004162d06768bsm18084976wmo.21.2024.04.09.06.38.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 01/11] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition Date: Tue, 9 Apr 2024 15:37:50 +0200 Message-ID: <20240409133801.23503-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 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. [...] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- (Not including Peter R-b from v1 due to semantic change) hw/net/lan9118.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 47ff25b441..8214569a2c 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; } From patchwork Tue Apr 9 13:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787201 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221507wrs; Tue, 9 Apr 2024 06:39:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVT8yMB3yHs0BsFkj8Gzo3uVgE6HW16ivC6rGNCC2BEqngD+igeZWU9jWZjy0JWIM79QKunQ0oFJUaZmUbjgUOz X-Google-Smtp-Source: AGHT+IFhzGvelXkE/tYfo9c9pXUeksyReOCRZUe4IEoHx22qPYjX8szm97tqWOKQJs5holvMWHfU X-Received: by 2002:ac8:7d43:0:b0:434:9c96:5c2c with SMTP id h3-20020ac87d43000000b004349c965c2cmr5992235qtb.25.1712669943585; Tue, 09 Apr 2024 06:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669943; cv=none; d=google.com; s=arc-20160816; b=cHVuEiyEUOcV5KGvKFUbW8v+tIgWnp8x58oTo+8uA2PpAbPF+Q4htoln/02LvPSzC4 S4920zlCBFHotwk0yUvMCceYtm5YLrK245n1P6KI/Fff2bCvR9b1dV9UBD1XlXJzDVt2 tv+T+kZO0SD1Gh2xJcYgUSti/tBBSW8JfbMMf+TVRYTJpCHuTL9dZ6DSt/qrJ6bE/WKu zllpAULCT+GHM5ooqk+xLVEglB3CEWlGJqEUWMYayDh2iAQIDSfsI5BRJX9i2qMBAtd1 76tviBqAzUPIV11gmRCzSbrk16HONE3Hz9gP5KAVq2IoiUXijCLs5blLQtLRoqDc2OVQ Xt8w== 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:dkim-signature; bh=hctFmQvoI+VoJ+wRhi5qSVao9Hd6gz46Zo0ppCYqkkE=; fh=WkRGc9NPNzU781/uHO/isd3CBlh99lZ4TJgDgtZyIQ0=; b=wKacJJXH4cADtQbHlKvp6jLpNVlXnHqsYYC/1hnKa2/HMEwkJnb4SsCOddhS6hkInn OWpeU30RqYV9YYFcmvljdsuyW3m+sP6oETmuE2aJMbAPOfWQwPqRGnUWwXPmIVGJM8vI 8i2dl0gyjp8Yj5gdFyGJMJ0+ycc48zYRXz6XZ2TnAEhA+H6lsGz0L7XsB3MYYBP9ZFpL eOkii6TxgkLruwKnDo6+DlkqAKrYE2HT3Y2mTbHxN1BfA9ehd6ef7fsKa0ejSzG7HeXq K5OVSfmjmxgAk1bzEnqm1AKVMABSmAW5aJzR0tYBNviclZ8akTIdlIVicsHMEMSAqTb9 WQEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MkNXaU16; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y9-20020a05622a004900b00432d55fb03bsi10595476qtw.413.2024.04.09.06.39.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:03 -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; dkim=pass header.i=@linaro.org header.s=google header.b=MkNXaU16; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBgD-0005up-83; Tue, 09 Apr 2024 09:38: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 1ruBg7-0005rP-QL for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:23 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBg0-0008D5-RH for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:18 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-41650ee55ffso16789115e9.0 for ; Tue, 09 Apr 2024 06:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669894; x=1713274694; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hctFmQvoI+VoJ+wRhi5qSVao9Hd6gz46Zo0ppCYqkkE=; b=MkNXaU16aYLZ5Bj4GLd6FHU8wRNJnqyBHEW2sC3PzpKbvENMUjK539nWTSu7rIsXID kFncCFWXfOZr5ifG1aehikXMluVh6R34N5MMCuoBaZDYqgX/lNVi1bGPX6DtJRQHxBbg KIA0YFR8YtonJDEgHleX7vTjUsgQ+r/6kKTVZ6ZL5ZbGwsxT3byIdsOMwja3SfvtIsPc 3M1o3K114bIhIP43eRAyBQ1oHLfk5TDgtI5BxcfwOemMUdPuZ4s3zVh8jyV73wXafzH0 Q89hGgGhH71wZNw+vhPvx/3cg83TyELI2OCqZZYXc2OlfFLVR8ipEWwWTtTbawOfubG2 Ww4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669894; x=1713274694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hctFmQvoI+VoJ+wRhi5qSVao9Hd6gz46Zo0ppCYqkkE=; b=F2UU/Ysx3Z5hff2xkct8krvhirsfiT8S5Vw00YRcfv4L+gTicqIF2Obq12hWatux5G 0Vmd8kz5NXJETs5gKNMvfKwHmuRDc3JspoHCIlE46BdLyMOy+0jRkD/dbswIyDKlPpHi IRg61BnLsxZpC1VeavEXwtI13DbUYIA9jrHi5bdRoZuZe6TqrE8jdB1eOLGNkU9gHUAe TWQ/A2OPaFslXoq5P8SM1jG6tH5AZ9ufvVABpGETJsGkVpeKfaqrfYxdJG1xIQ4ADAsp 78oI837ocn+Sz+YeTy0zVFIHlR7phFfkknkDZzO5CLwPPFrQvcZmT5cSeO8Q/MuEMNJr N8Kg== X-Gm-Message-State: AOJu0Yy0y++wCn8awGE9yj0+aHydCVW15evAgT59vQ+0vZ+a9X4t1AcR YXDc9hqwy9FnEw6+6heZzYPtpH1v4r55aWx2AtR1vtXnDUzQ36BKzZj/P5hMYz8Z/0cVzWldJfD P X-Received: by 2002:a05:600c:154b:b0:416:9c95:b712 with SMTP id f11-20020a05600c154b00b004169c95b712mr1792936wmg.20.1712669894544; Tue, 09 Apr 2024 06:38:14 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id c9-20020a05600c0a4900b0041638a085d3sm12938995wmq.15.2024.04.09.06.38.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH-for-9.0 v2 02/11] hw/net/lan9118: Fix overflow in MIL TX FIFO Date: Tue, 9 Apr 2024 15:37:51 +0200 Message-ID: <20240409133801.23503-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 When the MAC Interface Layer (MIL) transmit FIFO is full, truncate the packet, and raise the Transmitter Error (TXE) flag. Broken since model introduction in commit 2a42499017 ("LAN9118 emulation"). When using the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/2267 we get: hw/net/lan9118.c:798:17: runtime error: index 2048 out of bounds for type 'uint8_t[2048]' (aka 'unsigned char[2048]')     #0 0x563ec9a057b1 in tx_fifo_push hw/net/lan9118.c:798:43     #1 0x563ec99fbb28 in lan9118_writel hw/net/lan9118.c:1042:9     #2 0x563ec99f2de2 in lan9118_16bit_mode_write hw/net/lan9118.c:1205:9     #3 0x563ecbf78013 in memory_region_write_accessor system/memory.c:497:5     #4 0x563ecbf776f5 in access_with_adjusted_size system/memory.c:573:18     #5 0x563ecbf75643 in memory_region_dispatch_write system/memory.c:1521:16     #6 0x563ecc01bade in flatview_write_continue_step system/physmem.c:2713:18     #7 0x563ecc01b374 in flatview_write_continue system/physmem.c:2743:19     #8 0x563ecbff1c9b in flatview_write system/physmem.c:2774:12     #9 0x563ecbff1768 in address_space_write system/physmem.c:2894:18 ... [*] LAN9118 DS00002266B.pdf, Table 5.3.3 "INTERRUPT STATUS REGISTER" Reported-by: Will Lester Reported-by: Chuhong Yuan Suggested-by: Peter Maydell Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2267 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/net/lan9118.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 8214569a2c..91d81b410b 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -799,8 +799,22 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) /* Documentation is somewhat unclear on the ordering of bytes in FIFO words. Empirical results show it to be little-endian. */ - /* TODO: FIFO overflow checking. */ while (n--) { + if (s->txp->len == MIL_TXFIFO_SIZE) { + /* + * No more space in the FIFO. The datasheet is not + * precise about this case. We choose what is easiest + * to model: the packet is truncated, and TXE is raised. + * + * Note, it could be a fragmented packet, but we currently + * do not handle that (see earlier TX_B case). + */ + qemu_log_mask(LOG_GUEST_ERROR, + "MIL TX FIFO overrun, discarding %u byte%s\n", + n, n > 1 ? "s" : ""); + s->int_sts |= TXE_INT; + break; + } s->txp->data[s->txp->len] = val & 0xff; s->txp->len++; val >>= 8; From patchwork Tue Apr 9 13:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787203 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221672wrs; Tue, 9 Apr 2024 06:39:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWenWJXJDrg2m0gA9B4aBD0HMn/dV+V57IlshOFZihqFkn5rNI2oNa2OKYSJHDhGG5YfHWOwzWL0owYtUTtaced X-Google-Smtp-Source: AGHT+IGUjg1odefjWXKIvQTV12vDtRe0aXlkfOTfKZ+ZQ/LU5HQHkYCkob8ZW4e4Fx86PHN+8Pe8 X-Received: by 2002:ae9:c20a:0:b0:789:e72b:1250 with SMTP id j10-20020ae9c20a000000b00789e72b1250mr11788289qkg.59.1712669963802; Tue, 09 Apr 2024 06:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669963; cv=none; d=google.com; s=arc-20160816; b=kzIXvTr7NrAdaYZWfzn0rUdedxrfmZB28HC9/mYegJgeX8g2jmfbjNqiY1v/jy1BGp /qLhZTck96SxXj+rqubvVvZOFN/2NCAQS/lyx2WN+3/hbKIO7YP5KA9N5uteftwiCfzN e8sAHXAyuxS7e51ahL4miqDq8xI46yjX8qpLPA0E2T+UgRu91gHInZRXntqW+ZGXsgFP fEvbkQFYz6b3Ut6wZ7gSagbunH8Kty1bYVAph7svNt8sxDX3cL4EjA+NL77SLPWkw26+ ZMCkDwwqsGviCFgSxPiZRPePNPw4fTxpDBNZnoSLq9z5dq43Vd/yPucTJGeHrmyvl4UH XxzA== 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:dkim-signature; bh=DYq6emMuo84KXuK6pkPRkrWEaAEwv9PfaiSXDO6YJ5M=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=fwCYEd7gPpBgs4zCkZ3/3f0V/JtqfLmIRJx+4aUQ136lJ1m/sfPWz9pH7s73l5TdWi Qy5YACfJYrLHMCdPjF+jefsbPRi1VGwBLT8Z4Xc9BhASveq0K/LdceD6ae5OvWRy9BNB igNwnlP1HlfEVUHk32nxG+VMOWSO2SCIC7gI5vC5kSxICB2XQKThe7aONq+ig2Hm5wiM D13K2WGtOQRE9ZOgAUMZvAwShSy0H9oados26eKJ9E0dIhmnwssQpSvcNU2gNgi53//V yhPgO4t+sHKisYm/P5kvkyICq03IxQWEqCbPEUfyRfMzrzkJoXLmRQNGnCOqqdo5KTzz iPjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cxnoEpD6; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e1-20020a05620a014100b0078d64750c24si4770671qkn.297.2024.04.09.06.39.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:23 -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; dkim=pass header.i=@linaro.org header.s=google header.b=cxnoEpD6; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBgK-00064w-5z; Tue, 09 Apr 2024 09:38:36 -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 1ruBgC-0005uB-5w for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:28 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBg7-0008Dj-Iy for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:26 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4169d794358so6526265e9.1 for ; Tue, 09 Apr 2024 06:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669900; x=1713274700; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DYq6emMuo84KXuK6pkPRkrWEaAEwv9PfaiSXDO6YJ5M=; b=cxnoEpD6KAKtBEw5QDjDUrmguX7lzbDV0x8vzdsb8XUcaMF+c/PECNPb7qMz3cRse5 tuxwcywIHcy90NfWqp6yOx6VwXG+HWWsEZKBWJS0BNqFrS4xHazn3UXT8pimj86Y0KVC q1m63i4uFPfJn5/HFRi1e4b8BqsfjtHw3sQSHlMu8btsw2AVJTavZnfbKsEQdNPLW3QW KvhKctv52gsS4lJBXwTKIlvz6A/p7fLQSxxlVaaR3s67NrqwtxPvjdOnQ/AGceSYg2PP MyWKWXxGlCtLZ0L7dUcQciD+QH/PaY2EetO2VxruQu06qROX9zJMkf6ArpNpr7EZcJDL wGGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669900; x=1713274700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DYq6emMuo84KXuK6pkPRkrWEaAEwv9PfaiSXDO6YJ5M=; b=iwSJqAlFIeLsuyfXngx4Yi+p3UELVI0Wbb2VkjKQ2hbP2lheAJZu+HPzi1REF82yIu mbgUsbU+A/WwLNJZSvl6tXlNoJ6+l3Y6d9M88657zQYf/pvTB4SUgr72vax5TTS7Kb6e AbS+uqQbxm21A+5qwfjNGid+ViCP61O2/xF4oSX+Y4bqubsQ39GBxXyySZ8FYuWMKSXP LxDTkip13EXhNbBzynOTuqB0o9DjDPfZPbQsz2DE7i/o3mftLy6FDiBQFG9sR+AIJg1w w8Bl7lTDLzVW2JX4npHVEqXy1dHUncqcf+xR3Al3uBwFkr6ONcuV0o5+ozM28hw1C8+r V2Hg== X-Gm-Message-State: AOJu0Yxdc3nkIgptEP4kJqcC6ypspimYEl1DpPnIeBbfZrlA65NbCmuZ WpBG1hfAj21aPFV9akjzMdq2+ALewbQf7/ce1wcngiMemwR5sDmJgBCHwdDTq07xpfod+NAHOFo L X-Received: by 2002:a05:600c:4f0e:b0:416:6e42:ecc5 with SMTP id l14-20020a05600c4f0e00b004166e42ecc5mr4129262wmq.40.1712669899965; Tue, 09 Apr 2024 06:38:19 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id q23-20020adfab17000000b003437799a373sm11657644wrc.83.2024.04.09.06.38.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 03/11] hw/net/lan9118: Remove duplicated assignment Date: Tue, 9 Apr 2024 15:37:52 +0200 Message-ID: <20240409133801.23503-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 s->txp->fifo_used is zeroed in the next 3 lines. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/net/lan9118.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 91d81b410b..d6f0e37eb1 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -438,7 +438,6 @@ static void lan9118_reset(DeviceState *d) s->hw_cfg = s->mode_16bit ? 0x00050000 : 0x00050004; s->pmt_ctrl &= 0x45; s->gpio_cfg = 0; - s->txp->fifo_used = 0; s->txp->state = TX_IDLE; s->txp->cmd_a = 0xffffffffu; s->txp->cmd_b = 0xffffffffu; From patchwork Tue Apr 9 13:37:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787204 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221823wrs; Tue, 9 Apr 2024 06:39:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVp+sZCr/YbdbdDJJZd3fWznIk7Zq76rCdL2pInTvGMB6mK810k/Y95cb8DIj1nztyHoF0WOQbXoTtRix1ICTFP X-Google-Smtp-Source: AGHT+IGhjDozbUhN1mgO9I8+oTdhCvBqfLbBel8lOr3HZvxr1dC61GdKPFw6pdRvOcfXYcKGLbe0 X-Received: by 2002:a05:6102:c86:b0:47a:190a:3883 with SMTP id f6-20020a0561020c8600b0047a190a3883mr1402981vst.12.1712669982784; Tue, 09 Apr 2024 06:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669982; cv=none; d=google.com; s=arc-20160816; b=ea/BrFmyVpzXzkREccMqqCSJh5LcrYsQO4WvTrSjyC35Wyh/5hj21pmDBN3LtYUjpX Mqcu3ds4hAUSh3/5RK2LigQB+f3c8BmtbCgjzK6tggzL1OTBWWYZKqKhOKmfarpAJjWj cCQfrMIl3r4Fj9uMvxYWSf19/mldjLIQRmXYRRPP55ltOaWhqcGITaphVt+jOMQxMYIp UG0ararC6M7BnCONvW60/GSURh92iVtQK4MLow4Sp7nPaaMwlUQYe8NozVkS6kXEHKDp DwhHvFbyeCKO94sfjeLzqZJCd0tUDbfq001w9TQM7KHjqLC3yKLq2HNHw90+l1obxs4N ErGg== 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:dkim-signature; bh=gF6HIIw6B4sYh42vGN4HzBKkT28PHylGD41Sq3YKysg=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=Fta4VY2KaU3n8lOqGrDIH1ez1n2jmBH19e3tM7kZVgtXh1KADXX//xBVmVwT8IJseP iNXB1ztE62PT9jbf9ZACjxDrqYkSzUF5lQXJAAWUnbgIs42D826zrqd8/+mqMs8Y5VFi GArMLorXrE+ojAuIIJWWUWW4gQgD47vuEy4snAKz/tI152Qa3S91rkiDUzLi3a2jp0Nr dA+U/MIzxB/n0g3GtV3rIy8CfRb99zC8RBGYNzGyRBpFSGoWW2Wb+IyNW/+OfMhZDjVX /WXEP4gMjV/4RL4MZt38eF+lRGuGEcxiGtaoq3gsfFDr0MRdh2mvULSX5EzxT2IYO2jU beRQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8FpbpF7; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p5-20020ad451c5000000b006992954020asi10448143qvq.282.2024.04.09.06.39.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:42 -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; dkim=pass header.i=@linaro.org header.s=google header.b=S8FpbpF7; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBgt-0006NN-Mx; Tue, 09 Apr 2024 09:39:13 -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 1ruBgH-0005yG-P2 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:34 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgC-0008EA-3E for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-416b7f372b3so1963045e9.3 for ; Tue, 09 Apr 2024 06:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669905; x=1713274705; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gF6HIIw6B4sYh42vGN4HzBKkT28PHylGD41Sq3YKysg=; b=S8FpbpF7twbylfVlLu54c/YC69uDLbzg0pP476agLBBvdIKBMmCWTgyXahoachl3Ys 7nZq0VV+H/KjA35lgZISJY+T53ras3swDGGHGCduHrSiXd5IoYetFmm97AqKSvIifvUA 9XuLk2I+8BItERRWPANmPtkBwzxBsMUQDSNNVULKEmQFyeJmHltoxuRJCtjLb3+VxPXk we4D9R1n7KLZcOu7c0E8K8JN33ibFTJ10Qcjhvma4TvNDg0Hni9jsNhpqHFPdBM21rIW lfuMdWKXse2KfXM+5RQObW1S1ARYd1qwjKN9exmcwmFWRmWTEQ4sFDW+JrSep6meEGQf cgOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669905; x=1713274705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gF6HIIw6B4sYh42vGN4HzBKkT28PHylGD41Sq3YKysg=; b=og6LixhW6y3toAEHn3B68/A2YXcNriHS++uX7WtHqCX25PR/4W1bjXpCdtbMVZvRmg vDS2CXS+9F0JlYCUnSHay6IJy7C9V9P8rUTQK8/85t/dy3n00Fnx5ljbm5lUZXcSOXIR pTTNBmB1j+B68lcejFfCyALaWnByAJnUoyjWeEiZ2EHPG12WaCWdsqcHS1DI1xVp4Ojq xD70kpiJFuVU2Wf/FARsgfX0hUuWwIZoU7gHlfLyv85Gy9liUVezeW5kuj1WBlI7yvVp E1DmXiSY7nVpSU3V/Fa9opDt++94x9cUoStfpsTSSDwbBpTLStQBI+NOAz3i9UAO3Sh6 nyIg== X-Gm-Message-State: AOJu0YyrQk/6L9WlesPFRIYpeo1oV0E+K1WEfByW23lUmHR+PcG1Rai7 pL4b0bC/4nR2rA/7rmt2yNWj0QhPwZgXkA2n40Qh9entulSumJR1/F/Xxv/BfzmzxlNa7di9P1R B X-Received: by 2002:a05:600c:4f54:b0:416:6abe:2975 with SMTP id m20-20020a05600c4f5400b004166abe2975mr4221251wmq.15.1712669905261; Tue, 09 Apr 2024 06:38:25 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id hn3-20020a05600ca38300b004162b578d8bsm16974787wmb.1.2024.04.09.06.38.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 04/11] hw/net/lan9118: Replace magic '5' value by TX_FIF_SZ_RESET definition Date: Tue, 9 Apr 2024 15:37:53 +0200 Message-ID: <20240409133801.23503-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 TX_FIF_SZ is described in chapter 5.3.9, "HW_CFG — HARDWARE CONFIGURATION REGISTER". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/net/lan9118.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index d6f0e37eb1..a6a869de32 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -71,6 +71,8 @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0) #define CSR_E2P_CMD 0xb0 #define CSR_E2P_DATA 0xb4 +#define TX_FIF_SZ_RESET 5 + #define E2P_CMD_MAC_ADDR_LOADED 0x100 /* IRQ_CFG */ @@ -435,7 +437,7 @@ static void lan9118_reset(DeviceState *d) s->fifo_int = 0x48000000; s->rx_cfg = 0; s->tx_cfg = 0; - s->hw_cfg = s->mode_16bit ? 0x00050000 : 0x00050004; + s->hw_cfg = (TX_FIF_SZ_RESET << 16) | (s->mode_16bit << 2); s->pmt_ctrl &= 0x45; s->gpio_cfg = 0; s->txp->state = TX_IDLE; From patchwork Tue Apr 9 13:37:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787205 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221908wrs; Tue, 9 Apr 2024 06:39:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUiJOS9gQKHq5ByYw/6QVAI5hPqlPb6czM8i8vpn6eN+910WBTzJC82a1LNRRjfO8fXnNbYJm4N1mRG4KA0V0Co X-Google-Smtp-Source: AGHT+IFaN7bCO2DjDPGtCgFplj4JeldsIofC3YVEu8t9nJLCHoF8gUNwZwuf+ptdhh1cgC+BhZHK X-Received: by 2002:a05:6214:aa8:b0:69b:f01:6fbb with SMTP id ew8-20020a0562140aa800b0069b0f016fbbmr4035691qvb.22.1712669994565; Tue, 09 Apr 2024 06:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669994; cv=none; d=google.com; s=arc-20160816; b=fEEYI/xa6NBYzP61PnzqxwZBqrZIIjR/o/vBlxG7SFJubhek1l63ITXxFqKI8o/weS vxMESq/8Y7KUNgDDbtGbK8zNV9ao78ST1Z0CJsuGM/cBrS4oAvaExusZZX339PNaviDy 1lAUJW0kgkAfxCRodWbIocvE2puKZw6OXg/EkQNs5Xo5JNFuRmj8rY1W1jJm0epcv3Y2 3k1HLQ1sP2/yaFADdpL6ZC6qCGfaiKXtvmGE5K04qhpyFvOfQNx7QSOzf/E3XX+JngoN gFb8+L2IFmBDM43l493Q3GC2MD2RFpQMgltF268fpIE16ILMRWLd3LfwChIEKxNIwy/q B18A== 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:dkim-signature; bh=lbfyIBf/SQJfbeKOCdEpbKAjf0YIAs4J/ih0RuWwHfw=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=I8IEabYK98rtpcNN4IWG0ecI+rTtKJSJl46/KGzvDJF7HuJ1i6wejqQA/2YgeQnDcw MO+pwlZDAabiUGjV/lOCYlZewjtzTd2uXmAlBEhaLqUtriuIKOLNVLMpbFFWjnA22ZOa ZacrDL/YiJAzCBSzXIUHBxMtVy+reGuHfIvHG3/4jTEneWnTkhTsVAlDPJ3x2gHnhgzY iyDLbOT/lEf8rhdjPIRQC/5GLxP/t8RcyutsaUteC2yNt3gO0H7KM7LvhrkxvkyHqyFi vn5SJgRc+X2P5/16sMVz3bfrVwMLJFJMX358Y7ZbTJmNz1WPag7TDGsgB/rwur4j3sSa gO2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A5olmGq+; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a20-20020a0ce354000000b00699331b15f2si10227917qvm.3.2024.04.09.06.39.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=A5olmGq+; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBgo-0006Bv-Nn; Tue, 09 Apr 2024 09:39:09 -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 1ruBgJ-00061e-L8 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:35 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgG-0008EZ-JB for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:34 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-343f62d8124so2801384f8f.2 for ; Tue, 09 Apr 2024 06:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669910; x=1713274710; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lbfyIBf/SQJfbeKOCdEpbKAjf0YIAs4J/ih0RuWwHfw=; b=A5olmGq+DqVVVxLXaoPRzZOpkl3+bcx6X/tP30ChgWYesXDu5TFuooy0CuRwrNc9jm I3Wed44qyzFmJK+uJlCYRIE14nxvFfK9dOec23W/u5HXaBIYGaeoyZT3zdGqRbfdW1Im wAxIi9Wx6c7qVFP50YAfsUDKRlWXkPYzUvHMb77hFHRspm4e2p+WZbNHEm5SWNK3/u49 LK+Az1IT5t5lBH7Fvnio5HK4pR0n+qduf3Ew0rMRsoKh084WDevMpMarfeiphl4h34FB ZzbwoPfjLhoDAIlS8CaYqcZrtzzdmkS4BJ5faWewFpoD/JVnHRr+kS/P8jgbrrIOOr0G +wXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669910; x=1713274710; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbfyIBf/SQJfbeKOCdEpbKAjf0YIAs4J/ih0RuWwHfw=; b=gxbqfP5dwwtKcQit8hcoP6mkKfsyVLN2OUmQ0w03cwuUGFITcE5PiawR5t+GNfyhD3 Sjh1dM31HIm50pGxjfEKvxHJoKPSDf5gf7Uo+bdiB+7e+cYhGemlMZOGdgHTAf9+CtJt rgPeFCPp3rP3lpx7A2WFucB+y+s8OFLhnm3nUlzqtlWSHnYz45CIqygE769Jk12tjWC6 GGgZdzNB1ctjyOCOC7iM58uze5KGTL5VNpHKno4Vt/8kusDKhA5IWEfVqlgbF0H3m3bw J1D12uK9KweqN40+D4YNk+jH5mdBk5sLHrN3GQybVCR625OnfrIyvX29OcCYVZ6uK40y xiMA== X-Gm-Message-State: AOJu0Ywt0xsnqG6qLQXctQ8zO63GJDHMac87P1u7y9oEIQKRS2r24w8j 6835bzNqRVC9HyK8LmGBnFVBUSmnemScPmKlEE81a7KaXXVdyStzCmPfFJcELneIAqGlAcwW9Kp n X-Received: by 2002:a5d:5233:0:b0:341:bfe2:4509 with SMTP id i19-20020a5d5233000000b00341bfe24509mr8216775wra.42.1712669910719; Tue, 09 Apr 2024 06:38:30 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id k2-20020a5d5242000000b00343c0c24a65sm11460005wrc.89.2024.04.09.06.38.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 05/11] hw/net/lan9118: Add definitions for FIFO allocated sizes Date: Tue, 9 Apr 2024 15:37:54 +0200 Message-ID: <20240409133801.23503-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 Add definitions for the TX_FIF_SZ=5 case, per TABLE 5-3 "VALID TX/RX FIFO ALLOCATIONS". Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index a6a869de32..00409927fe 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -158,6 +158,17 @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0) */ #define MIL_TXFIFO_SIZE 2048 +/* + * TX and RX FIFO space is configurable through the TX FIFO Size (TX_FIF_SZ) + * field in the hardware configuration (CSR HW_CFG) register. These are the + * default configuration settings for TX_FIF_SZ = 5 + * (see TABLE 5-3: VALID TX/RX FIFO ALLOCATIONS). + */ +#define TX_DATA_FIFO_BYTES 4608 /* 1152 words */ +#define TX_STATUS_FIFO_BYTES 512 /* 128 words */ +#define RX_DATA_FIFO_BYTES 10560 /* 2640 words */ +#define RX_STATUS_FIFO_BYTES 704 /* 176 words */ + enum tx_state { TX_IDLE, TX_B, From patchwork Tue Apr 9 13:37:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787208 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp222029wrs; Tue, 9 Apr 2024 06:40:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQe5Y8014/rZEQtJ7y9mB9i3j08DlpRXtqiuVZ/Intea6DcK7kZvBg1gBiLqy+rwFbX5sEXGAY4CwNmbJlstfV X-Google-Smtp-Source: AGHT+IFWmfYulyAaL3eeqkXC0MGU1VSIfvrZ+wFF2UOHSeKdxqidc8u16v+eix2W5PHfRdDUimmP X-Received: by 2002:ac8:7e84:0:b0:434:ed54:3a07 with SMTP id w4-20020ac87e84000000b00434ed543a07mr815735qtj.49.1712670007804; Tue, 09 Apr 2024 06:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712670007; cv=none; d=google.com; s=arc-20160816; b=rqZoI4CxJL7K1DRRcjsO1u9RR33xXBg1HKMUwgQ6oakUugzumUgq09msn/cFd7RpSb 0dFrETVAjAFT02Jwqcj8ZlobZ37BXkRP6N5Ps5v8YF1h8qIl/kp9MUqfxNAmQiHWg3vF GiTDYLGF6F+1QzZrUGpOaiqUvF3de4d0lsESd+bzl9XBHdNb5mU9yP1a1Yt1bEuFP1mJ zTp9OuX6RCvxSu1QPVIEeSsytXaSP46ncRLaRmkAz1y81FQ1kVaVfhAZwV2cccSmQmjM Bp9IXeI5lxuFxjOllVLfnxUGITx6/DSq45YkhiG4AkhYxj+y0LITX9eNQ5FNiYpIFyls OCvw== 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:dkim-signature; bh=7TiWem1ZhFBanlvNYVKtTUilTqsESzuwGclOakf5YZY=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=Sm6TCBuc8QxZe/Jky0EG977VyMIIgs269/T4lKXoN3gI2n7R04I+qFPfql4L2u9nP8 HWpISXCZl7Qzo4DSLmCLn79EfXZDZCATLN3bvROrMVKY4CHkRtyryUpdmTL8LeL3A7l/ 2xKN/tsFDR7ocQ3GpKUVcT3R8Kre9acZmLUfdhNLdZ3Tj+1ZbyH1iX4uHxhHb7ySZaao SUg6FgktMS5NmQdVgVSbgPBicHO90PWEtMhzjuRa9XCdUj9QiJ5p0WeNMWIhLWpmhwfp lHfL2+Jc5ViaSDvH9o6mKscTwrPp7aWPqusHNlGMNgnPucrzIHD6H9mEjm5EQch79UZT hruw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nAkfqxAW; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n11-20020a05622a11cb00b00434e5fa8c9bsi827775qtk.473.2024.04.09.06.40.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:40:07 -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; dkim=pass header.i=@linaro.org header.s=google header.b=nAkfqxAW; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBh3-0006pW-N2; Tue, 09 Apr 2024 09:39:21 -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 1ruBgO-00069R-2K for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:40 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgL-0008F7-KY for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:38 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-41551639550so39139205e9.2 for ; Tue, 09 Apr 2024 06:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669916; x=1713274716; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7TiWem1ZhFBanlvNYVKtTUilTqsESzuwGclOakf5YZY=; b=nAkfqxAW/T5g4qa2Bse3sU0USrdEIaSGp1zsofwDjAoO18sSR/JDwM2qwGRpFENxc8 Qpuw8DSYRbV/Zw+/vXB77nWZp50XgMtFyzLYBlS2le/PRuGUo6kZvgWEdb9CfIuzXSaL NbJ9QQAf7j/QTyCnqe1oEH6BqBcsAjJqvqyNXGk2DXl4zw6+ClkIxgNHdbV4R0UULCen 2icsg0I1Zcvt198RnDVfh8p61bLQGahRt9H+z2Uzps5nJRBN1nXbwzM09KtUEJTBryS+ aToh6CxCCEMSHcYBonA6iBJ7kynbtxi5OoZU2X7eqphJD87JH3al1z2HxyZ73eTAgxzX l2tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669916; x=1713274716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7TiWem1ZhFBanlvNYVKtTUilTqsESzuwGclOakf5YZY=; b=NjrueuLXcRkV/TqFNkWo5P+vUaY3GmTqpkcOGpAT4osvhsgYJGXpH09Lvif7tmlnrD vHn4YJKKlvz6ZS970cqymiuAwfRfhQNWod4zlEX7MJuAcEkuDzKE+FrfOmMis+FN8GAl qju0oCVSpq3ojw1oJkpZcVqYznIvnLNFOCQsur9IGamJBYPTeShTCHTP46nNeJkBYfIm +ha8/SEJbXbdScTHB0yFrz0h7/fXI4vdcCn5Rxp+ZY5DJ6FggBB6ABcJ9NzfMOYdE5w5 TQ5+BHS7/tapkm+Wu+bM+azaNzR792WHi4JPEg+gCaE5aBd6u8/d2wFrtTn2JTpTiT8+ 9SsA== X-Gm-Message-State: AOJu0YybXwtBOxACu6SBJWgsldE5XCcv9vJykew3FKF4JlBpjHq/aVeS 4sG+vdC7/Uh2j8JD3oz8aOFgNfAe/DS0tv/F4BVN+mlL/PbN+8W+q1P+7N88Ex04YgVZxfFle/F 2 X-Received: by 2002:a05:600c:154d:b0:416:902e:51ac with SMTP id f13-20020a05600c154d00b00416902e51acmr3520404wmg.39.1712669916012; Tue, 09 Apr 2024 06:38:36 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id l13-20020a5d668d000000b0034354a99d43sm11483355wru.43.2024.04.09.06.38.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 06/11] hw/net/lan9118: Use TX_DATA_FIFO_BYTES definition Date: Tue, 9 Apr 2024 15:37:55 +0200 Message-ID: <20240409133801.23503-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 00409927fe..ba92681e2e 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -456,7 +456,7 @@ static void lan9118_reset(DeviceState *d) s->txp->cmd_b = 0xffffffffu; s->txp->len = 0; s->txp->fifo_used = 0; - s->tx_fifo_size = 4608; + s->tx_fifo_size = TX_DATA_FIFO_BYTES; s->tx_status_fifo_used = 0; s->rx_status_fifo_size = 704; s->rx_fifo_size = 2640; From patchwork Tue Apr 9 13:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787209 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp222157wrs; Tue, 9 Apr 2024 06:40:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5QadxGhz+dojjDrDqdBW0Rk74OU5BOi5+skgw4F0dmjHmnfpGLO5aH8E9/jR0t/9cf64M8Hq6ydjiT6p2/pk3 X-Google-Smtp-Source: AGHT+IEsy2KDUzf2EblipinPMcd/8wkziNfxeju1w+3y+uhABP55xtxdCm0Px1VBr+sPmlf0VWcq X-Received: by 2002:a05:622a:4f:b0:431:38ea:1d42 with SMTP id y15-20020a05622a004f00b0043138ea1d42mr3633076qtw.30.1712670024235; Tue, 09 Apr 2024 06:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712670024; cv=none; d=google.com; s=arc-20160816; b=PeQBK/+IU41Hr9HzDK8She0E4nymhBMj/8OJ7VlexJZ0YB14kldiPUmfkJc3IzYTxI VlmikyuSoI1DDpl4Go1bKwNMQzw4Bqi/rZk8oIGNem9icKxqA0RLG8KlIlMfokuzgjdQ 410vg4YlD/wb4A6JpUMYQhMCQqyFXahjKX6yX+ZVwmoQt2hQMH+P/FiP3YhJhnikkvzY 8jUUJ2G6mucc8OQiDaNOjKwGHtHW1wI3bF4z2ZXjw8Pm6zP/ATq0uJUJsWOYinPBL8h6 /WuubIm8dbPHWWOTJNnJINsd2MsDnEgsqaxVYWlqPQhST4AxzV0b20exdH++rlFJrp87 jt9A== 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:dkim-signature; bh=LWebOFnaO2YfqkM2Zqjj72nsNguBU6W//GqzHg4t0x0=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=tToVichfEw1jyBEL5YRse/eEhKQIcZRu1505daWHLSf628PJqRSvJojSAVN8YtXrdk Y8rK1ylybqY/qv7p8n1F9uMmT7uoJDgYb4z8ZBYioq7HRbvb4UdmTglJMOrs9wrTjQP0 vg3cIvjaJ22VSpYlF1V2Zkrg8WJeJ/J4QZbzgzuvjAtCExO/nVzcdxj1n7rPNryh4YYT IgVNa3fHLG51HE0GxAZKPXXRdGHnWYJ5Q34Ksj6Iix+1R9zC7fvkToxqWRDQEK4+PSKz nsXWPHKLnlogtb5/EHp+St5MyCy75U7yYN2kHt1j9FC4K++oWzWxTl4/ju+wpkYRU6Yx OxcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qmf28Bqt; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l14-20020a05622a050e00b00431819d4ebfsi10731331qtx.521.2024.04.09.06.40.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:40:24 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Qmf28Bqt; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBhE-0007Lc-Ao; Tue, 09 Apr 2024 09:39:32 -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 1ruBgX-0006Ah-KT for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:54 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgR-0008FV-Sq for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:46 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2d8b194341eso4265381fa.3 for ; Tue, 09 Apr 2024 06:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669921; x=1713274721; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LWebOFnaO2YfqkM2Zqjj72nsNguBU6W//GqzHg4t0x0=; b=Qmf28Bqt9/Lk8VbUT/Uc313cTBuk3nl4lQP5KX8ZeS8GuAWTX2MbYz9C9XPSO4O1fF I77tuA9SO39o+EDBWIOhWNAgMVHe24e+xckBxIjBA4nBXBAYlmuPJpPbwUgmEGKlrzcJ G+UKytPg3lxUkcbdbDaR1r9HLiXABHva30zAQn7oWA0uu3vVuJKMXDKW3HuiOH3Dkk/5 tOhJT8LHescq/62o/EanEkYKghAPApMIjBMe3/1HNW6EDmND9hnM57KbmKRnYQn7QWD8 v2yjfdHMHYzUpfZsH4G4RWuj72D+b6mgKx2JF6CnH4hy9FYjCHG0n2i47lIv93BTa6CV U+4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669921; x=1713274721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LWebOFnaO2YfqkM2Zqjj72nsNguBU6W//GqzHg4t0x0=; b=RXqqVXEP0dMmbbtPuq8Jyn+AXpxx+65JIORJei8SmnVfT3g8iZjsRBJZDsSGD5fcVi LWhu5w+7pKHjAZxxos/Vr/46XBf7IRHAyEqGH358EsJZU6/baI1dzIXT+Yi/JIp3FIs/ o7FOEt2ELR5xQckYgwryAfOqC+uf/o0qWfKvhiAaEejIe2iS19BFbTcEHZeFJ+rY0ICt DFLZLL7bDdSHVVTfJV9pFmdEgDVpN8D/6mTXKb92KRCn9DnkhcW688z3xoT5vE9f0vKf ApLOvdjbiHCjW6L6x8xdqld/gFJlV3cgZQrT+F8K7pIAbnpDLNVOhqyVpJzBuCkXw2xG E2yQ== X-Gm-Message-State: AOJu0YxxRqzdbGwjcNzMAXsXOIsfFjM5XEPy/QB9vIc1g7xK8GVPOTvr tDSjcJQTnTKsWYEJ5EbeLwlUfJg9MOpUG1bJBb+RpqaVZpjHJwA8oAnZa0Eakg1rkk6RmasAlkH E X-Received: by 2002:a05:651c:794:b0:2d8:67ee:2a44 with SMTP id g20-20020a05651c079400b002d867ee2a44mr6899106lje.8.1712669921293; Tue, 09 Apr 2024 06:38:41 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id t20-20020a05600c199400b0041691379a84sm1446429wmq.1.2024.04.09.06.38.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 07/11] hw/net/lan9118: Rename tx_fifo_size -> tx_fifo_bytes Date: Tue, 9 Apr 2024 15:37:56 +0200 Message-ID: <20240409133801.23503-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 tx_fifo_size is a byte count, rename it to avoid confusion. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index ba92681e2e..a983ce193b 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -251,7 +251,7 @@ struct lan9118_state { int32_t eeprom_writable; uint8_t eeprom[128]; - int32_t tx_fifo_size; + int32_t tx_fifo_bytes; LAN9118Packet *txp; LAN9118Packet tx_packet; @@ -322,7 +322,7 @@ static const VMStateDescription vmstate_lan9118 = { VMSTATE_UINT32(phy_int_mask, lan9118_state), VMSTATE_INT32(eeprom_writable, lan9118_state), VMSTATE_UINT8_ARRAY(eeprom, lan9118_state, 128), - VMSTATE_INT32(tx_fifo_size, lan9118_state), + VMSTATE_INT32(tx_fifo_bytes, lan9118_state), /* txp always points at tx_packet so need not be saved */ VMSTATE_STRUCT(tx_packet, lan9118_state, 0, vmstate_lan9118_packet, LAN9118Packet), @@ -456,7 +456,7 @@ static void lan9118_reset(DeviceState *d) s->txp->cmd_b = 0xffffffffu; s->txp->len = 0; s->txp->fifo_used = 0; - s->tx_fifo_size = TX_DATA_FIFO_BYTES; + s->tx_fifo_bytes = TX_DATA_FIFO_BYTES; s->tx_status_fifo_used = 0; s->rx_status_fifo_size = 704; s->rx_fifo_size = 2640; @@ -757,7 +757,7 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) { int n; - if (s->txp->fifo_used == s->tx_fifo_size) { + if (s->txp->fifo_used == s->tx_fifo_bytes) { s->int_sts |= TDFO_INT; return; } @@ -1285,7 +1285,7 @@ static uint64_t lan9118_readl(void *opaque, hwaddr offset, return (s->rx_status_fifo_used << 16) | (s->rx_fifo_used << 2); case CSR_TX_FIFO_INF: return (s->tx_status_fifo_used << 16) - | (s->tx_fifo_size - s->txp->fifo_used); + | (s->tx_fifo_bytes - s->txp->fifo_used); case CSR_PMT_CTRL: return s->pmt_ctrl; case CSR_GPIO_CFG: From patchwork Tue Apr 9 13:37:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787206 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221918wrs; Tue, 9 Apr 2024 06:39:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV0ki8HNNTuv37hv6DmndorLSut3mFguZXCHnh6VumUmBvS/hF6bPI+FdGqLGwnJfUkVZgvYIomhtF3ZGv469TQ X-Google-Smtp-Source: AGHT+IE64V1ylNqhqAwdYgKrCX0XWXZKoYgAl89yFhVcIrDpmD6rlgCva2Ef3OsKTCD+uzRRpzH2 X-Received: by 2002:a05:6808:1489:b0:3c5:f833:1fb1 with SMTP id e9-20020a056808148900b003c5f8331fb1mr5556508oiw.0.1712669995031; Tue, 09 Apr 2024 06:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669995; cv=none; d=google.com; s=arc-20160816; b=qwDEFxOCxd6W7X6Pk2ZGNOnx2OKY6zkoxOejmHV/qcPWDj5QGT8haC/1mh6U21IadD 2yAkhl1qN0WZLCLyVJl5Sv6XbCV5Y0jH2c3RKaOL5bR2MBtwOzyPCWR7Keiadz89tnrU 7FM4LFCRLD9OnFr0DGkGgXU8WdDgprm5Lj4jyY9iWhhcqXAGO1d5rxARcAqlSzU3v3Ci 0YiCmOLIf/dhrynjob/vZ3Q3vyt8WPkSuIroSUNCV3/pxfRdRgq+3OReiPJqnpBlZF7P Xy/80WpbbOR4UCIiAlqtoEhhjPSSmpFuoOQQIrgLKs+TCRdqS+mCsGpIVgltDwyhHvch Bk1A== 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:dkim-signature; bh=oGzPoYfNQCrbv8SBMTgNtn+qUHBJfLjzTK3ZMwrVVa0=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=DtOZ11+m/wG7nIENLSx1LlAmSM5KKx++AIRtwBn2H4FfQAGb5fZhcDcQ2NrpdNN2fw Dw81JC6xbg3JY7H9e7SCRcf/bpKCx2QYE293wWtLKvkWtyzOq/ZfJfhoxrtwBltxI8dc xU71CEd0akoTbzAmqUMmDP7vsO0Dmp4dIB4SPFCbM/2Rh05tGCgPQHUs5RL07olDhyV/ rhKSZBhPtWS+aMzKeUZpt/U18cwUesT0w6oY43Ryv5V3Ni8lOegLa3v/sBcDpCqt8gdZ R+nuJ5kpGilaHpIzTwsBJJ8qVQ9hwVOr24TLB+7xStp7UK4KdtPCd/qtRmpf1kNsinc4 WsWg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YLVPHWI9; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p24-20020a05620a113800b0078d760dfcf0si194255qkk.578.2024.04.09.06.39.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:55 -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; dkim=pass header.i=@linaro.org header.s=google header.b=YLVPHWI9; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBhB-000771-NN; Tue, 09 Apr 2024 09:39: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 1ruBga-0006Bb-8S for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:54 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgY-0008Fg-Cl for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:51 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-345e1c64695so940193f8f.1 for ; Tue, 09 Apr 2024 06:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669926; x=1713274726; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oGzPoYfNQCrbv8SBMTgNtn+qUHBJfLjzTK3ZMwrVVa0=; b=YLVPHWI9qf0YqvGfy+qWUYDFO34sRgz35Kr5pF9BOGHm0J1/ie3U27Iv+Wg6NTQXmU Zt9CCvlcOG/Lnm1t+h0k2OUElLmhMVMYZwQPhFgx3FUeEmF1t5/IeV+K/WBxU6uwNFqK s57WPDAHjbduBqL0p6mss1NlQthDZfnGN+z5l4uGO7yzx67iR/pl9ksqhYvlg0ynzK8h aj5rDi6uSDmgbxOIt+GsOjWuOQqwVE5KHMfSbocDELpm+NDYA8ycOWFMwWitQefCV8zi hT4IxCEon3qEgB20gmuVtigvFkf11knelYlT2DjnWsU8C1T3OyFGtXYI5Yq26vPhhpTm CIIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669926; x=1713274726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oGzPoYfNQCrbv8SBMTgNtn+qUHBJfLjzTK3ZMwrVVa0=; b=HNe95lChZkKJiCDJQRNMZyP4YRBOhHRCvD3K356rDaVIuLVDML0XEm+Nw4IYhd3Exi bjjwEskXc43A5YWHbLC7dcpxLoGsINjFaCBuqLynE0OnC2TWB8tjRMuKpnXuZ1FujLvl ioGilqKIRC+EncGTvmMsqvduTs01Fr/Y8u6T4sNL30RDagRaMd9sVV9/TWI/9EotmjnM 4UMWc8lq5L6KhksX2EGYhJGqZ+XiDQ2x/S8Wjseila/925D82y2E1LKFinc9lPhitItC 2TozSK++bQZGwMZpKn0EdLksGUEY8GwccDlMFz+15Ync0q2ZHEYKSxcQHvY0Ey9NMO9O uudQ== X-Gm-Message-State: AOJu0YwnnelMvHvQwuJVgOyeURkAtTYtbHo4OPjjQps8MVDVtxtbgjdz Sp3QxKAonmgVX8aXKUi9DGL1WKBn7l5FEfIr1IyR/UGbv78U5fL3InzqsHc795fvZU+KjpeHXoq T X-Received: by 2002:adf:f7cb:0:b0:343:ba58:97c4 with SMTP id a11-20020adff7cb000000b00343ba5897c4mr7607183wrq.10.1712669926663; Tue, 09 Apr 2024 06:38:46 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id y13-20020a5d4acd000000b00343eac2acc4sm10864616wrs.111.2024.04.09.06.38.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 08/11] hw/net/lan9118: Use RX_STATUS_FIFO_BYTES definition Date: Tue, 9 Apr 2024 15:37:57 +0200 Message-ID: <20240409133801.23503-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 rx_status_fifo[] is an array of words, rx_status_fifo_size is a word count. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index a983ce193b..cace22381d 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -262,7 +262,7 @@ struct lan9118_state { int32_t rx_status_fifo_size; int32_t rx_status_fifo_used; int32_t rx_status_fifo_head; - uint32_t rx_status_fifo[896]; + uint32_t rx_status_fifo[RX_STATUS_FIFO_BYTES / 4]; int32_t rx_fifo_size; int32_t rx_fifo_used; int32_t rx_fifo_head; @@ -332,7 +332,9 @@ static const VMStateDescription vmstate_lan9118 = { VMSTATE_INT32(rx_status_fifo_size, lan9118_state), VMSTATE_INT32(rx_status_fifo_used, lan9118_state), VMSTATE_INT32(rx_status_fifo_head, lan9118_state), - VMSTATE_UINT32_ARRAY(rx_status_fifo, lan9118_state, 896), + VMSTATE_UINT32_ARRAY(rx_status_fifo, lan9118_state, + RX_STATUS_FIFO_BYTES / 4), + VMSTATE_UNUSED(896 * 4 - RX_STATUS_FIFO_BYTES), VMSTATE_INT32(rx_fifo_size, lan9118_state), VMSTATE_INT32(rx_fifo_used, lan9118_state), VMSTATE_INT32(rx_fifo_head, lan9118_state), @@ -458,10 +460,9 @@ static void lan9118_reset(DeviceState *d) s->txp->fifo_used = 0; s->tx_fifo_bytes = TX_DATA_FIFO_BYTES; s->tx_status_fifo_used = 0; - s->rx_status_fifo_size = 704; s->rx_fifo_size = 2640; s->rx_fifo_used = 0; - s->rx_status_fifo_size = 176; + s->rx_status_fifo_size = RX_STATUS_FIFO_BYTES / 4; s->rx_status_fifo_used = 0; s->rxp_offset = 0; s->rxp_size = 0; From patchwork Tue Apr 9 13:37:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787211 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp222410wrs; Tue, 9 Apr 2024 06:40:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX4CU6+8RYztBdt/rdNl/f7NwmVDoFBpJwt5vKeL/mG6xOp+OBuBn2tCemhYW18lB918o71Xu4eq5yphDmAZfq9 X-Google-Smtp-Source: AGHT+IFFA+KTNKj7NSFjoqEvQRm8Hn8vfOEgdwiqrh0AF7HaGfgi6RQSBB8yf3IsQVJbYZ4fv+TY X-Received: by 2002:a05:6830:34a7:b0:6ea:767:9dc5 with SMTP id c39-20020a05683034a700b006ea07679dc5mr11561309otu.3.1712670053425; Tue, 09 Apr 2024 06:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712670053; cv=none; d=google.com; s=arc-20160816; b=I+JV5hECoeFjpG41EWt+BfYvHdh9w19kJ34n5MD3tPRCgPB63LdylcY7VWEVdc1IGc lHYJpYUrIY8FJ/un1Zy/L7f9VBFcuB6DCj1NRPRpWZHxeKe4tvTQkzDBIMGJ3033M6B6 mlzz/yDcFWq3qgwnMaNKyTgObCwhJBPWcve63Qk28yRZaSDUQlxVQingKuqE3bUbbFXO 5CmM+foH3yyKT6NqhdEDJjJcitkrWj3I4cVW7EcsJoXPhGZe9B7CZsFCtLy29rj03Y7e juM/tARObr/9YiRD8chhW0AoXrdpzQWZReO0woxhaTKIyncZGjKOtoTjT89QFTdaN+h6 gDWg== 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:dkim-signature; bh=REIm1SfLMUgG42n/AOyva4uJWnD7BJmJ3hGw4grtNrQ=; fh=WkRGc9NPNzU781/uHO/isd3CBlh99lZ4TJgDgtZyIQ0=; b=h6pNLWvaJjsb+5+SsmsiGi5kynnwxM6PuIUYiKx5iUvIOrBzbuCVOGR2akTrs7MIqo r3jGNaSwvPZNO4WwrQ0FPaZ+AiL7dW0b3yyevTKlUe0KSy0uq1jC1QJqe99y0wBMmDQ4 DDae38dg3rjdUwatnmSAJRDToqfFfzomBRpABTL4tFaPRQ1zYIYODL2LpuUQZNkKT3eZ XZ704M0r4J0grcPc9/qe+JPRQYqsW8eZ3FhPG7AX8dRyRXMidTnrxnM/OoOFi//8GsFb Ks/ZsTLr6OF62Cdmy0WdLdV/SZuvpsFAZhn8Pt7QVK/E1jbcgElHBzfsh7ZIYQdwcxXW TVDg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LSZmv35s; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bi20-20020a05620a319400b00789f61e3e39si11405458qkb.74.2024.04.09.06.40.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:40:53 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LSZmv35s; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBhE-0007MO-Ay; Tue, 09 Apr 2024 09:39:32 -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 1ruBgd-0006CJ-Ud for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:39:01 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgc-0008Gq-04 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:38:55 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-343c2f5b50fso3735527f8f.2 for ; Tue, 09 Apr 2024 06:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669932; x=1713274732; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=REIm1SfLMUgG42n/AOyva4uJWnD7BJmJ3hGw4grtNrQ=; b=LSZmv35s7D27V3+dGrZnCHfE9CB5s/cbgVpq5VCM3FIjLogRnulB1NLvrZtcIIwGJh eJM+XFKPxDKbq5MAaQEO0ZDYTxIZOGayb4oY2c55XFTHcddBjq3XoplVkrupSYjbdgBs H+TmTVSv2qO6ifSkFvUskg4L+8eryWlfQ9Q7ugUmZbQjc2qqTsWbEhjrCD0uqyvRQvil CCnUz9o2+VO3g16PfnWXrr18rSrsLFHFN8hDa788XgpEhNMby5Yy9G+lAIZj6PEcPhue MtDxkOTibz42wArgsv/0sXAz7XIMcKVGjQdVfUIDpJNtn6gOaWlSNM4bdGTnWUn8FMUO t4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669932; x=1713274732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=REIm1SfLMUgG42n/AOyva4uJWnD7BJmJ3hGw4grtNrQ=; b=SpYjdaaB4n/U3px1Prq+yvRg8hqytId8co433g9EVpbNq5qqwvayJ8maG98nSfKsEt 6uOt9JHbtHvqT/Jzxzjs/dlsJH4FxOT2449YmWYF33QdViGnUYKsIPsXD6dHmLrZsrJf t/xyuNCrO1D4KW6B89krbgvSgOo9c8OCyPG4Tc5Lml4GhK1zLqmPBhl5cmDFCcMHv2P2 D5ugS0wVxLreOl1xeez8CbZTfZQqQ32bmJWwEJ4956nxrHJ54CGLXvI+UOt54xAQUZ0Y 0IErE9fEonQaC9sbFQxXS/k7bZZSJy0RwF6gijtg4A/7D90c80Z29vZ5x2LYn651aEQr WdSQ== X-Gm-Message-State: AOJu0YwIoNnBRM5ayn+tgmCiKfnchYmDSCieXvad1sacSgZdA4B0cU2J 2b6c6ui6nQ8du3vbRU3JfaC/F8nWUnHJ2CoCMgjYVy0wp5bB8b/mk4zH1Ppy0RUF37ox6z9Nrhb u X-Received: by 2002:a05:6000:1864:b0:33e:48f9:169d with SMTP id d4-20020a056000186400b0033e48f9169dmr11866184wri.31.1712669932225; Tue, 09 Apr 2024 06:38:52 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id j1-20020adfb301000000b003464e150e30sm236605wrd.15.2024.04.09.06.38.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH-for-9.1 v2 09/11] hw/net/lan9118: Rename rx_status_fifo_size -> rx_status_fifo_wordcount Date: Tue, 9 Apr 2024 15:37:58 +0200 Message-ID: <20240409133801.23503-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 rx_status_fifo_size is a word count, rename it to avoid confusion. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index cace22381d..663776f575 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -259,7 +259,7 @@ struct lan9118_state { int32_t tx_status_fifo_head; uint32_t tx_status_fifo[512]; - int32_t rx_status_fifo_size; + int32_t rx_status_fifo_wordcount; int32_t rx_status_fifo_used; int32_t rx_status_fifo_head; uint32_t rx_status_fifo[RX_STATUS_FIFO_BYTES / 4]; @@ -329,7 +329,7 @@ static const VMStateDescription vmstate_lan9118 = { VMSTATE_INT32(tx_status_fifo_used, lan9118_state), VMSTATE_INT32(tx_status_fifo_head, lan9118_state), VMSTATE_UINT32_ARRAY(tx_status_fifo, lan9118_state, 512), - VMSTATE_INT32(rx_status_fifo_size, lan9118_state), + VMSTATE_INT32(rx_status_fifo_wordcount, lan9118_state), VMSTATE_INT32(rx_status_fifo_used, lan9118_state), VMSTATE_INT32(rx_status_fifo_head, lan9118_state), VMSTATE_UINT32_ARRAY(rx_status_fifo, lan9118_state, @@ -462,7 +462,7 @@ static void lan9118_reset(DeviceState *d) s->tx_status_fifo_used = 0; s->rx_fifo_size = 2640; s->rx_fifo_used = 0; - s->rx_status_fifo_size = RX_STATUS_FIFO_BYTES / 4; + s->rx_status_fifo_wordcount = RX_STATUS_FIFO_BYTES / 4; s->rx_status_fifo_used = 0; s->rxp_offset = 0; s->rxp_size = 0; @@ -568,7 +568,7 @@ static ssize_t lan9118_receive(NetClientState *nc, const uint8_t *buf, } /* TODO: Implement FIFO overflow notification. */ - if (s->rx_status_fifo_used == s->rx_status_fifo_size) { + if (s->rx_status_fifo_used == s->rx_status_fifo_wordcount) { return -1; } @@ -609,8 +609,8 @@ static ssize_t lan9118_receive(NetClientState *nc, const uint8_t *buf, rx_fifo_push(s, crc); } n = s->rx_status_fifo_head + s->rx_status_fifo_used; - if (n >= s->rx_status_fifo_size) { - n -= s->rx_status_fifo_size; + if (n >= s->rx_status_fifo_wordcount) { + n -= s->rx_status_fifo_wordcount; } s->rx_packet_size[s->rx_packet_size_tail] = fifo_len; s->rx_packet_size_tail = (s->rx_packet_size_tail + 1023) & 1023; @@ -732,8 +732,8 @@ static uint32_t rx_status_fifo_pop(lan9118_state *s) if (s->rx_status_fifo_used != 0) { s->rx_status_fifo_used--; s->rx_status_fifo_head++; - if (s->rx_status_fifo_head >= s->rx_status_fifo_size) { - s->rx_status_fifo_head -= s->rx_status_fifo_size; + if (s->rx_status_fifo_head >= s->rx_status_fifo_wordcount) { + s->rx_status_fifo_head -= s->rx_status_fifo_wordcount; } /* ??? What value should be returned when the FIFO is empty? */ DPRINTF("RX status pop 0x%08x\n", val); From patchwork Tue Apr 9 13:37:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787207 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp221950wrs; Tue, 9 Apr 2024 06:39:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUEmJWgqAyOtchyjjnV11oHdLfpAqVs4B4YJyFNL9hfyQprTiEyalPLavV5vU8b1uS/06i5qkqBM8/BCqBIBScb X-Google-Smtp-Source: AGHT+IH+kjwlof2RlK2ErIsn74OAe8kpR9icEIswsI50gPI5FjAja3wg57o0WNLpwZiS+eYuPu/M X-Received: by 2002:a05:620a:2098:b0:78d:3b55:21c8 with SMTP id e24-20020a05620a209800b0078d3b5521c8mr4248682qka.24.1712669999580; Tue, 09 Apr 2024 06:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712669999; cv=none; d=google.com; s=arc-20160816; b=fLTgSPJVHURcVSeHi8F0TmAlvDB+lbssLdiyZnTTmBrRNiRq+MwdbXJ40KHmobmC7w PdlnfdjRAANxDN0XGxrJ/vkapQyTqmcKsyh+Q1nNX8ZyPXvn9GkFu+WYX5VqUPibmGOj sSryPvaSALCu+Nucx7Egcr1oCS1TvOzu7AgKDpU3GIFyQ78zUckRw431JXJgcOPfvdDz OsaGhvjG3DxzgXEoyLHJAOyN24r8EgVSTRoLTK4IdLEVMXOats2zi+yx1G4fnHdUqTQH 7+omNzWWhfM6C8oZ61Od6t6WhMqAxhg762QeLG1xzSsdTqflAjaoHSmNUn5nvfUklPdy kWCA== 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:dkim-signature; bh=BUMgonNV5vOyAHp4tN1LAQ2kYLBDrcDQNXezZFX8ne0=; fh=QOl9Xi9nQ721K4qxGgLCqy+fNk/yfBHdpOYFmb4mu2g=; b=TmDptSy2Cnzh0zadByMWc+VcLAUS3y13vx57FSeNtSJtJbhv8nF2oT0HIaxVYIXKC2 Pbm6zC0vuz9eUNjs8P3mtkHHkI8cPaSDc191k2ZpcqIYAfmQsvJJN9k6TktX0EZ2mC2E bfC6yp1vMb1L/BMVND+wT+4h1fpgle3wM3zCIKirwqSEFbt7TxTwFuixoOcfEJxZt8Wl RIW6kBdGXCtwTQvFNB6abh3iZllFY+fLcDEwMtjfQ+2AVyAsPjh9t2ZX4AplyBuwoWYa bYe7+NekCo3/eTcerm9lPD5E2ygY5UfkMLQVgWqENWwIeeQoW/VfBajyNMj9KHpQ4PIJ aOIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p8bOXGQO; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c25-20020a05620a201900b0078d66631907si4239023qka.625.2024.04.09.06.39.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:39:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=p8bOXGQO; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBhF-0007ZE-J1; Tue, 09 Apr 2024 09:39:33 -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 1ruBgr-0006Y4-EJ for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:39:11 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgk-0008HD-Fh for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:39:04 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41649860cecso17808135e9.0 for ; Tue, 09 Apr 2024 06:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669937; x=1713274737; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BUMgonNV5vOyAHp4tN1LAQ2kYLBDrcDQNXezZFX8ne0=; b=p8bOXGQOuKgwte04ATus/EVw/yQ8wfLPYg1GjcnVJd3+GjcPLpnm8AZkogpMZftjSv TaE4sTC3UlO1eGETwZXHrnbAv8EuRkVaWdznE3W7/NZurQ/AxZV6fSvdIIXYvL1WRUO+ cti/K5EMyN9PKd07mBXMRMDXHxOZNkBrc9w/7I08Y/IUN0E+tbPUwpz6c8Lkv1l4erc1 jEowID4GCAUByDorBWzW3tDK1PIMoRBPq+i3OHWA2pTT9QzNieohc0RzENySN2cDgFP0 ZJGx79+kzdd4RGi16AgR2XefcGwwLQII0extAW2wCIJYkQfis/K9IOQrbdgl1T72Btk1 nOkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669937; x=1713274737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BUMgonNV5vOyAHp4tN1LAQ2kYLBDrcDQNXezZFX8ne0=; b=JdsHfoHVmenzSDtRiFjMNhfPbORx0NG+88TruKVncStrAuMZZtw4riHxE3IywId4Km l7/zzFt8XhoaI+5GQbg0QuWvA5FLurmzyKcaYN2Lpg5Mj5kAfROjwGAfiqV1UGN0IGMm /dfYC55iOUG2i92irbvcVUyvRU/F44iDhZyhYgLwvGwOl13eYR7eWIZVqAn7dSjkim58 hVrdhDki42r7kP2yEPJXnHNHV0UdeCJivRf0ISBh4RH/zUMlzkdnirDTeYnaRPYsyiXy yLeWvUkMU5bSeXsWVU3UpLF2j3TIryUa7HgGBYr9crOPKekHq0ZBsUKvs3ncBov1S6Hk 4Qvg== X-Gm-Message-State: AOJu0YyU7L4Lw8m+lh6dgbgSSn5P2oW5Id1hj+8at4ZrH4PBORhKso8Y gPkd9m5WWXCwPDoDWhEYNOsBU9oRbblKQ3/KlIKtIuTtcddPhc+Kis/+SDmXPU2HoO4PHQKS+y/ h X-Received: by 2002:a05:600c:1d81:b0:416:7b2c:df0f with SMTP id p1-20020a05600c1d8100b004167b2cdf0fmr4921965wms.7.1712669937543; Tue, 09 Apr 2024 06:38:57 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id l15-20020a05600c4f0f00b004166b960469sm8107944wmq.38.2024.04.09.06.38.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:38:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 10/11] hw/net/lan9118: Use RX_DATA_FIFO_BYTES definition Date: Tue, 9 Apr 2024 15:37:59 +0200 Message-ID: <20240409133801.23503-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 rx_fifo[] is an array of words, rx_fifo_size is a word count. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 663776f575..56cc52d450 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -266,7 +266,7 @@ struct lan9118_state { int32_t rx_fifo_size; int32_t rx_fifo_used; int32_t rx_fifo_head; - uint32_t rx_fifo[3360]; + uint32_t rx_fifo[RX_DATA_FIFO_BYTES / 4]; int32_t rx_packet_size_head; int32_t rx_packet_size_tail; int32_t rx_packet_size[1024]; @@ -338,7 +338,9 @@ static const VMStateDescription vmstate_lan9118 = { VMSTATE_INT32(rx_fifo_size, lan9118_state), VMSTATE_INT32(rx_fifo_used, lan9118_state), VMSTATE_INT32(rx_fifo_head, lan9118_state), - VMSTATE_UINT32_ARRAY(rx_fifo, lan9118_state, 3360), + VMSTATE_UINT32_ARRAY(rx_fifo, lan9118_state, + RX_DATA_FIFO_BYTES / 4), + VMSTATE_UNUSED(3360 * 4 - RX_DATA_FIFO_BYTES), VMSTATE_INT32(rx_packet_size_head, lan9118_state), VMSTATE_INT32(rx_packet_size_tail, lan9118_state), VMSTATE_INT32_ARRAY(rx_packet_size, lan9118_state, 1024), @@ -460,7 +462,7 @@ static void lan9118_reset(DeviceState *d) s->txp->fifo_used = 0; s->tx_fifo_bytes = TX_DATA_FIFO_BYTES; s->tx_status_fifo_used = 0; - s->rx_fifo_size = 2640; + s->rx_fifo_size = RX_DATA_FIFO_BYTES / 4; s->rx_fifo_used = 0; s->rx_status_fifo_wordcount = RX_STATUS_FIFO_BYTES / 4; s->rx_status_fifo_used = 0; From patchwork Tue Apr 9 13:38:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787210 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp222189wrs; Tue, 9 Apr 2024 06:40:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJS5YyeTRdyDulAbyua4w1rrjd32KAc4gov5RA6eOSxOul9gL9bcY2CouwN24S2/2xrXjMjTDlXHq7Bf+KMNpQ X-Google-Smtp-Source: AGHT+IHiiCV9/o2mZrCFQLoSSnJwKppPsNdBNWxdXtj26R9+NVD4JTLWftTY0QracLdahuCT7dXR X-Received: by 2002:ad4:5cce:0:b0:69b:23eb:3d3a with SMTP id iu14-20020ad45cce000000b0069b23eb3d3amr4107949qvb.35.1712670027322; Tue, 09 Apr 2024 06:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712670027; cv=none; d=google.com; s=arc-20160816; b=cfsForihQj/9w03hkvrDZtIZweF0moI/JeRpxPhDyUU4vXpVlFctPV85WdhHgkT5Jo ZEuFR2eD+XTJVlipOyd8qWBDwn8LHOMeqS6vIRKVPcNfhbMUj54SxqgkxdGdyoQvVYMK hyld8Kohz5uSk3s2Zqhi118yO6IKuQqpXPwHcN09M1Jl4AaW+ZP1DzXpnqY5JU+6JJpY MqTJaRPe8PfBFKAjnnNU0E6yI9fVxUjPLS3ioB/GHLOKog1J0Xs3OoGzeLyYFk3QJz1s eTWYNmeLoTMphGhi5pjou64+fQXsn1B0UXkgt/CagYi6yjxNxVdjlG8UOBLCx7Yai3pE rBig== 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:dkim-signature; bh=C1Zw+CVRCq/SOI5cLQNhCw7GlRbzROScTIFOWQl3mYw=; fh=WkRGc9NPNzU781/uHO/isd3CBlh99lZ4TJgDgtZyIQ0=; b=qIG/faV2AINKOMC0yVAWdcPcODZwhRlMcadvB+BV9DnbguvpsGbO5BBPGf6HizKLA1 kIky0VSnvb2CVHRPUybPMnDok1k8JqBuqYTdKn87W38JtPXLm+B3dAHHa8/+nFF/LnJ3 nRGNYHiAh4Fi0TX7vLKl4heZqICjSi+kndzOPec7Z2eKjxymgONEngA+TUPyAE9e8Kxo 38gB9GswXAia0nxG39LOpVlQhw3PUu/Y2RNLtYeDi13C86l0NGApXj3JyF/6FwF46+LN cjJjtmbnQTcKnLbkjKlH2s2JgUnR62qJxNj/wnPkcC1B9XBw9I5jmadn+mrBNN7Iy1a/ iRiw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDLRDwUt; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b16-20020a0cc990000000b006992b58a4desi10582103qvk.231.2024.04.09.06.40.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 06:40: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; dkim=pass header.i=@linaro.org header.s=google header.b=QDLRDwUt; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruBhG-0007f3-6u; Tue, 09 Apr 2024 09:39:34 -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 1ruBgt-0006d6-FZ for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:39:13 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruBgq-0008Jh-Rc for qemu-devel@nongnu.org; Tue, 09 Apr 2024 09:39:10 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-343bccc0b2cso4087158f8f.1 for ; Tue, 09 Apr 2024 06:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712669943; x=1713274743; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C1Zw+CVRCq/SOI5cLQNhCw7GlRbzROScTIFOWQl3mYw=; b=QDLRDwUt9F260+tAmYNolfScg60li8Hg55PKVdG0mGNsqfJdsCZ3EhL2EzRWmqJq2M R1lY3Z9ufDqcdj5Wa+ff64cqsDay+cmmHubcElOvq8UpXVOIAKxrRQ4VLIqR/Yy57F6n +OH+QVZUUDBcmTTjCeM3Rvy+kI9GXfnjOvnIEUonWKCn6Knu2sroQL4bvu3ijZbnfxyz 7uXtkkSVoxX94M/+EMLtWyI7ETpb5JdLxU1CgaVyNLMypuUJ1Li8fnEjFvyjL6uCFLz6 SP9g/kU5AzptsVKOGVyR5vO/CTmLek7e6Z9hkZqJGjr5SuY8A2ukznHdNdy6V5CsRtEC KtLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712669943; x=1713274743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C1Zw+CVRCq/SOI5cLQNhCw7GlRbzROScTIFOWQl3mYw=; b=bF+MTTDY0jvwztw1C9FL3TMCVBFwtzql0uTQIJINiBmmgj358ow+EYzvvKbl6tXNlH n7BfJBsE65l2cIHdQE88C15Ae27GW7yMD9X6GgUc/4s2avHf3j1SZpfzzgHiq6c9ULY9 VzxY0TUXWn8283e6C4lsVHnmsf9SgJWNTYZTzT2by2nl7uCmnukg/R9ihM3iyv3hgWa0 I7ttUCLiGTKDY/lsy5/n1C6AYj8pxzSpk2q/7B1iED2kQzh/Vyf/exzLqIZ/wK9zYz5m wdCpRsa5brmZ26b6Z7q1CC5j5+lV5RVRA7SD43Bo5lMBa0HqUpSp8i46b6vxmcdZAmUW atFw== X-Gm-Message-State: AOJu0YxUe+r3JIP5RDI24qq3DoEVDQTiDGlK87BQYsCzdQOV4s8NRT9h mwNmWx3t3jHHK2BJD3arQitIo2mQUl4tOvEUA4g6kex7CBa9WMqizinLY4a9+wbNdZyUyBQsK3/ N X-Received: by 2002:adf:e847:0:b0:343:dd56:b941 with SMTP id d7-20020adfe847000000b00343dd56b941mr8105877wrn.52.1712669942881; Tue, 09 Apr 2024 06:39:02 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id k7-20020a5d5187000000b003434c764f01sm11479350wrv.107.2024.04.09.06.39.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 06:39:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Chuhong Yuan , Jason Wang , Alexander Bulekov , qemu-arm@nongnu.org, =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH-for-9.1 v2 11/11] hw/net/lan9118: Rename rx_fifo_size -> rx_fifo_wordcount Date: Tue, 9 Apr 2024 15:38:00 +0200 Message-ID: <20240409133801.23503-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409133801.23503-1-philmd@linaro.org> References: <20240409133801.23503-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 rx_fifo_size is a word count, rename it to avoid confusion. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 56cc52d450..3db6bae908 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -263,7 +263,7 @@ struct lan9118_state { int32_t rx_status_fifo_used; int32_t rx_status_fifo_head; uint32_t rx_status_fifo[RX_STATUS_FIFO_BYTES / 4]; - int32_t rx_fifo_size; + int32_t rx_fifo_wordcount; int32_t rx_fifo_used; int32_t rx_fifo_head; uint32_t rx_fifo[RX_DATA_FIFO_BYTES / 4]; @@ -335,7 +335,7 @@ static const VMStateDescription vmstate_lan9118 = { VMSTATE_UINT32_ARRAY(rx_status_fifo, lan9118_state, RX_STATUS_FIFO_BYTES / 4), VMSTATE_UNUSED(896 * 4 - RX_STATUS_FIFO_BYTES), - VMSTATE_INT32(rx_fifo_size, lan9118_state), + VMSTATE_INT32(rx_fifo_wordcount, lan9118_state), VMSTATE_INT32(rx_fifo_used, lan9118_state), VMSTATE_INT32(rx_fifo_head, lan9118_state), VMSTATE_UINT32_ARRAY(rx_fifo, lan9118_state, @@ -462,7 +462,7 @@ static void lan9118_reset(DeviceState *d) s->txp->fifo_used = 0; s->tx_fifo_bytes = TX_DATA_FIFO_BYTES; s->tx_status_fifo_used = 0; - s->rx_fifo_size = RX_DATA_FIFO_BYTES / 4; + s->rx_fifo_wordcount = RX_DATA_FIFO_BYTES / 4; s->rx_fifo_used = 0; s->rx_status_fifo_wordcount = RX_STATUS_FIFO_BYTES / 4; s->rx_status_fifo_used = 0; @@ -504,8 +504,9 @@ static void rx_fifo_push(lan9118_state *s, uint32_t val) { int fifo_pos; fifo_pos = s->rx_fifo_head + s->rx_fifo_used; - if (fifo_pos >= s->rx_fifo_size) - fifo_pos -= s->rx_fifo_size; + if (fifo_pos >= s->rx_fifo_wordcount) { + fifo_pos -= s->rx_fifo_wordcount; + } s->rx_fifo[fifo_pos] = val; s->rx_fifo_used++; } @@ -584,7 +585,7 @@ static ssize_t lan9118_receive(NetClientState *nc, const uint8_t *buf, fifo_len = (size + n + 3) >> 2; /* Add a word for the CRC. */ fifo_len++; - if (s->rx_fifo_size - s->rx_fifo_used < fifo_len) { + if (s->rx_fifo_wordcount - s->rx_fifo_used < fifo_len) { return -1; } @@ -672,8 +673,8 @@ static uint32_t rx_fifo_pop(lan9118_state *s) } else if (s->rxp_size > 0) { s->rxp_size--; val = s->rx_fifo[s->rx_fifo_head++]; - if (s->rx_fifo_head >= s->rx_fifo_size) { - s->rx_fifo_head -= s->rx_fifo_size; + if (s->rx_fifo_head >= s->rx_fifo_wordcount) { + s->rx_fifo_head -= s->rx_fifo_wordcount; } s->rx_fifo_used--; } else if (s->rxp_pad > 0) { @@ -1135,8 +1136,8 @@ static void lan9118_writel(void *opaque, hwaddr offset, s->rxp_offset = 0; } s->rx_fifo_head += s->rxp_size; - if (s->rx_fifo_head >= s->rx_fifo_size) { - s->rx_fifo_head -= s->rx_fifo_size; + if (s->rx_fifo_head >= s->rx_fifo_wordcount) { + s->rx_fifo_head -= s->rx_fifo_wordcount; } } break;