From owner-freebsd-net@FreeBSD.ORG Thu Jun 10 09:00:35 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 938A2106566B; Thu, 10 Jun 2010 09:00:35 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id 12CE78FC23; Thu, 10 Jun 2010 09:00:34 +0000 (UTC) Received: from lstewart.caia.swin.edu.au (lstewart.caia.swin.edu.au [136.186.229.95]) by lauren.room52.net (Postfix) with ESMTPSA id 78CDE7E871; Thu, 10 Jun 2010 19:00:30 +1000 (EST) Message-ID: <4C10A9AD.9020308@freebsd.org> Date: Thu, 10 Jun 2010 19:00:29 +1000 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.9) Gecko/20100409 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jung-uk Kim References: <201006091444.50560.jkim@FreeBSD.org> In-Reply-To: <201006091444.50560.jkim@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: [RFC] BPF timestamping X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2010 09:00:35 -0000 On 06/10/10 04:44, Jung-uk Kim wrote: > bpf(4) can only timestamp packets with microtime(9). I want to expand > it to be able to use different format and resolution. The patch is > here: > > http://people.freebsd.org/~jkim/bpf_tstamp.diff > > With this patch, we can select different format and resolution of the > timestamps. It is done via ioctl(2) with BIOCSTSTAMP command. > Similarly, you can get the current format and resolution with > BIOCGTSTAMP command. Currently, the following functions are > available: > > BPF_T_MICROTIME microtime(9) > BPF_T_NANOTIME nanotime(9) > BPF_T_BINTIME bintime(9) > BPF_T_MICROTIME_FAST getmicrotime(9) > BPF_T_NANOTIME_FAST getnanotime(9) > BPF_T_BINTIME_FAST getbintime(9) > BPF_T_NONE ignore time stamps This sounds great, assuming it is extensible such that it's easy to add new methods in the future. > (Note: Additionally, there is an experimental machanism to tag packets > with timestamps in struct bintime format via mbuf_tags(9) from lower > layer, e.g., device driver. However, I didn't test it because I > wasn't sure whether this is the right thing to do.) This is also an important feature for newer NICs, but I'm also not sure if tags are the right way to do it. It certainly wouldn't be a bad way to start though. > While I was here, I moved the bogus SIZEOF_BPF_HDR macro into bpf.c > and tried to make it little bit more correct. For example, the > 32-bit shim should be able to handle alignment more properly for > non-Ethernet DLTs. I tried my best not to break ABI/API (especially > for 32-bit platforms) and relevant places are all marked with > BURN_BRIDGES. > > What do you think? Is it worth committing? I won't comment on the actual patch, but the ideas described above get the thumbs up from me. Cheers, Lawrence