struct rte_mempool *rx_mpool; /* mpool used by the rx queues. */
unsigned rx_offset; /* Receive head room. */
unsigned rx_size_code; /* mPIPE rx buffer size code. */
- unsigned rx_buffers; /* receive buffers on stack. */
int is_xaui:1, /* Is this an xgbe or gbe? */
initialized:1, /* Initialized port? */
running:1; /* Running port? */
speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
+ new.link_autoneg = (dev->data->dev_conf.link_speeds &
+ ETH_LINK_SPEED_AUTONEG);
if (speed == GXIO_MPIPE_LINK_1G) {
- new.link_speed = ETH_LINK_SPEED_1000;
+ new.link_speed = ETH_SPEED_NUM_1G;
new.link_duplex = ETH_LINK_FULL_DUPLEX;
- new.link_status = 1;
+ new.link_status = ETH_LINK_UP;
} else if (speed == GXIO_MPIPE_LINK_10G) {
- new.link_speed = ETH_LINK_SPEED_10000;
+ new.link_speed = ETH_SPEED_NUM_10G;
new.link_duplex = ETH_LINK_FULL_DUPLEX;
- new.link_status = 1;
+ new.link_status = ETH_LINK_UP;
}
rc = mpipe_link_compare(&old, &new);
int i;
for (i = 0; i < count; i++) {
- mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool);
+ mbuf = rte_mbuf_raw_alloc(priv->rx_mpool);
if (!mbuf)
break;
mpipe_recv_push(priv, mbuf);
}
- priv->rx_buffers += count;
PMD_DEBUG_RX("%s: Filled %d/%d buffers\n", mpipe_name(priv), i, count);
}
const int offset = priv->rx_offset & ~RTE_MEMPOOL_ALIGN_MASK;
uint8_t in_port = priv->port_id;
struct rte_mbuf *mbuf;
- unsigned count;
void *va;
- for (count = 0; count < priv->rx_buffers; count++) {
+ while (1) {
va = gxio_mpipe_pop_buffer(priv->context, priv->stack);
if (!va)
break;
__rte_mbuf_raw_free(mbuf);
}
-
- PMD_DEBUG_RX("%s: Returned %d/%d buffers\n",
- mpipe_name(priv), count, priv->rx_buffers);
- priv->rx_buffers -= count;
}
static void
/* Start xmit/recv on queues. */
for (queue = 0; queue < priv->nb_tx_queues; queue++)
- mpipe_tx_queue(priv, queue)->q.link_status = 1;
+ mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
for (queue = 0; queue < priv->nb_rx_queues; queue++)
- mpipe_rx_queue(priv, queue)->q.link_status = 1;
+ mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
priv->running = 1;
return 0;
int rc;
for (queue = 0; queue < priv->nb_tx_queues; queue++)
- mpipe_tx_queue(priv, queue)->q.link_status = 0;
+ mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
for (queue = 0; queue < priv->nb_rx_queues; queue++)
- mpipe_rx_queue(priv, queue)->q.link_status = 0;
+ mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
/* Make sure the link_status writes land. */
rte_wmb();
}
}
-static struct eth_dev_ops mpipe_dev_ops = {
+static const struct eth_dev_ops mpipe_dev_ops = {
.dev_infos_get = mpipe_infos_get,
.dev_configure = mpipe_configure,
.dev_start = mpipe_start,
gxio_mpipe_iqueue_t *iqueue;
gxio_mpipe_idesc_t idesc;
struct rte_mbuf *mbuf;
- int retries = 0;
unsigned queue;
- do {
- mpipe_recv_flush_stack(priv);
-
- /* Flush packets sitting in recv queues. */
- for (queue = 0; queue < priv->nb_rx_queues; queue++) {
- rx_queue = mpipe_rx_queue(priv, queue);
- iqueue = &rx_queue->iqueue;
- while (gxio_mpipe_iqueue_try_get(iqueue, &idesc) >= 0) {
- mbuf = mpipe_recv_mbuf(priv, &idesc, in_port);
- rte_pktmbuf_free(mbuf);
- priv->rx_buffers--;
- }
- rte_free(rx_queue->rx_ring_mem);
- }
- } while (retries++ < 10 && priv->rx_buffers);
+ /* Release packets on the buffer stack. */
+ mpipe_recv_flush_stack(priv);
- if (priv->rx_buffers) {
- RTE_LOG(ERR, PMD, "%s: Leaked %d receive buffers.\n",
- mpipe_name(priv), priv->rx_buffers);
- } else {
- PMD_DEBUG_RX("%s: Returned all receive buffers.\n",
- mpipe_name(priv));
+ /* Flush packets sitting in recv queues. */
+ for (queue = 0; queue < priv->nb_rx_queues; queue++) {
+ rx_queue = mpipe_rx_queue(priv, queue);
+ iqueue = &rx_queue->iqueue;
+ while (gxio_mpipe_iqueue_try_get(iqueue, &idesc) >= 0) {
+ /* Skip idesc with the 'buffer error' bit set. */
+ if (idesc.be)
+ continue;
+ mbuf = mpipe_recv_mbuf(priv, &idesc, in_port);
+ rte_pktmbuf_free(mbuf);
+ }
+ rte_free(rx_queue->rx_ring_mem);
}
}
.xfer_size = rte_pktmbuf_data_len(mbuf),
.bound = next ? 0 : 1,
.stack_idx = mpipe_mbuf_stack_index(priv, mbuf),
+ .size = priv->rx_size_code,
} };
if (mpipe_local.mbuf_push_debt[port_id] > 0) {
mpipe_local.mbuf_push_debt[port_id]--;
MPIPE_BUF_DEBT_THRESHOLD)
mpipe_local.mbuf_push_debt[in_port]++;
else {
- mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool);
+ mbuf = rte_mbuf_raw_alloc(priv->rx_mpool);
if (unlikely(!mbuf)) {
nb_nomem++;
gxio_mpipe_iqueue_drop(iqueue, idesc);
return -ENODEV;
}
- eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+ eth_dev = rte_eth_dev_allocate(ifname);
if (!eth_dev) {
RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
rte_free(priv);
}
static struct rte_driver pmd_mpipe_xgbe_drv = {
- .name = "xgbe",
.type = PMD_VDEV,
.init = rte_pmd_mpipe_devinit,
};
static struct rte_driver pmd_mpipe_gbe_drv = {
- .name = "gbe",
.type = PMD_VDEV,
.init = rte_pmd_mpipe_devinit,
};
-PMD_REGISTER_DRIVER(pmd_mpipe_xgbe_drv);
-PMD_REGISTER_DRIVER(pmd_mpipe_gbe_drv);
+PMD_REGISTER_DRIVER(pmd_mpipe_xgbe_drv, net_mpipe_xgbe);
+PMD_REGISTER_DRIVER(pmd_mpipe_gbe_drv, net_mpipe_gbe);
static void __attribute__((constructor, used))
mpipe_init_contexts(void)