From nobody Tue Feb 10 00:59:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) client-ip=209.85.128.41; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f41.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1626037311; cv=none; d=zohomail.com; s=zohoarc; b=C8Bd4r3t++3In4z6wtejbAJzdYtsTZNHpAddzLvxMMLmeAruzq6YBBhTUphiyYjbgYmiC6pE8qXwrDGVs+XnU4F0gJonJFgt1lKTgQtFdkcA4rNDXAwU5A5nxPWViC8CxYmAxB2tHoqBKdvAq+ZxJJQbJwcSAwIzl26nkOr/S+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626037311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vNIHCXPggM034f3kqxuyfYmegS1Lrb5pCTTwom4fFi8=; b=f4XXeoNyH+FHnal/V8YdO/RsDlQMnW9AXf4ho9alG6/21Y0vhgdYBjV3x38p8I7x3e520IYStOhSTwZXaxe4lB/ha7GWgjk9/bTwT4NnO/RO9+9WZOGNYyojku+2dDkc4nsqKU8RSN3cix/wAwQb3h5pEwrfPSWOQIU2FAwN90U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.zohomail.com with SMTPS id 16260373114741010.7966113216082; Sun, 11 Jul 2021 14:01:51 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id n33so9972183wms.1 for ; Sun, 11 Jul 2021 14:01:50 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (abayonne-654-1-142-116.w86-222.abo.wanadoo.fr. [86.222.93.116]) by smtp.gmail.com with ESMTPSA id l18sm7943457wme.29.2021.07.11.14.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 14:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vNIHCXPggM034f3kqxuyfYmegS1Lrb5pCTTwom4fFi8=; b=YT05f/Il3kdlzZ65Fkwlil6GcCcNh4m63iezrsIpeC9FbpdApo6DLD5WxUj2DPjw8r 01Nwj2kr4oSNxiepxCpDd6f6rklFDwty9vipE8nhRigIFWGmKJ3VqumS4sYwbdoJzWM2 hvFxS7wXR7k5RmDwWq5gaN34v+zGfUjdMpnsBlixj7MezhwW74Bai303bC6nHdwJkYTQ bgJuZF0agaD9eSywsUlbMvgNqGuWX3NwIqpUTg5aAh1Ol8uqvhSf5wBwLU17QId7S+sf tWO4oRxvN8wXKZ6Oo/Hy7zhWpaPBf/HMZG27J6if+CVlpJC9okrhH6yVwlRCGx+32LxD bZUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vNIHCXPggM034f3kqxuyfYmegS1Lrb5pCTTwom4fFi8=; b=EHBKJgme85Vi/QhmRapXIpPP3K3hkuh+QwEcAkb2sRzbNL5bn4yP4qhrHW1AmUa1XI HN7umXbasg+4Ywas6GR14opuJUzSiiKtZf0ht3sMqSZM2TRs+2eX8BO8GISbzmXjT9fR agq1OBTDBMs6XIyhNZsA+3T4jTKXf80I5/Ph4JJ+xIPOQ37b30/eLhdNP3O17+G5dL3V 4I3sx8yHVUsrRYfEZpH53RZxl6HTDOJnaRSCPZqIlaPB7m1UITpBgTXu0P5fske3E8+L nyf6IwmX1PuZgom3czIHJBo8mhjdwTSi0yURiQmMZ+EwERlz7OXu75Lb3PFbtpHmhxb9 9Vqw== X-Gm-Message-State: AOAM531VDLan4Q92AvaFFSWZQchp89YaFFr9VjDt3AO9yndp2LZV9MUI Q0YkZh5k/WP3Gferjx9vtQU= X-Google-Smtp-Source: ABdhPJxM5Tu90C1usc1McTitZJ2BfGgPsSCfkAGcA4vkQwlAd6OtrQqnxgPWTyB4qdxGK8bYa2mP4w== X-Received: by 2002:a7b:c096:: with SMTP id r22mr10940429wmh.186.1626037309745; Sun, 11 Jul 2021 14:01:49 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Fredrik Noring , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Finn Thain Subject: [PULL 17/19] dp8393x: Store CAM registers as 16-bit Date: Sun, 11 Jul 2021 23:00:14 +0200 Message-Id: <20210711210016.2710100-18-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210711210016.2710100-1-f4bug@amsat.org> References: <20210711210016.2710100-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1626037312529100001 Per the DP83932C datasheet from July 1995: 4.0 SONIC Registers 4.1 THE CAM UNIT The Content Addressable Memory (CAM) consists of sixteen 48-bit entries for complete address filtering of network packets. Each entry corresponds to a 48-bit destination address that is user programmable and can contain any combination of Multicast or Physical addresses. Each entry is partitioned into three 16-bit CAM cells accessible through CAM Address Ports (CAP 2, CAP 1 and CAP 0) with CAP0 corresponding to the least significant 16 bits of the Destination Address and CAP2 corresponding to the most significant bits. Store the CAM registers as 16-bit as it simplifies the code. Having now the CAM registers as arrays of 3 uint16_t, we can avoid using the VMSTATE_BUFFER_UNSAFE macro by using VMSTATE_UINT16_2DARRAY which is more appropriate. This breaks the migration stream however. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Mark Cave-Ayland Tested-by: Finn Thain Message-Id: <20210710174954.2577195-5-f4bug@amsat.org> Tested-by: Mark Cave-Ayland --- hw/net/dp8393x.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index d1e147a82a6..283de9db0bf 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -158,7 +158,7 @@ struct dp8393xState { MemoryRegion mmio; =20 /* Registers */ - uint8_t cam[16][6]; + uint16_t cam[16][3]; uint16_t regs[SONIC_REG_COUNT]; =20 /* Temporaries */ @@ -281,15 +281,13 @@ static void dp8393x_do_load_cam(dp8393xState *s) address_space_read(&s->as, dp8393x_cdp(s), MEMTXATTRS_UNSPECIFIED, s->data, size); index =3D dp8393x_get(s, width, 0) & 0xf; - s->cam[index][0] =3D dp8393x_get(s, width, 1) & 0xff; - s->cam[index][1] =3D dp8393x_get(s, width, 1) >> 8; - s->cam[index][2] =3D dp8393x_get(s, width, 2) & 0xff; - s->cam[index][3] =3D dp8393x_get(s, width, 2) >> 8; - s->cam[index][4] =3D dp8393x_get(s, width, 3) & 0xff; - s->cam[index][5] =3D dp8393x_get(s, width, 3) >> 8; - trace_dp8393x_load_cam(index, s->cam[index][0], s->cam[index][1], - s->cam[index][2], s->cam[index][3], - s->cam[index][4], s->cam[index][5]); + s->cam[index][0] =3D dp8393x_get(s, width, 1); + s->cam[index][1] =3D dp8393x_get(s, width, 2); + s->cam[index][2] =3D dp8393x_get(s, width, 3); + trace_dp8393x_load_cam(index, + s->cam[index][0] >> 8, s->cam[index][0] & 0= xff, + s->cam[index][1] >> 8, s->cam[index][1] & 0= xff, + s->cam[index][2] >> 8, s->cam[index][2] & 0= xff); /* Move to next entry */ s->regs[SONIC_CDC]--; s->regs[SONIC_CDP] +=3D size; @@ -592,8 +590,7 @@ static uint64_t dp8393x_read(void *opaque, hwaddr addr,= unsigned int size) case SONIC_CAP1: case SONIC_CAP0: if (s->regs[SONIC_CR] & SONIC_CR_RST) { - val =3D s->cam[s->regs[SONIC_CEP] & 0xf][2 * (SONIC_CAP0 - reg= ) + 1] << 8; - val |=3D s->cam[s->regs[SONIC_CEP] & 0xf][2 * (SONIC_CAP0 - re= g)]; + val =3D s->cam[s->regs[SONIC_CEP] & 0xf][SONIC_CAP0 - reg]; } break; /* All other registers have no special contraints */ @@ -984,10 +981,10 @@ static void dp8393x_realize(DeviceState *dev, Error *= *errp) =20 static const VMStateDescription vmstate_dp8393x =3D { .name =3D "dp8393x", - .version_id =3D 0, - .minimum_version_id =3D 0, + .version_id =3D 1, + .minimum_version_id =3D 1, .fields =3D (VMStateField []) { - VMSTATE_BUFFER_UNSAFE(cam, dp8393xState, 0, 16 * 6), + VMSTATE_UINT16_2DARRAY(cam, dp8393xState, 16, 3), VMSTATE_UINT16_ARRAY(regs, dp8393xState, SONIC_REG_COUNT), VMSTATE_END_OF_LIST() } --=20 2.31.1