aboutsummaryrefslogtreecommitdiffstats
path: root/net/smc/smc_core.c
diff options
context:
space:
mode:
authorHans Wippel <hwippel@linux.ibm.com>2018-05-18 03:34:14 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-18 13:15:01 -0400
commit2f6becaf79cd16f35ee7cb108200b898235b5aa2 (patch)
tree8e287e836bb252d90310988c2878fe9152dda58c /net/smc/smc_core.c
parent95d8d26306ee19f9ba32b6381571a72ee924a0b6 (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.c27
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:
543 return rc ? rc : local_contact; 543 return rc ? rc : local_contact;
544} 544}
545 545
546/* convert the RMB size into the compressed notation - minimum 16K.
547 * In contrast to plain ilog2, this rounds towards the next power of 2,
548 * so the socket application gets at least its desired sndbuf / rcvbuf size.
549 */
550static u8 smc_compress_bufsize(int size)
551{
552 u8 compressed;
553
554 if (size <= SMC_BUF_MIN_SIZE)
555 return 0;
556
557 size = (size - 1) >> 14;
558 compressed = ilog2(size) + 1;
559 if (compressed >= SMC_RMBE_SIZES)
560 compressed = SMC_RMBE_SIZES - 1;
561 return compressed;
562}
563
564/* convert the RMB size from compressed notation into integer */
565int smc_uncompress_bufsize(u8 compressed)
566{
567 u32 size;
568
569 size = 0x00000001 << (((int)compressed) + 14);
570 return (int)size;
571}
572
546/* try to reuse a sndbuf or rmb description slot for a certain 573/* try to reuse a sndbuf or rmb description slot for a certain
547 * buffer size; if not available, return NULL 574 * buffer size; if not available, return NULL
548 */ 575 */