netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rasesh Mody <rmody@brocade.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>,
	<adapter_linux_open_src_team@Brocade.COM>,
	Rasesh Mody <rmody@Brocade.COM>
Subject: [net-next 07/13] bna: Fix Stale MTU used to Configure Multi-buffer RX
Date: Sat, 7 Dec 2013 21:48:38 -0800	[thread overview]
Message-ID: <1386481724-32367-8-git-send-email-rmody@brocade.com> (raw)
In-Reply-To: <1386481724-32367-1-git-send-email-rmody@brocade.com>

Change Details:
 - Rx initialization uses MTU. ENET MTU set should be called before setting up
   Rx. Added checks to make sure that reinit is called only when required.

Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
 drivers/net/ethernet/brocade/bna/bnad.c | 32 +++++++++++++++++++++++++-------
 drivers/net/ethernet/brocade/bna/bnad.h |  6 +-----
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index 849de5a..508f5fc 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -2013,6 +2013,7 @@ err_return:
 static void
 bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)
 {
+	memset(rx_config, 0, sizeof(*rx_config));
 	rx_config->rx_type = BNA_RX_T_REGULAR;
 	rx_config->num_paths = bnad->num_rxp_per_rx;
 	rx_config->coalescing_timeo = bnad->rx_coalescing_timeo;
@@ -2035,6 +2036,7 @@ bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)
 	}
 
 	rx_config->frame_size = BNAD_FRAME_SIZE(bnad->netdev->mtu);
+	rx_config->q0_multi_buf = BNA_STATUS_T_DISABLED;
 
 	/* BNA_RXP_SINGLE - one data-buffer queue
 	 * BNA_RXP_SLR - one small-buffer and one large-buffer queues
@@ -2044,7 +2046,8 @@ bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)
 	rx_config->rxp_type = BNA_RXP_SLR;
 
 	if (BNAD_PCI_DEV_IS_CAT2(bnad) &&
-	    bnad_enable_multi_buffer(rx_config->frame_size)) {
+			bnad_enable_multi_buffer &&
+			rx_config->frame_size > 4096) {
 		/* though size_routing_enable is set in SLR,
 		 * small packets may get routed to same rxq.
 		 * set buf_size to 2048 instead of PAGE_SIZE.
@@ -2092,8 +2095,16 @@ bnad_reinit_rx(struct bnad *bnad)
 	for (rx_id = 0; rx_id < bnad->num_rx; rx_id++) {
 		if (!bnad->rx_info[rx_id].rx)
 			continue;
-		count++;
 		bnad_destroy_rx(bnad, rx_id);
+	}
+
+	spin_lock_irqsave(&bnad->bna_lock, flags);
+	bna_enet_mtu_set(&bnad->bna.enet,
+			 BNAD_FRAME_SIZE(bnad->netdev->mtu), NULL);
+	spin_unlock_irqrestore(&bnad->bna_lock, flags);
+
+	for (rx_id = 0; rx_id < bnad->num_rx; rx_id++) {
+		count++;
 		current_err = bnad_setup_rx(bnad, rx_id);
 		if (current_err && !err) {
 			err = current_err;
@@ -3262,7 +3273,7 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	int err, mtu;
 	struct bnad *bnad = netdev_priv(netdev);
-	u32 rx_count = 0;
+	u32 rx_count = 0, frame, new_frame;
 
 	if (new_mtu + ETH_HLEN < ETH_ZLEN || new_mtu > BNAD_JUMBO_MTU)
 		return -EINVAL;
@@ -3272,15 +3283,22 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
 	mtu = netdev->mtu;
 	netdev->mtu = new_mtu;
 
+	frame = BNAD_FRAME_SIZE(mtu);
+	new_frame = BNAD_FRAME_SIZE(new_mtu);
+
 	/* check if multi-buffer needs to be enabled */
-	if (BNAD_PCI_DEV_IS_CAT2(bnad) &&
-	    bnad_reinit_rx_needed(BNAD_FRAME_SIZE(new_mtu)))
-		rx_count = bnad_reinit_rx(bnad);
+	if (BNAD_PCI_DEV_IS_CAT2(bnad) && bnad_enable_multi_buffer &&
+	    netif_running(bnad->netdev)) {
+		/* only when transition is over 4K */
+		if ((frame <= 4096 && new_frame > 4096) ||
+		    (frame > 4096 && new_frame <= 4096))
+			rx_count = bnad_reinit_rx(bnad);
+	}
 
 	/* rx_count > 0 - new rx created
 	 *	- Linux set err = 0 and return
 	 */
-	err = bnad_mtu_set(bnad, new_mtu);
+	err = bnad_mtu_set(bnad, new_frame);
 	if (err)
 		err = -EBUSY;
 
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
index d1dc930..f2b50d9 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.h
+++ b/drivers/net/ethernet/brocade/bna/bnad.h
@@ -263,11 +263,7 @@ struct bnad_rx_unmap_q {
 #define BNAD_PCI_DEV_IS_CAT2(_bnad) \
 	((_bnad)->pcidev->device == BFA_PCI_DEVICE_ID_CT2)
 
-#define bnad_enable_multi_buffer(_mtu) \
-		bnad_reinit_rx_needed((_mtu))
-
-#define bnad_reinit_rx_needed(_frame) \
-	(bnad_multi_buffer_rx && (_frame) > 4096)
+#define bnad_enable_multi_buffer bnad_multi_buffer_rx
 
 /* Bit mask values for bnad->cfg_flags */
 #define	BNAD_CF_DIM_ENABLED		0x01	/* DIM */
-- 
1.8.2.3

  parent reply	other threads:[~2013-12-08  5:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-08  5:48 [net-next 00/13] bna: Update the Driver to v3.2.23.0 Rasesh Mody
2013-12-08  5:48 ` [net-next 01/13] bna: Add software PTP support Rasesh Mody
2013-12-08  5:48 ` [net-next 02/13] bna: Set Get IOC fw State Rasesh Mody
2013-12-08  5:48 ` [net-next 03/13] bna: Fix Filter Add Del Rasesh Mody
2013-12-08  5:48 ` [net-next 04/13] bna: RX Filter Enhancements Rasesh Mody
2013-12-08  5:48 ` [net-next 05/13] bna: Enable Multi Buffer RX Rasesh Mody
2013-12-08  5:48 ` [net-next 06/13] bna: UDP RX Processing Improvements Rasesh Mody
2013-12-10  0:17   ` David Miller
2013-12-11  0:05     ` Rasesh Mody
2013-12-11  2:11       ` David Miller
2013-12-08  5:48 ` Rasesh Mody [this message]
2013-12-08  5:48 ` [net-next 08/13] bna: CQ Read Fix Rasesh Mody
2013-12-08  5:48 ` [net-next 09/13] bna: Add NULL Check Before Dereferencing TCB Rasesh Mody
2013-12-08  5:48 ` [net-next 10/13] bna: Handle the TX Setup Failures Rasesh Mody
2013-12-08  5:48 ` [net-next 11/13] bna: Embed SKB Length in TX Vector Rasesh Mody
2013-12-08  5:48 ` [net-next 12/13] bna: Firmware Patch Simplification Rasesh Mody
2013-12-08  5:48 ` [net-next 13/13] bna: Update the Driver Version to 3.2.23.0 Rasesh Mody
  -- strict thread matches above, loose matches on Subject: below --
2013-11-21  5:54 [net-next 00/13] bna: Update the Driver to v3.2.23.0 Rasesh Mody
2013-11-21  5:54 ` [net-next 07/13] bna: Fix Stale MTU used to Configure Multi-buffer RX Rasesh Mody

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=1386481724-32367-8-git-send-email-rmody@brocade.com \
    --to=rmody@brocade.com \
    --cc=adapter_linux_open_src_team@Brocade.COM \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).