FreeBSD/sys/net/netisr.c
/*
 * Initialize the netisr subsystem.  We rely on BSS and static initialization
 * of most fields in global data structures.
 *
 * Start a worker thread for the boot CPU so that we can support network
 * traffic immediately in case the network stack is used before additional
 * CPUs are started (for example, diskless boot).
 */
Initialize the netisr subsystem.  We rely on BSS and static initialization
of most fields in global data structures.

Start a worker thread for the boot CPU so that we can support network
traffic immediately in case the network stack is used before additional
CPUs are started (for example, diskless boot).
Initialize the netisr subsystem . We rely on BSS and static initialization of most fields in global data structures . Start a worker thread for the boot CPU so that we can support network traffic immediately in case the network stack is used before additional CPUs are started ( for example diskless boot ) .
static void
netisr_init(void *arg)
{
#ifdef EARLY_AP_STARTUP
	struct pcpu *pc;
#endif
	KASSERT(curcpu == 0, ("%s: not on CPU 0", __func__));
	NETISR_LOCK_INIT();
	if (netisr_maxthreads == 0 || netisr_maxthreads < -1 )
		netisr_maxthreads = 1;		
	else if (netisr_maxthreads == -1)
		netisr_maxthreads = mp_ncpus;	
	if (netisr_maxthreads > mp_ncpus) {
		printf("netisr_init: forcing maxthreads from %d to %d\n",
		    netisr_maxthreads, mp_ncpus);
		netisr_maxthreads = mp_ncpus;
	}
	if (netisr_defaultqlimit > netisr_maxqlimit) {
		printf("netisr_init: forcing defaultqlimit from %d to %d\n",
		    netisr_defaultqlimit, netisr_maxqlimit);
		netisr_defaultqlimit = netisr_maxqlimit;
	}
#ifdef DEVICE_POLLING
	if (netisr_maxthreads != 1 || netisr_bindthreads != 0) {
		printf("netisr_init: forcing maxthreads to 1 and "
		    "bindthreads to 0 for device polling\n");
		netisr_maxthreads = 1;
		netisr_bindthreads = 0;
	}
#endif
#ifdef EARLY_AP_STARTUP
	STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) {
		if (nws_count >= netisr_maxthreads)
			break;
		netisr_start_swi(pc->pc_cpuid, pc);
	}
#else
	netisr_start_swi(curcpu, pcpu_find(curcpu));
#endif
}
static void netisr_init ( void * arg ) { #ifdef EARLY_AP_STARTUP struct pcpu * pc ; #endif KASSERT ( curcpu == 0 , ( " " , __func__ ) ) ; NETISR_LOCK_INIT ( ) ; if ( netisr_maxthreads == 0 || netisr_maxthreads < -1 ) netisr_maxthreads = 1 ; else if ( netisr_maxthreads == -1 ) netisr_maxthreads = mp_ncpus ; if ( netisr_maxthreads > mp_ncpus ) { printf ( " \n " , netisr_maxthreads , mp_ncpus ) ; netisr_maxthreads = mp_ncpus ; } if ( netisr_defaultqlimit > netisr_maxqlimit ) { printf ( " \n " , netisr_defaultqlimit , netisr_maxqlimit ) ; netisr_defaultqlimit = netisr_maxqlimit ; } #ifdef DEVICE_POLLING if ( netisr_maxthreads != 1 || netisr_bindthreads != 0 ) { printf ( " " " \n " ) ; netisr_maxthreads = 1 ; netisr_bindthreads = 0 ; } #endif #ifdef EARLY_AP_STARTUP STAILQ_FOREACH ( pc , & cpuhead , pc_allcpu ) { if ( nws_count >= netisr_maxthreads ) break ; netisr_start_swi ( pc -> pc_cpuid , pc ) ; } #else netisr_start_swi ( curcpu , pcpu_find ( curcpu ) ) ; #endif }
Initialize the netisr subsystem.
Initialize the netisr subsystem .
/* default behavior */ /* use max cpus */ /*
	 * The device polling code is not yet aware of how to deal with
	 * multiple netisr threads, so for the time being compiling in device
	 * polling disables parallel netisr workers.
	 */