Code Review
/
deb_dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Install arch-specific headers in /usr/include/ARCH
[deb_dpdk.git]
/
examples
/
l2fwd-keepalive
/
main.c
diff --git
a/examples/l2fwd-keepalive/main.c
b/examples/l2fwd-keepalive/main.c
index
8da89aa
..
8b43e63
100644
(file)
--- a/
examples/l2fwd-keepalive/main.c
+++ b/
examples/l2fwd-keepalive/main.c
@@
-66,12
+66,13
@@
#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
-#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_timer.h>
#include <rte_keepalive.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_timer.h>
#include <rte_keepalive.h>
+#include "shm.h"
+
#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
#define NB_MBUF 8192
#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
#define NB_MBUF 8192
@@
-115,7
+116,7
@@
static const struct rte_eth_conf port_conf = {
.hw_ip_checksum = 0, /**< IP checksum offload disabled */
.hw_vlan_filter = 0, /**< VLAN filtering disabled */
.jumbo_frame = 0, /**< Jumbo Frame Support disabled */
.hw_ip_checksum = 0, /**< IP checksum offload disabled */
.hw_vlan_filter = 0, /**< VLAN filtering disabled */
.jumbo_frame = 0, /**< Jumbo Frame Support disabled */
- .hw_strip_crc =
0
, /**< CRC stripped by hardware */
+ .hw_strip_crc =
1
, /**< CRC stripped by hardware */
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
@@
-523,7
+524,7
@@
check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
}
static void
}
static void
-dead_core(__
attribute__((unused))
void *ptr_data, const int id_core)
+dead_core(__
rte_unused
void *ptr_data, const int id_core)
{
printf("Dead core %i - restarting..\n", id_core);
if (rte_eal_get_lcore_state(id_core) == FINISHED) {
{
printf("Dead core %i - restarting..\n", id_core);
if (rte_eal_get_lcore_state(id_core) == FINISHED) {
@@
-534,6
+535,14
@@
dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
}
}
}
}
+static void
+relay_core_state(void *ptr_data, const int id_core,
+ const enum rte_keepalive_state core_state, uint64_t last_alive)
+{
+ rte_keepalive_relayed_state((struct rte_keepalive_shm *)ptr_data,
+ id_core, core_state, last_alive);
+}
+
int
main(int argc, char **argv)
{
int
main(int argc, char **argv)
{
@@
-570,9
+579,6
@@
main(int argc, char **argv)
if (nb_ports == 0)
rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
if (nb_ports == 0)
rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
- if (nb_ports > RTE_MAX_ETHPORTS)
- nb_ports = RTE_MAX_ETHPORTS;
-
/* reset l2fwd_dst_ports */
for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
l2fwd_dst_ports[portid] = 0;
/* reset l2fwd_dst_ports */
for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
l2fwd_dst_ports[portid] = 0;
@@
-725,10
+731,18
@@
main(int argc, char **argv)
rte_timer_init(&stats_timer);
if (check_period > 0) {
rte_timer_init(&stats_timer);
if (check_period > 0) {
+ struct rte_keepalive_shm *ka_shm;
+
+ ka_shm = rte_keepalive_shm_create();
+ if (ka_shm == NULL)
+ rte_exit(EXIT_FAILURE,
+ "rte_keepalive_shm_create() failed");
rte_global_keepalive_info =
rte_global_keepalive_info =
- rte_keepalive_create(&dead_core,
NULL
);
+ rte_keepalive_create(&dead_core,
ka_shm
);
if (rte_global_keepalive_info == NULL)
rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
if (rte_global_keepalive_info == NULL)
rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+ rte_keepalive_register_relay_callback(rte_global_keepalive_info,
+ relay_core_state, ka_shm);
rte_timer_init(&hb_timer);
if (rte_timer_reset(&hb_timer,
(check_period * rte_get_timer_hz()) / 1000,
rte_timer_init(&hb_timer);
if (rte_timer_reset(&hb_timer,
(check_period * rte_get_timer_hz()) / 1000,