15129044dSC.J. Collier/*-
25129044dSC.J. Collier *   BSD LICENSE
35129044dSC.J. Collier *
45129044dSC.J. Collier *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
55129044dSC.J. Collier *   All rights reserved.
65129044dSC.J. Collier *
75129044dSC.J. Collier *   Redistribution and use in source and binary forms, with or without
85129044dSC.J. Collier *   modification, are permitted provided that the following conditions
95129044dSC.J. Collier *   are met:
105129044dSC.J. Collier *
115129044dSC.J. Collier *     * Redistributions of source code must retain the above copyright
125129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer.
135129044dSC.J. Collier *     * Redistributions in binary form must reproduce the above copyright
145129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer in
155129044dSC.J. Collier *       the documentation and/or other materials provided with the
165129044dSC.J. Collier *       distribution.
175129044dSC.J. Collier *     * Neither the name of Intel Corporation nor the names of its
185129044dSC.J. Collier *       contributors may be used to endorse or promote products derived
195129044dSC.J. Collier *       from this software without specific prior written permission.
205129044dSC.J. Collier *
215129044dSC.J. Collier *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
225129044dSC.J. Collier *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
235129044dSC.J. Collier *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
245129044dSC.J. Collier *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
255129044dSC.J. Collier *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
265129044dSC.J. Collier *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
275129044dSC.J. Collier *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
285129044dSC.J. Collier *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
295129044dSC.J. Collier *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
305129044dSC.J. Collier *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
315129044dSC.J. Collier *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325129044dSC.J. Collier */
335129044dSC.J. Collier
345129044dSC.J. Collier#ifndef PACKET_BURST_GENERATOR_H_
355129044dSC.J. Collier#define PACKET_BURST_GENERATOR_H_
365129044dSC.J. Collier
375129044dSC.J. Collier#ifdef __cplusplus
385129044dSC.J. Collierextern "C" {
395129044dSC.J. Collier#endif
405129044dSC.J. Collier
415129044dSC.J. Collier#include <rte_mbuf.h>
425129044dSC.J. Collier#include <rte_ether.h>
435129044dSC.J. Collier#include <rte_arp.h>
445129044dSC.J. Collier#include <rte_ip.h>
455129044dSC.J. Collier#include <rte_udp.h>
465129044dSC.J. Collier
475129044dSC.J. Collier
485129044dSC.J. Collier#define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
495129044dSC.J. Collier		((c & 0xff) << 8) | (d & 0xff))
505129044dSC.J. Collier
515129044dSC.J. Collier#define PACKET_BURST_GEN_PKT_LEN 60
525129044dSC.J. Collier#define PACKET_BURST_GEN_PKT_LEN_128 128
535129044dSC.J. Collier
545129044dSC.J. Colliervoid
555129044dSC.J. Collierinitialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
565129044dSC.J. Collier		struct ether_addr *dst_mac, uint16_t ether_type,
575129044dSC.J. Collier		uint8_t vlan_enabled, uint16_t van_id);
585129044dSC.J. Collier
595129044dSC.J. Colliervoid
605129044dSC.J. Collierinitialize_arp_header(struct arp_hdr *arp_hdr, struct ether_addr *src_mac,
615129044dSC.J. Collier		struct ether_addr *dst_mac, uint32_t src_ip, uint32_t dst_ip,
625129044dSC.J. Collier		uint32_t opcode);
635129044dSC.J. Collier
645129044dSC.J. Collieruint16_t
655129044dSC.J. Collierinitialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,
665129044dSC.J. Collier		uint16_t dst_port, uint16_t pkt_data_len);
675129044dSC.J. Collier
685129044dSC.J. Collier
695129044dSC.J. Collieruint16_t
705129044dSC.J. Collierinitialize_ipv6_header(struct ipv6_hdr *ip_hdr, uint8_t *src_addr,
715129044dSC.J. Collier		uint8_t *dst_addr, uint16_t pkt_data_len);
725129044dSC.J. Collier
735129044dSC.J. Collieruint16_t
745129044dSC.J. Collierinitialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
755129044dSC.J. Collier		uint32_t dst_addr, uint16_t pkt_data_len);
765129044dSC.J. Collier
775129044dSC.J. Collierint
785129044dSC.J. Colliergenerate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
795129044dSC.J. Collier		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
805129044dSC.J. Collier		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
815129044dSC.J. Collier		uint8_t pkt_len, uint8_t nb_pkt_segs);
825129044dSC.J. Collier
835129044dSC.J. Collier#ifdef __cplusplus
845129044dSC.J. Collier}
855129044dSC.J. Collier#endif
865129044dSC.J. Collier
875129044dSC.J. Collier
885129044dSC.J. Collier#endif /* PACKET_BURST_GENERATOR_H_ */
89