Ursula Braun | ac71387 | 2017-01-09 16:55:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Shared Memory Communications over RDMA (SMC-R) and RoCE |
| 3 | * |
| 4 | * Definitions for the SMC module (socket related) |
| 5 | * |
| 6 | * Copyright IBM Corp. 2016 |
| 7 | * |
| 8 | * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com> |
| 9 | */ |
| 10 | #ifndef __SMC_H |
| 11 | #define __SMC_H |
| 12 | |
| 13 | #include <linux/socket.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <net/sock.h> |
| 16 | |
| 17 | #define SMCPROTO_SMC 0 /* SMC protocol */ |
| 18 | |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 19 | #define SMC_MAX_PORTS 2 /* Max # of ports */ |
| 20 | |
Ursula Braun | ac71387 | 2017-01-09 16:55:13 +0100 | [diff] [blame] | 21 | enum smc_state { /* possible states of an SMC socket */ |
| 22 | SMC_ACTIVE = 1, |
| 23 | SMC_INIT = 2, |
| 24 | SMC_CLOSED = 7, |
| 25 | SMC_LISTEN = 10, |
| 26 | }; |
| 27 | |
| 28 | struct smc_sock { /* smc sock container */ |
| 29 | struct sock sk; |
| 30 | struct socket *clcsock; /* internal tcp socket */ |
Ursula Braun | a046d57 | 2017-01-09 16:55:16 +0100 | [diff] [blame^] | 31 | struct sockaddr *addr; /* inet connect address */ |
| 32 | struct smc_sock *listen_smc; /* listen parent */ |
| 33 | struct work_struct tcp_listen_work;/* handle tcp socket accepts */ |
| 34 | struct work_struct smc_listen_work;/* prepare new accept socket */ |
| 35 | struct list_head accept_q; /* sockets to be accepted */ |
| 36 | spinlock_t accept_q_lock; /* protects accept_q */ |
Ursula Braun | ac71387 | 2017-01-09 16:55:13 +0100 | [diff] [blame] | 37 | bool use_fallback; /* fallback to tcp */ |
| 38 | }; |
| 39 | |
| 40 | static inline struct smc_sock *smc_sk(const struct sock *sk) |
| 41 | { |
| 42 | return (struct smc_sock *)sk; |
| 43 | } |
| 44 | |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 45 | #define SMC_SYSTEMID_LEN 8 |
| 46 | |
| 47 | extern u8 local_systemid[SMC_SYSTEMID_LEN]; /* unique system identifier */ |
| 48 | |
Ursula Braun | a046d57 | 2017-01-09 16:55:16 +0100 | [diff] [blame^] | 49 | #ifdef CONFIG_XFRM |
| 50 | static inline bool using_ipsec(struct smc_sock *smc) |
| 51 | { |
| 52 | return (smc->clcsock->sk->sk_policy[0] || |
| 53 | smc->clcsock->sk->sk_policy[1]) ? 1 : 0; |
| 54 | } |
| 55 | #else |
| 56 | static inline bool using_ipsec(struct smc_sock *smc) |
| 57 | { |
| 58 | return 0; |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 | int smc_netinfo_by_tcpsk(struct socket *clcsock, __be32 *subnet, |
| 63 | u8 *prefix_len); |
| 64 | |
Ursula Braun | ac71387 | 2017-01-09 16:55:13 +0100 | [diff] [blame] | 65 | #endif /* __SMC_H */ |