diff options
Diffstat (limited to 'common/VIL/l2l3_stack/lib_arp.h')
-rw-r--r-- | common/VIL/l2l3_stack/lib_arp.h | 131 |
1 files changed, 76 insertions, 55 deletions
diff --git a/common/VIL/l2l3_stack/lib_arp.h b/common/VIL/l2l3_stack/lib_arp.h index e2d38419..9cb0205f 100644 --- a/common/VIL/l2l3_stack/lib_arp.h +++ b/common/VIL/l2l3_stack/lib_arp.h @@ -24,11 +24,15 @@ #define ND_IPV6_ADDR_SIZE 16 /**< 16 Byte of IPv6 Address. */ #define ND_IPV6_TIMER_EXPIRY 300 /**< in Seconds, Timer for ND IPv6 Expiry */ -#define ARP_TIMER_EXPIRY 1800 /**< in Seconds, TIMER for ARP Expiry */ +#define ARP_TIMER_EXPIRY 20 /**< in Seconds, TIMER for ARP Expiry */ #define TIMER_MILLISECOND 1 #define RTE_LOGTYPE_LIBARP RTE_LOGTYPE_USER1 #define MAX_ND_RT_ENTRY 32 #define MAX_ARP_RT_ENTRY 32 +#define NUM_DESC (get_arp_buf()) +#define ARP_BUF_DEFAULT 30000 +#define PROBE_TIME 50 +#undef L3_STACK_SUPPORT /** * A structure for Route table entries of IPv4 @@ -39,6 +43,21 @@ struct lib_arp_route_table_entry { uint32_t mask; /**< mask */ uint32_t port; /**< Physical port */ uint32_t nh; /**< next hop */ + uint32_t nh_mask; +}; + +#define MAX_LOCAL_MAC_ADDRESS 32 +#define MAX_PORTS 32 +struct arp_cache { + uint32_t nhip[MAX_LOCAL_MAC_ADDRESS]; + struct ether_addr link_hw_laddr[MAX_LOCAL_MAC_ADDRESS]; + uint32_t num_nhip; +}; + +struct nd_cache { + uint8_t nhip[MAX_LOCAL_MAC_ADDRESS][16]; + struct ether_addr link_hw_laddr[MAX_LOCAL_MAC_ADDRESS]; + uint32_t num_nhip; }; /** @@ -52,8 +71,17 @@ struct lib_nd_route_table_entry { uint8_t nhipv6[16]; /**< next hop Ipv6 */ }; +uint8_t arp_cache_dest_mac_present(uint32_t out_port); +uint8_t nd_cache_dest_mac_present(uint32_t out_port); extern struct lib_nd_route_table_entry lib_nd_route_table[MAX_ND_RT_ENTRY]; extern struct lib_arp_route_table_entry lib_arp_route_table[MAX_ARP_RT_ENTRY]; +extern struct ether_addr *get_local_link_hw_addr(uint8_t out_port, uint32_t nhip); +extern struct ether_addr *get_nd_local_link_hw_addr(uint8_t out_port, uint8_t nhip[]); +extern struct arp_cache arp_local_cache[MAX_PORTS]; +extern void prefetch(void); +extern void update_nhip_access(uint8_t); +uint32_t get_arp_buf(void); +uint32_t get_nd_buf(void); enum { ARP_FOUND, @@ -116,8 +144,13 @@ struct arp_timer_key { extern uint32_t ARPICMP_DEBUG; -#define COMPLETE 1 /**< ARP entry populated and echo reply recieved. */ -#define INCOMPLETE 0 /**< ARP entry populated and either awaiting echo reply or stale entry. */ +enum { + INCOMPLETE, + COMPLETE, + PROBE, + STALE +}; +#define USED_TIME 5 extern uint32_t NDIPV6_DEBUG; /**< ND IPv6 */ @@ -142,6 +175,10 @@ struct arp_entry_data { uint8_t retry_count; /**< retry count for ARP*/ struct rte_timer *timer; /**< Timer Associated with ARP*/ struct arp_timer_key *timer_key; + rte_rwlock_t queue_lock; /** queue lock */ + struct rte_mbuf **buf_pkts; + uint32_t num_pkts; + uint64_t n_confirmed; } __attribute__ ((packed)); /** @@ -167,7 +204,13 @@ struct nd_entry_data { uint8_t status; /**< statusof the entry */ uint8_t mode; /**< Mode */ uint8_t ipv6[ND_IPV6_ADDR_SIZE]; /**< Ipv6 address */ + uint8_t retry_count; /**< retry count for ARP*/ struct rte_timer *timer; /**< Timer */ + struct nd_timer_key *timer_key; + rte_rwlock_t queue_lock; /** queue lock */ + struct rte_mbuf **buf_pkts; + uint32_t num_pkts; + uint64_t n_confirmed; } __attribute__ ((packed)); /** @@ -184,22 +227,22 @@ struct table_nd_entry_data { struct rte_timer *timer; /**< Timer */ } __attribute__ ((packed)); -/** -* To get the destination MAC address andnext hop for the ip address and outgoing port -* @param1 ip addr -* IP address for which MAC address is needed. -* @param2 phy_port -* Physical Port -* @param3 ether_addr -* pointer to the ether_addr, This gets update with valid MAC addresss -* @Param4 next nhip -* Gets the next hop IP by Ip address and physical port -* @return -* 0 if failure, and 1 if success -*/ +struct arp_data { + struct lib_arp_route_table_entry + lib_arp_route_table[MAX_ARP_RT_ENTRY]; + uint8_t lib_arp_route_ent_cnt; + struct lib_nd_route_table_entry + lib_nd_route_table[MAX_ARP_RT_ENTRY]; + uint8_t lib_nd_route_ent_cnt; + struct arp_cache arp_local_cache[MAX_PORTS]; + struct nd_cache nd_local_cache[MAX_PORTS]; + struct ether_addr link_hw_addr[MAX_LOCAL_MAC_ADDRESS]; + uint32_t link_hw_addr_array_idx; + uint8_t arp_cache_hw_laddr_valid[MAX_LOCAL_MAC_ADDRESS]; + uint8_t nd_cache_hw_laddr_valid[MAX_LOCAL_MAC_ADDRESS]; + uint64_t update_tsc[MAX_LOCAL_MAC_ADDRESS]; +} __rte_cache_aligned; -int get_dest_mac_address(const uint32_t ipaddr, uint32_t *phy_port, - struct ether_addr *hw_addr, uint32_t *nhip); /** * To get the destination MAC address andnext hop for the ip address and outgoing port * @param1 ip addr @@ -213,39 +256,10 @@ int get_dest_mac_address(const uint32_t ipaddr, uint32_t *phy_port, * @return * 0 if failure, and 1 if success */ -int get_dest_mac_addr_port(const uint32_t ipaddr, +struct arp_entry_data *get_dest_mac_addr_port(const uint32_t ipaddr, uint32_t *phy_port, struct ether_addr *hw_addr); /** -* To get the destination mac address for IPv4 address -* @param Ipaddr -* IP address which need the destination mac address -* @param Phy_port -* physical port -* @param ether_addr -* pointer to the ether_addr, This gets update with valid mac address -* @return -* 0 if failure, 1 if success -*/ -int get_dest_mac_addr(const uint32_t ipaddr, uint32_t *phy_port, - struct ether_addr *hw_addr); - -/** -* To get the destination mac address for IPV6 address -* @param ipv6addr -* IPv6 address which need the destination mac adress -* @param Phy_Port -* physical prt -* @param ether_addr -* pointer to the ether_address, This gets update with valid mac address -* @param Nhipv6[] -* Gets the next hop ipv6 address by ipv6 address and physical port -* @return -* 0 if failure, 1 ifsuccess -*/ -int get_dest_mac_address_ipv6(uint8_t ipv6addr[], uint32_t *phy_port, - struct ether_addr *hw_addr, uint8_t nhipv6[]); -/** * To get the destination mac address for IPV6 address * @param ipv6addr * IPv6 address which need the destination mac adress @@ -259,9 +273,16 @@ int get_dest_mac_address_ipv6(uint8_t ipv6addr[], uint32_t *phy_port, * 0 if failure, 1 ifsuccess */ -int get_dest_mac_address_ipv6_port(uint8_t ipv6addr[], uint32_t *phy_port, +struct nd_entry_data *get_dest_mac_address_ipv6_port(uint8_t ipv6addr[], uint32_t *phy_port, struct ether_addr *hw_addr, uint8_t nhipv6[]); +int arp_queue_unresolved_packet(struct arp_entry_data * arp_data, + struct rte_mbuf * m); +extern void arp_send_buffered_pkts(struct arp_entry_data *ret_arp_data,struct ether_addr *hw_addr, uint8_t port_id); + +int nd_queue_unresolved_packet(struct nd_entry_data *nd_data, + struct rte_mbuf * m); +extern void nd_send_buffered_pkts(struct nd_entry_data *ret_nd_data,struct ether_addr *hw_addr, uint8_t port_id); /** * To get hardware link address @@ -292,7 +313,7 @@ void print_nd_table(void); * @param portid * Port id */ -void remove_arp_entry(uint32_t ipaddr, uint8_t portid, void *arg); +void remove_arp_entry(struct arp_entry_data *ret_arp_data, void *arg); /** * Removes ND entry from Nd Table @@ -302,7 +323,7 @@ void remove_arp_entry(uint32_t ipaddr, uint8_t portid, void *arg); * Port id */ -void remove_nd_entry_ipv6(uint8_t ipv6addr[], uint8_t portid); +void remove_nd_entry_ipv6(struct nd_entry_data *ret_nd_data, void *arg); /** * Populate arp entry in arp Table @@ -387,7 +408,7 @@ void process_arpicmp_pkt(struct rte_mbuf *pkt, l2_phy_interface_t *port); * @Param arp_key * Arp key to validate entry */ -struct arp_entry_data *retrieve_arp_entry(const struct arp_key_ipv4 arp_key); +struct arp_entry_data *retrieve_arp_entry(const struct arp_key_ipv4 arp_key, uint8_t mode); /** * ND IPv6 @@ -396,7 +417,7 @@ struct arp_entry_data *retrieve_arp_entry(const struct arp_key_ipv4 arp_key); * Nd key to validate Nd entry */ -struct nd_entry_data *retrieve_nd_entry(struct nd_key_ipv6 nd_key); +struct nd_entry_data *retrieve_nd_entry(struct nd_key_ipv6 nd_key, uint8_t mode); /** * Setsup Arp Initilization @@ -492,7 +513,7 @@ void set_arptimeout(uint32_t timeout_val); * @Param * timeout_val to set */ -uint32_t get_nh(uint32_t, uint32_t *); +uint32_t get_nh(uint32_t, uint32_t *, struct ether_addr *addr); /** * To get nexthop for ipv6 * @Param ipv6 @@ -502,5 +523,5 @@ uint32_t get_nh(uint32_t, uint32_t *); * @Param nhipv6 * next hop ipv6 */ -void get_nh_ipv6(uint8_t ipv6[], uint32_t *port, uint8_t nhipv6[]); +void get_nh_ipv6(uint8_t ipv6[], uint32_t *port, uint8_t nhipv6[], struct ether_addr *hw_addr); #endif |