xref: /linux/include/linux/ism.h (revision 07fdad3a93756b872da7b53647715c48d0f4a2d0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  Internal Shared Memory
4  *
5  *  Definitions for the ISM module
6  *
7  *  Copyright IBM Corp. 2022
8  */
9 #ifndef _ISM_H
10 #define _ISM_H
11 
12 #include <linux/workqueue.h>
13 
14 /* Unless we gain unexpected popularity, this limit should hold for a while */
15 #define MAX_CLIENTS		8
16 #define ISM_NR_DMBS		1920
17 
18 struct ism_dev {
19 	spinlock_t lock; /* protects the ism device */
20 	spinlock_t cmd_lock; /* serializes cmds */
21 	struct list_head list;
22 	struct dibs_dev *dibs;
23 	struct pci_dev *pdev;
24 
25 	struct ism_sba *sba;
26 	dma_addr_t sba_dma_addr;
27 	DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS);
28 	void *priv[MAX_CLIENTS];
29 
30 	struct ism_eq *ieq;
31 	dma_addr_t ieq_dma_addr;
32 
33 	int ieq_idx;
34 
35 	struct ism_client *subs[MAX_CLIENTS];
36 };
37 
38 struct ism_event {
39 	u32 type;
40 	u32 code;
41 	u64 tok;
42 	u64 time;
43 	u64 info;
44 };
45 
46 struct ism_client {
47 	const char *name;
48 	void (*handle_event)(struct ism_dev *dev, struct ism_event *event);
49 	/* Private area - don't touch! */
50 	u8 id;
51 };
52 
53 int ism_register_client(struct ism_client *client);
54 int  ism_unregister_client(struct ism_client *client);
55 static inline void *ism_get_priv(struct ism_dev *dev,
56 				 struct ism_client *client) {
57 	return dev->priv[client->id];
58 }
59 
60 static inline void ism_set_priv(struct ism_dev *dev, struct ism_client *client,
61 				void *priv) {
62 	dev->priv[client->id] = priv;
63 }
64 
65 const struct smcd_ops *ism_get_smcd_ops(void);
66 
67 #endif	/* _ISM_H */
68