2 // Copyright (c) 2010-2020 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include "task_base.h"
19 #include "task_init.h"
23 MAC_INFO_FROM_MASTER_FOR_IPV6,
24 IPV6_INFO_FROM_MASTER,
25 ROUTE_ADD_FROM_MASTER,
26 ROUTE_DEL_FROM_MASTER,
27 SEND_ARP_REQUEST_FROM_MASTER,
28 SEND_ARP_REPLY_FROM_MASTER,
30 SEND_ICMP_FROM_MASTER,
32 ARP_PKT_FROM_NET_TO_MASTER,
33 NDP_PKT_FROM_NET_TO_MASTER,
36 IP4_REQ_MAC_TO_MASTER,
37 IP6_REQ_MAC_TO_MASTER,
42 #define PROX_MAX_ARP_REQUESTS 32 // Maximum number of tasks requesting the same MAC address
44 #define HANDLE_RANDOM_IP_FLAG 1
45 #define HANDLE_RANDOM_LOCAL_IP_FLAG 2
46 #define HANDLE_RANDOM_GLOBAL_IP_FLAG 4
48 #define RANDOM_IP 0xffffffff
50 #define PROX_PSEUDO_PKT_PORT 0xdead
53 prox_rte_ether_addr mac;
54 struct rte_ring *ring;
58 struct ipv6_addr local_ipv6_addr;
59 struct ipv6_addr global_ipv6_addr;
60 struct ipv6_addr router_prefix;
61 uint64_t last_echo_req_rcvd_tsc;
62 uint64_t last_echo_rep_rcvd_tsc;
68 prox_rte_ether_addr mac;
69 struct rte_ring *ring;
72 struct external_ip_table {
73 prox_rte_ether_addr mac;
74 struct rte_ring *rings[PROX_MAX_ARP_REQUESTS];
80 struct rte_ring *ring;
84 struct task_base base;
85 struct rte_ring *ctrl_rx_ring;
86 struct rte_ring **ctrl_tx_rings;
87 struct ip_table *internal_ip_table; // Store mac address from our IP
88 struct external_ip_table *external_ip_table; // Store mac address from external systems
89 struct ip_table *internal_ip6_table; // Store mac address from our IP
90 struct external_ip_table *external_ip6_table; // Store mac address from external systems
91 struct rte_hash *external_ip_hash;
92 struct rte_hash *external_ip6_hash;
93 struct rte_hash *internal_ip_hash;
94 struct rte_hash *internal_ip6_hash;
95 struct port_table internal_port_table[PROX_MAX_PORTS];
96 struct vdev all_vdev[PROX_MAX_PORTS];
98 struct pollfd arp_fds;
99 struct pollfd route_fds;
102 const char *actions_string[MAX_ACTIONS];
104 void init_ctrl_plane(struct task_base *tbase);
106 int (*handle_ctrl_plane)(struct task_base *tbase, struct rte_mbuf **mbuf, uint16_t n_pkts);
108 static inline void tx_drop(struct rte_mbuf *mbuf)
110 rte_pktmbuf_free(mbuf);
113 void register_ip_to_ctrl_plane(struct task_base *task, uint32_t ip, uint8_t port_id, uint8_t core_id, uint8_t task_id);
114 void master_init_vdev(struct task_base *task, uint8_t port_id, uint8_t core_id, uint8_t task_id);
115 void register_router_to_ctrl_plane(struct task_base *tbase, uint8_t port_id, uint8_t core_id, uint8_t task_id, struct ipv6_addr *local_ipv6_addr, struct ipv6_addr *global_ipv6_addr, struct ipv6_addr *router_prefix);
116 void register_node_to_ctrl_plane(struct task_base *tbase, struct ipv6_addr *local_ipv6_addr, struct ipv6_addr *global_ipv6_addr, uint8_t port_id, uint8_t core_id, uint8_t task_id);