]> git.proxmox.com Git - ceph.git/blame - ceph/src/dpdk/drivers/net/thunderx/base/nicvf_plat.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / dpdk / drivers / net / thunderx / base / nicvf_plat.h
CommitLineData
7c673cae
FG
1/*
2 * BSD LICENSE
3 *
4 * Copyright (C) Cavium networks Ltd. 2016.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Cavium networks nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _THUNDERX_NICVF_H
34#define _THUNDERX_NICVF_H
35
36/* Platform/OS/arch specific abstractions */
37
38/* log */
39#include <rte_log.h>
40#include "../nicvf_logs.h"
41
42#define nicvf_log_error(s, ...) PMD_DRV_LOG(ERR, s, ##__VA_ARGS__)
43
44#define nicvf_log_debug(s, ...) PMD_DRV_LOG(DEBUG, s, ##__VA_ARGS__)
45
46#define nicvf_mbox_log(s, ...) PMD_MBOX_LOG(DEBUG, s, ##__VA_ARGS__)
47
48#define nicvf_log(s, ...) fprintf(stderr, s, ##__VA_ARGS__)
49
50/* delay */
51#include <rte_cycles.h>
52#define nicvf_delay_us(x) rte_delay_us(x)
53
54/* barrier */
55#include <rte_atomic.h>
56#define nicvf_smp_wmb() rte_smp_wmb()
57#define nicvf_smp_rmb() rte_smp_rmb()
58
59/* utils */
60#include <rte_common.h>
61#define nicvf_min(x, y) RTE_MIN(x, y)
62
63/* byte order */
64#include <rte_byteorder.h>
65#define nicvf_cpu_to_be_64(x) rte_cpu_to_be_64(x)
66#define nicvf_be_to_cpu_64(x) rte_be_to_cpu_64(x)
67
68/* Constants */
69#include <rte_ether.h>
70#define NICVF_MAC_ADDR_SIZE ETHER_ADDR_LEN
71
72/* ARM64 specific functions */
73#if defined(RTE_ARCH_ARM64)
74#define nicvf_prefetch_store_keep(_ptr) ({\
75 asm volatile("prfm pstl1keep, %a0\n" : : "p" (_ptr)); })
76
77static inline void __attribute__((always_inline))
78nicvf_addr_write(uintptr_t addr, uint64_t val)
79{
80 asm volatile(
81 "str %x[val], [%x[addr]]"
82 :
83 : [val] "r" (val), [addr] "r" (addr));
84}
85
86static inline uint64_t __attribute__((always_inline))
87nicvf_addr_read(uintptr_t addr)
88{
89 uint64_t val;
90
91 asm volatile(
92 "ldr %x[val], [%x[addr]]"
93 : [val] "=r" (val)
94 : [addr] "r" (addr));
95 return val;
96}
97
98#define NICVF_LOAD_PAIR(reg1, reg2, addr) ({ \
99 asm volatile( \
100 "ldp %x[x1], %x[x0], [%x[p1]]" \
101 : [x1]"=r"(reg1), [x0]"=r"(reg2)\
102 : [p1]"r"(addr) \
103 ); })
104
105#else /* non optimized functions for building on non arm64 arch */
106
107#define nicvf_prefetch_store_keep(_ptr) do {} while (0)
108
109static inline void __attribute__((always_inline))
110nicvf_addr_write(uintptr_t addr, uint64_t val)
111{
112 *(volatile uint64_t *)addr = val;
113}
114
115static inline uint64_t __attribute__((always_inline))
116nicvf_addr_read(uintptr_t addr)
117{
118 return *(volatile uint64_t *)addr;
119}
120
121#define NICVF_LOAD_PAIR(reg1, reg2, addr) \
122do { \
123 reg1 = nicvf_addr_read((uintptr_t)addr); \
124 reg2 = nicvf_addr_read((uintptr_t)addr + 8); \
125} while (0)
126
127#endif
128
129#include "nicvf_hw.h"
130#include "nicvf_mbox.h"
131
132#endif /* _THUNDERX_NICVF_H */