From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 704533798 for ; Tue, 29 Aug 2017 18:12:18 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 29 Aug 2017 09:12:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,445,1498546800"; d="scan'208";a="123703145" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by orsmga004.jf.intel.com with ESMTP; 29 Aug 2017 09:12:16 -0700 To: Ajit Khaparde , dev@dpdk.org References: <20170824162956.62761-1-ajit.khaparde@broadcom.com> <20170824162956.62761-9-ajit.khaparde@broadcom.com> From: Ferruh Yigit Message-ID: <939529d4-6cf4-381c-7f22-8d8881da33fb@intel.com> Date: Tue, 29 Aug 2017 17:12:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170824162956.62761-9-ajit.khaparde@broadcom.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 7/8] net/bnxt: fix HWRM_*() macros and locking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Aug 2017 16:12:18 -0000 On 8/24/2017 5:29 PM, Ajit Khaparde wrote: > Obtain the spinlock in HWRM_PREP() > Eliminate two unnecessary arguments in HWRM_PREP(). > Unlock the spinlock before returning in HWRM_ERROR_CHECK() > Add new HWRM_UNLOCK() macro > Update usage of the thre macros. > > Signed-off-by: Ajit Khaparde <...> > -#define HWRM_PREP(req, type, cr, resp) \ > +/* > + * HWRM_PREP() should be used to prepare *ALL* HWRM commands. It grabs the > + * spinlock, and does initial processing. > + * > + * HWRM_CHECK_RESULT() returns errors on failure and may not be used. It > + * releases the spinlock only if it returns. If the regular int return codes > + * are not used by the function, HWRM_CHECK_RESULT() should not be used > + * directly, rather it should be copied and modified to suit the function. > + * > + * HWRM_UNLOCK() must be called after all response processing is completed. > + */ > +#define HWRM_PREP(x, type) do { \ > + typeof(x) req = (x); \ > + rte_spinlock_lock(&bp->hwrm_lock); \ > memset(bp->hwrm_cmd_resp_addr, 0, bp->max_resp_len); \ > req.req_type = rte_cpu_to_le_16(HWRM_##type); \ > - req.cmpl_ring = rte_cpu_to_le_16(cr); \ > + req.cmpl_ring = rte_cpu_to_le_16(-1); \ > req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); \ > req.target_id = rte_cpu_to_le_16(0xffff); \ > - req.resp_addr = rte_cpu_to_le_64(bp->hwrm_cmd_resp_dma_addr) > + req.resp_addr = rte_cpu_to_le_64(bp->hwrm_cmd_resp_dma_addr); \ > +} while (0) > <...> > - HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp); > + HWRM_PREP(req, CFA_L2_SET_RX_MASK); Getting following build error [1] many times with clang (and icc). I guess this is because using variable name in macro itself. [1] .../drivers/net/bnxt/bnxt_hwrm.c:235:12: error: variable 'req' is uninitialized when used within its own initialization [-Werror,-Wuninitialized] HWRM_PREP(req, CFA_L2_SET_RX_MASK); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ .../drivers/net/bnxt/bnxt_hwrm.c:186:19: note: expanded from macro 'HWRM_PREP' typeof(x) req = (x); \ ~~~ ^