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

Function test_setup

dpdk/app/test/test_link_bonding.c:214–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212
213
214static int
215test_setup(void)
216{
217 int i, nb_mbuf_per_pool;
218 struct rte_ether_addr *mac_addr = (struct rte_ether_addr *)member_mac;
219
220 /* Allocate ethernet packet header with space for VLAN header */
221 if (test_params->pkt_eth_hdr == NULL) {
222 test_params->pkt_eth_hdr = malloc(sizeof(struct rte_ether_hdr) +
223 sizeof(struct rte_vlan_hdr));
224
225 TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
226 "Ethernet header struct allocation failed!");
227 }
228
229 nb_mbuf_per_pool = RX_DESC_MAX + DEF_PKT_BURST +
230 TX_DESC_MAX + MAX_PKT_BURST;
231 if (test_params->mbuf_pool == NULL) {
232 test_params->mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL",
233 nb_mbuf_per_pool, MBUF_CACHE_SIZE, 0,
234 RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
235 TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
236 "rte_mempool_create failed");
237 }
238
239 /* Create / Initialize virtual eth devs */
240 if (!members_initialized) {
241 for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
242 char pmd_name[RTE_ETH_NAME_MAX_LEN];
243
244 mac_addr->addr_bytes[RTE_ETHER_ADDR_LEN-1] = i;
245
246 snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
247
248 test_params->member_port_ids[i] = virtual_ethdev_create(pmd_name,
249 mac_addr, rte_socket_id(), 1);
250 TEST_ASSERT(test_params->member_port_ids[i] >= 0,
251 "Failed to create virtual virtual ethdev %s", pmd_name);
252
253 TEST_ASSERT_SUCCESS(configure_ethdev(
254 test_params->member_port_ids[i], 1, 0),
255 "Failed to configure virtual ethdev %s", pmd_name);
256 }
257 members_initialized = 1;
258 }
259
260 return 0;
261}
262
263static int
264test_create_bonding_device(void)

Callers

nothing calls this directly

Calls 6

mallocFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_socket_idFunction · 0.85
snprintfFunction · 0.85
virtual_ethdev_createFunction · 0.85
configure_ethdevFunction · 0.70

Tested by

no test coverage detected