MCPcopy Create free account
hub / github.com/F-Stack/f-stack / load_balancing

Function load_balancing

dpdk/drivers/event/sw/sw_evdev_selftest.c:1983–2068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1981}
1982
1983static int
1984load_balancing(struct test *t)
1985{
1986 const int rx_enq = 0;
1987 int err;
1988 uint32_t i;
1989
1990 if (init(t, 1, 4) < 0 ||
1991 create_ports(t, 4) < 0 ||
1992 create_atomic_qids(t, 1) < 0) {
1993 printf("%d: Error initializing device\n", __LINE__);
1994 return -1;
1995 }
1996
1997 for (i = 0; i < 3; i++) {
1998 /* map port 1 - 3 inclusive */
1999 if (rte_event_port_link(evdev, t->port[i+1], &t->qid[0],
2000 NULL, 1) != 1) {
2001 printf("%d: error mapping qid to port %d\n",
2002 __LINE__, i);
2003 return -1;
2004 }
2005 }
2006
2007 if (rte_event_dev_start(evdev) < 0) {
2008 printf("%d: Error with start call\n", __LINE__);
2009 return -1;
2010 }
2011
2012 /************** FORWARD ****************/
2013 /*
2014 * Create a set of flows that test the load-balancing operation of the
2015 * implementation. Fill CQ 0 and 1 with flows 0 and 1, and test
2016 * with a new flow, which should be sent to the 3rd mapped CQ
2017 */
2018 static uint32_t flows[] = {0, 1, 1, 0, 0, 2, 2, 0, 2};
2019
2020 for (i = 0; i < RTE_DIM(flows); i++) {
2021 struct rte_mbuf *arp = rte_gen_arp(0, t->mbuf_pool);
2022 if (!arp) {
2023 printf("%d: gen of pkt failed\n", __LINE__);
2024 return -1;
2025 }
2026
2027 struct rte_event ev = {
2028 .op = RTE_EVENT_OP_NEW,
2029 .queue_id = t->qid[0],
2030 .flow_id = flows[i],
2031 .mbuf = arp,
2032 };
2033 /* generate pkt and enqueue */
2034 err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
2035 if (err != 1) {
2036 printf("%d: Failed to enqueue\n", __LINE__);
2037 return -1;
2038 }
2039 }
2040

Callers 1

test_sw_eventdevFunction · 0.85

Calls 11

rte_event_port_linkFunction · 0.85
rte_event_dev_startFunction · 0.85
rte_event_enqueue_burstFunction · 0.85
test_event_dev_stats_getFunction · 0.85
initFunction · 0.70
create_portsFunction · 0.70
create_atomic_qidsFunction · 0.70
rte_gen_arpFunction · 0.70
cleanupFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected