From patchwork Mon Jan 19 11:34:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yan.songming" X-Patchwork-Id: 43305 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0A26A2034D for ; Mon, 19 Jan 2015 11:43:05 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id y19sf16555164wgg.1 for ; Mon, 19 Jan 2015 03:43:04 -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=yOStqd4pmSWJVKnZ7+8g/JpvFj32A9cNmScQ9urpmzU=; b=I2WxEJfsjiZX0rpsH8ILIP2KAVPZADssjwVZKTr417Zd3jup+0PUmXxHEqNsUwBqQa 41n5JzNRteR9x1vb5s4PefffTS3SsxLWY3OZQaUaNgjePlvS8JBtGRSff3dCtoB7ji0C fxnG5+h3iuKoVyr9V1f35zexXxAYK3abcwAHfBX2S5sYHYm0n5ggTXhl8bx9w3uJN0A0 D94DNRJHfZFctHUxToOm/p+j0sYH3fSIWBGnhHrVofnYWarQc541WXS0s4WLkRtOn/Xf cjqAaxMpESrEAVflKsigekERBfTrt7xxdBWAMZXjw+nYk1/OY+pNcUgKgS2Al+ILZ5SQ 1Q3w== X-Gm-Message-State: ALoCoQnHLDqBA3SD03qTEHZsDeCMLECfWNYayEZwQXc62np/HZtVEiMjfJgA8MRt+zf49lslCBH+ X-Received: by 10.112.137.136 with SMTP id qi8mr216796lbb.13.1421667783666; Mon, 19 Jan 2015 03:43:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.202 with SMTP id u10ls434573lau.68.gmail; Mon, 19 Jan 2015 03:43:03 -0800 (PST) X-Received: by 10.152.5.101 with SMTP id r5mr17682306lar.33.1421667783510; Mon, 19 Jan 2015 03:43:03 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id y9si11160723lbr.7.2015.01.19.03.43.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 03:43:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id s18so7397849lam.5 for ; Mon, 19 Jan 2015 03:43:03 -0800 (PST) X-Received: by 10.112.52.229 with SMTP id w5mr30025074lbo.52.1421667325424; Mon, 19 Jan 2015 03:35:25 -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.9.200 with SMTP id c8csp1059624lbb; Mon, 19 Jan 2015 03:35:24 -0800 (PST) X-Received: by 10.140.83.100 with SMTP id i91mr43256053qgd.97.1421667323474; Mon, 19 Jan 2015 03:35:23 -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 k7si2272341qaj.81.2015.01.19.03.35.22 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Jan 2015 03:35:23 -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 1YDAc3-00089N-Vp; Mon, 19 Jan 2015 11:35:20 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDAby-00089C-9E for lng-odp@lists.linaro.org; Mon, 19 Jan 2015 11:35:14 +0000 Received: by mail-pd0-f179.google.com with SMTP id v10so17969276pde.10 for ; Mon, 19 Jan 2015 03:35:08 -0800 (PST) X-Received: by 10.70.37.166 with SMTP id z6mr33558016pdj.89.1421667308715; Mon, 19 Jan 2015 03:35:08 -0800 (PST) Received: from ysm-linux.localdomain ([180.150.157.30]) by mx.google.com with ESMTPSA id mz7sm11516362pdb.3.2015.01.19.03.35.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jan 2015 03:35:07 -0800 (PST) From: Yan Songming To: lng-odp@lists.linaro.org Date: Mon, 19 Jan 2015 19:34:11 +0800 Message-Id: <1421667251-14208-1-git-send-email-yan.songming@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Topics: patch Subject: [lng-odp] [PATCH] 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.215.46 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 all resource of odp which include share memory, queue and buffer pool. Fix the bug of odp_shm_free. Signed-off-by: Yan Songming --- platform/linux-generic/include/odp_internal.h | 10 +++ platform/linux-generic/odp_buffer_pool.c | 88 +++++++++++++++++++-------- platform/linux-generic/odp_classification.c | 42 ++++++++++--- platform/linux-generic/odp_crypto.c | 12 ++++ platform/linux-generic/odp_init.c | 43 ++++++++++++- platform/linux-generic/odp_packet_io.c | 35 ++++++++--- platform/linux-generic/odp_queue.c | 24 ++++++++ platform/linux-generic/odp_schedule.c | 34 +++++++++-- platform/linux-generic/odp_shared_memory.c | 12 +++- platform/linux-generic/odp_thread.c | 13 ++++ 10 files changed, 263 insertions(+), 50 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 549d406..d46f5ef 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -24,23 +24,33 @@ 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_buffer_pool_term_local(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_schedule_term_local(void); int odp_timer_init_global(void); int odp_timer_disarm_all(void); diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index eedb380..85e99e2 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_BUFFER_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,13 +96,48 @@ 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_BUFFER_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; +} + +int odp_buffer_pool_term_local(void) +{ + _odp_flush_caches(); + return 0; +} + + /** * Buffer pool creation */ odp_buffer_pool_t odp_buffer_pool_create(const char *name, - odp_shm_t shm, - odp_buffer_pool_param_t *params) + odp_shm_t shm, + odp_buffer_pool_param_t *params) { odp_buffer_pool_t pool_hdl = ODP_BUFFER_POOL_INVALID; pool_entry_t *pool; @@ -127,8 +163,8 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, /* Restriction for v1.0: No udata support */ uint32_t udata_stride = (init_params->udata_size > sizeof(void *)) ? - ODP_CACHE_LINE_SIZE_ROUNDUP(init_params->udata_size) : - 0; + ODP_CACHE_LINE_SIZE_ROUNDUP(init_params->udata_size) : + 0; uint32_t blk_size, buf_stride; uint32_t buf_align = params->buf_align; @@ -155,8 +191,8 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, blk_size = ODP_ALIGN_ROUNDUP(blk_size, buf_align); buf_stride = params->buf_type == ODP_BUFFER_TYPE_RAW ? - sizeof(odp_buffer_hdr_stride) : - sizeof(odp_timeout_hdr_stride); + sizeof(odp_buffer_hdr_stride) : + sizeof(odp_timeout_hdr_stride); break; case ODP_BUFFER_TYPE_PACKET: @@ -167,16 +203,16 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, if (unsegmented) blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf_size + tailroom, - buf_align); + headroom + params->buf_size + tailroom, + buf_align); else blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf_size + tailroom, - ODP_CONFIG_PACKET_BUF_LEN_MIN); + headroom + params->buf_size + tailroom, + ODP_CONFIG_PACKET_BUF_LEN_MIN); buf_stride = params->buf_type == ODP_BUFFER_TYPE_PACKET ? - sizeof(odp_packet_hdr_stride) : - sizeof(odp_any_hdr_stride); + sizeof(odp_packet_hdr_stride) : + sizeof(odp_any_hdr_stride); break; default: @@ -230,9 +266,9 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, udata_size = params->num_bufs * udata_stride; pool->s.pool_size = ODP_PAGE_SIZE_ROUNDUP(block_size + - pad_size + - mdata_size + - udata_size); + pad_size + + mdata_size + + udata_size); if (shm == ODP_SHM_NULL) { shm = odp_shm_reserve(pool->s.name, @@ -274,7 +310,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, pool->s.flags.unsegmented = unsegmented; pool->s.flags.zeroized = zeroized; pool->s.seg_size = unsegmented ? - blk_size : ODP_CONFIG_PACKET_BUF_LEN_MIN; + blk_size : ODP_CONFIG_PACKET_BUF_LEN_MIN; uint8_t *block_base_addr = pool->s.pool_base_addr; @@ -297,7 +333,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, uint8_t *buf = udata_base_addr - buf_stride; uint8_t *udat = udata_stride == 0 ? NULL : - block_base_addr - udata_stride; + block_base_addr - udata_stride; /* Init buffer common header and add to pool buffer freelist */ do { @@ -407,7 +443,7 @@ int odp_buffer_pool_info(odp_buffer_pool_t pool_hdl, info->name = pool->s.name; info->shm = pool->s.flags.user_supplied_shm ? - pool->s.pool_shm : ODP_SHM_INVALID; + pool->s.pool_shm : ODP_SHM_INVALID; info->params.buf_size = pool->s.params.buf_size; info->params.buf_align = pool->s.params.buf_align; info->params.num_bufs = pool->s.params.num_bufs; @@ -466,7 +502,7 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl, size_t size) /* Try to satisfy request from the local cache */ buf = (odp_anybuf_t *)(void *)get_local_buf(&local_cache[pool_id], - &pool->s, totsize); + &pool->s, totsize); /* If cache is empty, satisfy request from the pool */ if (odp_unlikely(buf == NULL)) { @@ -499,8 +535,8 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl, size_t size) if (pool->s.init_params.buf_init != NULL) (*pool->s.init_params.buf_init) - (buf->buf.handle.handle, - pool->s.init_params.buf_init_arg); + (buf->buf.handle.handle, + pool->s.init_params.buf_init_arg); } return odp_hdr_to_buf(&buf->buf); @@ -559,10 +595,10 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) pool->s.flags.has_name ? pool->s.name : "Unnamed Pool"); ODP_DBG(" pool type %s\n", pool->s.params.buf_type == ODP_BUFFER_TYPE_RAW ? "raw" : - (pool->s.params.buf_type == ODP_BUFFER_TYPE_PACKET ? "packet" : - (pool->s.params.buf_type == ODP_BUFFER_TYPE_TIMEOUT ? "timeout" : - (pool->s.params.buf_type == ODP_BUFFER_TYPE_ANY ? "any" : - "unknown")))); + (pool->s.params.buf_type == ODP_BUFFER_TYPE_PACKET ? "packet" : + (pool->s.params.buf_type == ODP_BUFFER_TYPE_TIMEOUT ? "timeout" : + (pool->s.params.buf_type == ODP_BUFFER_TYPE_ANY ? "any" : + "unknown")))); ODP_DBG(" pool storage %sODP managed\n", pool->s.flags.user_supplied_shm ? "application provided, " : ""); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index eeb049a..21728ac 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -53,8 +53,8 @@ int odp_classification_init_global(void) int i; cos_shm = odp_shm_reserve("shm_odp_cos_tbl", - sizeof(cos_tbl_t), - sizeof(cos_t), 0); + sizeof(cos_tbl_t), + sizeof(cos_t), 0); if (cos_shm == ODP_SHM_INVALID) { ODP_ERR("shm allocation failed for shm_odp_cos_tbl"); @@ -73,8 +73,8 @@ int odp_classification_init_global(void) } pmr_shm = odp_shm_reserve("shm_odp_pmr_tbl", - sizeof(pmr_tbl_t), - sizeof(pmr_t), 0); + sizeof(pmr_tbl_t), + sizeof(pmr_t), 0); if (pmr_shm == ODP_SHM_INVALID) { ODP_ERR("shm allocation failed for shm_odp_pmr_tbl"); @@ -93,8 +93,8 @@ int odp_classification_init_global(void) } pmr_set_shm = odp_shm_reserve("shm_odp_pmr_set_tbl", - sizeof(pmr_set_tbl_t), - sizeof(pmr_set_t), 0); + sizeof(pmr_set_tbl_t), + sizeof(pmr_set_t), 0); if (pmr_set_shm == ODP_SHM_INVALID) { ODP_ERR("shm allocation failed for shm_odp_pmr_set_tbl"); @@ -124,6 +124,32 @@ 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; @@ -604,7 +630,7 @@ int odp_pmr_match_set_destroy(odp_pmr_set_t pmr_set_id) } int odp_pktio_pmr_match_set_cos(odp_pmr_set_t pmr_set_id, odp_pktio_t src_pktio, - odp_cos_t dst_cos) + odp_cos_t dst_cos) { uint8_t num_pmr; pktio_entry_t *pktio_entry; @@ -829,7 +855,7 @@ int packet_classifier(odp_pktio_t pktio, odp_packet_t pkt) } cos_t *pktio_select_cos(pktio_entry_t *entry, uint8_t *pkt_addr, - odp_packet_hdr_t *pkt_hdr) + odp_packet_hdr_t *pkt_hdr) { pmr_t *pmr; cos_t *cos; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 2f95cbe..bf36b35 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -421,6 +421,18 @@ 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 4d0aa07..6b22023 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -11,7 +11,7 @@ int odp_init_global(odp_init_t *params ODP_UNUSED, - odp_platform_init_t *platform_params ODP_UNUSED) + odp_platform_init_t *platform_params ODP_UNUSED) { odp_system_info_init(); @@ -64,7 +64,46 @@ 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 cd109d2..a815020 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -73,6 +73,25 @@ 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) { @@ -345,15 +364,15 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) switch (pktio_entry->s.type) { case ODP_PKTIO_TYPE_SOCKET_BASIC: pkts = recv_pkt_sock_basic(&pktio_entry->s.pkt_sock, - pkt_table, len); + pkt_table, len); break; case ODP_PKTIO_TYPE_SOCKET_MMSG: pkts = recv_pkt_sock_mmsg(&pktio_entry->s.pkt_sock, - pkt_table, len); + pkt_table, len); break; case ODP_PKTIO_TYPE_SOCKET_MMAP: pkts = recv_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, - pkt_table, len); + pkt_table, len); break; default: pkts = -1; @@ -382,15 +401,15 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) switch (pktio_entry->s.type) { case ODP_PKTIO_TYPE_SOCKET_BASIC: pkts = send_pkt_sock_basic(&pktio_entry->s.pkt_sock, - pkt_table, len); + pkt_table, len); break; case ODP_PKTIO_TYPE_SOCKET_MMSG: pkts = send_pkt_sock_mmsg(&pktio_entry->s.pkt_sock, - pkt_table, len); + pkt_table, len); break; case ODP_PKTIO_TYPE_SOCKET_MMAP: pkts = send_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, - pkt_table, len); + pkt_table, len); break; default: pkts = -1; @@ -548,7 +567,7 @@ int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) nbr = queue_deq_multi(qentry, buf_hdr, num); if (odp_unlikely(nbr > num)) ODP_ABORT("queue_deq_multi req: %d, returned %d\n", - num, nbr); + num, nbr); /** queue already has number of requsted buffers, * do not do receive in that case. @@ -707,7 +726,7 @@ int odp_pktio_promisc_mode(odp_pktio_t id) } size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, - size_t addr_size) + size_t addr_size) { pktio_entry_t *entry; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 70c006d..97d11bd 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -127,6 +127,30 @@ 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) { diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index f7c3588..080edeb 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -20,7 +20,8 @@ #include #include - +#include +#include /* Limits to number of scheduled queues */ #define SCHED_POOL_SIZE (256*1024) @@ -144,6 +145,27 @@ 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_buffer_pool_destroy(sched->pool) != 0) + return -1; + + shm = odp_shm_lookup("odp_scheduler"); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} int odp_schedule_init_local(void) { @@ -162,7 +184,11 @@ int odp_schedule_init_local(void) return 0; } - +int odp_schedule_term_local(void) +{ + memset(&sched_local, 0, sizeof(sched_local_t)); + return 0; +} void odp_schedule_mask_set(odp_queue_t queue, int prio) { @@ -331,8 +357,8 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], static int schedule_loop(odp_queue_t *out_queue, uint64_t wait, - odp_buffer_t out_buf[], - unsigned int max_num, unsigned int max_deq) + odp_buffer_t out_buf[], + unsigned int max_num, unsigned int max_deq) { uint64_t start_cycle, cycle, diff; int ret; diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 99c5b40..7f1f6a8 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -94,6 +94,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) { @@ -135,9 +143,9 @@ int odp_shm_free(odp_shm_t shm) shm_block = &odp_shm_tbl->block[i]; alloc_size = shm_block->size + shm_block->align; - ret = munmap(shm_block->addr, alloc_size); + ret = munmap(shm_block->addr_orig, alloc_size); if (0 != ret) { - ODP_DBG("odp_shm_free: munmap failed\n"); + ODP_DBG("odp_shm_free: munmap failed : %s\n", shm_block->name); odp_spinlock_unlock(&odp_shm_tbl->lock); return -1; } 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) {