FreeBSD/sys/net/netisr.c
/*
 * Sysctl monitoring for netisr: query per-protocol data across all
 * workstreams.
 */
Sysctl monitoring for netisr: query per-protocol data across all
workstreams.
Sysctl monitoring for netisr : query per - protocol data across all workstreams .
static int
sysctl_netisr_work(SYSCTL_HANDLER_ARGS)
{
	struct rm_priotracker tracker;
	struct sysctl_netisr_work *snwp, *snw_array;
	struct netisr_workstream *nwsp;
	struct netisr_proto *npp;
	struct netisr_work *nwp;
	u_int counter, cpuid, proto;
	int error;
	if (req->newptr != NULL)
		return (EINVAL);
	snw_array = malloc(sizeof(*snw_array) * MAXCPU * NETISR_MAXPROT,
	    M_TEMP, M_ZERO | M_WAITOK);
	counter = 0;
	NETISR_RLOCK(&tracker);
	CPU_FOREACH(cpuid) {
		nwsp = DPCPU_ID_PTR(cpuid, nws);
		if (nwsp->nws_intr_event == NULL)
			continue;
		NWS_LOCK(nwsp);
		for (proto = 0; proto < NETISR_MAXPROT; proto++) {
			npp = &netisr_proto[proto];
			if (npp->np_name == NULL)
				continue;
			nwp = &nwsp->nws_work[proto];
			snwp = &snw_array[counter];
			snwp->snw_version = sizeof(*snwp);
			snwp->snw_wsid = cpuid;		
			snwp->snw_proto = proto;
			snwp->snw_len = nwp->nw_len;
			snwp->snw_watermark = nwp->nw_watermark;
			snwp->snw_dispatched = nwp->nw_dispatched;
			snwp->snw_hybrid_dispatched =
			    nwp->nw_hybrid_dispatched;
			snwp->snw_qdrops = nwp->nw_qdrops;
			snwp->snw_queued = nwp->nw_queued;
			snwp->snw_handled = nwp->nw_handled;
			counter++;
		}
		NWS_UNLOCK(nwsp);
	}
	KASSERT(counter <= MAXCPU * NETISR_MAXPROT,
	    ("sysctl_netisr_work: counter too big (%d)", counter));
	NETISR_RUNLOCK(&tracker);
	error = SYSCTL_OUT(req, snw_array, sizeof(*snw_array) * counter);
	free(snw_array, M_TEMP);
	return (error);
}
static int sysctl_netisr_work ( SYSCTL_HANDLER_ARGS ) { struct rm_priotracker tracker ; struct sysctl_netisr_work * snwp , * snw_array ; struct netisr_workstream * nwsp ; struct netisr_proto * npp ; struct netisr_work * nwp ; u_int counter , cpuid , proto ; int error ; if ( req -> newptr != NULL ) return ( EINVAL ) ; snw_array = malloc ( sizeof ( * snw_array ) * MAXCPU * NETISR_MAXPROT , M_TEMP , M_ZERO | M_WAITOK ) ; counter = 0 ; NETISR_RLOCK ( & tracker ) ; CPU_FOREACH ( cpuid ) { nwsp = DPCPU_ID_PTR ( cpuid , nws ) ; if ( nwsp -> nws_intr_event == NULL ) continue ; NWS_LOCK ( nwsp ) ; for ( proto = 0 ; proto < NETISR_MAXPROT ; proto ++ ) { npp = & netisr_proto [ proto ] ; if ( npp -> np_name == NULL ) continue ; nwp = & nwsp -> nws_work [ proto ] ; snwp = & snw_array [ counter ] ; snwp -> snw_version = sizeof ( * snwp ) ; snwp -> snw_wsid = cpuid ; snwp -> snw_proto = proto ; snwp -> snw_len = nwp -> nw_len ; snwp -> snw_watermark = nwp -> nw_watermark ; snwp -> snw_dispatched = nwp -> nw_dispatched ; snwp -> snw_hybrid_dispatched = nwp -> nw_hybrid_dispatched ; snwp -> snw_qdrops = nwp -> nw_qdrops ; snwp -> snw_queued = nwp -> nw_queued ; snwp -> snw_handled = nwp -> nw_handled ; counter ++ ; } NWS_UNLOCK ( nwsp ) ; } KASSERT ( counter <= MAXCPU * NETISR_MAXPROT , ( " " , counter ) ) ; NETISR_RUNLOCK ( & tracker ) ; error = SYSCTL_OUT ( req , snw_array , sizeof ( * snw_array ) * counter ) ; free ( snw_array , M_TEMP ) ; return ( error ) ; }
Sysctl monitoring for netisr: query per-protocol data across all
 workstreams.
Sysctl monitoring for netisr : query per - protocol data across all workstreams .
/* See comment above. */