From patchwork Mon Jan 27 14:48:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 23748 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3966D20300 for ; Mon, 27 Jan 2014 14:51:58 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id 131sf29371014ykp.1 for ; Mon, 27 Jan 2014 06:51:57 -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=T9AdtPhwF3Mum5YoQ8GwJ5ZWnc+28Vpp0oyrt0OwTypmCEdJVF+z3vSljDJGNYsOu1 MktMqjGNBPyNYvbPS0ZJXssKtVgTY0xWB0W2zsyWlfNjkIZnfh3emrXIKdGWDURqTd7f 478DuZEK1LjYyAQkHCpPmTK6I79gsdZb+BZDqTvFOc3NIR26bCzlWTYCNU33WlBAQ2My ELxdSZmdZ/IYBAvLG3K1dhV6JC/54P3sr6B+ZAf/y73pVlsGP4Mo9d/xlsRu7usiIBOM JMgncNyeHofnGLKvnJk47EzWb+GOt3aSA53bOSQ8H2lQhXra+fo+3aVmt8JGqMg10piv N59w== X-Gm-Message-State: ALoCoQnh7yWoS7S+wfuGstKCWamOcpeZDx6RNaFymmE9uxAH8hFm8A1tOp5W3STdDKr2pt9LoPQB X-Received: by 10.58.18.172 with SMTP id x12mr10307834ved.3.1390834317360; Mon, 27 Jan 2014 06:51:57 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls1636482qge.43.gmail; Mon, 27 Jan 2014 06:51:57 -0800 (PST) X-Received: by 10.52.76.105 with SMTP id j9mr105528vdw.52.1390834317222; Mon, 27 Jan 2014 06:51:57 -0800 (PST) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id ls10si5177631vec.19.2014.01.27.06.51.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 06:51:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.51 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.51; Received: by mail-vb0-f51.google.com with SMTP id 11so3415245vbe.38 for ; Mon, 27 Jan 2014 06:51:57 -0800 (PST) X-Received: by 10.220.92.135 with SMTP id r7mr16014504vcm.11.1390834317122; Mon, 27 Jan 2014 06:51:57 -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.220.174.196 with SMTP id u4csp134483vcz; Mon, 27 Jan 2014 06:51:56 -0800 (PST) X-Received: by 10.204.167.81 with SMTP id p17mr19937752bky.59.1390834315956; Mon, 27 Jan 2014 06:51:55 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id lh1si14628419bkb.262.2014.01.27.06.51.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 27 Jan 2014 06:51: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]:59945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7nXW-0004kM-Ch for patch@linaro.org; Mon, 27 Jan 2014 09:51:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7nV2-0000wq-Lj for qemu-devel@nongnu.org; Mon, 27 Jan 2014 09:49:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7nUx-0006Zm-RI for qemu-devel@nongnu.org; Mon, 27 Jan 2014 09:49:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7nUx-0006Zb-J7 for qemu-devel@nongnu.org; Mon, 27 Jan 2014 09:49:15 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0REnAoa025516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Jan 2014 09:49:10 -0500 Received: from localhost (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0REn9PY002046; Mon, 27 Jan 2014 09:49:09 -0500 From: Stefan Hajnoczi To: Date: Mon, 27 Jan 2014 15:48:47 +0100 Message-Id: <1390834129-19625-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1390834129-19625-1-git-send-email-stefanha@redhat.com> References: <1390834129-19625-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Anthony Liguori Subject: [Qemu-devel] [PULL 2/4] 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.51 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) {