Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3352304ybl; Mon, 20 Jan 2020 22:22:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzj0PxyjN/mtPlW3qCNG9id6YwAEXt/S1rlFmjvDGPNfHJXtF93GuuGCVPbStrQyCghamzQ X-Received: by 2002:a54:4106:: with SMTP id l6mr1844006oic.76.1579587735273; Mon, 20 Jan 2020 22:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579587735; cv=none; d=google.com; s=arc-20160816; b=MTksfd7j10S0mnubYNS76Rgx4KrLnjxU8GhfhbcOckPPYDekj9vj1/2NY8cM6X2U2j FP3ayFYXln1q4IGLNGtY+tnRgkr9u5h8nRXMovEN05hMMOEDZ4mFvbp6/lDJ73bQKxxh owE16TWddi0KBTy69YdiWtHb6Un8ecFZGaC9F3E9RK2vCNwMa7xI9J1KFi2GjfkcBzkw 4sd4KISJW1UI/aPjeQiBEJSiaqvbzsH8WP92rD2UZiuZbliDUf855fnQduPsLemvMYLR AicEYTeIutKHAF6XKVsn9LhowlhnGFM7/BSFJA+RO205bukj/UXtkTii49Opz/BnrevJ GhEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=aYmjkBej51IXbH25I28JKAObPjPcchrJz7bHQqX3qSE=; b=rdGXTregsCLStqsJUN7hskkfQpTPk01rrw+rHYC2KZkKLJbwB7K51UMrdwDIbL+oBd AqBnsJ9TAj6dcXjvXwfyX2i+WXCxiNvIDTG09nPnTjp4V2YLIBujO3l7QxC3gvaSv0o6 6zx0sxxsK+u2J3mMEswI1SCcvi+fm8ik2ekrprEFW2Y7/wYp6C6uP5vrnOVMzw1Ud4zK myCEpDvp0JGkkvIauhhO5mbBDW7orB6pypK8fCcIyIwNSv0nkqp6WWgRtGIxEbLxHCO4 /RGzLJQbk3hweBw7reVj2S1YQfenO+N1uF4OB9y1fzhD3gdFJMpYY2wrp/EENoIxc8kW 9ajg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si22514948otp.286.2020.01.20.22.22.03; Mon, 20 Jan 2020 22:22:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728982AbgAUGTv (ORCPT + 99 others); Tue, 21 Jan 2020 01:19:51 -0500 Received: from mga14.intel.com ([192.55.52.115]:33355 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728896AbgAUGTt (ORCPT ); Tue, 21 Jan 2020 01:19:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jan 2020 22:19:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,344,1574150400"; d="scan'208";a="278301959" Received: from hyperv-sh3.bj.intel.com ([10.240.193.95]) by fmsmga001.fm.intel.com with ESMTP; 20 Jan 2020 22:19:47 -0800 From: Jing Liu To: virtio-dev@lists.oasis-open.org Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, Jing Liu , Chao Peng , Liu Jiang , Zha Bin Subject: [virtio-dev] [PATCH v2 2/5] virtio-mmio: Enhance queue notification support Date: Tue, 21 Jan 2020 21:54:30 +0800 Message-Id: <1579614873-21907-3-git-send-email-jing2.liu@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579614873-21907-1-git-send-email-jing2.liu@linux.intel.com> References: <1579614873-21907-1-git-send-email-jing2.liu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With VIRTIO_F_MMIO_NOTIFICATION feature bit offered, the notification mechanism is enhanced. Driver reads QueueNotify register to get notification structure and calculate notification addresses of each virtqueue. Co-developed-by: Chao Peng Signed-off-by: Chao Peng Co-developed-by: Liu Jiang Signed-off-by: Liu Jiang Co-developed-by: Zha Bin Signed-off-by: Zha Bin Signed-off-by: Jing Liu --- content.tex | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/content.tex b/content.tex index 826bc7d..5881253 100644 --- a/content.tex +++ b/content.tex @@ -1671,20 +1671,18 @@ \subsection{MMIO Device Register Layout}\label{sec:Virtio Transport Options / Vi accesses apply to the queue selected by writing to \field{QueueSel}. } \hline - \mmioreg{QueueNotify}{Queue notifier}{0x050}{W}{% - Writing a value to this register notifies the device that - there are new buffers to process in a queue. + \mmioreg{QueueNotify}{Queue notifier}{0x050}{RW}{% + When VIRTIO_F_MMIO_NOTIFICATION has not been negotiated, writing to this + register notifies the device that there are new buffers to process in a queue. - When VIRTIO_F_NOTIFICATION_DATA has not been negotiated, - the value written is the queue index. + When VIRTIO_F_MMIO_NOTIFICATION has been negotiated, reading this register + returns the virtqueue notification structure for calculating notification location. - When VIRTIO_F_NOTIFICATION_DATA has been negotiated, - the \field{Notification data} value has the following format: + See \ref{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Notification Structure Layout} + for the notification structure format. - \lstinputlisting{notifications-le.c} - - See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications} - for the definition of the components. + See \ref{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Available Buffer Notifications} + for the notification data format. } \hline \mmioreg{InterruptStatus}{Interrupt status}{0x60}{R}{% @@ -1858,6 +1856,31 @@ \subsubsection{Device Initialization}\label{sec:Virtio Transport Options / Virti Further initialization MUST follow the procedure described in \ref{sec:General Initialization And Device Operation / Device Initialization}~\nameref{sec:General Initialization And Device Operation / Device Initialization}. +\subsubsection{Notification Structure Layout}\label{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Notification Structure Layout} + +When VIRTIO_F_MMIO_NOTIFICATION has been negotiated, the notification location is calculated +by notification structure. Driver reads \field{QueueNotify} to get this structure formatted +as follows. + +\begin{lstlisting} +le32 { + notify_base : 16; + notify_multiplier : 16; +}; +\end{lstlisting} + +\field{notify_multiplier} is combined with virtqueue index to derive the Queue Notify address +within a memory mapped control registers for a virtqueue: + +\begin{lstlisting} + notify_base + queue_index * notify_multiplier +\end{lstlisting} + +\begin{note} +For example, if notify_multiplier is 0, the device uses the same Queue Notify address for all +queues. +\end{note} + \subsubsection{Virtqueue Configuration}\label{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Virtqueue Configuration} The driver will typically initialize the virtual queue in the following way: @@ -1893,16 +1916,20 @@ \subsubsection{Available Buffer Notifications}\label{sec:Virtio Transport Option When VIRTIO_F_NOTIFICATION_DATA has not been negotiated, the driver sends an available buffer notification to the device by writing the 16-bit virtqueue index -of the queue to be notified to \field{QueueNotify}. +of the queue to be notified to Queue Notify address. When VIRTIO_F_NOTIFICATION_DATA has been negotiated, the driver sends an available buffer notification to the device by writing -the following 32-bit value to \field{QueueNotify}: +the following 32-bit value to Queue Notify address: \lstinputlisting{notifications-le.c} See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications} for the definition of the components. +For device not offering VIRTIO_F_MMIO_NOTIFICATION, the Queue Notify address is \field{QueueNotify}. +For device offering VIRTIO_F_MMIO_NOTIFICATION, see \ref{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Notification Structure Layout} +for how to calculate the Queue Notify address. + \subsubsection{Notifications From The Device}\label{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / Notifications From The Device} The memory mapped virtio device is using a single, dedicated -- 2.7.4