Ethtool Support for Microsoft Hyper-V

Ethtool Support for Microsoft Hyper-V is a programming project to implement support of the Linux command-line application "ethtool" on virtual machine guests of the Microsoft Hyper-V hypervisor. Ethtool is used to query and control network driver and hardware settings. Enabling support requires patching the virtual network driver in the Linux kernel.

Problem Statement
Ethtool is a command-line utility for Linux-kernel based operated systems, maintained in parallel with the kernel. Ethtool is primarily used by system administrators to query and/or set network driver variables such as link status, number of send and receive queues of vRSS, size of send and receive buffers, available features, and gathered statistics.

The network driver used by Linux virtual machines running on Microsoft Hyper-V minimally supports ethtool; it can return the name of the driver, "hv_netvsc," and the permanent address of the network device. All Linux-supported network drivers are responsible for implementing the ethtool API. The goal of this project is to implement support for all common uses of ethtool.

Background
A common scenario for system administrators is to host multiple virtual machines on the same piece of hardware, so one physical computer and its host operating system can support many guest computers, each with its own operating system. This process of "virtualization" is dependent on an abstraction layer called a hypervisor. Microsoft's solution is a native hypervisor, Microsoft Hyper-V, included in most versions of Microsoft Windows. A native hypervisor runs directly on the host's hardware, in contrast to a hosted hypervisor which runs on the host's operating system, so the former has fewer layers of translation for guest operating system instructions.

Specifications
Since the guest operating systems are separate from the host operating system, a host machine running Windows with Hyper-V supports guests running Linux (as well as Windows). Linux supports being run as a guest operating system on a hypervisor through virtual drivers for the guest's virtual hardware, including video, storage, keyboard, mouse and networking. These drivers are a part of the Linux kernel, and are maintained by our client, the Microsoft Linux Integration Services team. We are concerned with the virtual network driver, netvsc.

Design
Ethtool is a mature application and its programming interface in the kernel is well-established. In general, adding support for each ethtool operation requires patching netvsc with the appropriate new callback for the operation and any additional necessary changes.

Goals
Our current goal is to implement support for the following ethtool operations:

Implementation
Our work in progress is tracked on our issues page.

Currently, we have implemented the show-channels operation. Our patch was signed-off by Haiyang Zhang, and applied to the net-next kernel tree by Dave Miller. The patch was commited and is now in the development version of the Linux kernel.

Our next goal is to implement the set-channels operation. We several issues to finalize before our final patch submission. These issues include:

Testing
Testing patches to a virtual network driver on a Linux machine is a tedious process. It requires direct access to a host machine running Windows with Hyper-V, and a Linux virtual machine for development and testing. When testing the network driver your machine is dependent on, if your patch causes the driver to break, direct access through the console is needed to debug, as network access will be disabled.

Additionally, developing Linux kernel patches requires configuring and installing the correct development version of the Linux kernel to the test machine. For networking drivers, we work off Dave Miller's net-next tree. Our team primarily develops on CentOS 7 virtual machines, since installing a locally compiled kernel is made relatively easy with the kernel build system's creation of a native package.

We wrote a Linux development compilation reference guide for each time test machine we setup.

Our normal workflow is to develop on a local clone of the kernel tree, and then push the patch to our test machine, where we can compile and install the patched netvsc module. When our patch breaks, we use the Remote Desktop Protocol to connect to the host Windows machine, to then use the Hyper-V manager's to connect to the Linux virtual machine without requiring the guest's networking to be operational. Further debugging is done through liberal use of printk, the kernel's version of printf for printing out debug information.

Testing the patches under load requires an extensive hardware setup: a Windows Server 2012 R2 machine running Hyper-V, with a 1 Gbps network adapter which supports Receive Side Scaling, so that the virtual machines can use virtual RSS. This resource is currently being provisioned.

get-channels

 * From: Andrew Schwartzmeyer 
 * Date: Wed, 25 Feb 2015 19:49:24 -0800
 * Subject: [PATCH net-next] hyperv: Implement netvsc_get_channels ethool op

This adds support for reporting the actual and maximum combined channels count of the hv_netvsc driver via 'ethtool --show-channels'.

This required adding 'max_chn' to 'struct netvsc_device', and assigning it 'rsscap.num_recv_que' in 'rndis_filter_device_add'. Now we can access the combined maximum channel count via 'struct netvsc_device' in the ethtool callback.

Signed-off-by: Andrew Schwartzmeyer 

set-channels
From aecd06e665323c07aae18ca9f394a4de282a12c3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer  Date: Mon, 27 Apr 2015 22:45:18 -0700 Subject: [PATCH net-next] hyperv: Implement netvsc_set_channels ethtool op

rndis_filter_device_add struct device_info, else use num_cpus
 * Remove and add RNDIS device with new channel count
 * Added num_chn to struct device_info so it can be passed to
 * Initialize device_info to 0 always
 * Set num_chan in rndis_filter_device_add when passed via
 * Add local u32 num_chan to rndis_filter_device_add for shorter name
 * Declare netvsc_link_change
 * Check that NVSP version is at least 5
 * Check given combined count against bounds [1, num_online_cpus]
 * Use num_online_cpus if given count is too high (and log a notice)
 * Check return values of netif set tx/rx queues
 * Attempt to recover RNDIS if it fails with new setting

Signed-off-by: Andrew Schwartzmeyer 

Expo Deliverables
Here are the following deliverables for the 22nd Annual Senior Design Expo:

Andrew Schwartzmeyer
Computer Science and Mathematics Student

Hometown: Seattle, WA

Bio: Andrew is a senior undergraduate student in Computer Science and Mathematics at the University of Idaho. He is the current chair of the University of Idaho Association of Computing Machinery, and an avid open source developer. He blogs at schwartzmeyer.com, and is interested in Linux systems programming, evolutionary computation, security and cryptography, server administration automation (with Puppet), and functional programming.

Email: [mailto:schw2620@vandals.uidaho.edu schw2620@vandals.uidaho.edu]



Justin Hall
Computer Science Student

Hometown: Lewiston, ID

Bio: Justin is a senior in Computer Science at the University of Idaho, currently pursuing his Bachelors of Science. He spends summers as a freelance front-end Javascript developer, particularly the AngularJS framework. His interests focus on front-end and full-stack web development.

Email: [mailto:hall5714@vandals.uidaho.edu hall5714@vandals.uidaho.edu]



Keith Drew
Computer Science Student

Hometown: Olympia, Washington

Bio: Keith is a senior undergraduate student in Computer Science at the University of Idaho. He is also a NSF Scholarship for Service (SFS) CyberCorps Student. He is interested cyber security, specifically secure programming.

Email: [mailto:keithd@vandals.uidaho.edu keithd@vandals.uidaho.edu]



Eric Doman
Computer Science Student

Hometown: St. Maries, Idaho

Bio: Eric is a senior undergraduate student in Computer Science at the University of Idaho. He is a member of the University of Idaho Association of Computing Machinery. He is interested in computer graphics and visualization. In his free time, Eric enjoys running and playing soccer.

Email: [mailto:doma8101@vandals.uidaho.edu doma8101@vandals.uidaho.edu]



Chris Waltrip (Fall 2014)
Computer Science Student

Hometown: Coeur d'Alene, ID

Bio: Chris is a senior undergraduate in Computer Science at the University of Idaho. He is also a NSF Scholarship for Service (SFS) CyberCorps Student and system administrator for the Center for Secure and Dependable Systems (CSDS). His interests lie in information assurance and network security.

Email: [mailto:walt2178@vandals.uidaho.edu walt2178@vandals.uidaho.edu]

Other Links

 * Linux Kernel in a Nutshell
 * Linux Kernel Coding Style
 * netdev FAQ
 * Linux Kernel Hacking
 * Guide to building the Linux kernel
 * Linux Kernel Debugging
 * Linux Kernel Hacking Tools
 * Build Your Own Kernel Modules