Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2014 09:38:13 -0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        "Andrey V. Elsukov" <ae@freebsd.org>
Cc:        "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: [RFC] add macros for ifnet statistic accounting
Message-ID:  <CAJ-Vmo=vP3TeV0G0vib4JuXx_%2B13x7y7CYMsv29_Ajv5U0c4XQ@mail.gmail.com>
In-Reply-To: <546E25D1.7020900@FreeBSD.org>
References:  <546E25D1.7020900@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <ae@freebsd.org> 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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-Vmo=vP3TeV0G0vib4JuXx_%2B13x7y7CYMsv29_Ajv5U0c4XQ>