Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Shared Memory Communications over RDMA (SMC-R) and RoCE
0004  *
0005  *  Definitions for the SMC module (socket related)
0006  *
0007  *  Copyright IBM Corp. 2016
0008  *
0009  *  Author(s):  Ursula Braun <ubraun@linux.vnet.ibm.com>
0010  */
0011 #ifndef _SMC_H
0012 #define _SMC_H
0013 
0014 #include <linux/device.h>
0015 #include <linux/spinlock.h>
0016 #include <linux/types.h>
0017 #include <linux/wait.h>
0018 
0019 struct sock;
0020 
0021 #define SMC_MAX_PNETID_LEN  16  /* Max. length of PNET id */
0022 
0023 struct smc_hashinfo {
0024     rwlock_t lock;
0025     struct hlist_head ht;
0026 };
0027 
0028 int smc_hash_sk(struct sock *sk);
0029 void smc_unhash_sk(struct sock *sk);
0030 
0031 /* SMCD/ISM device driver interface */
0032 struct smcd_dmb {
0033     u64 dmb_tok;
0034     u64 rgid;
0035     u32 dmb_len;
0036     u32 sba_idx;
0037     u32 vlan_valid;
0038     u32 vlan_id;
0039     void *cpu_addr;
0040     dma_addr_t dma_addr;
0041 };
0042 
0043 #define ISM_EVENT_DMB   0
0044 #define ISM_EVENT_GID   1
0045 #define ISM_EVENT_SWR   2
0046 
0047 #define ISM_RESERVED_VLANID 0x1FFF
0048 
0049 #define ISM_ERROR   0xFFFF
0050 
0051 struct smcd_event {
0052     u32 type;
0053     u32 code;
0054     u64 tok;
0055     u64 time;
0056     u64 info;
0057 };
0058 
0059 struct smcd_dev;
0060 
0061 struct smcd_ops {
0062     int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
0063                 u32 vid);
0064     int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
0065     int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
0066     int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
0067     int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
0068     int (*set_vlan_required)(struct smcd_dev *dev);
0069     int (*reset_vlan_required)(struct smcd_dev *dev);
0070     int (*signal_event)(struct smcd_dev *dev, u64 rgid, u32 trigger_irq,
0071                 u32 event_code, u64 info);
0072     int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
0073              bool sf, unsigned int offset, void *data,
0074              unsigned int size);
0075     u8* (*get_system_eid)(void);
0076     u16 (*get_chid)(struct smcd_dev *dev);
0077 };
0078 
0079 struct smcd_dev {
0080     const struct smcd_ops *ops;
0081     struct device dev;
0082     void *priv;
0083     u64 local_gid;
0084     struct list_head list;
0085     spinlock_t lock;
0086     struct smc_connection **conn;
0087     struct list_head vlan;
0088     struct workqueue_struct *event_wq;
0089     u8 pnetid[SMC_MAX_PNETID_LEN];
0090     bool pnetid_by_user;
0091     struct list_head lgr_list;
0092     spinlock_t lgr_lock;
0093     atomic_t lgr_cnt;
0094     wait_queue_head_t lgrs_deleted;
0095     u8 going_away : 1;
0096 };
0097 
0098 struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
0099                 const struct smcd_ops *ops, int max_dmbs);
0100 int smcd_register_dev(struct smcd_dev *smcd);
0101 void smcd_unregister_dev(struct smcd_dev *smcd);
0102 void smcd_free_dev(struct smcd_dev *smcd);
0103 void smcd_handle_event(struct smcd_dev *dev, struct smcd_event *event);
0104 void smcd_handle_irq(struct smcd_dev *dev, unsigned int bit, u16 dmbemask);
0105 #endif  /* _SMC_H */