19 #include <sys/mount.h> 42 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 68 .pktfield0_slabpos = 0,
69 .pktfield0_slabmask = 0,
76 .pktfield1_slabpos = 40,
77 .pktfield1_slabmask = 0x0000000FFF000000LLU,
84 .pktfield2_slabpos = 8,
85 .pktfield2_slabmask = 0x00000000000000FCLLU,
87 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
88 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
89 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
90 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
99 .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT,
100 .n_subports_per_port = 1,
101 .n_pipes_per_subport = 4096,
102 .qsize = {64, 64, 64, 64},
103 .pipe_profiles =
NULL,
104 .n_pipe_profiles = 1,
109 [0][0] = {.min_th = 48,.max_th = 64,.maxp_inv =
111 [0][1] = {.min_th = 40,.max_th = 64,.maxp_inv =
113 [0][2] = {.min_th = 32,.max_th = 64,.maxp_inv =
117 [1][0] = {.min_th = 48,.max_th = 64,.maxp_inv =
119 [1][1] = {.min_th = 40,.max_th = 64,.maxp_inv =
121 [1][2] = {.min_th = 32,.max_th = 64,.maxp_inv =
125 [2][0] = {.min_th = 48,.max_th = 64,.maxp_inv =
127 [2][1] = {.min_th = 40,.max_th = 64,.maxp_inv =
129 [2][2] = {.min_th = 32,.max_th = 64,.maxp_inv =
133 [3][0] = {.min_th = 48,.max_th = 64,.maxp_inv =
135 [3][1] = {.min_th = 40,.max_th = 64,.maxp_inv =
137 [3][2] = {.min_th = 32,.max_th = 64,.maxp_inv =
145 .tb_rate = 1250000000,
147 .tc_rate = {1250000000, 1250000000, 1250000000, 1250000000},
154 .tc_rate = {305175, 305175, 305175, 305175},
156 #ifdef RTE_SCHED_SUBPORT_TC_OV 159 .wrr_weights = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
171 int count = __builtin_popcountll (mask);
172 int pos_lead =
sizeof (
u64) * 8 - __builtin_clzll (mask);
173 int pos_trail = __builtin_ctzll (mask);
174 int count_expected = __builtin_popcount (n - 1);
180 if ((mask == 0) && (n == 1))
183 if (((mask == 0) && (n != 1)) || ((mask != 0) && (n == 1)))
187 if ((pos_lead - pos_trail) != count)
191 if (count != count_expected)
199 hqos,
u32 pipe_profile_id)
208 struct rte_sched_subport_params *subport_params;
209 struct rte_sched_pipe_params *pipe_params;
213 memcpy (hqos, &hqos_params_default,
sizeof (hqos_params_default));
219 memcpy (&pipe_params[i],
222 hqos->
port.pipe_profiles = hqos->
pipe;
228 memcpy (&subport_params[i],
235 hqos->
port.n_subports_per_port * hqos->
port.n_pipes_per_subport);
256 int worker_thread_first = 0;
257 int worker_thread_count = 0;
263 if (tr && tr->
count > 0)
266 worker_thread_count = tr->
count;
281 for (i = 0; i < worker_thread_count + 1; i++)
283 u32 swq_flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
285 snprintf (name,
sizeof (name),
"SWQ-worker%u-to-device%u", i,
291 "SWQ-worker%u-to-device%u: rte_ring_create err",
300 snprintf (name,
sizeof (name),
"HQoS%u", xd->
device_index);
301 hqos->
port.name = strdup (name);
306 if (hqos->
port.socket == SOCKET_ID_ANY)
307 hqos->
port.socket = 0;
315 for (subport_id = 0; subport_id < hqos->
port.n_subports_per_port;
321 rte_sched_subport_config (xd->
hqos_ht->
hqos, subport_id,
325 "HQoS%u subport %u: rte_sched_subport_config err (%d)",
329 for (pipe_id = 0; pipe_id < hqos->
port.n_pipes_per_subport; pipe_id++)
331 u32 pos = subport_id * hqos->
port.n_pipes_per_subport + pipe_id;
335 rte_sched_pipe_config (xd->
hqos_ht->
hqos, subport_id, pipe_id,
339 "HQoS%u subport %u pipe %u: rte_sched_pipe_config err (%d)",
355 for (i = 0; i < worker_thread_count + 1; i++)
359 tid = worker_thread_first + (i - 1);
407 if (dev_pos >= n_devs)
418 struct rte_mbuf **pkts_enq = hqos->
pkts_enq;
424 for (
i = 0;
i < n_swq;
i++)
427 struct rte_ring *swq = hqos->
swq[swq_pos];
430 pkts_enq_len += rte_ring_sc_dequeue_burst (swq,
432 &pkts_enq[pkts_enq_len],
433 #
if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
441 if (swq_pos >= n_swq)
448 u32 n_pkts = rte_eth_tx_burst (device_index,
451 (uint16_t) pkts_enq_len);
453 for (; n_pkts < pkts_enq_len; n_pkts++)
454 rte_pktmbuf_free (pkts_enq[n_pkts]);
466 rte_sched_port_enqueue (hqos->
hqos, pkts_enq, pkts_enq_len);
498 if (dev_pos >= n_devs)
509 struct rte_mbuf **pkts_enq = hqos->
pkts_enq;
510 struct rte_mbuf **pkts_deq = hqos->
pkts_deq;
519 for (
i = 0;
i < n_swq;
i++)
522 struct rte_ring *swq = hqos->
swq[swq_pos];
525 pkts_enq_len += rte_ring_sc_dequeue_burst (swq,
527 &pkts_enq[pkts_enq_len],
528 #
if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
536 if (swq_pos >= n_swq)
543 rte_sched_port_enqueue (hqos->
hqos, pkts_enq, pkts_enq_len);
555 rte_sched_port_enqueue (hqos->
hqos, pkts_enq, pkts_enq_len);
568 u32 pkts_deq_len, n_pkts;
570 pkts_deq_len = rte_sched_port_dequeue (hqos->
hqos,
574 for (n_pkts = 0; n_pkts < pkts_deq_len;)
575 n_pkts += rte_eth_tx_burst (device_index,
578 (uint16_t) (pkts_deq_len - n_pkts));
607 (
"current I/O TX thread does not have any devices assigned to it");
626 .name =
"hqos-threads",
627 .short_name =
"hqos-threads",
635 #define BITFIELD(byte_array, slab_pos, slab_mask, slab_shr) \ 637 u64 slab = *((u64 *) &byte_array[slab_pos]); \ 638 u64 val = (rte_be_to_cpu_64(slab) & slab_mask) >> slab_shr; \ 642 #define RTE_SCHED_PORT_HIERARCHY(subport, pipe, traffic_class, queue, color) \ 643 ((((u64) (queue)) & 0x3) | \ 644 ((((u64) (traffic_class)) & 0x3) << 2) | \ 645 ((((u64) (color)) & 0x3) << 4) | \ 646 ((((u64) (subport)) & 0xFFFF) << 16) | \ 647 ((((u64) (pipe)) & 0xFFFFFFFF) << 32)) 651 struct rte_mbuf **pkts,
u32 n_pkts)
655 for (i = 0; i < (n_pkts & (~0x3)); i += 4)
657 struct rte_mbuf *pkt0 = pkts[
i];
658 struct rte_mbuf *pkt1 = pkts[i + 1];
659 struct rte_mbuf *pkt2 = pkts[i + 2];
660 struct rte_mbuf *pkt3 = pkts[i + 3];
662 u8 *pkt0_data = rte_pktmbuf_mtod (pkt0,
u8 *);
663 u8 *pkt1_data = rte_pktmbuf_mtod (pkt1,
u8 *);
664 u8 *pkt2_data = rte_pktmbuf_mtod (pkt2,
u8 *);
665 u8 *pkt3_data = rte_pktmbuf_mtod (pkt3,
u8 *);
736 pkt0->hash.sched.lo = pkt0_sched & 0xFFFFFFFF;
737 pkt0->hash.sched.hi = pkt0_sched >> 32;
738 pkt1->hash.sched.lo = pkt1_sched & 0xFFFFFFFF;
739 pkt1->hash.sched.hi = pkt1_sched >> 32;
740 pkt2->hash.sched.lo = pkt2_sched & 0xFFFFFFFF;
741 pkt2->hash.sched.hi = pkt2_sched >> 32;
742 pkt3->hash.sched.lo = pkt3_sched & 0xFFFFFFFF;
743 pkt3->hash.sched.hi = pkt3_sched >> 32;
746 for (; i < n_pkts; i++)
748 struct rte_mbuf *pkt = pkts[
i];
750 u8 *pkt_data = rte_pktmbuf_mtod (pkt,
u8 *);
770 pkt->hash.sched.lo = pkt_sched & 0xFFFFFFFF;
771 pkt->hash.sched.hi = pkt_sched >> 32;
VLIB_REGISTER_THREAD(hqos_thread_reg, static)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
static struct rte_sched_subport_params hqos_subport_params_default
#define clib_error(format, args...)
dpdk_device_and_queue_t ** devices_by_hqos_cpu
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
struct rte_sched_port_params port
struct rte_mbuf ** pkts_enq
struct rte_sched_port * hqos
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define BITFIELD(byte_array, slab_pos, slab_mask, slab_shr)
static void vlib_worker_thread_barrier_check(void)
struct rte_sched_pipe_params * pipe
#define static_always_inline
struct rte_mbuf ** pkts_deq
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
dpdk_device_hqos_per_worker_thread_t * hqos_wt
static_always_inline void dpdk_hqos_thread_internal_hqos_dbg_bypass(vlib_main_t *vm)
void clib_time_init(clib_time_t *c)
int dpdk_hqos_validate_mask(u64 mask, u32 n)
#define HQOS_FLUSH_COUNT_THRESHOLD
static_always_inline uword vlib_get_thread_index(void)
static void * clib_mem_set_heap(void *heap)
void vlib_worker_thread_init(vlib_worker_thread_t *w)
#define DPDK_HQOS_DBG_BYPASS
void dpdk_hqos_thread_fn(void *arg)
clib_error_t * dpdk_port_setup_hqos(dpdk_device_t *xd, dpdk_device_config_hqos_t *hqos)
Bitmaps built as vectors of machine words.
dpdk_device_hqos_per_hqos_thread_t * hqos_ht
static_always_inline void dpdk_hqos_thread_internal(vlib_main_t *vm)
uword * thread_registrations_by_name
static vlib_main_t * vlib_get_main(void)
void dpdk_hqos_metadata_set(dpdk_device_hqos_per_worker_thread_t *hqos, struct rte_mbuf **pkts, u32 n_pkts)
void dpdk_device_config_hqos_default(dpdk_device_config_hqos_t *hqos)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void dpdk_hqos_thread(vlib_worker_thread_t *w)
#define hash_get_mem(h, key)
static vlib_thread_main_t * vlib_get_thread_main()
struct rte_sched_subport_params * subport
#define RTE_SCHED_PORT_HIERARCHY(subport, pipe, traffic_class, queue, color)
#define CLIB_CACHE_LINE_BYTES
void dpdk_device_config_hqos_pipe_profile_default(dpdk_device_config_hqos_t *hqos, u32 pipe_profile_id)
volatile u32 worker_thread_release
static struct rte_sched_pipe_params hqos_pipe_params_default
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".