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_IRQ_SUSPEND_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 [NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT] = { .type = NLA_UINT, }, 100 }; 101 102 /* Ops table for netdev */ 103 static const struct genl_split_ops netdev_nl_ops[] = { 104 { 105 .cmd = NETDEV_CMD_DEV_GET, 106 .doit = netdev_nl_dev_get_doit, 107 .policy = netdev_dev_get_nl_policy, 108 .maxattr = NETDEV_A_DEV_IFINDEX, 109 .flags = GENL_CMD_CAP_DO, 110 }, 111 { 112 .cmd = NETDEV_CMD_DEV_GET, 113 .dumpit = netdev_nl_dev_get_dumpit, 114 .flags = GENL_CMD_CAP_DUMP, 115 }, 116 #ifdef CONFIG_PAGE_POOL 117 { 118 .cmd = NETDEV_CMD_PAGE_POOL_GET, 119 .doit = netdev_nl_page_pool_get_doit, 120 .policy = netdev_page_pool_get_nl_policy, 121 .maxattr = NETDEV_A_PAGE_POOL_ID, 122 .flags = GENL_CMD_CAP_DO, 123 }, 124 { 125 .cmd = NETDEV_CMD_PAGE_POOL_GET, 126 .dumpit = netdev_nl_page_pool_get_dumpit, 127 .flags = GENL_CMD_CAP_DUMP, 128 }, 129 #endif /* CONFIG_PAGE_POOL */ 130 #ifdef CONFIG_PAGE_POOL_STATS 131 { 132 .cmd = NETDEV_CMD_PAGE_POOL_STATS_GET, 133 .doit = netdev_nl_page_pool_stats_get_doit, 134 .policy = netdev_page_pool_stats_get_nl_policy, 135 .maxattr = NETDEV_A_PAGE_POOL_STATS_INFO, 136 .flags = GENL_CMD_CAP_DO, 137 }, 138 { 139 .cmd = NETDEV_CMD_PAGE_POOL_STATS_GET, 140 .dumpit = netdev_nl_page_pool_stats_get_dumpit, 141 .flags = GENL_CMD_CAP_DUMP, 142 }, 143 #endif /* CONFIG_PAGE_POOL_STATS */ 144 { 145 .cmd = NETDEV_CMD_QUEUE_GET, 146 .doit = netdev_nl_queue_get_doit, 147 .policy = netdev_queue_get_do_nl_policy, 148 .maxattr = NETDEV_A_QUEUE_TYPE, 149 .flags = GENL_CMD_CAP_DO, 150 }, 151 { 152 .cmd = NETDEV_CMD_QUEUE_GET, 153 .dumpit = netdev_nl_queue_get_dumpit, 154 .policy = netdev_queue_get_dump_nl_policy, 155 .maxattr = NETDEV_A_QUEUE_IFINDEX, 156 .flags = GENL_CMD_CAP_DUMP, 157 }, 158 { 159 .cmd = NETDEV_CMD_NAPI_GET, 160 .doit = netdev_nl_napi_get_doit, 161 .policy = netdev_napi_get_do_nl_policy, 162 .maxattr = NETDEV_A_NAPI_ID, 163 .flags = GENL_CMD_CAP_DO, 164 }, 165 { 166 .cmd = NETDEV_CMD_NAPI_GET, 167 .dumpit = netdev_nl_napi_get_dumpit, 168 .policy = netdev_napi_get_dump_nl_policy, 169 .maxattr = NETDEV_A_NAPI_IFINDEX, 170 .flags = GENL_CMD_CAP_DUMP, 171 }, 172 { 173 .cmd = NETDEV_CMD_QSTATS_GET, 174 .dumpit = netdev_nl_qstats_get_dumpit, 175 .policy = netdev_qstats_get_nl_policy, 176 .maxattr = NETDEV_A_QSTATS_SCOPE, 177 .flags = GENL_CMD_CAP_DUMP, 178 }, 179 { 180 .cmd = NETDEV_CMD_BIND_RX, 181 .doit = netdev_nl_bind_rx_doit, 182 .policy = netdev_bind_rx_nl_policy, 183 .maxattr = NETDEV_A_DMABUF_FD, 184 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 185 }, 186 { 187 .cmd = NETDEV_CMD_NAPI_SET, 188 .doit = netdev_nl_napi_set_doit, 189 .policy = netdev_napi_set_nl_policy, 190 .maxattr = NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, 191 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 192 }, 193 }; 194 195 static const struct genl_multicast_group netdev_nl_mcgrps[] = { 196 [NETDEV_NLGRP_MGMT] = { "mgmt", }, 197 [NETDEV_NLGRP_PAGE_POOL] = { "page-pool", }, 198 }; 199 200 struct genl_family netdev_nl_family __ro_after_init = { 201 .name = NETDEV_FAMILY_NAME, 202 .version = NETDEV_FAMILY_VERSION, 203 .netnsok = true, 204 .parallel_ops = true, 205 .module = THIS_MODULE, 206 .split_ops = netdev_nl_ops, 207 .n_split_ops = ARRAY_SIZE(netdev_nl_ops), 208 .mcgrps = netdev_nl_mcgrps, 209 .n_mcgrps = ARRAY_SIZE(netdev_nl_mcgrps), 210 .sock_priv_size = sizeof(struct list_head), 211 .sock_priv_init = (void *)netdev_nl_sock_priv_init, 212 .sock_priv_destroy = (void *)netdev_nl_sock_priv_destroy, 213 }; 214