Data Accelerator Offload
Loading...
Searching...
No Matches
dao_net.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Marvell-MIT
2 * Copyright (c) 2023 Marvell.
3 */
4
13#ifndef __DAO_NET_H__
14#define __DAO_NET_H__
15
16#include <rte_ethdev.h>
17
21typedef struct {
22 rte_be16_t hi, lo;
24
25/* union used for byte conversion */
26union dao_16aligned_in6_addr {
27 rte_be16_t be16[8];
28 dao_16aligned_be32 be32[4];
29};
30
31static inline rte_be32_t
32dao_get_16aligned_be32(const dao_16aligned_be32 *x)
33{
34#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
35 return ((rte_be32_t)x->hi << 16) | x->lo;
36#else
37 return ((rte_be32_t)x->lo << 16) | x->hi;
38#endif
39}
40
50static inline struct in6_addr
52{
53 struct in6_addr ip6;
54
55 memset(&ip6, 0, sizeof(ip6));
56 ip6.s6_addr[10] = 0xff;
57 ip6.s6_addr[11] = 0xff;
58 memcpy(&ip6.s6_addr[12], &ip4, 4);
59 return ip6;
60}
61
70static inline void
71dao_in6_addr_set_mapped_ipv4(struct in6_addr *ip6, rte_be32_t ip4)
72{
73 *ip6 = dao_in6_addr_mapped_ipv4(ip4);
74}
75
86static inline rte_be32_t
87dao_in6_addr_get_mapped_ipv4(struct in6_addr *addr)
88{
89 union dao_16aligned_in6_addr *taddr =
90 (union dao_16aligned_in6_addr *)addr;
91
92 if (IN6_IS_ADDR_V4MAPPED(taddr))
93 return dao_get_16aligned_be32(&taddr->be32[3]);
94 else
95 return INADDR_ANY;
96}
97
98#endif /* __DAO_NET_H__ */
static struct in6_addr dao_in6_addr_mapped_ipv4(rte_be32_t ip4)
Definition dao_net.h:51
static void dao_in6_addr_set_mapped_ipv4(struct in6_addr *ip6, rte_be32_t ip4)
Definition dao_net.h:71
static rte_be32_t dao_in6_addr_get_mapped_ipv4(struct in6_addr *addr)
Definition dao_net.h:87