aboutsummaryrefslogtreecommitdiffstats
path: root/net/smc/smc_core.c
diff options
context:
space:
mode:
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 */