From patchwork Wed Jan 8 04:19:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 22929 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 10B80202E0 for ; Wed, 8 Jan 2014 04:20:04 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id h16sf4518270oag.1 for ; Tue, 07 Jan 2014 20:20:04 -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=vqi0eyfa/zD43PX7Pi13/UlQUD1+PmQXn7c/PNM8J4U=; b=Vl7uu4wghkUlB+dJ3Y56kC75bG7gN5jI3egepZWWGJvQ/O95YNAmll2uFcMVdQ2+ua 2xaUyCLZ/Ypp6269qqpk2QjQWONzZbru5XjehBA8r0ndnRIbiPKzku0xeah9MHlykU9r FD9cmZqWVQfF4cZXJQTwnyXl6ZmEPKqi9WW0JxYHitnLPxHj7AWSU2f8dI18sjzeFWdo Pbt3JG6gY/PDuqsys32s9IEs5MzCjoMDjBfSlPf652XPIIicXoTUXOS7G0opkE5+CrPF PnPOSPp4rAMZkPyfGLX6Nc1KhQM+afGPou9cwj9zRGoZGRFUEaHhxbsimL/URk23iK6i /lTQ== X-Gm-Message-State: ALoCoQlmIUJx2kPQXj7dCSrOlDAxedbp3p24sSNFkDDgmCxN7L4IX1ES456dWtTrzUHV67WHzbf3 X-Received: by 10.43.163.202 with SMTP id mp10mr45904744icc.19.1389154804212; Tue, 07 Jan 2014 20:20:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.131.4 with SMTP id oi4ls411158qeb.76.gmail; Tue, 07 Jan 2014 20:20:04 -0800 (PST) X-Received: by 10.58.223.137 with SMTP id qu9mr55255536vec.10.1389154804118; Tue, 07 Jan 2014 20:20:04 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id qi8si1383834vec.31.2014.01.07.20.20.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 07 Jan 2014 20:20:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 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.52; Received: by mail-vb0-f52.google.com with SMTP id p5so787993vbn.11 for ; Tue, 07 Jan 2014 20:20:04 -0800 (PST) X-Received: by 10.58.223.137 with SMTP id qu9mr55255529vec.10.1389154803965; Tue, 07 Jan 2014 20:20:03 -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 ey3csp201978ved; Tue, 7 Jan 2014 20:20:03 -0800 (PST) X-Received: by 10.236.119.141 with SMTP id n13mr492845yhh.136.1389154803462; Tue, 07 Jan 2014 20:20:03 -0800 (PST) Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by mx.google.com with ESMTPS id n7si15893546qac.85.2014.01.07.20.20.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 07 Jan 2014 20:20:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.42 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.216.42; Received: by mail-qa0-f42.google.com with SMTP id ii20so1451832qab.1 for ; Tue, 07 Jan 2014 20:20:03 -0800 (PST) X-Received: by 10.49.2.170 with SMTP id 10mr206473443qev.24.1389154803246; Tue, 07 Jan 2014 20:20:03 -0800 (PST) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id g10sm108535412qaf.9.2014.01.07.20.20.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jan 2014 20:20:02 -0800 (PST) From: Roy Franz To: qemu-devel@nongnu.org, peter.maydell@linaro.org, kwolf@redhat.com, stefanha@redhat.com Cc: peter.crosthwaite@xilinx.com, patches@linaro.org, Roy Franz Subject: [PATCH V2 1/2] Fix lan9118 TX "CMD A" handling Date: Tue, 7 Jan 2014 20:19:51 -0800 Message-Id: <1389154792-6651-2-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1389154792-6651-1-git-send-email-roy.franz@linaro.org> References: <1389154792-6651-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.212.52 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. Also update extraction of fields from the CMD A word to use extract32(). 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..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) {