Beispiel #1
0
static inline int
linux_generic_rx_handler_common(struct mbuf *m)
{
	int stolen;

	/* If we were called by NM_SEND_UP(), we want to pass the mbuf
	   to network stack. We detect this situation looking at the
	   priority field. */
	if (m->priority == NM_MAGIC_PRIORITY_RX) {
		return NM_RX_HANDLER_PASS;
	}

	/* When we intercept a sk_buff coming from the driver, it happens that
	   skb->data points to the IP header, e.g. the ethernet header has
	   already been pulled. Since we want the netmap rings to contain the
	   full ethernet header, we push it back, so that the RX ring reader
	   can see it. */
	skb_push(m, ETH_HLEN);

	/* Possibly steal the mbuf and notify the pollers for a new RX
	 * packet. */
	stolen = generic_rx_handler(m->dev, m);
	if (stolen) {
		return NM_RX_HANDLER_STOLEN;
	}

	skb_pull(m, ETH_HLEN);

	return NM_RX_HANDLER_PASS;
}
Beispiel #2
0
/*
 * windows_handle_rx is called by the nm-ndis module on an incoming packet
 * from the NIC (miniport driver). After encapsulating into a buffer,
 * we pass it to the generic rx handler in netmap_generic.c to be queued
 * on the NIC rx ring.
 * XXX in the future we could avoid the allocation by passing up the NDIS
 * packet, and setting a callback to generate the notification when the
 * netmap receiver eventually calls rxsync. However the savings from the
 * extra allocation and copy are probably modest at least until we
 * have a relatively slow NIC.
 */
struct NET_BUFFER *
windows_handle_rx(struct net_device *ifp, uint32_t length, const char *data)
{
	struct mbuf *m = win_make_mbuf(ifp, length, data);

	if (m)
		generic_rx_handler(ifp, m);
	return NULL;
}
Beispiel #3
0
static rx_handler_result_t linux_generic_rx_handler(struct mbuf **pm)
{
    /* If we were called by NM_SEND_UP(), we want to pass the mbuf
       to network stack. We detect this situation looking at the
       priority field. */
    if ((*pm)->priority == NM_MAGIC_PRIORITY_RX)
            return RX_HANDLER_PASS;

    /* When we intercept a sk_buff coming from the driver, it happens that
       skb->data points to the IP header, e.g. the ethernet header has
       already been pulled. Since we want the netmap rings to contain the
       full ethernet header, we push it back, so that the RX ring reader
       can see it. */
    skb_push(*pm, 14);

    /* Steal the mbuf and notify the pollers for a new RX packet. */
    generic_rx_handler((*pm)->dev, *pm);

    return RX_HANDLER_CONSUMED;
}
Beispiel #4
0
    /* Steal the mbuf and notify the pollers for a new RX packet. */
    generic_rx_handler((*pm)->dev, *pm);

    return RX_HANDLER_CONSUMED;
}
#else /* ! HAVE_RX_HANDLER_RESULT */
static struct sk_buff *linux_generic_rx_handler(struct mbuf *m)
{
	generic_rx_handler(m->dev, m);
	return NULL;
}