From nobody Sun Nov 2 16:40:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527575502880794.5350373070105; Mon, 28 May 2018 23:31:42 -0700 (PDT) Received: from localhost ([::1]:59208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNYAS-0002lv-Oh for importer@patchew.org; Tue, 29 May 2018 02:31:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNY7z-0001Im-D9 for qemu-devel@nongnu.org; Tue, 29 May 2018 02:29:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNY7w-0001Ty-AP for qemu-devel@nongnu.org; Tue, 29 May 2018 02:29:03 -0400 Received: from 5.mo7.mail-out.ovh.net ([178.32.120.239]:49813) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNY7w-0001SD-3S for qemu-devel@nongnu.org; Tue, 29 May 2018 02:29:00 -0400 Received: from player718.ha.ovh.net (unknown [10.109.108.4]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 2262BACACD for ; Tue, 29 May 2018 08:28:57 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-TOU-1-49-10.w86-201.abo.wanadoo.fr [86.201.141.10]) (Authenticated sender: clg@kaod.org) by player718.ha.ovh.net (Postfix) with ESMTPSA id 7B9FD4E00AE; Tue, 29 May 2018 08:28:52 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-arm@nongnu.org Date: Tue, 29 May 2018 08:28:34 +0200 Message-Id: <20180529062838.20556-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180529062838.20556-1-clg@kaod.org> References: <20180529062838.20556-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 17521535827166137264 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrheejgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.120.239 Subject: [Qemu-devel] [PATCH 2/6] ftgmac100: add IEEE 802.1Q VLAN support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Jason Wang , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The ftgmac100 NIC supports VLAN tag insertion and the MAC engine also has a control to remove VLAN tags from received packets. The VLAN control bits and VLAN tag information are contained in the second word of the transmit and receive descriptors. The Insert VLAN bit and the VLAN Tag available bit are only valid in the first segment of the packet. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/ftgmac100.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 7598d08c9cb9..50af1222464a 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -443,6 +443,24 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_= t tx_ring, break; } =20 + /* Check for VLAN */ + if (bd.des0 & FTGMAC100_TXDES0_FTS && + bd.des1 & FTGMAC100_TXDES1_INS_VLANTAG && + be16_to_cpu(PKT_GET_ETH_HDR(ptr)->h_proto) !=3D ETH_P_VLAN) { + if (frame_size + len + 4 > sizeof(s->frame)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %d byt= es\n", + __func__, len); + s->isr |=3D FTGMAC100_INT_XPKT_LOST; + len =3D sizeof(s->frame) - frame_size - 4; + } + memmove(ptr + 16, ptr + 12, len - 12); + ptr[12] =3D 0x81; + ptr[13] =3D 0x00; + ptr[14] =3D (uint8_t) bd.des1 >> 8; + ptr[15] =3D (uint8_t) bd.des1; + len +=3D 4; + } + ptr +=3D len; frame_size +=3D len; if (bd.des0 & FTGMAC100_TXDES0_LTS) { @@ -858,7 +876,19 @@ static ssize_t ftgmac100_receive(NetClientState *nc, c= onst uint8_t *buf, buf_len +=3D size - 4; } buf_addr =3D bd.des3; - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + if (first && proto =3D=3D ETH_P_VLAN && buf_len >=3D 18) { + bd.des1 =3D (buf[14] << 8) | buf[15] | FTGMAC100_RXDES1_VLANTA= G_AVAIL; + if (s->maccr & FTGMAC100_MACCR_RM_VLAN) { + dma_memory_write(&address_space_memory, buf_addr, buf, 12); + dma_memory_write(&address_space_memory, buf_addr + 12, buf= + 16, + buf_len - 16); + } else { + dma_memory_write(&address_space_memory, buf_addr, buf, buf= _len); + } + } else { + bd.des1 =3D 0; + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len= ); + } buf +=3D buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, --=20 2.13.6