#include <rte_ip_frag.h>
#include <rte_devargs.h>
#include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
#include <rte_alarm.h>
#include <rte_cycles.h>
struct bond_rx_queue *bd_rx_q;
struct bond_tx_queue *bd_tx_q;
+ uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
+ uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
int errval;
uint16_t q_id;
}
/* Setup Rx Queues */
- for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
+ /* Use existing queues, if any */
+ for (q_id = old_nb_rx_queues;
+ q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
}
/* Setup Tx Queues */
- for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
+ /* Use existing queues, if any */
+ for (q_id = old_nb_tx_queues;
+ q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
slave_details->port_id = slave_eth_dev->data->port_id;
slave_details->last_link_status = 0;
- /* If slave device doesn't support interrupts then we need to enabled
- * polling to monitor link status */
+ /* Mark slave devices that don't support interrupts so we can
+ * compensate when we start the bond
+ */
if (!(slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)) {
slave_details->link_status_poll_enabled = 1;
-
- if (!internals->link_status_polling_enabled) {
- internals->link_status_polling_enabled = 1;
-
- rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
- bond_ethdev_slave_link_status_change_monitor,
- (void *)&rte_eth_devices[internals->port_id]);
- }
}
slave_details->link_status_wait_to_complete = 0;
return -1;
}
- eth_dev->data->dev_link.link_status = 0;
+ eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
eth_dev->data->dev_started = 1;
internals = eth_dev->data->dev_private;
eth_dev->data->port_id, internals->slaves[i].port_id);
return -1;
}
+ /* We will need to poll for link status if any slave doesn't
+ * support interrupts
+ */
+ if (internals->slaves[i].link_status_poll_enabled)
+ internals->link_status_polling_enabled = 1;
+ }
+ /* start polling if needed */
+ if (internals->link_status_polling_enabled) {
+ rte_eal_alarm_set(
+ internals->link_status_polling_interval_ms * 1000,
+ bond_ethdev_slave_link_status_change_monitor,
+ (void *)&rte_eth_devices[internals->port_id]);
}
if (internals->user_defined_primary_port)
for (i = 0; i < internals->active_slave_count; i++) {
port = &mode_8023ad_ports[internals->active_slaves[i]];
- RTE_VERIFY(port->rx_ring != NULL);
+ RTE_ASSERT(port->rx_ring != NULL);
while (rte_ring_dequeue(port->rx_ring, &pkt) != -ENOENT)
rte_pktmbuf_free(pkt);
- RTE_VERIFY(port->tx_ring != NULL);
+ RTE_ASSERT(port->tx_ring != NULL);
while (rte_ring_dequeue(port->tx_ring, &pkt) != -ENOENT)
rte_pktmbuf_free(pkt);
}
internals->active_slave_count = 0;
internals->link_status_polling_enabled = 0;
+ for (i = 0; i < internals->slave_count; i++)
+ internals->slaves[i].last_link_status = 0;
- eth_dev->data->dev_link.link_status = 0;
+ eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
eth_dev->data->dev_started = 0;
}
dev_info->max_mac_addrs = 1;
- dev_info->max_rx_pktlen = (uint32_t)2048;
+ dev_info->max_rx_pktlen = internals->candidate_max_rx_pktlen ?
+ internals->candidate_max_rx_pktlen : 2048;
dev_info->max_rx_queues = (uint16_t)128;
dev_info->max_tx_queues = (uint16_t)512;
if (!bonded_eth_dev->data->dev_started ||
internals->active_slave_count == 0) {
- bonded_eth_dev->data->dev_link.link_status = 0;
+ bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
return 0;
} else {
struct rte_eth_dev *slave_eth_dev;
(*slave_eth_dev->dev_ops->link_update)(slave_eth_dev,
wait_to_complete);
- if (slave_eth_dev->data->dev_link.link_status == 1) {
+ if (slave_eth_dev->data->dev_link.link_status == ETH_LINK_UP) {
link_up = 1;
break;
}
stats->imissed += slave_stats.imissed;
stats->ierrors += slave_stats.ierrors;
stats->oerrors += slave_stats.oerrors;
- stats->imcasts += slave_stats.imcasts;
stats->rx_nombuf += slave_stats.rx_nombuf;
for (j = 0; j < RTE_ETHDEV_QUEUE_STAT_CNTRS; j++) {
/* if no active slave ports then set this port to be primary port */
if (internals->active_slave_count < 1) {
/* If first active slave, then change link status */
- bonded_eth_dev->data->dev_link.link_status = 1;
+ bonded_eth_dev->data->dev_link.link_status = ETH_LINK_UP;
internals->current_primary_port = port_id;
lsc_flag = 1;
* link properties */
if (internals->active_slave_count < 1) {
lsc_flag = 1;
- bonded_eth_dev->data->dev_link.link_status = 0;
+ bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
link_properties_reset(bonded_eth_dev);
}
};
static int
-bond_init(const char *name, const char *params)
+bond_probe(const char *name, const char *params)
{
struct bond_dev_private *internals;
struct rte_kvargs *kvlist;
}
static int
-bond_uninit(const char *name)
+bond_remove(const char *name)
{
int ret;
}
}
+ /* set the max_rx_pktlen */
+ internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;
+
/*
* if no kvlist, it means that this bonded device has been created
* through the bonding api.
return 0;
}
-static struct rte_driver bond_drv = {
- .name = "eth_bond",
- .type = PMD_VDEV,
- .init = bond_init,
- .uninit = bond_uninit,
+static struct rte_vdev_driver bond_drv = {
+ .probe = bond_probe,
+ .remove = bond_remove,
};
-PMD_REGISTER_DRIVER(bond_drv);
+DRIVER_REGISTER_VDEV(net_bonding, bond_drv);
+
+DRIVER_REGISTER_PARAM_STRING(net_bonding,
+ "slave=<ifc> "
+ "primary=<ifc> "
+ "mode=[0-6] "
+ "xmit_policy=[l2 | l23 | l34] "
+ "socket_id=<int> "
+ "mac=<mac addr> "
+ "lsc_poll_period_ms=<int> "
+ "up_delay=<int> "
+ "down_delay=<int>");