From owner-svn-soc-all@FreeBSD.ORG Tue Jun 2 14:28:46 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DB951506 for ; Tue, 2 Jun 2015 14:28:45 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE5231538 for ; Tue, 2 Jun 2015 14:28:45 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t52ESjGN029760 for ; Tue, 2 Jun 2015 14:28:45 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t52ESihj029738 for svn-soc-all@FreeBSD.org; Tue, 2 Jun 2015 14:28:44 GMT (envelope-from btw@FreeBSD.org) Date: Tue, 2 Jun 2015 14:28:44 GMT Message-Id: <201506021428.t52ESihj029738@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286556 - soc2015/btw/head/sys/net MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2015 14:28:46 -0000 Author: btw Date: Tue Jun 2 14:28:43 2015 New Revision: 286556 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286556 Log: Add the supports for allocating per-ring counters to ifnet KPI. Modified: soc2015/btw/head/sys/net/if.c soc2015/btw/head/sys/net/if.h soc2015/btw/head/sys/net/if_var.h Modified: soc2015/btw/head/sys/net/if.c ============================================================================== --- soc2015/btw/head/sys/net/if.c Tue Jun 2 13:07:22 2015 (r286555) +++ soc2015/btw/head/sys/net/if.c Tue Jun 2 14:28:43 2015 (r286556) @@ -514,8 +514,9 @@ struct iftype *ift; struct ifnet *ifp; struct ifaddr *ifa; + struct ifring **ifrs; struct sockaddr_dl *sdl; - int socksize, ifasize, namelen, masklen; + int socksize, ifasize, namelen, masklen, nrings; KASSERT(ifat->ifat_version == IF_ATTACH_VERSION, ("%s: version %d, expected %d", @@ -611,6 +612,18 @@ refcount_init(&ifp->if_refcount, 1); /* + * Allocate ifring to store the per-ring statistics for this + * interface. + */ + nrings = ifat->ifat_nrings; + ifrs = malloc(sizeof(struct ifring *) * nrings, M_IFNET, M_WAITOK); + for (int i = 0; i < nrings; i++) + ifrs[i] = malloc(sizeof(struct ifring), M_IFNET, + M_WAITOK | M_ZERO); + ifp->if_nrings = nrings; + ifp->if_rings = ifrs; + + /* * Allocate ifaddr to store link level address and name for this * interface. Always save enough space for any possiable name so * we can do a rename in place later. @@ -683,6 +696,10 @@ ifmedia_free(ifp); + for (int i = 0; i < ifp->if_nrings; i++) + free(ifp->if_rings[i], M_IFNET); + free(ifp->if_rings, M_IFNET); + rw_destroy(&ifp->if_lock); free(ifp, M_IFNET); } @@ -1572,6 +1589,8 @@ return (ifp->if_xname); case IF_VLAN: return (ifp->if_vlantrunk); + case IF_RING: + return (ifp->if_rings); default: /* fall through */ ; Modified: soc2015/btw/head/sys/net/if.h ============================================================================== --- soc2015/btw/head/sys/net/if.h Tue Jun 2 13:07:22 2015 (r286555) +++ soc2015/btw/head/sys/net/if.h Tue Jun 2 14:28:43 2015 (r286556) @@ -588,6 +588,7 @@ IF_VLAN, IF_TOEDEV, IF_MEDIA, + IF_RING, /* * Space above 99999 is split among different vendors. * @@ -597,6 +598,7 @@ } ift_feature; typedef struct ifnet * if_t; +typedef struct ifring * ifring_t; typedef void (*if_input_t)(if_t, struct mbuf *); typedef int (*if_transmit_t)(if_t, struct mbuf *); @@ -726,6 +728,10 @@ * later. Otherwise it inherits static iftsomax from ifdriver. */ struct iftsomax *ifat_tsomax; + /* + * Number of the tx/rx rings. + */ + int ifat_nrings; }; /* Modified: soc2015/btw/head/sys/net/if_var.h ============================================================================== --- soc2015/btw/head/sys/net/if_var.h Tue Jun 2 13:07:22 2015 (r286555) +++ soc2015/btw/head/sys/net/if_var.h Tue Jun 2 14:28:43 2015 (r286556) @@ -152,7 +152,7 @@ size_t if_linkmiblen; /* length of above data */ u_int if_refcount; /* reference count */ u_int if_fib; /* interface FIB */ - struct ifring *if_rings; /* pairs of tx and rx rings */ + struct ifring **if_rings; /* pairs of tx and rx rings */ int if_nrings; /* elements in if_rings */ uint8_t if_link_state; /* current link state */