From patchwork Mon Sep 30 07:34: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: 831524 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp1831947wrw; Mon, 30 Sep 2024 01:02:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUhyXkloeNLX7snEVwC8CjDHQDYmthtXciIo4/1nANubNNogyW/KJuEb0dMJJVuAmvlACkHlQ==@linaro.org X-Google-Smtp-Source: AGHT+IFvFg7QF+Fe0BnyUOWqV1BKkZIQKAicavlCsBngDvPNsw5nbsmfjxTKkUOdaDzgCafrAKWv X-Received: by 2002:a05:6214:3d02:b0:6cb:3afd:f9f1 with SMTP id 6a1803df08f44-6cb3b5c54ffmr141233936d6.8.1727683328938; Mon, 30 Sep 2024 01:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727683328; cv=none; d=google.com; s=arc-20240605; b=DvIJ4ijsT1YGyR4COu9nvcfahglzdSUhS/zW2+ZZst3yAN4DRLmyauZd8DJKIHkaP8 v1B14YKxvu+RF8KsSLh2dLbwueJT43YpVFkDsb+ZvW58+M9G9C8Vfah4nc1F4ZDk55Ei U13OkSUxXDU71g5FY5kM6zEZ/FAnu2+3GjsR2OkS9MU0VBv62APZmNcSll1lA3ZuPzOE fmyv1RMXI1A+VCuJ2CBfw6y1+AnKh1FIMpV99nPjv5YiUYg3AD9IzEi4MOAPHEZ1e1QY qd3vftkqNcVF0l9GFxiz/zJOiIBr8iaZFp7xn6DWBcfoqaLHMnGv3ucFWNcArPbfxvne gzXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=qgFNx5loGg07bkVRCAPUaZ+t66SDahiEcwbYBeR9pKk=; fh=Wy2Q3sNWPDKxNwELUcZZKTFep4jJmSUk04d3iQNw3B8=; b=NXTu971B0QorANL09KmgVG0co8ssXqKXRCNvxHMvDaaWU1RH2s78LOr+dr5NczR/wJ sN8iZWFx9GVikeHN0lDDltUUdBWD0Bq3Lv8C6LMVqg5hiGwd2uc77KvqxMCu1ri+4R+n Kg4ASqYJc9ljRjNU/MXWD6ShMGtoQ24omn62ahy5yUxaASSITpVVzxCvJ0jrBGjXza03 sOF1ILqqZCQUaqT+ZzqpbiOuhN2ixvb3p685/+/yuZx8MtwBToTRT15GcqRXDRqvVv5J v35f5c5AL+uAoK/Rgtu+C8GlHA+LyC0cIPyuoH861GQmCP10y5q3keqoq3lnVV7fJzwy Toxw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OcrhSLLd; 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 6a1803df08f44-6cb3b6cca2asi86860026d6.586.2024.09.30.01.02.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2024 01:02:08 -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=OcrhSLLd; 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 1svBLf-0006Y7-2D; Mon, 30 Sep 2024 04:01:39 -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 1svBLO-0006A2-U0 for qemu-devel@nongnu.org; Mon, 30 Sep 2024 04:01:33 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svBLN-0003i2-AH for qemu-devel@nongnu.org; Mon, 30 Sep 2024 04:01:22 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5398e53ca28so1296609e87.3 for ; Mon, 30 Sep 2024 01:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727683279; x=1728288079; 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=qgFNx5loGg07bkVRCAPUaZ+t66SDahiEcwbYBeR9pKk=; b=OcrhSLLdI4UVTTegTKcFLkH0S9eazbZxrXRy5HY1H1dHikwJ6dyfEssgYEmmGLroA7 fGzoUJwWP1L+QG/mkERMnA6l+O+FU+zq8Ux4/fCq56Y5m+aazUaSVVMy8+u6kE8PKBA9 qn6qNrsRbaIXkd8at07+uGWqzFqeS+VapKWX3vIf75kRs1YbFIwHiEz/ORi/x4dqMvDp okNse1YW0LJKq3PG5V6kj+sb754EeKnZcH6zZXoOk0r1kjALfq1X4lb+CZyoG1gwFfRY 5TPx3RdXIT4HQgl1X8gPtjxXpLFt19ES7lEo/KPFi48RP7wAl9AHanx9qwa0qF1ge3vQ vXTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727683279; x=1728288079; 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=qgFNx5loGg07bkVRCAPUaZ+t66SDahiEcwbYBeR9pKk=; b=fTh9ExoiIZSSy4AhEfMbtc1vNVXBf2Ek6gp3Vft4DhJDaw60RBjfG4Qpp77iAGWcUp UU0sRfeg0d0dBE2HoqDWlbuMC52a5obvA/jg1MtpUGYhgRO7kO/wSiTL17RGcaF3ATy7 OSWkeZawis8aypo8P4VNjZ512evFaLQszlbU5aBNVkYEiUOJnEJxB/B+AC6bF+80cBah E4ZVOYmHdw2Ppqp8oVwByaBcaD2kNO7i6RrBVs2VxpUVZNDJGpTmaRYHGmzAmS9FMG/8 oGDDvSn9HpnkDs4gDi5Q/nGxhQSLEDLgu9aB9ANp/CdaMxbBRsVJIArC9T1Aq77Kq87b eZbQ== X-Gm-Message-State: AOJu0Yx+MJ4eZC6YOhPoqNLobRpCZmWeiJNrMCY96WupR+tKwcgbr/KZ auAOzT6fejY7TSMWFtc155HngEMzHlqzzemP9QgndJ6CZLKyfozvuvNS1c7VVxa07LZIrcV56nN C8ys= X-Received: by 2002:adf:8bd3:0:b0:37c:cd0d:3433 with SMTP id ffacd0b85a97d-37cd5a9e0f3mr6507614f8f.29.1727681802055; Mon, 30 Sep 2024 00:36:42 -0700 (PDT) Received: from localhost.localdomain (186.red-88-28-13.dynamicip.rima-tde.net. [88.28.13.186]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd57427c6sm8356329f8f.96.2024.09.30.00.36.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Sep 2024 00:36:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Jason Wang , Aleksandar Rikalo , Anton Johansson , Peter Maydell , Huacai Chen , "Michael S. Tsirkin" , Sven Schnelle , Jiaxun Yang , qemu-arm@nongnu.org, Aurelien Jarno , Pierrick Bouvier , Max Filippov , Paul Burton Subject: [PATCH 13/13] hw/net/tulip: Use ld/st_endian_pci_dma() API Date: Mon, 30 Sep 2024 09:34:50 +0200 Message-ID: <20240930073450.33195-14-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930073450.33195-1-philmd@linaro.org> References: <20240930073450.33195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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, 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 Refactor to use the recently introduced ld/st_endian_pci_dma() API. No logical change intended. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- hw/net/tulip.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index 9df3e17162..6c67958da7 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -71,36 +71,24 @@ static void tulip_desc_read(TULIPState *s, hwaddr p, struct tulip_descriptor *desc) { const MemTxAttrs attrs = { .memory = true }; + bool use_big_endian = s->csr[0] & CSR0_DBO; - if (s->csr[0] & CSR0_DBO) { - ldl_be_pci_dma(&s->dev, p, &desc->status, attrs); - ldl_be_pci_dma(&s->dev, p + 4, &desc->control, attrs); - ldl_be_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs); - ldl_be_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs); - } else { - ldl_le_pci_dma(&s->dev, p, &desc->status, attrs); - ldl_le_pci_dma(&s->dev, p + 4, &desc->control, attrs); - ldl_le_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs); - ldl_le_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs); - } + ldl_endian_pci_dma(use_big_endian, &s->dev, p, &desc->status, attrs); + ldl_endian_pci_dma(use_big_endian, &s->dev, p + 4, &desc->control, attrs); + ldl_endian_pci_dma(use_big_endian, &s->dev, p + 8, &desc->buf_addr1, attrs); + ldl_endian_pci_dma(use_big_endian, &s->dev, p + 12, &desc->buf_addr2, attrs); } static void tulip_desc_write(TULIPState *s, hwaddr p, struct tulip_descriptor *desc) { const MemTxAttrs attrs = { .memory = true }; + bool use_big_endian = s->csr[0] & CSR0_DBO; - if (s->csr[0] & CSR0_DBO) { - stl_be_pci_dma(&s->dev, p, desc->status, attrs); - stl_be_pci_dma(&s->dev, p + 4, desc->control, attrs); - stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); - stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); - } else { - stl_le_pci_dma(&s->dev, p, desc->status, attrs); - stl_le_pci_dma(&s->dev, p + 4, desc->control, attrs); - stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); - stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); - } + stl_endian_pci_dma(use_big_endian, &s->dev, p, desc->status, attrs); + stl_endian_pci_dma(use_big_endian, &s->dev, p + 4, desc->control, attrs); + stl_endian_pci_dma(use_big_endian, &s->dev, p + 8, desc->buf_addr1, attrs); + stl_endian_pci_dma(use_big_endian, &s->dev, p + 12, desc->buf_addr2, attrs); } static void tulip_update_int(TULIPState *s)