Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hans Wippel and committed by
David S. Miller
2f6becaf 95d8d263

+39 -41
-41
net/smc/smc.h
··· 220 220 return be32_to_cpu(t); 221 221 } 222 222 223 - #define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */ 224 - 225 - #define SMC_RMBE_SIZES 16 /* number of distinct sizes for an RMBE */ 226 - /* theoretically, the RFC states that largest size would be 512K, 227 - * i.e. compressed 5 and thus 6 sizes (0..5), despite 228 - * struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15) 229 - */ 230 - 231 - /* convert the RMB size into the compressed notation - minimum 16K. 232 - * In contrast to plain ilog2, this rounds towards the next power of 2, 233 - * so the socket application gets at least its desired sndbuf / rcvbuf size. 234 - */ 235 - static inline u8 smc_compress_bufsize(int size) 236 - { 237 - u8 compressed; 238 - 239 - if (size <= SMC_BUF_MIN_SIZE) 240 - return 0; 241 - 242 - size = (size - 1) >> 14; 243 - compressed = ilog2(size) + 1; 244 - if (compressed >= SMC_RMBE_SIZES) 245 - compressed = SMC_RMBE_SIZES - 1; 246 - return compressed; 247 - } 248 - 249 - /* convert the RMB size from compressed notation into integer */ 250 - static inline int smc_uncompress_bufsize(u8 compressed) 251 - { 252 - u32 size; 253 - 254 - size = 0x00000001 << (((int)compressed) + 14); 255 - return (int)size; 256 - } 257 - 258 223 #ifdef CONFIG_XFRM 259 224 static inline bool using_ipsec(struct smc_sock *smc) 260 225 { ··· 233 268 } 234 269 #endif 235 270 236 - struct smc_clc_msg_local; 237 - 238 - void smc_conn_free(struct smc_connection *conn); 239 - int smc_conn_create(struct smc_sock *smc, 240 - struct smc_ib_device *smcibdev, u8 ibport, 241 - struct smc_clc_msg_local *lcl, int srv_first_contact); 242 271 struct sock *smc_accept_dequeue(struct sock *parent, struct socket *new_sock); 243 272 void smc_close_non_accepted(struct sock *sk); 244 273
+27
net/smc/smc_core.c
··· 543 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 + */ 550 + static 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 */ 565 + int smc_uncompress_bufsize(u8 compressed) 566 + { 567 + u32 size; 568 + 569 + size = 0x00000001 << (((int)compressed) + 14); 570 + return (int)size; 571 + } 572 + 546 573 /* try to reuse a sndbuf or rmb description slot for a certain 547 574 * buffer size; if not available, return NULL 548 575 */
+12
net/smc/smc_core.h
··· 141 141 }; 142 142 143 143 #define SMC_LGR_ID_SIZE 4 144 + #define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */ 145 + #define SMC_RMBE_SIZES 16 /* number of distinct RMBE sizes */ 146 + /* theoretically, the RFC states that largest size would be 512K, 147 + * i.e. compressed 5 and thus 6 sizes (0..5), despite 148 + * struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15) 149 + */ 144 150 145 151 struct smc_link_group { 146 152 struct list_head list; ··· 211 205 212 206 struct smc_sock; 213 207 struct smc_clc_msg_accept_confirm; 208 + struct smc_clc_msg_local; 214 209 215 210 void smc_lgr_free(struct smc_link_group *lgr); 216 211 void smc_lgr_forget(struct smc_link_group *lgr); 217 212 void smc_lgr_terminate(struct smc_link_group *lgr); 218 213 void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport); 219 214 int smc_buf_create(struct smc_sock *smc); 215 + int smc_uncompress_bufsize(u8 compressed); 220 216 int smc_rmb_rtoken_handling(struct smc_connection *conn, 221 217 struct smc_clc_msg_accept_confirm *clc); 222 218 int smc_rtoken_add(struct smc_link_group *lgr, __be64 nw_vaddr, __be32 nw_rkey); ··· 227 219 void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn); 228 220 void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn); 229 221 void smc_rmb_sync_sg_for_device(struct smc_connection *conn); 222 + void smc_conn_free(struct smc_connection *conn); 223 + int smc_conn_create(struct smc_sock *smc, 224 + struct smc_ib_device *smcibdev, u8 ibport, 225 + struct smc_clc_msg_local *lcl, int srv_first_contact); 230 226 void smc_core_exit(void); 231 227 #endif