From owner-freebsd-net@FreeBSD.ORG Mon Aug 11 18:27:27 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 94AE2AD8 for ; Mon, 11 Aug 2014 18:27:27 +0000 (UTC) Received: from mail-qg0-x22d.google.com (mail-qg0-x22d.google.com [IPv6:2607:f8b0:400d:c04::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 526AF2FF2 for ; Mon, 11 Aug 2014 18:27:27 +0000 (UTC) Received: by mail-qg0-f45.google.com with SMTP id f51so8745879qge.32 for ; Mon, 11 Aug 2014 11:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=OTHAGzKtSRgs/rv+efJJCe6336hpo/TLjtDUocAa73U=; b=uCRQxrg9Q4MllEczT9881d3DYZKjQu4Aiwc8yUNcj71Fh+5AbaQLwzPypCzev0QHpM CvBUOPsMYZAOmHunfBc0PCxFWi87vuPD6fIra2G5na3H9Jxg7ydvHlZO0Wfsjz6oZ0SY jmwnlNKYhFss0DiOrHp6ysb28eWs3VFOB51shWyeO+dnerQTD9v4h/ixEKvaT9dd0Fr+ D42zfF1ffudKWhNdEjUiOaFtisrhVL0FsZBvR1Y1lS1ZzvbtrL7ECD3J839ZbNHhnOhH CR1nT8i7FbW89zXQT4J8z7JyRDJaPtVYTIFEYCHfWPEOkxm8uvyHe6RNlPFvmbVscUHq kttw== MIME-Version: 1.0 X-Received: by 10.224.0.141 with SMTP id 13mr66589004qab.26.1407781646212; Mon, 11 Aug 2014 11:27:26 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.224.41.6 with HTTP; Mon, 11 Aug 2014 11:27:26 -0700 (PDT) In-Reply-To: References: <184b69414bd246eeacc0d4234a730f2f@BY1PR0301MB0902.namprd03.prod.outlook.com> Date: Mon, 11 Aug 2014 11:27:26 -0700 X-Google-Sender-Auth: ADlHDhCYsBf4RHQ3q73VSraYYj8 Message-ID: Subject: Re: vRSS support on FreeBSD From: Adrian Chadd To: Wei Hu Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-net@freebsd.org" , "d@delphij.net" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Aug 2014 18:27:27 -0000 On 11 August 2014 02:48, Wei Hu wrote: > CC freebsd-net@ for wider discussion. > > Hi Adrian, > > Many thanks for the explanation. I checked the if_igb.c and found the f= lowid field was set in the RX side in igb_rxeof(): > > Igb_rxeof() > { > ... > #ifdef RSS > /* XXX set flowtype once this works right */ > rxr->fmp->m_pkthdr.flowid =3D > le32toh(cur->wb.lower.hi_dword.rss); > rxr->fmp->m_flags |=3D M_FLOWID; > ... > } > > I have two questions regarding this. > > 1. Is the RSS hash value stored in cur->wb.lower.hi_dword.rss set by the = NIC hardware? Yup. > 2. So the hash value and m_flags are stored in the mbuf related to the re= ceived packet on the rx side(lgb_rxeof()). But we check the hash value and = m_flags in mbuf related to the send packet on the tx side (in igb_mq_start(= )). Does the kernel re-use the same mbuf for tx? If so, how does it know fo= r the same network stream it should use the same mbuf got from the rx for p= acket sending? If not, how does the kernel preserve the same hash value acr= oss the rx mbuf and tx mbuf for same network stream? This seems quite magic= al to me. The mbuf flowid/flowtype ends up in the inpcb->inp_flowid / inpcb->inp_flowtype as part of the TCP receive path. Then whenever the TCP code outputs an mbuf, it copies the inpcb flow details out to outbound mbufs. > > For the Hyper-V case, the host controls which vCPU it wants to interrupt.= And the rule can change dynamically based on the load. For a non-busy VM, = host will send most packets to same vCPU for power saving purpose. For a bu= sy VM, host will distribute the packets evenly across all vCPUs. This means= host could change the RSS bucket mapping dynamically. Hyper-V does this by= sending a mapping table to VM whenever the it needs update. This also mean= s we cannot use FreeBSD's own bucket mapping which I believe is fixed. Also= Hyper-V use its own hash key. So do you think it is possible we still use = the exisiting RSS infrastructure built in FreeBSD in this purpose? Eventually. Doing rebalancing in RSS is on the TODO list, after I get the rest of the basic packet handling / routing done. How's vRSS notify the VM that the mapping table has changed? What's the format of it look like? -a