smc.h 2.31 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4 5 6 7 8 9 10 11 12 13
/*
 *  Shared Memory Communications over RDMA (SMC-R) and RoCE
 *
 *  Definitions for the SMC module (socket related)
 *
 *  Copyright IBM Corp. 2016
 *
 *  Author(s):  Ursula Braun <ubraun@linux.vnet.ibm.com>
 */
#ifndef _SMC_H
#define _SMC_H

14 15 16 17
#include <linux/device.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/wait.h>
18
#include "linux/ism.h"
19 20 21

struct sock;

Ursula Braun's avatar
Ursula Braun committed
22 23
#define SMC_MAX_PNETID_LEN	16	/* Max. length of PNET id */

24 25 26 27 28 29 30
struct smc_hashinfo {
	rwlock_t lock;
	struct hlist_head ht;
};

int smc_hash_sk(struct sock *sk);
void smc_unhash_sk(struct sock *sk);
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

/* SMCD/ISM device driver interface */
struct smcd_dmb {
	u64 dmb_tok;
	u64 rgid;
	u32 dmb_len;
	u32 sba_idx;
	u32 vlan_valid;
	u32 vlan_id;
	void *cpu_addr;
	dma_addr_t dma_addr;
};

#define ISM_EVENT_DMB	0
#define ISM_EVENT_GID	1
#define ISM_EVENT_SWR	2

48 49
#define ISM_RESERVED_VLANID	0x1FFF

50 51
#define ISM_ERROR	0xFFFF

52
struct smcd_dev;
53
struct ism_client;
54

55 56 57 58 59
struct smcd_gid {
	u64	gid;
	u64	gid_ext;
};

60
struct smcd_ops {
61 62
	int (*query_remote_gid)(struct smcd_dev *dev, struct smcd_gid *rgid,
				u32 vid_valid, u32 vid);
63 64
	int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb,
			    struct ism_client *client);
65 66 67 68 69
	int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
	int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
	int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
	int (*set_vlan_required)(struct smcd_dev *dev);
	int (*reset_vlan_required)(struct smcd_dev *dev);
70 71
	int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid,
			    u32 trigger_irq, u32 event_code, u64 info);
72 73 74
	int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
			 bool sf, unsigned int offset, void *data,
			 unsigned int size);
75
	int (*supports_v2)(void);
76
	void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
77
	u16 (*get_chid)(struct smcd_dev *dev);
78
	struct device* (*get_dev)(struct smcd_dev *dev);
79 80 81 82 83 84 85 86 87 88
};

struct smcd_dev {
	const struct smcd_ops *ops;
	void *priv;
	struct list_head list;
	spinlock_t lock;
	struct smc_connection **conn;
	struct list_head vlan;
	struct workqueue_struct *event_wq;
89
	u8 pnetid[SMC_MAX_PNETID_LEN];
90
	bool pnetid_by_user;
91
	struct list_head lgr_list;
92
	spinlock_t lgr_lock;
93 94
	atomic_t lgr_cnt;
	wait_queue_head_t lgrs_deleted;
95
	u8 going_away : 1;
96 97
};

98
#endif	/* _SMC_H */