diff options
author | Hans Wippel <hwippel@linux.ibm.com> | 2018-05-18 09:34:14 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-18 13:15:01 -0400 |
commit | 2f6becaf79cd16f35ee7cb108200b898235b5aa2 (patch) | |
tree | 8e287e836bb252d90310988c2878fe9152dda58c /net/smc/smc_core.c | |
parent | 95d8d26306ee19f9ba32b6381571a72ee924a0b6 (diff) |
net/smc: move smc_core specific code from smc.h to smc_core
SMC connection and buffer handling belong to smc_core. So, this patch
moves this code from smc.h to smc_core.
Signed-off-by: Hans Wippel <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_core.c')
-rw-r--r-- | net/smc/smc_core.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 70ab2f716f83..66afa086ae72 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -543,6 +543,33 @@ out: return rc ? rc : local_contact; } +/* convert the RMB size into the compressed notation - minimum 16K. + * In contrast to plain ilog2, this rounds towards the next power of 2, + * so the socket application gets at least its desired sndbuf / rcvbuf size. + */ +static u8 smc_compress_bufsize(int size) +{ + u8 compressed; + + if (size <= SMC_BUF_MIN_SIZE) + return 0; + + size = (size - 1) >> 14; + compressed = ilog2(size) + 1; + if (compressed >= SMC_RMBE_SIZES) + compressed = SMC_RMBE_SIZES - 1; + return compressed; +} + +/* convert the RMB size from compressed notation into integer */ +int smc_uncompress_bufsize(u8 compressed) +{ + u32 size; + + size = 0x00000001 << (((int)compressed) + 14); + return (int)size; +} + /* try to reuse a sndbuf or rmb description slot for a certain * buffer size; if not available, return NULL */ |