From owner-freebsd-mips@FreeBSD.ORG Sat Mar 10 13:37:16 2012 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDD041065672 for ; Sat, 10 Mar 2012 13:37:16 +0000 (UTC) (envelope-from ray@ddteam.net) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 645298FC12 for ; Sat, 10 Mar 2012 13:37:16 +0000 (UTC) Received: by wern13 with SMTP id n13so7850wer.13 for ; Sat, 10 Mar 2012 05:37:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=MxnGfkH3X94LBvFdP5gfD0/me7YWfoFBRHeZa9H5N74=; b=BhU+OiSZVWWJoV9THj1eM5z/jZwFlx8bxM18T9yi+VY9FpSsbdCNoh/yHXRpJ02bCO 8le6ceghdxpyglLOYKdaSdn7Mi7Yi4uAsvvL2ZfW0O2u95zhsHiyPciyqkTa3JSdKyhj K5WJBcOkV3sKV3KJ246WOIw77fBwOQL5TOHLhaKuMMGH/y7BA1pur9mVWFspCN+87HYO NqUWpETd1vM/1Xae90TT8VYdo+kqxMw7azVsadyv4cdzre01JwM2Rv+rcLu1MEDIbTo6 aT0NMdJTuiYxyHJT3Xz66tVF0kxFE0cdV1j9LliKkVO+IMDaK/S/x29BJ6zdQEtPzPAs GCPw== Received: by 10.216.134.24 with SMTP id r24mr3473106wei.84.1331385133742; Sat, 10 Mar 2012 05:12:13 -0800 (PST) Received: from rnote.ddteam.net (153-105-133-95.pool.ukrtel.net. [95.133.105.153]) by mx.google.com with ESMTPS id ep17sm14327295wid.2.2012.03.10.05.12.11 (version=SSLv3 cipher=OTHER); Sat, 10 Mar 2012 05:12:12 -0800 (PST) Date: Sat, 10 Mar 2012 15:11:28 +0200 From: Aleksandr Rybalko To: Patrick Kelsey Message-Id: <20120310151128.647d4a18.ray@ddteam.net> In-Reply-To: References: X-Mailer: Sylpheed 3.1.2 (GTK+ 2.24.5; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQljU5v5Dn+QBfrZAS4Ae4HCuiUGyKaKJlq1n9gQ3FPKMw3qJmBTszWw1iZIpxzulQANuNly Cc: freebsd-mips@freebsd.org Subject: Re: [PATCH] Fix for using NFS root with if_arge X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2012 13:37:16 -0000 On Fri, 9 Mar 2012 21:53:13 -0500 Patrick Kelsey wrote: > This patch fixes an issue I encountered using an NFS root with an > ar71xx-based MikroTik RouterBoard 450G on -current where the kernel > fails to contact a DHCP/BOOTP server via if_arge when it otherwise > should be able to. This may be the same issue that Monthadar Al > Jaberi reported against an RSPRO on 6 March, as the signature is the > same: > > %%% > > DHCP/BOOTP timeout for server 255.255.255.255 > DHCP/BOOTP timeout for server 255.255.255.255 > DHCP/BOOTP timeout for server 255.255.255.255 > . > . > . > DHCP/BOOTP timeout for server 255.255.255.255 > DHCP/BOOTP timeout for server 255.255.255.255 > arge0: initialization failed: no memory for rx buffers > DHCP/BOOTP timeout for server 255.255.255.255 > arge0: initialization failed: no memory for rx buffers > > %%% > > The primary issue that I found is that the DHCP/BOOTP message that > bootpc_call() is sending never makes it onto the wire, which I > believe is due to the following: > > - Last December, a change was made to the ifioctl that bootpc_call() > uses to adjust the netmask around the sosend(). > > - The new ioctl (SIOCAIFADDR) performs an if_init when invoked, > whereas the old one (SIOCSIFNETMASK) did not. > > - if_arge maintains its own sense of link state in > sc->arge_link_status. > > - On a single-phy interface, sc->arge_link_status is initialized to 0 > in arge_init_locked(). > > - sc->arge_link_status remains 0 until a phy state change notification > causes arge_link_task to run, notice the link is up, and set it to 1. > > - The inits caused by the ifioctls in bootpc_call are reinitializing > the interface, but not the phy, so sc->arge_link_status goes to 0 and > remains there. > > - arge_start_locked() always sees sc->arge_link_status == 0 and > returns without queuing anything. > > > The attached patch changes arge_init_locked() such that in the > single-phy case, instead of initializing sc->arge_link_status to 0, > it runs arge_link_task() to set it according to the current phy > state. This change has allowed my setup to mount an NFS root > successfully. > > I think there is a secondary issue here regarding the "arge0: > initialization failed: no memory for rx buffers". I have not dug > into it completely yet, but at first blush it seems that arge_stop() > leaks mbufs from the rx ring, so after some number of arge_init() > calls (in this case triggered by the DHCP/BOOTP message timeouts), > all mbufs are exhausted. > > -Patrick Hi Patrick, yeah, if_arge really have two or even three problems: 1. Different levels of allocate/free ring buffer (allocate in if_start, but free in device_detatch), so we get memory leak when do if_up/if_down. 2. some wrong value which sometime passed to arge_set_pll, then we try to send some packet without run MAC clock. 3. problem that you explain First and second fixed by http://my.ddteam.net/files/if_arge.c.patch. Not yet commited, because not solve main problem. We will test your patch and commit it ASAP. Thank you! WBW -- Aleksandr Rybalko