New upstream version 18.08
[deb_dpdk.git] / drivers / net / ark / ark_pktgen.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2015-2018 Atomic Rules LLC
3  */
4
5 #ifndef _ARK_PKTGEN_H_
6 #define _ARK_PKTGEN_H_
7
8 #include <stdint.h>
9 #include <inttypes.h>
10
11 #define ARK_PKTGEN_BASE_ADR  0x10000
12
13 typedef void *ark_pkt_gen_t;
14
15 /* The packet generator is an internal Arkville hardware module, which
16  * generates known packets for use in integrity and line-rate testing.
17  * This module is *not* intended for end-user manipulation, hence
18  * there is minimal documentation.
19  */
20
21 /*
22  * This is an overlay structure to a memory mapped FPGA device.  These
23  * structs will never be instantiated in ram memory
24  */
25 struct ark_pkt_gen_regs {
26         uint32_t r0;
27         volatile uint32_t pkt_start_stop;
28         volatile uint32_t pkt_ctrl;
29         uint32_t pkt_payload;
30         uint32_t pkt_spacing;
31         uint32_t pkt_size_min;
32         uint32_t pkt_size_max;
33         uint32_t pkt_size_incr;
34         volatile uint32_t num_pkts;
35         volatile uint32_t pkts_sent;
36         uint32_t src_mac_addr_l;
37         uint32_t src_mac_addr_h;
38         uint32_t dst_mac_addr_l;
39         uint32_t dst_mac_addr_h;
40         uint32_t eth_type;
41         uint32_t hdr_dw[7];
42         uint32_t start_offset;
43         uint32_t bytes_per_cycle;
44 } __attribute__ ((packed));
45
46 struct ark_pkt_gen_inst {
47         struct rte_eth_dev_info *dev_info;
48         struct ark_pkt_gen_regs *regs;
49         int l2_mode;
50         int ordinal;
51 };
52
53 /*  packet generator functions */
54 ark_pkt_gen_t ark_pktgen_init(void *arg, int ord, int l2_mode);
55 void ark_pktgen_uninit(ark_pkt_gen_t handle);
56 void ark_pktgen_run(ark_pkt_gen_t handle);
57 void ark_pktgen_pause(ark_pkt_gen_t handle);
58 uint32_t ark_pktgen_paused(ark_pkt_gen_t handle);
59 uint32_t ark_pktgen_is_gen_forever(ark_pkt_gen_t handle);
60 uint32_t ark_pktgen_is_running(ark_pkt_gen_t handle);
61 uint32_t ark_pktgen_tx_done(ark_pkt_gen_t handle);
62 void ark_pktgen_reset(ark_pkt_gen_t handle);
63 void ark_pktgen_wait_done(ark_pkt_gen_t handle);
64 uint32_t ark_pktgen_get_pkts_sent(ark_pkt_gen_t handle);
65 void ark_pktgen_set_payload_byte(ark_pkt_gen_t handle, uint32_t b);
66 void ark_pktgen_set_pkt_spacing(ark_pkt_gen_t handle, uint32_t x);
67 void ark_pktgen_set_pkt_size_min(ark_pkt_gen_t handle, uint32_t x);
68 void ark_pktgen_set_pkt_size_max(ark_pkt_gen_t handle, uint32_t x);
69 void ark_pktgen_set_pkt_size_incr(ark_pkt_gen_t handle, uint32_t x);
70 void ark_pktgen_set_num_pkts(ark_pkt_gen_t handle, uint32_t x);
71 void ark_pktgen_set_src_mac_addr(ark_pkt_gen_t handle, uint64_t mac_addr);
72 void ark_pktgen_set_dst_mac_addr(ark_pkt_gen_t handle, uint64_t mac_addr);
73 void ark_pktgen_set_eth_type(ark_pkt_gen_t handle, uint32_t x);
74 void ark_pktgen_set_hdr_dW(ark_pkt_gen_t handle, uint32_t *hdr);
75 void ark_pktgen_set_start_offset(ark_pkt_gen_t handle, uint32_t x);
76 void ark_pktgen_parse(char *argv);
77 void ark_pktgen_setup(ark_pkt_gen_t handle);
78
79 #endif