DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Xiaoxin Peng <xiaoxin.peng@broadcom.com>,
	stable@dpdk.org, Jay Ding <jay.ding@broadcom.com>,
	Scott Branden <scott.branden@broadcom.com>
Subject: [dpdk-dev] [PATCH 10/12] net/bnxt: fix rx mbuf and agg ring leak in dev stop
Date: Mon, 30 Apr 2018 18:06:14 -0700	[thread overview]
Message-ID: <20180501010616.40472-11-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20180501010616.40472-1-ajit.khaparde@broadcom.com>

From: Xiaoxin Peng <xiaoxin.peng@broadcom.com>

In the start/stop_op operation, mbufs allocated for rings were not freed

1) add bnxt_free_tx_mbuf/bnxt_free_rx_mbuf in bnxt_dev_stop_op to free MBUF
   before freeing the rings.
2) MBUF allocation and free routines were not in sync. Allocation uses the
   ring->ring_size including any rounded up and multiple factors while the
   free routine uses the requested queue size.

Fixes: c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
Cc: stable@dpdk.org

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Xiaoxin Peng <xiaoxin.peng@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 4 ++--
 drivers/net/bnxt/bnxt_rxq.c    | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 352fc30b4..dc445f9a5 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -655,6 +655,8 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	}
 	bnxt_set_hwrm_link_config(bp, false);
 	bnxt_hwrm_port_clr_stats(bp);
+	bnxt_free_tx_mbufs(bp);
+	bnxt_free_rx_mbufs(bp);
 	bnxt_shutdown_nic(bp);
 	bp->dev_stopped = 1;
 }
@@ -666,8 +668,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	if (bp->dev_stopped == 0)
 		bnxt_dev_stop_op(eth_dev);
 
-	bnxt_free_tx_mbufs(bp);
-	bnxt_free_rx_mbufs(bp);
 	bnxt_free_mem(bp);
 	if (eth_dev->data->mac_addrs != NULL) {
 		rte_free(eth_dev->data->mac_addrs);
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 4b380d4f0..866fb56b1 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -207,7 +207,8 @@ static void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
 	if (rxq) {
 		sw_ring = rxq->rx_ring->rx_buf_ring;
 		if (sw_ring) {
-			for (i = 0; i < rxq->nb_rx_desc; i++) {
+			for (i = 0;
+			     i < rxq->rx_ring->rx_ring_struct->ring_size; i++) {
 				if (sw_ring[i].mbuf) {
 					rte_pktmbuf_free_seg(sw_ring[i].mbuf);
 					sw_ring[i].mbuf = NULL;
@@ -217,7 +218,8 @@ static void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
 		/* Free up mbufs in Agg ring */
 		sw_ring = rxq->rx_ring->ag_buf_ring;
 		if (sw_ring) {
-			for (i = 0; i < rxq->nb_rx_desc; i++) {
+			for (i = 0;
+			     i < rxq->rx_ring->ag_ring_struct->ring_size; i++) {
 				if (sw_ring[i].mbuf) {
 					rte_pktmbuf_free_seg(sw_ring[i].mbuf);
 					sw_ring[i].mbuf = NULL;
-- 
2.15.1 (Apple Git-101)

  parent reply	other threads:[~2018-05-01  1:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01  1:06 [dpdk-dev] [PATCH 00/12] bnxt patchset Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 01/12] net/bnxt: add support for lsc interrupt event Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 02/12] net/bnxt: rename function checking MAC address Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 03/12] net/bnxt: rename driver version from Cumulus to NetXtreme Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 04/12] net/bnxt: return EINVAL instead of ENOSPC on invalid max ring Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 05/12] net/bnxt: Validate structs and pointers before use Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 06/12] net/bnxt: set MTU in dev config for jumbo packets Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 07/12] net/bnxt: fix MTU calculation Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 08/12] net/bnxt: return error if init is not complete before accessing stats Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 09/12] net/bnxt: fix to reset status of initialization Ajit Khaparde
2018-05-01  1:06 ` Ajit Khaparde [this message]
2018-05-01  1:06 ` [dpdk-dev] [PATCH 11/12] net/bnxt: fix usage of vnic id Ajit Khaparde
2018-05-01  1:06 ` [dpdk-dev] [PATCH 12/12] net/bnxt: clear HWRM sniffer list for PFs Ajit Khaparde
2018-05-08 16:30 ` [dpdk-dev] [PATCH 00/12] bnxt patchset Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180501010616.40472-11-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=jay.ding@broadcom.com \
    --cc=scott.branden@broadcom.com \
    --cc=stable@dpdk.org \
    --cc=xiaoxin.peng@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).