From patchwork Tue Jul 25 20:05:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 793606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="De+Bnll4"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xH8Pb010Wz9sN7; Wed, 26 Jul 2017 06:05:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1da65Y-0002z8-BB; Tue, 25 Jul 2017 20:05:52 +0000 Received: from mail-qt0-f182.google.com ([209.85.216.182]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1da65Q-0002wc-4T for kernel-team@lists.ubuntu.com; Tue, 25 Jul 2017 20:05:44 +0000 Received: by mail-qt0-f182.google.com with SMTP id s6so45224988qtc.1 for ; Tue, 25 Jul 2017 13:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=b6/N1PXDxVPJL5fZ4OQnUM+DvZeLvHwvCzeEN+aH5KU=; b=De+Bnll4/7HC0FGAt2vDrQD6iqXbNDt6Raya9xzNdHQ0hm4aEm4UTmdJ6TQCJ1jSnK TwYG3qPSMiP3Y1wn+VPQmp0s3oQn+mRROs5zsCl7RO5ou6FHfzct2wfXvwtw7CFZdHtA DYrpxPucFbAabEeMaYr+GdfwOXBB+90upQh9BugtLIcarBgt29XkeiKfgNRz3q1DJs+I JX2m38pqNQzalzVzEROYhppMBX+hsv5ely7pZr4wf5+8dSQ59OUC917IEGbbSHPDa0t0 SzrORW6z8zxQzOCNFBxyXrJn7cPMer+V6AbIhDMwFC2xJ/ckJsN6hNJ+qPoyKiHLdfdP 7bxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=b6/N1PXDxVPJL5fZ4OQnUM+DvZeLvHwvCzeEN+aH5KU=; b=imBBz65FrxHrC6ho6n+VxJWjhwSF8uxEUxutqPea5nwjHKvtpO091vqGTO6duz9lFr NwsQ8yXgENh+06HlH21r2ZFXfatzJsVqp6tNpoQ1+3fnsUW5dCOgn/6ectCntwHXaBC0 EgQyPCa5iSLPOfBQ9vHQe4yEN1qNCNjsEghyM4i6RhKsjWoGmPKM4xdUJWqrFSxnSHaN 34F+LULTjeIKxZbquMhyVNdL8ydjD7w8kQskNTwYK6FUXogqOWLvhHG9yymMxiycS9sU b/EjVj7moiPIEBr2tPc6qj0+oKHibxSs7aej2e5KCny83EhQqIdnIWSZiGZtaVkP9a0m QBeA== X-Gm-Message-State: AIVw112/esIZd47XXMUBB8BUHa4frpVxpCbEL2C4yvKBOBEO5ctfSFlY /pvDkMSmW19j4XkCZes= X-Received: by 10.200.4.39 with SMTP id v39mr28099189qtg.335.1501013142799; Tue, 25 Jul 2017 13:05:42 -0700 (PDT) Received: from localhost.localdomain ([177.68.187.26]) by smtp.gmail.com with ESMTPSA id v3sm9390142qth.37.2017.07.25.13.05.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 13:05:42 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure][PATCH] hv_netvsc: Exclude non-TCP port numbers from vRSS hashing Date: Tue, 25 Jul 2017 17:05:33 -0300 Message-Id: <1501013133-26889-2-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501013133-26889-1-git-send-email-marcelo.cerri@canonical.com> References: <1501013133-26889-1-git-send-email-marcelo.cerri@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1690174 Azure hosts are not supporting non-TCP port numbers in vRSS hashing for now. For example, UDP packet loss rate will be high if port numbers are also included in vRSS hash. So, we created this patch to use only IP numbers for hashing in non-TCP traffic. Signed-off-by: Haiyang Zhang Reviewed-by: Stephen Hemminger Signed-off-by: David S. Miller (cherry picked from commit f72860afa2e32cdc674cbdd7f354f8fb62e908a6) Signed-off-by: Marcelo Henrique Cerri Acked-by: Stefan Bader Acked-by: Marcelo Henrique Cerri --- drivers/net/hyperv/netvsc_drv.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 68a9b8bf5eb6..43b838c863cb 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -191,6 +191,36 @@ static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size, return ppi; } +/* Azure hosts don't support non-TCP port numbers in hashing yet. We compute + * hash for non-TCP traffic with only IP numbers. + */ +static inline u32 netvsc_get_hash(struct sk_buff *skb, struct sock *sk) +{ + struct flow_keys flow; + u32 hash; + static u32 hashrnd __read_mostly; + + net_get_random_once(&hashrnd, sizeof(hashrnd)); + + if (!skb_flow_dissect_flow_keys(skb, &flow, 0)) + return 0; + + if (flow.basic.ip_proto == IPPROTO_TCP) { + return skb_get_hash(skb); + } else { + if (flow.basic.n_proto == htons(ETH_P_IP)) + hash = jhash2((u32 *)&flow.addrs.v4addrs, 2, hashrnd); + else if (flow.basic.n_proto == htons(ETH_P_IPV6)) + hash = jhash2((u32 *)&flow.addrs.v6addrs, 8, hashrnd); + else + hash = 0; + + skb_set_hash(skb, hash, PKT_HASH_TYPE_L3); + } + + return hash; +} + static inline int netvsc_get_tx_queue(struct net_device *ndev, struct sk_buff *skb, int old_idx) { @@ -198,7 +228,7 @@ static inline int netvsc_get_tx_queue(struct net_device *ndev, struct sock *sk = skb->sk; int q_idx; - q_idx = ndc->tx_send_table[skb_get_hash(skb) & + q_idx = ndc->tx_send_table[netvsc_get_hash(skb, sk) & (VRSS_SEND_TAB_SIZE - 1)]; /* If queue index changed record the new value */