1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2#ifndef _UAPI_LINUX_NEXTHOP_H 3#define _UAPI_LINUX_NEXTHOP_H 4 5#include <linux/types.h> 6 7struct nhmsg { 8 unsigned char nh_family; 9 unsigned char nh_scope; /* return only */ 10 unsigned char nh_protocol; /* Routing protocol that installed nh */ 11 unsigned char resvd; 12 unsigned int nh_flags; /* RTNH_F flags */ 13}; 14 15/* entry in a nexthop group */ 16struct nexthop_grp { 17 __u32 id; /* nexthop id - must exist */ 18 __u8 weight; /* weight of this nexthop */ 19 __u8 resvd1; 20 __u16 resvd2; 21}; 22 23enum { 24 NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group 25 * default type if not specified 26 */ 27 NEXTHOP_GRP_TYPE_RES, /* resilient nexthop group */ 28 __NEXTHOP_GRP_TYPE_MAX, 29}; 30 31#define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1) 32 33#define NHA_OP_FLAG_DUMP_STATS BIT(0) 34#define NHA_OP_FLAG_DUMP_HW_STATS BIT(1) 35 36enum { 37 NHA_UNSPEC, 38 NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */ 39 40 NHA_GROUP, /* array of nexthop_grp */ 41 NHA_GROUP_TYPE, /* u16 one of NEXTHOP_GRP_TYPE */ 42 /* if NHA_GROUP attribute is added, no other attributes can be set */ 43 44 NHA_BLACKHOLE, /* flag; nexthop used to blackhole packets */ 45 /* if NHA_BLACKHOLE is added, OIF, GATEWAY, ENCAP can not be set */ 46 47 NHA_OIF, /* u32; nexthop device */ 48 NHA_GATEWAY, /* be32 (IPv4) or in6_addr (IPv6) gw address */ 49 NHA_ENCAP_TYPE, /* u16; lwt encap type */ 50 NHA_ENCAP, /* lwt encap data */ 51 52 /* NHA_OIF can be appended to dump request to return only 53 * nexthops using given device 54 */ 55 NHA_GROUPS, /* flag; only return nexthop groups in dump */ 56 NHA_MASTER, /* u32; only return nexthops with given master dev */ 57 58 NHA_FDB, /* flag; nexthop belongs to a bridge fdb */ 59 /* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */ 60 61 /* nested; resilient nexthop group attributes */ 62 NHA_RES_GROUP, 63 /* nested; nexthop bucket attributes */ 64 NHA_RES_BUCKET, 65 66 /* u32; operation-specific flags */ 67 NHA_OP_FLAGS, 68 69 /* nested; nexthop group stats */ 70 NHA_GROUP_STATS, 71 72 /* u32; nexthop hardware stats enable */ 73 NHA_HW_STATS_ENABLE, 74 75 /* u32; read-only; whether any driver collects HW stats */ 76 NHA_HW_STATS_USED, 77 78 __NHA_MAX, 79}; 80 81#define NHA_MAX (__NHA_MAX - 1) 82 83enum { 84 NHA_RES_GROUP_UNSPEC, 85 /* Pad attribute for 64-bit alignment. */ 86 NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC, 87 88 /* u16; number of nexthop buckets in a resilient nexthop group */ 89 NHA_RES_GROUP_BUCKETS, 90 /* clock_t as u32; nexthop bucket idle timer (per-group) */ 91 NHA_RES_GROUP_IDLE_TIMER, 92 /* clock_t as u32; nexthop unbalanced timer */ 93 NHA_RES_GROUP_UNBALANCED_TIMER, 94 /* clock_t as u64; nexthop unbalanced time */ 95 NHA_RES_GROUP_UNBALANCED_TIME, 96 97 __NHA_RES_GROUP_MAX, 98}; 99 100#define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1) 101 102enum { 103 NHA_RES_BUCKET_UNSPEC, 104 /* Pad attribute for 64-bit alignment. */ 105 NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC, 106 107 /* u16; nexthop bucket index */ 108 NHA_RES_BUCKET_INDEX, 109 /* clock_t as u64; nexthop bucket idle time */ 110 NHA_RES_BUCKET_IDLE_TIME, 111 /* u32; nexthop id assigned to the nexthop bucket */ 112 NHA_RES_BUCKET_NH_ID, 113 114 __NHA_RES_BUCKET_MAX, 115}; 116 117#define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1) 118 119enum { 120 NHA_GROUP_STATS_UNSPEC, 121 122 /* nested; nexthop group entry stats */ 123 NHA_GROUP_STATS_ENTRY, 124 125 __NHA_GROUP_STATS_MAX, 126}; 127 128#define NHA_GROUP_STATS_MAX (__NHA_GROUP_STATS_MAX - 1) 129 130enum { 131 NHA_GROUP_STATS_ENTRY_UNSPEC, 132 133 /* u32; nexthop id of the nexthop group entry */ 134 NHA_GROUP_STATS_ENTRY_ID, 135 136 /* uint; number of packets forwarded via the nexthop group entry */ 137 NHA_GROUP_STATS_ENTRY_PACKETS, 138 139 /* uint; number of packets forwarded via the nexthop group entry in 140 * hardware 141 */ 142 NHA_GROUP_STATS_ENTRY_PACKETS_HW, 143 144 __NHA_GROUP_STATS_ENTRY_MAX, 145}; 146 147#define NHA_GROUP_STATS_ENTRY_MAX (__NHA_GROUP_STATS_ENTRY_MAX - 1) 148 149#endif 150