From owner-svn-src-head@freebsd.org Sat Apr 15 08:23:24 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C6EED3C55F; Sat, 15 Apr 2017 08:23:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 49D49E69; Sat, 15 Apr 2017 08:23:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 4C2DF1044DFC; Sat, 15 Apr 2017 18:23:16 +1000 (AEST) Date: Sat, 15 Apr 2017 18:23:15 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: rgrimes@freebsd.org cc: Navdeep Parhar , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r316936 - head/sys/dev/cxgbe/iw_cxgbe In-Reply-To: <201704150727.v3F7Rt9e010658@pdx.rh.CN85.dnsmgr.net> Message-ID: <20170415181258.E1854@besplex.bde.org> References: <201704150727.v3F7Rt9e010658@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=KeqiiUQD c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=XnfSFxyx20jCCp17jlQA:9 a=THTVO4oSvBJ2XBti:21 a=NLJJKto-OsRgpRGp:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Apr 2017 08:23:24 -0000 On Sat, 15 Apr 2017, Rodney W. Grimes wrote: >> On Fri, Apr 14, 2017 at 06:15:10PM -0700, Rodney W. Grimes wrote: >>> [ Charset UTF-8 unsupported, converting... ] >>>> Author: np >>>> Date: Fri Apr 14 19:15:31 2017 >>>> New Revision: 316936 >>>> URL: https://svnweb.freebsd.org/changeset/base/316936 >>>> >>>> Log: >>>> cxgbe/iw_cxgbe: hw supports 64K (not 32K) Protection Domains. >>>> >>>> MFC after: 3 days >>>> Sponsored by: Chelsio Communications >>>> >>>> Modified: >>>> head/sys/dev/cxgbe/iw_cxgbe/t4.h >>>> >>>> Modified: head/sys/dev/cxgbe/iw_cxgbe/t4.h >>>> ============================================================================== >>>> --- head/sys/dev/cxgbe/iw_cxgbe/t4.h Fri Apr 14 18:56:00 2017 (r316935) >>>> +++ head/sys/dev/cxgbe/iw_cxgbe/t4.h Fri Apr 14 19:15:31 2017 (r316936) >>>> @@ -61,7 +61,7 @@ >>>> >>>> #define T4_MAX_NUM_QP (1<<16) >>>> #define T4_MAX_NUM_CQ (1<<15) >>>> -#define T4_MAX_NUM_PD (1<<15) >>>> +#define T4_MAX_NUM_PD 65536 >>> >>> Why the change in methods of expressing powers of 2 here? >>> This, imho, would better match the near by code as >>> #define T4_MAX_NUM_PD (1<<16) >> >> r316940 removed both of the 1<> in this part of the header match nearby code: >> >> #define T4_MAX_NUM_PD 65536 >> #define T4_MAX_EQ_SIZE 65520 >> #define T4_MAX_IQ_SIZE 65520 >> #define T4_MAX_RQ_SIZE(n) (8192 - (n) - 1) > ^^^ unexplained off by 1 Magic??? > > Ok, but why not code those as (1<<16), ((1<<16)-16) to me it makes > it more clear as to what is going on here. I suspect the -16 is > actually sizeof(something). So even more clear is > to do something like: > #define X ((1<<16)-sizeof(somethingXreleated)) > > Magic constants like 65520 that dont even have a comment as to > why they are 65520 are in bad form as well. When the expressions are even slightly complicated, it can be better to have magic numbers (but spell ones near 64K in hex). Try vmparam.h and related files to figure out where basic addresses are. Most are perfectly unreadably parametrized by going through about 5 layers of nested macros leading back to not very many basic parameters. Bruce