ifpoll: Dispatch netmsgs to netisr, which is MPSAFE now
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 10 Sep 2012 09:45:15 +0000 (17:45 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 10 Sep 2012 09:45:15 +0000 (17:45 +0800)
sys/net/if_poll.c

index dcaa210..6b6ff77 100644 (file)
@@ -275,7 +275,7 @@ static __inline void
 ifpoll_sendmsg_oncpu(netmsg_t msg)
 {
        if (msg->lmsg.ms_flags & MSGF_DONE)
-               ifnet_sendmsg(&msg->lmsg, mycpuid);
+               lwkt_sendmsg(cpu_portfn(mycpuid), &msg->lmsg);
 }
 
 static __inline void
@@ -378,7 +378,7 @@ ifpoll_register(struct ifnet *ifp)
                    0, ifpoll_register_handler);
        nmsg.lmsg.u.ms_resultp = &info;
 
-       error = ifnet_domsg(&nmsg.lmsg, 0);
+       error = lwkt_domsg(cpu_portfn(0), &nmsg.lmsg, 0);
        if (error) {
                if (!ifpoll_deregister(ifp)) {
                        if_printf(ifp, "ifpoll_register: "
@@ -411,7 +411,7 @@ ifpoll_deregister(struct ifnet *ifp)
                    0, ifpoll_deregister_handler);
        nmsg.lmsg.u.ms_resultp = ifp;
 
-       error = ifnet_domsg(&nmsg.lmsg, 0);
+       error = lwkt_domsg(cpu_portfn(0), &nmsg.lmsg, 0);
        if (!error) {
                ifnet_serialize_all(ifp);
                ifp->if_qpoll(ifp, NULL);
@@ -428,7 +428,7 @@ ifpoll_register_handler(netmsg_t nmsg)
        int error;
 
        KKASSERT(cpuid < ifpoll_ncpus);
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(cpuid));
 
        if (cpuid == 0) {
                error = stpoll_register(info->ifpi_ifp, &info->ifpi_status);
@@ -451,7 +451,7 @@ ifpoll_register_handler(netmsg_t nmsg)
 
        nextcpu = cpuid + 1;
        if (nextcpu < ifpoll_ncpus)
-               ifnet_forwardmsg(&nmsg->lmsg, nextcpu);
+               lwkt_forwardmsg(cpu_portfn(nextcpu), &nmsg->lmsg);
        else
                lwkt_replymsg(&nmsg->lmsg, 0);
        return;
@@ -466,7 +466,7 @@ ifpoll_deregister_handler(netmsg_t nmsg)
        int cpuid = mycpuid, nextcpu;
 
        KKASSERT(cpuid < ifpoll_ncpus);
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(cpuid));
 
        /* Ignore errors */
        if (cpuid == 0)
@@ -479,7 +479,7 @@ ifpoll_deregister_handler(netmsg_t nmsg)
 
        nextcpu = cpuid + 1;
        if (nextcpu < ifpoll_ncpus)
-               ifnet_forwardmsg(&nmsg->lmsg, nextcpu);
+               lwkt_forwardmsg(cpu_portfn(nextcpu), &nmsg->lmsg);
        else
                lwkt_replymsg(&nmsg->lmsg, 0);
 }
@@ -518,7 +518,7 @@ stpoll_handler(netmsg_t msg)
        struct thread *td = curthread;
        int i;
 
-       KKASSERT(&td->td_msgport == ifnet_portfn(0));
+       KKASSERT(&td->td_msgport == cpu_portfn(0));
 
        crit_enter_quick(td);
 
@@ -567,7 +567,7 @@ stpoll_register(struct ifnet *ifp, const struct ifpoll_status *st_rec)
        struct stpoll_ctx *st_ctx = &stpoll_context;
        int error;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(0));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(0));
 
        if (st_rec->status_func == NULL)
                return 0;
@@ -610,7 +610,7 @@ stpoll_deregister(struct ifnet *ifp)
        struct stpoll_ctx *st_ctx = &stpoll_context;
        int i, error;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(0));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(0));
 
        for (i = 0; i < st_ctx->poll_handlers; ++i) {
                if (st_ctx->pr[i].ifp == ifp) /* Found it */
@@ -786,7 +786,7 @@ iopoll_handler(netmsg_t msg)
        int i, cycles;
 
        io_ctx = msg->lmsg.u.ms_resultp;
-       KKASSERT(&td->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&td->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        crit_enter_quick(td);
 
@@ -857,7 +857,7 @@ iopollmore_handler(netmsg_t msg)
        uint32_t pending_polls;
 
        io_ctx = msg->lmsg.u.ms_resultp;
-       KKASSERT(&td->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&td->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        crit_enter_quick(td);
 
@@ -973,7 +973,7 @@ sysctl_burstmax_handler(netmsg_t nmsg)
        struct iopoll_ctx *io_ctx;
 
        io_ctx = msg->ctx;
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        io_ctx->poll_burst_max = nmsg->lmsg.u.ms_result;
        if (io_ctx->poll_each_burst > io_ctx->poll_burst_max)
@@ -1008,7 +1008,7 @@ sysctl_burstmax(SYSCTL_HANDLER_ARGS)
        msg.base.lmsg.u.ms_result = burst_max;
        msg.ctx = io_ctx;
 
-       return ifnet_domsg(&msg.base.lmsg, io_ctx->poll_cpuid);
+       return lwkt_domsg(cpu_portfn(io_ctx->poll_cpuid), &msg.base.lmsg, 0);
 }
 
 static void
@@ -1019,7 +1019,7 @@ sysctl_eachburst_handler(netmsg_t nmsg)
        uint32_t each_burst;
 
        io_ctx = msg->ctx;
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        each_burst = nmsg->lmsg.u.ms_result;
        if (each_burst > io_ctx->poll_burst_max)
@@ -1049,7 +1049,7 @@ sysctl_eachburst(SYSCTL_HANDLER_ARGS)
        msg.base.lmsg.u.ms_result = each_burst;
        msg.ctx = io_ctx;
 
-       return ifnet_domsg(&msg.base.lmsg, io_ctx->poll_cpuid);
+       return lwkt_domsg(cpu_portfn(io_ctx->poll_cpuid), &msg.base.lmsg, 0);
 }
 
 static int
@@ -1058,7 +1058,7 @@ iopoll_register(struct ifnet *ifp, struct iopoll_ctx *io_ctx,
 {
        int error;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        if (io_rec->poll_func == NULL)
                return 0;
@@ -1100,7 +1100,7 @@ iopoll_deregister(struct ifnet *ifp, struct iopoll_ctx *io_ctx)
 {
        int i, error;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(io_ctx->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(io_ctx->poll_cpuid));
 
        for (i = 0; i < io_ctx->poll_handlers; ++i) {
                if (io_ctx->pr[i].ifp == ifp) /* Found it */
@@ -1234,7 +1234,7 @@ poll_comm_adjust_pollhz(struct poll_comm *comm)
        uint32_t handlers;
        int pollhz = 1;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(comm->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(comm->poll_cpuid));
 
        /*
         * If there is no polling handler registered, set systimer
@@ -1271,7 +1271,7 @@ sysctl_pollhz(SYSCTL_HANDLER_ARGS)
                    0, sysctl_pollhz_handler);
        nmsg.lmsg.u.ms_result = phz;
 
-       return ifnet_domsg(&nmsg.lmsg, comm->poll_cpuid);
+       return lwkt_domsg(cpu_portfn(comm->poll_cpuid), &nmsg.lmsg, 0);
 }
 
 static void
@@ -1279,7 +1279,7 @@ sysctl_pollhz_handler(netmsg_t nmsg)
 {
        struct poll_comm *comm = poll_common[mycpuid];
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(comm->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(comm->poll_cpuid));
 
        /* Save polling frequency */
        comm->pollhz = nmsg->lmsg.u.ms_result;
@@ -1321,7 +1321,7 @@ sysctl_stfrac(SYSCTL_HANDLER_ARGS)
                    0, sysctl_stfrac_handler);
        nmsg.lmsg.u.ms_result = stfrac;
 
-       return ifnet_domsg(&nmsg.lmsg, comm->poll_cpuid);
+       return lwkt_domsg(cpu_portfn(comm->poll_cpuid), &nmsg.lmsg, 0);
 }
 
 static void
@@ -1330,7 +1330,7 @@ sysctl_stfrac_handler(netmsg_t nmsg)
        struct poll_comm *comm = poll_common[mycpuid];
        int stfrac = nmsg->lmsg.u.ms_result;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(comm->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(comm->poll_cpuid));
 
        crit_enter();
        comm->poll_stfrac = stfrac;
@@ -1359,7 +1359,7 @@ sysctl_txfrac(SYSCTL_HANDLER_ARGS)
                    0, sysctl_txfrac_handler);
        nmsg.lmsg.u.ms_result = txfrac;
 
-       return ifnet_domsg(&nmsg.lmsg, comm->poll_cpuid);
+       return lwkt_domsg(cpu_portfn(comm->poll_cpuid), &nmsg.lmsg, 0);
 }
 
 static void
@@ -1368,7 +1368,7 @@ sysctl_txfrac_handler(netmsg_t nmsg)
        struct poll_comm *comm = poll_common[mycpuid];
        int txfrac = nmsg->lmsg.u.ms_result;
 
-       KKASSERT(&curthread->td_msgport == ifnet_portfn(comm->poll_cpuid));
+       KKASSERT(&curthread->td_msgport == cpu_portfn(comm->poll_cpuid));
 
        crit_enter();
        comm->poll_txfrac = txfrac;