4 * Copyright (c) 2015-2017 Atomic Rules LLC
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef _ARK_PKTCHKR_H_
35 #define _ARK_PKTCHKR_H_
40 #define ARK_PKTCHKR_BASE_ADR 0x90000
42 typedef void *ark_pkt_chkr_t;
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.
52 * This are overlay structures to a memory mapped FPGA device. These
53 * structs will never be instantiated in ram memory
55 struct ark_pkt_chkr_stat_regs {
57 uint32_t pkt_start_stop;
62 uint32_t pkts_mismatch;
64 uint32_t first_mismatch;
65 uint32_t resync_events;
66 uint32_t pkts_missing;
69 } __attribute__ ((packed));
71 struct ark_pkt_chkr_ctl_regs {
74 uint32_t pkt_size_min;
75 uint32_t pkt_size_max;
76 uint32_t pkt_size_incr;
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;
85 } __attribute__ ((packed));
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;
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);