Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2015-2018 Atomic Rules LLC 3 : : */ 4 : : 5 : : #ifndef _ARK_MPU_H_ 6 : : #define _ARK_MPU_H_ 7 : : 8 : : #include <stdint.h> 9 : : 10 : : #include <rte_memory.h> 11 : : 12 : : /* The MPU or Memory Prefetch Unit is an internal Arkville hardware 13 : : * module for moving data between host memory and the hardware FPGA. 14 : : * This module is *not* intended for end-user manipulation, hence 15 : : * there is minimal documentation. 16 : : */ 17 : : 18 : : #define ARK_MPU_MODID 0x2055504d 19 : : #define ARK_MPU_MODVER 0x37313232 20 : : /* 21 : : * MPU hardware structures 22 : : * These are overlay structures to a memory mapped FPGA device. These 23 : : * structs will never be instantiated in ram memory 24 : : */ 25 : : 26 : : #define ARK_MPU_ID 0x00 27 : : struct ark_mpu_id_t { 28 : : union { 29 : : char id[4]; 30 : : uint32_t idnum; 31 : : }; 32 : : union { 33 : : char ver[4]; 34 : : uint32_t vernum; 35 : : }; 36 : : uint32_t phys_id; 37 : : uint32_t mrr_code; 38 : : }; 39 : : 40 : : #define ARK_MPU_HW 0x010 41 : : struct ark_mpu_hw_t { 42 : : uint32_t num_queues; 43 : : uint32_t hw_depth; 44 : : uint32_t obj_size; 45 : : uint32_t obj_per_mrr; 46 : : }; 47 : : 48 : : #define ARK_MPU_CFG 0x040 49 : : struct ark_mpu_cfg_t { 50 : : rte_iova_t ring_base; /* rte_iova_t is a uint64_t */ 51 : : uint32_t ring_size; 52 : : uint32_t ring_mask; 53 : : uint32_t min_host_move; 54 : : uint32_t min_hw_move; 55 : : volatile uint32_t sw_prod_index; 56 : : volatile uint32_t hw_cons_index; 57 : : volatile uint32_t command; 58 : : }; 59 : : enum ARK_MPU_COMMAND { 60 : : MPU_CMD_IDLE = 1, 61 : : MPU_CMD_RUN = 2, 62 : : MPU_CMD_STOP = 4, 63 : : MPU_CMD_RESET = 8, 64 : : MPU_CMD_FORCE_RESET = 16, 65 : : MPU_COMMAND_LIMIT = 0xfFFFFFFF 66 : : }; 67 : : 68 : : /* Consolidated structure */ 69 : : struct ark_mpu_t { 70 : : struct ark_mpu_id_t id; 71 : : uint8_t reserved0[(ARK_MPU_HW - ARK_MPU_ID) 72 : : - sizeof(struct ark_mpu_id_t)]; 73 : : struct ark_mpu_hw_t hw; 74 : : uint8_t reserved1[(ARK_MPU_CFG - ARK_MPU_HW) - 75 : : sizeof(struct ark_mpu_hw_t)]; 76 : : struct ark_mpu_cfg_t cfg; 77 : : }; 78 : : 79 : : uint16_t ark_api_num_queues(struct ark_mpu_t *mpu); 80 : : uint16_t ark_api_num_queues_per_port(struct ark_mpu_t *mpu, 81 : : uint16_t ark_ports); 82 : : int ark_mpu_verify(struct ark_mpu_t *mpu, uint32_t obj_size); 83 : : void ark_mpu_stop(struct ark_mpu_t *mpu); 84 : : void ark_mpu_start(struct ark_mpu_t *mpu); 85 : : int ark_mpu_reset(struct ark_mpu_t *mpu); 86 : : int ark_mpu_configure(struct ark_mpu_t *mpu, rte_iova_t ring, 87 : : uint32_t ring_size, int is_tx); 88 : : 89 : : void ark_mpu_dump(struct ark_mpu_t *mpu, const char *msg, uint16_t idx); 90 : : void ark_mpu_dump_setup(struct ark_mpu_t *mpu, uint16_t qid); 91 : : 92 : : /* this action is in a performance critical path */ 93 : : static inline void 94 : : ark_mpu_set_producer(struct ark_mpu_t *mpu, uint32_t idx) 95 : : { 96 : 0 : mpu->cfg.sw_prod_index = idx; 97 : 0 : } 98 : : 99 : : #endif