diff mbox

[ovs-dev,V11,04/33] tc: Move functions the create/parse handle to be static inline

Message ID 1497366235-20892-5-git-send-email-roid@mellanox.com
State Accepted
Headers show

Commit Message

Roi Dayan June 13, 2017, 3:03 p.m. UTC
Those functions are just wrappers to available macros for readability.
Move them to tc.h to avoid function-call overhead.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
---
 lib/tc.c | 21 ---------------------
 lib/tc.h | 24 +++++++++++++++++++++---
 2 files changed, 21 insertions(+), 24 deletions(-)

Comments

Simon Horman June 14, 2017, 8:26 a.m. UTC | #1
On Tue, Jun 13, 2017 at 06:03:26PM +0300, Roi Dayan wrote:
> Those functions are just wrappers to available macros for readability.
> Move them to tc.h to avoid function-call overhead.
> 
> Signed-off-by: Roi Dayan <roid@mellanox.com>
> Acked-by: Flavio Leitner <fbl@sysclose.org>

Thanks, applied to master.
diff mbox

Patch

diff --git a/lib/tc.c b/lib/tc.c
index a71a9e0..1f12e4a 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -24,27 +24,6 @@ 
 
 VLOG_DEFINE_THIS_MODULE(tc);
 
-/* Returns tc handle 'major':'minor'. */
-unsigned int
-tc_make_handle(unsigned int major, unsigned int minor)
-{
-    return TC_H_MAKE(major << 16, minor);
-}
-
-/* Returns the major number from 'handle'. */
-unsigned int
-tc_get_major(unsigned int handle)
-{
-    return TC_H_MAJ(handle) >> 16;
-}
-
-/* Returns the minor number from 'handle'. */
-unsigned int
-tc_get_minor(unsigned int handle)
-{
-    return TC_H_MIN(handle);
-}
-
 struct tcmsg *
 tc_make_request(int ifindex, int type, unsigned int flags,
                 struct ofpbuf *request)
diff --git a/lib/tc.h b/lib/tc.h
index 420cdf8..ad8a458 100644
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -22,9 +22,27 @@ 
 #include <linux/rtnetlink.h>
 #include "openvswitch/ofpbuf.h"
 
-unsigned int tc_make_handle(unsigned int major, unsigned int minor);
-unsigned int tc_get_major(unsigned int handle);
-unsigned int tc_get_minor(unsigned int handle);
+/* Returns tc handle 'major':'minor'. */
+static inline unsigned int
+tc_make_handle(unsigned int major, unsigned int minor)
+{
+    return TC_H_MAKE(major << 16, minor);
+}
+
+/* Returns the major number from 'handle'. */
+static inline unsigned int
+tc_get_major(unsigned int handle)
+{
+    return TC_H_MAJ(handle) >> 16;
+}
+
+/* Returns the minor number from 'handle'. */
+static inline unsigned int
+tc_get_minor(unsigned int handle)
+{
+    return TC_H_MIN(handle);
+}
+
 struct tcmsg *tc_make_request(int ifindex, int type,
                               unsigned int flags, struct ofpbuf *);
 int tc_transact(struct ofpbuf *request, struct ofpbuf **replyp);