From patchwork Tue Oct 10 15:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 115413 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3858518qgn; Tue, 10 Oct 2017 08:04:03 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA7IwA+vsG2QsEg66i/QkDlsXEl6aXPz2Mfn8aL5LPIx3rJVutWEfMGVC5/AqMoUq+5Th8b X-Received: by 10.36.150.3 with SMTP id z3mr17658424itd.43.1507647843739; Tue, 10 Oct 2017 08:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507647843; cv=none; d=google.com; s=arc-20160816; b=JvD27JgX8C04xAgW6StZ8UcZxZYyLd+0XpRpkYifTV3Ffta5ATbfRARx0DsS5j8Utv lczQsKbDA8qlwc3PpJz7pR+9E0ZvmKfuycOJ8IC1cGdPMnhY5r+l6hkSBlExkHYXzio3 U1tcdyUTYaLAfuqynq8sha2M+0HbhavoLzw3a0h6GiGFV0IEv0rpqXu/y2AqrlmwTdKl jAdgmGcHix8Sr6du6lDtZGnDQKdfFQvMC6dk3q8UTO3YOEZwvMSR4VJcpmMkutrJMoO/ DXSXfBegeNm4e9m3HBezDZWMCF3AH8ryi3xt3DUY4rQGEDGM/9OC9TzpwoJXVXH4+uIT 0Rpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=bE2PlRnryUnnWatM3D+jAtPpk0+pFMf37ZQIhZ5wIpo=; b=ybVsj24X9NeYnW3w/RGsNGFZ/1WsJ4Uqp7P91HUVXJoeyv2uQoljZQJ87Pl1YMVOGR l2k+lInia3pmTgysSQwF6VB7LRCAzg/kkNlOFIRjxX+zg9bW6iwQdXLUbXjLPey7GQMs EGvmcsmR7bzktfPY8twak472DgoiKmrLc39I8/HUGQFIuxVNlDcwubNi2rs8OEp4HBmy lOWRvXCh6XewynkIQbub+5h0RYr27dOueEwkgekL754VwdM60LD+hWTf5bJmALm0dmLF Xv+gueT2p2d9x2GtGIpbiGpI1N9aIXfL3WEceZoHnfr3nXwoRVTklsvzqK8jqsl69pSz pJ4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p23si7007383ioi.25.2017.10.10.08.04.01; Tue, 10 Oct 2017 08:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A9C7861056; Tue, 10 Oct 2017 15:04:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6B04D60CC6; Tue, 10 Oct 2017 15:01:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6A7B960C18; Tue, 10 Oct 2017 15:00:55 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id C917560BFB for ; Tue, 10 Oct 2017 15:00:47 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward104o.mail.yandex.net (Yandex) with ESMTP id C3CE6701FBE for ; Tue, 10 Oct 2017 18:00:45 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 42vHMoSo7o-0jOaYg6M; Tue, 10 Oct 2017 18:00:45 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id jk0YtVglYD-0jxqSxop; Tue, 10 Oct 2017 18:00:45 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 10 Oct 2017 18:00:08 +0300 Message-Id: <1507647610-23573-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507647610-23573-1-git-send-email-odpbot@yandex.ru> References: <1507647610-23573-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 205 Subject: [lng-odp] [PATCH v2 2/4] linux-gen: timer: drop odp prefix from odp_timer_pool X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov internal data type should not be named with odp api prefix. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 205 (muvarov:master_timer_cleanup) ** https://github.com/Linaro/odp/pull/205 ** Patch: https://github.com/Linaro/odp/pull/205.patch ** Base sha: 3bacbfd55edf76b897a4b2e5c62b59ca6fa95331 ** Merge commit sha: 818bddefdf4c5afa6d1608da3de280ebcf585d75 **/ platform/linux-generic/odp_timer.c | 61 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 0a4fbb7e3..977385a7f 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -162,7 +162,7 @@ static inline void set_next_free(odp_timer *tim, uint32_t nf) } /****************************************************************************** - * odp_timer_pool abstract datatype + * timer_pool_t abstract datatype * Inludes alloc and free timer *****************************************************************************/ @@ -186,18 +186,18 @@ typedef struct odp_timer_pool_s { pthread_t timer_thread; /* pthread_t of timer thread */ pid_t timer_thread_id; /* gettid() for timer thread */ int timer_thread_exit; /* request to exit for timer thread */ -} odp_timer_pool; +} timer_pool_t; #define MAX_TIMER_POOLS 255 /* Leave one for ODP_TIMER_INVALID */ #define INDEX_BITS 24 static odp_atomic_u32_t num_timer_pools; -static odp_timer_pool *timer_pool[MAX_TIMER_POOLS]; +static timer_pool_t *timer_pool[MAX_TIMER_POOLS]; -static inline odp_timer_pool *handle_to_tp(odp_timer_t hdl) +static inline timer_pool_t *handle_to_tp(odp_timer_t hdl) { uint32_t tp_idx = _odp_typeval(hdl) >> INDEX_BITS; if (odp_likely(tp_idx < MAX_TIMER_POOLS)) { - odp_timer_pool *tp = timer_pool[tp_idx]; + timer_pool_t *tp = timer_pool[tp_idx]; if (odp_likely(tp != NULL)) return timer_pool[tp_idx]; } @@ -222,8 +222,8 @@ static inline odp_timer_t tp_idx_to_handle(struct odp_timer_pool_s *tp, } /* Forward declarations */ -static void itimer_init(odp_timer_pool *tp); -static void itimer_fini(odp_timer_pool *tp); +static void itimer_init(timer_pool_t *tp); +static void itimer_fini(timer_pool_t *tp); static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_param_t *param) @@ -235,7 +235,7 @@ static odp_timer_pool_t timer_pool_new(const char *name, __odp_errno = ENFILE; /* Table overflow */ return ODP_TIMER_POOL_INVALID; } - size_t sz0 = ROUNDUP_CACHE_LINE(sizeof(odp_timer_pool)); + size_t sz0 = ROUNDUP_CACHE_LINE(sizeof(timer_pool_t)); size_t sz1 = ROUNDUP_CACHE_LINE(sizeof(tick_buf_t) * param->num_timers); size_t sz2 = ROUNDUP_CACHE_LINE(sizeof(odp_timer) * param->num_timers); odp_shm_t shm = odp_shm_reserve(name, sz0 + sz1 + sz2, @@ -243,7 +243,7 @@ static odp_timer_pool_t timer_pool_new(const char *name, if (odp_unlikely(shm == ODP_SHM_INVALID)) ODP_ABORT("%s: timer pool shm-alloc(%zuKB) failed\n", name, (sz0 + sz1 + sz2) / 1024); - odp_timer_pool *tp = (odp_timer_pool *)odp_shm_addr(shm); + timer_pool_t *tp = (timer_pool_t *)odp_shm_addr(shm); odp_atomic_init_u64(&tp->cur_tick, 0); if (name == NULL) { @@ -292,7 +292,7 @@ static void block_sigalarm(void) sigprocmask(SIG_BLOCK, &sigset, NULL); } -static void stop_timer_thread(odp_timer_pool *tp) +static void stop_timer_thread(timer_pool_t *tp) { int ret; @@ -303,7 +303,7 @@ static void stop_timer_thread(odp_timer_pool *tp) ODP_ABORT("unable to join thread, err %d\n", ret); } -static void odp_timer_pool_del(odp_timer_pool *tp) +static void odp_timer_pool_del(timer_pool_t *tp) { odp_spinlock_lock(&tp->lock); timer_pool[tp->tp_idx] = NULL; @@ -326,7 +326,7 @@ static void odp_timer_pool_del(odp_timer_pool *tp) odp_atomic_sub_u32(&num_timer_pools, 1); } -static inline odp_timer_t timer_alloc(odp_timer_pool *tp, +static inline odp_timer_t timer_alloc(timer_pool_t *tp, odp_queue_t queue, void *user_ptr) { @@ -357,11 +357,11 @@ static inline odp_timer_t timer_alloc(odp_timer_pool *tp, return hdl; } -static odp_buffer_t timer_cancel(odp_timer_pool *tp, - uint32_t idx, - uint64_t new_state); +static odp_buffer_t timer_cancel(timer_pool_t *tp, + uint32_t idx, + uint64_t new_state); -static inline odp_buffer_t timer_free(odp_timer_pool *tp, uint32_t idx) +static inline odp_buffer_t timer_free(timer_pool_t *tp, uint32_t idx) { odp_timer *tim = &tp->timers[idx]; @@ -391,7 +391,7 @@ static inline odp_buffer_t timer_free(odp_timer_pool *tp, uint32_t idx) static bool timer_reset(uint32_t idx, uint64_t abs_tck, odp_buffer_t *tmo_buf, - odp_timer_pool *tp) + timer_pool_t *tp) { bool success = true; tick_buf_t *tb = &tp->tick_buf[idx]; @@ -522,9 +522,9 @@ static bool timer_reset(uint32_t idx, return success; } -static odp_buffer_t timer_cancel(odp_timer_pool *tp, - uint32_t idx, - uint64_t new_state) +static odp_buffer_t timer_cancel(timer_pool_t *tp, + uint32_t idx, + uint64_t new_state) { tick_buf_t *tb = &tp->tick_buf[idx]; odp_buffer_t old_buf; @@ -561,7 +561,7 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, return old_buf; } -static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) +static unsigned timer_expire(timer_pool_t *tp, uint32_t idx, uint64_t tick) { odp_timer *tim = &tp->timers[idx]; tick_buf_t *tb = &tp->tick_buf[idx]; @@ -677,7 +677,7 @@ static unsigned odp_timer_pool_expire(odp_timer_pool_t tpid, uint64_t tick) * Functions that use Linux/POSIX per-process timers and related facilities *****************************************************************************/ -static void timer_notify(odp_timer_pool *tp) +static void timer_notify(timer_pool_t *tp) { int overrun; int64_t prev_tick; @@ -707,7 +707,7 @@ static void timer_notify(odp_timer_pool *tp) static void *timer_thread(void *arg) { - odp_timer_pool *tp = (odp_timer_pool *)arg; + timer_pool_t *tp = (timer_pool_t *)arg; sigset_t sigset; int ret; struct timespec tmo; @@ -737,7 +737,7 @@ static void *timer_thread(void *arg) return NULL; } -static void itimer_init(odp_timer_pool *tp) +static void itimer_init(timer_pool_t *tp) { struct sigevent sigev; struct itimerspec ispec; @@ -782,7 +782,7 @@ static void itimer_init(odp_timer_pool *tp) strerror(errno)); } -static void itimer_fini(odp_timer_pool *tp) +static void itimer_fini(timer_pool_t *tp) { if (timer_delete(tp->timerid) != 0) ODP_ABORT("timer_delete() returned error %s\n", @@ -868,7 +868,7 @@ odp_timer_t odp_timer_alloc(odp_timer_pool_t tpid, odp_event_t odp_timer_free(odp_timer_t hdl) { - odp_timer_pool *tp = handle_to_tp(hdl); + timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); odp_buffer_t old_buf = timer_free(tp, idx); return odp_buffer_to_event(old_buf); @@ -878,9 +878,10 @@ int odp_timer_set_abs(odp_timer_t hdl, uint64_t abs_tck, odp_event_t *tmo_ev) { - odp_timer_pool *tp = handle_to_tp(hdl); + timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); uint64_t cur_tick = odp_atomic_load_u64(&tp->cur_tick); + if (odp_unlikely(abs_tck < cur_tick + tp->min_rel_tck)) return ODP_TIMER_TOOEARLY; if (odp_unlikely(abs_tck > cur_tick + tp->max_rel_tck)) @@ -895,7 +896,7 @@ int odp_timer_set_rel(odp_timer_t hdl, uint64_t rel_tck, odp_event_t *tmo_ev) { - odp_timer_pool *tp = handle_to_tp(hdl); + timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); uint64_t abs_tck = odp_atomic_load_u64(&tp->cur_tick) + rel_tck; if (odp_unlikely(rel_tck < tp->min_rel_tck)) @@ -910,7 +911,7 @@ int odp_timer_set_rel(odp_timer_t hdl, int odp_timer_cancel(odp_timer_t hdl, odp_event_t *tmo_ev) { - odp_timer_pool *tp = handle_to_tp(hdl); + timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); /* Set the expiration tick of the timer to TMO_INACTIVE */ odp_buffer_t old_buf = timer_cancel(tp, idx, TMO_INACTIVE); @@ -949,7 +950,7 @@ int odp_timeout_fresh(odp_timeout_t tmo) { const odp_timeout_hdr_t *hdr = timeout_hdr(tmo); odp_timer_t hdl = hdr->timer; - odp_timer_pool *tp = handle_to_tp(hdl); + timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); tick_buf_t *tb = &tp->tick_buf[idx]; #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2