Beispiel #1
0
static void
poll_comm_init(int cpuid)
{
	struct poll_comm *comm;
	char cpuid_str[16];

	comm = kmalloc_cachealign(sizeof(*comm), M_DEVBUF, M_WAITOK | M_ZERO);

	if (ifpoll_stfrac < 1)
		ifpoll_stfrac = IFPOLL_STFRAC_DEFAULT;
	if (ifpoll_txfrac < 1)
		ifpoll_txfrac = IFPOLL_TXFRAC_DEFAULT;

	comm->poll_cpuid = cpuid;
	comm->pollhz = poll_comm_pollhz_div(comm, ifpoll_pollhz);
	comm->poll_stfrac = ifpoll_stfrac - 1;
	comm->poll_txfrac = ifpoll_txfrac - 1;

	ksnprintf(cpuid_str, sizeof(cpuid_str), "%d", cpuid);

	sysctl_ctx_init(&comm->sysctl_ctx);
	comm->sysctl_tree = SYSCTL_ADD_NODE(&comm->sysctl_ctx,
			    SYSCTL_STATIC_CHILDREN(_net_ifpoll),
			    OID_AUTO, cpuid_str, CTLFLAG_RD, 0, "");

	SYSCTL_ADD_PROC(&comm->sysctl_ctx, SYSCTL_CHILDREN(comm->sysctl_tree),
			OID_AUTO, "pollhz", CTLTYPE_INT | CTLFLAG_RW,
			comm, 0, sysctl_pollhz,
			"I", "Device polling frequency");

	if (cpuid == 0) {
		SYSCTL_ADD_PROC(&comm->sysctl_ctx,
				SYSCTL_CHILDREN(comm->sysctl_tree),
				OID_AUTO, "status_frac",
				CTLTYPE_INT | CTLFLAG_RW,
				comm, 0, sysctl_stfrac,
				"I", "# of cycles before status is polled");
	}
	SYSCTL_ADD_PROC(&comm->sysctl_ctx, SYSCTL_CHILDREN(comm->sysctl_tree),
			OID_AUTO, "tx_frac", CTLTYPE_INT | CTLFLAG_RW,
			comm, 0, sysctl_txfrac,
			"I", "# of cycles before TX is polled");

	poll_common[cpuid] = comm;
}
Beispiel #2
0
void
udp_init(void)
{
	struct inpcbportinfo *portinfo;
	int cpu;

	portinfo = kmalloc_cachealign(sizeof(*portinfo) * ncpus2, M_PCB,
	    M_WAITOK);

	for (cpu = 0; cpu < ncpus2; cpu++) {
		struct inpcbinfo *uicb = &udbinfo[cpu];

		/*
		 * NOTE:
		 * UDP pcb list, wildcard hash table and localgroup hash
		 * table are shared.
		 */
		in_pcbinfo_init(uicb, cpu, TRUE);
		uicb->hashbase = hashinit(UDBHASHSIZE, M_PCB, &uicb->hashmask);

		in_pcbportinfo_init(&portinfo[cpu], UDBHASHSIZE, TRUE, cpu);
		uicb->portinfo = portinfo;
		uicb->portinfo_mask = ncpus2_mask;

		uicb->wildcardhashbase = hashinit(UDBHASHSIZE, M_PCB,
		    &uicb->wildcardhashmask);
		uicb->localgrphashbase = hashinit(UDBHASHSIZE, M_PCB,
		    &uicb->localgrphashmask);

		uicb->ipi_size = sizeof(struct inpcb);
	}

	/*
	 * Initialize UDP statistics counters for each CPU.
	 */
	for (cpu = 0; cpu < ncpus; ++cpu)
		bzero(&udpstat_percpu[cpu], sizeof(struct udpstat));
}
Beispiel #3
0
static struct iopoll_ctx *
iopoll_ctx_create(int cpuid, int poll_type)
{
	struct poll_comm *comm;
	struct iopoll_ctx *io_ctx;
	const char *poll_type_str;
	netisr_fn_t handler, more_handler;

	KKASSERT(poll_type == IFPOLL_RX || poll_type == IFPOLL_TX);

	/*
	 * Make sure that tunables are in sane state
	 */
	if (iopoll_burst_max < MIN_IOPOLL_BURST_MAX)
		iopoll_burst_max = MIN_IOPOLL_BURST_MAX;
	else if (iopoll_burst_max > MAX_IOPOLL_BURST_MAX)
		iopoll_burst_max = MAX_IOPOLL_BURST_MAX;

	if (iopoll_each_burst > iopoll_burst_max)
		iopoll_each_burst = iopoll_burst_max;

	comm = poll_common[cpuid];

	/*
	 * Create the per-cpu polling context
	 */
	io_ctx = kmalloc_cachealign(sizeof(*io_ctx), M_DEVBUF,
	    M_WAITOK | M_ZERO);

	io_ctx->poll_each_burst = iopoll_each_burst;
	io_ctx->poll_burst_max = iopoll_burst_max;
	io_ctx->user_frac = iopoll_user_frac;
	if (poll_type == IFPOLL_RX)
		io_ctx->pollhz = comm->pollhz;
	else
		io_ctx->pollhz = comm->pollhz / (comm->poll_txfrac + 1);
	io_ctx->poll_cpuid = cpuid;
	iopoll_reset_state(io_ctx);

	if (poll_type == IFPOLL_RX) {
		handler = rxpoll_handler;
		more_handler = rxpollmore_handler;
	} else {
		handler = txpoll_handler;
		more_handler = txpollmore_handler;
	}

	netmsg_init(&io_ctx->poll_netmsg, NULL, &netisr_adone_rport,
	    0, handler);
	io_ctx->poll_netmsg.lmsg.u.ms_resultp = io_ctx;

	netmsg_init(&io_ctx->poll_more_netmsg, NULL, &netisr_adone_rport,
	    0, more_handler);
	io_ctx->poll_more_netmsg.lmsg.u.ms_resultp = io_ctx;

	/*
	 * Initialize per-cpu sysctl nodes
	 */
	if (poll_type == IFPOLL_RX)
		poll_type_str = "rx";
	else
		poll_type_str = "tx";

	sysctl_ctx_init(&io_ctx->poll_sysctl_ctx);
	io_ctx->poll_sysctl_tree = SYSCTL_ADD_NODE(&io_ctx->poll_sysctl_ctx,
				   SYSCTL_CHILDREN(comm->sysctl_tree),
				   OID_AUTO, poll_type_str, CTLFLAG_RD, 0, "");
	iopoll_add_sysctl(&io_ctx->poll_sysctl_ctx,
	    SYSCTL_CHILDREN(io_ctx->poll_sysctl_tree), io_ctx, poll_type);

	return io_ctx;
}