Skip to content

Commit c6ba7c9

Browse files
Hans Wippeldavem330
authored andcommitted
net/smc: add base infrastructure for SMC-D and ISM
SMC supports two variants: SMC-R and SMC-D. For data transport, SMC-R uses RDMA devices, SMC-D uses so-called Internal Shared Memory (ISM) devices. An ISM device only allows shared memory communication between SMC instances on the same machine. For example, this allows virtual machines on the same host to communicate via SMC without RDMA devices. This patch adds the base infrastructure for SMC-D and ISM devices to the existing SMC code. It contains the following: * ISM driver interface: This interface allows an ISM driver to register ISM devices in SMC. In the process, the driver provides a set of device ops for each device. SMC uses these ops to execute SMC specific operations on or transfer data over the device. * Core SMC-D link group, connection, and buffer support: Link groups, SMC connections and SMC buffers (in smc_core) are extended to support SMC-D. * SMC type checks: Some type checks are added to prevent using SMC-R specific code for SMC-D and vice versa. To actually use SMC-D, additional changes to pnetid, CLC, CDC, etc. are required. These are added in follow-up patches. Signed-off-by: Hans Wippel <[email protected]> Signed-off-by: Ursula Braun <[email protected]> Suggested-by: Thomas Richter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e82f2e3 commit c6ba7c9

File tree

8 files changed

+679
-92
lines changed

8 files changed

+679
-92
lines changed

include/net/smc.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,66 @@ struct smc_hashinfo {
2020

2121
int smc_hash_sk(struct sock *sk);
2222
void smc_unhash_sk(struct sock *sk);
23+
24+
/* SMCD/ISM device driver interface */
25+
struct smcd_dmb {
26+
u64 dmb_tok;
27+
u64 rgid;
28+
u32 dmb_len;
29+
u32 sba_idx;
30+
u32 vlan_valid;
31+
u32 vlan_id;
32+
void *cpu_addr;
33+
dma_addr_t dma_addr;
34+
};
35+
36+
#define ISM_EVENT_DMB 0
37+
#define ISM_EVENT_GID 1
38+
#define ISM_EVENT_SWR 2
39+
40+
struct smcd_event {
41+
u32 type;
42+
u32 code;
43+
u64 tok;
44+
u64 time;
45+
u64 info;
46+
};
47+
48+
struct smcd_dev;
49+
50+
struct smcd_ops {
51+
int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
52+
u32 vid);
53+
int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
54+
int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
55+
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
56+
int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
57+
int (*set_vlan_required)(struct smcd_dev *dev);
58+
int (*reset_vlan_required)(struct smcd_dev *dev);
59+
int (*signal_event)(struct smcd_dev *dev, u64 rgid, u32 trigger_irq,
60+
u32 event_code, u64 info);
61+
int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
62+
bool sf, unsigned int offset, void *data,
63+
unsigned int size);
64+
};
65+
66+
struct smcd_dev {
67+
const struct smcd_ops *ops;
68+
struct device dev;
69+
void *priv;
70+
u64 local_gid;
71+
struct list_head list;
72+
spinlock_t lock;
73+
struct smc_connection **conn;
74+
struct list_head vlan;
75+
struct workqueue_struct *event_wq;
76+
};
77+
78+
struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
79+
const struct smcd_ops *ops, int max_dmbs);
80+
int smcd_register_dev(struct smcd_dev *smcd);
81+
void smcd_unregister_dev(struct smcd_dev *smcd);
82+
void smcd_free_dev(struct smcd_dev *smcd);
83+
void smcd_handle_event(struct smcd_dev *dev, struct smcd_event *event);
84+
void smcd_handle_irq(struct smcd_dev *dev, unsigned int bit);
2385
#endif /* _SMC_H */

net/smc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
obj-$(CONFIG_SMC) += smc.o
22
obj-$(CONFIG_SMC_DIAG) += smc_diag.o
33
smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o
4-
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o
4+
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o

net/smc/af_smc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ static int smc_connect_rdma(struct smc_sock *smc,
475475
int reason_code = 0;
476476

477477
mutex_lock(&smc_create_lgr_pending);
478-
local_contact = smc_conn_create(smc, ibdev, ibport, &aclc->lcl,
479-
aclc->hdr.flag);
478+
local_contact = smc_conn_create(smc, false, aclc->hdr.flag, ibdev,
479+
ibport, &aclc->lcl, NULL, 0);
480480
if (local_contact < 0) {
481481
if (local_contact == -ENOMEM)
482482
reason_code = SMC_CLC_DECL_MEM;/* insufficient memory*/
@@ -491,7 +491,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
491491
smc_conn_save_peer_info(smc, aclc);
492492

493493
/* create send buffer and rmb */
494-
if (smc_buf_create(smc))
494+
if (smc_buf_create(smc, false))
495495
return smc_connect_abort(smc, SMC_CLC_DECL_MEM, local_contact);
496496

497497
if (local_contact == SMC_FIRST_CONTACT)
@@ -894,15 +894,16 @@ static int smc_listen_rdma_init(struct smc_sock *new_smc,
894894
int *local_contact)
895895
{
896896
/* allocate connection / link group */
897-
*local_contact = smc_conn_create(new_smc, ibdev, ibport, &pclc->lcl, 0);
897+
*local_contact = smc_conn_create(new_smc, false, 0, ibdev, ibport,
898+
&pclc->lcl, NULL, 0);
898899
if (*local_contact < 0) {
899900
if (*local_contact == -ENOMEM)
900901
return SMC_CLC_DECL_MEM;/* insufficient memory*/
901902
return SMC_CLC_DECL_INTERR; /* other error */
902903
}
903904

904905
/* create send buffer and rmb */
905-
if (smc_buf_create(new_smc))
906+
if (smc_buf_create(new_smc, false))
906907
return SMC_CLC_DECL_MEM;
907908

908909
return 0;

0 commit comments

Comments
 (0)