From patchwork Mon Jul 22 16:07:45 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: 813733 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1942126wro; Mon, 22 Jul 2024 09:10:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUEWRLpzZYMsqsFKWHeaeZ2gNHQy7vgX3vhtAuo4j+WoWjW0kUZs0AYXZ+zjoknKMrpkrsmCTeiNZDmCWsQCGFV X-Google-Smtp-Source: AGHT+IHBik7Gq0+yivxwPVUQGFkulMyqKyrtvn5MUVAh0BwGLuZwgdJ1SZd5Zp7vw6b7AAXZUQMN X-Received: by 2002:ac8:7dc2:0:b0:446:64c9:df6a with SMTP id d75a77b69052e-44fc559b51dmr2986941cf.55.1721664651550; Mon, 22 Jul 2024 09:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664651; cv=none; d=google.com; s=arc-20160816; b=pTcL8ZRHbeeo0JSDmy8B8PE2YNL5pRdEi5crHggr2E4trFzsD3yNcHk4+QPmt6gCaw 3qIIxXbrDfXOrpZ/s11i8tuKdaPNqbghCDevTBG1KRfFnlsPVhqUnIyhhLyAUC9ZCr/I k7X+F/CDmi0RefzkbYz3Y2XJOv0xJ4eYBX6maaVHajfOq95xwTPsbYRuH7O5rNQMoiqc CiG4xWyc74W55Rqg7bVczNxLmycj53EpQuP8yieN1WqNhJ1MEtM4TG9Z/x/AZm9BrNYk 0M1x0HlmKW3eCxjjHD8G4U7TOx+5gFx5S5L53rrwokfrGOlDg71i7Kicaa8nCf1fMJH7 6tfA== 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=zi4Xrl4JBTbdJac2W2gQ0MSIXZWbJ+xQSRf0Wad1r6QtwydIC29Jiihm6KqmvQsMQi C/AAqGCMtX7OlFDdcYX0FaAYGMxQFWLHGKDMYhUGx2+ADJVra4xgfY4m1JvmAnWFWzHs Yotrz0Vn+xcipVZw93nwHAf5Qv1hao/ZURc8y0Kf79xTAZsxg/OIBSN7WbojKk9kebHS rF6g+McJP97f7OA+luGjGNp+RnRWclTybutK6YDQZCWKyTVkVuZFnS6ToBlTilAMInIm Zpg4VfNASbGXeMbG+Tr4LAOCbeUR3AafG7PfGKEP9Oi7d7vYS/6+GXCSlv5Z9KerjA3q U9BQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K9YNVqLt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ce04cf8si85118951cf.619.2024.07.22.09.10.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:10:51 -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=K9YNVqLt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvai-0000eR-W6; Mon, 22 Jul 2024 12:08:49 -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 1sVvah-0000YP-8H for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:47 -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 1sVvad-0007qV-LP for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:46 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4266ea6a488so38728365e9.1 for ; Mon, 22 Jul 2024 09:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664520; x=1722269320; 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; b=K9YNVqLtWWTk+hxjMwf9Eatx1nXW+GfNWMwXRDGVMbXBREsT24Sh3+Rn6vzdaHlOXC YTHN6aYKqXS8b2nlRblCPlgwiCMp9PmyHMpCkarljXx0N4pruHFRpE+scBEx9WmNdK9D pb6pOP/iopkk/1cl3yoswM6JFh1EWRUSS7mT/wJlzbrhzbKmZf10PAAivQp+7XV+zZ4C CoOAi8ISS3AuO+pKEr2Kec/k1Vjx6CBym17pqHOL6jVrBft15dqV6pNtXi62urqSfnAK 9iUoQW+rZEPgZIleJwm0CAf7QVuKmxt0SYKu61urMPEP/YDgg7yuPoUyZ/bEfQF+ieVt GVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664520; x=1722269320; 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; b=cfJbu0wlgoWQIrB6N0ooYnZ2lp9EV0dCfcN0gmkOLIUoG+aRcSfRlhOm0pSSQaTsZv W5VnqYmfBy63yy+iq6xPdy9NVu5L+toS5QDkNqHlmzunEYKRuyrjeMzT3fVOQprN7EbI MLA9YE776VZzNUtc9PX0CBbnChlaiy7KfMELEOYEmWXXZVokM2yfJbt5JDEALfvmg9+h GXh0O4cpAo/PDOHwv8zj+HGzlAZ04qH/mZgVW86SxZ58LR8x/zvtY/FUWHKPwqRNbC8H rr3TLJ/gg/Azsc2UJfl30Piszi16Kv/zrLD+b0KydTxSBt2Em6BJGPYIAWRIRJz6PELU eT4Q== X-Gm-Message-State: AOJu0YwLDPcY5MMeLUPzKtI7/qYVTMkS1ohyCo9onEx4UKt5x/lSeLsJ Lt+kKqKWEkMwqzj/Oo68ZXWrpRvYPapxNLcZJ0Ym5yVFR6G9gVjGUt5mB20vQitI+LYnYYagF/r m X-Received: by 2002:a05:600c:3b26:b0:426:5b44:2be7 with SMTP id 5b1f17b1804b1-427dc5204bfmr69229835e9.10.1721664520226; Mon, 22 Jul 2024 09:08:40 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427e29d11d5sm66473215e9.38.2024.07.22.09.08.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 7/7] util/fifo8: Introduce fifo8_discard() Date: Mon, 22 Jul 2024 18:07:45 +0200 Message-ID: <20240722160745.67904-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-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 Add the fifo8_discard() helper for clarity. It is a simple wrapper over fifo8_pop_buf(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 8 ++++++++ hw/scsi/esp.c | 2 +- util/fifo8.c | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 21c7a22937..53bafabd25 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -129,6 +129,14 @@ const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); */ const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +/** + * fifo8_discard: + * @fifo: FIFO to consume bytes + * + * Discard (consume) bytes from a FIFO. + */ +void fifo8_discard(Fifo8 *fifo, uint32_t len); + /** * fifo8_reset: * @fifo: FIFO to reset diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index cec847b54a..c703fa7351 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -351,7 +351,7 @@ static void do_message_phase(ESPState *s) /* Ignore extended messages for now */ if (s->cmdfifo_cdb_offset) { int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo)); - fifo8_pop_buf(&s->cmdfifo, NULL, len); + fifo8_discard(&s->cmdfifo, len); s->cmdfifo_cdb_offset = 0; } } diff --git a/util/fifo8.c b/util/fifo8.c index 6610b79182..ea39ca2552 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -131,6 +131,12 @@ uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen) return n1 + n2; } +void fifo8_consume(Fifo8 *fifo, uint32_t len) +{ + len -= fifo8_pop_buf(fifo, NULL, len); + assert(len == 0); +} + bool fifo8_is_empty(Fifo8 *fifo) { return (fifo->num == 0);