diff options
Diffstat (limited to 'drivers/net/ark')
-rw-r--r-- | drivers/net/ark/ark_ddm.c | 12 | ||||
-rw-r--r-- | drivers/net/ark/ark_ddm.h | 7 | ||||
-rw-r--r-- | drivers/net/ark/ark_ethdev.c | 4 | ||||
-rw-r--r-- | drivers/net/ark/ark_ethdev_rx.c | 55 | ||||
-rw-r--r-- | drivers/net/ark/ark_ethdev_tx.c | 2 |
5 files changed, 66 insertions, 14 deletions
diff --git a/drivers/net/ark/ark_ddm.c b/drivers/net/ark/ark_ddm.c index eea388a1..57026f8d 100644 --- a/drivers/net/ark/ark_ddm.c +++ b/drivers/net/ark/ark_ddm.c @@ -11,14 +11,22 @@ int ark_ddm_verify(struct ark_ddm_t *ddm) { + uint32_t hw_const; if (sizeof(struct ark_ddm_t) != ARK_DDM_EXPECTED_SIZE) { PMD_DRV_LOG(ERR, "ARK: DDM structure looks incorrect %d vs %zd\n", ARK_DDM_EXPECTED_SIZE, sizeof(struct ark_ddm_t)); return -1; } - if (ddm->cfg.const0 != ARK_DDM_CONST) { - PMD_DRV_LOG(ERR, "ARK: DDM module not found as expected 0x%08x\n", + hw_const = ddm->cfg.const0; + if (hw_const == ARK_DDM_CONST1) { + PMD_DRV_LOG(ERR, + "ARK: DDM module is version 1, " + "PMD expects version 2\n"); + return -1; + } else if (hw_const != ARK_DDM_CONST2) { + PMD_DRV_LOG(ERR, + "ARK: DDM module not found as expected 0x%08x\n", ddm->cfg.const0); return -1; } diff --git a/drivers/net/ark/ark_ddm.h b/drivers/net/ark/ark_ddm.h index b37d1e09..5456b4b5 100644 --- a/drivers/net/ark/ark_ddm.h +++ b/drivers/net/ark/ark_ddm.h @@ -19,7 +19,7 @@ /* struct defining Tx meta data -- fixed in FPGA -- 16 bytes */ struct ark_tx_meta { uint64_t physaddr; - uint32_t delta_ns; + uint32_t user1; uint16_t data_len; /* of this MBUF */ #define ARK_DDM_EOP 0x01 #define ARK_DDM_SOP 0x02 @@ -34,7 +34,10 @@ struct ark_tx_meta { * structs will never be instantiated in ram memory */ #define ARK_DDM_CFG 0x0000 -#define ARK_DDM_CONST 0xfacecafe +/* Set unique HW ID for hardware version */ +#define ARK_DDM_CONST2 (0x324d4444) +#define ARK_DDM_CONST1 (0xfacecafe) + struct ark_ddm_cfg_t { uint32_t r0; volatile uint32_t tlp_stats_clear; diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 552ca01a..4f52e2bd 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -313,6 +313,9 @@ eth_ark_dev_init(struct rte_eth_dev *dev) /* We are a single function multi-port device. */ ret = ark_config_device(dev); + if (ret) + return -1; + dev->dev_ops = &ark_eth_dev_ops; dev->data->mac_addrs = rte_zmalloc("ark", ETHER_ADDR_LEN, 0); @@ -506,7 +509,6 @@ eth_ark_dev_uninit(struct rte_eth_dev *dev) dev->dev_ops = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; - rte_free(dev->data->mac_addrs); return 0; } diff --git a/drivers/net/ark/ark_ethdev_rx.c b/drivers/net/ark/ark_ethdev_rx.c index 16f0d11e..300029d6 100644 --- a/drivers/net/ark/ark_ethdev_rx.c +++ b/drivers/net/ark/ark_ethdev_rx.c @@ -25,6 +25,9 @@ static uint32_t eth_ark_rx_jumbo(struct ark_rx_queue *queue, struct rte_mbuf *mbuf0, uint32_t cons_index); static inline int eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue); +static int eth_ark_rx_seed_recovery(struct ark_rx_queue *queue, + uint32_t *pnb, + struct rte_mbuf **mbufs); /* ************************************************************************* */ struct ark_rx_queue { @@ -50,7 +53,7 @@ struct ark_rx_queue { /* The queue Index is used within the dpdk device structures */ uint16_t queue_index; - uint32_t pad1; + uint32_t last_cons; /* separate cache line */ /* second cache line - fields only used in slow path */ @@ -102,7 +105,10 @@ eth_ark_rx_update_cons_index(struct ark_rx_queue *queue, uint32_t cons_index) { queue->cons_index = cons_index; eth_ark_rx_seed_mbufs(queue); - ark_mpu_set_producer(queue->mpu, queue->seed_index); + if (((cons_index - queue->last_cons) >= 64U)) { + queue->last_cons = cons_index; + ark_mpu_set_producer(queue->mpu, queue->seed_index); + } } /* ************************************************************************* */ @@ -196,20 +202,25 @@ eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev, /* populate mbuf reserve */ status = eth_ark_rx_seed_mbufs(queue); + if (queue->seed_index != nb_desc) { + PMD_DRV_LOG(ERR, "ARK: Failed to allocate %u mbufs for RX queue %d\n", + nb_desc, qidx); + status = -1; + } /* MPU Setup */ if (status == 0) status = eth_ark_rx_hw_setup(dev, queue, qidx, queue_idx); if (unlikely(status != 0)) { - struct rte_mbuf *mbuf; + struct rte_mbuf **mbuf; PMD_DRV_LOG(ERR, "Failed to initialize RX queue %d %s\n", qidx, __func__); /* Free the mbufs allocated */ - for (i = 0, mbuf = queue->reserve_q[0]; - i < nb_desc; ++i, mbuf++) { - rte_pktmbuf_free(mbuf); + for (i = 0, mbuf = queue->reserve_q; + i < queue->seed_index; ++i, mbuf++) { + rte_pktmbuf_free(*mbuf); } rte_free(queue->reserve_q); rte_free(queue->paddress_q); @@ -446,8 +457,13 @@ eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue) struct rte_mbuf **mbufs = &queue->reserve_q[seed_m]; int status = rte_pktmbuf_alloc_bulk(queue->mb_pool, mbufs, nb); - if (unlikely(status != 0)) - return -1; + if (unlikely(status != 0)) { + /* Try to recover from lack of mbufs in pool */ + status = eth_ark_rx_seed_recovery(queue, &nb, mbufs); + if (unlikely(status != 0)) { + return -1; + } + } if (ARK_RX_DEBUG) { /* DEBUG */ while (count != nb) { @@ -495,6 +511,29 @@ eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue) return 0; } +int +eth_ark_rx_seed_recovery(struct ark_rx_queue *queue, + uint32_t *pnb, + struct rte_mbuf **mbufs) +{ + int status = -1; + + /* Ignore small allocation failures */ + if (*pnb <= 64) + return -1; + + *pnb = 64U; + status = rte_pktmbuf_alloc_bulk(queue->mb_pool, mbufs, *pnb); + if (status != 0) { + PMD_DRV_LOG(ERR, + "ARK: Could not allocate %u mbufs from pool for RX queue %u;" + " %u free buffers remaining in queue\n", + *pnb, queue->queue_index, + queue->seed_index - queue->cons_index); + } + return status; +} + void eth_ark_rx_dump_queue(struct rte_eth_dev *dev, uint16_t queue_id, const char *msg) diff --git a/drivers/net/ark/ark_ethdev_tx.c b/drivers/net/ark/ark_ethdev_tx.c index 57188c24..94da5f95 100644 --- a/drivers/net/ark/ark_ethdev_tx.c +++ b/drivers/net/ark/ark_ethdev_tx.c @@ -65,7 +65,7 @@ eth_ark_tx_meta_from_mbuf(struct ark_tx_meta *meta, uint8_t flags) { meta->physaddr = rte_mbuf_data_iova(mbuf); - meta->delta_ns = 0; + meta->user1 = (uint32_t)mbuf->udata64; meta->data_len = rte_pktmbuf_data_len(mbuf); meta->flags = flags; } |