0001
0002 #ifndef S390_ISM_H
0003 #define S390_ISM_H
0004
0005 #include <linux/spinlock.h>
0006 #include <linux/types.h>
0007 #include <linux/pci.h>
0008 #include <net/smc.h>
0009 #include <asm/pci_insn.h>
0010
0011 #define UTIL_STR_LEN 16
0012
0013
0014
0015
0016 #define ISM_DMB_WORD_OFFSET 1
0017 #define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32)
0018 #define ISM_NR_DMBS 1920
0019 #define ISM_IDENT_MASK 0x00FFFF
0020
0021 #define ISM_REG_SBA 0x1
0022 #define ISM_REG_IEQ 0x2
0023 #define ISM_READ_GID 0x3
0024 #define ISM_ADD_VLAN_ID 0x4
0025 #define ISM_DEL_VLAN_ID 0x5
0026 #define ISM_SET_VLAN 0x6
0027 #define ISM_RESET_VLAN 0x7
0028 #define ISM_QUERY_INFO 0x8
0029 #define ISM_QUERY_RGID 0x9
0030 #define ISM_REG_DMB 0xA
0031 #define ISM_UNREG_DMB 0xB
0032 #define ISM_SIGNAL_IEQ 0xE
0033 #define ISM_UNREG_SBA 0x11
0034 #define ISM_UNREG_IEQ 0x12
0035
0036 struct ism_req_hdr {
0037 u32 cmd;
0038 u16 : 16;
0039 u16 len;
0040 };
0041
0042 struct ism_resp_hdr {
0043 u32 cmd;
0044 u16 ret;
0045 u16 len;
0046 };
0047
0048 union ism_reg_sba {
0049 struct {
0050 struct ism_req_hdr hdr;
0051 u64 sba;
0052 } request;
0053 struct {
0054 struct ism_resp_hdr hdr;
0055 } response;
0056 } __aligned(16);
0057
0058 union ism_reg_ieq {
0059 struct {
0060 struct ism_req_hdr hdr;
0061 u64 ieq;
0062 u64 len;
0063 } request;
0064 struct {
0065 struct ism_resp_hdr hdr;
0066 } response;
0067 } __aligned(16);
0068
0069 union ism_read_gid {
0070 struct {
0071 struct ism_req_hdr hdr;
0072 } request;
0073 struct {
0074 struct ism_resp_hdr hdr;
0075 u64 gid;
0076 } response;
0077 } __aligned(16);
0078
0079 union ism_qi {
0080 struct {
0081 struct ism_req_hdr hdr;
0082 } request;
0083 struct {
0084 struct ism_resp_hdr hdr;
0085 u32 version;
0086 u32 max_len;
0087 u64 ism_state;
0088 u64 my_gid;
0089 u64 sba;
0090 u64 ieq;
0091 u32 ieq_len;
0092 u32 : 32;
0093 u32 dmbs_owned;
0094 u32 dmbs_used;
0095 u32 vlan_required;
0096 u32 vlan_nr_ids;
0097 u16 vlan_id[64];
0098 } response;
0099 } __aligned(64);
0100
0101 union ism_query_rgid {
0102 struct {
0103 struct ism_req_hdr hdr;
0104 u64 rgid;
0105 u32 vlan_valid;
0106 u32 vlan_id;
0107 } request;
0108 struct {
0109 struct ism_resp_hdr hdr;
0110 } response;
0111 } __aligned(16);
0112
0113 union ism_reg_dmb {
0114 struct {
0115 struct ism_req_hdr hdr;
0116 u64 dmb;
0117 u32 dmb_len;
0118 u32 sba_idx;
0119 u32 vlan_valid;
0120 u32 vlan_id;
0121 u64 rgid;
0122 } request;
0123 struct {
0124 struct ism_resp_hdr hdr;
0125 u64 dmb_tok;
0126 } response;
0127 } __aligned(32);
0128
0129 union ism_sig_ieq {
0130 struct {
0131 struct ism_req_hdr hdr;
0132 u64 rgid;
0133 u32 trigger_irq;
0134 u32 event_code;
0135 u64 info;
0136 } request;
0137 struct {
0138 struct ism_resp_hdr hdr;
0139 } response;
0140 } __aligned(32);
0141
0142 union ism_unreg_dmb {
0143 struct {
0144 struct ism_req_hdr hdr;
0145 u64 dmb_tok;
0146 } request;
0147 struct {
0148 struct ism_resp_hdr hdr;
0149 } response;
0150 } __aligned(16);
0151
0152 union ism_cmd_simple {
0153 struct {
0154 struct ism_req_hdr hdr;
0155 } request;
0156 struct {
0157 struct ism_resp_hdr hdr;
0158 } response;
0159 } __aligned(8);
0160
0161 union ism_set_vlan_id {
0162 struct {
0163 struct ism_req_hdr hdr;
0164 u64 vlan_id;
0165 } request;
0166 struct {
0167 struct ism_resp_hdr hdr;
0168 } response;
0169 } __aligned(16);
0170
0171 struct ism_eq_header {
0172 u64 idx;
0173 u64 ieq_len;
0174 u64 entry_len;
0175 u64 : 64;
0176 };
0177
0178 struct ism_eq {
0179 struct ism_eq_header header;
0180 struct smcd_event entry[15];
0181 };
0182
0183 struct ism_sba {
0184 u32 s : 1;
0185 u32 e : 1;
0186 u32 : 30;
0187 u32 dmb_bits[ISM_NR_DMBS / 32];
0188 u32 reserved[3];
0189 u16 dmbe_mask[ISM_NR_DMBS];
0190 };
0191
0192 struct ism_dev {
0193 spinlock_t lock;
0194 struct pci_dev *pdev;
0195 struct smcd_dev *smcd;
0196
0197 struct ism_sba *sba;
0198 dma_addr_t sba_dma_addr;
0199 DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS);
0200
0201 struct ism_eq *ieq;
0202 dma_addr_t ieq_dma_addr;
0203
0204 int ieq_idx;
0205 };
0206
0207 #define ISM_CREATE_REQ(dmb, idx, sf, offset) \
0208 ((dmb) | (idx) << 24 | (sf) << 23 | (offset))
0209
0210 struct ism_systemeid {
0211 u8 seid_string[24];
0212 u8 serial_number[4];
0213 u8 type[4];
0214 };
0215
0216 static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
0217 unsigned long offset, unsigned long len)
0218 {
0219 struct zpci_dev *zdev = to_zpci(ism->pdev);
0220 u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, 8);
0221
0222 while (len > 0) {
0223 __zpci_load(data, req, offset);
0224 offset += 8;
0225 data += 8;
0226 len -= 8;
0227 }
0228 }
0229
0230 static inline void __ism_write_cmd(struct ism_dev *ism, void *data,
0231 unsigned long offset, unsigned long len)
0232 {
0233 struct zpci_dev *zdev = to_zpci(ism->pdev);
0234 u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, len);
0235
0236 if (len)
0237 __zpci_store_block(data, req, offset);
0238 }
0239
0240 static inline int __ism_move(struct ism_dev *ism, u64 dmb_req, void *data,
0241 unsigned int size)
0242 {
0243 struct zpci_dev *zdev = to_zpci(ism->pdev);
0244 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, size);
0245
0246 return __zpci_store_block(data, req, dmb_req);
0247 }
0248
0249 #endif