static void bond_port_init(struct rte_mempool *mbuf_pool) { int retval; uint8_t i; retval = rte_eth_bond_create("bond0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/); if (retval < 0) rte_exit(EXIT_FAILURE, "Faled to create bond port\n"); BOND_PORT = (uint8_t)retval; retval = rte_eth_dev_configure(BOND_PORT, 1, 1, &port_conf); if (retval != 0) rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n", BOND_PORT, retval); /* RX setup */ retval = rte_eth_rx_queue_setup(BOND_PORT, 0, RTE_RX_DESC_DEFAULT, rte_eth_dev_socket_id(BOND_PORT), NULL, mbuf_pool); if (retval < 0) rte_exit(retval, " port %u: RX queue 0 setup failed (res=%d)", BOND_PORT, retval); /* TX setup */ retval = rte_eth_tx_queue_setup(BOND_PORT, 0, RTE_TX_DESC_DEFAULT, rte_eth_dev_socket_id(BOND_PORT), NULL); if (retval < 0) rte_exit(retval, "port %u: TX queue 0 setup failed (res=%d)", BOND_PORT, retval); for (i = 0; i < slaves_count; i++) { if (rte_eth_bond_slave_add(BOND_PORT, slaves[i]) == -1) rte_exit(-1, "Oooops! adding slave (%u) to bond (%u) failed!\n", slaves[i], BOND_PORT); } retval = rte_eth_dev_start(BOND_PORT); if (retval < 0) rte_exit(retval, "Start port %d failed (res=%d)", BOND_PORT, retval); rte_eth_promiscuous_enable(BOND_PORT); struct ether_addr addr; rte_eth_macaddr_get(BOND_PORT, &addr); printf("Port %u MAC: ", (unsigned)BOND_PORT); PRINT_MAC(addr); printf("\n"); }
static void bond_port_init(struct rte_mempool *mbuf_pool) { int retval; uint8_t i; uint16_t nb_rxd = RTE_RX_DESC_DEFAULT; uint16_t nb_txd = RTE_TX_DESC_DEFAULT; struct rte_eth_dev_info dev_info; struct rte_eth_rxconf rxq_conf; struct rte_eth_txconf txq_conf; struct rte_eth_conf local_port_conf = port_conf; retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/); if (retval < 0) rte_exit(EXIT_FAILURE, "Faled to create bond port\n"); BOND_PORT = retval; rte_eth_dev_info_get(BOND_PORT, &dev_info); if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; retval = rte_eth_dev_configure(BOND_PORT, 1, 1, &local_port_conf); if (retval != 0) rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n", BOND_PORT, retval); retval = rte_eth_dev_adjust_nb_rx_tx_desc(BOND_PORT, &nb_rxd, &nb_txd); if (retval != 0) rte_exit(EXIT_FAILURE, "port %u: rte_eth_dev_adjust_nb_rx_tx_desc " "failed (res=%d)\n", BOND_PORT, retval); /* RX setup */ rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = local_port_conf.rxmode.offloads; retval = rte_eth_rx_queue_setup(BOND_PORT, 0, nb_rxd, rte_eth_dev_socket_id(BOND_PORT), &rxq_conf, mbuf_pool); if (retval < 0) rte_exit(retval, " port %u: RX queue 0 setup failed (res=%d)", BOND_PORT, retval); /* TX setup */ txq_conf = dev_info.default_txconf; txq_conf.offloads = local_port_conf.txmode.offloads; retval = rte_eth_tx_queue_setup(BOND_PORT, 0, nb_txd, rte_eth_dev_socket_id(BOND_PORT), &txq_conf); if (retval < 0) rte_exit(retval, "port %u: TX queue 0 setup failed (res=%d)", BOND_PORT, retval); for (i = 0; i < slaves_count; i++) { if (rte_eth_bond_slave_add(BOND_PORT, slaves[i]) == -1) rte_exit(-1, "Oooops! adding slave (%u) to bond (%u) failed!\n", slaves[i], BOND_PORT); } retval = rte_eth_dev_start(BOND_PORT); if (retval < 0) rte_exit(retval, "Start port %d failed (res=%d)", BOND_PORT, retval); rte_eth_promiscuous_enable(BOND_PORT); struct ether_addr addr; rte_eth_macaddr_get(BOND_PORT, &addr); printf("Port %u MAC: ", (unsigned)BOND_PORT); PRINT_MAC(addr); printf("\n"); }