|
4 | 4 | #ifndef __OTX2_CPTLF_H |
5 | 5 | #define __OTX2_CPTLF_H |
6 | 6 |
|
| 7 | +#include <linux/soc/marvell/octeontx2/asm.h> |
7 | 8 | #include <mbox.h> |
8 | 9 | #include <rvu.h> |
9 | 10 | #include "otx2_cpt_common.h" |
| 11 | +#include "otx2_cpt_reqmgr.h" |
10 | 12 |
|
11 | 13 | /* |
12 | 14 | * CPT instruction and pending queues user requested length in CPT_INST_S msgs |
@@ -272,6 +274,66 @@ static inline void otx2_cptlf_enable_iqueues(struct otx2_cptlfs_info *lfs) |
272 | 274 | } |
273 | 275 | } |
274 | 276 |
|
| 277 | +static inline void otx2_cpt_fill_inst(union otx2_cpt_inst_s *cptinst, |
| 278 | + struct otx2_cpt_iq_command *iq_cmd, |
| 279 | + u64 comp_baddr) |
| 280 | +{ |
| 281 | + cptinst->u[0] = 0x0; |
| 282 | + cptinst->s.doneint = true; |
| 283 | + cptinst->s.res_addr = comp_baddr; |
| 284 | + cptinst->u[2] = 0x0; |
| 285 | + cptinst->u[3] = 0x0; |
| 286 | + cptinst->s.ei0 = iq_cmd->cmd.u; |
| 287 | + cptinst->s.ei1 = iq_cmd->dptr; |
| 288 | + cptinst->s.ei2 = iq_cmd->rptr; |
| 289 | + cptinst->s.ei3 = iq_cmd->cptr.u; |
| 290 | +} |
| 291 | + |
| 292 | +/* |
| 293 | + * On OcteonTX2 platform the parameter insts_num is used as a count of |
| 294 | + * instructions to be enqueued. The valid values for insts_num are: |
| 295 | + * 1 - 1 CPT instruction will be enqueued during LMTST operation |
| 296 | + * 2 - 2 CPT instructions will be enqueued during LMTST operation |
| 297 | + */ |
| 298 | +static inline void otx2_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, |
| 299 | + u32 insts_num, struct otx2_cptlf_info *lf) |
| 300 | +{ |
| 301 | + void __iomem *lmtline = lf->lmtline; |
| 302 | + long ret; |
| 303 | + |
| 304 | + /* |
| 305 | + * Make sure memory areas pointed in CPT_INST_S |
| 306 | + * are flushed before the instruction is sent to CPT |
| 307 | + */ |
| 308 | + dma_wmb(); |
| 309 | + |
| 310 | + do { |
| 311 | + /* Copy CPT command to LMTLINE */ |
| 312 | + memcpy_toio(lmtline, cptinst, insts_num * OTX2_CPT_INST_SIZE); |
| 313 | + |
| 314 | + /* |
| 315 | + * LDEOR initiates atomic transfer to I/O device |
| 316 | + * The following will cause the LMTST to fail (the LDEOR |
| 317 | + * returns zero): |
| 318 | + * - No stores have been performed to the LMTLINE since it was |
| 319 | + * last invalidated. |
| 320 | + * - The bytes which have been stored to LMTLINE since it was |
| 321 | + * last invalidated form a pattern that is non-contiguous, does |
| 322 | + * not start at byte 0, or does not end on a 8-byte boundary. |
| 323 | + * (i.e.comprises a formation of other than 1–16 8-byte |
| 324 | + * words.) |
| 325 | + * |
| 326 | + * These rules are designed such that an operating system |
| 327 | + * context switch or hypervisor guest switch need have no |
| 328 | + * knowledge of the LMTST operations; the switch code does not |
| 329 | + * need to store to LMTCANCEL. Also note as LMTLINE data cannot |
| 330 | + * be read, there is no information leakage between processes. |
| 331 | + */ |
| 332 | + ret = otx2_lmt_flush(lf->ioreg); |
| 333 | + |
| 334 | + } while (!ret); |
| 335 | +} |
| 336 | + |
275 | 337 | int otx2_cptlf_init(struct otx2_cptlfs_info *lfs, u8 eng_grp_msk, int pri, |
276 | 338 | int lfs_num); |
277 | 339 | void otx2_cptlf_shutdown(struct otx2_cptlfs_info *lfs); |
|
0 commit comments