net/hns3: fix return value for unsupported tuple
[dpdk.git] / drivers / net / ark / ark_udm.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2015-2018 Atomic Rules LLC
3  */
4
5 #ifndef _ARK_UDM_H_
6 #define _ARK_UDM_H_
7
8 #include <stdint.h>
9
10 #include <rte_memory.h>
11
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.
16  */
17
18 /* Meta data structure passed from FPGA, must match layout in FPGA
19  * -- 32 bytes
20  */
21 struct ark_rx_meta {
22         uint32_t user_meta[5];  /* user defined based on fpga code */
23         uint8_t  reserved[10];
24         uint16_t pkt_len;
25 } __rte_packed;
26
27 /*
28  * UDM hardware structures
29  * These are overlay structures to a memory mapped FPGA device.  These
30  * structs will never be instantiated in ram memory
31  */
32
33 #define ARK_RX_WRITE_TIME_NS 2500
34 #define ARK_UDM_SETUP 0
35 #define ARK_UDM_MODID 0x4d445500
36 #define ARK_UDM_MODVER 0x37313232
37
38 struct ark_udm_setup_t {
39         union {
40                 char id[4];
41                 uint32_t idnum;
42         };
43         union {
44                 char ver[4];
45                 uint32_t vernum;
46         };
47         uint32_t r0;
48         uint32_t const0;
49 };
50
51 #define ARK_UDM_CFG 0x010
52 struct ark_udm_cfg_t {
53         uint32_t write_interval;        /* 4ns cycles */
54         volatile uint32_t command;
55         uint32_t dataroom;
56         uint32_t headroom;
57 };
58
59 typedef enum {
60         ARK_UDM_START = 0x1,
61         ARK_UDM_STOP = 0x2,
62         ARK_UDM_RESET = 0x3
63 } ark_udm_commands;
64
65 #define ARK_UDM_STATS 0x020
66 struct ark_udm_stats_t {
67         volatile uint64_t rx_byte_count;
68         volatile uint64_t rx_packet_count;
69         volatile uint64_t rx_mbuf_count;
70         volatile uint64_t rx_sent_packets;
71 };
72
73 #define ARK_UDM_PQ 0x040
74 struct ark_udm_queue_stats_t {
75         volatile uint64_t q_byte_count;
76         volatile uint64_t q_packet_count;       /* includes drops */
77         volatile uint64_t q_mbuf_count;
78         volatile uint64_t q_ff_packet_count;
79         volatile uint64_t q_pkt_drop;
80         uint32_t q_enable;
81 };
82
83 #define ARK_UDM_RT_CFG 0x00e0
84 struct ark_udm_rt_cfg_t {
85         rte_iova_t hw_prod_addr;
86         uint32_t reserved;
87         volatile uint32_t prod_idx; /* Updated by HW */
88 };
89
90 /*  Consolidated structure */
91 #define ARK_UDM_EXPECT_SIZE (0x00fc + 4)
92 #define ARK_UDM_QOFFSET ARK_UDM_EXPECT_SIZE
93 struct ark_udm_t {
94         struct ark_udm_setup_t setup;
95         struct ark_udm_cfg_t cfg;
96         struct ark_udm_stats_t stats;
97         struct ark_udm_queue_stats_t qstats;
98         uint8_t reserved1[(ARK_UDM_RT_CFG - ARK_UDM_PQ) -
99                           sizeof(struct ark_udm_queue_stats_t)];
100         struct ark_udm_rt_cfg_t rt_cfg;
101         int8_t reserved3[(ARK_UDM_EXPECT_SIZE - ARK_UDM_RT_CFG) -
102                          sizeof(struct ark_udm_rt_cfg_t)];
103 };
104
105
106 int ark_udm_verify(struct ark_udm_t *udm);
107 void ark_udm_configure(struct ark_udm_t *udm,
108                        uint32_t headroom,
109                        uint32_t dataroom);
110 void ark_udm_write_addr(struct ark_udm_t *udm, rte_iova_t addr);
111 void ark_udm_dump_stats(struct ark_udm_t *udm, const char *msg);
112 void ark_udm_dump_queue_stats(struct ark_udm_t *udm, const char *msg,
113                               uint16_t qid);
114 void ark_udm_dump_setup(struct ark_udm_t *udm, uint16_t q_id);
115
116 /* Per queue data */
117 uint64_t ark_udm_dropped(struct ark_udm_t *udm);
118 uint64_t ark_udm_bytes(struct ark_udm_t *udm);
119 uint64_t ark_udm_packets(struct ark_udm_t *udm);
120
121 void ark_udm_queue_stats_reset(struct ark_udm_t *udm);
122 void ark_udm_queue_enable(struct ark_udm_t *udm, int enable);
123
124 #endif