From: Sepherosa Ziehau Date: Sat, 20 Oct 2012 12:12:38 +0000 (+0800) Subject: ifpoll: Make status fraction and TX fraction easier to read X-Git-Tag: v3.4.0rc~990^2~24 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/0c7fdccd449859edbb19b30ec96423a0bd184e4b ifpoll: Make status fraction and TX fraction easier to read --- diff --git a/sys/dev/netif/bnx/if_bnx.c b/sys/dev/netif/bnx/if_bnx.c index 71cb526430..dbd8d74337 100644 --- a/sys/dev/netif/bnx/if_bnx.c +++ b/sys/dev/netif/bnx/if_bnx.c @@ -2102,7 +2102,7 @@ bnx_attach(device_t dev) } #ifdef IFPOLL_ENABLE - sc->bnx_npoll_stfrac = 39; /* 1/40 polling freq */ + sc->bnx_npoll_stfrac = 40 - 1; /* 1/40 polling freq */ sc->bnx_npoll_cpuid = device_get_unit(dev) % ncpus2; #endif @@ -3946,13 +3946,13 @@ bnx_sysctl_npoll_stfrac(SYSCTL_HANDLER_ARGS) lwkt_serialize_enter(ifp->if_serializer); - stfrac = sc->bnx_npoll_stfrac; + stfrac = sc->bnx_npoll_stfrac + 1; error = sysctl_handle_int(oidp, &stfrac, 0, req); if (!error && req->newptr != NULL) { - if (stfrac < 0) { + if (stfrac < 1) { error = EINVAL; } else { - sc->bnx_npoll_stfrac = stfrac; + sc->bnx_npoll_stfrac = stfrac - 1; if (sc->bnx_npoll_stcount > sc->bnx_npoll_stfrac) sc->bnx_npoll_stcount = sc->bnx_npoll_stfrac; } diff --git a/sys/net/if_poll.c b/sys/net/if_poll.c index b0117aa81f..189fe195be 100644 --- a/sys/net/if_poll.c +++ b/sys/net/if_poll.c @@ -113,8 +113,8 @@ #define IFPOLL_FREQ_DEFAULT 4000 -#define IFPOLL_TXFRAC_DEFAULT 0 /* 1/1 of the pollhz */ -#define IFPOLL_STFRAC_DEFAULT 39 /* 1/40 of the pollhz */ +#define IFPOLL_TXFRAC_DEFAULT 1 /* 1/1 of the pollhz */ +#define IFPOLL_STFRAC_DEFAULT 40 /* 1/40 of the pollhz */ #define IFPOLL_RX 0x1 #define IFPOLL_TX 0x2 @@ -1222,15 +1222,15 @@ poll_comm_init(int cpuid) comm = kmalloc_cachealign(sizeof(*comm), M_DEVBUF, M_WAITOK | M_ZERO); - if (ifpoll_stfrac < 0) + if (ifpoll_stfrac < 1) ifpoll_stfrac = IFPOLL_STFRAC_DEFAULT; - if (ifpoll_txfrac < 0) + if (ifpoll_txfrac < 1) ifpoll_txfrac = IFPOLL_TXFRAC_DEFAULT; comm->pollhz = ifpoll_pollhz; comm->poll_cpuid = cpuid; - comm->poll_stfrac = ifpoll_stfrac; - comm->poll_txfrac = ifpoll_txfrac; + comm->poll_stfrac = ifpoll_stfrac - 1; + comm->poll_txfrac = ifpoll_txfrac - 1; ksnprintf(cpuid_str, sizeof(cpuid_str), "%d", cpuid); @@ -1400,16 +1400,16 @@ sysctl_stfrac(SYSCTL_HANDLER_ARGS) KKASSERT(comm->poll_cpuid == 0); - stfrac = comm->poll_stfrac; + stfrac = comm->poll_stfrac + 1; error = sysctl_handle_int(oidp, &stfrac, 0, req); if (error || req->newptr == NULL) return error; - if (stfrac < 0) + if (stfrac < 1) return EINVAL; netmsg_init(&nmsg, NULL, &curthread->td_msgport, 0, sysctl_stfrac_handler); - nmsg.lmsg.u.ms_result = stfrac; + nmsg.lmsg.u.ms_result = stfrac - 1; return lwkt_domsg(netisr_portfn(comm->poll_cpuid), &nmsg.lmsg, 0); } @@ -1438,16 +1438,16 @@ sysctl_txfrac(SYSCTL_HANDLER_ARGS) struct netmsg_base nmsg; int error, txfrac; - txfrac = comm->poll_txfrac; + txfrac = comm->poll_txfrac + 1; error = sysctl_handle_int(oidp, &txfrac, 0, req); if (error || req->newptr == NULL) return error; - if (txfrac < 0) + if (txfrac < 1) return EINVAL; netmsg_init(&nmsg, NULL, &curthread->td_msgport, 0, sysctl_txfrac_handler); - nmsg.lmsg.u.ms_result = txfrac; + nmsg.lmsg.u.ms_result = txfrac - 1; return lwkt_domsg(netisr_portfn(comm->poll_cpuid), &nmsg.lmsg, 0); }