From patchwork Mon Jan 13 07:43:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 23151 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B81C216D9 for ; Mon, 13 Jan 2014 07:44:57 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id h16sf27903599oag.1 for ; Sun, 12 Jan 2014 23:44:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Feeyv+O9P8N0Lj8162INITWAm2XRe5MDIArybx9x3IM=; b=PsX5QZn1nIsO8RDj7TB/t9Eg0rmWfSQAjFr6zrJZrEfSOUDP2AsEeDDvnJyA5z/iLn hqX8TPQkhsFFum6w8zLZ7rMJl8/f2356s7fDmLMLbMudXYlw5dd72bIR86JOySa8Uynw EVc9nPl2zCxo0W9ZDfG81+rEn2UWjxaDhIt4+rpAUYSsw3/wj66Pxb2lX8XkM50jMPJ9 odO/PNGUlLSLHpLwfin8fjTfo2kY1J8ttovuDD+jC1UNep/PiE6NFNgomI1DLgwMi1nm 12r+FtQjVkwB0Jq3kEGqrKIP/9DoHJlVLFEMysSspkYfMJHlXnxbPPNuv+fW6zqG3Txp tzCA== X-Gm-Message-State: ALoCoQlgCsB5SqaBfCkzfizv+lqB/XosYjVxg41MrbYML5vPY/lq3d06f9DLB2S37eFyDaiM2lRB X-Received: by 10.42.35.75 with SMTP id p11mr7298775icd.16.1389599096660; Sun, 12 Jan 2014 23:44:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.82 with SMTP id j18ls2443878qen.49.gmail; Sun, 12 Jan 2014 23:44:56 -0800 (PST) X-Received: by 10.52.116.200 with SMTP id jy8mr14201969vdb.15.1389599096571; Sun, 12 Jan 2014 23:44:56 -0800 (PST) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id c14si10636690veu.66.2014.01.12.23.44.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 23:44:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id p5so134918vbn.30 for ; Sun, 12 Jan 2014 23:44:56 -0800 (PST) X-Received: by 10.58.85.133 with SMTP id h5mr17127082vez.4.1389599096474; Sun, 12 Jan 2014 23:44:56 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp109742ved; Sun, 12 Jan 2014 23:44:56 -0800 (PST) X-Received: by 10.49.81.178 with SMTP id b18mr36769471qey.0.1389599095990; Sun, 12 Jan 2014 23:44:55 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e4si9889732qas.185.2014.01.12.23.44.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jan 2014 23:44:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:40930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cCd-0000Ev-KW for patch@linaro.org; Mon, 13 Jan 2014 02:44:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cBb-0007PC-Sb for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:43:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2cBW-00055o-0W for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:43:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cBV-00055Z-Ii for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:43:45 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0D7hhcV022028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Jan 2014 02:43:43 -0500 Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0D7hdeO018658; Mon, 13 Jan 2014 02:43:41 -0500 From: Stefan Hajnoczi To: Date: Mon, 13 Jan 2014 15:43:17 +0800 Message-Id: <1389598998-19897-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1389598998-19897-1-git-send-email-stefanha@redhat.com> References: <1389598998-19897-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori Subject: [Qemu-devel] [PULL 2/3] Fix lan9118 TX "CMD A" handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Roy Franz The 9118 ethernet controller supports transmission of multi-buffer packets with arbitrary byte alignment of the start and end bytes. All writes to the packet fifo are 32 bits, so the controller discards bytes at the beginning and end of each buffer based on the 'Data start offset' and 'Buffer size' of the TX command 'A' format. This patch changes the buffer size and offset internal state variables to be updated on every "TX command A" write. Previously they were only updated for the first segment, which resulted incorrect behavior for packets with more than one segment. Each segment of the packet has its own CMD A command, with its own buffer size and start offset. Also update extraction of fields from the CMD A word to use extract32(). Signed-off-by: Roy Franz Reviewed-by: Peter Crosthwaite Signed-off-by: Stefan Hajnoczi --- hw/net/lan9118.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 2315f99..bb0c503 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -727,14 +727,14 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) s->txp->cmd_a = val & 0x831f37ff; s->txp->fifo_used++; s->txp->state = TX_B; + s->txp->buffer_size = extract32(s->txp->cmd_a, 0, 11); + s->txp->offset = extract32(s->txp->cmd_a, 16, 5); break; case TX_B: if (s->txp->cmd_a & 0x2000) { /* First segment */ s->txp->cmd_b = val; s->txp->fifo_used++; - s->txp->buffer_size = s->txp->cmd_a & 0x7ff; - s->txp->offset = (s->txp->cmd_a >> 16) & 0x1f; /* End alignment does not include command words. */ n = (s->txp->buffer_size + s->txp->offset + 3) >> 2; switch ((n >> 24) & 3) {