From 0cda0a2354661cca6eebd692af940ce7af158b96 Mon Sep 17 00:00:00 2001 From: Himanshi Ghai <72979568+hghai14@users.noreply.github.com> Date: Mon, 12 Sep 2022 18:41:48 +0530 Subject: [PATCH 1/2] Create Desc-of-SimpleHandler.md --- Desc-of-SimpleHandler.md | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Desc-of-SimpleHandler.md diff --git a/Desc-of-SimpleHandler.md b/Desc-of-SimpleHandler.md new file mode 100644 index 0000000..12688e0 --- /dev/null +++ b/Desc-of-SimpleHandler.md @@ -0,0 +1,62 @@ +# SimpleHandler + +It maintains a pair of queue `RX/TX`. These queues would be used for packets tranfer(communication) between VM and `net` device. This is used along with MMIO between the guest and the devices. + +It is used in the `QueueHandler` in the net device. + +```rs +pub struct SimpleHandler { + pub driver_notify: S, + pub rxq: Queue, + pub rxbuf_current: usize, + pub rxbuf: [u8; MAX_BUFFER_SIZE], + pub txq: Queue, + pub txbuf: [u8; MAX_BUFFER_SIZE], + pub tap: Tap, +} +``` +- `driver_notify` gets an instance of `SingleFdSignalQueue` which is used in notification to driver about the used queue events. +- `rxq`(for receiving) and `txq`(for transmiting) are instances of rust's `Queue` which is present in the `virtio queue` interface. It consist of Descriptor tables, Available Ring, Used Ring. Descriptor contains information of length and address of buffer in the guest address space. +- `tap` is an interface which provides virtual machines access to physical network. + +`iter` of queue consumes over all descriptor heads in queue to return a chain. `DescriptorChain` can be used to parse descriptors provided by the device, which represent input or output memory areas for device I/O. + +## Methods +```rs + pub fn process_rxq(&mut self) -> result::Result<(), Error> +``` +This method invokes `process_tap` methods on self. +
+ +```rs + pub fn process_tap(&mut self) -> result::Result<(), Error> +``` +This method reads frames from the tap into the `rxbuf` of simple_handler object. +
+ +```rs + fn write_frame_to_guest(&mut self) -> result::Result +``` +This method is invoked in `process_tap` method. It iter over the `rxq` to check for descriptors for receving. If found any, frames from `rxbuf` is written to the address space specified by descriptors in the `DescriptionChain`. +
+ +```rs + pub fn process_txq(&mut self) -> result::Result<(), Error> +``` +For transmission, it gets the descriptors chain by iterating over the `txq`. Here the descriptors points the address space containing the frames that needs to be transmitted. It calls `send_frame_from_chain` +
+ +```rs + fn send_frame_from_chain( + &mut self, + chain: &mut DescriptorChain, + ) -> result::Result +``` +It iterates over chain to read data from guest address space into `txbuf`. Using `txbuf` it further writes data into tap device. +
+ +## Resources for more understanding + +- https://github.com/rust-vmm/vm-virtio/blob/main/crates/virtio-queue/README.md + + From f25000b3679bf62356cf6581471f1de1b1239a7a Mon Sep 17 00:00:00 2001 From: Himanshi Ghai <72979568+hghai14@users.noreply.github.com> Date: Sat, 17 Sep 2022 11:48:35 +0530 Subject: [PATCH 2/2] Updates --- Desc-of-SimpleHandler.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Desc-of-SimpleHandler.md b/Desc-of-SimpleHandler.md index 12688e0..0419ceb 100644 --- a/Desc-of-SimpleHandler.md +++ b/Desc-of-SimpleHandler.md @@ -1,8 +1,10 @@ # SimpleHandler -It maintains a pair of queue `RX/TX`. These queues would be used for packets tranfer(communication) between VM and `net` device. This is used along with MMIO between the guest and the devices. +**File Path** - vmm-reference/src/devices/src/virtio/net/simple_handler.rs -It is used in the `QueueHandler` in the net device. +SimpleHandler object maintains a pair of queue `RX/TX`. These queues would be used for packets transfer(communication) between VM and `net` device. These queues facilitate in MMIO between guest and devices. + +SimpleHandler is used in the `QueueHandler` in the net device. ```rs pub struct SimpleHandler { @@ -16,10 +18,10 @@ pub struct SimpleHandler { } ``` - `driver_notify` gets an instance of `SingleFdSignalQueue` which is used in notification to driver about the used queue events. -- `rxq`(for receiving) and `txq`(for transmiting) are instances of rust's `Queue` which is present in the `virtio queue` interface. It consist of Descriptor tables, Available Ring, Used Ring. Descriptor contains information of length and address of buffer in the guest address space. +- `rxq`(for receiving) and `txq`(for transmiting) are instances of rust's `Queue` which is present in the [virtio-queue](https://github.com/rust-vmm/vm-virtio/blob/main/crates/virtio-queue/README.md) interface. It consist of Descriptor tables, Available Ring, Used Ring. Descriptor contains information of length and address of buffer in the guest address space. - `tap` is an interface which provides virtual machines access to physical network. -`iter` of queue consumes over all descriptor heads in queue to return a chain. `DescriptorChain` can be used to parse descriptors provided by the device, which represent input or output memory areas for device I/O. +`iter` method of `Queue` consumes over all descriptor heads in queue to return a chain. `DescriptorChain` can be used to parse descriptors provided by the device, which represent input or output memory areas for device I/O. ## Methods ```rs @@ -37,13 +39,13 @@ This method reads frames from the tap into the `rxbuf` of simple_handler object. ```rs fn write_frame_to_guest(&mut self) -> result::Result ``` -This method is invoked in `process_tap` method. It iter over the `rxq` to check for descriptors for receving. If found any, frames from `rxbuf` is written to the address space specified by descriptors in the `DescriptionChain`. +This method is invoked in `process_tap` method. It iters over the `rxq` to check for descriptors for receving. If found any, frames from `rxbuf` are written to the address space specified by descriptors in the `DescriptionChain`.
```rs pub fn process_txq(&mut self) -> result::Result<(), Error> ``` -For transmission, it gets the descriptors chain by iterating over the `txq`. Here the descriptors points the address space containing the frames that needs to be transmitted. It calls `send_frame_from_chain` +For transmission, it gets the descriptors chain by iterating over the `txq`. Here the descriptors points the address space containing the frames that needs to be transmitted. It then calls `send_frame_from_chain`
```rs @@ -52,11 +54,8 @@ For transmission, it gets the descriptors chain by iterating over the `txq`. Her chain: &mut DescriptorChain, ) -> result::Result ``` -It iterates over chain to read data from guest address space into `txbuf`. Using `txbuf` it further writes data into tap device. +It iterates over chain to read data from guest address space into `txbuf`. Using `txbuf` it further writes data into the tap device.
-## Resources for more understanding - -- https://github.com/rust-vmm/vm-virtio/blob/main/crates/virtio-queue/README.md