From owner-freebsd-net@FreeBSD.ORG Thu May 17 15:00:42 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2DDE4106564A; Thu, 17 May 2012 15:00:42 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id F32708FC18; Thu, 17 May 2012 15:00:38 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3FB1EB94E; Thu, 17 May 2012 11:00:38 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Thu, 17 May 2012 10:33:37 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <75E1A2A7D185F841A975979B0906BBA67C7A229F49@AVEXMB1.qlogic.org> In-Reply-To: <75E1A2A7D185F841A975979B0906BBA67C7A229F49@AVEXMB1.qlogic.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201205171033.37636.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 17 May 2012 11:00:38 -0400 (EDT) Cc: "freebsd-net@freebsd.org" , "freebsd-current@freebsd.org \(freebsd-current@FreeBSD.org\)" , "davidcs@FreeBSD.org" , David Somayajulu Subject: Re: Ethernet Drivers: Question on ifp->if_ioctl invocation for SIOCADDMULTI and SIOCDELMULTI 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, 17 May 2012 15:00:42 -0000 On Wednesday, May 16, 2012 2:41:25 pm David Somayajulu wrote: > Hi All, > When ifp->if_ioctl() is invoked for the ioctl cmd SIOCADDMULTI, > > > > IN_MULTI_LOCK() is called in one of the functions in_joingroup() in the caller stack. > > > > >From netinet/in_var.h, line 357 : #define IN_MULTI_LOCK() mtx_lock(&in_multi_mtx) > > > > >From netinet/in_mcast.c > 1098 in_joingroup(struct ifnet *ifp, const struct in_addr *gina, > 1099 /*const*/ struct in_mfilter *imf, struct in_multi **pinm) > 1100 { > 1101 int error; > 1102 > 1103 IN_MULTI_LOCK(); > 1104 error = in_joingroup_locked(ifp, gina, imf, pinm); > 1105 IN_MULTI_UNLOCK(); > 1106 > > This is also the case for SIOCDELMULTI, where the function holding "in_multi_mtx" lock is in_leavegroup() > > This poses a problem in the driver in that the hardware dependent function performing it, is not allowed to sleep() in case it needs to poll some state. > > Question: > > 1. If I want to implement any delays - for the above case - in the driver using DELAY(usec) macro, is there a maximum amount of time that the driver is allowed to complete this function? I am concerned that if it takes to too long I might run into a soft_lockup() situation. > > 2. Is it o.k to defer the processing in a separate in a separate thread which can sleep() ? You can always queue a task to update the MAC table if you need to use a sleep. -- John Baldwin