1 // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 2 /* Do not edit directly, auto-generated from: */ 3 /* Documentation/netlink/specs/netdev.yaml */ 4 /* YNL-GEN kernel source */ 5 6 #include <net/netlink.h> 7 #include <net/genetlink.h> 8 9 #include "netdev-genl-gen.h" 10 11 #include <uapi/linux/netdev.h> 12 #include <linux/list.h> 13 14 /* Integer value ranges */ 15 static const struct netlink_range_validation netdev_a_page_pool_id_range = { 16 .min = 1ULL, 17 .max = U32_MAX, 18 }; 19 20 static const struct netlink_range_validation netdev_a_page_pool_ifindex_range = { 21 .min = 1ULL, 22 .max = S32_MAX, 23 }; 24 25 static const struct netlink_range_validation netdev_a_napi_defer_hard_irqs_range = { 26 .max = S32_MAX, 27 }; 28 29 /* Common nested types */ 30 const struct nla_policy netdev_page_pool_info_nl_policy[NETDEV_A_PAGE_POOL_IFINDEX + 1] = { 31 [NETDEV_A_PAGE_POOL_ID] = NLA_POLICY_FULL_RANGE(NLA_UINT, &netdev_a_page_pool_id_range), 32 [NETDEV_A_PAGE_POOL_IFINDEX] = NLA_POLICY_FULL_RANGE(NLA_U32, &netdev_a_page_pool_ifindex_range), 33 }; 34 35 const struct nla_policy netdev_queue_id_nl_policy[NETDEV_A_QUEUE_TYPE + 1] = { 36 [NETDEV_A_QUEUE_ID] = { .type = NLA_U32, }, 37 [NETDEV_A_QUEUE_TYPE] = NLA_POLICY_MAX(NLA_U32, 1), 38 }; 39 40 /* NETDEV_CMD_DEV_GET - do */ 41 static const struct nla_policy netdev_dev_get_nl_policy[NETDEV_A_DEV_IFINDEX + 1] = { 42 [NETDEV_A_DEV_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 43 }; 44 45 /* NETDEV_CMD_PAGE_POOL_GET - do */ 46 #ifdef CONFIG_PAGE_POOL 47 static const struct nla_policy netdev_page_pool_get_nl_policy[NETDEV_A_PAGE_POOL_ID + 1] = { 48 [NETDEV_A_PAGE_POOL_ID] = NLA_POLICY_FULL_RANGE(NLA_UINT, &netdev_a_page_pool_id_range), 49 }; 50 #endif /* CONFIG_PAGE_POOL */ 51 52 /* NETDEV_CMD_PAGE_POOL_STATS_GET - do */ 53 #ifdef CONFIG_PAGE_POOL_STATS 54 static const struct nla_policy netdev_page_pool_stats_get_nl_policy[NETDEV_A_PAGE_POOL_STATS_INFO + 1] = { 55 [NETDEV_A_PAGE_POOL_STATS_INFO] = NLA_POLICY_NESTED(netdev_page_pool_info_nl_policy), 56 }; 57 #endif /* CONFIG_PAGE_POOL_STATS */ 58 59 /* NETDEV_CMD_QUEUE_GET - do */ 60 static const struct nla_policy netdev_queue_get_do_nl_policy[NETDEV_A_QUEUE_TYPE + 1] = { 61 [NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 62 [NETDEV_A_QUEUE_TYPE] = NLA_POLICY_MAX(NLA_U32, 1), 63 [NETDEV_A_QUEUE_ID] = { .type = NLA_U32, }, 64 }; 65 66 /* NETDEV_CMD_QUEUE_GET - dump */ 67 static const struct nla_policy netdev_queue_get_dump_nl_policy[NETDEV_A_QUEUE_IFINDEX + 1] = { 68 [NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 69 }; 70 71 /* NETDEV_CMD_NAPI_GET - do */ 72 static const struct nla_policy netdev_napi_get_do_nl_policy[NETDEV_A_NAPI_ID + 1] = { 73 [NETDEV_A_NAPI_ID] = { .type = NLA_U32, }, 74 }; 75 76 /* NETDEV_CMD_NAPI_GET - dump */ 77 static const struct nla_policy netdev_napi_get_dump_nl_policy[NETDEV_A_NAPI_IFINDEX + 1] = { 78 [NETDEV_A_NAPI_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 79 }; 80 81 /* NETDEV_CMD_QSTATS_GET - dump */ 82 static const struct nla_policy netdev_qstats_get_nl_policy[NETDEV_A_QSTATS_SCOPE + 1] = { 83 [NETDEV_A_QSTATS_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 84 [NETDEV_A_QSTATS_SCOPE] = NLA_POLICY_MASK(NLA_UINT, 0x1), 85 }; 86 87 /* NETDEV_CMD_BIND_RX - do */ 88 static const struct nla_policy netdev_bind_rx_nl_policy[NETDEV_A_DMABUF_FD + 1] = { 89 [NETDEV_A_DMABUF_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1), 90 [NETDEV_A_DMABUF_FD] = { .type = NLA_U32, }, 91 [NETDEV_A_DMABUF_QUEUES] = NLA_POLICY_NESTED(netdev_queue_id_nl_policy), 92 }; 93 94 /* NETDEV_CMD_NAPI_SET - do */ 95 static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT + 1] = { 96 [NETDEV_A_NAPI_ID] = { .type = NLA_U32, }, 97 [NETDEV_A_NAPI_DEFER_HARD_IRQS] = NLA_POLICY_FULL_RANGE(NLA_U32, &netdev_a_napi_defer_hard_irqs_range), 98 [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] = { .type = NLA_UINT, }, 99 }; 100 101 /* Ops table for netdev */ 102 static const struct genl_split_ops netdev_nl_ops[] = { 103 { 104 .cmd = NETDEV_CMD_DEV_GET, 105 .doit = netdev_nl_dev_get_doit, 106 .policy = netdev_dev_get_nl_policy, 107 .maxattr = NETDEV_A_DEV_IFINDEX, 108 .flags = GENL_CMD_CAP_DO, 109 }, 110 { 111 .cmd = NETDEV_CMD_DEV_GET, 112 .dumpit = netdev_nl_dev_get_dumpit, 113 .flags = GENL_CMD_CAP_DUMP, 114 }, 115 #ifdef CONFIG_PAGE_POOL 116 { 117 .cmd = NETDEV_CMD_PAGE_POOL_GET, 118 .doit = netdev_nl_page_pool_get_doit, 119 .policy = netdev_page_pool_get_nl_policy, 120 .maxattr = NETDEV_A_PAGE_POOL_ID, 121 .flags = GENL_CMD_CAP_DO, 122 }, 123 { 124 .cmd = NETDEV_CMD_PAGE_POOL_GET, 125 .dumpit = netdev_nl_page_pool_get_dumpit, 126 .flags = GENL_CMD_CAP_DUMP, 127 }, 128 #endif /* CONFIG_PAGE_POOL */ 129 #ifdef CONFIG_PAGE_POOL_STATS 130 { 131 .cmd = NETDEV_CMD_PAGE_POOL_STATS_GET, 132 .doit = netdev_nl_page_pool_stats_get_doit, 133 .policy = netdev_page_pool_stats_get_nl_policy, 134 .maxattr = NETDEV_A_PAGE_POOL_STATS_INFO, 135 .flags = GENL_CMD_CAP_DO, 136 }, 137 { 138 .cmd = NETDEV_CMD_PAGE_POOL_STATS_GET, 139 .dumpit = netdev_nl_page_pool_stats_get_dumpit, 140 .flags = GENL_CMD_CAP_DUMP, 141 }, 142 #endif /* CONFIG_PAGE_POOL_STATS */ 143 { 144 .cmd = NETDEV_CMD_QUEUE_GET, 145 .doit = netdev_nl_queue_get_doit, 146 .policy = netdev_queue_get_do_nl_policy, 147 .maxattr = NETDEV_A_QUEUE_TYPE, 148 .flags = GENL_CMD_CAP_DO, 149 }, 150 { 151 .cmd = NETDEV_CMD_QUEUE_GET, 152 .dumpit = netdev_nl_queue_get_dumpit, 153 .policy = netdev_queue_get_dump_nl_policy, 154 .maxattr = NETDEV_A_QUEUE_IFINDEX, 155 .flags = GENL_CMD_CAP_DUMP, 156 }, 157 { 158 .cmd = NETDEV_CMD_NAPI_GET, 159 .doit = netdev_nl_napi_get_doit, 160 .policy = netdev_napi_get_do_nl_policy, 161 .maxattr = NETDEV_A_NAPI_ID, 162 .flags = GENL_CMD_CAP_DO, 163 }, 164 { 165 .cmd = NETDEV_CMD_NAPI_GET, 166 .dumpit = netdev_nl_napi_get_dumpit, 167 .policy = netdev_napi_get_dump_nl_policy, 168 .maxattr = NETDEV_A_NAPI_IFINDEX, 169 .flags = GENL_CMD_CAP_DUMP, 170 }, 171 { 172 .cmd = NETDEV_CMD_QSTATS_GET, 173 .dumpit = netdev_nl_qstats_get_dumpit, 174 .policy = netdev_qstats_get_nl_policy, 175 .maxattr = NETDEV_A_QSTATS_SCOPE, 176 .flags = GENL_CMD_CAP_DUMP, 177 }, 178 { 179 .cmd = NETDEV_CMD_BIND_RX, 180 .doit = netdev_nl_bind_rx_doit, 181 .policy = netdev_bind_rx_nl_policy, 182 .maxattr = NETDEV_A_DMABUF_FD, 183 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 184 }, 185 { 186 .cmd = NETDEV_CMD_NAPI_SET, 187 .doit = netdev_nl_napi_set_doit, 188 .policy = netdev_napi_set_nl_policy, 189 .maxattr = NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, 190 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 191 }, 192 }; 193 194 static const struct genl_multicast_group netdev_nl_mcgrps[] = { 195 [NETDEV_NLGRP_MGMT] = { "mgmt", }, 196 [NETDEV_NLGRP_PAGE_POOL] = { "page-pool", }, 197 }; 198 199 struct genl_family netdev_nl_family __ro_after_init = { 200 .name = NETDEV_FAMILY_NAME, 201 .version = NETDEV_FAMILY_VERSION, 202 .netnsok = true, 203 .parallel_ops = true, 204 .module = THIS_MODULE, 205 .split_ops = netdev_nl_ops, 206 .n_split_ops = ARRAY_SIZE(netdev_nl_ops), 207 .mcgrps = netdev_nl_mcgrps, 208 .n_mcgrps = ARRAY_SIZE(netdev_nl_mcgrps), 209 .sock_priv_size = sizeof(struct list_head), 210 .sock_priv_init = (void *)netdev_nl_sock_priv_init, 211 .sock_priv_destroy = (void *)netdev_nl_sock_priv_destroy, 212 }; 213