*/
#define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
- TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t tx_pkt_nb_segs = 1;
-
int
generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
- struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
- uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+ struct ether_hdr *eth_hdr, uint8_t vlan_enabled,
+ void *ip_hdr, uint8_t ipv4, struct udp_hdr *udp_hdr,
+ int nb_pkt_per_burst, uint8_t pkt_len,
+ uint8_t nb_pkt_segs)
{
int i, nb_pkt = 0;
size_t eth_hdr_size;
break;
}
- pkt->data_len = tx_pkt_seg_lengths[0];
+ pkt->data_len = pkt_len;
pkt_seg = pkt;
- for (i = 1; i < tx_pkt_nb_segs; i++) {
+ for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
if (pkt_seg->next == NULL) {
pkt->nb_segs = i;
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
- pkt_seg->data_len = tx_pkt_seg_lengths[i];
+ pkt_seg->data_len = pkt_len;
}
pkt_seg->next = NULL; /* Last segment of packet. */
* Complete first mbuf of packet and append it to the
* burst of packets to be transmitted.
*/
- pkt->nb_segs = tx_pkt_nb_segs;
- pkt->pkt_len = tx_pkt_length;
+ pkt->nb_segs = nb_pkt_segs;
+ pkt->pkt_len = pkt_len;
pkt->l2_len = eth_hdr_size;
if (ipv4) {
#define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
((c & 0xff) << 8) | (d & 0xff))
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
void
initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
- struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id);
+ struct ether_addr *dst_mac, uint8_t vlan_enabled,
+ uint16_t van_id);
uint16_t
initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,
int
generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
- struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
- uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+ struct ether_hdr *eth_hdr, uint8_t vlan_enabled,
+ void *ip_hdr, uint8_t ipv4, struct udp_hdr *udp_hdr,
+ int nb_pkt_per_burst, uint8_t pkt_len,
+ uint8_t nb_pkt_segs);
#ifdef __cplusplus
}
}
/* Generate burst of packets to transmit */
- generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
- pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
- test_params->pkt_udp_hdr, burst_size);
+ generated_burst_size =
+ generate_packet_burst(test_params->mbuf_pool,
+ pkts_burst, test_params->pkt_eth_hdr,
+ vlan, ip_hdr, ipv4,
+ test_params->pkt_udp_hdr, burst_size,
+ PACKET_BURST_GEN_PKT_LEN_128, 1);
if (generated_burst_size != burst_size) {
printf("Failed to generate packet burst");
return -1;
}
/* Generate a burst of packets to transmit */
- generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
- pkts_burst, test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
- 1, test_params->pkt_udp_hdr, burst_size);
+ generated_burst_size =
+ generate_packet_burst(test_params->mbuf_pool,
+ pkts_burst, test_params->pkt_eth_hdr, 0,
+ test_params->pkt_ipv4_hdr, 1,
+ test_params->pkt_udp_hdr, burst_size,
+ PACKET_BURST_GEN_PKT_LEN, 1);
if (generated_burst_size != burst_size)
return -1;
/* Generate a burst 1 of packets to transmit */
if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
- test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
- test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0])
+ test_params->pkt_eth_hdr, 0,
+ test_params->pkt_ipv4_hdr, 1,
+ test_params->pkt_udp_hdr, burst_size[0],
+ PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
return -1;
initialize_eth_header(test_params->pkt_eth_hdr,
/* Generate a burst 2 of packets to transmit */
if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
- test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
- test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1])
+ test_params->pkt_eth_hdr, 0,
+ test_params->pkt_ipv4_hdr, 1,
+ test_params->pkt_udp_hdr, burst_size[1],
+ PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
return -1;
/* Send burst 1 on bonded port */
}
/* Generate a burst of packets to transmit */
- generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
- pkts_burst, test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
- 1, test_params->pkt_udp_hdr, burst_size);
+ generated_burst_size =
+ generate_packet_burst(test_params->mbuf_pool,
+ pkts_burst, test_params->pkt_eth_hdr, 0,
+ test_params->pkt_ipv4_hdr, 1,
+ test_params->pkt_udp_hdr, burst_size,
+ PACKET_BURST_GEN_PKT_LEN, 1);
if (generated_burst_size != burst_size)
return -1;