#include <vnet/ethernet/ethernet.h>
#include <dpdk/device/dpdk.h>
-#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
#include <vlibmemory/api.h>
#include <vlibmemory/vl_memory_msg_enum.h> /* enumerate all vlib messages */
#include <dpdk/device/dpdk_priv.h>
-dpdk_main_t dpdk_main;
-
/***
*
* HQoS default configuration values
dpdk_hqos_validate_mask (u64 mask, u32 n)
{
int count = __builtin_popcountll (mask);
- int pos_lead = sizeof (u64) * 8 - __builtin_clzll (mask);
- int pos_trail = __builtin_ctzll (mask);
+ int pos_lead = sizeof (u64) * 8 - count_leading_zeros (mask);
+ int pos_trail = count_trailing_zeros (mask);
int count_expected = __builtin_popcount (n - 1);
/* Handle the exceptions */
u32 swq_flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
snprintf (name, sizeof (name), "SWQ-worker%u-to-device%u", i,
- xd->device_index);
+ xd->port_id);
xd->hqos_ht->swq[i] =
rte_ring_create (name, hqos->swq_size, xd->cpu_socket, swq_flags);
if (xd->hqos_ht->swq[i] == NULL)
return clib_error_return (0,
"SWQ-worker%u-to-device%u: rte_ring_create err",
- i, xd->device_index);
+ i, xd->port_id);
}
/*
*/
/* HQoS port */
- snprintf (name, sizeof (name), "HQoS%u", xd->device_index);
+ snprintf (name, sizeof (name), "HQoS%u", xd->port_id);
hqos->port.name = strdup (name);
if (hqos->port.name == NULL)
- return clib_error_return (0, "HQoS%u: strdup err", xd->device_index);
+ return clib_error_return (0, "HQoS%u: strdup err", xd->port_id);
- hqos->port.socket = rte_eth_dev_socket_id (xd->device_index);
+ hqos->port.socket = rte_eth_dev_socket_id (xd->port_id);
if (hqos->port.socket == SOCKET_ID_ANY)
hqos->port.socket = 0;
xd->hqos_ht->hqos = rte_sched_port_config (&hqos->port);
if (xd->hqos_ht->hqos == NULL)
return clib_error_return (0, "HQoS%u: rte_sched_port_config err",
- xd->device_index);
+ xd->port_id);
/* HQoS subport */
for (subport_id = 0; subport_id < hqos->port.n_subports_per_port;
if (rv)
return clib_error_return (0,
"HQoS%u subport %u: rte_sched_subport_config err (%d)",
- xd->device_index, subport_id, rv);
+ xd->port_id, subport_id, rv);
/* HQoS pipe */
for (pipe_id = 0; pipe_id < hqos->port.n_pipes_per_subport; pipe_id++)
if (rv)
return clib_error_return (0,
"HQoS%u subport %u pipe %u: rte_sched_pipe_config err (%d)",
- xd->device_index, subport_id, pipe_id,
- rv);
+ xd->port_id, subport_id, pipe_id, rv);
}
}
xd->hqos_wt[tid].hqos_field0_slabpos = hqos->pktfield0_slabpos;
xd->hqos_wt[tid].hqos_field0_slabmask = hqos->pktfield0_slabmask;
xd->hqos_wt[tid].hqos_field0_slabshr =
- __builtin_ctzll (hqos->pktfield0_slabmask);
+ count_trailing_zeros (hqos->pktfield0_slabmask);
xd->hqos_wt[tid].hqos_field1_slabpos = hqos->pktfield1_slabpos;
xd->hqos_wt[tid].hqos_field1_slabmask = hqos->pktfield1_slabmask;
xd->hqos_wt[tid].hqos_field1_slabshr =
- __builtin_ctzll (hqos->pktfield1_slabmask);
+ count_trailing_zeros (hqos->pktfield1_slabmask);
xd->hqos_wt[tid].hqos_field2_slabpos = hqos->pktfield2_slabpos;
xd->hqos_wt[tid].hqos_field2_slabmask = hqos->pktfield2_slabmask;
xd->hqos_wt[tid].hqos_field2_slabshr =
- __builtin_ctzll (hqos->pktfield2_slabmask);
+ count_trailing_zeros (hqos->pktfield2_slabmask);
memcpy (xd->hqos_wt[tid].hqos_tc_table, hqos->tc_table,
sizeof (hqos->tc_table));
}
dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm)
{
dpdk_main_t *dm = &dpdk_main;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
u32 dev_pos;
dev_pos = 0;
{
vlib_worker_thread_barrier_check ();
- u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]);
+ u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]);
if (dev_pos >= n_devs)
dev_pos = 0;
dpdk_device_and_queue_t *dq =
- vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos);
+ vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos);
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
- u32 device_index = xd->device_index;
+ u32 device_index = xd->port_id;
u16 queue_id = dq->queue_id;
struct rte_mbuf **pkts_enq = hqos->pkts_enq;
pkts_enq_len += rte_ring_sc_dequeue_burst (swq,
(void **)
&pkts_enq[pkts_enq_len],
- hqos->hqos_burst_enq);
+ hqos->hqos_burst_enq, 0);
/* Get next SWQ for this device */
swq_pos++;
dpdk_hqos_thread_internal (vlib_main_t * vm)
{
dpdk_main_t *dm = &dpdk_main;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
u32 dev_pos;
dev_pos = 0;
{
vlib_worker_thread_barrier_check ();
- u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]);
+ u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]);
if (PREDICT_FALSE (n_devs == 0))
{
dev_pos = 0;
dev_pos = 0;
dpdk_device_and_queue_t *dq =
- vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos);
+ vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos);
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
- u32 device_index = xd->device_index;
+ u32 device_index = xd->port_id;
u16 queue_id = dq->queue_id;
struct rte_mbuf **pkts_enq = hqos->pkts_enq;
pkts_enq_len += rte_ring_sc_dequeue_burst (swq,
(void **)
&pkts_enq[pkts_enq_len],
- hqos->hqos_burst_enq);
+ hqos->hqos_burst_enq, 0);
/* Get next SWQ for this device */
swq_pos++;
vm = vlib_get_main ();
- ASSERT (vm->cpu_index == os_get_cpu_number ());
+ ASSERT (vm->thread_index == vlib_get_thread_index ());
clib_time_init (&vm->clib_time);
clib_mem_set_heap (w->thread_mheap);
while (tm->worker_thread_release == 0)
vlib_worker_thread_barrier_check ();
- if (vec_len (dm->devices_by_hqos_cpu[vm->cpu_index]) == 0)
+ if (vec_len (dm->devices_by_hqos_cpu[vm->thread_index]) == 0)
return
clib_error
("current I/O TX thread does not have any devices assigned to it");