| 1 |
|
| 2 | |
| 3 | * Shared Memory Communications over RDMA (SMC-R) and RoCE
|
| 4 | *
|
| 5 | * Definitions for the SMC module (socket related)
|
| 6 | *
|
| 7 | * Copyright IBM Corp. 2016
|
| 8 | *
|
| 9 | * Author(s): Ursula Braun <[email protected]>
|
| 10 |
|
| 11 | #ifndef _SMC_H
|
| 12 | #define _SMC_H
|
| 13 |
|
| 14 | #include <linux/device.h>
|
| 15 | #include <linux/spinlock.h>
|
| 16 | #include <linux/types.h>
|
| 17 | #include <linux/wait.h>
|
| 18 | #include <linux/dibs.h>
|
| 19 |
|
| 20 | struct tcp_sock;
|
| 21 | struct inet_request_sock;
|
| 22 | struct sock;
|
| 23 |
|
| 24 | #define SMC_MAX_PNETID_LEN 16
|
| 25 |
|
| 26 | struct smc_hashinfo {
|
| 27 | rwlock_t lock;
|
| 28 | struct hlist_head ht;
|
| 29 | };
|
| 30 |
|
| 31 |
|
| 32 | #define ISM_RESERVED_VLANID 0x1FFF
|
| 33 |
|
| 34 | struct smcd_gid {
|
| 35 | u64 gid;
|
| 36 | u64 gid_ext;
|
| 37 | };
|
| 38 |
|
| 39 | struct smcd_dev {
|
| 40 | struct dibs_dev *dibs;
|
| 41 | struct list_head list;
|
| 42 | spinlock_t lock;
|
| 43 | struct list_head vlan;
|
| 44 | struct workqueue_struct *event_wq;
|
| 45 | u8 pnetid[SMC_MAX_PNETID_LEN];
|
| 46 | bool pnetid_by_user;
|
| 47 | struct list_head lgr_list;
|
| 48 | spinlock_t lgr_lock;
|
| 49 | atomic_t lgr_cnt;
|
| 50 | wait_queue_head_t lgrs_deleted;
|
| 51 | u8 going_away : 1;
|
| 52 | struct smc_connection *conn[];
|
| 53 | };
|
| 54 |
|
| 55 | #define SMC_HS_CTRL_NAME_MAX 16
|
| 56 |
|
| 57 | enum {
|
| 58 |
|
| 59 | SMC_HS_CTRL_FLAG_INHERITABLE = 0x1,
|
| 60 |
|
| 61 | SMC_HS_CTRL_ALL_FLAGS = SMC_HS_CTRL_FLAG_INHERITABLE,
|
| 62 | };
|
| 63 |
|
| 64 | struct smc_hs_ctrl {
|
| 65 |
|
| 66 |
|
| 67 | struct list_head list;
|
| 68 | struct module *owner;
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 | char name[SMC_HS_CTRL_NAME_MAX];
|
| 74 | int flags;
|
| 75 |
|
| 76 | |
| 77 | * We can control whether to set SMC options by returning various value.
|
| 78 | * Return 0 to disable SMC, or return any other value to enable it.
|
| 79 |
|
| 80 | int (*syn_option)(struct tcp_sock *tp);
|
| 81 |
|
| 82 | |
| 83 | * We can control whether to respond SMC options by returning various
|
| 84 | * value. Return 0 to disable SMC, or return any other value to enable
|
| 85 | * it.
|
| 86 |
|
| 87 | int (*synack_option)(const struct tcp_sock *tp,
|
| 88 | struct inet_request_sock *ireq);
|
| 89 | };
|
| 90 |
|
| 91 | #if IS_ENABLED(CONFIG_SMC_HS_CTRL_BPF)
|
| 92 | #define smc_call_hsbpf(init_val, tp, func, ...) ({ \
|
| 93 | typeof(init_val) __ret = (init_val); \
|
| 94 | struct smc_hs_ctrl *ctrl; \
|
| 95 | rcu_read_lock(); \
|
| 96 | ctrl = rcu_dereference(sock_net((struct sock *)(tp))->smc.hs_ctrl); \
|
| 97 | if (ctrl && ctrl->func) \
|
| 98 | __ret = ctrl->func(tp, ##__VA_ARGS__); \
|
| 99 | rcu_read_unlock(); \
|
| 100 | __ret; \
|
| 101 | })
|
| 102 | #else
|
| 103 | #define smc_call_hsbpf(init_val, tp, ...) ({ (void)(tp); (init_val); })
|
| 104 | #endif
|
| 105 |
|
| 106 | #endif
|