0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef __OCTEON_IQ_H__
0025 #define __OCTEON_IQ_H__
0026
0027 #define IQ_STATUS_RUNNING 1
0028
0029 #define IQ_SEND_OK 0
0030 #define IQ_SEND_STOP 1
0031 #define IQ_SEND_FAILED -1
0032
0033
0034
0035
0036
0037 #define REQTYPE_NONE 0
0038 #define REQTYPE_NORESP_NET 1
0039 #define REQTYPE_NORESP_NET_SG 2
0040 #define REQTYPE_RESP_NET 3
0041 #define REQTYPE_RESP_NET_SG 4
0042 #define REQTYPE_SOFT_COMMAND 5
0043 #define REQTYPE_LAST 5
0044
0045 struct octeon_request_list {
0046 u32 reqtype;
0047 void *buf;
0048 };
0049
0050
0051
0052
0053 struct oct_iq_stats {
0054 u64 instr_posted;
0055 u64 instr_processed;
0056 u64 instr_dropped;
0057 u64 bytes_sent;
0058 u64 sgentry_sent;
0059 u64 tx_done;
0060 u64 tx_iq_busy;
0061 u64 tx_dropped;
0062 u64 tx_tot_bytes;
0063 u64 tx_gso;
0064 u64 tx_vxlan;
0065 u64 tx_dmamap_fail;
0066 u64 tx_restart;
0067 };
0068
0069 #define OCT_IQ_STATS_SIZE (sizeof(struct oct_iq_stats))
0070
0071
0072
0073
0074
0075
0076 struct octeon_instr_queue {
0077 struct octeon_device *oct_dev;
0078
0079
0080 spinlock_t lock;
0081
0082
0083 spinlock_t post_lock;
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 bool allow_soft_cmds;
0094
0095 u32 pkt_in_done;
0096
0097 u32 pkts_processed;
0098
0099
0100 spinlock_t iq_flush_running_lock;
0101
0102
0103 u32 iqcmd_64B:1;
0104
0105
0106 union oct_txpciq txpciq;
0107
0108 u32 rsvd:17;
0109
0110
0111 u32 do_auto_flush:1;
0112
0113 u32 status:8;
0114
0115
0116 u32 max_count;
0117
0118
0119 u32 host_write_index;
0120
0121
0122
0123
0124 u32 octeon_read_index;
0125
0126
0127
0128
0129 u32 flush_index;
0130
0131
0132 atomic_t instr_pending;
0133
0134 u32 reset_instr_cnt;
0135
0136
0137 u8 *base_addr;
0138
0139 struct octeon_request_list *request_list;
0140
0141
0142 void __iomem *doorbell_reg;
0143
0144
0145 void __iomem *inst_cnt_reg;
0146
0147
0148 u32 fill_cnt;
0149
0150
0151
0152
0153 u32 fill_threshold;
0154
0155
0156 u64 last_db_time;
0157
0158
0159
0160
0161 u32 db_timeout;
0162
0163
0164 struct oct_iq_stats stats;
0165
0166
0167 dma_addr_t base_addr_dma;
0168
0169
0170 void *app_ctx;
0171
0172
0173 int q_index;
0174
0175
0176 int ifidx;
0177
0178 };
0179
0180
0181
0182
0183
0184
0185 struct octeon_instr_32B {
0186
0187 u64 dptr;
0188
0189
0190 u64 ih;
0191
0192
0193
0194
0195 u64 rptr;
0196
0197
0198 u64 irh;
0199
0200 };
0201
0202 #define OCT_32B_INSTR_SIZE (sizeof(struct octeon_instr_32B))
0203
0204
0205
0206
0207 struct octeon_instr2_64B {
0208
0209 u64 dptr;
0210
0211
0212 u64 ih2;
0213
0214
0215 u64 irh;
0216
0217
0218 u64 ossp[2];
0219
0220
0221 u64 rdp;
0222
0223
0224
0225
0226 u64 rptr;
0227
0228 u64 reserved;
0229 };
0230
0231 struct octeon_instr3_64B {
0232
0233 u64 dptr;
0234
0235
0236 u64 ih3;
0237
0238
0239 u64 pki_ih3;
0240
0241
0242 u64 irh;
0243
0244
0245 u64 ossp[2];
0246
0247
0248 u64 rdp;
0249
0250
0251
0252
0253 u64 rptr;
0254
0255 };
0256
0257 union octeon_instr_64B {
0258 struct octeon_instr2_64B cmd2;
0259 struct octeon_instr3_64B cmd3;
0260 };
0261
0262 #define OCT_64B_INSTR_SIZE (sizeof(union octeon_instr_64B))
0263
0264
0265
0266 #define SOFT_COMMAND_BUFFER_SIZE 2048
0267
0268 struct octeon_soft_command {
0269
0270 struct list_head node;
0271 u64 dma_addr;
0272 u32 size;
0273
0274
0275 union octeon_instr_64B cmd;
0276
0277 #define COMPLETION_WORD_INIT 0xffffffffffffffffULL
0278 u64 *status_word;
0279
0280
0281 void *virtdptr;
0282 u64 dmadptr;
0283 u32 datasize;
0284
0285
0286 void *virtrptr;
0287 u64 dmarptr;
0288 u32 rdatasize;
0289
0290
0291 void *ctxptr;
0292 u32 ctxsize;
0293
0294
0295 size_t expiry_time;
0296 u32 iq_no;
0297 void (*callback)(struct octeon_device *, u32, void *);
0298 void *callback_arg;
0299
0300 int caller_is_done;
0301 u32 sc_status;
0302 struct completion complete;
0303 };
0304
0305
0306 #define LIO_SC_MAX_TMO_MS 60000
0307
0308
0309
0310 #define MAX_SOFT_COMMAND_BUFFERS 256
0311
0312
0313
0314 struct octeon_sc_buffer_pool {
0315
0316 struct list_head head;
0317
0318
0319 spinlock_t lock;
0320
0321 atomic_t alloc_buf_count;
0322 };
0323
0324 #define INCR_INSTRQUEUE_PKT_COUNT(octeon_dev_ptr, iq_no, field, count) \
0325 (((octeon_dev_ptr)->instr_queue[iq_no]->stats.field) += count)
0326
0327 int octeon_setup_sc_buffer_pool(struct octeon_device *oct);
0328 int octeon_free_sc_done_list(struct octeon_device *oct);
0329 int octeon_free_sc_zombie_list(struct octeon_device *oct);
0330 int octeon_free_sc_buffer_pool(struct octeon_device *oct);
0331 struct octeon_soft_command *
0332 octeon_alloc_soft_command(struct octeon_device *oct,
0333 u32 datasize, u32 rdatasize,
0334 u32 ctxsize);
0335 void octeon_free_soft_command(struct octeon_device *oct,
0336 struct octeon_soft_command *sc);
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348 int octeon_init_instr_queue(struct octeon_device *octeon_dev,
0349 union oct_txpciq txpciq,
0350 u32 num_descs);
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362 int octeon_delete_instr_queue(struct octeon_device *octeon_dev, u32 iq_no);
0363
0364 int lio_wait_for_instr_fetch(struct octeon_device *oct);
0365
0366 void
0367 octeon_ring_doorbell_locked(struct octeon_device *oct, u32 iq_no);
0368
0369 int
0370 octeon_register_reqtype_free_fn(struct octeon_device *oct, int reqtype,
0371 void (*fn)(void *));
0372
0373 int
0374 lio_process_iq_request_list(struct octeon_device *oct,
0375 struct octeon_instr_queue *iq, u32 napi_budget);
0376
0377 int octeon_send_command(struct octeon_device *oct, u32 iq_no,
0378 u32 force_db, void *cmd, void *buf,
0379 u32 datasize, u32 reqtype);
0380
0381 void octeon_dump_soft_command(struct octeon_device *oct,
0382 struct octeon_soft_command *sc);
0383
0384 void octeon_prepare_soft_command(struct octeon_device *oct,
0385 struct octeon_soft_command *sc,
0386 u8 opcode, u8 subcode,
0387 u32 irh_ossp, u64 ossp0,
0388 u64 ossp1);
0389
0390 int octeon_send_soft_command(struct octeon_device *oct,
0391 struct octeon_soft_command *sc);
0392
0393 int octeon_setup_iq(struct octeon_device *oct, int ifidx,
0394 int q_index, union oct_txpciq iq_no, u32 num_descs,
0395 void *app_ctx);
0396 int
0397 octeon_flush_iq(struct octeon_device *oct, struct octeon_instr_queue *iq,
0398 u32 napi_budget);
0399 #endif