at master 2.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 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 <ubraun@linux.vnet.ibm.com> 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 20struct tcp_sock; 21struct inet_request_sock; 22struct sock; 23 24#define SMC_MAX_PNETID_LEN 16 /* Max. length of PNET id */ 25 26struct smc_hashinfo { 27 rwlock_t lock; 28 struct hlist_head ht; 29}; 30 31/* SMCD/ISM device driver interface */ 32#define ISM_RESERVED_VLANID 0x1FFF 33 34struct smcd_gid { 35 u64 gid; 36 u64 gid_ext; 37}; 38 39struct smcd_dev { 40 struct dibs_dev *dibs; 41 struct list_head list; 42 spinlock_t lock; 43 struct smc_connection **conn; 44 struct list_head vlan; 45 struct workqueue_struct *event_wq; 46 u8 pnetid[SMC_MAX_PNETID_LEN]; 47 bool pnetid_by_user; 48 struct list_head lgr_list; 49 spinlock_t lgr_lock; 50 atomic_t lgr_cnt; 51 wait_queue_head_t lgrs_deleted; 52 u8 going_away : 1; 53}; 54 55#define SMC_HS_CTRL_NAME_MAX 16 56 57enum { 58 /* ops can be inherit from init_net */ 59 SMC_HS_CTRL_FLAG_INHERITABLE = 0x1, 60 61 SMC_HS_CTRL_ALL_FLAGS = SMC_HS_CTRL_FLAG_INHERITABLE, 62}; 63 64struct smc_hs_ctrl { 65 /* private */ 66 67 struct list_head list; 68 struct module *owner; 69 70 /* public */ 71 72 /* unique name */ 73 char name[SMC_HS_CTRL_NAME_MAX]; 74 int flags; 75 76 /* Invoked before computing SMC option for SYN packets. 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 /* Invoked before Set up SMC options for SYN-ACK packets 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 /* CONFIG_SMC_HS_CTRL_BPF */ 105 106#endif /* _SMC_H */