From owner-freebsd-net@FreeBSD.ORG Thu Nov 20 17:38:15 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5510D8AD; Thu, 20 Nov 2014 17:38:15 +0000 (UTC) Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [IPv6:2a00:1450:400c:c00::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DC6F9CD7; Thu, 20 Nov 2014 17:38:14 +0000 (UTC) Received: by mail-wg0-f50.google.com with SMTP id k14so4327879wgh.23 for ; Thu, 20 Nov 2014 09:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=q50DR4LGOujL0xdyTYIedS3eA7gTH85frbwPt9RIlkc=; b=EPgtGo7yIsB5sI7cFEUl0gniTrZohTnH1rQFzNPqkXivhqYgj/4w7/+SMr8c6Coe3g LSbtvw3TBxHFMB9ufOVYuVrCZOPharJYVSzusEM0wN05aCMoHu/s4f7p2UijVHbLOiRX jpeGbsVhGtVnvppv5JMgAErCCqnn223yrlclizFFT15RxbdM1hWWAFHF8Irvt7G3usEV ZJ1N083pGbGuMQBFNe0Xd5EZjX1U69I/jLNwh8aMuSrU3iznZGdOPKcBnA4mzeCr0Z7V GA9B96FFsiXnXSRhtF635bf6RciRf3XTyxLY+ovART/i3LY3JJivDXmFrw8S2nerLgbf uFiw== MIME-Version: 1.0 X-Received: by 10.194.85.83 with SMTP id f19mr72135090wjz.20.1416505093204; Thu, 20 Nov 2014 09:38:13 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Thu, 20 Nov 2014 09:38:13 -0800 (PST) In-Reply-To: <546E25D1.7020900@FreeBSD.org> References: <546E25D1.7020900@FreeBSD.org> Date: Thu, 20 Nov 2014 09:38:13 -0800 X-Google-Sender-Auth: hw_kjtOUwa-S-BmMEWPQyxWsnx4 Message-ID: Subject: Re: [RFC] add macros for ifnet statistic accounting From: Adrian Chadd To: "Andrey V. Elsukov" Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-net@freebsd.org" , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 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, 20 Nov 2014 17:38:15 -0000 I like accessor things like this. It'll make the general porting of things across places more feasible. +1 from me. -adrian On 20 November 2014 09:33, Andrey V. Elsukov wrote: > Hi All, > > we already did some changes in network stack in head/, that made ability > for merging changes into stable branches much harder. > > What you think about adding the following macro to head/: > > --- if_var.h (revision 274736) > +++ if_var.h (working copy) > @@ -111,6 +111,10 @@ typedef enum { > IFCOUNTERS /* Array size. */ > } ift_counter; > > +#define IFSTAT_ADD(ifp, name, value) \ > + if_inc_counter((ifp), IFCOUNTER_ ## name, (value)) > +#define IFSTAT_INC(ifp, name) IFSTAT_ADD(ifp, name, 1) > + > typedef struct ifnet * if_t; > > typedef void (*if_start_fn_t)(if_t); > > > And then make a direct commit to stable/* branches like this: > > --- if_var.h (revision 274750) > +++ if_var.h (working copy) > @@ -104,6 +104,23 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* > #define V_link_pfil_hook VNET(link_pfil_hook) > #endif /* _KERNEL */ > > +#define IFSTAT_ADD(ifp, name, value) \ > + IFSTAT_ ## name ## _ADD(ifp, value) > +#define IFSTAT_INC(ifp, name) IFSTAT_ADD(ifp, name, 1) > + > +#define IFSTAT_IPACKETS_ADD(ifp, inc) (ifp)->if_ipackets += (inc) > +#define IFSTAT_IERRORS_ADD(ifp, inc) (ifp)->if_ierrors += (inc) > +#define IFSTAT_OPACKETS_ADD(ifp, inc) (ifp)->if_opackets += (inc) > +#define IFSTAT_OERRORS_ADD(ifp, inc) (ifp)->if_oerrors += (inc) > +#define IFSTAT_COLLISIONS_ADD(ifp, inc) (ifp)->if_collisions += (inc) > +#define IFSTAT_IBYTES_ADD(ifp, inc) (ifp)->if_ibytes += (inc) > +#define IFSTAT_OBYTES_ADD(ifp, inc) (ifp)->if_obytes += (inc) > +#define IFSTAT_IMCASTS_ADD(ifp, inc) (ifp)->if_imcasts += (inc) > +#define IFSTAT_OMCASTS_ADD(ifp, inc) (ifp)->if_omcasts += (inc) > +#define IFSTAT_IQDROPS_ADD(ifp, inc) (ifp)->if_iqdrops += (inc) > +#define IFSTAT_OQDROPS_ADD(ifp, inc) /* NOP */ > +#define IFSTAT_NOPROTO_ADD(ifp, inc) (ifp)->if_noproto += (inc) > + > /* > * Structure defining a queue for a network interface. > */ > > This can make merging a little bit easier, at least for generic code in > the network stack. > > -- > WBR, Andrey V. Elsukov > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"