1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
10 #include <rte_memory.h>
12 /* The UDM or Upstream Data Mover is an internal Arkville hardware
13 * module for moving packet from the RX packet streams to host memory.
14 * This module is *not* intended for end-user manipulation, hence
15 * there is minimal documentation.
18 /* Meta data structure passed from FPGA, must match layout in FPGA
29 * UDM hardware structures
30 * These are overlay structures to a memory mapped FPGA device. These
31 * structs will never be instantiated in ram memory
34 #define ARK_RX_WRITE_TIME_NS 2500
35 #define ARK_UDM_SETUP 0
36 #define ARK_UDM_CONST2 0xbACECACE
37 #define ARK_UDM_CONST3 0x334d4455
38 #define ARK_UDM_CONST ARK_UDM_CONST3
39 struct ark_udm_setup_t {
42 volatile uint32_t cycle_count;
46 #define ARK_UDM_CFG 0x010
47 struct ark_udm_cfg_t {
48 volatile uint32_t stop_flushed; /* RO */
49 volatile uint32_t command;
60 #define ARK_UDM_STATS 0x020
61 struct ark_udm_stats_t {
62 volatile uint64_t rx_byte_count;
63 volatile uint64_t rx_packet_count;
64 volatile uint64_t rx_mbuf_count;
65 volatile uint64_t rx_sent_packets;
68 #define ARK_UDM_PQ 0x040
69 struct ark_udm_queue_stats_t {
70 volatile uint64_t q_byte_count;
71 volatile uint64_t q_packet_count; /* includes drops */
72 volatile uint64_t q_mbuf_count;
73 volatile uint64_t q_ff_packet_count;
74 volatile uint64_t q_pkt_drop;
78 #define ARK_UDM_TLP 0x0070
79 struct ark_udm_tlp_t {
80 volatile uint64_t pkt_drop; /* global */
81 volatile uint32_t tlp_q1;
82 volatile uint32_t tlp_q2;
83 volatile uint32_t tlp_q3;
84 volatile uint32_t tlp_q4;
85 volatile uint32_t tlp_full;
88 #define ARK_UDM_PCIBP 0x00a0
89 struct ark_udm_pcibp_t {
90 volatile uint32_t pci_clear;
91 volatile uint32_t pci_empty;
92 volatile uint32_t pci_q1;
93 volatile uint32_t pci_q2;
94 volatile uint32_t pci_q3;
95 volatile uint32_t pci_q4;
96 volatile uint32_t pci_full;
99 #define ARK_UDM_TLP_PS 0x00bc
100 struct ark_udm_tlp_ps_t {
101 volatile uint32_t tlp_clear;
102 volatile uint32_t tlp_ps_min;
103 volatile uint32_t tlp_ps_max;
104 volatile uint32_t tlp_full_ps_min;
105 volatile uint32_t tlp_full_ps_max;
106 volatile uint32_t tlp_dw_ps_min;
107 volatile uint32_t tlp_dw_ps_max;
108 volatile uint32_t tlp_pldw_ps_min;
109 volatile uint32_t tlp_pldw_ps_max;
112 #define ARK_UDM_RT_CFG 0x00e0
113 struct ark_udm_rt_cfg_t {
114 rte_iova_t hw_prod_addr;
115 uint32_t write_interval; /* 4ns cycles */
116 volatile uint32_t prod_idx; /* RO */
119 /* Consolidated structure */
120 #define ARK_UDM_EXPECT_SIZE (0x00fc + 4)
121 #define ARK_UDM_QOFFSET ARK_UDM_EXPECT_SIZE
123 struct ark_udm_setup_t setup;
124 struct ark_udm_cfg_t cfg;
125 struct ark_udm_stats_t stats;
126 struct ark_udm_queue_stats_t qstats;
127 uint8_t reserved1[(ARK_UDM_TLP - ARK_UDM_PQ) -
128 sizeof(struct ark_udm_queue_stats_t)];
129 struct ark_udm_tlp_t tlp;
130 uint8_t reserved2[(ARK_UDM_PCIBP - ARK_UDM_TLP) -
131 sizeof(struct ark_udm_tlp_t)];
132 struct ark_udm_pcibp_t pcibp;
133 struct ark_udm_tlp_ps_t tlp_ps;
134 struct ark_udm_rt_cfg_t rt_cfg;
135 int8_t reserved3[(ARK_UDM_EXPECT_SIZE - ARK_UDM_RT_CFG) -
136 sizeof(struct ark_udm_rt_cfg_t)];
140 int ark_udm_verify(struct ark_udm_t *udm);
141 int ark_udm_stop(struct ark_udm_t *udm, int wait);
142 void ark_udm_start(struct ark_udm_t *udm);
143 int ark_udm_reset(struct ark_udm_t *udm);
144 void ark_udm_configure(struct ark_udm_t *udm,
147 uint32_t write_interval_ns);
148 void ark_udm_write_addr(struct ark_udm_t *udm, rte_iova_t addr);
149 void ark_udm_stats_reset(struct ark_udm_t *udm);
150 void ark_udm_dump_stats(struct ark_udm_t *udm, const char *msg);
151 void ark_udm_dump_queue_stats(struct ark_udm_t *udm, const char *msg,
153 void ark_udm_dump(struct ark_udm_t *udm, const char *msg);
154 void ark_udm_dump_perf(struct ark_udm_t *udm, const char *msg);
155 void ark_udm_dump_setup(struct ark_udm_t *udm, uint16_t q_id);
156 int ark_udm_is_flushed(struct ark_udm_t *udm);
159 uint64_t ark_udm_dropped(struct ark_udm_t *udm);
160 uint64_t ark_udm_bytes(struct ark_udm_t *udm);
161 uint64_t ark_udm_packets(struct ark_udm_t *udm);
163 void ark_udm_queue_stats_reset(struct ark_udm_t *udm);
164 void ark_udm_queue_enable(struct ark_udm_t *udm, int enable);