]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ofed/libibverbs/nl1_compat.h
Optionally bind ktls threads to NUMA domains
[FreeBSD/FreeBSD.git] / contrib / ofed / libibverbs / nl1_compat.h
1 /* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
2  */
3
4 #ifndef _NL1_COMPAT_H_
5 #define _NL1_COMPAT_H_
6
7 #include <netlink/route/rtnl.h>
8 #include <netlink/route/link.h>
9 #include <netlink/route/route.h>
10 #include <netlink/route/neighbour.h>
11
12 struct nl_handle;
13
14 /* Workaround - declaration missing */
15 extern int              rtnl_link_vlan_get_id(struct rtnl_link *);
16
17 #define nl_geterror(x) nl_geterror()
18 #define nl_sock nl_handle
19
20 static inline void nl_socket_disable_seq_check(struct nl_sock *sock)
21 {
22         nl_disable_sequence_check(sock);
23 }
24
25 struct rtnl_nexthop {};
26
27 static inline struct rtnl_nexthop *rtnl_route_nexthop_n(
28         struct rtnl_route *r, int n)
29 {
30         return (struct rtnl_nexthop *)r;
31 }
32
33 static inline struct nl_addr *rtnl_route_nh_get_gateway(struct rtnl_nexthop *nh)
34 {
35         return rtnl_route_get_gateway((struct rtnl_route *)nh);
36 }
37
38 static inline int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *nh)
39 {
40         return rtnl_route_get_oif((struct rtnl_route *)nh);
41 }
42
43 #define nl_addr_info(addr, result)      (               \
44         *(result) = nl_addr_info(addr),                 \
45         (*(result) == NULL) ? nl_get_errno() : 0                \
46 )
47
48 static inline void nl_socket_free(struct nl_sock *sock)
49 {
50         nl_close(sock);
51 }
52
53 static inline struct nl_sock *nl_socket_alloc(void)
54 {
55         return nl_handle_alloc();
56 }
57
58 #define rtnl_link_alloc_cache(sock, family, result) (   \
59         *result = rtnl_link_alloc_cache(sock),          \
60         (*result == NULL) ? nl_get_errno() : 0          \
61 )
62
63 #define rtnl_route_alloc_cache(sock, family, flags, result) (   \
64         *result = rtnl_route_alloc_cache(sock),                 \
65         (*result == NULL) ? nl_get_errno() : 0                  \
66 )
67
68 #define rtnl_neigh_alloc_cache(sock, result) (                  \
69         *result = rtnl_neigh_alloc_cache(sock),                 \
70         (*result == NULL) ? nl_get_errno() : 0                  \
71 )
72
73 static inline int rtnl_link_is_vlan(struct rtnl_link *link)
74 {
75         return rtnl_link_vlan_get_id(link) <= 0;
76 }
77
78 #endif