New upstream version 18.02
[deb_dpdk.git] / drivers / net / ark / ark_pktchkr.h
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright (c) 2015-2017 Atomic Rules LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _ARK_PKTCHKR_H_
35 #define _ARK_PKTCHKR_H_
36
37 #include <stdint.h>
38 #include <inttypes.h>
39
40 #define ARK_PKTCHKR_BASE_ADR  0x90000
41
42 typedef void *ark_pkt_chkr_t;
43
44 /* The packet checker is an internal Arkville hardware module, which
45  * verifies packet streams generated from the corresponding packet
46  * generator.  This module is used for Arkville testing.
47  * This module is *not* intended for end-user manipulation, hence
48  * there is minimal documentation.
49  */
50
51 /*
52  * This are overlay structures to a memory mapped FPGA device.  These
53  * structs will never be instantiated in ram memory
54  */
55 struct ark_pkt_chkr_stat_regs {
56         uint32_t r0;
57         uint32_t pkt_start_stop;
58         uint32_t pkt_ctrl;
59         uint32_t pkts_rcvd;
60         uint64_t bytes_rcvd;
61         uint32_t pkts_ok;
62         uint32_t pkts_mismatch;
63         uint32_t pkts_err;
64         uint32_t first_mismatch;
65         uint32_t resync_events;
66         uint32_t pkts_missing;
67         uint32_t min_latency;
68         uint32_t max_latency;
69 } __attribute__ ((packed));
70
71 struct ark_pkt_chkr_ctl_regs {
72         uint32_t pkt_ctrl;
73         uint32_t pkt_payload;
74         uint32_t pkt_size_min;
75         uint32_t pkt_size_max;
76         uint32_t pkt_size_incr;
77         uint32_t num_pkts;
78         uint32_t pkts_sent;
79         uint32_t src_mac_addr_l;
80         uint32_t src_mac_addr_h;
81         uint32_t dst_mac_addr_l;
82         uint32_t dst_mac_addr_h;
83         uint32_t eth_type;
84         uint32_t hdr_dw[7];
85 } __attribute__ ((packed));
86
87 struct ark_pkt_chkr_inst {
88         struct rte_eth_dev_info *dev_info;
89         volatile struct ark_pkt_chkr_stat_regs *sregs;
90         volatile struct ark_pkt_chkr_ctl_regs *cregs;
91         int l2_mode;
92         int ordinal;
93 };
94
95 /*  packet checker functions */
96 ark_pkt_chkr_t ark_pktchkr_init(void *addr, int ord, int l2_mode);
97 void ark_pktchkr_uninit(ark_pkt_chkr_t handle);
98 void ark_pktchkr_run(ark_pkt_chkr_t handle);
99 int ark_pktchkr_stopped(ark_pkt_chkr_t handle);
100 void ark_pktchkr_stop(ark_pkt_chkr_t handle);
101 int ark_pktchkr_is_running(ark_pkt_chkr_t handle);
102 int ark_pktchkr_get_pkts_sent(ark_pkt_chkr_t handle);
103 void ark_pktchkr_set_payload_byte(ark_pkt_chkr_t handle, uint32_t b);
104 void ark_pktchkr_set_pkt_size_min(ark_pkt_chkr_t handle, uint32_t x);
105 void ark_pktchkr_set_pkt_size_max(ark_pkt_chkr_t handle, uint32_t x);
106 void ark_pktchkr_set_pkt_size_incr(ark_pkt_chkr_t handle, uint32_t x);
107 void ark_pktchkr_set_num_pkts(ark_pkt_chkr_t handle, uint32_t x);
108 void ark_pktchkr_set_src_mac_addr(ark_pkt_chkr_t handle, uint64_t mac_addr);
109 void ark_pktchkr_set_dst_mac_addr(ark_pkt_chkr_t handle, uint64_t mac_addr);
110 void ark_pktchkr_set_eth_type(ark_pkt_chkr_t handle, uint32_t x);
111 void ark_pktchkr_set_hdr_dW(ark_pkt_chkr_t handle, uint32_t *hdr);
112 void ark_pktchkr_parse(char *args);
113 void ark_pktchkr_setup(ark_pkt_chkr_t handle);
114 void ark_pktchkr_dump_stats(ark_pkt_chkr_t handle);
115 int ark_pktchkr_wait_done(ark_pkt_chkr_t handle);
116
117 #endif