1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/spinlock.h>
6 #include <linux/types.h>
9 #include <asm/pci_insn.h>
11 #define UTIL_STR_LEN 16
14 * Do not use the first word of the DMB bits to ensure 8 byte aligned access.
16 #define ISM_DMB_WORD_OFFSET 1
17 #define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32)
18 #define ISM_NR_DMBS 1920
20 #define ISM_REG_SBA 0x1
21 #define ISM_REG_IEQ 0x2
22 #define ISM_READ_GID 0x3
23 #define ISM_ADD_VLAN_ID 0x4
24 #define ISM_DEL_VLAN_ID 0x5
25 #define ISM_SET_VLAN 0x6
26 #define ISM_RESET_VLAN 0x7
27 #define ISM_QUERY_INFO 0x8
28 #define ISM_QUERY_RGID 0x9
29 #define ISM_REG_DMB 0xA
30 #define ISM_UNREG_DMB 0xB
31 #define ISM_SIGNAL_IEQ 0xE
32 #define ISM_UNREG_SBA 0x11
33 #define ISM_UNREG_IEQ 0x12
35 #define ISM_ERROR 0xFFFF
51 struct ism_req_hdr hdr;
55 struct ism_resp_hdr hdr;
61 struct ism_req_hdr hdr;
66 struct ism_resp_hdr hdr;
72 struct ism_req_hdr hdr;
75 struct ism_resp_hdr hdr;
82 struct ism_req_hdr hdr;
85 struct ism_resp_hdr hdr;
102 union ism_query_rgid {
104 struct ism_req_hdr hdr;
110 struct ism_resp_hdr hdr;
116 struct ism_req_hdr hdr;
125 struct ism_resp_hdr hdr;
132 struct ism_req_hdr hdr;
139 struct ism_resp_hdr hdr;
143 union ism_unreg_dmb {
145 struct ism_req_hdr hdr;
149 struct ism_resp_hdr hdr;
153 union ism_cmd_simple {
155 struct ism_req_hdr hdr;
158 struct ism_resp_hdr hdr;
162 union ism_set_vlan_id {
164 struct ism_req_hdr hdr;
168 struct ism_resp_hdr hdr;
172 struct ism_eq_header {
180 struct ism_eq_header header;
181 struct smcd_event entry[15];
185 u32 s : 1; /* summary bit */
186 u32 e : 1; /* event bit */
188 u32 dmb_bits[ISM_NR_DMBS / 32];
190 u16 dmbe_mask[ISM_NR_DMBS];
195 struct pci_dev *pdev;
196 struct smcd_dev *smcd;
199 dma_addr_t sba_dma_addr;
200 DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS);
203 dma_addr_t ieq_dma_addr;
208 #define ISM_CREATE_REQ(dmb, idx, sf, offset) \
209 ((dmb) | (idx) << 24 | (sf) << 23 | (offset))
211 static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
212 unsigned long offset, unsigned long len)
214 struct zpci_dev *zdev = to_zpci(ism->pdev);
215 u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, 8);
218 __zpci_load(data, req, offset);
225 static inline void __ism_write_cmd(struct ism_dev *ism, void *data,
226 unsigned long offset, unsigned long len)
228 struct zpci_dev *zdev = to_zpci(ism->pdev);
229 u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, len);
232 __zpci_store_block(data, req, offset);
235 static inline int __ism_move(struct ism_dev *ism, u64 dmb_req, void *data,
238 struct zpci_dev *zdev = to_zpci(ism->pdev);
239 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, size);
241 return __zpci_store_block(data, req, dmb_req);
244 #endif /* S390_ISM_H */