DPDK 25.03.0-rc0
rte_io.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Cavium, Inc
3 */
4
5#ifndef _RTE_IO_H_
6#define _RTE_IO_H_
7
15#include <stdint.h>
16#include <rte_common.h>
17#include <rte_compat.h>
18#include <rte_atomic.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#ifdef __DOXYGEN__
25
38static inline uint8_t
39rte_read8_relaxed(const volatile void *addr);
40
53static inline uint16_t
54rte_read16_relaxed(const volatile void *addr);
55
68static inline uint32_t
69rte_read32_relaxed(const volatile void *addr);
70
83static inline uint64_t
84rte_read64_relaxed(const volatile void *addr);
85
99static inline void
100rte_write8_relaxed(uint8_t value, volatile void *addr);
101
114static inline void
115rte_write16_relaxed(uint16_t value, volatile void *addr);
116
129static inline void
130rte_write32_relaxed(uint32_t value, volatile void *addr);
131
144static inline void
145rte_write64_relaxed(uint64_t value, volatile void *addr);
146
155static inline uint8_t
156rte_read8(const volatile void *addr);
157
167static inline uint16_t
168rte_read16(const volatile void *addr);
169
178static inline uint32_t
179rte_read32(const volatile void *addr);
180
189static inline uint64_t
190rte_read64(const volatile void *addr);
191
201static inline void
202rte_write8(uint8_t value, volatile void *addr);
203
212static inline void
213rte_write16(uint16_t value, volatile void *addr);
214
223static inline void
224rte_write32(uint32_t value, volatile void *addr);
225
234static inline void
235rte_write64(uint64_t value, volatile void *addr);
236
248__rte_experimental
249static inline void
250rte_write32_wc(uint32_t value, volatile void *addr);
251
267__rte_experimental
268static inline void
269rte_write32_wc_relaxed(uint32_t value, volatile void *addr);
270
271#endif /* __DOXYGEN__ */
272
273#ifndef RTE_OVERRIDE_IO_H
274
275static __rte_always_inline uint8_t
276rte_read8_relaxed(const volatile void *addr)
277{
278 return *(const volatile uint8_t *)addr;
279}
280
281static __rte_always_inline uint16_t
282rte_read16_relaxed(const volatile void *addr)
283{
284 return *(const volatile uint16_t *)addr;
285}
286
287static __rte_always_inline uint32_t
288rte_read32_relaxed(const volatile void *addr)
289{
290 return *(const volatile uint32_t *)addr;
291}
292
293static __rte_always_inline uint64_t
294rte_read64_relaxed(const volatile void *addr)
295{
296 return *(const volatile uint64_t *)addr;
297}
298
299static __rte_always_inline void
300rte_write8_relaxed(uint8_t value, volatile void *addr)
301{
302 *(volatile uint8_t *)addr = value;
303}
304
305static __rte_always_inline void
306rte_write16_relaxed(uint16_t value, volatile void *addr)
307{
308 *(volatile uint16_t *)addr = value;
309}
310
311static __rte_always_inline void
312rte_write32_relaxed(uint32_t value, volatile void *addr)
313{
314 *(volatile uint32_t *)addr = value;
315}
316
317static __rte_always_inline void
318rte_write64_relaxed(uint64_t value, volatile void *addr)
319{
320 *(volatile uint64_t *)addr = value;
321}
322
323static __rte_always_inline uint8_t
324rte_read8(const volatile void *addr)
325{
326 uint8_t val;
327 val = rte_read8_relaxed(addr);
328 rte_io_rmb();
329 return val;
330}
331
332static __rte_always_inline uint16_t
333rte_read16(const volatile void *addr)
334{
335 uint16_t val;
336 val = rte_read16_relaxed(addr);
337 rte_io_rmb();
338 return val;
339}
340
341static __rte_always_inline uint32_t
342rte_read32(const volatile void *addr)
343{
344 uint32_t val;
345 val = rte_read32_relaxed(addr);
346 rte_io_rmb();
347 return val;
348}
349
350static __rte_always_inline uint64_t
351rte_read64(const volatile void *addr)
352{
353 uint64_t val;
354 val = rte_read64_relaxed(addr);
355 rte_io_rmb();
356 return val;
357}
358
359static __rte_always_inline void
360rte_write8(uint8_t value, volatile void *addr)
361{
362 rte_io_wmb();
363 rte_write8_relaxed(value, addr);
364}
365
366static __rte_always_inline void
367rte_write16(uint16_t value, volatile void *addr)
368{
369 rte_io_wmb();
370 rte_write16_relaxed(value, addr);
371}
372
373static __rte_always_inline void
374rte_write32(uint32_t value, volatile void *addr)
375{
376 rte_io_wmb();
377 rte_write32_relaxed(value, addr);
378}
379
380static __rte_always_inline void
381rte_write64(uint64_t value, volatile void *addr)
382{
383 rte_io_wmb();
384 rte_write64_relaxed(value, addr);
385}
386
387#ifndef RTE_NATIVE_WRITE32_WC
388static __rte_always_inline void
389rte_write32_wc(uint32_t value, volatile void *addr)
390{
391 rte_write32(value, addr);
392}
393
394static __rte_always_inline void
395rte_write32_wc_relaxed(uint32_t value, volatile void *addr)
396{
397 rte_write32_relaxed(value, addr);
398}
399#endif /* RTE_NATIVE_WRITE32_WC */
400
401#endif /* RTE_OVERRIDE_IO_H */
402
403#ifdef __cplusplus
404}
405#endif
406
407#endif /* _RTE_IO_H_ */
static void rte_io_rmb(void)
static void rte_io_wmb(void)
#define __rte_always_inline
Definition: rte_common.h:413
static void rte_write8(uint8_t value, volatile void *addr)
Definition: rte_io.h:360
static void rte_write16_relaxed(uint16_t value, volatile void *addr)
Definition: rte_io.h:306
static void rte_write64(uint64_t value, volatile void *addr)
Definition: rte_io.h:381
static uint8_t rte_read8(const volatile void *addr)
Definition: rte_io.h:324
static uint8_t rte_read8_relaxed(const volatile void *addr)
Definition: rte_io.h:276
static uint64_t rte_read64(const volatile void *addr)
Definition: rte_io.h:351
static uint16_t rte_read16(const volatile void *addr)
Definition: rte_io.h:333
static uint32_t rte_read32_relaxed(const volatile void *addr)
Definition: rte_io.h:288
static void rte_write64_relaxed(uint64_t value, volatile void *addr)
Definition: rte_io.h:318
static uint64_t rte_read64_relaxed(const volatile void *addr)
Definition: rte_io.h:294
static void rte_write32(uint32_t value, volatile void *addr)
Definition: rte_io.h:374
static __rte_experimental void rte_write32_wc_relaxed(uint32_t value, volatile void *addr)
Definition: rte_io.h:395
static uint16_t rte_read16_relaxed(const volatile void *addr)
Definition: rte_io.h:282
static void rte_write32_relaxed(uint32_t value, volatile void *addr)
Definition: rte_io.h:312
static void rte_write8_relaxed(uint8_t value, volatile void *addr)
Definition: rte_io.h:300
static __rte_experimental void rte_write32_wc(uint32_t value, volatile void *addr)
Definition: rte_io.h:389
static uint32_t rte_read32(const volatile void *addr)
Definition: rte_io.h:342
static void rte_write16(uint16_t value, volatile void *addr)
Definition: rte_io.h:367