From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 582AA36E for ; Tue, 28 Mar 2017 08:46:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490683567; x=1522219567; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UTiDglpGyj5Gguvq5CXGuggkvCMp1rSQitABK2wf8Aw=; b=IrcrWPLEiwFMF0E5XM2tJiEP6lu3QpEf9xg2qNeYieg+9O09qeeugiCL 1PBUF+glZkMdOy62RD4y5YrQPBlNoA==; Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 23:46:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,235,1486454400"; d="scan'208";a="1127910956" Received: from dpdk06.sh.intel.com ([10.239.129.195]) by fmsmga001.fm.intel.com with ESMTP; 27 Mar 2017 23:46:05 -0700 From: Jianfeng Tan To: zhiyong.yang@intel.com Cc: Jianfeng Tan , stable@dpdk.org, Stephen Hemminger Date: Tue, 28 Mar 2017 06:46:51 +0000 Message-Id: <1490683611-72221-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] net/virtio: fix read isr as MSI is enabled X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2017 06:46:07 -0000 We should not always check isr to know if link status is changed. Here is how driver should handle interrupt quoted from virtio spec, If MSI-X capability is disabled: – Read the ISR Status field, which will reset it to zero. – If the lower bit is set: look through the used rings of all virtqueues for the device, to see if any progress has been made by the device which requires servicing. – If the second lower bit is set: re-examine the configuration space to see what changed. If MSI-X capability is enabled: – Look through the used rings of all virtqueues mapped to that MSI-X vector for the device, to see if any progress has been made by the device which requires servicing. – If the MSI-X vector is equal to config_msix_vector, re-examine the configuration space to see what changed Fixes: 8d6d7e5cb3b1 ("virtio: support link state interrupt") CC: stable@dpdk.org CC: Stephen Hemminger Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_ethdev.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 3cf4102..cb30d11 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1197,20 +1198,23 @@ virtio_interrupt_handler(struct rte_intr_handle *handle, struct rte_eth_dev *dev = param; struct virtio_hw *hw = dev->data->dev_private; uint8_t isr; + bool check_config; - /* Read interrupt status which clears interrupt */ - isr = vtpci_isr(hw); - PMD_DRV_LOG(INFO, "interrupt status = %#x", isr); + /* isr is used only when msix is not enabled */ + if (!hw->modern && !hw->use_msix) { + isr = vtpci_isr(hw); /* Read to clears interrupt */ + PMD_DRV_LOG(INFO, "interrupt status = %#x", isr); + check_config = (isr & VIRTIO_PCI_ISR_CONFIG) ? true : false; + } else { + check_config = true; + } if (rte_intr_enable(handle) < 0) PMD_DRV_LOG(ERR, "interrupt enable failed"); - if (isr & VIRTIO_PCI_ISR_CONFIG) { - if (virtio_dev_link_update(dev, 0) == 0) - _rte_eth_dev_callback_process(dev, - RTE_ETH_EVENT_INTR_LSC, NULL); - } - + if (check_config && virtio_dev_link_update(dev, 0) == 0) + _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_INTR_LSC, NULL); } static void -- 2.7.4