From owner-svn-src-projects@FreeBSD.ORG Tue Jan 13 18:22:36 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DBEE3112; Tue, 13 Jan 2015 18:22:36 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4C9F77F; Tue, 13 Jan 2015 18:22:36 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 802DCB962; Tue, 13 Jan 2015 13:22:35 -0500 (EST) From: John Baldwin To: Gleb Smirnoff Subject: Re: svn commit: r277122 - projects/ifnet/sys/dev/msk Date: Tue, 13 Jan 2015 13:22:09 -0500 Message-ID: <5330876.Sb1U9Iz8Cz@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <201501130902.t0D927NE077024@svn.freebsd.org> References: <201501130902.t0D927NE077024@svn.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 13 Jan 2015 13:22:35 -0500 (EST) Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2015 18:22:37 -0000 On Tuesday, January 13, 2015 09:02:07 AM Gleb Smirnoff wrote: > Author: glebius > Date: Tue Jan 13 09:02:06 2015 > New Revision: 277122 > URL: https://svnweb.freebsd.org/changeset/base/277122 > > Log: > Welcome first real hardware NIC driver successfully converted to new > API, which hides struct ifnet from drivers entirely. > > This driver can be taken as an example, and this commit message will > probably be used to start a wiki page on conversion. > > List of changes required: > > o Remove at least if_var.h, bpf.h, if_arp.h, if_types.h, if_vlan_var.h > from includes list. > o Declare struct ifdriver in the beginning of a file. > o Convert from xxx_start(ifp) to xxx_transmit(ifp, m). > A simple conversion itself is quite straight: > * In ifdriver declaration define .ifdrv_maxqlen, take the value > from IFQ_SET_MAXLEN() macro. > * In ifdriver ifops declaration define if_transmit function. > * Rename xxx_start() to xxx_transmit() and change its prototype. > * The new named xxx_transmit() should: > - Try to if_snd_enqueue() the mbuf or return. > - Try to mtx_lock() the driver softc or return. Please no. This is a major source of pain with the current drivers that use buf_ring that is worked around in various (often broken) ways. The problem is that the other thread holding the lock might drop it right after your try lock fails and then the packet you just queued doesn't go out until you queue another packet. That's all fine and good if you are blasting packets out an interface. It is not fine and good if you have sparse traffic. That packet is now potentially delayed indefinitely. (In a real world scenario with a heartbeat protocol that sent out timing packets once a second or so to measure RTT between hosts this manifested as odd timings because we would see the timings jump by a second every so often when the packet was delayed until the next heartbeat). This kind of design decision is why I do not want to just blindly convert everything to suboptimal if_transmit routines. The current ifq based if_start model is better for 10/100 single-queue drivers than this. -- John Baldwin