From patchwork Fri Dec 20 18:26:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 22693 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B07252054F for ; Fri, 20 Dec 2013 18:26:52 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id c14sf3147469vea.10 for ; Fri, 20 Dec 2013 10:26:51 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ih/7Az8oByMB9VpJSDJBuiIakXMpN9BjxU0OIXmf4rk=; b=UC3tvHHq8DtC/p1kaZV1hujnc8f2Cvc7pXQHyRSHWHyVq9XNWH5KNhaoo/MmWvCs+v GgFF6jgg6vf3/krZSInkYNQvFoPl82RR8HgaZRrYC80MonXES46+wSkcUE61IPSCGIAB PhogMkS16gufq5BOz4Y+bl/szSYVVdif7pkKWQXKixX7lCTdJ3micql4XUEgFJBuE+6g eI6HvXYnpcLQxKs+0ncSvSRs6KZkMr59LYPAkLlS8m2aHA9v0nxCMHcgor2h1V1eKj9j g2fbDKM5FGoiZOfynizM5L0NIDLc8OOpd7loR+zO1V8HZGHh5f7HTRcPwVdNWbCwAHDs 6Pyg== X-Gm-Message-State: ALoCoQlW/aEYhsZ5rvVsEDhNMpLB0jlJ7Sn43UNGERti5gQV/XhHbSh5mWBmn1t5wyPxKoH+T67y X-Received: by 10.58.134.15 with SMTP id pg15mr174924veb.14.1387564011828; Fri, 20 Dec 2013 10:26:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.35 with SMTP id c3ls791258qed.83.gmail; Fri, 20 Dec 2013 10:26:51 -0800 (PST) X-Received: by 10.220.174.200 with SMTP id u8mr5924188vcz.6.1387564011714; Fri, 20 Dec 2013 10:26:51 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id gw7si1683300veb.114.2013.12.20.10.26.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:26:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so1638068veb.7 for ; Fri, 20 Dec 2013 10:26:51 -0800 (PST) X-Received: by 10.52.168.106 with SMTP id zv10mr1971349vdb.21.1387564011621; Fri, 20 Dec 2013 10:26:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp81552ved; Fri, 20 Dec 2013 10:26:50 -0800 (PST) X-Received: by 10.66.26.106 with SMTP id k10mr10435498pag.136.1387564010483; Fri, 20 Dec 2013 10:26:50 -0800 (PST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by mx.google.com with ESMTPS id tr4si5826102pab.266.2013.12.20.10.26.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:26:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.49 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.220.49; Received: by mail-pa0-f49.google.com with SMTP id kx10so2958978pab.36 for ; Fri, 20 Dec 2013 10:26:50 -0800 (PST) X-Received: by 10.68.134.229 with SMTP id pn5mr10374593pbb.9.1387564010080; Fri, 20 Dec 2013 10:26:50 -0800 (PST) Received: from rfranz-i7.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id yi10sm20739985pab.8.2013.12.20.10.26.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2013 10:26:49 -0800 (PST) From: Roy Franz To: qemu-devel@nongnu.org, stefanha@redhat.com, aliguori@amazon.com Cc: peter.maydell@linaro.org, patches@linaro.org, Roy Franz Subject: [PATCH 1/2] net: Fix lan9118 TX "CMD A" handling Date: Fri, 20 Dec 2013 10:26:36 -0800 Message-Id: <1387563997-1845-2-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387563997-1845-1-git-send-email-roy.franz@linaro.org> References: <1387563997-1845-1-git-send-email-roy.franz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Signed-off-by: Roy Franz --- 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..c5d6f14 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 = s->txp->cmd_a & 0x7ff; + s->txp->offset = (s->txp->cmd_a >> 16) & 0x1f; 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) {