0001
0002
0003
0004
0005
0006 #ifndef _PIO_H
0007 #define _PIO_H
0008
0009 #define SC_KERNEL 0
0010 #define SC_VL15 1
0011 #define SC_ACK 2
0012 #define SC_USER 3
0013 #define SC_MAX 4
0014
0015
0016 #define INVALID_SCI 0xff
0017
0018
0019 typedef void (*pio_release_cb)(void *arg, int code);
0020
0021
0022 #define PRC_OK 0
0023 #define PRC_STATUS_ERR 0x01
0024 #define PRC_PBC 0x02
0025 #define PRC_THRESHOLD 0x04
0026 #define PRC_FILL_ERR 0x08
0027 #define PRC_FORCE 0x10
0028 #define PRC_SC_DISABLE 0x20
0029
0030
0031 union mix {
0032 u64 val64;
0033 u32 val32[2];
0034 u8 val8[8];
0035 };
0036
0037
0038 struct pio_buf {
0039 struct send_context *sc;
0040 pio_release_cb cb;
0041 void *arg;
0042 void __iomem *start;
0043 void __iomem *end;
0044 unsigned long sent_at;
0045 union mix carry;
0046 u16 qw_written;
0047 u8 carry_bytes;
0048 };
0049
0050
0051 union pio_shadow_ring {
0052 struct pio_buf pbuf;
0053 } ____cacheline_aligned;
0054
0055
0056 struct send_context {
0057
0058 struct hfi1_devdata *dd;
0059 union pio_shadow_ring *sr;
0060 void __iomem *base_addr;
0061 u32 __percpu *buffers_allocated;
0062 u32 size;
0063
0064 int node;
0065 u32 sr_size;
0066 u16 flags;
0067 u8 type;
0068 u8 sw_index;
0069 u8 hw_context;
0070 u8 group;
0071
0072
0073 spinlock_t alloc_lock ____cacheline_aligned_in_smp;
0074 u32 sr_head;
0075 unsigned long fill;
0076 unsigned long alloc_free;
0077 u32 fill_wrap;
0078 u32 credits;
0079
0080
0081
0082 spinlock_t release_lock ____cacheline_aligned_in_smp;
0083 u32 sr_tail;
0084 unsigned long free;
0085 volatile __le64 *hw_free;
0086
0087 struct list_head piowait ____cacheline_aligned_in_smp;
0088 seqlock_t waitlock;
0089
0090 spinlock_t credit_ctrl_lock ____cacheline_aligned_in_smp;
0091 u32 credit_intr_count;
0092 u64 credit_ctrl;
0093 wait_queue_head_t halt_wait;
0094 struct work_struct halt_work;
0095 };
0096
0097
0098 #define SCF_ENABLED 0x01
0099 #define SCF_IN_FREE 0x02
0100 #define SCF_HALTED 0x04
0101 #define SCF_FROZEN 0x08
0102 #define SCF_LINK_DOWN 0x10
0103
0104 struct send_context_info {
0105 struct send_context *sc;
0106 u16 allocated;
0107 u16 type;
0108 u16 base;
0109 u16 credits;
0110 };
0111
0112
0113 struct credit_return {
0114 volatile __le64 cr[8];
0115 };
0116
0117
0118 struct credit_return_base {
0119 struct credit_return *va;
0120 dma_addr_t dma;
0121 };
0122
0123
0124 struct sc_config_sizes {
0125 short int size;
0126 short int count;
0127 };
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 #define INIT_SC_PER_VL 2
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 struct pio_map_elem {
0203 u32 mask;
0204 struct send_context *ksc[];
0205 };
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 struct pio_vl_map {
0220 struct rcu_head list;
0221 u32 mask;
0222 u8 actual_vls;
0223 u8 vls;
0224 struct pio_map_elem *map[];
0225 };
0226
0227 int pio_map_init(struct hfi1_devdata *dd, u8 port, u8 num_vls,
0228 u8 *vl_scontexts);
0229 void free_pio_map(struct hfi1_devdata *dd);
0230 struct send_context *pio_select_send_context_vl(struct hfi1_devdata *dd,
0231 u32 selector, u8 vl);
0232 struct send_context *pio_select_send_context_sc(struct hfi1_devdata *dd,
0233 u32 selector, u8 sc5);
0234
0235
0236 int init_credit_return(struct hfi1_devdata *dd);
0237 void free_credit_return(struct hfi1_devdata *dd);
0238 int init_sc_pools_and_sizes(struct hfi1_devdata *dd);
0239 int init_send_contexts(struct hfi1_devdata *dd);
0240 int init_pervl_scs(struct hfi1_devdata *dd);
0241 struct send_context *sc_alloc(struct hfi1_devdata *dd, int type,
0242 uint hdrqentsize, int numa);
0243 void sc_free(struct send_context *sc);
0244 int sc_enable(struct send_context *sc);
0245 void sc_disable(struct send_context *sc);
0246 int sc_restart(struct send_context *sc);
0247 void sc_return_credits(struct send_context *sc);
0248 void sc_flush(struct send_context *sc);
0249 void sc_drop(struct send_context *sc);
0250 void sc_stop(struct send_context *sc, int bit);
0251 struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len,
0252 pio_release_cb cb, void *arg);
0253 void sc_release_update(struct send_context *sc);
0254 void sc_group_release_update(struct hfi1_devdata *dd, u32 hw_context);
0255 void sc_add_credit_return_intr(struct send_context *sc);
0256 void sc_del_credit_return_intr(struct send_context *sc);
0257 void sc_set_cr_threshold(struct send_context *sc, u32 new_threshold);
0258 u32 sc_percent_to_threshold(struct send_context *sc, u32 percent);
0259 u32 sc_mtu_to_threshold(struct send_context *sc, u32 mtu, u32 hdrqentsize);
0260 void hfi1_sc_wantpiobuf_intr(struct send_context *sc, u32 needint);
0261 void sc_wait(struct hfi1_devdata *dd);
0262 void set_pio_integrity(struct send_context *sc);
0263
0264
0265 void pio_reset_all(struct hfi1_devdata *dd);
0266 void pio_freeze(struct hfi1_devdata *dd);
0267 void pio_kernel_unfreeze(struct hfi1_devdata *dd);
0268 void pio_kernel_linkup(struct hfi1_devdata *dd);
0269
0270
0271 #define PSC_GLOBAL_ENABLE 0
0272 #define PSC_GLOBAL_DISABLE 1
0273 #define PSC_GLOBAL_VLARB_ENABLE 2
0274 #define PSC_GLOBAL_VLARB_DISABLE 3
0275 #define PSC_CM_RESET 4
0276 #define PSC_DATA_VL_ENABLE 5
0277 #define PSC_DATA_VL_DISABLE 6
0278
0279 void __cm_reset(struct hfi1_devdata *dd, u64 sendctrl);
0280 void pio_send_control(struct hfi1_devdata *dd, int op);
0281
0282
0283 void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc,
0284 const void *from, size_t count);
0285 void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc,
0286 const void *from, size_t nbytes);
0287 void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes);
0288 void seg_pio_copy_end(struct pio_buf *pbuf);
0289
0290 void seqfile_dump_sci(struct seq_file *s, u32 i,
0291 struct send_context_info *sci);
0292
0293 #endif