From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B89CD9139 for ; Wed, 31 May 2017 11:21:05 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2017 02:21:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,422,1491289200"; d="scan'208";a="863078232" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.223]) by FMSMGA003.fm.intel.com with ESMTP; 31 May 2017 02:21:04 -0700 From: Bruce Richardson To: Robert Sanford Cc: dev@dpdk.org, Bruce Richardson Date: Wed, 31 May 2017 10:16:20 +0100 Message-Id: <20170531091621.203189-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170531091621.203189-1-bruce.richardson@intel.com> References: <20170428132538.15995-1-bruce.richardson@intel.com> <20170531091621.203189-1-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 2/3] timer: add symbol versions for ABI compatibility X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 May 2017 09:21:06 -0000 With the change in parameters to the callback function for timers, ABI compatibility needs to be managed. Do this by adding symbol version information and adding back in older copies of some functions. Signed-off-by: Bruce Richardson --- lib/librte_timer/rte_timer.c | 79 ++++++++++++++++++++++++++++++---- lib/librte_timer/rte_timer.h | 27 ++++++++++-- lib/librte_timer/rte_timer_version.map | 9 ++++ 3 files changed, 104 insertions(+), 11 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 2c5d5f3..c272643 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -365,7 +365,7 @@ timer_del(struct rte_timer *tim, union rte_timer_status prev_status, static int __rte_timer_reset(struct rte_timer *tim, uint64_t expire, uint64_t period, unsigned tim_lcore, - rte_timer_cb_t fct, void *arg, + void *fct, void *arg, int local_is_locked) { union rte_timer_status prev_status, status; @@ -424,9 +424,9 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire, /* Reset and start the timer associated with the timer handle tim */ int -rte_timer_reset(struct rte_timer *tim, uint64_t ticks, +rte_timer_reset_v20(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, - rte_timer_cb_t fct, void *arg) + rte_timer_cb_t_v20 fct, void *arg) { uint64_t cur_time = rte_get_timer_cycles(); uint64_t period; @@ -443,17 +443,58 @@ rte_timer_reset(struct rte_timer *tim, uint64_t ticks, return __rte_timer_reset(tim, cur_time + ticks, period, tim_lcore, fct, arg, 0); } +VERSION_SYMBOL(rte_timer_reset, _v20, 2.0); /* loop until rte_timer_reset() succeed */ void -rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, +rte_timer_reset_sync_v20(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, - rte_timer_cb_t fct, void *arg) + rte_timer_cb_t_v20 fct, void *arg) +{ + while (rte_timer_reset_v20(tim, ticks, type, tim_lcore, + fct, arg) != 0) + rte_pause(); +} +VERSION_SYMBOL(rte_timer_reset_sync, _v20, 2.0); + +/* Reset and start the timer associated with the timer handle tim */ +int +rte_timer_reset_v1708(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg) +{ + uint64_t cur_time = rte_get_timer_cycles(); + uint64_t period; + + if (unlikely((tim_lcore != (unsigned int)LCORE_ID_ANY) && + !rte_lcore_is_enabled(tim_lcore))) + return -1; + + if (type == PERIODICAL) + period = ticks; + else + period = 0; + + return __rte_timer_reset(tim, cur_time + ticks, period, tim_lcore, + fct, arg, 0); +} +MAP_STATIC_SYMBOL(int rte_timer_reset(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg), rte_timer_reset_v1708); + +/* loop until rte_timer_reset() succeed */ +void +rte_timer_reset_sync_v1708(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg) { while (rte_timer_reset(tim, ticks, type, tim_lcore, fct, arg) != 0) rte_pause(); } +MAP_STATIC_SYMBOL(void rte_timer_reset_sync(struct rte_timer *tim, + uint64_t ticks, enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg), rte_timer_reset_sync_v1708); /* Stop the timer associated with the timer handle tim */ int @@ -505,8 +546,13 @@ rte_timer_pending(struct rte_timer *tim) return tim->status.state == RTE_TIMER_PENDING; } +enum timer_version { + TIMER_VERSION_20, + TIMER_VERSION_1708, +}; /* must be called periodically, run all timer that expired */ -void rte_timer_manage(void) +static void +__timer_manage(enum timer_version ver) { union rte_timer_status status; struct rte_timer *tim, *next_tim; @@ -590,9 +636,12 @@ void rte_timer_manage(void) priv_timer[lcore_id].running_tim = tim; /* execute callback function with list unlocked */ - if (tim->period == 0) + if (ver == TIMER_VERSION_20) { + rte_timer_cb_t_v20 f = (void *)tim->f; + f(tim, tim->arg); + } else if (tim->period == 0) { tim->f(tim, 1, tim->arg); - else { + } else { /* for periodic check how many expiries we have */ uint64_t over_time = cur_time - tim->expire; unsigned int extra_expiries = over_time / tim->period; @@ -630,6 +679,20 @@ void rte_timer_manage(void) priv_timer[lcore_id].running_tim = NULL; } +void +rte_timer_manage_v20(void) +{ + __timer_manage(TIMER_VERSION_20); +} +VERSION_SYMBOL(rte_timer_manage, _v20, 2.0); + +void +rte_timer_manage_v1708(void) +{ + __timer_manage(TIMER_VERSION_1708); +} +MAP_STATIC_SYMBOL(void rte_timer_manage(void), rte_timer_manage_v1708); + /* dump statistics about timers */ void rte_timer_dump_stats(FILE *f) { diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h index bc434ec..049af72 100644 --- a/lib/librte_timer/rte_timer.h +++ b/lib/librte_timer/rte_timer.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -224,7 +225,7 @@ void rte_timer_init(struct rte_timer *tim); int rte_timer_reset(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, rte_timer_cb_t fct, void *arg); - +BIND_DEFAULT_SYMBOL(rte_timer_reset, _v1708, 17.08); /** * Loop until rte_timer_reset() succeeds. @@ -256,6 +257,7 @@ void rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, rte_timer_cb_t fct, void *arg); +BIND_DEFAULT_SYMBOL(rte_timer_reset_sync, _v1708, 17.08); /** * Stop a timer. @@ -321,7 +323,7 @@ int rte_timer_pending(struct rte_timer *tim); * CPU resources it will use. */ void rte_timer_manage(void); - +BIND_DEFAULT_SYMBOL(rte_timer_manage, _v1708, 17.08); /** * Dump statistics about timers. * @@ -330,6 +332,25 @@ void rte_timer_manage(void); */ void rte_timer_dump_stats(FILE *f); +/* legacy definition for ABI compatibility */ +typedef void (*rte_timer_cb_t_v20)(struct rte_timer *, void *); + +/* prototypes for versioned functions for ABI compatibility */ +int rte_timer_reset_v20(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t_v20 fct, void *arg); +void rte_timer_reset_sync_v20(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t_v20 fct, void *arg); +int rte_timer_reset_v1708(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg); +void rte_timer_reset_sync_v1708(struct rte_timer *tim, uint64_t ticks, + enum rte_timer_type type, unsigned int tim_lcore, + rte_timer_cb_t fct, void *arg); +void rte_timer_manage_v20(void); +void rte_timer_manage_v1708(void); + #ifdef __cplusplus } #endif diff --git a/lib/librte_timer/rte_timer_version.map b/lib/librte_timer/rte_timer_version.map index 9b2e4b8..06553d1 100644 --- a/lib/librte_timer/rte_timer_version.map +++ b/lib/librte_timer/rte_timer_version.map @@ -13,3 +13,12 @@ DPDK_2.0 { local: *; }; + +DPDK_17.08 { + global: + + rte_timer_reset; + rte_timer_reset_sync; + rte_timer_manage; + +} DPDK_2.0; -- 2.9.4