- /* If scheduling is stopped, tickle NAPI bits */
- spin_lock_irqsave(&netpoll_poll_lock, flags);
- if (np->dev->poll &&
- test_bit(__LINK_STATE_RX_SCHED, &np->dev->state)) {
- np->dev->netpoll_rx |= NETPOLL_RX_DROP;
+ if (uh->check == 0 || skb->ip_summed == CHECKSUM_UNNECESSARY)
+ return 0;
+
+ psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
+
+ if (skb->ip_summed == CHECKSUM_HW &&
+ !(u16)csum_fold(csum_add(psum, skb->csum)))
+ return 0;
+
+ skb->csum = psum;
+
+ return __skb_checksum_complete(skb);
+}
+
+/*
+ * Check whether delayed processing was scheduled for our NIC. If so,
+ * we attempt to grab the poll lock and use ->poll() to pump the card.
+ * If this fails, either we've recursed in ->poll() or it's already
+ * running on another CPU.
+ *
+ * Note: we don't mask interrupts with this lock because we're using
+ * trylock here and interrupts are already disabled in the softirq
+ * case. Further, we test the poll_owner to avoid recursion on UP
+ * systems where the lock doesn't exist.
+ *
+ * In cases where there is bi-directional communications, reading only
+ * one message at a time can lead to packets being dropped by the
+ * network adapter, forcing superfluous retries and possibly timeouts.
+ * Thus, we set our budget to greater than 1.
+ */
+static void poll_napi(struct netpoll *np)
+{
+ struct netpoll_info *npinfo = np->dev->npinfo;
+ int budget = 16;
+
+ if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) &&
+ npinfo->poll_owner != smp_processor_id() &&
+ spin_trylock(&npinfo->poll_lock)) {
+ npinfo->rx_flags |= NETPOLL_RX_DROP;