From patchwork Fri Dec 20 18:26:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 22694 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5DF612054F for ; Fri, 20 Dec 2013 18:26:55 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id jw12sf3159494veb.7 for ; Fri, 20 Dec 2013 10:26:54 -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=Srdz8BlNa7N+HeN3di3mv4qTkOIStS9Q/Cw+Kqgfwj4=; b=er/T2Y+sxjeLYuHdjpCNHTNfhxbvBskL2OFLSOeKzmDopVERIAaC9v9q5P4B/wceXW kBM9VTRk8t8ftIPC5qSswSQC/3K+YebGJjYCn9iq01cZld4hP3UOED/3COui1r1RDONV YEH/IsFxLzAcrTUGASFnIrrY1Ce+sIVptH3bXl3npNaBnUvgRhdf4fHUgSclMcAO2Lju ARRFytXo4C/6VCtUvQkGNqLW2jx77IBXyIe4QN9fkYrmpbnMzSbEcBQF/jc3wSc3FS50 1yo0eFjmcHuVvqGUtsXBZYZa+c40U6j+07qawS+bO7jgCoOXF637vI6ZUr0jOHU3AVid xh3Q== X-Gm-Message-State: ALoCoQlmhKpIPlsWrUvcvz65m20ohxUAVB6YAz9PBBHuLoe/fP/P4r++9WJtzFG5gZvs4C99n4WE X-Received: by 10.58.154.5 with SMTP id vk5mr4105066veb.32.1387564014579; Fri, 20 Dec 2013 10:26:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.164 with SMTP id ld4ls824237qeb.51.gmail; Fri, 20 Dec 2013 10:26:54 -0800 (PST) X-Received: by 10.220.57.195 with SMTP id d3mr5748547vch.15.1387564014503; Fri, 20 Dec 2013 10:26:54 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id sl9si1677162vdc.138.2013.12.20.10.26.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:26:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ia6so1405999vcb.39 for ; Fri, 20 Dec 2013 10:26:54 -0800 (PST) X-Received: by 10.52.237.228 with SMTP id vf4mr4910131vdc.3.1387564014425; Fri, 20 Dec 2013 10:26:54 -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 ey3csp81555ved; Fri, 20 Dec 2013 10:26:53 -0800 (PST) X-Received: by 10.68.134.98 with SMTP id pj2mr10292727pbb.110.1387564013488; Fri, 20 Dec 2013 10:26:53 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id tt8si5852200pbc.198.2013.12.20.10.26.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:26:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.220.54; Received: by mail-pa0-f54.google.com with SMTP id rd3so2971786pab.13 for ; Fri, 20 Dec 2013 10:26:53 -0800 (PST) X-Received: by 10.68.218.98 with SMTP id pf2mr10088953pbc.121.1387564013109; Fri, 20 Dec 2013 10:26:53 -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.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2013 10:26:52 -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 2/2] net: Fix lan9118 buffer length handling Date: Fri, 20 Dec 2013 10:26:37 -0800 Message-Id: <1387563997-1845-3-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.220.180 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 uses the provided buffer length to limit the bytes transmitted. Previously all the bytes of the last 32-bit word written to the TX fifo were added to the internal transmit buffer structure resulting in more bytes being transmitted than were submitted to the hardware in the command. This resulted in extra bytes being inserted into the middle of multi-buffer packets when the non-final buffers had non-32bit aligned ending addresses. Signed-off-by: Roy Franz --- hw/net/lan9118.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index c5d6f14..712bb41 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -773,11 +773,10 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) in FIFO words. Empirical results show it to be little-endian. */ /* TODO: FIFO overflow checking. */ - while (n--) { + while (n-- && s->txp->buffer_size--) { s->txp->data[s->txp->len] = val & 0xff; s->txp->len++; val >>= 8; - s->txp->buffer_size--; } s->txp->fifo_used++; }