#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
+#include <vnet/interface/rx_queue_funcs.h>
#include "af_xdp.h"
#define foreach_af_xdp_input_error \
/*
* Note about headroom: for some reasons, there seem to be a discrepency
- * between 0-copy and copy mode:
- * - 0-copy: XDP_PACKET_HEADROOM will be added to the user headroom
- * - copy: nothing is added to the user headroom
- * We privileged 0-copy and set headroom to 0. As XDP_PACKET_HEADROOM ==
- * sizeof(vlib_buffer_t), data will correctly point to vlib_buffer_t->data.
- * In copy mode, we have to add sizeof(vlib_buffer_t) to desc offset during
- * refill.
+ * between 0-copy and copy mode. See
+ * src/plugins/af_xdp/device.c:af_xdp_create_queue()
*/
- STATIC_ASSERT (sizeof (vlib_buffer_t) == XDP_PACKET_HEADROOM, "wrong size");
-#define bi2addr(bi) \
- (((bi) << CLIB_LOG2_CACHE_LINE_BYTES) + (copy ? sizeof(vlib_buffer_t) : 0))
+#define bi2addr(bi) \
+ (((bi) << CLIB_LOG2_CACHE_LINE_BYTES) + (copy ? XDP_PACKET_HEADROOM : 0))
wrap_around:
const u32 mask = rxq->rx.mask;
u32 n = n_rx, *bi = bis, bytes = 0;
-#define addr2bi(addr) \
- (((addr) - (copy ? sizeof(vlib_buffer_t) : 0)) >> CLIB_LOG2_CACHE_LINE_BYTES)
+#define addr2bi(addr) \
+ (((addr) - (copy ? XDP_PACKET_HEADROOM : 0)) >> CLIB_LOG2_CACHE_LINE_BYTES)
while (n >= 1)
{
{
u32 n_rx = 0;
af_xdp_main_t *am = &af_xdp_main;
- vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
- vnet_device_and_queue_t *dq;
-
- foreach_device_and_queue (dq, rt->devices_and_queues)
- {
- af_xdp_device_t *ad;
- ad = vec_elt_at_index (am->devices, dq->dev_instance);
- if ((ad->flags & AF_XDP_DEVICE_F_ADMIN_UP) == 0)
- continue;
- if (PREDICT_TRUE (ad->flags & AF_XDP_DEVICE_F_ZEROCOPY))
- n_rx += af_xdp_device_input_inline (vm, node, frame, ad, dq->queue_id,
- /* copy */ 0);
- else
- n_rx += af_xdp_device_input_inline (vm, node, frame, ad, dq->queue_id,
- /* copy */ 1);
- }
+ vnet_hw_if_rxq_poll_vector_t *p,
+ *pv = vnet_hw_if_get_rxq_poll_vector (vm, node);
+
+ vec_foreach (p, pv)
+ {
+ af_xdp_device_t *ad = vec_elt_at_index (am->devices, p->dev_instance);
+ if ((ad->flags & AF_XDP_DEVICE_F_ADMIN_UP) == 0)
+ continue;
+ if (PREDICT_TRUE (ad->flags & AF_XDP_DEVICE_F_ZEROCOPY))
+ n_rx += af_xdp_device_input_inline (vm, node, frame, ad, p->queue_id,
+ /* copy */ 0);
+ else
+ n_rx += af_xdp_device_input_inline (vm, node, frame, ad, p->queue_id,
+ /* copy */ 1);
+ }
+
return n_rx;
}