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

Function bond_port_init

dpdk/examples/bond/main.c:207–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207static void
208bond_port_init(struct rte_mempool *mbuf_pool)
209{
210 int retval;
211 uint8_t i;
212 uint16_t nb_rxd = RTE_RX_DESC_DEFAULT;
213 uint16_t nb_txd = RTE_TX_DESC_DEFAULT;
214 struct rte_eth_dev_info dev_info;
215 struct rte_eth_rxconf rxq_conf;
216 struct rte_eth_txconf txq_conf;
217 struct rte_eth_conf local_port_conf = port_conf;
218 uint16_t wait_counter = 20;
219
220 retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB,
221 0 /*SOCKET_ID_ANY*/);
222 if (retval < 0)
223 rte_exit(EXIT_FAILURE,
224 "Failed to create bond port\n");
225
226 BOND_PORT = retval;
227
228 retval = rte_eth_dev_info_get(BOND_PORT, &dev_info);
229 if (retval != 0)
230 rte_exit(EXIT_FAILURE,
231 "Error during getting device (port %u) info: %s\n",
232 BOND_PORT, strerror(-retval));
233
234 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
235 local_port_conf.txmode.offloads |=
236 RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
237 retval = rte_eth_dev_configure(BOND_PORT, 1, 1, &local_port_conf);
238 if (retval != 0)
239 rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
240 BOND_PORT, retval);
241
242 retval = rte_eth_dev_adjust_nb_rx_tx_desc(BOND_PORT, &nb_rxd, &nb_txd);
243 if (retval != 0)
244 rte_exit(EXIT_FAILURE, "port %u: rte_eth_dev_adjust_nb_rx_tx_desc "
245 "failed (res=%d)\n", BOND_PORT, retval);
246
247 for (i = 0; i < members_count; i++) {
248 if (rte_eth_bond_member_add(BOND_PORT, members[i]) == -1)
249 rte_exit(-1, "Oooops! adding member (%u) to bond (%u) failed!\n",
250 members[i], BOND_PORT);
251
252 }
253
254 /* RX setup */
255 rxq_conf = dev_info.default_rxconf;
256 rxq_conf.offloads = local_port_conf.rxmode.offloads;
257 retval = rte_eth_rx_queue_setup(BOND_PORT, 0, nb_rxd,
258 rte_eth_dev_socket_id(BOND_PORT),
259 &rxq_conf, mbuf_pool);
260 if (retval < 0)
261 rte_exit(retval, " port %u: RX queue 0 setup failed (res=%d)",
262 BOND_PORT, retval);
263
264 /* TX setup */

Callers 1

mainFunction · 0.85

Calls 15

rte_eth_bond_createFunction · 0.85
rte_exitFunction · 0.85
rte_eth_dev_info_getFunction · 0.85
rte_eth_dev_configureFunction · 0.85
rte_eth_bond_member_addFunction · 0.85
rte_eth_rx_queue_setupFunction · 0.85
rte_eth_dev_socket_idFunction · 0.85
rte_eth_tx_queue_setupFunction · 0.85
rte_eth_dev_startFunction · 0.85

Tested by

no test coverage detected