Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp534366ybf; Sat, 29 Feb 2020 09:14:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyJjN7JZ2ItxwGobFfsiYJDAJD/7UMP8/Q5l2YbQU25XPEECyLBZ9QC1RF2RjqGLiNOjrG2 X-Received: by 2002:aca:4d47:: with SMTP id a68mr4392496oib.145.1582996471434; Sat, 29 Feb 2020 09:14:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582996471; cv=none; d=google.com; s=arc-20160816; b=M03Iub8+5wqmZsIBZ08D6NY3EkHXSnrMFy947zPaEOmACFbsWgaBrQ1/jbjbjE8AB5 r3UBfJNvFl7UZ0FSemZKZu3FgAQF8MZbY5sT/2R9D0aeMB3JdILh3RDUcEFFWXWJP6hP Mp5A8n3sEICcPGAZ6FenA+J4nY0D4mFtkY3kKglVGBEZdSduTfNYAoPlleaeRAIn8921 2Zx4eOwc4VCtMmZejufC4HbiRa8rKk7C2PUYxYvGJQbZTQlz5N6i7GsXyLoswpUWHDnT crwhQvm9U0kJsv/nUHOGGhSV6rVGX7uF2MytcPThGjofsCtSiQrISPtqs1bxQBYEQd/0 TJlw== 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:dkim-signature; bh=+fIQn9uyVer5wlDY9m6nXs8oyQIBHwFNHtVk99ISOtM=; b=PDXlLGuXqET6Uxua7lmfkRP63lQQnlYZRnewZu06gkT8z13JjjRz2Qi8S7LmvieYJ6 b0mPemcjzu6S32xDNyAR+2rqpEbDVw3s6qxx8tS/oriwQ+rZWk5c4j5YuvumtcZ1MiMo QZS2FPunJrUgEalSynPgMOfBHHygnazltF40bHnNWqxmTdUn1SoZeCHSRwmnllsStKfd ZDBnOD+TxvABD8aF8LB1CS3wlYzv1o9Bwc9UZliPyf8ZpVK+jrNeOXnjavckFGSEnNu9 CaYvMAFZzrlgh+RPrz8HAJwf5B/bflk2+tCZm3XSLpq+5SAjE+sli4eBgHw+vli+ovpS RJhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b=h6R8hIBC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si3730561oie.32.2020.02.29.09.14.17; Sat, 29 Feb 2020 09:14:31 -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; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b=h6R8hIBC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727392AbgB2RNP (ORCPT + 99 others); Sat, 29 Feb 2020 12:13:15 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42014 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbgB2RNO (ORCPT ); Sat, 29 Feb 2020 12:13:14 -0500 Received: by mail-wr1-f65.google.com with SMTP id p18so7174558wre.9 for ; Sat, 29 Feb 2020 09:13:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+fIQn9uyVer5wlDY9m6nXs8oyQIBHwFNHtVk99ISOtM=; b=h6R8hIBCaYjYWedumK3a7C0mS4sgxjN2FwmK9KSRKyMHBFgf/jBkRcjXXQ8zXSP/+9 ofHQgj6esfKap7q0AmD4xfkRcENq1whofrteocJCm90kwTYLiPBRb036b1YVk5oXjIzI JbKre0+Z7TlgcR4cLtdp5NhnqHttcx7TtMF6QNy2Q1GqVHtPAPrM+jyHliqf0yctitw4 r63DhCRx2hGfB15XPPZKpoRpYQQHewIysOC/UyuVqVhozHiAYlmkrp0FwGpV02cNCMpG wNeYr0jTkzU6Yfs+bbkDTMasTGyvosWr1rvRP9cmsnWMwvq/f5Ui08R0OU+NVTOf4jVH WL5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+fIQn9uyVer5wlDY9m6nXs8oyQIBHwFNHtVk99ISOtM=; b=XET0aNJGQJ2wE3q32ozGai2B5qcKj/1QhQdVzMptY618bn14+qyOib03skJFt98GlP Sjk/bFeXQiRp+1U9DqsYsopFkdXdceFhHMsVzfkOVbOmAw5Ro5IhCQlctRcedt0W8XHU GZw5NYzLPJDT6fXIvX6EkoA1nECETtFPObUgwi0ty4qY6QCndZ/LcqH2j5TbrXlAA8jC N/GA5cSoeDMMH9OAuErxbM0UliRdCybUaCkbk0/Nggd6G2s/p/YdmbQ0492Je1WYQC5k ExaY0M9+GXCwJLNndEaD7gUP0n0UN+mARH2cRi5tROwIkklyG5CU/HA05/HQH90scfSr 1jxQ== X-Gm-Message-State: APjAAAXS8djioYIz04RuM6Po0TNPwE9d732/e/VzyByASO6NQMX3uSTe z7ZCRJgCepj/7/R12zQh9y+6Ig== X-Received: by 2002:adf:de0b:: with SMTP id b11mr11109419wrm.89.1582996390949; Sat, 29 Feb 2020 09:13:10 -0800 (PST) Received: from f2.redhat.com (bzq-79-177-42-131.red.bezeqint.net. [79.177.42.131]) by smtp.gmail.com with ESMTPSA id r1sm17045046wrx.11.2020.02.29.09.13.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 29 Feb 2020 09:13:10 -0800 (PST) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: yan@daynix.com Subject: [PATCH 2/3] virtio-net: Introduce RSS receive steering feature Date: Sat, 29 Feb 2020 19:13:00 +0200 Message-Id: <20200229171301.15234-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200229171301.15234-1-yuri.benditovich@daynix.com> References: <20200229171301.15234-1-yuri.benditovich@daynix.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RSS (Receive-side scaling) defines hash calculation rules and decision on receive virtqueue according to the calculated hash, provided mask to apply and provided indirection table containing indices of receive virqueues. The driver sends the control command to enable multiqueue and provide parameters for receive steering. Signed-off-by: Yuri Benditovich --- include/uapi/linux/virtio_net.h | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 6e26a2cc6ad0..7a342657fb6c 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -57,6 +57,7 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device * with the same MAC. @@ -70,6 +71,17 @@ #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ +/* supported/enabled hash types */ +#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) +#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) +#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) + struct virtio_net_config { /* The config defining mac address (if VIRTIO_NET_F_MAC) */ __u8 mac[ETH_ALEN]; @@ -93,6 +105,12 @@ struct virtio_net_config { * Any other value stands for unknown. */ __u8 duplex; + /* maximal size of RSS key */ + __u8 rss_max_key_size; + /* maximal number of indirection table entries */ + __u16 rss_max_indirection_table_length; + /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ + __u32 supported_hash_types; } __attribute__((packed)); /* @@ -236,7 +254,9 @@ struct virtio_net_ctrl_mac { /* * Control Receive Flow Steering - * + */ +#define VIRTIO_NET_CTRL_MQ 4 +/* * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET * enables Receive Flow Steering, specifying the number of the transmit and * receive queues that will be used. After the command is consumed and acked by @@ -249,11 +269,29 @@ struct virtio_net_ctrl_mq { __virtio16 virtqueue_pairs; }; -#define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 +/* + * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as + * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures + * the receive steering to use a hash calculated for incoming packet + * to decide on receive virtqueue to place the packet. The command + * also provides parameters to calculate a hash and receive virtqueue. + */ +struct virtio_net_rss_config { + __virtio32 hash_types; + __virtio16 indirection_table_mask; + __virtio16 unclassified_queue; + __virtio16 indirection_table[1/* + indirection_table_mask*/]; + __virtio16 max_tx_vq; + __u8 hash_key_length; + __u8 hash_key_data[/*hash_key_length*/]; +}; + + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 + /* * Control network offloads * -- 2.17.1