From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730678; cv=none; d=zohomail.com; s=zohoarc; b=m6y+QdOxeXtqOV+c20P9Y9pfKHvFwIAQ54E6xnz5U53WA7EJrrAedD7bWE4ms6bBQMvnaRXx9Jkpn0eYJTKHlIUoLZ/YV2oWMbkbgo1hlo4E0REpnvUx3T63CQkueI5KFCAfMjrwP1rXYc6x4H8cbRdpvfL+MnmrIsNtGOqRqq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730678; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UHA6cw5duNChzRkisU1kblSnuYm9RTmHim2/vThBDEc=; b=aLWIP4jAWieZTMIXN8dL2hSe9ivDo6AGO0nIUVtn3xoZMs27BzoE1SBtUBD2kC+N1pvEZ7oaHjICapNtzCh0EYwf7bQDospYScG/A4eg4IsSAFu7lx6Mgiu31BVG+W8WHQGJ8ZwMBwPgQqTQ/922GRe2t9lP5DfMVYpA6geDu6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730678329891.4075796835458; Mon, 26 Aug 2024 20:51:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinEI-0004vW-Qq; Mon, 26 Aug 2024 23:50:51 -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 1sinEG-0004uU-HW for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:48 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEE-0003pi-WB for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:48 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-204d391f53bso12762775ad.2 for ; Mon, 26 Aug 2024 20:50:46 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730645; x=1725335445; 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=UHA6cw5duNChzRkisU1kblSnuYm9RTmHim2/vThBDEc=; b=chVk0xlDvyOdOmUlRvCGIJXwixDR0Ny6fdDNB71mY0BFLDIJlVMcHCGM/ntq3Lt37E enbaCWcXTDw66OYp1Gn1dzmZBwi1MaSOUmrZWkhnQFDeW2MLenZgPnYGxrHlrmVwHwQn vkfcQVGp2bKBhJ1mSmop1ArhhZdSqoOBZ8g2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730645; x=1725335445; 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=UHA6cw5duNChzRkisU1kblSnuYm9RTmHim2/vThBDEc=; b=YLYYg2AeEc/vbOxd2BrrUjv27d6O5PpLCzmosQ/kGMPRw7NT7vhhGHwdcC8PZ68iQk pkQvBMdlDuVwYSb+GTw5APbExqBLTJIte7j1H7DAyuqLKHWo6Lykw0CMgCACbv83r5oi qJthlMkvcTdrb9b8IzoeLCLLshkM8QIf2Rw++pKgtoypf2bUzrgHHrcq+/qYRrfJhJii h6MqHgmOpBoqmp7CKki8yHZP1gLcIorqgBiS1Qh2e5c2W5XNaWOSNw3c73Wz/q5nLxtz AVo3KA/YF47b3U0rnV5xsTxWqs2O7bg4Wii0Qy2UxRuNcJBFuGQqLI4ASGMFV6BGKCuw j9sg== X-Forwarded-Encrypted: i=1; AJvYcCUvu5yF6tFYJtTQ4f/bFWuB7cypJvlU9K3Bea3cpKMYM+ZEux4O1kV2BjEwiXGQfRb3c8BX+/Muu/JK@nongnu.org X-Gm-Message-State: AOJu0YxDBUUHLtp5YpxYeETPSNDx7++yTexu4330SCNh5CRGcIiUUKbL rFLKvej+BEZajhHTpEY1ULc/T9VIFXDSteNUi1zzzubDZd5SYW8qREtcYTVs8VfcRTg9ZrWOSKW 2PLmSVQ== X-Google-Smtp-Source: AGHT+IFurwu+Jv5psvR4SfizAmgJWtpim4N3JALHfxN9irgZeiJuYfLBuJoEeLed+ZQQkiF5UeqTFw== X-Received: by 2002:a17:902:c942:b0:202:48a6:c882 with SMTP id d9443c01a7336-204df4e337dmr17398485ad.52.1724730644936; Mon, 26 Aug 2024 20:50:44 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 1/7] hw/net/can/xlnx-versal-canfd: Fix interrupt level Date: Mon, 26 Aug 2024 20:49:21 -0700 Message-Id: <20240827034927.66659-2-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=doug@schmorgal.com; helo=mail-pl1-x62b.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730681264116600 Content-Type: text/plain; charset="utf-8" The interrupt level should be 0 or 1. The existing code was using the interrupt flags to determine the level. In the only machine currently supported (xlnx-versal-virt), the GICv3 was masking off all bits except bit 0 when applying it, resulting in the IRQ never being delivered. Signed-off-by: Doug Brown Reviewed-by: Francisco Iglesias Reviewed-by: Pavel Pisa --- hw/net/can/xlnx-versal-canfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 5f083c21e9..ad0c4da3c8 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -682,8 +682,8 @@ static uint8_t canfd_dlc_array[8] =3D {8, 12, 16, 20, 2= 4, 32, 48, 64}; =20 static void canfd_update_irq(XlnxVersalCANFDState *s) { - unsigned int irq =3D s->regs[R_INTERRUPT_STATUS_REGISTER] & - s->regs[R_INTERRUPT_ENABLE_REGISTER]; + const bool irq =3D (s->regs[R_INTERRUPT_STATUS_REGISTER] & + s->regs[R_INTERRUPT_ENABLE_REGISTER]) !=3D 0; g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); =20 /* RX watermark interrupts. */ --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730678; cv=none; d=zohomail.com; s=zohoarc; b=hfpxWJrOnepzP98bSh7lkk6+ovUVWFaYR6BxaR632JkwODkmriDx8ZQHbTMmUdDPfS2OSIXhRMtBp2utX/i8cB3cXPSco4dgXttuFHH3TgzXZ5zm689zvC5W+M53pSXEw/iykH8FZxsds2iDI1KpMn93c8xBuwcwrx+vEn6wfjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730678; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6OPbVwUKXCH/ZUut8ds9FLbfn3e0300EaiaFIsbv4pw=; b=OtMlv8yug0ar2hgh1HrqCZcixqYw5sI4RKTWSM126RFXPZ8v5oDHU8QLpJoza2FXQwHNr1BFsDRBmlwVOCpg0Euk1P6GHhQz7LYnhpKh0B1ClJOosAtW9zSd0LRMEsI5WRNtmcPXyVSXu+ZxRu2E1HHXn9q+kkG9GbChef0VqLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730678524849.844802114575; Mon, 26 Aug 2024 20:51:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinEN-00052c-Li; Mon, 26 Aug 2024 23:50:57 -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 1sinEJ-0004vw-24 for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:51 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEG-0003pq-Hz for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:49 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-201df0b2df4so40715555ad.0 for ; Mon, 26 Aug 2024 20:50:48 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730647; x=1725335447; 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=6OPbVwUKXCH/ZUut8ds9FLbfn3e0300EaiaFIsbv4pw=; b=Noe43Pkj15yEUxwo040PnZkPKPzU9BSx2UrOCTG7CsPIGR5mW5E9E34wp4jiNNWVaS kPj8AdYgnXkvoB5opf2zx3GDb9HJl79UF6rdu9PKOekIHCiKVm/GS1wolXHQRFonHZI4 oqCT8EOqCgkeNyP00TVd28Utyf1JkO9vAEEZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730647; x=1725335447; 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=6OPbVwUKXCH/ZUut8ds9FLbfn3e0300EaiaFIsbv4pw=; b=gB4iGc1ZU2tZmZCDQDs+C2cAtFx+dEowf2GD7dbd7L+2tunLJIgeNvf2ndEDFQBco/ cV1KmmX6J0LDgXncNStrdkULeuYsGzWfJqCW7q+OikHO7xsVCifb4Yi5rdCY4LHc6eJE xxacsAAKKUGiwsYxmUlTHCkzZPEVicvLBSMoBzAaWb9K2v82p4BpkPwxuUbZBV/Vf3QV k6H2Ffmioba+rimCemx6ZusIszBYkT3ziHBYY0seElfarF8prl8dDIu4kdhzaAB/XDOG OE73ZFpw6mcsYw23DdNsN4hXJS8w/V95wrFoVoIeSKxFllZme00icOVjgtNgfFggMInD /ymw== X-Forwarded-Encrypted: i=1; AJvYcCUUUblLKkppcVgsQGuI4p6fsXwfPSG+dvWcRA3qguAj9XqNGjraX2ebcgbITiMxY244ar9/+oVJg/qh@nongnu.org X-Gm-Message-State: AOJu0YydOP1Bnl+cNPLPU8rq3+AFPicYkHw20vpqTzz6s6Gs374OK/BY QVBwipilWi2W9v2cCQbEzB+LniEW3teCbBxjyohCLndaEFMyBKWM1OYCJ2fi6n4= X-Google-Smtp-Source: AGHT+IFOf+n6n/YjXR/TV5GKVYumayLespLoZ2LxMmi9p2CuaAcA3k6mzi0PIJDRJr23ukZymeHtiA== X-Received: by 2002:a17:902:d503:b0:202:3430:654e with SMTP id d9443c01a7336-2039e4f2573mr175015125ad.42.1724730647210; Mon, 26 Aug 2024 20:50:47 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 2/7] hw/net/can/xlnx-versal-canfd: Fix CAN FD flag check Date: Mon, 26 Aug 2024 20:49:22 -0700 Message-Id: <20240827034927.66659-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=doug@schmorgal.com; helo=mail-pl1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730681252116600 Content-Type: text/plain; charset="utf-8" When checking the QEMU_CAN_FRMF_TYPE_FD flag, we need to ignore other potentially set flags. Before this change, received CAN FD frames from SocketCAN weren't being recognized as CAN FD. Signed-off-by: Doug Brown Reviewed-by: Pavel Pisa Reviewed-by: Francisco Iglesias --- hw/net/can/xlnx-versal-canfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index ad0c4da3c8..8968672b84 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -1003,7 +1003,7 @@ static void store_rx_sequential(XlnxVersalCANFDState = *s, =20 dlc =3D frame->can_dlc; =20 - if (frame->flags =3D=3D QEMU_CAN_FRMF_TYPE_FD) { + if (frame->flags & QEMU_CAN_FRMF_TYPE_FD) { is_canfd_frame =3D true; =20 /* Store dlc value in Xilinx specific format. */ --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730734; cv=none; d=zohomail.com; s=zohoarc; b=DhEcEEYCDFont7dug/gGiBzOsyud9abvtFdmksfB04OvxeUMajJD1H5IbR62m0eWThB7Mo0q6+mM1Q3OS0lxWc5/qb7cS96a3BOspr+X1eILZJvKwKwqs4TwICr87jOnbqbM9nIw15lx91SMWO7OfwQ2vinxIARty3G0EbPzR+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730734; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ror+zQ+DasxDMrRgs2ZAqV/eDrJt5Rr/T3wV9vKTaPA=; b=jBdpnQdjQR1WVkjNFbCNtVN2K4N1BCeIKwLnLdZ1RuqLQzlIXHQuL7LipzHmRaa6pe1n9nlEznTjm5pRiV/2Ub+/9ALpTPpY0GllaprrBg9OE7J8qubHyCXGFR8woXB4EIT2yTbtTQ8iVTn3DnI1KhaQxrVMcPVlZp4s4tv7lkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730734489586.9932811027674; Mon, 26 Aug 2024 20:52:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinEQ-0005At-NV; Mon, 26 Aug 2024 23:50:58 -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 1sinEL-00050q-Sz for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:55 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEI-0003qK-LE for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:53 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fc47abc040so43308285ad.0 for ; Mon, 26 Aug 2024 20:50:49 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730649; x=1725335449; 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=Ror+zQ+DasxDMrRgs2ZAqV/eDrJt5Rr/T3wV9vKTaPA=; b=iwZi6GGqP0SV4O9nSpowq1P4uFAZOFM+HhsXiNFZjFqjR3Z/6r+Zm6X0Np5eIk9SZZ IvWgpbJigdxxQCgPj+y3dm4FEA+c6mufnaQtbArIbFaPVzq1qUAFXtGoO/j2v+WPpbLN D4vUD8uNLpDzU8eCupNI2RV8++NF35sUBYxXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730649; x=1725335449; 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=Ror+zQ+DasxDMrRgs2ZAqV/eDrJt5Rr/T3wV9vKTaPA=; b=DZXFqyPu6kA+q8oeZPP8fia4ETbFyVlA2u0OYyG/I44epK7BqRvKBVz/tytXpDAQai 1u2y4Gn3RFtVm84GPiZNDnfVz/KlnkOqqUsX6gkhcliKzydEx6AY8uDuRrEJZpIHfQ9E HeEs90j2zAEQKTdUdBaT0R78xztQUuajHQFp5UqBr3KN0raulIPwm2oLNNL5yKAedF0C ucjR/1RDFq3e/vZymyueFDiK9f90IB8zD3/MrLe2tMtZoaWbaxpMcVBKvkYNsk4hwaeS N1qgk4NpWurCJP4AQeBIdfgcqDX3IyZ01yP7aWaKOjqu+8thDyI15Mvkib+We3pI1IkI mvPA== X-Forwarded-Encrypted: i=1; AJvYcCWBCkuaWM+T04IhlkWEtZq3APuaqI3p7HKSHiltumwENPVqPhmOxlm6HzULKSCDpesbeL2ii4TA2mnE@nongnu.org X-Gm-Message-State: AOJu0YzICoqVOqadSEohgFy77WnMVaUKsbwPHJTKH1vpeYEGvJpLK0Kd dbZdENxtBj45W6NLQrL7ZStslnHzTHYek2e5XVs6yxty0wL6lnpSjErPwbITfKU= X-Google-Smtp-Source: AGHT+IH7r2rul8mzFc9QMCi4nmCHwJCYg4Z6YP/mq3st+xfgjYV5Tas+S2/vWDMwDPjdw1MAYnFUzg== X-Received: by 2002:a17:902:db09:b0:1fc:6a13:a39f with SMTP id d9443c01a7336-2039e48a2eemr167277755ad.25.1724730648755; Mon, 26 Aug 2024 20:50:48 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 3/7] hw/net/can/xlnx-versal-canfd: Translate CAN ID registers Date: Mon, 26 Aug 2024 20:49:23 -0700 Message-Id: <20240827034927.66659-4-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=doug@schmorgal.com; helo=mail-pl1-x629.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730735663116600 Content-Type: text/plain; charset="utf-8" Previously the emulated CAN ID register was being set to the exact same value stored in qemu_can_frame.can_id. This doesn't work correctly because the Xilinx IP core uses a different bit arrangement than qemu_can_frame for all of its ID registers. Correct this problem for both RX and TX, including RX filtering. Signed-off-by: Doug Brown Reviewed-by: Francisco Iglesias Acked-by: Pavel Pisa --- hw/net/can/xlnx-versal-canfd.c | 53 ++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 8968672b84..1704b558d0 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -869,6 +869,8 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_ca= n_frame *frame, uint32_t val =3D 0; uint32_t dlc_reg_val =3D 0; uint32_t dlc_value =3D 0; + uint32_t id_reg_val =3D 0; + bool is_rtr =3D false; =20 /* Check that reg_num should be within TX register space. */ assert(reg_num <=3D R_TB_ID_REGISTER + (NUM_REGS_PER_MSG_SPACE * @@ -877,7 +879,20 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_c= an_frame *frame, dlc_reg_val =3D s->regs[reg_num + 1]; dlc_value =3D FIELD_EX32(dlc_reg_val, TB0_DLC_REGISTER, DLC); =20 - frame->can_id =3D s->regs[reg_num]; + id_reg_val =3D s->regs[reg_num]; + if (FIELD_EX32(id_reg_val, TB_ID_REGISTER, IDE)) { + frame->can_id =3D (FIELD_EX32(id_reg_val, TB_ID_REGISTER, ID) << 1= 8) | + (FIELD_EX32(id_reg_val, TB_ID_REGISTER, ID_EXT)) | + QEMU_CAN_EFF_FLAG; + if (FIELD_EX32(id_reg_val, TB_ID_REGISTER, RTR_RRS)) { + is_rtr =3D true; + } + } else { + frame->can_id =3D FIELD_EX32(id_reg_val, TB_ID_REGISTER, ID); + if (FIELD_EX32(id_reg_val, TB_ID_REGISTER, SRR_RTR_RRS)) { + is_rtr =3D true; + } + } =20 if (FIELD_EX32(dlc_reg_val, TB0_DLC_REGISTER, FDF)) { /* @@ -923,6 +938,10 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_c= an_frame *frame, } else { frame->can_dlc =3D dlc_value; } + + if (is_rtr) { + frame->can_id |=3D QEMU_CAN_RTR_FLAG; + } } =20 for (j =3D 0; j < frame->can_dlc; j++) { @@ -948,6 +967,33 @@ static void process_cancellation_requests(XlnxVersalCA= NFDState *s) canfd_update_irq(s); } =20 +static uint32_t frame_to_reg_id(const qemu_can_frame *frame) +{ + uint32_t id_reg_val =3D 0; + const bool is_canfd_frame =3D frame->flags & QEMU_CAN_FRMF_TYPE_FD; + const bool is_rtr =3D !is_canfd_frame && (frame->can_id & QEMU_CAN_RTR= _FLAG); + + if (frame->can_id & QEMU_CAN_EFF_FLAG) { + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, ID, + (frame->can_id & QEMU_CAN_EFF_MASK) >> 18= ); + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, ID_EXT, + frame->can_id & QEMU_CAN_EFF_MASK); + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, IDE, 1); + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, SRR_RTR_RRS, 1); + if (is_rtr) { + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, RTR_RRS, 1); + } + } else { + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, ID, + frame->can_id & QEMU_CAN_SFF_MASK); + if (is_rtr) { + id_reg_val |=3D FIELD_DP32(0, RB_ID_REGISTER, SRR_RTR_RRS, 1); + } + } + + return id_reg_val; +} + static void store_rx_sequential(XlnxVersalCANFDState *s, const qemu_can_frame *frame, uint32_t fill_level, uint32_t read_index, @@ -999,7 +1045,7 @@ static void store_rx_sequential(XlnxVersalCANFDState *= s, NUM_REGS_PER_MSG_SPACE= )); } =20 - s->regs[store_location] =3D frame->can_id; + s->regs[store_location] =3D frame_to_reg_id(frame); =20 dlc =3D frame->can_dlc; =20 @@ -1090,11 +1136,12 @@ static void update_rx_sequential(XlnxVersalCANFDSta= te *s, if (s->regs[R_ACCEPTANCE_FILTER_CONTROL_REGISTER]) { uint32_t acceptance_filter_status =3D s->regs[R_ACCEPTANCE_FILTER_CONTROL_REGIST= ER]; + const uint32_t reg_id =3D frame_to_reg_id(frame); =20 for (i =3D 0; i < 32; i++) { if (acceptance_filter_status & 0x1) { uint32_t msg_id_masked =3D s->regs[R_AFMR_REGISTER + 2 * i= ] & - frame->can_id; + reg_id; uint32_t afir_id_masked =3D s->regs[R_AFIR_REGISTER + 2 * = i] & s->regs[R_AFMR_REGISTER + 2 * i]; uint16_t std_msg_id_masked =3D FIELD_EX32(msg_id_masked, --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730730; cv=none; d=zohomail.com; s=zohoarc; b=Zi+ZxewZP+LOwycZk71t/oPhOCstSDK9X78feL2iHHWmM8+SAjvgci6sUFcT0ikFJp4SRBI7o7Zy0RAwGEwZzN2Jh0lgClb6B0J1tiObd1HeDRm9mXRJGlLUe8n0pIXKtBNphVi1sL8y+/4A/nsAAun2X/5d7/lmpeX/SQeyHVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730730; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S0zsQlf6Fpb3LogkSdeHLWACnHhbNDLVL/P8RxdypHM=; b=bnCE/It7FYvj+FL0Ac3dJnUtASlm9aPGzgAgIF0FQnur1qj8eSgC1YuveBCN6DAT4KcWfhN8hNXydIrRbewzgjvyFPmmVOF9o4pQWA5cAiM+AMpGIIhGB0xdXtlCJHpvwSR4h3I8dxRUTTTMAiWkoR+qurqdiWtq98GRXP4FMXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730730790223.49813906709153; Mon, 26 Aug 2024 20:52:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinER-0005D4-6i; Mon, 26 Aug 2024 23:50:59 -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 1sinEN-000553-Pp for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:57 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEJ-0003qY-Rg for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:54 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-20230059241so40781015ad.3 for ; Mon, 26 Aug 2024 20:50:51 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730650; x=1725335450; 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=S0zsQlf6Fpb3LogkSdeHLWACnHhbNDLVL/P8RxdypHM=; b=emOTH1OSvNprDeGur9l+DepiM4vZ7VkUVv5X63f73hsn/eErEjxDNdRYOwhIywBIEc 5aeDabqQbpjUkSSyoz2rSyOYpwc6ePpEjRpkkFZAQvIiJCsHOXqJ1Si7zwOy/dmVdWMU Jt2bcM+feFoOec+1LbFkouMrJL6WWHKQaqrrg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730650; x=1725335450; 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=S0zsQlf6Fpb3LogkSdeHLWACnHhbNDLVL/P8RxdypHM=; b=Dzotwy4DUp9BXTpGkTrdmogXbP8nHeSRdP0KhcJuUMQ0s9IHjDHCLjTJEfVqgcouk4 9xJ4jtlNRwtqWIDrRU+wzPfoDLHinNao4hdTjp63iLFOll4LF/3MaKw68Oi/KwPRDUSc UmIkqoZ6grlruX0rgXmND+/8opEGMOgNH8mFc1ktSqzegTdPFW6PZHioPytAh2WYjqKC Z85NTYf+DIo072m4SB9mDCRycz5XEAxKuz25hUGFAUtjQlrIqhS85LLrj1YTmUuftiVR sqJMSzbOFr6ysSqnCK4TSHLI8Yj9T8TWQLnXXjzKK6hO4lVJYdlOYLcUTz2tTTLH/5Ok KRcQ== X-Forwarded-Encrypted: i=1; AJvYcCWIWSzuAN1V12lOnzC3H97RAjjLXa6RMcla0HG2tkcahq/kKkuVzVn6iFa0DnSgF/aI9vPJwXa+ik8s@nongnu.org X-Gm-Message-State: AOJu0YwmpLgmcWllxE2N03grMJgL4cyZK+HLlfNHbKfiFwEhD9IX755f Zx0yBXB1YRbz3+Tlh3AIYrQ0qGwvqUZA9ibnIviXLNqjcDfnNIWz76nJEt3L+lo= X-Google-Smtp-Source: AGHT+IEwuUQ3gLat4m6or9KyVLa/RrfyK5pIfIYJe9KC8cESOTG7v7uh7oE0g8/jcAIfTVwoHF6kEQ== X-Received: by 2002:a17:903:2c7:b0:201:f1b5:24ac with SMTP id d9443c01a7336-2039e51279bmr139896365ad.54.1724730650264; Mon, 26 Aug 2024 20:50:50 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 4/7] hw/net/can/xlnx-versal-canfd: Handle flags correctly Date: Mon, 26 Aug 2024 20:49:24 -0700 Message-Id: <20240827034927.66659-5-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=doug@schmorgal.com; helo=mail-pl1-x635.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730731829116600 Content-Type: text/plain; charset="utf-8" Add support for QEMU_CAN_FRMF_ESI and QEMU_CAN_FRMF_BRS flags, and ensure frame->flags is always initialized to 0. Note that the Xilinx IP core doesn't allow manually setting the ESI bit during transmits, so it's only implemented for the receive case. Signed-off-by: Doug Brown Reviewed-by: Pavel Pisa --- hw/net/can/xlnx-versal-canfd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 1704b558d0..47631917ab 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -872,6 +872,8 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_ca= n_frame *frame, uint32_t id_reg_val =3D 0; bool is_rtr =3D false; =20 + frame->flags =3D 0; + /* Check that reg_num should be within TX register space. */ assert(reg_num <=3D R_TB_ID_REGISTER + (NUM_REGS_PER_MSG_SPACE * s->cfg.tx_fifo)); @@ -913,7 +915,7 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_ca= n_frame *frame, * 15 49 - 64 */ =20 - frame->flags =3D QEMU_CAN_FRMF_TYPE_FD; + frame->flags |=3D QEMU_CAN_FRMF_TYPE_FD; =20 if (dlc_value < 8) { frame->can_dlc =3D dlc_value; @@ -921,6 +923,10 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_c= an_frame *frame, assert((dlc_value - 8) < ARRAY_SIZE(canfd_dlc_array)); frame->can_dlc =3D canfd_dlc_array[dlc_value - 8]; } + + if (FIELD_EX32(dlc_reg_val, TB0_DLC_REGISTER, BRS)) { + frame->flags |=3D QEMU_CAN_FRMF_BRS; + } } else { /* * FD Format bit not set that means it is a CAN Frame. @@ -1058,6 +1064,13 @@ static void store_rx_sequential(XlnxVersalCANFDState= *s, dlc_reg_val =3D FIELD_DP32(0, RB_DLC_REGISTER, DLC, 8 = + i); } } + + if (frame->flags & QEMU_CAN_FRMF_BRS) { + dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, BRS, 1); + } + if (frame->flags & QEMU_CAN_FRMF_ESI) { + dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, ESI, 1); + } } else { is_canfd_frame =3D false; =20 --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730740; cv=none; d=zohomail.com; s=zohoarc; b=gG/HeoTM2OnDPK6r3gXF5MjU9iaJ7j+YFRAPbHKi2PoA+bRBGfRok1mBaBVmdlA1hwBWEuNiNYACjTfJOCJf1ef1/tR3L2/SSKt8kTCSX6NIxWmHyF+TkgIlSEXCOfE9dv7Qw1bDxm7pY76dRzSZCp+49YmIpu3WaWv8YPxSxjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730740; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JnP3Mz0YCYvkvuQOeow8f8X6KYRPaGRZd1rCOK6MrJs=; b=c3s8sSMFyygzbx5rBd1m/Dk+1kvxeuRjiQxJTCRyqEo1eRCbnfP29B+tHZeGbAGbG4ZCmFwa3IhSt7JDchGQuTNwfv83ldc3e7lU1zaaEfZQ3xiOpoRi4AeUr8Cp+lj2JcbVsjG7DwvA0xB1uX8Gv1e/sYi3a323LYhQ0liHnuk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172473073887470.15918327929649; Mon, 26 Aug 2024 20:52:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinET-0005K2-0H; Mon, 26 Aug 2024 23:51:01 -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 1sinEN-00055j-Vj for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:57 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEL-0003qs-LW for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:55 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7bb75419123so3264053a12.3 for ; Mon, 26 Aug 2024 20:50:52 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730651; x=1725335451; 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=JnP3Mz0YCYvkvuQOeow8f8X6KYRPaGRZd1rCOK6MrJs=; b=ezn6Jw5yIk/p1LxOfuLXUfwN2RNBV1E5lO5T4x/exItkNiWPnpWTeOiKue205tDyAS t/WSe3abnQJYnUNlf+BDU1lWz+WhODlMp/6eNvjY+ZzzuiyExYhqZoG7McIZdrz+cMoA oyXA+8jtShnR870yNeGLGphSbxHT1a1a2qvLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730651; x=1725335451; 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=JnP3Mz0YCYvkvuQOeow8f8X6KYRPaGRZd1rCOK6MrJs=; b=S4wFOiqZXhudGhyn07Ja53JG0+R5ZqNSce5+bAaCBkLFSEMBifAu2ZGtWXO3chSNGo m5a+5nsmlQ+7lDHEgG4FoB6njih91pUM97uTn+TPOXqt5ddk4H9vbUBN7K2Kifi4bx4Z xL4L4CQwiL6F6bq7wkjlkxkHUl1qAKtBw2xZlG2xCzDHKhVbe81nHM4DnaMWBxBQ7xRs pakM826h7o3csM6ehfhxf+/QXImiE58VbXWYflwxaO8bZyFt4h4ONJvZn9smc3Mub7I0 82kQ/tfzUkPfN7dRbHGcjymYn9UmCABK96Kka5DKbso8b7f9DV6yD75tqmLt64MmTJhm VeBQ== X-Forwarded-Encrypted: i=1; AJvYcCUtnXuYyzB2o8WTrpaZmePQYsN2FZ40WHoIXpOxKFoU8e6tFE/APxuMgyQk6ZD37KrDND+VRfYat8Nl@nongnu.org X-Gm-Message-State: AOJu0YyceIiirmmae5XyWTa/ztir6vri3TOC0afoYcuX/r6Uqoj5Rp31 25YlmGypbNq718cHcJgSzjiex0bwt/8rcqMn0YCC3edVgSAqhTRfnntv0B5yifk= X-Google-Smtp-Source: AGHT+IGe3PUZEYCSgJsKiA6gmmK50hNyHr7QOk853mSIwidN4JmobSoIwlgaGyUk6yU8I4xAs38q6w== X-Received: by 2002:a17:902:d2c6:b0:202:2cd5:2085 with SMTP id d9443c01a7336-2039e4b4b90mr96999355ad.32.1724730651632; Mon, 26 Aug 2024 20:50:51 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 5/7] hw/net/can/xlnx-versal-canfd: Fix byte ordering Date: Mon, 26 Aug 2024 20:49:25 -0700 Message-Id: <20240827034927.66659-6-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=doug@schmorgal.com; helo=mail-pg1-x52f.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730741708116600 Content-Type: text/plain; charset="utf-8" The endianness of the CAN data was backwards in each group of 4 bytes. For example, the following data: 00 11 22 33 44 55 66 77 was showing up like this: 33 22 11 00 77 66 55 44 Fix both the TX and RX code to put the data in the correct order. Signed-off-by: Doug Brown Reviewed-by: Francisco Iglesias Acked-by: Pavel Pisa --- hw/net/can/xlnx-versal-canfd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 47631917ab..5d7adf8740 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -951,7 +951,7 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_ca= n_frame *frame, } =20 for (j =3D 0; j < frame->can_dlc; j++) { - val =3D 8 * i; + val =3D 8 * (3 - i); =20 frame->data[j] =3D extract32(s->regs[reg_num + 2 + (j / 4)], val, = 8); i++; @@ -1093,19 +1093,19 @@ static void store_rx_sequential(XlnxVersalCANFDStat= e *s, case 0: rx_reg_num =3D i / 4; =20 - data_reg_val =3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTES= 3, + data_reg_val =3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTES= 0, frame->data[i]); break; case 1: - data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S2, + data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S1, frame->data[i]); break; case 2: - data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S1, + data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S2, frame->data[i]); break; case 3: - data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S0, + data_reg_val |=3D FIELD_DP32(0, RB_DW0_REGISTER, DATA_BYTE= S3, frame->data[i]); /* * Last Bytes data which means we have all 4 bytes ready to --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730732; cv=none; d=zohomail.com; s=zohoarc; b=XrsPJAfASRSmG+daDrm+BmIZK6rirNMGCyH1pLRVjCJKJZ6UUY8mxAkCQL6Ll6r+h48AY/nQt7amtFLfdlMbuuhOaPlOdHkcKG0Fep7mxit8tDEGhZf25rMR9SUSPjlbi3MNsWq8gPyyolVEQb67sdB8mhr1cponS5XWG95tGQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730732; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Awp0ytvcQ56tnn09fPAbSHHgINoCasgEEQF1NRSqcwA=; b=BQ50Z3Y7PAuhIZfkjmaZs2bya6Zbq20vqCDhXiMqPiaMmncwrZZaZi8kyf1+T5yntuoPEJmAEcUKJw7PMp5QCFYMuGkygxVQN8VQk2VFA4HwxYFq6JCqA/4+harBqE89jMo8GxHacPHj1unZCc9DZh+RRX7a6Prfq55KH2TyA64= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730732080616.0478939675538; Mon, 26 Aug 2024 20:52:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinET-0005NM-R2; Mon, 26 Aug 2024 23:51:01 -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 1sinEP-00057M-P0 for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:58 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEN-0003rC-Hb for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:56 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-7163489149eso3078957a12.1 for ; Mon, 26 Aug 2024 20:50:54 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730653; x=1725335453; 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=Awp0ytvcQ56tnn09fPAbSHHgINoCasgEEQF1NRSqcwA=; b=EFZvROAMuShF9+vW7CZxycQSaKHRXIK0Etlgw2NXhx28ONZr1bvj46GBCIzHM8nKx9 eZZ9Iw8Ip1Ys1U9hzfpkQ3EF+SbicOl1lfHV7uIW7iMD4xkZ3oOP+Y0XvgaHu6JNaTzA 00wUNod9KiIqViauhrBAzEx4lQnRpX8W8WVr8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730653; x=1725335453; 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=Awp0ytvcQ56tnn09fPAbSHHgINoCasgEEQF1NRSqcwA=; b=KPZ6XpN/K/9J6O1aI2MpHzWzAPKvAN3bnL8o5RcYS5n+85qqSfWs21Y553L8zh/url U49DUJ/I3zGeoJmBBNamPDuYG0M7qwxcZF2BxxzR4hn25YYhytaYLwCM+0JdM61DkEi5 AH2TdZOfVf+C1POOjmxXwAaqd8jo6w/3yJ4u5R56AvJC9jtFCM+kzFdcPo3CIMfBhGXj fCNgsjhMP0qJgzkc8Y2OI5jHzkr2NT1ACeennzUr5C4UGYCJnBJh3cICinNBfBxeufsI bRSn2+2ycSaIAE3tQmT53LMKn0X4sTLP7upqX7sCwux3dij7dtP/KGwBdn617EakODxM mvhg== X-Forwarded-Encrypted: i=1; AJvYcCVEz5+3FmklyZ/cZesjNMNU6sChKMdIbdkRxV1WlKuvT+I4NBvWcPsWEkOsz+CfNI/zTIvItV6YEvgY@nongnu.org X-Gm-Message-State: AOJu0Yw47GqrMWzwBpTX57ywb+on03JKsm2vHRgr0g7bmDbbt3ppWz6Q UNdHaPzmNFofNX8hTJeStWuVli0KjEZYPczZQRYMuVFb/9tsq1DcHGhy3qtZqz0= X-Google-Smtp-Source: AGHT+IEMwa0uTkA57YVq8QyRnfzAPIK03A5xb3nbdhcI//ULSPBM6r28Im8OSZxxgno1CdVcpS6wTg== X-Received: by 2002:a05:6a20:e687:b0:1c8:b10d:eadb with SMTP id adf61e73a8af0-1cc8b4855b3mr14515630637.17.1724730653261; Mon, 26 Aug 2024 20:50:53 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 6/7] hw/net/can/xlnx-versal-canfd: Simplify DLC conversions Date: Mon, 26 Aug 2024 20:49:26 -0700 Message-Id: <20240827034927.66659-7-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=doug@schmorgal.com; helo=mail-pg1-x529.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730734077116600 Content-Type: text/plain; charset="utf-8" Use QEMU's helper functions can_dlc2len() and can_len2dlc() for translating between the raw DLC value and the SocketCAN length value. This also has the side effect of correctly handling received CAN FD frames with a DLC of 0-8, which was broken previously. Signed-off-by: Doug Brown Reviewed-by: Francisco Iglesias Reviewed-by: Pavel Pisa --- hw/net/can/xlnx-versal-canfd.c | 67 ++-------------------------------- 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 5d7adf8740..589c21db69 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -678,8 +678,6 @@ REG32(RB_DW15_REGISTER_1, 0x4144) FIELD(RB_DW15_REGISTER_1, DATA_BYTES62, 8, 8) FIELD(RB_DW15_REGISTER_1, DATA_BYTES63, 0, 8) =20 -static uint8_t canfd_dlc_array[8] =3D {8, 12, 16, 20, 24, 32, 48, 64}; - static void canfd_update_irq(XlnxVersalCANFDState *s) { const bool irq =3D (s->regs[R_INTERRUPT_STATUS_REGISTER] & @@ -897,59 +895,19 @@ static void regs2frame(XlnxVersalCANFDState *s, qemu_= can_frame *frame, } =20 if (FIELD_EX32(dlc_reg_val, TB0_DLC_REGISTER, FDF)) { - /* - * CANFD frame. - * Converting dlc(0 to 15) 4 Byte data to plain length(i.e. 0 to 6= 4) - * 1 Byte data. This is done to make it work with SocketCAN. - * On actual CANFD frame, this value can't be more than 0xF. - * Conversion table for DLC to plain length: - * - * DLC Plain Length - * 0 - 8 0 - 8 - * 9 9 - 12 - * 10 13 - 16 - * 11 17 - 20 - * 12 21 - 24 - * 13 25 - 32 - * 14 33 - 48 - * 15 49 - 64 - */ - frame->flags |=3D QEMU_CAN_FRMF_TYPE_FD; =20 - if (dlc_value < 8) { - frame->can_dlc =3D dlc_value; - } else { - assert((dlc_value - 8) < ARRAY_SIZE(canfd_dlc_array)); - frame->can_dlc =3D canfd_dlc_array[dlc_value - 8]; - } - if (FIELD_EX32(dlc_reg_val, TB0_DLC_REGISTER, BRS)) { frame->flags |=3D QEMU_CAN_FRMF_BRS; } } else { - /* - * FD Format bit not set that means it is a CAN Frame. - * Conversion table for classic CAN: - * - * DLC Plain Length - * 0 - 7 0 - 7 - * 8 - 15 8 - */ - - if (dlc_value > 8) { - frame->can_dlc =3D 8; - qemu_log_mask(LOG_GUEST_ERROR, "Maximum DLC value for Classic = CAN" - " frame is 8. Only 8 byte data will be sent.\n"); - } else { - frame->can_dlc =3D dlc_value; - } - if (is_rtr) { frame->can_id |=3D QEMU_CAN_RTR_FLAG; } } =20 + frame->can_dlc =3D can_dlc2len(dlc_value); + for (j =3D 0; j < frame->can_dlc; j++) { val =3D 8 * (3 - i); =20 @@ -1007,7 +965,6 @@ static void store_rx_sequential(XlnxVersalCANFDState *= s, bool rx_fifo_id, uint8_t filter_index) { int i; - bool is_canfd_frame; uint8_t dlc =3D frame->can_dlc; uint8_t rx_reg_num =3D 0; uint32_t dlc_reg_val =3D 0; @@ -1053,17 +1010,10 @@ static void store_rx_sequential(XlnxVersalCANFDStat= e *s, =20 s->regs[store_location] =3D frame_to_reg_id(frame); =20 - dlc =3D frame->can_dlc; + dlc_reg_val =3D FIELD_DP32(0, RB_DLC_REGISTER, DLC, can_len2dlc(dl= c)); =20 if (frame->flags & QEMU_CAN_FRMF_TYPE_FD) { - is_canfd_frame =3D true; - - /* Store dlc value in Xilinx specific format. */ - for (i =3D 0; i < ARRAY_SIZE(canfd_dlc_array); i++) { - if (canfd_dlc_array[i] =3D=3D frame->can_dlc) { - dlc_reg_val =3D FIELD_DP32(0, RB_DLC_REGISTER, DLC, 8 = + i); - } - } + dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, FDF, 1); =20 if (frame->flags & QEMU_CAN_FRMF_BRS) { dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, BRS, 1); @@ -1071,17 +1021,8 @@ static void store_rx_sequential(XlnxVersalCANFDState= *s, if (frame->flags & QEMU_CAN_FRMF_ESI) { dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, ESI, 1); } - } else { - is_canfd_frame =3D false; - - if (frame->can_dlc > 8) { - dlc =3D 8; - } - - dlc_reg_val =3D FIELD_DP32(0, RB_DLC_REGISTER, DLC, dlc); } =20 - dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, FDF, is_canfd_fram= e); dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, TIMESTAMP, rx_time= stamp); dlc_reg_val |=3D FIELD_DP32(0, RB_DLC_REGISTER, MATCHED_FILTER_IND= EX, filter_index); --=20 2.34.1 From nobody Sun Nov 24 07:57:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=schmorgal.com ARC-Seal: i=1; a=rsa-sha256; t=1724730702; cv=none; d=zohomail.com; s=zohoarc; b=hj1OA3j0D2O7C7gR8jfVXUbLzkZ/U2/7pq9aI4Kgz6tTV4ktFI04d2R32bQ5yZjAGbt2+jvhVhkwNfen58nHb8RKmVL5o7RrIZF7PKnyLM9nj1paHo+YILMzLdvDWoe0z4Se85NGR2iD/Ao3rF5KmcyGnFSA4nfye/GkAt63LU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724730702; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/zRMYEmVpTZe+R3MyadGyIt4py5ThMYbf+0okcx+mC0=; b=mwZkSFQ+pQUn3YadD4hEy892V1urOcoQebG5FXul6gYgrUwmLZeLNTZdhKlOIU6Cx3HS3kcxZMmTB8VTjY15PEcNtsHxPFIOEIxKq5WiXTl/VjdmMMmKxR51o78OPBVoq+5ObCKPoXLeMM5qxbj4+MaGL2Cn+SS0vjGSiBnx8F8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724730702967632.9950945474368; Mon, 26 Aug 2024 20:51:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sinES-0005Hu-EY; Mon, 26 Aug 2024 23:51:00 -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 1sinEQ-0005Be-SU for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:58 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sinEO-0003rb-6E for qemu-devel@nongnu.org; Mon, 26 Aug 2024 23:50:57 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-7d1fa104851so1296907a12.3 for ; Mon, 26 Aug 2024 20:50:55 -0700 (PDT) Received: from doug-ryzen-5700G.. ([50.37.200.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855dd269sm74503625ad.135.2024.08.26.20.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 20:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; t=1724730655; x=1725335455; 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=/zRMYEmVpTZe+R3MyadGyIt4py5ThMYbf+0okcx+mC0=; b=QpA5tWvCkSXOg27uO5imHcmghXAVKSvRVvpzBuU0J4t4163gJG1G7z1LCm0QRO2tZG IONY35LECB8YO6q5VEyI3I/K4jyCypKV+0qAI8zqoMmUn0/xNGfvZ+NA/bwGnXr3E3h8 kV47F5dy9v/HUAq/bJz2x83PHwNfRrABLnng8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724730655; x=1725335455; 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=/zRMYEmVpTZe+R3MyadGyIt4py5ThMYbf+0okcx+mC0=; b=W1XKHrJxrURFqpGH9tfDF6YLGnNLZwepGjUpamJXU7rOgCo1LLSz7ZbLW5riz07gVZ jxPLfBOQAgy9Ur+HzcKGzo66/N1EGkKng4F36drtAyu+yYIMTB3CJpM/rXUCqwrXZOYh FOi7BLM4jBKraaYnEoTzMCXBkLBKUj5VHM+0s5PW3F+q3+n14Zls0nN45ktG115ZIuUl fungJ85ZFdfQUYRiRDRAJhkAm08FoV9GPHekJFU90uU9qf6VCdEQANvtxcphMxXnur6S 1m58FFNOaqa+wfnHjySDUsQZfZmKxfTcz+oZDtCh3Zhgc5uWiyQvIaZnroyJgvRA1s7D WI8A== X-Forwarded-Encrypted: i=1; AJvYcCUUAG1RF+brc+MQoyXEOXDq0mvLVwHQVJjzRpwqKSExalNR1LZpJRkhJWcC3re4XydqoazPuFO7a0fm@nongnu.org X-Gm-Message-State: AOJu0YxC35z33y2NTGlLKW4Di2BVYoXUMT2fqCSPj/vzNoUya5fL1kBK CIi80NUqtgl5RhRc4LY4egkVxNLcFGRbSjrZ70DXllPMcTh7rcr6GLy5vChEiLs= X-Google-Smtp-Source: AGHT+IGCevETHQsx4Ox8kx8Mvkuq5YUp3/5bmIZZFBi8ZndXG3W00PUxyF2V0DzCIYvEnnx9BwUS9A== X-Received: by 2002:a17:902:cf4f:b0:202:1db8:d9b0 with SMTP id d9443c01a7336-204df4803e0mr15259535ad.34.1724730654755; Mon, 26 Aug 2024 20:50:54 -0700 (PDT) From: Doug Brown To: Francisco Iglesias , Pavel Pisa Cc: Jason Wang , Paolo Bonzini , qemu-devel@nongnu.org, Doug Brown Subject: [PATCH v2 7/7] hw/net/can/xlnx-versal-canfd: Fix FIFO issues Date: Mon, 26 Aug 2024 20:49:27 -0700 Message-Id: <20240827034927.66659-8-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827034927.66659-1-doug@schmorgal.com> References: <20240827034927.66659-1-doug@schmorgal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=doug@schmorgal.com; helo=mail-pg1-x531.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @schmorgal.com) X-ZM-MESSAGEID: 1724730704018116600 Content-Type: text/plain; charset="utf-8" The read index should not be changed when storing a new message into the RX or TX FIFO. Changing it at this point will cause the reader to get out of sync. The wrapping of the read index is already handled by the pre-write functions for the FIFO status registers anyway. Additionally, the calculation for wrapping the store index was off by one, which caused new messages to be written to the wrong location in the FIFO. This caused incorrect messages to be delivered. Signed-off-by: Doug Brown Reviewed-by: Francisco Iglesias --- hw/net/can/xlnx-versal-canfd.c | 36 +++------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 589c21db69..c291a0272b 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -1144,18 +1144,8 @@ static void update_rx_sequential(XlnxVersalCANFDStat= e *s, read_index =3D ARRAY_FIELD_EX32(s->regs, RX_FIFO_STATUS_REGIST= ER, RI); store_index =3D read_index + fill_level; =20 - if (read_index =3D=3D s->cfg.rx0_fifo - 1) { - /* - * When ri is s->cfg.rx0_fifo - 1 i.e. max, it goes cyclic= that - * means we reset the ri to 0x0. - */ - read_index =3D 0; - ARRAY_FIELD_DP32(s->regs, RX_FIFO_STATUS_REGISTER, RI, - read_index); - } - if (store_index > s->cfg.rx0_fifo - 1) { - store_index -=3D s->cfg.rx0_fifo - 1; + store_index -=3D s->cfg.rx0_fifo; } =20 store_location =3D R_RB_ID_REGISTER + @@ -1172,18 +1162,8 @@ static void update_rx_sequential(XlnxVersalCANFDStat= e *s, RI_1); store_index =3D read_index + fill_level; =20 - if (read_index =3D=3D s->cfg.rx1_fifo - 1) { - /* - * When ri is s->cfg.rx1_fifo - 1 i.e. max, it goes cyclic= that - * means we reset the ri to 0x0. - */ - read_index =3D 0; - ARRAY_FIELD_DP32(s->regs, RX_FIFO_STATUS_REGISTER, RI_1, - read_index); - } - if (store_index > s->cfg.rx1_fifo - 1) { - store_index -=3D s->cfg.rx1_fifo - 1; + store_index -=3D s->cfg.rx1_fifo; } =20 store_location =3D R_RB_ID_REGISTER_1 + @@ -1265,18 +1245,8 @@ static void tx_fifo_stamp(XlnxVersalCANFDState *s, u= int32_t tb0_regid) " Discarding the message\n"); ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXEOFLW, = 1); } else { - if (read_index =3D=3D s->cfg.tx_fifo - 1) { - /* - * When ri is s->cfg.tx_fifo - 1 i.e. max, it goes cyclic = that - * means we reset the ri to 0x0. - */ - read_index =3D 0; - ARRAY_FIELD_DP32(s->regs, TX_EVENT_FIFO_STATUS_REGISTER, T= XE_RI, - read_index); - } - if (store_index > s->cfg.tx_fifo - 1) { - store_index -=3D s->cfg.tx_fifo - 1; + store_index -=3D s->cfg.tx_fifo; } =20 assert(store_index < s->cfg.tx_fifo); --=20 2.34.1