From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B884429AA; Fri, 21 Apr 2023 10:47:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D09742D62; Fri, 21 Apr 2023 10:46:24 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 6196342D16 for ; Fri, 21 Apr 2023 10:46:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682066780; x=1713602780; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d1xR7S990AdEi3exqcwT8dyyEWyM85AY8GpZU7bWuMc=; b=isOHDzyK4H11HZrPQ1MBOjscACXugGmEV2z88DqILeQMO1gO3iY4DWJ6 76pXYVZ1FLU6zAaumNmCAhqinoNbwZMOc05AgTYjN10evjP61+pMt9boO tHjidqb4T1wzfmicfmXwuUXK2HmTT+xKR1KeWd+28r1GIzb8oSBXJh6bb 8srcVuef6cq3y+w0hLgVF5iNlzYJ3BLDTVFHXvzJQm9ZzOcIAmrJ1dUlO VDqsRSs+Fll7HGoc5/X1PeVChKENaKUgOjRbuuEIvjF8fEOFttXP++4Et Er1szxITw7z294trpDbP7mFae4s5fMXn+lh+eudtLJV2ui+tsNgcilLFw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="334822906" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="334822906" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 01:46:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="761501513" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="761501513" Received: from dpdk-wenjing-01.sh.intel.com ([10.67.118.239]) by fmsmga004.fm.intel.com with ESMTP; 21 Apr 2023 01:46:18 -0700 From: Wenjing Qiao To: jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com Cc: dev@dpdk.org, Wenjing Qiao , Christopher Pau Subject: [PATCH v2 11/15] common/idpf: allocate static buffer at initialization Date: Fri, 21 Apr 2023 04:40:39 -0400 Message-Id: <20230421084043.135503-12-wenjing.qiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421084043.135503-1-wenjing.qiao@intel.com> References: <20230413094502.1714755-2-wenjing.qiao@intel.com> <20230421084043.135503-1-wenjing.qiao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Some OSs don't allow allocating DMA memory at runtime. So create an initial static buffer at initialization to hold this data. Signed-off-by: Christopher Pau Signed-off-by: Wenjing Qiao --- drivers/common/idpf/base/idpf_common.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/common/idpf/base/idpf_common.c b/drivers/common/idpf/base/idpf_common.c index de82c3458f..f4a5707272 100644 --- a/drivers/common/idpf/base/idpf_common.c +++ b/drivers/common/idpf/base/idpf_common.c @@ -6,6 +6,7 @@ #include "idpf_prototype.h" #include "virtchnl.h" +struct idpf_dma_mem send_dma_mem = { 0 }; /** * idpf_set_mac_type - Sets MAC type @@ -132,6 +133,15 @@ int idpf_init_hw(struct idpf_hw *hw, struct idpf_ctlq_size ctlq_size) idpf_free(hw, q_info); + /* + * Need an initial static buffer to copy DMA memory to send + * for drivers that do not allow this allocation at runtime + */ + send_dma_mem.va = (struct idpf_dma_mem *) + idpf_alloc_dma_mem(hw, &send_dma_mem, 4096); + if (!send_dma_mem.va) + return -ENOMEM; + return 0; } @@ -152,7 +162,6 @@ int idpf_send_msg_to_cp(struct idpf_hw *hw, int v_opcode, int v_retval, u8 *msg, u16 msglen) { struct idpf_ctlq_msg ctlq_msg = { 0 }; - struct idpf_dma_mem dma_mem = { 0 }; int status; ctlq_msg.opcode = idpf_mbq_opc_send_msg_to_pf; @@ -162,19 +171,11 @@ int idpf_send_msg_to_cp(struct idpf_hw *hw, int v_opcode, ctlq_msg.cookie.mbx.chnl_opcode = v_opcode; if (msglen > 0) { - dma_mem.va = (struct idpf_dma_mem *) - idpf_alloc_dma_mem(hw, &dma_mem, msglen); - if (!dma_mem.va) - return -ENOMEM; - - idpf_memcpy(dma_mem.va, msg, msglen, IDPF_NONDMA_TO_DMA); - ctlq_msg.ctx.indirect.payload = &dma_mem; + idpf_memcpy(send_dma_mem.va, msg, msglen, IDPF_NONDMA_TO_DMA); + ctlq_msg.ctx.indirect.payload = &send_dma_mem; } status = idpf_ctlq_send(hw, hw->asq, 1, &ctlq_msg); - if (dma_mem.va) - idpf_free_dma_mem(hw, &dma_mem); - return status; } @@ -262,6 +263,9 @@ int idpf_clean_arq_element(struct idpf_hw *hw, */ int idpf_deinit_hw(struct idpf_hw *hw) { + if (send_dma_mem.va) + idpf_free_dma_mem(hw, &send_dma_mem); + hw->asq = NULL; hw->arq = NULL; -- 2.25.1