aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-06-21 08:14:34 -0700
committerDamjan Marion <dmarion@me.com>2018-06-22 07:31:29 +0000
commit9679c81b64a5da48932ec0b6aebfb473d3e0410b (patch)
tree0db5d00e7142d1c8f4d5dfb1f0ac29bf883d1c26 /src/vnet
parent02c88e41791b11e8ed5dd08c76fa7bf5991ba3d7 (diff)
session: improve session lookup speeds
It would seem that this avoids using the stack for computing the subsequent crc32 by storing the 2 x u64 ip4 5-tuple key into two registers. Probably the cast to the "convenience" data structure "masks" the fact that the key is 16B. Probably ... :-) "sh run" on an ip4 tcp sender reports that the number of clocks spent in tcp_input, where a session lookup is performed, drops ~25% (from ~100 clocks/packet to ~75 clocks/packet) Change-Id: I50d647115ac72f8407bff7e3b73328ba42f0ddb5 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/session_lookup.c81
1 files changed, 24 insertions, 57 deletions
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index 83f95bed062..3a313526b49 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -86,14 +86,8 @@ always_inline void
make_v4_ss_kv (session_kv4_t * kv, ip4_address_t * lcl, ip4_address_t * rmt,
u16 lcl_port, u16 rmt_port, u8 proto)
{
- v4_connection_key_t *key = (v4_connection_key_t *) kv->key;
-
- key->src.as_u32 = lcl->as_u32;
- key->dst.as_u32 = rmt->as_u32;
- key->src_port = lcl_port;
- key->dst_port = rmt_port;
- key->proto = proto;
-
+ kv->key[0] = (u64) rmt->as_u32 << 32 | (u64) lcl->as_u32;
+ kv->key[1] = (u64) proto << 32 | (u64) rmt_port << 16 | (u64) lcl_port;
kv->value = ~0ULL;
}
@@ -101,28 +95,16 @@ always_inline void
make_v4_listener_kv (session_kv4_t * kv, ip4_address_t * lcl, u16 lcl_port,
u8 proto)
{
- v4_connection_key_t *key = (v4_connection_key_t *) kv->key;
-
- key->src.as_u32 = lcl->as_u32;
- key->dst.as_u32 = 0;
- key->src_port = lcl_port;
- key->dst_port = 0;
- key->proto = proto;
-
+ kv->key[0] = (u64) lcl->as_u32;
+ kv->key[1] = (u64) proto << 32 | (u64) lcl_port;
kv->value = ~0ULL;
}
always_inline void
make_v4_proxy_kv (session_kv4_t * kv, ip4_address_t * lcl, u8 proto)
{
- v4_connection_key_t *key = (v4_connection_key_t *) kv->key;
-
- key->src.as_u32 = lcl->as_u32;
- key->dst.as_u32 = 0;
- key->src_port = 0;
- key->dst_port = 0;
- key->proto = proto;
-
+ kv->key[0] = (u64) lcl->as_u32;
+ kv->key[1] = (u64) proto << 32;
kv->value = ~0ULL;
}
@@ -137,17 +119,12 @@ always_inline void
make_v6_ss_kv (session_kv6_t * kv, ip6_address_t * lcl, ip6_address_t * rmt,
u16 lcl_port, u16 rmt_port, u8 proto)
{
- v6_connection_key_t *key = (v6_connection_key_t *) kv->key;
-
- key->src.as_u64[0] = lcl->as_u64[0];
- key->src.as_u64[1] = lcl->as_u64[1];
- key->dst.as_u64[0] = rmt->as_u64[0];
- key->dst.as_u64[1] = rmt->as_u64[1];
- key->src_port = lcl_port;
- key->dst_port = rmt_port;
- key->proto = proto;
- key->unused = 0;
-
+ kv->key[0] = lcl->as_u64[0];
+ kv->key[1] = lcl->as_u64[1];
+ kv->key[2] = rmt->as_u64[0];
+ kv->key[3] = rmt->as_u64[1];
+ kv->key[4] = (u64) proto << 32 | (u64) rmt_port << 16 | (u64) lcl_port;
+ kv->key[5] = 0;
kv->value = ~0ULL;
}
@@ -155,34 +132,24 @@ always_inline void
make_v6_listener_kv (session_kv6_t * kv, ip6_address_t * lcl, u16 lcl_port,
u8 proto)
{
- v6_connection_key_t *key = (v6_connection_key_t *) kv->key;
-
- key->src.as_u64[0] = lcl->as_u64[0];
- key->src.as_u64[1] = lcl->as_u64[1];
- key->dst.as_u64[0] = 0;
- key->dst.as_u64[1] = 0;
- key->src_port = lcl_port;
- key->dst_port = 0;
- key->proto = proto;
- key->unused = 0;
-
+ kv->key[0] = lcl->as_u64[0];
+ kv->key[1] = lcl->as_u64[1];
+ kv->key[2] = 0;
+ kv->key[3] = 0;
+ kv->key[4] = (u64) proto << 32 | (u64) lcl_port;
+ kv->key[5] = 0;
kv->value = ~0ULL;
}
always_inline void
make_v6_proxy_kv (session_kv6_t * kv, ip6_address_t * lcl, u8 proto)
{
- v6_connection_key_t *key = (v6_connection_key_t *) kv->key;
-
- key->src.as_u64[0] = lcl->as_u64[0];
- key->src.as_u64[1] = lcl->as_u64[1];
- key->dst.as_u64[0] = 0;
- key->dst.as_u64[1] = 0;
- key->src_port = 0;
- key->dst_port = 0;
- key->proto = proto;
- key->unused = 0;
-
+ kv->key[0] = lcl->as_u64[0];
+ kv->key[1] = lcl->as_u64[1];
+ kv->key[2] = 0;
+ kv->key[3] = 0;
+ kv->key[4] = (u64) proto << 32;
+ kv->key[5] = 0;
kv->value = ~0ULL;
}