From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id 47C9072FB for ; Tue, 13 Sep 2016 22:04:41 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id i130so14004877wmf.0 for ; Tue, 13 Sep 2016 13:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=mfUbgdwJQrpBq3bTOgUIPHQOPO+6x32TLXCVhtsw7xo=; b=YkXYemZStn90NYA/EbzkfLkbGGcwXLH+4jkHAsustiE8fkcc2QI4uk9y/+RDFEMiu/ AJRXcM2wjEfpM1IfE0bkPx2lJc7sEDFblG69dUi5Y4DPMdJVKkNe/FZjAL4dZ0zx+Ha2 F3AZgCLxLxXUcPHF9waQ/g813liJ3l9SO9SkI/asHOyNQfGdqFM5kTkzkW2mwKjoyPPV oqeTzqd8RFMkZKKoOKVQeE2E4E8ZWgwQCUU7+p+sx+RJpxPKigGwT9K7Qzo0iOi29V2d S6i0qq5UNJkqbEFYCt4ZWCTQEaUM6Jgau6qpHPtu1SsuCoLWuJHyG4gZS+YJuSKQVpZx XFwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=mfUbgdwJQrpBq3bTOgUIPHQOPO+6x32TLXCVhtsw7xo=; b=F4C5A5l4+NYXHIELWlBF0pQH5nrUk6SK0/0X35zbyUH+5uGJTqylhRuNNt/445QpT3 Vl3SzdHaitcrXcz2KhH1a+MWJZPDuJPQGOWJ7ipgXVpXocr48xjq3v0CBvthn8Ekoe4d lqkTTV/xjCADjRWd+As7YXprwTONU2aQ5M69jc3nqMERtKbqsnIi6jOJ1/dbepfP28bv 52r8T2p+R8X7hG6Mk0Z1+v1zD0k+8qtRRs5BnWp5XDvQBgMglnsLU/I2XvY8aNZTxZU4 XIQSKeRbAZb7CX1Gbo7r3FkUJHbBQtE+EheU+B5uxgSe0Z8dWqXc/YyzST1QMi67YWwJ kSjg== X-Gm-Message-State: AE9vXwP4935iZEBlYApcEt0eM3TzGkic70pm5nj3CJkqTN+KVRfQfub5jM+tuDdMY6iuw/oI X-Received: by 10.194.184.78 with SMTP id es14mr20983197wjc.85.1473797080852; Tue, 13 Sep 2016 13:04:40 -0700 (PDT) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id au10sm427636wjc.12.2016.09.13.13.04.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 13:04:39 -0700 (PDT) From: Thomas Monjalon To: jozmarti@cisco.com Cc: dev@dpdk.org Date: Tue, 13 Sep 2016 22:04:38 +0200 Message-ID: <8519806.gZT5cxUFJR@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1469016644-6521-1-git-send-email-jozmarti@cisco.com> References: <1469016644-6521-1-git-send-email-jozmarti@cisco.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] rte_delay_us can be replaced with user function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Sep 2016 20:04:41 -0000 Hi, Sorry for late review. This patch was in a summer hole :/ First a general comment: please check your patch with scripts/checkpatches.sh. In order to ease tracking of this patch, please increment the version when sending a new one in the same thread: git send-email -1 -v3 --annotate --to dev@dpdk.org \ --in-reply-to 1469016644-6521-1-git-send-email-jozmarti@cisco.com More comments below. 2016-07-20 14:10, jozmarti@cisco.com: > +void rte_delay_us_callback_register(void (*userfunc)(unsigned)) > +{ > + if (userfunc == NULL) > + rte_delay_us = rte_delay_us_block; Here you are creating an exception for rte_delay_us_block which is mapped as a NULL handler. What will happen if we need to provide more builtin handlers? I still think that rte_delay_us_block can be exported and initialized as the default handler. Other opinions are obviously welcome. > + else > + rte_delay_us = userfunc; > +} > + > +static void __attribute__((constructor)) > +rte_timer_init(void) > +{ > + /* set rte_delay_us_block as a delay function */ > + rte_delay_us_callback_register(NULL); > +} > diff --git a/lib/librte_eal/common/include/generic/rte_cycles.h b/lib/librte_eal/common/include/generic/rte_cycles.h > index 8cc21f2..7a45b58 100644 > --- a/lib/librte_eal/common/include/generic/rte_cycles.h > +++ b/lib/librte_eal/common/include/generic/rte_cycles.h > @@ -182,13 +182,16 @@ rte_get_timer_hz(void) > } > > /** > + * useless newline > * Wait at least us microseconds. > + * This function can be replaced with user-defined function using > + * rte_delay_us_callback_register I think you can use @see to point to rte_delay_us_callback_register. > * > * @param us > * The number of microseconds to wait. > */ > void > -rte_delay_us(unsigned us); > +(*rte_delay_us)(unsigned us); > > /** > * Wait at least ms milliseconds. > @@ -202,4 +205,14 @@ rte_delay_ms(unsigned ms) > rte_delay_us(ms * 1000); > } > > +/** > + * Replace rte_delay_us with user defined function. > + * > + * @param userfunc > + * User function which replaces rte_delay_us. NULL restores > + * buildin block delay function. buildin -> builtin ? > + */ > +void rte_delay_us_callback_register(void(*userfunc)(unsigned));