From owner-svn-src-head@FreeBSD.ORG Fri Dec 23 16:03:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC5061065675; Fri, 23 Dec 2011 16:03:57 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B26288FC1B; Fri, 23 Dec 2011 16:03:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBNG3vgB073742; Fri, 23 Dec 2011 16:03:57 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBNG3vrV073739; Fri, 23 Dec 2011 16:03:57 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201112231603.pBNG3vrV073739@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 23 Dec 2011 16:03:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228845 - head/sys/dev/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2011 16:03:58 -0000 Author: luigi Date: Fri Dec 23 16:03:57 2011 New Revision: 228845 URL: http://svn.freebsd.org/changeset/base/228845 Log: 1. don't use if_pspare directly, but through a macro WMA() 2. move a variable declaration at the beginning of a block Modified: head/sys/dev/netmap/netmap.c head/sys/dev/netmap/netmap_kern.h Modified: head/sys/dev/netmap/netmap.c ============================================================================== --- head/sys/dev/netmap/netmap.c Fri Dec 23 16:02:14 2011 (r228844) +++ head/sys/dev/netmap/netmap.c Fri Dec 23 16:03:57 2011 (r228845) @@ -1039,7 +1039,7 @@ netmap_poll(__unused struct cdev *dev, i struct netmap_adapter *na; struct ifnet *ifp; struct netmap_kring *kring; - u_int i, check_all, want_tx, want_rx, revents = 0; + u_int core_lock, i, check_all, want_tx, want_rx, revents = 0; void *adapter; if (devfs_get_cdevpriv((void **)&priv) != 0 || priv == NULL) @@ -1116,8 +1116,7 @@ netmap_poll(__unused struct cdev *dev, i * LOCKED_CL core lock is set, so we need to release it. */ enum {NO_CL, NEED_CL, LOCKED_CL }; - int core_lock = (check_all || !na->separate_locks) ? - NEED_CL:NO_CL; + core_lock = (check_all || !na->separate_locks) ? NEED_CL:NO_CL; /* * We start with a lock free round which is good if we have * data available. If this fails, then lock and call the sync @@ -1246,7 +1245,7 @@ netmap_attach(struct netmap_adapter *na, buf = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); if (buf) { - ifp->if_pspare[0] = buf; + WNA(ifp) = buf; na->tx_rings = (void *)((char *)buf + sizeof(*na)); na->rx_rings = na->tx_rings + n; bcopy(na, buf, sizeof(*na)); @@ -1276,7 +1275,7 @@ netmap_detach(struct ifnet *ifp) knlist_destroy(&na->rx_rings[i].si.si_note); } bzero(na, sizeof(*na)); - ifp->if_pspare[0] = NULL; + WNA(ifp) = NULL; free(na, M_DEVBUF); } Modified: head/sys/dev/netmap/netmap_kern.h ============================================================================== --- head/sys/dev/netmap/netmap_kern.h Fri Dec 23 16:02:14 2011 (r228844) +++ head/sys/dev/netmap/netmap_kern.h Fri Dec 23 16:03:57 2011 (r228845) @@ -196,9 +196,13 @@ enum { }; /* - * return a pointer to the struct netmap adapter from the ifp + * NA returns a pointer to the struct netmap adapter from the ifp, + * WNA is used to write it. */ -#define NA(_ifp) ((struct netmap_adapter *)(_ifp)->if_pspare[0]) +#ifndef WNA +#define WNA(_ifp) (_ifp)->if_pspare[0] +#endif +#define NA(_ifp) ((struct netmap_adapter *)WNA(_ifp)) /*