From patchwork Tue Jan 10 10:27:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 135254 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C1A6EB6FB6 for ; Wed, 11 Jan 2012 02:31:58 +1100 (EST) Received: from localhost ([::1]:57804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkczp-0006QG-9c for incoming@patchwork.ozlabs.org; Tue, 10 Jan 2012 09:48:17 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkYvc-0003TO-6n for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkYvX-0004jk-J9 for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:40 -0500 Received: from ra.se.axis.com ([195.60.68.13]:57442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkYvX-0004ig-7x for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:35 -0500 Received: from localhost (localhost [127.0.0.1]) by ra.se.axis.com (Postfix) with ESMTP id 8C58786C7C for ; Tue, 10 Jan 2012 11:27:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ra.se.axis.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "To" Received: from ra.se.axis.com ([127.0.0.1]) by localhost (ra.se.axis.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7wLbGWr1saEf for ; Tue, 10 Jan 2012 11:27:27 +0100 (CET) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by ra.se.axis.com (Postfix) with ESMTP id 93BE713D5C for ; Tue, 10 Jan 2012 11:27:27 +0100 (CET) Received: from localhost (edgar.se.axis.com [10.93.151.1]) by thoth.se.axis.com (Postfix) with ESMTP id 85DE734105 for ; Tue, 10 Jan 2012 11:27:27 +0100 (CET) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Tue, 10 Jan 2012 11:27:27 +0100 Message-Id: <1326191247-14880-4-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1326191247-14880-1-git-send-email-edgar.iglesias@gmail.com> References: <1326191247-14880-1-git-send-email-edgar.iglesias@gmail.com> To: edgar.iglesias@gmail.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 195.60.68.13 X-Mailman-Approved-At: Tue, 10 Jan 2012 09:47:50 -0500 Subject: [Qemu-devel] [PATCH] etraxfs-dma: Model metadata and eop 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Lars Persson - Send EOP flags to the out channels. - Send data descriptor metadata to the out channels. Signed-off-by: Lars Persson Signed-off-by: Edgar E. Iglesias --- hw/etraxfs_dma.c | 28 ++++++++++++++++++++++------ hw/etraxfs_dma.h | 13 ++++++++++--- hw/etraxfs_eth.c | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c index d2bd584..332525c 100644 --- a/hw/etraxfs_dma.c +++ b/hw/etraxfs_dma.c @@ -401,15 +401,29 @@ static int channel_out_run(struct fs_dma_ctrl *ctrl, int c) uint32_t saved_data_buf; unsigned char buf[2 * 1024]; + struct dma_context_metadata meta; + bool send_context = true; + if (ctrl->channels[c].eol) return 0; do { + bool out_eop; D(printf("ch=%d buf=%x after=%x\n", c, (uint32_t)ctrl->channels[c].current_d.buf, (uint32_t)ctrl->channels[c].current_d.after)); + if (send_context) { + if (ctrl->channels[c].client->client.metadata_push) { + meta.metadata = ctrl->channels[c].current_d.md; + ctrl->channels[c].client->client.metadata_push( + ctrl->channels[c].client->client.opaque, + &meta); + } + send_context = false; + } + channel_load_d(ctrl, c); saved_data_buf = channel_reg(ctrl, c, RW_SAVED_DATA_BUF); len = (uint32_t)(unsigned long) @@ -420,13 +434,17 @@ static int channel_out_run(struct fs_dma_ctrl *ctrl, int c) len = sizeof buf; cpu_physical_memory_read (saved_data_buf, buf, len); - D(printf("channel %d pushes %x %u bytes\n", c, - saved_data_buf, len)); + out_eop = ((saved_data_buf + len) == + ctrl->channels[c].current_d.after) && + ctrl->channels[c].current_d.out_eop; + + D(printf("channel %d pushes %x %u bytes eop=%u\n", c, + saved_data_buf, len, out_eop)); if (ctrl->channels[c].client->client.push) ctrl->channels[c].client->client.push( ctrl->channels[c].client->client.opaque, - buf, len); + buf, len, out_eop); else printf("WARNING: DMA ch%d dataloss," " no attached client.\n", c); @@ -437,11 +455,9 @@ static int channel_out_run(struct fs_dma_ctrl *ctrl, int c) ctrl->channels[c].current_d.after) { /* Done. Step to next. */ if (ctrl->channels[c].current_d.out_eop) { - /* TODO: signal eop to the client. */ - D(printf("signal eop\n")); + send_context = true; } if (ctrl->channels[c].current_d.intr) { - /* TODO: signal eop to the client. */ /* data intr. */ D(printf("signal intr %d eol=%d\n", len, ctrl->channels[c].current_d.eol)); diff --git a/hw/etraxfs_dma.h b/hw/etraxfs_dma.h index 96408ab..021c52a 100644 --- a/hw/etraxfs_dma.h +++ b/hw/etraxfs_dma.h @@ -1,3 +1,8 @@ +struct dma_context_metadata { + /* data descriptor md */ + uint16_t metadata; +}; + struct etraxfs_dma_client { /* DMA controller. */ @@ -5,10 +10,12 @@ struct etraxfs_dma_client void *ctrl; /* client. */ - struct - { - int (*push)(void *opaque, unsigned char *buf, int len); + struct { + int (*push)(void *opaque, unsigned char *buf, + int len, bool eop); void (*pull)(void *opaque); + void (*metadata_push)(void *opaque, + const struct dma_context_metadata *md); void *opaque; } client; }; diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index b525258..5afa55f 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -540,7 +540,7 @@ static ssize_t eth_receive(VLANClientState *nc, const uint8_t *buf, size_t size) return size; } -static int eth_tx_push(void *opaque, unsigned char *buf, int len) +static int eth_tx_push(void *opaque, unsigned char *buf, int len, bool eop) { struct fs_eth *eth = opaque;