ifpoll: Setup if_start cpuid for NPOLLING properly
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 18 Sep 2012 01:08:57 +0000 (09:08 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 18 Sep 2012 01:09:25 +0000 (09:09 +0800)
sys/dev/netif/emx/if_emx.c
sys/net/if.c
sys/net/if_poll.c
sys/net/if_var.h

index 2a7b0dd..c9c95cd 100644 (file)
@@ -3681,8 +3681,11 @@ emx_npoll(struct ifnet *ifp, struct ifpoll_info *info)
 
                if (ifp->if_flags & IFF_RUNNING)
                        emx_disable_intr(sc);
-       } else if (ifp->if_flags & IFF_RUNNING) {
-               emx_enable_intr(sc);
+               ifp->if_npoll_cpuid = 0; /* XXX */
+       } else {
+               if (ifp->if_flags & IFF_RUNNING)
+                       emx_enable_intr(sc);
+               ifp->if_npoll_cpuid = -1;
        }
 }
 
index f02d2fc..cd92df4 100644 (file)
@@ -224,6 +224,19 @@ if_start_cpuid_poll(struct ifnet *ifp)
 }
 #endif
 
+#ifdef IFPOLL_ENABLE
+static int
+if_start_cpuid_npoll(struct ifnet *ifp)
+{
+       int poll_cpuid = ifp->if_npoll_cpuid;
+
+       if (poll_cpuid >= 0)
+               return poll_cpuid;
+       else
+               return ifp->if_cpuid;
+}
+#endif
+
 static void
 if_start_ipifunc(void *arg)
 {
@@ -478,6 +491,12 @@ if_attach(struct ifnet *ifp, lwkt_serialize_t serializer)
        if (ifp->if_poll != NULL)
                ifp->if_start_cpuid = if_start_cpuid_poll;
 #endif
+#ifdef IFPOLL_ENABLE
+       /* Device is not in polling mode by default */
+       ifp->if_npoll_cpuid = -1;
+       if (ifp->if_npoll != NULL)
+               ifp->if_start_cpuid = if_start_cpuid_npoll;
+#endif
 
        ifp->if_start_nmsg = kmalloc(ncpus * sizeof(*ifp->if_start_nmsg),
                                     M_LWKTMSG, M_WAITOK);
index 6828e79..5e9ae7b 100644 (file)
@@ -364,6 +364,7 @@ ifpoll_register(struct ifnet *ifp)
 
        ifp->if_flags |= IFF_NPOLLING;
        ifp->if_npoll(ifp, info);
+       KASSERT(ifp->if_npoll_cpuid >= 0, ("invalid npoll cpuid"));
 
        ifnet_deserialize_all(ifp);
 
@@ -410,6 +411,7 @@ ifpoll_deregister(struct ifnet *ifp)
        if (!error) {
                ifnet_serialize_all(ifp);
                ifp->if_npoll(ifp, NULL);
+               KASSERT(ifp->if_npoll_cpuid < 0, ("invalid npoll cpuid"));
                ifnet_deserialize_all(ifp);
        }
        return error;
index 5913d07..ab912f8 100644 (file)
@@ -262,9 +262,11 @@ struct ifnet {
 #ifdef IFPOLL_ENABLE
        void    (*if_npoll)
                (struct ifnet *, struct ifpoll_info *);
+       int     if_npoll_cpuid;
 #else
        /* Place holders */
        void    (*if_npoll_unused)(void);
+       int     if_npoll_cpuid_unused;
 #endif
        struct  ifaltq if_snd;          /* output queue (includes altq) */
        struct  ifprefixhead if_prefixhead; /* list of prefixes per if */