Skip to content

Commit

Permalink
net: mrvl: handle bpool/mempool cleanup properly in case error happens
Browse files Browse the repository at this point in the history
  • Loading branch information
semihalf-duszynski-tomasz authored and dimaep committed Jun 10, 2017
1 parent f0c5e0c commit 49a4070
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/net/mrvl/mrvl_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static int
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 + 1] = { };
struct rte_mbuf *mbufs[MRVL_PP2_TXD_MAX];
uint64_t dma_addr;
int i, ret;

Expand All @@ -693,7 +693,7 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)
if (rxq->priv->dma_addr_high != dma_addr >> 32) {
RTE_LOG(ERR, PMD, "mbuf outside proper address range\n");
ret = -EFAULT;
goto out;
goto out_free;
}

entries[i].buff.addr = dma_addr;
Expand All @@ -703,15 +703,26 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)

ret = pp2_bpool_put_buffs(rxq->priv->hif, entries, (uint16_t *)&i);
if (ret)
goto out;
goto out_free;
if (i != num) {
ret = -1;
goto out;
}

return 0;
out:
for (; i >= 0; i--)
for (; i > 0; i--) {
struct pp2_buff_inf inf;
pp2_bpool_get_buff(rxq->priv->hif, rxq->priv->bpool, &inf);
/*
* TODO
* Do more testing to make sure that putting buffers and
* getting them from hw bpool work in LIFO manner.
*/
assert((struct rte_mbuf *)inf.cookie == mbufs[i]);
}
out_free:
for (i = 0; i < num; i++)
rte_pktmbuf_free(mbufs[i]);

return ret;
Expand Down

0 comments on commit 49a4070

Please sign in to comment.