From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15523 invoked by alias); 3 Mar 2009 19:24:13 -0000 Received: (qmail 15513 invoked by uid 22791); 3 Mar 2009 19:24:12 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Mar 2009 19:24:06 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LeaDj-000153-Ny for ecos-discuss@sources.redhat.com; Tue, 03 Mar 2009 19:24:03 +0000 Received: from 65.111.170.175 ([65.111.170.175]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Mar 2009 19:24:03 +0000 Received: from grante by 65.111.170.175 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Mar 2009 19:24:03 +0000 To: ecos-discuss@sources.redhat.com From: Grant Edwards Date: Wed, 04 Mar 2009 11:34:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: slrn/pre0.9.9-102 (Linux) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] Re: Avoiding memcpy in ethernet drivers X-SW-Source: 2009-03/txt/msg00011.txt.bz2 On 2009-03-03, Bart Veer wrote: >>>>>> "Edgar" == Edgar Grimberg writes: > >> Having to write a driver for an ethernet device, I noticed >> that there are 2 memcpy()s in most of the drivers, one when >> sending and one when receiving. This usually happens from and >> to the sg_list passed from the hardware independent ethernet >> driver. Now, is this really necessary? > > Ethernet hardware varies widely, but there are two main > categories: fifo vs. DMA. [...] > With DMA, ideally there would be no need for a copy operation > - if the hardware was designed just right, and if higher-level > code like the BSD, RedBoot or LWIP TCP/IP stacks did the right > thing. Unfortunately neither assumption is safe. > > For outgoing packets the DMA engine typically imposes some > limitations. For example the start of a DMA buffer may have to > be aligned to an integer boundary, or to a cacheline boundary > (typically but not always 16-bytes). If an outgoing packet is > split over multiple buffers then the DMA engine may require > that every buffer except the last one is a multiple of the > cacheline size. My experience is somewhat limited, but I've yet to see a uC Ethernet controller with a DMA engine that supported splitting frames in any manner at all (inbound or outbound). If the network stack requires that packets be split into various chunks, then there's simply no avoiding the copy operation. I think some high-end PCI Ethernet controllers aimed at the "server" market do have support for scatter/gather DMA, but that's not really the market for which eCos is intended. -- Grant Edwards grante Yow! HELLO KITTY gang at terrorizes town, family visi.com STICKERED to death! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss