From nobody Thu Nov 13 10:28:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579587772; cv=none; d=zohomail.com; s=zohoarc; b=HPvLQYiCSbNiERGHrShKqfzfiT2ttLEsObzflDdM1cVpSR50FSgy6i2dRLk8vpGztbIWB7qjWrlbfx6i/KJldhDV+bg4IZvO8hYbgLHGrLLYbOVYmK6822HmJ2kG1z4r7YY2U5APv2Q8yd5rjoPS5+iD5gaZc9dgONqaJBpmGOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579587772; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aYmjkBej51IXbH25I28JKAObPjPcchrJz7bHQqX3qSE=; b=AS4DOVBWuwM8wOq8Yqs18Usgg0ys4PLe/fkbAQWLxa6sbiUTHBR6x4KQ1e6fc7cEzfHxguMHH/PfhXvUgPtJBN7tZhVeZGFJUa46gly0mDxyBHY9d63LeXT85RymAQ1pwKwCo3VqP7zH9O1bxhfExrgbxU9zfGb5HPbKIzrX7Pc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579587772875899.0538525806062; Mon, 20 Jan 2020 22:22:52 -0800 (PST) Received: from localhost ([::1]:48958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itmw7-0002RS-Iv for importer@patchew.org; Tue, 21 Jan 2020 01:22:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41963) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itmtD-0007HG-QK for qemu-devel@nongnu.org; Tue, 21 Jan 2020 01:19:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itmtC-0006T1-3R for qemu-devel@nongnu.org; Tue, 21 Jan 2020 01:19:51 -0500 Received: from mga03.intel.com ([134.134.136.65]:35723) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1itmtB-0006Rf-Ro for qemu-devel@nongnu.org; Tue, 21 Jan 2020 01:19:50 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jan 2020 22:19:48 -0800 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,344,1574150400"; d="scan'208";a="278301959" From: Jing Liu To: virtio-dev@lists.oasis-open.org 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zha Bin , kvm@vger.kernel.org, Jing Liu , linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, Chao Peng , Liu Jiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=20 - \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 th= is + register notifies the device that there are new buffers to process in = a queue. =20 - 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 regi= ster + returns the virtqueue notification structure for calculating notificat= ion location. =20 - 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-specif= ic Initialization And Device Operation / Notification Structure Layout} + for the notification structure format. =20 - \lstinputlisting{notifications-le.c} - - See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueue= s / Driver notifications} - for the definition of the components. + See \ref{sec:Virtio Transport Options / Virtio Over MMIO / MMIO-specif= ic Initialization And Device Operation / Available Buffer Notifications} + for the notification data format. } \hline=20 \mmioreg{InterruptStatus}{Interrupt status}{0x60}{R}{% @@ -1858,6 +1856,31 @@ \subsubsection{Device Initialization}\label{sec:Virt= io Transport Options / Virti Further initialization MUST follow the procedure described in \ref{sec:General Initialization And Device Operation / Device Initializati= on}~\nameref{sec:General Initialization And Device Operation / Device Initi= alization}. =20 +\subsubsection{Notification Structure Layout}\label{sec:Virtio Transport O= ptions / Virtio Over MMIO / MMIO-specific Initialization And Device Operati= on / Notification Structure Layout} + +When VIRTIO_F_MMIO_NOTIFICATION has been negotiated, the notification loca= tion is calculated +by notification structure. Driver reads \field{QueueNotify} to get this st= ructure 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 Q= ueue 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 Not= ify address for all +queues. +\end{note} + \subsubsection{Virtqueue Configuration}\label{sec:Virtio Transport Options= / Virtio Over MMIO / MMIO-specific Initialization And Device Operation / V= irtqueue Configuration} =20 The driver will typically initialize the virtual queue in the following wa= y: @@ -1893,16 +1916,20 @@ \subsubsection{Available Buffer Notifications}\labe= l{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. =20 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} =20 See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / = Driver notifications} for the definition of the components. =20 +For device not offering VIRTIO_F_MMIO_NOTIFICATION, the Queue Notify addre= ss is \field{QueueNotify}. +For device offering VIRTIO_F_MMIO_NOTIFICATION, see \ref{sec:Virtio Transp= ort Options / Virtio Over MMIO / MMIO-specific Initialization And Device Op= eration / Notification Structure Layout} +for how to calculate the Queue Notify address. + \subsubsection{Notifications From The Device}\label{sec:Virtio Transport O= ptions / Virtio Over MMIO / MMIO-specific Initialization And Device Operati= on / Notifications From The Device} =20 The memory mapped virtio device is using a single, dedicated --=20 2.7.4