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 struct ism_dmb { 15 u64 dmb_tok; 16 u64 rgid; 17 u32 dmb_len; 18 u32 sba_idx; 19 u32 vlan_valid; 20 u32 vlan_id; 21 void *cpu_addr; 22 dma_addr_t dma_addr; 23 }; 24 25 /* Unless we gain unexpected popularity, this limit should hold for a while */ 26 #define MAX_CLIENTS 8 27 #define ISM_NR_DMBS 1920 28 29 struct ism_dev { 30 spinlock_t lock; /* protects the ism device */ 31 spinlock_t cmd_lock; /* serializes cmds */ 32 struct list_head list; 33 struct dibs_dev *dibs; 34 struct pci_dev *pdev; 35 36 struct ism_sba *sba; 37 dma_addr_t sba_dma_addr; 38 DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS); 39 u8 *sba_client_arr; /* entries are indices into 'clients' array */ 40 void *priv[MAX_CLIENTS]; 41 42 struct ism_eq *ieq; 43 dma_addr_t ieq_dma_addr; 44 45 int ieq_idx; 46 47 struct ism_client *subs[MAX_CLIENTS]; 48 }; 49 50 struct ism_event { 51 u32 type; 52 u32 code; 53 u64 tok; 54 u64 time; 55 u64 info; 56 }; 57 58 struct ism_client { 59 const char *name; 60 void (*handle_event)(struct ism_dev *dev, struct ism_event *event); 61 /* Parameter dmbemask contains a bit vector with updated DMBEs, if sent 62 * via ism_move_data(). Callback function must handle all active bits 63 * indicated by dmbemask. 64 */ 65 void (*handle_irq)(struct ism_dev *dev, unsigned int bit, u16 dmbemask); 66 /* Private area - don't touch! */ 67 u8 id; 68 }; 69 70 int ism_register_client(struct ism_client *client); 71 int ism_unregister_client(struct ism_client *client); 72 static inline void *ism_get_priv(struct ism_dev *dev, 73 struct ism_client *client) { 74 return dev->priv[client->id]; 75 } 76 77 static inline void ism_set_priv(struct ism_dev *dev, struct ism_client *client, 78 void *priv) { 79 dev->priv[client->id] = priv; 80 } 81 82 int ism_register_dmb(struct ism_dev *dev, struct ism_dmb *dmb, 83 struct ism_client *client); 84 int ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb); 85 int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf, 86 unsigned int offset, void *data, unsigned int size); 87 88 const struct smcd_ops *ism_get_smcd_ops(void); 89 90 #endif /* _ISM_H */ 91