From patchwork Tue Mar 10 15:31:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 45588 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BED29214BF for ; Tue, 10 Mar 2015 15:32:13 +0000 (UTC) Received: by lbdu14 with SMTP id u14sf2060390lbd.3 for ; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=mFgfeSW/Ec/NopoFC9YtwEBgtoxczDLcaercTH+9xak=; b=SRScxXI/TXjHPxpExaS/bdAuvrVgbMzUsxzg6aFiJGZPKqEsXpsFmlcqsvBSKrVvIR 7ywBekgHtLj+W/QdVTLj84A+fumlf67/BzZ5eyRjLYsDpyDjDRrwBmBZYxORc71L6wVq Pq+lQWDgTV3HGwtsj/LedERFvfw1Hk9h9n/OdjNQEv2XD3yvvL3XPC7QOxCqSgGj4PmI JddUDbk9H9D6tdXmI70trbTVP7IYGEEIdmYYEUOvDUo7KsdDnbVRY8z6a9+y6e0GEvHB 99x79PlSg0nUpBfHfaNJKdsFzKzMxzZKY1gbGLYwUQtZuGGSI2FHXpOsUwcxafaF6gLZ 3C+Q== X-Gm-Message-State: ALoCoQmHbWAjTAazJM/oTRrwXdYDK4J5x6UWZPU/CeyUszpIfd7uWkDuQsD4F4gPU0zghYqfGvPS X-Received: by 10.194.161.194 with SMTP id xu2mr4804316wjb.1.1426001532676; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.116 with SMTP id jv20ls41170lab.34.gmail; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) X-Received: by 10.112.67.107 with SMTP id m11mr6177456lbt.43.1426001532367; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id kv4si536051lbb.102.2015.03.10.08.32.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 08:32:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbiz12 with SMTP id z12so2519163lbi.12 for ; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) X-Received: by 10.112.130.195 with SMTP id og3mr30453259lbb.112.1426001532257; Tue, 10 Mar 2015 08:32:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2206789lbj; Tue, 10 Mar 2015 08:32:11 -0700 (PDT) X-Received: by 10.140.48.133 with SMTP id o5mr41461639qga.8.1426001524414; Tue, 10 Mar 2015 08:32:04 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id f193si537104qka.36.2015.03.10.08.32.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 10 Mar 2015 08:32:04 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVM8W-0003tN-IH; Tue, 10 Mar 2015 15:32:00 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVM84-0003p7-Kw for lng-odp@lists.linaro.org; Tue, 10 Mar 2015 15:31:32 +0000 Received: by labge10 with SMTP id ge10so2082748lab.10 for ; Tue, 10 Mar 2015 08:31:27 -0700 (PDT) X-Received: by 10.152.198.203 with SMTP id je11mr23168217lac.85.1426001486877; Tue, 10 Mar 2015 08:31:26 -0700 (PDT) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id a2sm106609lbm.32.2015.03.10.08.31.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Mar 2015 08:31:25 -0700 (PDT) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Tue, 10 Mar 2015 17:31:05 +0200 Message-Id: <1426001473-14618-8-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426001473-14618-1-git-send-email-taras.kondratiuk@linaro.org> References: <1426001473-14618-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Cc: Taras Kondratiuk Subject: [lng-odp] [KEYSTONE2 PATCH 07/15] linux-ks2: init: implement McSDK termination X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Taras Kondratiuk Signed-off-by: Taras Kondratiuk --- platform/linux-keystone2/include/odp/plat/state.h | 2 + .../linux-keystone2/include/odp/plat/ti_mcsdk.h | 6 +- platform/linux-keystone2/mcsdk/mcsdk_init.c | 140 ++++++++++++++------- platform/linux-keystone2/mcsdk/mcsdk_navig.c | 35 ++++++ platform/linux-keystone2/odp_init.c | 5 +- 5 files changed, 136 insertions(+), 52 deletions(-) diff --git a/platform/linux-keystone2/include/odp/plat/state.h b/platform/linux-keystone2/include/odp/plat/state.h index 63428cb..0f8304a 100644 --- a/platform/linux-keystone2/include/odp/plat/state.h +++ b/platform/linux-keystone2/include/odp/plat/state.h @@ -25,6 +25,7 @@ struct odp_global_s { nwal_Inst handle; /**< NWAL handle */ Pktlib_HeapHandle sa2pa_heap; /**< Internal SA->PA heap */ Pktlib_HeapHandle pa2sa_heap; /**< Internal PA->SA head */ + nwalGlobCxtInfo_t info; /**< NWAL global info */ } nwal; /**< Global NWAL state */ Qmss_MemRegion public_desc_memregion; }; @@ -35,6 +36,7 @@ struct odp_proc_s { Pktlib_HeapHandle netcp_heap; /**< internal default heap */ Pktlib_HeapHandle netcp_control_rx_heap; /**< rx control messages */ Pktlib_HeapHandle netcp_control_tx_heap; /**< tx control messages */ + void *context_buffer; /**< NWAL internal process context */ } nwal; /**< Per process NWAL state */ Rm_ServiceHandle *rm_service; /**< Resource Manager service handle */ void *descriptor_mem_base; diff --git a/platform/linux-keystone2/include/odp/plat/ti_mcsdk.h b/platform/linux-keystone2/include/odp/plat/ti_mcsdk.h index b8e002a..d0bc5af 100644 --- a/platform/linux-keystone2/include/odp/plat/ti_mcsdk.h +++ b/platform/linux-keystone2/include/odp/plat/ti_mcsdk.h @@ -27,7 +27,6 @@ extern "C" { /** @internal McSDK initialization configuration */ struct mcsdk_cfg_s { int def_mem_size; /**< Bytes of CMA memory we have allocated */ - int min_buf_headroom_size; /**< Minimal amount of headroom in a buffer */ int def_max_descriptors; /**< Number of descriptors in system (must be power of 2), 2^14 max */ int def_tot_descriptors_for_us; /**< Number of descriptors to create in our region (must be power of 2)*/ int def_heap_n_descriptors; /**< Number of descriptor plus buffers in default heap*/ @@ -40,17 +39,22 @@ struct mcsdk_cfg_s { Rm_ServiceHandle *rm_client_init(void); int mcsdk_global_init(void); +int mcsdk_global_term(void); int mcsdk_local_init(int thread_id); int mcsdk_cppi_init(void); int mcsdk_qmss_init(int max_descriptors); int mcsdk_qmss_start(void); +int mcsdk_qmss_exit(void); int mcsdk_cppi_start(void); +int mcsdk_cppi_exit(void); int mcsdk_qmss_setup_memregion(uint32_t desc_num, uint32_t desc_size, uint32_t *desc_mem_base); +int mcsdk_qmss_remove_memregion(void); int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table); int mcsdk_nwal_start(Pktlib_HeapHandle pkt_heap, Pktlib_HeapHandle cmd_rx_heap, Pktlib_HeapHandle cmd_tx_heap); +int mcsdk_delete_heap(Pktlib_HeapHandle heap); extern Pktlib_HeapIfTable pktlib_if_table; extern hplib_virtualAddrInfo_T odp_vm_info; diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c b/platform/linux-keystone2/mcsdk/mcsdk_init.c index 2c1407a..d7b5406 100644 --- a/platform/linux-keystone2/mcsdk/mcsdk_init.c +++ b/platform/linux-keystone2/mcsdk/mcsdk_init.c @@ -39,7 +39,6 @@ struct mcsdk_cfg_s default_mcsdk_cfg = { .def_heap_buf_size = TUNE_NETAPI_DEFAULT_BUFFER_SIZE, .def_heap_tailroom_size = 0, .def_heap_extra_size = 0, - .min_buf_headroom_size = ODP_CACHE_LINE_SIZE, }; /** @@ -108,9 +107,7 @@ static uint8_t *cma_mem_alloc(uint32_t size) static void cma_mem_free(uint8_t *ptr ODP_UNUSED, uint32_t size ODP_UNUSED) { - /* Do Nothing. */ - odp_pr_err("need to provide a free () for some reason!!\n"); - return; + hplib_vmMemFree(ptr, size + odp_global->cfg.def_heap_extra_size, 0); } /******************************************************************** @@ -263,57 +260,42 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) count = 0; bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)nwal_entry->nwal_inst_mem); - if (NWAL_CONFIG_BUFSIZE_HANDLE < sizes[nwal_BUF_INDEX_INST]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CONFIG_BUFSIZE_HANDLE >= sizes[nwal_BUF_INDEX_INST], + "Not enough space"); count++; bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)nwal_entry->nwal_handle_mem); - if (NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CHAN_HANDLE_SIZE >= sizes[nwal_BUF_INDEX_INT_HANDLES], + "Not enough space"); count++; bases[nwal_BUF_INDEX_PA_LLD_BUF0] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)pa_entry->pa_buf0); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CONFIG_BUFSIZE_PA_BUF0 >= + sizes[nwal_BUF_INDEX_PA_LLD_BUF0], + "Not enough space"); count++; bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)pa_entry->pa_buf1); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CONFIG_BUFSIZE_PA_BUF1 >= + sizes[nwal_BUF_INDEX_PA_LLD_BUF1], + "Not enough space"); count++; bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)pa_entry->pa_buf2); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CONFIG_BUFSIZE_PA_BUF2 >= + sizes[nwal_BUF_INDEX_PA_LLD_BUF2], + "Not enough space"); count++; #ifdef NETAPI_ENABLE_SECURITY bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)sa_entry->salld_handle); - if ((NWAL_CONFIG_BUFSIZE_SA_HANDLE) - < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT(NWAL_CONFIG_BUFSIZE_SA_HANDLE >= + sizes[nwal_BUF_INDEX_SA_LLD_HANDLE], + "Not enough space"); count++; bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr( @@ -325,13 +307,10 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr( (uint32_t)sa_entry->salld_chan_handle); - if ((NWAL_CONFIG_BUFSIZE_SA_HANDLE_PER_CHAN - * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS * 2) - < sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]) { - /* Resize Memory */ - while (1) - ; - } + ODP_ASSERT((NWAL_CONFIG_BUFSIZE_SA_HANDLE_PER_CHAN + * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS * 2) >= + sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE], + "Not enough space"); count++; #else bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = 0; @@ -339,10 +318,7 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0; count = count+3; #endif - if (count != nwal_N_BUFS) { - while (1) - ; - } + ODP_ASSERT(count == nwal_N_BUFS, "count == nwal_N_BUFS"); nwal_getLocContextBufferReq(nwal_size_info.nProc, &local_ctx_size); nwal_loc_ctx_mem = malloc(local_ctx_size); @@ -350,6 +326,7 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) odp_pr_err("Couldn't allocate NWAL local contex\n"); return -1; } + odp_proc.nwal.context_buffer = nwal_loc_ctx_mem; nwal_ret = nwal_createProc(bases[nwal_BUF_INDEX_INST], nwal_loc_ctx_mem, &base_addr_cfg); @@ -366,8 +343,14 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) odp_pr_err("nwal_create Failed %d\n", nwal_ret); return -1; } - odp_pr_dbg("Global and Local Network initialization Successful\n"); + + nwal_ret = nwal_getGlobCxtInfo(odp_global->nwal.handle, + &odp_global->nwal.info); + if (nwal_ret != nwal_OK) { + odp_pr_err("Couldn't get global NWAL info: %d\n", nwal_ret); + return -1; + } return 1; } @@ -388,7 +371,7 @@ int mcsdk_nwal_start(Pktlib_HeapHandle pkt_heap, Pktlib_HeapHandle cmd_rx_heap, * Update the Start of Packet Offset for the default flows created * by NWAL */ - nwal_local_cfg.rxSopPktOffset = odp_global->cfg.min_buf_headroom_size; + nwal_local_cfg.rxSopPktOffset = 0; nwal_local_cfg.rxPktTailRoomSz = odp_global->cfg.def_heap_tailroom_size; /* Call back registration for the core */ @@ -665,6 +648,67 @@ int mcsdk_global_init(void) return 0; } +int mcsdk_delete_heap(Pktlib_HeapHandle heap) +{ + int32_t err_code = 0, ret; + + ret = Pktlib_deleteHeap(heap, &err_code); + + if (ret < 0) { + odp_pr_err("Pktlib_deleteHeap failed ret: %d, err: %d", + ret, err_code); + return -1; + } + + return 0; +} + +int mcsdk_global_term(void) +{ + nwal_RetValue nwal_ret; + hplib_RetValue hplib_ret; + + nwal_ret = nwal_delete(odp_global->nwal.handle); + if (nwal_ret != nwal_OK) { + odp_pr_err("nwal_delete_failed: %d", nwal_ret); + return -1; + } + + /* close heaps */ + mcsdk_delete_heap(odp_proc.nwal.netcp_heap); + mcsdk_delete_heap(odp_proc.nwal.netcp_control_rx_heap); + mcsdk_delete_heap(odp_proc.nwal.netcp_control_tx_heap); + mcsdk_delete_heap(odp_global->nwal.pa2sa_heap); + mcsdk_delete_heap(odp_global->nwal.sa2pa_heap); + + free(odp_proc.nwal.context_buffer); + odp_proc.nwal.context_buffer = NULL; + + /** + * @todo: NWAL doesn't close CPPI handles so Cppi_exit fails. NWAL + * should be fixed. + * + * mcsdk_cppi_exit(); + */ + mcsdk_qmss_remove_memregion(); + mcsdk_qmss_exit(); + + hplib_ret = hplib_resetMallocArea(0); + if (hplib_ret != hplib_OK) + odp_pr_err("hplib_resetMallocArea() failed for pool 0: %d\n", + hplib_ret); + hplib_ret = hplib_resetMallocArea(1); + if (hplib_ret != hplib_OK) + odp_pr_err("hplib_resetMallocArea() failed for pool 1: %d\n", + hplib_ret); + hplib_vmTeardown(); + hplib_shmDelete(); + if (hplib_ret != hplib_OK) + odp_pr_err("hplib_shmDelete() failed: %d\n", hplib_ret); + + return 0; +} + int mcsdk_local_init(int thread_id) { int ret; diff --git a/platform/linux-keystone2/mcsdk/mcsdk_navig.c b/platform/linux-keystone2/mcsdk/mcsdk_navig.c index c3009b7..146068c 100644 --- a/platform/linux-keystone2/mcsdk/mcsdk_navig.c +++ b/platform/linux-keystone2/mcsdk/mcsdk_navig.c @@ -94,6 +94,17 @@ int mcsdk_cppi_init(void) return 1; } +int mcsdk_cppi_exit(void) +{ + Cppi_Result result; + result = Cppi_exit(); + if (result != CPPI_SOK) { + odp_pr_err("Cppi_exit failed with error code %d\n", result); + return -1; + } + return 1; +} + /***************************************************************************** * FUNCTION PURPOSE: Global Initialization of Queue Manager. Once Per System ***************************************************************************** @@ -202,6 +213,17 @@ int mcsdk_qmss_init(int max_descriptors) return 1; } +int mcsdk_qmss_exit(void) +{ + Qmss_Result result; + result = Qmss_exit(); + if (result != QMSS_SOK) { + odp_pr_err("Qmss_exit failed with error code %d\n", result); + return -1; + } + return 1; +} + /******************************************************************** * FUNCTION PURPOSE: Internal NETAPI function to start QM ******************************************************************** @@ -267,3 +289,16 @@ int mcsdk_qmss_setup_memregion(uint32_t desc_num, uint32_t desc_size, return 1; } + +int mcsdk_qmss_remove_memregion(void) +{ + Qmss_Result result; + result = Qmss_removeMemoryRegion(odp_global->public_desc_memregion, + QMSS_PARAM_NOT_SPECIFIED); + if (result != QMSS_SOK) { + odp_pr_err("Qmss_removeMemoryRegion failed with error code %d\n", + result); + return -1; + } + return 1; +} diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c index 1fde2ce..86df7fe 100644 --- a/platform/linux-keystone2/odp_init.c +++ b/platform/linux-keystone2/odp_init.c @@ -81,7 +81,7 @@ int odp_init_global(odp_init_t *params ODP_UNUSED, int odp_term_global(void) { - ODP_UNIMPLEMENTED(); + mcsdk_global_term(); return 0; } @@ -116,6 +116,5 @@ int odp_init_local(void) int odp_term_local(void) { - ODP_UNIMPLEMENTED(); - return 0; + return (odp_thread_term_local() > 0) ? 1 : 0; }