From patchwork Mon Jun 15 22:00:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 484604 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 78CD914029E for ; Tue, 16 Jun 2015 08:01:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 86E77A3F5C; Mon, 15 Jun 2015 22:01:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mLZdvW0Jf1ec; Mon, 15 Jun 2015 22:01:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B7D1AA3BB6; Mon, 15 Jun 2015 22:01:06 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 74EE31C0E70 for ; Mon, 15 Jun 2015 22:01:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6F6818F0A2 for ; Mon, 15 Jun 2015 22:01:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YTUnOlKSbHSI for ; Mon, 15 Jun 2015 22:01:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by whitealder.osuosl.org (Postfix) with ESMTP id CAA738C9D9 for ; Mon, 15 Jun 2015 22:01:04 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 15 Jun 2015 15:01:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,621,1427785200"; d="scan'208";a="508766650" Received: from jekeller-desk.amr.corp.intel.com ([134.134.3.85]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2015 15:01:04 -0700 From: Jacob Keller To: Intel Wired LAN Date: Mon, 15 Jun 2015 15:00:54 -0700 Message-Id: <1434405656-10465-4-git-send-email-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.4.2 In-Reply-To: <1434405656-10465-1-git-send-email-jacob.e.keller@intel.com> References: <1434405656-10465-1-git-send-email-jacob.e.keller@intel.com> Subject: [Intel-wired-lan] [PATCH 4/6] fm10k: reset Tx FIFO head and tail pointers as part of reset_work X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" This patch fixes a corner case issue with the PF/VF mailbox code. Currently, fm10k_mbx_reset_work clears various state about the mailbox. However, it did not clear the Tx FIFO head/tail pointers. Thus, when the PF finally re-connects (say due to VF reset), it in-advertently might send some previous data in the Tx FIFO again. This was discovered by attempting to perform a static VF MAC address assignment on the PF device. The VF would receive the message and then initiate a reset. During this process it disconnects and reconnects to the mailbox. If the PF doesn't respond fast enough, it may not see the disconnect message, and only sees a new connect message. In this flow, it does not properly clear the Tx FIFO pointers. Thus, it will re-transmit the last message in the Tx FIFO. However, it does not increment the mailbox Tx messages because it has already reset mbx->pulled and thus does not think it is actually sending any data. The fix is to simply reset the Tx FIFO pointers whenever we call fm10k_mbx_reset_work. As a consequence, we no longer need both fm10k_mbx_fifo_drop_all and calls to fm10k_mbx_update_max_size with a size of 0. Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/fm10k/fm10k_mbx.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c index 1a4b52637de9..f9016bf8b5b1 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c @@ -126,18 +126,6 @@ static u16 fm10k_fifo_head_drop(struct fm10k_mbx_fifo *fifo) } /** - * fm10k_fifo_drop_all - Drop all messages in FIFO - * @fifo: pointer to FIFO - * - * This function resets the head pointer to drop all messages in the FIFO, - * and ensure the FIFO is empty. - **/ -static void fm10k_fifo_drop_all(struct fm10k_mbx_fifo *fifo) -{ - fifo->head = fifo->tail; -} - -/** * fm10k_mbx_index_len - Convert a head/tail index into a length value * @mbx: pointer to mailbox * @head: head index @@ -1054,6 +1042,8 @@ static void fm10k_mbx_reset_work(struct fm10k_mbx_info *mbx) mbx->pulled = 0; mbx->tail_len = 0; mbx->head_len = 0; + mbx->tx.tail = 0; + mbx->tx.head = 0; mbx->rx.tail = 0; mbx->rx.head = 0; } @@ -1384,7 +1374,6 @@ static void fm10k_mbx_disconnect(struct fm10k_hw *hw, * drop all left over messages in the FIFO. */ fm10k_mbx_connect_reset(mbx); - fm10k_fifo_drop_all(&mbx->tx); fm10k_write_reg(hw, mbx->mbmem_reg, 0); } @@ -1725,7 +1714,6 @@ static void fm10k_sm_mbx_disconnect(struct fm10k_hw *hw, mbx->state = FM10K_STATE_CLOSED; mbx->remote = 0; fm10k_mbx_reset_work(mbx); - fm10k_mbx_update_max_size(mbx, 0); fm10k_write_reg(hw, mbx->mbmem_reg, 0); }