1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Shared Memory Communications Direct over ISM devices (SMC-D)
4 * SMC-D ISM device structure definitions.
6 * Copyright IBM Corp. 2018
12 #include <linux/uio.h>
13 #include <linux/types.h>
14 #include <linux/mutex.h>
18 #define SMC_VIRTUAL_ISM_CHID_MASK 0xFF00
19 #define SMC_ISM_IDENT_MASK 0x00FFFF
21 struct smcd_dev_list { /* List of SMCD devices */
22 struct list_head list;
23 struct mutex mutex; /* Protects list of devices */
26 extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */
28 struct smc_ism_vlanid { /* VLAN id set on ISM device */
29 struct list_head list;
30 unsigned short vlanid; /* Vlan id */
31 refcount_t refcnt; /* Reference count */
42 int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id,
43 struct smcd_dev *dev);
44 void smc_ism_set_conn(struct smc_connection *conn);
45 void smc_ism_unset_conn(struct smc_connection *conn);
46 int smc_ism_get_vlan(struct smcd_dev *dev, unsigned short vlan_id);
47 int smc_ism_put_vlan(struct smcd_dev *dev, unsigned short vlan_id);
48 int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size,
49 struct smc_buf_desc *dmb_desc);
50 int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc);
51 int smc_ism_signal_shutdown(struct smc_link_group *lgr);
52 void smc_ism_get_system_eid(u8 **eid);
53 u16 smc_ism_get_chid(struct smcd_dev *dev);
54 bool smc_ism_is_v2_capable(void);
55 int smc_ism_init(void);
56 void smc_ism_exit(void);
57 int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);
59 static inline int smc_ism_write(struct smcd_dev *smcd, u64 dmb_tok,
60 unsigned int idx, bool sf, unsigned int offset,
61 void *data, size_t len)
65 rc = smcd->ops->move_data(smcd, dmb_tok, idx, sf, offset, data, len);
66 return rc < 0 ? rc : 0;
69 static inline bool __smc_ism_is_virtual(u16 chid)
71 /* CHIDs in range of 0xFF00 to 0xFFFF are reserved
72 * for virtual ISM device.
74 * loopback-ism: 0xFFFF
75 * virtio-ism: 0xFF00 ~ 0xFFFE
77 return ((chid & 0xFF00) == 0xFF00);
80 static inline bool smc_ism_is_virtual(struct smcd_dev *smcd)
82 u16 chid = smcd->ops->get_chid(smcd);
84 return __smc_ism_is_virtual(chid);