1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
11 ark_api_num_queues(struct ark_mpu_t *mpu)
13 return mpu->hw.num_queues;
17 ark_api_num_queues_per_port(struct ark_mpu_t *mpu, uint16_t ark_ports)
19 return mpu->hw.num_queues / ark_ports;
23 ark_mpu_verify(struct ark_mpu_t *mpu, uint32_t obj_size)
27 version = mpu->id.vernum & 0x0000fF00;
28 if ((mpu->id.idnum != 0x2055504d) ||
29 (mpu->hw.obj_size != obj_size) ||
30 (version != 0x00003100)) {
32 " MPU module not found as expected %08x"
33 " \"%c%c%c%c %c%c%c%c\"\n",
35 mpu->id.id[0], mpu->id.id[1],
36 mpu->id.id[2], mpu->id.id[3],
37 mpu->id.ver[0], mpu->id.ver[1],
38 mpu->id.ver[2], mpu->id.ver[3]);
40 " MPU HW num_queues: %u hw_depth %u,"
41 " obj_size: %u, obj_per_mrr: %u"
42 " Expected size %u\n",
54 ark_mpu_stop(struct ark_mpu_t *mpu)
56 mpu->cfg.command = MPU_CMD_STOP;
60 ark_mpu_start(struct ark_mpu_t *mpu)
62 mpu->cfg.command = MPU_CMD_RUN;
66 ark_mpu_reset(struct ark_mpu_t *mpu)
70 mpu->cfg.command = MPU_CMD_RESET;
72 while (mpu->cfg.command != MPU_CMD_IDLE) {
77 if (mpu->cfg.command != MPU_CMD_IDLE) {
78 mpu->cfg.command = MPU_CMD_FORCE_RESET;
81 ark_mpu_reset_stats(mpu);
82 return mpu->cfg.command != MPU_CMD_IDLE;
86 ark_mpu_reset_stats(struct ark_mpu_t *mpu)
88 mpu->stats.pci_request = 1; /* reset stats */
92 ark_mpu_configure(struct ark_mpu_t *mpu, rte_iova_t ring, uint32_t ring_size,
97 if (!rte_is_power_of_2(ring_size)) {
98 PMD_DRV_LOG(ERR, "ARK: Invalid ring size for MPU %d\n",
103 mpu->cfg.ring_base = ring;
104 mpu->cfg.ring_size = ring_size;
105 mpu->cfg.ring_mask = ring_size - 1;
106 mpu->cfg.min_host_move = is_tx ? 1 : mpu->hw.obj_per_mrr;
107 mpu->cfg.min_hw_move = mpu->hw.obj_per_mrr;
108 mpu->cfg.sw_prod_index = 0;
109 mpu->cfg.hw_cons_index = 0;
114 ark_mpu_dump(struct ark_mpu_t *mpu, const char *code, uint16_t qid)
116 /* DUMP to see that we have started */
117 PMD_DEBUG_LOG(DEBUG, "MPU: %s Q: %3u sw_prod %u, hw_cons: %u\n",
119 mpu->cfg.sw_prod_index, mpu->cfg.hw_cons_index);
120 PMD_DEBUG_LOG(DEBUG, "MPU: %s state: %d count %d, reserved %d"
121 " data 0x%08x_%08x 0x%08x_%08x\n",
123 mpu->debug.state, mpu->debug.count,
130 PMD_STATS_LOG(INFO, "MPU: %s Q: %3u"
131 ARK_SU64 ARK_SU64 ARK_SU64 ARK_SU64
132 ARK_SU64 ARK_SU64 ARK_SU64 "\n",
134 "PCI Request:", mpu->stats.pci_request,
135 "Queue_empty", mpu->stats.q_empty,
136 "Queue_q1", mpu->stats.q_q1,
137 "Queue_q2", mpu->stats.q_q2,
138 "Queue_q3", mpu->stats.q_q3,
139 "Queue_q4", mpu->stats.q_q4,
140 "Queue_full", mpu->stats.q_full
145 ark_mpu_dump_setup(struct ark_mpu_t *mpu, uint16_t q_id)
147 PMD_DEBUG_LOG(DEBUG, "MPU Setup Q: %u"
150 "ring_base", mpu->cfg.ring_base