From patchwork Thu Jan 29 13:10:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yan.songming" X-Patchwork-Id: 43935 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C53C524119 for ; Thu, 29 Jan 2015 13:11:00 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf12583537wiv.2 for ; Thu, 29 Jan 2015 05:11:00 -0800 (PST) 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: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=XSoKiUsnMMwrco+meut6xtm7Faq7Ao7Tq777d8cSfC4=; b=dlYzug8sGmJleHF5AS+0pt0aragBdM8QkSyo70PHuq1PHm0kPJyFikBFoq01o76K+W AuldY5kRPCwV5CJYoxfM4Rol61TzZcGVeUSr4td3dgYg45yxhK2qeiM7kcXn7KlcR3Ta zpvsUF73hTOuc7aEzgzJl/w2HUdG9zrHufkBdZM2C/uzzKvsMmf/0MFG8Lf7GWzEpsYv enBNPXqI5xQuS4OG7bJr3EOwhBIlCNNiPBZlI61iJFLk+prJKJPUTp6wejfOKDC6gLQq hihGWjQSuaRxVAPdc1zLmzB1UgS4HCWyfWzbbmwZl6o8MrMG/TFLZYvO3AgXzkj+yyNt Xdlw== X-Gm-Message-State: ALoCoQk96e5TyKVrU8COzHi8Sm495AgdgjI+FTfm8+UD5NilX8aIMOJBZbiZHOAV2SvkLusimy1r X-Received: by 10.180.105.97 with SMTP id gl1mr324990wib.7.1422537060001; Thu, 29 Jan 2015 05:11:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.193 with SMTP id le1ls306146lab.11.gmail; Thu, 29 Jan 2015 05:10:59 -0800 (PST) X-Received: by 10.112.133.4 with SMTP id oy4mr467696lbb.83.1422537059766; Thu, 29 Jan 2015 05:10:59 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id ld8si3029256lac.86.2015.01.29.05.10.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 05:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u10so27824153lbd.9 for ; Thu, 29 Jan 2015 05:10:59 -0800 (PST) X-Received: by 10.152.20.169 with SMTP id o9mr657580lae.50.1422537059463; Thu, 29 Jan 2015 05:10:59 -0800 (PST) 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 h5csp1757714lbj; Thu, 29 Jan 2015 05:10:58 -0800 (PST) X-Received: by 10.229.172.67 with SMTP id k3mr967627qcz.11.1422537057651; Thu, 29 Jan 2015 05:10:57 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k9si1701174qch.49.2015.01.29.05.10.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 05:10:57 -0800 (PST) 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 1YGos2-00067N-5k; Thu, 29 Jan 2015 13:10:54 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YGorv-00067H-UY for lng-odp@lists.linaro.org; Thu, 29 Jan 2015 13:10:48 +0000 Received: by mail-pa0-f43.google.com with SMTP id eu11so38966891pac.2 for ; Thu, 29 Jan 2015 05:10:42 -0800 (PST) X-Received: by 10.66.65.169 with SMTP id y9mr444396pas.105.1422537042351; Thu, 29 Jan 2015 05:10:42 -0800 (PST) Received: from ysm-linux.localdomain (119.81.145.116-static.reverse.softlayer.com. [119.81.145.116]) by mx.google.com with ESMTPSA id k5sm7829168pdb.14.2015.01.29.05.10.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jan 2015 05:10:41 -0800 (PST) From: Yan Songming To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 21:10:01 +0800 Message-Id: <1422537001-25566-1-git-send-email-yan.songming@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Topics: patch Subject: [lng-odp] [PATCH v4 1/2] linux-generic: implement of odp_term_global. 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: yan.songming@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.178 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 From: Yan Sonming Free global resource of odp which include share memory, queue and buffer pool. Signed-off-by: Yan Songming --- platform/linux-generic/include/odp_internal.h | 8 ++++++ platform/linux-generic/odp_buffer_pool.c | 31 ++++++++++++++++++++- platform/linux-generic/odp_classification.c | 25 +++++++++++++++++ platform/linux-generic/odp_crypto.c | 13 +++++++++ platform/linux-generic/odp_init.c | 40 ++++++++++++++++++++++++++- platform/linux-generic/odp_packet_io.c | 20 ++++++++++++++ platform/linux-generic/odp_queue.c | 25 +++++++++++++++++ platform/linux-generic/odp_schedule.c | 25 +++++++++++++++++ platform/linux-generic/odp_shared_memory.c | 8 ++++++ platform/linux-generic/odp_thread.c | 13 +++++++++ 10 files changed, 206 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 07c9f60..60d89b1 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -29,22 +29,30 @@ int odp_system_info_init(void); int odp_thread_init_global(void); int odp_thread_init_local(void); int odp_thread_term_local(void); +int odp_thread_term_global(void); int odp_shm_init_global(void); +int odp_shm_term_global(void); int odp_shm_init_local(void); int odp_buffer_pool_init_global(void); +int odp_buffer_pool_term_global(void); int odp_pktio_init_global(void); +int odp_pktio_term_global(void); int odp_pktio_init_local(void); int odp_classification_init_global(void); +int odp_classification_term_global(void); int odp_queue_init_global(void); +int odp_queue_term_global(void); int odp_crypto_init_global(void); +int odp_crypto_term_global(void); int odp_schedule_init_global(void); +int odp_schedule_term_global(void); int odp_schedule_init_local(void); int odp_timer_init_global(void); diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index ac12057..3f4a3e6 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -55,6 +55,7 @@ typedef struct pool_table_t { /* The pool table */ static pool_table_t *pool_tbl; +static const char shm_name[] = "odp_buffer_pools"; /* Pool entry pointers (for inlining) */ void *pool_entry_ptr[ODP_CONFIG_POOLS]; @@ -67,7 +68,7 @@ int odp_buffer_pool_init_global(void) uint32_t i; odp_shm_t shm; - shm = odp_shm_reserve("odp_buffer_pools", + shm = odp_shm_reserve(shm_name, sizeof(pool_table_t), sizeof(pool_entry_t), 0); @@ -95,6 +96,34 @@ int odp_buffer_pool_init_global(void) return 0; } +int odp_buffer_pool_term_global(void) +{ + odp_shm_t shm; + int i; + pool_entry_t *pool; + int ret = 0; + + for (i = 0; i < ODP_CONFIG_POOLS; i++) { + pool = get_pool_entry(i); + + POOL_LOCK(&pool->s.lock); + if (pool->s.pool_shm != ODP_SHM_INVALID) { + ODP_ERR("Not destroyed pool: %s\n", pool->s.name); + ret = -1; + } + POOL_UNLOCK(&pool->s.lock); + } + if (ret) + return ret; + + shm = odp_shm_lookup(shm_name); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + /** * Pool creation */ diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 0f58836..56447fd 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -124,6 +124,31 @@ error: return -1; } +int odp_classification_term_global(void) +{ + odp_shm_t cos_shm; + odp_shm_t pmr_shm; + odp_shm_t pmr_set_shm; + int ret = 0; + + cos_shm = odp_shm_lookup("shm_odp_cos_tbl"); + if (cos_shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(cos_shm); + + pmr_shm = odp_shm_lookup("shm_odp_pmr_tbl"); + if (pmr_shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(pmr_shm); + + pmr_set_shm = odp_shm_lookup("shm_odp_pmr_set_tbl"); + if (pmr_set_shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(pmr_set_shm); + + return ret; +} + odp_cos_t odp_cos_create(const char *name) { int i; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 4436a0c..4b9ab76 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -428,6 +428,19 @@ odp_crypto_init_global(void) return 0; } +int odp_crypto_term_global(void) +{ + odp_shm_t shm; + int ret = 0; + + shm = odp_shm_lookup("crypto_pool"); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + int odp_hw_random_get(uint8_t *buf, size_t *len, bool use_entropy ODP_UNUSED) { diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 9815ecf..1351b31 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -72,7 +72,45 @@ int odp_init_global(odp_init_t *params ODP_UNUSED, int odp_term_global(void) { - ODP_UNIMPLEMENTED(); + if (odp_classification_term_global()) { + ODP_ERR("ODP classificatio term failed.\n"); + return -1; + } + + if (odp_crypto_term_global()) { + ODP_ERR("ODP crypto term failed.\n"); + return -1; + } + + if (odp_pktio_term_global()) { + ODP_ERR("ODP pktio term failed.\n"); + return -1; + } + + if (odp_schedule_term_global()) { + ODP_ERR("ODP schedule term failed.\n"); + return -1; + } + + if (odp_queue_term_global()) { + ODP_ERR("ODP queue term failed.\n"); + return -1; + } + + if (odp_buffer_pool_term_global()) { + ODP_ERR("ODP buffer pool term failed.\n"); + return -1; + } + + if (odp_thread_term_global()) { + ODP_ERR("ODP thread term failed.\n"); + return -1; + } + + if (odp_shm_term_global()) { + ODP_ERR("ODP shm term failed.\n"); + return -1; + } return 0; } diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 52125fc..3bfa03f 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -79,6 +79,26 @@ int odp_pktio_init_global(void) return 0; } +int odp_pktio_term_global(void) +{ + odp_shm_t shm; + pktio_entry_t *pktio_entry; + int ret = 0; + int id; + + for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) { + pktio_entry = &pktio_tbl->entries[id - 1]; + odp_queue_destroy(pktio_entry->s.outq_default); + } + + shm = odp_shm_lookup("odp_pktio_entries"); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + int odp_pktio_init_local(void) { return 0; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 17ff7c1..58db0bc 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -128,6 +128,31 @@ int odp_queue_init_global(void) return 0; } +int odp_queue_term_global(void) +{ + odp_shm_t shm; + int ret = 0; + queue_entry_t *queue; + int i; + + for (i = 0; i < ODP_CONFIG_QUEUES; i++) { + queue = &queue_tbl->queue[i]; + LOCK(&queue->s.lock); + if (queue->s.status != QUEUE_STATUS_FREE) { + ODP_ERR("Not destroyed queue: %s\n", queue->s.name); + ret = -1; + } + UNLOCK(&queue->s.lock); + } + + shm = odp_shm_lookup("odp_queues"); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + odp_queue_type_t odp_queue_type(odp_queue_t handle) { queue_entry_t *queue; diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 58561a9..bff28d9 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -144,6 +144,31 @@ int odp_schedule_init_global(void) return 0; } +int odp_schedule_term_global(void) +{ + odp_shm_t shm; + int ret = 0; + int i, j; + + for (i = 0; i < ODP_CONFIG_SCHED_PRIOS; i++) { + for (j = 0; j < QUEUES_PER_PRIO; j++) + odp_queue_destroy(sched->pri_queue[i][j]); + } + + if (odp_pool_destroy(sched->pool) != 0) { + ODP_ERR("Sched term: Pool destroy fail.\n"); + return -1; + } + + shm = odp_shm_lookup("odp_scheduler"); + if (shm == ODP_SHM_INVALID) { + ODP_ERR("Sched term: Shm lookup fail.\n"); + return -1; + } + ret = odp_shm_free(shm); + + return ret; +} int odp_schedule_init_local(void) { diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 515a26f..9ba0dc9 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -96,6 +96,14 @@ int odp_shm_init_global(void) return 0; } +int odp_shm_term_global(void) +{ + int ret = 0; + + ret = munmap(odp_shm_tbl, sizeof(odp_shm_table_t)); + return ret; +} + int odp_shm_init_local(void) { diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index ccbd068..933e920 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -64,6 +64,19 @@ int odp_thread_init_global(void) return 0; } +int odp_thread_term_global(void) +{ + odp_shm_t shm; + int ret = 0; + + shm = odp_shm_lookup("odp_thread_globals"); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + static int thread_id(void) {