From owner-freebsd-net@FreeBSD.ORG Wed Jul 23 12:37:41 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BD71F9E5 for ; Wed, 23 Jul 2014 12:37:41 +0000 (UTC) Received: from mail-pd0-x235.google.com (mail-pd0-x235.google.com [IPv6:2607:f8b0:400e:c02::235]) (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 9571C2630 for ; Wed, 23 Jul 2014 12:37:41 +0000 (UTC) Received: by mail-pd0-f181.google.com with SMTP id g10so1555664pdj.40 for ; Wed, 23 Jul 2014 05:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=ph1QFoHosT/q9GqY5FI7CdsiDSlob+l8phGts95N8Xo=; b=vluhTwocryappYLUMkj2HiqzNzJ1oZjDX7MN5eavsZTJfoxlNf6xIRE/YWtNQ2V22B mPDNiuS+fW9v47dHNjQGnswecriX/WDEmg4mLsSCZRoiA+/KYMVYTG7TshuAWSsZ2Kc+ TMmP3st+KWBuloVAZlyC2Klz88Rp9BnAcNS4UyeouxUu/z7D5CqKJmz0+mPgy4oCThIA AjAOHE/u+8q5SJWPfbsPTi2vxylHSyGM3pUxp6oX2/MQ5RQQqoSfbpWWzHvC52drnRnK aae2nzGXMxGo8HNrxBug9KtbNSJMOntlRW0mLywx1wxngCWLcbzf4YwWXU7fOepYywRg xTDw== X-Received: by 10.68.125.226 with SMTP id mt2mr1428297pbb.6.1406119060975; Wed, 23 Jul 2014 05:37:40 -0700 (PDT) Received: from Peters-MacAir.local ([106.38.204.43]) by mx.google.com with ESMTPSA id b9sm3044867pdo.3.2014.07.23.05.37.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 05:37:40 -0700 (PDT) Message-ID: <53CFAC8F.8090404@gmail.com> Date: Wed, 23 Jul 2014 20:37:35 +0800 From: Xu Zhe User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: Question on rx queue in ixgbe driver Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: Wed, 23 Jul 2014 12:37:41 -0000 Hi, I am reading ixgbe driver of Freebsd and got some problems, which are described below. (1) Why rxd_tail does not equals to rxd_head? Here, rxd_tail/rxd_head is the value of dev.ix.0.queue0.rxd_tail/dev.ix.0.queue0.rxd_head from sysctl (take the first queue of ix0 as example). Actually, in most cases, rxd_head - rxd_tail == 1. Refers to the code, these values are actually next_to_refresh/next_to_check for each receive queue (though the sysctl implementation is read directly from the hardware registers I suppose). Why next_to_refresh is always one smaller than next_to_check (of course, when the latter is 0, the former is 2047 possibly, which is the size of rx ring - 1)? In my point of view, this means that we will always have one tiny mbuf (which is pointed by next_to_refresh) that is already checked (passed up to upper network stack) but not refreshed (not prepared for the next receive). It does not make sense? Or I missed anything important? (2) The init value of rxd_tail Even if (1) has no problem, when ixgbe device is inited, rxd_tail (or say, next_to_refresh) is set to zero (in function ixgbe_setup_receive_ring). I think it should be rxr->num_desc - 1. This should not matter much in the latest ixgbe driver, but it might cause old driver (ixgbe 2.5.8 at least) to double init the rx_ring descriptors (both in ixgbe_setup_receive_ring when ixgbe init up, and the first entry of ixgbe_refresh_mbufs of the first interrupt come). This is a case I met in my test environment. ========== Looking forward to any of your replies to help clarify my thoughts. Thanks in advance. Peter