* [dpdk-dev] [PATCH 1/5] net/mrvl: fix multiple probe issue
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
@ 2018-01-11 15:35 ` Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation Tomasz Duszynski
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-11 15:35 UTC (permalink / raw)
To: dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
From: Natalie Samsonov <nsamsono@marvell.com>
MUSDK library initialization and cleanup should be done once.
This commit fixes that by doing necessary initialization once the first
port is probed and cleanup once the last port is removed.
Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 78 +++++++++++++++++++++++++++++-------------
drivers/net/mrvl/mrvl_ethdev.h | 3 --
drivers/net/mrvl/mrvl_qos.c | 2 +-
3 files changed, 56 insertions(+), 27 deletions(-)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 127ce44..8b3865b 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -111,6 +111,11 @@ struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
+struct mrvl_ifnames {
+ const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
+ int idx;
+};
+
/*
* To use buffer harvesting based on loopback port shadow queue structure
* was introduced for buffers information bookkeeping.
@@ -156,10 +161,9 @@ struct mrvl_txq {
*/
struct mrvl_shadow_txq shadow_txqs[RTE_MAX_ETHPORTS][RTE_MAX_LCORE];
-/** Number of ports configured. */
-int mrvl_ports_nb;
static int mrvl_lcore_first;
static int mrvl_lcore_last;
+static int mrvl_dev_num;
static inline int
mrvl_get_bpool_size(int pp2_id, int pool_id)
@@ -584,8 +588,10 @@ mrvl_dev_stop(struct rte_eth_dev *dev)
mrvl_dev_set_link_down(dev);
mrvl_flush_rx_queues(dev);
mrvl_flush_tx_shadow_queues(dev);
- if (priv->qos_tbl)
+ if (priv->qos_tbl) {
pp2_cls_qos_tbl_deinit(priv->qos_tbl);
+ priv->qos_tbl = NULL;
+ }
pp2_ppio_deinit(priv->ppio);
priv->ppio = NULL;
}
@@ -2070,6 +2076,7 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
eth_dev->tx_pkt_burst = mrvl_tx_pkt_burst;
+ eth_dev->data->kdrv = RTE_KDRV_NONE;
eth_dev->data->dev_private = priv;
eth_dev->device = &vdev->device;
eth_dev->dev_ops = &mrvl_ops;
@@ -2103,6 +2110,7 @@ mrvl_eth_dev_destroy(const char *name)
priv = eth_dev->data->dev_private;
pp2_bpool_deinit(priv->bpool);
+ used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit);
rte_free(priv);
rte_free(eth_dev->data->mac_addrs);
rte_eth_dev_release_port(eth_dev);
@@ -2126,9 +2134,9 @@ static int
mrvl_get_ifnames(const char *key __rte_unused, const char *value,
void *extra_args)
{
- const char **ifnames = extra_args;
+ struct mrvl_ifnames *ifnames = extra_args;
- ifnames[mrvl_ports_nb++] = value;
+ ifnames->names[ifnames->idx++] = value;
return 0;
}
@@ -2177,6 +2185,8 @@ mrvl_deinit_hifs(void)
if (hifs[i])
pp2_hif_deinit(hifs[i]);
}
+ used_hifs = MRVL_MUSDK_HIFS_RESERVED;
+ memset(hifs, 0, sizeof(hifs));
}
static void mrvl_set_first_last_cores(int core_id)
@@ -2201,7 +2211,7 @@ static int
rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
{
struct rte_kvargs *kvlist;
- const char *ifnames[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
+ struct mrvl_ifnames ifnames;
int ret = -EINVAL;
uint32_t i, ifnum, cfgnum, core_id;
const char *params;
@@ -2215,21 +2225,34 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
return -EINVAL;
ifnum = rte_kvargs_count(kvlist, MRVL_IFACE_NAME_ARG);
- if (ifnum > RTE_DIM(ifnames))
+ if (ifnum > RTE_DIM(ifnames.names))
goto out_free_kvlist;
+ ifnames.idx = 0;
rte_kvargs_process(kvlist, MRVL_IFACE_NAME_ARG,
mrvl_get_ifnames, &ifnames);
- cfgnum = rte_kvargs_count(kvlist, MRVL_CFG_ARG);
- if (cfgnum > 1) {
- RTE_LOG(ERR, PMD, "Cannot handle more than one config file!\n");
- goto out_free_kvlist;
- } else if (cfgnum == 1) {
- rte_kvargs_process(kvlist, MRVL_CFG_ARG,
- mrvl_get_qoscfg, &mrvl_qos_cfg);
+
+ /*
+ * The below system initialization should be done only once,
+ * on the first provided configuration file
+ */
+ if (!mrvl_qos_cfg) {
+ cfgnum = rte_kvargs_count(kvlist, MRVL_CFG_ARG);
+ RTE_LOG(INFO, PMD, "Parsing config file!\n");
+ if (cfgnum > 1) {
+ RTE_LOG(ERR, PMD, "Cannot handle more than one config file!\n");
+ goto out_free_kvlist;
+ } else if (cfgnum == 1) {
+ rte_kvargs_process(kvlist, MRVL_CFG_ARG,
+ mrvl_get_qoscfg, &mrvl_qos_cfg);
+ }
}
+ if (mrvl_dev_num)
+ goto init_devices;
+
+ RTE_LOG(INFO, PMD, "Perform MUSDK initializations\n");
/*
* ret == -EEXIST is correct, it means DMA
* has been already initialized (by another PMD).
@@ -2253,12 +2276,14 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
if (ret)
goto out_deinit_hifs;
+init_devices:
for (i = 0; i < ifnum; i++) {
- RTE_LOG(INFO, PMD, "Creating %s\n", ifnames[i]);
- ret = mrvl_eth_dev_create(vdev, ifnames[i]);
+ RTE_LOG(INFO, PMD, "Creating %s\n", ifnames.names[i]);
+ ret = mrvl_eth_dev_create(vdev, ifnames.names[i]);
if (ret)
goto out_cleanup;
}
+ mrvl_dev_num += ifnum;
rte_kvargs_free(kvlist);
@@ -2274,12 +2299,15 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
return 0;
out_cleanup:
for (; i > 0; i--)
- mrvl_eth_dev_destroy(ifnames[i]);
+ mrvl_eth_dev_destroy(ifnames.names[i]);
out_deinit_hifs:
- mrvl_deinit_hifs();
- mrvl_deinit_pp2();
+ if (mrvl_dev_num == 0) {
+ mrvl_deinit_hifs();
+ mrvl_deinit_pp2();
+ }
out_deinit_dma:
- mv_sys_dma_mem_destroy();
+ if (mrvl_dev_num == 0)
+ mv_sys_dma_mem_destroy();
out_free_kvlist:
rte_kvargs_free(kvlist);
@@ -2312,11 +2340,15 @@ rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
rte_eth_dev_get_name_by_port(i, ifname);
mrvl_eth_dev_destroy(ifname);
+ mrvl_dev_num--;
}
- mrvl_deinit_hifs();
- mrvl_deinit_pp2();
- mv_sys_dma_mem_destroy();
+ if (mrvl_dev_num == 0) {
+ RTE_LOG(INFO, PMD, "Perform MUSDK deinit\n");
+ mrvl_deinit_hifs();
+ mrvl_deinit_pp2();
+ mv_sys_dma_mem_destroy();
+ }
return 0;
}
diff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h
index 8a647a5..f7afae5 100644
--- a/drivers/net/mrvl/mrvl_ethdev.h
+++ b/drivers/net/mrvl/mrvl_ethdev.h
@@ -115,7 +115,4 @@ struct mrvl_priv {
uint16_t nb_rx_queues;
};
-/** Number of ports configured. */
-extern int mrvl_ports_nb;
-
#endif /* _MRVL_ETHDEV_H_ */
diff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c
index 7c9943a..fbb3681 100644
--- a/drivers/net/mrvl/mrvl_qos.c
+++ b/drivers/net/mrvl/mrvl_qos.c
@@ -369,7 +369,7 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
}
/* Use the number of ports given as vdev parameters. */
- for (n = 0; n < mrvl_ports_nb; ++n) {
+ for (n = 0; n < (PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC); ++n) {
snprintf(sec_name, sizeof(sec_name), "%s %d %s",
MRVL_TOK_PORT, n, MRVL_TOK_DEFAULT);
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 1/5] net/mrvl: fix multiple probe issue Tomasz Duszynski
@ 2018-01-11 15:35 ` Tomasz Duszynski
2018-01-12 19:13 ` Ferruh Yigit
2018-01-11 15:35 ` [dpdk-dev] [PATCH 3/5] net/mrvl: fix oversize bpool handling Tomasz Duszynski
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-11 15:35 UTC (permalink / raw)
To: dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
From: Natalie Samsonov <nsamsono@marvell.com>
1. Add checking for non-EAL threads.
2. Create hif objects on first use since sometimes on probe not all
lcores are initialized and can be added later.
In this case the hif objects for later cores were not created and
this caused system crash.
Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 181 ++++++++++++++++++++++++-----------------
1 file changed, 107 insertions(+), 74 deletions(-)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 8b3865b..5c3b700 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -190,6 +190,59 @@ mrvl_reserve_bit(int *bitmap, int max)
return n;
}
+static int
+mrvl_init_hif(int core_id)
+{
+ struct pp2_hif_params params;
+ char match[MRVL_MATCH_LEN];
+ int ret;
+
+ ret = mrvl_reserve_bit(&used_hifs, MRVL_MUSDK_HIFS_MAX);
+ if (ret < 0) {
+ RTE_LOG(ERR, PMD, "Failed to allocate hif %d\n", core_id);
+ return ret;
+ }
+
+ snprintf(match, sizeof(match), "hif-%d", ret);
+ memset(¶ms, 0, sizeof(params));
+ params.match = match;
+ params.out_size = MRVL_PP2_AGGR_TXQD_MAX;
+ ret = pp2_hif_init(¶ms, &hifs[core_id]);
+ if (ret) {
+ RTE_LOG(ERR, PMD, "Failed to initialize hif %d\n", core_id);
+ return ret;
+ }
+
+ return 0;
+}
+
+static inline struct pp2_hif*
+mrvl_get_hif(struct mrvl_priv *priv, int core_id)
+{
+ int ret;
+
+ if (likely(hifs[core_id] != NULL))
+ return hifs[core_id];
+
+ rte_spinlock_lock(&priv->lock);
+
+ ret = mrvl_init_hif(core_id);
+ if (ret < 0) {
+ RTE_LOG(ERR, PMD, "Failed to allocate hif %d\n", core_id);
+ goto out;
+ }
+
+ if (core_id < mrvl_lcore_first)
+ mrvl_lcore_first = core_id;
+
+ if (core_id > mrvl_lcore_last)
+ mrvl_lcore_last = core_id;
+out:
+ rte_spinlock_unlock(&priv->lock);
+
+ return hifs[core_id];
+}
+
/**
* Configure rss based on dpdk rss configuration.
*
@@ -551,8 +604,15 @@ static void
mrvl_flush_bpool(struct rte_eth_dev *dev)
{
struct mrvl_priv *priv = dev->data->dev_private;
+ struct pp2_hif *hif;
uint32_t num;
int ret;
+ unsigned int core_id = rte_lcore_id();
+
+ if (core_id == LCORE_ID_ANY)
+ core_id = 0;
+
+ hif = mrvl_get_hif(priv, core_id);
ret = pp2_bpool_get_num_buffs(priv->bpool, &num);
if (ret) {
@@ -564,8 +624,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev)
struct pp2_buff_inf inf;
uint64_t addr;
- ret = pp2_bpool_get_buff(hifs[rte_lcore_id()], priv->bpool,
- &inf);
+ ret = pp2_bpool_get_buff(hif, priv->bpool, &inf);
if (ret)
break;
@@ -1173,9 +1232,19 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)
struct buff_release_entry entries[MRVL_PP2_TXD_MAX];
struct rte_mbuf *mbufs[MRVL_PP2_TXD_MAX];
int i, ret;
- unsigned int core_id = rte_lcore_id();
- struct pp2_hif *hif = hifs[core_id];
- struct pp2_bpool *bpool = rxq->priv->bpool;
+ unsigned int core_id;
+ struct pp2_hif *hif;
+ struct pp2_bpool *bpool;
+
+ core_id = rte_lcore_id();
+ if (core_id == LCORE_ID_ANY)
+ core_id = 0;
+
+ hif = mrvl_get_hif(rxq->priv, core_id);
+ if (!hif)
+ return -1;
+
+ bpool = rxq->priv->bpool;
ret = rte_pktmbuf_alloc_bulk(rxq->mp, mbufs, num);
if (ret)
@@ -1311,8 +1380,15 @@ mrvl_rx_queue_release(void *rxq)
struct mrvl_rxq *q = rxq;
struct pp2_ppio_tc_params *tc_params;
int i, num, tc, inq;
+ struct pp2_hif *hif;
+ unsigned int core_id = rte_lcore_id();
- if (!q)
+ if (core_id == LCORE_ID_ANY)
+ core_id = 0;
+
+ hif = mrvl_get_hif(q->priv, core_id);
+
+ if (!q || !hif)
return;
tc = q->priv->rxq_map[q->queue_id].tc;
@@ -1323,7 +1399,7 @@ mrvl_rx_queue_release(void *rxq)
struct pp2_buff_inf inf;
uint64_t addr;
- pp2_bpool_get_buff(hifs[rte_lcore_id()], q->priv->bpool, &inf);
+ pp2_bpool_get_buff(hif, q->priv->bpool, &inf);
addr = cookie_addr_high | inf.cookie;
rte_pktmbuf_free((struct rte_mbuf *)addr);
}
@@ -1599,9 +1675,12 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
struct pp2_bpool *bpool;
int i, ret, rx_done = 0;
int num;
+ struct pp2_hif *hif;
unsigned int core_id = rte_lcore_id();
- if (unlikely(!q->priv->ppio))
+ hif = mrvl_get_hif(q->priv, core_id);
+
+ if (unlikely(!q->priv->ppio || !hif))
return 0;
bpool = q->priv->bpool;
@@ -1644,7 +1723,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
.cookie = (pp2_cookie_t)(uint64_t)mbuf,
};
- pp2_bpool_put_buff(hifs[core_id], bpool, &binf);
+ pp2_bpool_put_buff(hif, bpool, &binf);
mrvl_port_bpool_size
[bpool->pp2_id][bpool->id][core_id]++;
q->drop_mac++;
@@ -1690,7 +1769,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
q->priv->bpool_init_size);
for (i = 0; i < pkt_to_remove; i++) {
- pp2_bpool_get_buff(hifs[core_id], bpool, &buff);
+ pp2_bpool_get_buff(hif, bpool, &buff);
mbuf = (struct rte_mbuf *)
(cookie_addr_high | buff.cookie);
rte_pktmbuf_free(mbuf);
@@ -1782,11 +1861,12 @@ mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
*/
static inline void
mrvl_free_sent_buffers(struct pp2_ppio *ppio, struct pp2_hif *hif,
- struct mrvl_shadow_txq *sq, int qid, int force)
+ unsigned int core_id, struct mrvl_shadow_txq *sq,
+ int qid, int force)
{
struct buff_release_entry *entry;
uint16_t nb_done = 0, num = 0, skip_bufs = 0;
- int i, core_id = rte_lcore_id();
+ int i;
pp2_ppio_get_num_outq_done(ppio, hif, qid, &nb_done);
@@ -1860,17 +1940,21 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
struct mrvl_txq *q = txq;
struct mrvl_shadow_txq *sq = &shadow_txqs[q->port_id][rte_lcore_id()];
- struct pp2_hif *hif = hifs[rte_lcore_id()];
+ struct pp2_hif *hif;
struct pp2_ppio_desc descs[nb_pkts];
+ unsigned int core_id = rte_lcore_id();
int i, ret, bytes_sent = 0;
uint16_t num, sq_free_size;
uint64_t addr;
- if (unlikely(!q->priv->ppio))
+ hif = mrvl_get_hif(q->priv, core_id);
+
+ if (unlikely(!q->priv->ppio || !hif))
return 0;
if (sq->size)
- mrvl_free_sent_buffers(q->priv->ppio, hif, sq, q->queue_id, 0);
+ mrvl_free_sent_buffers(q->priv->ppio, hif, core_id,
+ sq, q->queue_id, 0);
sq_free_size = MRVL_PP2_TX_SHADOWQ_SIZE - sq->size - 1;
if (unlikely(nb_pkts > sq_free_size)) {
@@ -2142,38 +2226,6 @@ mrvl_get_ifnames(const char *key __rte_unused, const char *value,
}
/**
- * Initialize per-lcore MUSDK hardware interfaces (hifs).
- *
- * @return
- * 0 on success, negative error value otherwise.
- */
-static int
-mrvl_init_hifs(void)
-{
- struct pp2_hif_params params;
- char match[MRVL_MATCH_LEN];
- int i, ret;
-
- RTE_LCORE_FOREACH(i) {
- ret = mrvl_reserve_bit(&used_hifs, MRVL_MUSDK_HIFS_MAX);
- if (ret < 0)
- return ret;
-
- snprintf(match, sizeof(match), "hif-%d", ret);
- memset(¶ms, 0, sizeof(params));
- params.match = match;
- params.out_size = MRVL_PP2_AGGR_TXQD_MAX;
- ret = pp2_hif_init(¶ms, &hifs[i]);
- if (ret) {
- RTE_LOG(ERR, PMD, "Failed to initialize hif %d\n", i);
- return ret;
- }
- }
-
- return 0;
-}
-
-/**
* Deinitialize per-lcore MUSDK hardware interfaces (hifs).
*/
static void
@@ -2181,7 +2233,7 @@ mrvl_deinit_hifs(void)
{
int i;
- RTE_LCORE_FOREACH(i) {
+ for (i = mrvl_lcore_first; i <= mrvl_lcore_last; i++) {
if (hifs[i])
pp2_hif_deinit(hifs[i]);
}
@@ -2189,15 +2241,6 @@ mrvl_deinit_hifs(void)
memset(hifs, 0, sizeof(hifs));
}
-static void mrvl_set_first_last_cores(int core_id)
-{
- if (core_id < mrvl_lcore_first)
- mrvl_lcore_first = core_id;
-
- if (core_id > mrvl_lcore_last)
- mrvl_lcore_last = core_id;
-}
-
/**
* DPDK callback to register the virtual device.
*
@@ -2213,7 +2256,7 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
struct rte_kvargs *kvlist;
struct mrvl_ifnames ifnames;
int ret = -EINVAL;
- uint32_t i, ifnum, cfgnum, core_id;
+ uint32_t i, ifnum, cfgnum;
const char *params;
params = rte_vdev_device_args(vdev);
@@ -2272,9 +2315,10 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
goto out_deinit_dma;
}
- ret = mrvl_init_hifs();
- if (ret)
- goto out_deinit_hifs;
+ memset(mrvl_port_bpool_size, 0, sizeof(mrvl_port_bpool_size));
+
+ mrvl_lcore_first = RTE_MAX_LCORE;
+ mrvl_lcore_last = 0;
init_devices:
for (i = 0; i < ifnum; i++) {
@@ -2287,24 +2331,13 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
rte_kvargs_free(kvlist);
- memset(mrvl_port_bpool_size, 0, sizeof(mrvl_port_bpool_size));
-
- mrvl_lcore_first = RTE_MAX_LCORE;
- mrvl_lcore_last = 0;
-
- RTE_LCORE_FOREACH(core_id) {
- mrvl_set_first_last_cores(core_id);
- }
-
return 0;
out_cleanup:
for (; i > 0; i--)
mrvl_eth_dev_destroy(ifnames.names[i]);
-out_deinit_hifs:
- if (mrvl_dev_num == 0) {
- mrvl_deinit_hifs();
+
+ if (mrvl_dev_num == 0)
mrvl_deinit_pp2();
- }
out_deinit_dma:
if (mrvl_dev_num == 0)
mv_sys_dma_mem_destroy();
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation
2018-01-11 15:35 ` [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation Tomasz Duszynski
@ 2018-01-12 19:13 ` Ferruh Yigit
2018-01-15 6:53 ` Tomasz Duszynski
0 siblings, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2018-01-12 19:13 UTC (permalink / raw)
To: Tomasz Duszynski, dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
On 1/11/2018 3:35 PM, Tomasz Duszynski wrote:
> From: Natalie Samsonov <nsamsono@marvell.com>
Commit title updated to [1] assuming hif is an abbreviation (btw, what is hif?)
[1]
net/mrvl: fix HIF objects allocation
>
> 1. Add checking for non-EAL threads.
>
> 2. Create hif objects on first use since sometimes on probe not all
> lcores are initialized and can be added later.
> In this case the hif objects for later cores were not created and
> this caused system crash.
>
> Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton")
Cc: stable@dpdk.org
>
> Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
<...>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation
2018-01-12 19:13 ` Ferruh Yigit
@ 2018-01-15 6:53 ` Tomasz Duszynski
0 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-15 6:53 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: Tomasz Duszynski, dev, jck, mw, dima, nsamsono, Jianbo.liu
On Fri, Jan 12, 2018 at 07:13:22PM +0000, Ferruh Yigit wrote:
> On 1/11/2018 3:35 PM, Tomasz Duszynski wrote:
> > From: Natalie Samsonov <nsamsono@marvell.com>
>
> Commit title updated to [1] assuming hif is an abbreviation (btw, what is hif?)
Thanks for fixing that. HIF stands for host-interface. You want to allocate
it per lcore so that couple of lcores can use MUSDK library simultaneously.
>
> [1]
> net/mrvl: fix HIF objects allocation
>
> >
> > 1. Add checking for non-EAL threads.
> >
> > 2. Create hif objects on first use since sometimes on probe not all
> > lcores are initialized and can be added later.
> > In this case the hif objects for later cores were not created and
> > this caused system crash.
> >
> > Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
>
> Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton")
> Cc: stable@dpdk.org
>
> >
> > Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
>
> <...>
>
--
- Tomasz Duszyński
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 3/5] net/mrvl: fix oversize bpool handling
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 1/5] net/mrvl: fix multiple probe issue Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation Tomasz Duszynski
@ 2018-01-11 15:35 ` Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 4/5] net/mrvl: fix shadow queue tail and size calculations Tomasz Duszynski
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-11 15:35 UTC (permalink / raw)
To: dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
From: Natalie Samsonov <nsamsono@marvell.com>
Don't return mbuf to dpdk pool if failed to get buffer from the bpool.
Fix maximum bpool size calculation to prevent unnecessary bpool
oversize cases when working with small rx queues.
Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 5c3b700..e650bf8 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -165,6 +165,8 @@ static int mrvl_lcore_first;
static int mrvl_lcore_last;
static int mrvl_dev_num;
+static int mrvl_fill_bpool(struct mrvl_rxq *rxq, int num);
+
static inline int
mrvl_get_bpool_size(int pp2_id, int pool_id)
{
@@ -461,20 +463,13 @@ mrvl_dev_start(struct rte_eth_dev *dev)
{
struct mrvl_priv *priv = dev->data->dev_private;
char match[MRVL_MATCH_LEN];
- int ret;
+ int ret = 0, def_init_size;
snprintf(match, sizeof(match), "ppio-%d:%d",
priv->pp_id, priv->ppio_id);
priv->ppio_params.match = match;
/*
- * Calculate the maximum bpool size for refill feature to 1.5 of the
- * configured size. In case the bpool size will exceed this value,
- * superfluous buffers will be removed
- */
- priv->bpool_max_size = priv->bpool_init_size +
- (priv->bpool_init_size >> 1);
- /*
* Calculate the minimum bpool size for refill feature as follows:
* 2 default burst sizes multiply by number of rx queues.
* If the bpool size will be below this value, new buffers will
@@ -482,6 +477,29 @@ mrvl_dev_start(struct rte_eth_dev *dev)
*/
priv->bpool_min_size = priv->nb_rx_queues * MRVL_BURST_SIZE * 2;
+ /* In case initial bpool size configured in queues setup is
+ * smaller than minimum size add more buffers
+ */
+ def_init_size = priv->bpool_min_size + MRVL_BURST_SIZE * 2;
+ if (priv->bpool_init_size < def_init_size) {
+ int buffs_to_add = def_init_size - priv->bpool_init_size;
+
+ priv->bpool_init_size += buffs_to_add;
+ ret = mrvl_fill_bpool(dev->data->rx_queues[0], buffs_to_add);
+ if (ret)
+ RTE_LOG(ERR, PMD, "Failed to add buffers to bpool\n");
+ }
+
+ /*
+ * Calculate the maximum bpool size for refill feature as follows:
+ * maximum number of descriptors in rx queue multiply by number
+ * of rx queues plus minimum bpool size.
+ * In case the bpool size will exceed this value, superfluous buffers
+ * will be removed
+ */
+ priv->bpool_max_size = (priv->nb_rx_queues * MRVL_PP2_RXD_MAX) +
+ priv->bpool_min_size;
+
ret = pp2_ppio_init(&priv->ppio_params, &priv->ppio);
if (ret) {
RTE_LOG(ERR, PMD, "Failed to init ppio\n");
@@ -1769,14 +1787,15 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
q->priv->bpool_init_size);
for (i = 0; i < pkt_to_remove; i++) {
- pp2_bpool_get_buff(hif, bpool, &buff);
+ ret = pp2_bpool_get_buff(hif, bpool, &buff);
+ if (ret)
+ break;
mbuf = (struct rte_mbuf *)
(cookie_addr_high | buff.cookie);
rte_pktmbuf_free(mbuf);
}
mrvl_port_bpool_size
- [bpool->pp2_id][bpool->id][core_id] -=
- pkt_to_remove;
+ [bpool->pp2_id][bpool->id][core_id] -= i;
}
rte_spinlock_unlock(&q->priv->lock);
}
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 4/5] net/mrvl: fix shadow queue tail and size calculations
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
` (2 preceding siblings ...)
2018-01-11 15:35 ` [dpdk-dev] [PATCH 3/5] net/mrvl: fix oversize bpool handling Tomasz Duszynski
@ 2018-01-11 15:35 ` Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 5/5] net/mrvl: keep shadow txqs inside pmd txq Tomasz Duszynski
2018-01-12 19:13 ` [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Ferruh Yigit
5 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-11 15:35 UTC (permalink / raw)
To: dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
From: Natalie Samsonov <nsamsono@marvell.com>
Reset skip_buf after use to avoid wrong tail and size
calculations.
Fixes: afb4d0d ("net/mrvl: add Rx/Tx support")
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index e650bf8..7ce4df3 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -1932,6 +1932,7 @@ mrvl_free_sent_buffers(struct pp2_ppio *ppio, struct pp2_hif *hif,
sq->tail = (sq->tail + num) & MRVL_PP2_TX_SHADOWQ_MASK;
sq->size -= num;
num = 0;
+ skip_bufs = 0;
}
if (likely(num)) {
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 5/5] net/mrvl: keep shadow txqs inside pmd txq
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
` (3 preceding siblings ...)
2018-01-11 15:35 ` [dpdk-dev] [PATCH 4/5] net/mrvl: fix shadow queue tail and size calculations Tomasz Duszynski
@ 2018-01-11 15:35 ` Tomasz Duszynski
2018-01-12 19:13 ` [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Ferruh Yigit
5 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-11 15:35 UTC (permalink / raw)
To: dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
From: Natalie Samsonov <nsamsono@marvell.com>
Change shadow queues allocation from port/core to txq/core.
Use array of shadow queues (one per lcore) for each tx queue object to
avoid data corruption when few tx queues are handled by one lcore and
buffers that were not sent yet, can be released and used for receive.
Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 47 ++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 7ce4df3..4294c56 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -150,22 +150,17 @@ struct mrvl_txq {
int queue_id;
int port_id;
uint64_t bytes_sent;
+ struct mrvl_shadow_txq shadow_txqs[RTE_MAX_LCORE];
};
-/*
- * Every tx queue should have dedicated shadow tx queue.
- *
- * Ports assigned by DPDK might not start at zero or be continuous so
- * as a workaround define shadow queues for each possible port so that
- * we eventually fit somewhere.
- */
-struct mrvl_shadow_txq shadow_txqs[RTE_MAX_ETHPORTS][RTE_MAX_LCORE];
-
static int mrvl_lcore_first;
static int mrvl_lcore_last;
static int mrvl_dev_num;
static int mrvl_fill_bpool(struct mrvl_rxq *rxq, int num);
+static inline void mrvl_free_sent_buffers(struct pp2_ppio *ppio,
+ struct pp2_hif *hif, unsigned int core_id,
+ struct mrvl_shadow_txq *sq, int qid, int force);
static inline int
mrvl_get_bpool_size(int pp2_id, int pool_id)
@@ -594,21 +589,32 @@ mrvl_flush_rx_queues(struct rte_eth_dev *dev)
static void
mrvl_flush_tx_shadow_queues(struct rte_eth_dev *dev)
{
- int i;
+ int i, j;
+ struct mrvl_txq *txq;
RTE_LOG(INFO, PMD, "Flushing tx shadow queues\n");
- for (i = 0; i < RTE_MAX_LCORE; i++) {
- struct mrvl_shadow_txq *sq =
- &shadow_txqs[dev->data->port_id][i];
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ txq = (struct mrvl_txq *)dev->data->tx_queues[i];
+
+ for (j = 0; j < RTE_MAX_LCORE; j++) {
+ struct mrvl_shadow_txq *sq;
+
+ if (!hifs[j])
+ continue;
- while (sq->tail != sq->head) {
- uint64_t addr = cookie_addr_high |
+ sq = &txq->shadow_txqs[j];
+ mrvl_free_sent_buffers(txq->priv->ppio,
+ hifs[j], j, sq, txq->queue_id, 1);
+ while (sq->tail != sq->head) {
+ uint64_t addr = cookie_addr_high |
sq->ent[sq->tail].buff.cookie;
- rte_pktmbuf_free((struct rte_mbuf *)addr);
- sq->tail = (sq->tail + 1) & MRVL_PP2_TX_SHADOWQ_MASK;
+ rte_pktmbuf_free(
+ (struct rte_mbuf *)addr);
+ sq->tail = (sq->tail + 1) &
+ MRVL_PP2_TX_SHADOWQ_MASK;
+ }
+ memset(sq, 0, sizeof(*sq));
}
-
- memset(sq, 0, sizeof(*sq));
}
}
@@ -1959,7 +1965,7 @@ static uint16_t
mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
struct mrvl_txq *q = txq;
- struct mrvl_shadow_txq *sq = &shadow_txqs[q->port_id][rte_lcore_id()];
+ struct mrvl_shadow_txq *sq;
struct pp2_hif *hif;
struct pp2_ppio_desc descs[nb_pkts];
unsigned int core_id = rte_lcore_id();
@@ -1968,6 +1974,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
uint64_t addr;
hif = mrvl_get_hif(q->priv, core_id);
+ sq = &q->shadow_txqs[core_id];
if (unlikely(!q->priv->ppio || !hif))
return 0;
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
` (4 preceding siblings ...)
2018-01-11 15:35 ` [dpdk-dev] [PATCH 5/5] net/mrvl: keep shadow txqs inside pmd txq Tomasz Duszynski
@ 2018-01-12 19:13 ` Ferruh Yigit
2018-01-15 7:35 ` Tomasz Duszynski
5 siblings, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2018-01-12 19:13 UTC (permalink / raw)
To: Tomasz Duszynski, dev; +Cc: jck, mw, dima, nsamsono, Jianbo.liu
On 1/11/2018 3:35 PM, Tomasz Duszynski wrote:
> Following commits provide fixes for a few recently
> found NET MRVL PMD issues.
>
> Natalie Samsonov (5):
> net/mrvl: fix multiple probe issue
> net/mrvl: fix hif objects allocation
> net/mrvl: fix oversize bpool handling
> net/mrvl: fix shadow queue tail and size calculations
> net/mrvl: keep shadow txqs inside pmd txq
Series applied to dpdk-next-net/master, thanks.
Please use provided fixline alias to generate Fixes lines, which produces
slightly different output than yours.
Also my scripts doesn't cover mrvl PMD because of MUSDK dependency, can you
please confirm the build with latest next-net?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues
2018-01-12 19:13 ` [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Ferruh Yigit
@ 2018-01-15 7:35 ` Tomasz Duszynski
0 siblings, 0 replies; 10+ messages in thread
From: Tomasz Duszynski @ 2018-01-15 7:35 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: Tomasz Duszynski, dev, jck, mw, dima, nsamsono, Jianbo.liu
On Fri, Jan 12, 2018 at 07:13:09PM +0000, Ferruh Yigit wrote:
> On 1/11/2018 3:35 PM, Tomasz Duszynski wrote:
> > Following commits provide fixes for a few recently
> > found NET MRVL PMD issues.
> >
> > Natalie Samsonov (5):
> > net/mrvl: fix multiple probe issue
> > net/mrvl: fix hif objects allocation
> > net/mrvl: fix oversize bpool handling
> > net/mrvl: fix shadow queue tail and size calculations
> > net/mrvl: keep shadow txqs inside pmd txq
>
> Series applied to dpdk-next-net/master, thanks.
>
>
> Please use provided fixline alias to generate Fixes lines, which produces
> slightly different output than yours.
Right, one of the fixlines was wrong. Thanks for catching this.
>
> Also my scripts doesn't cover mrvl PMD because of MUSDK dependency, can you
> please confirm the build with latest next-net?
Build works.
--
- Tomasz Duszyński
^ permalink raw reply [flat|nested] 10+ messages in thread