git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test: add devargs test cases
[dpdk.git]
/
examples
/
bond
/
main.c
diff --git
a/examples/bond/main.c
b/examples/bond/main.c
index
8608285
..
fd8fd76
100644
(file)
--- a/
examples/bond/main.c
+++ b/
examples/bond/main.c
@@
-24,7
+24,6
@@
#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
-#include <rte_atomic.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
@@
-41,6
+40,10
@@
#include <rte_tcp.h>
#include <rte_arp.h>
#include <rte_spinlock.h>
#include <rte_tcp.h>
#include <rte_arp.h>
#include <rte_spinlock.h>
+#include <rte_devargs.h>
+#include <rte_byteorder.h>
+#include <rte_cpuflags.h>
+#include <rte_eth_bond.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
@@
-53,13
+56,6
@@
#include "main.h"
#include "main.h"
-#include <rte_devargs.h>
-
-
-#include "rte_byteorder.h"
-#include "rte_cpuflags.h"
-#include "rte_eth_bond.h"
-
#define RTE_LOGTYPE_DCB RTE_LOGTYPE_USER1
#define NB_MBUF (1024*8)
#define RTE_LOGTYPE_DCB RTE_LOGTYPE_USER1
#define NB_MBUF (1024*8)
@@
-107,8
+103,7
@@
#define MAX_PORTS 4
#define PRINT_MAC(addr) printf("%02"PRIx8":%02"PRIx8":%02"PRIx8 \
":%02"PRIx8":%02"PRIx8":%02"PRIx8, \
#define MAX_PORTS 4
#define PRINT_MAC(addr) printf("%02"PRIx8":%02"PRIx8":%02"PRIx8 \
":%02"PRIx8":%02"PRIx8":%02"PRIx8, \
- addr.addr_bytes[0], addr.addr_bytes[1], addr.addr_bytes[2], \
- addr.addr_bytes[3], addr.addr_bytes[4], addr.addr_bytes[5])
+ RTE_ETHER_ADDR_BYTES(&addr))
uint16_t slaves[RTE_MAX_ETHPORTS];
uint16_t slaves_count;
uint16_t slaves[RTE_MAX_ETHPORTS];
uint16_t slaves_count;
@@
-120,7
+115,6
@@
static struct rte_mempool *mbuf_pool;
static struct rte_eth_conf port_conf = {
.rxmode = {
.mq_mode = ETH_MQ_RX_NONE,
static struct rte_eth_conf port_conf = {
.rxmode = {
.mq_mode = ETH_MQ_RX_NONE,
- .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
.split_hdr_size = 0,
},
.rx_adv_conf = {
.split_hdr_size = 0,
},
.rx_adv_conf = {
@@
-362,7
+356,7
@@
struct global_flag_stru_t *global_flag_stru_p = &global_flag_stru;
static int lcore_main(__rte_unused void *arg1)
{
struct rte_mbuf *pkts[MAX_PKT_BURST] __rte_cache_aligned;
static int lcore_main(__rte_unused void *arg1)
{
struct rte_mbuf *pkts[MAX_PKT_BURST] __rte_cache_aligned;
- struct rte_ether_addr d_addr;
+ struct rte_ether_addr d
st
_addr;
struct rte_ether_addr bond_mac_addr;
struct rte_ether_hdr *eth_hdr;
struct rte_ether_addr bond_mac_addr;
struct rte_ether_hdr *eth_hdr;
@@
-426,13
+420,13
@@
static int lcore_main(__rte_unused void *arg1)
if (arp_hdr->arp_opcode == rte_cpu_to_be_16(RTE_ARP_OP_REQUEST)) {
arp_hdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY);
/* Switch src and dst data and set bonding MAC */
if (arp_hdr->arp_opcode == rte_cpu_to_be_16(RTE_ARP_OP_REQUEST)) {
arp_hdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY);
/* Switch src and dst data and set bonding MAC */
- rte_ether_addr_copy(ð_hdr->s
_addr, ð_hdr->d
_addr);
- rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s_addr);
+ rte_ether_addr_copy(ð_hdr->s
rc_addr, ð_hdr->dst
_addr);
+ rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s
rc
_addr);
rte_ether_addr_copy(&arp_hdr->arp_data.arp_sha,
&arp_hdr->arp_data.arp_tha);
arp_hdr->arp_data.arp_tip = arp_hdr->arp_data.arp_sip;
rte_ether_addr_copy(&arp_hdr->arp_data.arp_sha,
&arp_hdr->arp_data.arp_tha);
arp_hdr->arp_data.arp_tip = arp_hdr->arp_data.arp_sip;
- rte_ether_addr_copy(&bond_mac_addr, &d_addr);
- rte_ether_addr_copy(&d_addr, &arp_hdr->arp_data.arp_sha);
+ rte_ether_addr_copy(&bond_mac_addr, &d
st
_addr);
+ rte_ether_addr_copy(&d
st
_addr, &arp_hdr->arp_data.arp_sha);
arp_hdr->arp_data.arp_sip = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
is_free = 1;
arp_hdr->arp_data.arp_sip = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
is_free = 1;
@@
-447,8
+441,10
@@
static int lcore_main(__rte_unused void *arg1)
}
ipv4_hdr = (struct rte_ipv4_hdr *)((char *)(eth_hdr + 1) + offset);
if (ipv4_hdr->dst_addr == bond_ip) {
}
ipv4_hdr = (struct rte_ipv4_hdr *)((char *)(eth_hdr + 1) + offset);
if (ipv4_hdr->dst_addr == bond_ip) {
- rte_ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr);
- rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s_addr);
+ rte_ether_addr_copy(ð_hdr->src_addr,
+ ð_hdr->dst_addr);
+ rte_ether_addr_copy(&bond_mac_addr,
+ ð_hdr->src_addr);
ipv4_hdr->dst_addr = ipv4_hdr->src_addr;
ipv4_hdr->src_addr = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
ipv4_hdr->dst_addr = ipv4_hdr->src_addr;
ipv4_hdr->src_addr = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
@@
-523,8
+519,8
@@
static void cmd_obj_send_parsed(void *parsed_result,
created_pkt->pkt_len = pkt_size;
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
created_pkt->pkt_len = pkt_size;
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
- rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s_addr);
- memset(ð_hdr->d_addr, 0xFF, RTE_ETHER_ADDR_LEN);
+ rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s
rc
_addr);
+ memset(ð_hdr->d
st
_addr, 0xFF, RTE_ETHER_ADDR_LEN);
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
arp_hdr = (struct rte_arp_hdr *)(
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
arp_hdr = (struct rte_arp_hdr *)(
@@
-573,7
+569,7
@@
static void cmd_start_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
struct cmdline *cl,
__rte_unused void *data)
{
- int
slave
_core_id = rte_lcore_id();
+ int
worker
_core_id = rte_lcore_id();
rte_spinlock_trylock(&global_flag_stru_p->lock);
if (global_flag_stru_p->LcoreMainIsRunning == 0) {
rte_spinlock_trylock(&global_flag_stru_p->lock);
if (global_flag_stru_p->LcoreMainIsRunning == 0) {
@@
-590,9
+586,9
@@
static void cmd_start_parsed(__rte_unused void *parsed_result,
return;
}
return;
}
- /* start lcore main on core != ma
ster
_core - ARP response thread */
-
slave
_core_id = rte_get_next_lcore(rte_lcore_id(), 1, 0);
- if ((
slave_core_id >= RTE_MAX_LCORE) || (slave
_core_id == 0))
+ /* start lcore main on core != ma
in
_core - ARP response thread */
+
worker
_core_id = rte_get_next_lcore(rte_lcore_id(), 1, 0);
+ if ((
worker_core_id >= RTE_MAX_LCORE) || (worker
_core_id == 0))
return;
rte_spinlock_trylock(&global_flag_stru_p->lock);
return;
rte_spinlock_trylock(&global_flag_stru_p->lock);
@@
-601,8
+597,8
@@
static void cmd_start_parsed(__rte_unused void *parsed_result,
cmdline_printf(cl,
"Starting lcore_main on core %d:%d "
"Our IP:%d.%d.%d.%d\n",
cmdline_printf(cl,
"Starting lcore_main on core %d:%d "
"Our IP:%d.%d.%d.%d\n",
-
slave
_core_id,
- rte_eal_remote_launch(lcore_main, NULL,
slave
_core_id),
+
worker
_core_id,
+ rte_eal_remote_launch(lcore_main, NULL,
worker
_core_id),
BOND_IP_1,
BOND_IP_2,
BOND_IP_3,
BOND_IP_1,
BOND_IP_2,
BOND_IP_3,
@@
-802,7
+798,7
@@
cmdline_parse_ctx_t main_ctx[] = {
NULL,
};
NULL,
};
-/* prompt function, called from main on MA
STER
lcore */
+/* prompt function, called from main on MA
IN
lcore */
static void prompt(__rte_unused void *arg1)
{
struct cmdline *cl;
static void prompt(__rte_unused void *arg1)
{
struct cmdline *cl;
@@
-818,7
+814,7
@@
static void prompt(__rte_unused void *arg1)
int
main(int argc, char *argv[])
{
int
main(int argc, char *argv[])
{
- int ret,
slave
_core_id;
+ int ret,
worker
_core_id;
uint16_t nb_ports, i;
/* init EAL */
uint16_t nb_ports, i;
/* init EAL */
@@
-852,23
+848,23
@@
main(int argc, char *argv[])
rte_spinlock_init(&global_flag_stru_p->lock);
/* check state of lcores */
rte_spinlock_init(&global_flag_stru_p->lock);
/* check state of lcores */
- RTE_LCORE_FOREACH_
SLAVE(slave
_core_id) {
- if (rte_eal_get_lcore_state(
slave
_core_id) != WAIT)
+ RTE_LCORE_FOREACH_
WORKER(worker
_core_id) {
+ if (rte_eal_get_lcore_state(
worker
_core_id) != WAIT)
return -EBUSY;
}
return -EBUSY;
}
- /* start lcore main on core != ma
ster
_core - ARP response thread */
-
slave
_core_id = rte_get_next_lcore(rte_lcore_id(), 1, 0);
- if ((
slave_core_id >= RTE_MAX_LCORE) || (slave
_core_id == 0))
+ /* start lcore main on core != ma
in
_core - ARP response thread */
+
worker
_core_id = rte_get_next_lcore(rte_lcore_id(), 1, 0);
+ if ((
worker_core_id >= RTE_MAX_LCORE) || (worker
_core_id == 0))
return -EPERM;
global_flag_stru_p->LcoreMainIsRunning = 1;
return -EPERM;
global_flag_stru_p->LcoreMainIsRunning = 1;
- global_flag_stru_p->LcoreMainCore =
slave
_core_id;
+ global_flag_stru_p->LcoreMainCore =
worker
_core_id;
printf("Starting lcore_main on core %d:%d Our IP:%d.%d.%d.%d\n",
printf("Starting lcore_main on core %d:%d Our IP:%d.%d.%d.%d\n",
-
slave
_core_id,
+
worker
_core_id,
rte_eal_remote_launch((lcore_function_t *)lcore_main,
NULL,
rte_eal_remote_launch((lcore_function_t *)lcore_main,
NULL,
-
slave
_core_id),
+
worker
_core_id),
BOND_IP_1,
BOND_IP_2,
BOND_IP_3,
BOND_IP_1,
BOND_IP_2,
BOND_IP_3,
@@
-879,5
+875,9
@@
main(int argc, char *argv[])
prompt(NULL);
rte_delay_ms(100);
prompt(NULL);
rte_delay_ms(100);
+
+ /* clean up the EAL */
+ rte_eal_cleanup();
+
return 0;
}
return 0;
}