From 034218aa647cf1a8ca6134da36753df7d6631d09 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Mon, 14 Oct 2024 15:20:32 -0700 Subject: [PATCH] sync to upstream 01b6b9315f15 ("Merge branch net-ti-ethernet-warnings") Signed-off-by: Jakub Kicinski --- generated/netdev-user.c | 128 +++++++++++++++++++++++++++++++++++++++ include/linux/netdev.h | 13 ++++ include/ynl-c/mptcp_pm.h | 24 ++++---- include/ynl-c/netdev.h | 72 ++++++++++++++++++++++ 4 files changed, 225 insertions(+), 12 deletions(-) diff --git a/generated/netdev-user.c b/generated/netdev-user.c index 6b065df..eb5aa32 100644 --- a/generated/netdev-user.c +++ b/generated/netdev-user.c @@ -25,6 +25,7 @@ static const char * const netdev_op_strmap[] = { [NETDEV_CMD_QUEUE_GET] = "queue-get", [NETDEV_CMD_NAPI_GET] = "napi-get", [NETDEV_CMD_QSTATS_GET] = "qstats-get", + [NETDEV_CMD_BIND_RX] = "bind-rx", }; const char *netdev_op_str(int op) @@ -114,6 +115,16 @@ const struct ynl_policy_nest netdev_page_pool_info_nest = { .table = netdev_page_pool_info_policy, }; +const struct ynl_policy_attr netdev_queue_id_policy[NETDEV_A_QUEUE_MAX + 1] = { + [NETDEV_A_QUEUE_ID] = { .name = "id", .type = YNL_PT_U32, }, + [NETDEV_A_QUEUE_TYPE] = { .name = "type", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest netdev_queue_id_nest = { + .max_attr = NETDEV_A_QUEUE_MAX, + .table = netdev_queue_id_policy, +}; + const struct ynl_policy_attr netdev_dev_policy[NETDEV_A_DEV_MAX + 1] = { [NETDEV_A_DEV_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, [NETDEV_A_DEV_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, @@ -135,6 +146,7 @@ const struct ynl_policy_attr netdev_page_pool_policy[NETDEV_A_PAGE_POOL_MAX + 1] [NETDEV_A_PAGE_POOL_INFLIGHT] = { .name = "inflight", .type = YNL_PT_UINT, }, [NETDEV_A_PAGE_POOL_INFLIGHT_MEM] = { .name = "inflight-mem", .type = YNL_PT_UINT, }, [NETDEV_A_PAGE_POOL_DETACH_TIME] = { .name = "detach-time", .type = YNL_PT_UINT, }, + [NETDEV_A_PAGE_POOL_DMABUF] = { .name = "dmabuf", .type = YNL_PT_U32, }, }; const struct ynl_policy_nest netdev_page_pool_nest = { @@ -167,6 +179,7 @@ const struct ynl_policy_attr netdev_queue_policy[NETDEV_A_QUEUE_MAX + 1] = { [NETDEV_A_QUEUE_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, [NETDEV_A_QUEUE_TYPE] = { .name = "type", .type = YNL_PT_U32, }, [NETDEV_A_QUEUE_NAPI_ID] = { .name = "napi-id", .type = YNL_PT_U32, }, + [NETDEV_A_QUEUE_DMABUF] = { .name = "dmabuf", .type = YNL_PT_U32, }, }; const struct ynl_policy_nest netdev_queue_nest = { @@ -225,6 +238,18 @@ const struct ynl_policy_nest netdev_qstats_nest = { .table = netdev_qstats_policy, }; +const struct ynl_policy_attr netdev_dmabuf_policy[NETDEV_A_DMABUF_MAX + 1] = { + [NETDEV_A_DMABUF_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, + [NETDEV_A_DMABUF_QUEUES] = { .name = "queues", .type = YNL_PT_NEST, .nest = &netdev_queue_id_nest, }, + [NETDEV_A_DMABUF_FD] = { .name = "fd", .type = YNL_PT_U32, }, + [NETDEV_A_DMABUF_ID] = { .name = "id", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest netdev_dmabuf_nest = { + .max_attr = NETDEV_A_DMABUF_MAX, + .table = netdev_dmabuf_policy, +}; + /* Common nested types */ void netdev_page_pool_info_free(struct netdev_page_pool_info *obj) { @@ -270,6 +295,25 @@ int netdev_page_pool_info_parse(struct ynl_parse_arg *yarg, return 0; } +void netdev_queue_id_free(struct netdev_queue_id *obj) +{ +} + +int netdev_queue_id_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct netdev_queue_id *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.id) + ynl_attr_put_u32(nlh, NETDEV_A_QUEUE_ID, obj->id); + if (obj->_present.type) + ynl_attr_put_u32(nlh, NETDEV_A_QUEUE_TYPE, obj->type); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + /* ============== NETDEV_CMD_DEV_GET ============== */ /* NETDEV_CMD_DEV_GET - do */ void netdev_dev_get_req_free(struct netdev_dev_get_req *req) @@ -453,6 +497,11 @@ int netdev_page_pool_get_rsp_parse(const struct nlmsghdr *nlh, return YNL_PARSE_CB_ERROR; dst->_present.detach_time = 1; dst->detach_time = ynl_attr_get_uint(attr); + } else if (type == NETDEV_A_PAGE_POOL_DMABUF) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dmabuf = 1; + dst->dmabuf = ynl_attr_get_u32(attr); } } @@ -752,6 +801,11 @@ int netdev_queue_get_rsp_parse(const struct nlmsghdr *nlh, return YNL_PARSE_CB_ERROR; dst->_present.ifindex = 1; dst->ifindex = ynl_attr_get_u32(attr); + } else if (type == NETDEV_A_QUEUE_DMABUF) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dmabuf = 1; + dst->dmabuf = ynl_attr_get_u32(attr); } } @@ -1077,6 +1131,80 @@ netdev_qstats_get_dump(struct ynl_sock *ys, return NULL; } +/* ============== NETDEV_CMD_BIND_RX ============== */ +/* NETDEV_CMD_BIND_RX - do */ +void netdev_bind_rx_req_free(struct netdev_bind_rx_req *req) +{ + unsigned int i; + + for (i = 0; i < req->n_queues; i++) + netdev_queue_id_free(&req->queues[i]); + free(req->queues); + free(req); +} + +void netdev_bind_rx_rsp_free(struct netdev_bind_rx_rsp *rsp) +{ + free(rsp); +} + +int netdev_bind_rx_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct netdev_bind_rx_rsp *dst; + const struct nlattr *attr; + + dst = yarg->data; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == NETDEV_A_DMABUF_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.id = 1; + dst->id = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct netdev_bind_rx_rsp * +netdev_bind_rx(struct ynl_sock *ys, struct netdev_bind_rx_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct netdev_bind_rx_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_BIND_RX, 1); + ys->req_policy = &netdev_dmabuf_nest; + yrs.yarg.rsp_policy = &netdev_dmabuf_nest; + + if (req->_present.ifindex) + ynl_attr_put_u32(nlh, NETDEV_A_DMABUF_IFINDEX, req->ifindex); + if (req->_present.fd) + ynl_attr_put_u32(nlh, NETDEV_A_DMABUF_FD, req->fd); + for (unsigned int i = 0; i < req->n_queues; i++) + netdev_queue_id_put(nlh, NETDEV_A_DMABUF_QUEUES, &req->queues[i]); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = netdev_bind_rx_rsp_parse; + yrs.rsp_cmd = NETDEV_CMD_BIND_RX; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + netdev_bind_rx_rsp_free(rsp); + return NULL; +} + static const struct ynl_ntf_info netdev_ntf_info[] = { [NETDEV_CMD_DEV_ADD_NTF] = { .alloc_sz = sizeof(struct netdev_dev_get_ntf), diff --git a/include/linux/netdev.h b/include/linux/netdev.h index 43742ac..7c308f0 100644 --- a/include/linux/netdev.h +++ b/include/linux/netdev.h @@ -93,6 +93,7 @@ enum { NETDEV_A_PAGE_POOL_INFLIGHT, NETDEV_A_PAGE_POOL_INFLIGHT_MEM, NETDEV_A_PAGE_POOL_DETACH_TIME, + NETDEV_A_PAGE_POOL_DMABUF, __NETDEV_A_PAGE_POOL_MAX, NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1) @@ -131,6 +132,7 @@ enum { NETDEV_A_QUEUE_IFINDEX, NETDEV_A_QUEUE_TYPE, NETDEV_A_QUEUE_NAPI_ID, + NETDEV_A_QUEUE_DMABUF, __NETDEV_A_QUEUE_MAX, NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1) @@ -173,6 +175,16 @@ enum { NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1) }; +enum { + NETDEV_A_DMABUF_IFINDEX = 1, + NETDEV_A_DMABUF_QUEUES, + NETDEV_A_DMABUF_FD, + NETDEV_A_DMABUF_ID, + + __NETDEV_A_DMABUF_MAX, + NETDEV_A_DMABUF_MAX = (__NETDEV_A_DMABUF_MAX - 1) +}; + enum { NETDEV_CMD_DEV_GET = 1, NETDEV_CMD_DEV_ADD_NTF, @@ -186,6 +198,7 @@ enum { NETDEV_CMD_QUEUE_GET, NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, + NETDEV_CMD_BIND_RX, __NETDEV_CMD_MAX, NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1) diff --git a/include/ynl-c/mptcp_pm.h b/include/ynl-c/mptcp_pm.h index 1d3632b..221c97c 100644 --- a/include/ynl-c/mptcp_pm.h +++ b/include/ynl-c/mptcp_pm.h @@ -35,7 +35,7 @@ struct mptcp_pm_address { __u8 id; __u32 addr4 /* big-endian */; void *addr6; - __u16 port /* big-endian */; + __u16 port; __u32 flags; __s32 if_idx; }; @@ -91,7 +91,7 @@ mptcp_pm_add_addr_req_set_addr_addr6(struct mptcp_pm_add_addr_req *req, } static inline void mptcp_pm_add_addr_req_set_addr_port(struct mptcp_pm_add_addr_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -170,7 +170,7 @@ mptcp_pm_del_addr_req_set_addr_addr6(struct mptcp_pm_del_addr_req *req, } static inline void mptcp_pm_del_addr_req_set_addr_port(struct mptcp_pm_del_addr_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -251,7 +251,7 @@ mptcp_pm_get_addr_req_set_addr_addr6(struct mptcp_pm_get_addr_req *req, } static inline void mptcp_pm_get_addr_req_set_addr_port(struct mptcp_pm_get_addr_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -359,7 +359,7 @@ mptcp_pm_flush_addrs_req_set_addr_addr6(struct mptcp_pm_flush_addrs_req *req, } static inline void mptcp_pm_flush_addrs_req_set_addr_port(struct mptcp_pm_flush_addrs_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -535,7 +535,7 @@ mptcp_pm_set_flags_req_set_addr_addr6(struct mptcp_pm_set_flags_req *req, } static inline void mptcp_pm_set_flags_req_set_addr_port(struct mptcp_pm_set_flags_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -600,7 +600,7 @@ mptcp_pm_set_flags_req_set_addr_remote_addr6(struct mptcp_pm_set_flags_req *req, } static inline void mptcp_pm_set_flags_req_set_addr_remote_port(struct mptcp_pm_set_flags_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr_remote = 1; req->addr_remote._present.port = 1; @@ -681,7 +681,7 @@ mptcp_pm_announce_req_set_addr_addr6(struct mptcp_pm_announce_req *req, } static inline void mptcp_pm_announce_req_set_addr_port(struct mptcp_pm_announce_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -808,7 +808,7 @@ mptcp_pm_subflow_create_req_set_addr_addr6(struct mptcp_pm_subflow_create_req *r } static inline void mptcp_pm_subflow_create_req_set_addr_port(struct mptcp_pm_subflow_create_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -874,7 +874,7 @@ mptcp_pm_subflow_create_req_set_addr_remote_addr6(struct mptcp_pm_subflow_create } static inline void mptcp_pm_subflow_create_req_set_addr_remote_port(struct mptcp_pm_subflow_create_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr_remote = 1; req->addr_remote._present.port = 1; @@ -961,7 +961,7 @@ mptcp_pm_subflow_destroy_req_set_addr_addr6(struct mptcp_pm_subflow_destroy_req } static inline void mptcp_pm_subflow_destroy_req_set_addr_port(struct mptcp_pm_subflow_destroy_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr = 1; req->addr._present.port = 1; @@ -1027,7 +1027,7 @@ mptcp_pm_subflow_destroy_req_set_addr_remote_addr6(struct mptcp_pm_subflow_destr } static inline void mptcp_pm_subflow_destroy_req_set_addr_remote_port(struct mptcp_pm_subflow_destroy_req *req, - __u16 port /* big-endian */) + __u16 port) { req->_present.addr_remote = 1; req->addr_remote._present.port = 1; diff --git a/include/ynl-c/netdev.h b/include/ynl-c/netdev.h index 906271a..a407e22 100644 --- a/include/ynl-c/netdev.h +++ b/include/ynl-c/netdev.h @@ -34,6 +34,16 @@ struct netdev_page_pool_info { __u32 ifindex; }; +struct netdev_queue_id { + struct { + __u32 id:1; + __u32 type:1; + } _present; + + __u32 id; + enum netdev_queue_type type; +}; + /* ============== NETDEV_CMD_DEV_GET ============== */ /* NETDEV_CMD_DEV_GET - do */ struct netdev_dev_get_req { @@ -134,6 +144,7 @@ struct netdev_page_pool_get_rsp { __u32 inflight:1; __u32 inflight_mem:1; __u32 detach_time:1; + __u32 dmabuf:1; } _present; __u64 id; @@ -142,6 +153,7 @@ struct netdev_page_pool_get_rsp { __u64 inflight; __u64 inflight_mem; __u64 detach_time; + __u32 dmabuf; }; void netdev_page_pool_get_rsp_free(struct netdev_page_pool_get_rsp *rsp); @@ -310,12 +322,14 @@ struct netdev_queue_get_rsp { __u32 type:1; __u32 napi_id:1; __u32 ifindex:1; + __u32 dmabuf:1; } _present; __u32 id; enum netdev_queue_type type; __u32 napi_id; __u32 ifindex; + __u32 dmabuf; }; void netdev_queue_get_rsp_free(struct netdev_queue_get_rsp *rsp); @@ -505,4 +519,62 @@ struct netdev_qstats_get_rsp_list * netdev_qstats_get_dump(struct ynl_sock *ys, struct netdev_qstats_get_req_dump *req); +/* ============== NETDEV_CMD_BIND_RX ============== */ +/* NETDEV_CMD_BIND_RX - do */ +struct netdev_bind_rx_req { + struct { + __u32 ifindex:1; + __u32 fd:1; + } _present; + + __u32 ifindex; + __u32 fd; + unsigned int n_queues; + struct netdev_queue_id *queues; +}; + +static inline struct netdev_bind_rx_req *netdev_bind_rx_req_alloc(void) +{ + return calloc(1, sizeof(struct netdev_bind_rx_req)); +} +void netdev_bind_rx_req_free(struct netdev_bind_rx_req *req); + +static inline void +netdev_bind_rx_req_set_ifindex(struct netdev_bind_rx_req *req, __u32 ifindex) +{ + req->_present.ifindex = 1; + req->ifindex = ifindex; +} +static inline void +netdev_bind_rx_req_set_fd(struct netdev_bind_rx_req *req, __u32 fd) +{ + req->_present.fd = 1; + req->fd = fd; +} +static inline void +__netdev_bind_rx_req_set_queues(struct netdev_bind_rx_req *req, + struct netdev_queue_id *queues, + unsigned int n_queues) +{ + free(req->queues); + req->queues = queues; + req->n_queues = n_queues; +} + +struct netdev_bind_rx_rsp { + struct { + __u32 id:1; + } _present; + + __u32 id; +}; + +void netdev_bind_rx_rsp_free(struct netdev_bind_rx_rsp *rsp); + +/* + * Bind dmabuf to netdev + */ +struct netdev_bind_rx_rsp * +netdev_bind_rx(struct ynl_sock *ys, struct netdev_bind_rx_req *req); + #endif /* _LINUX_NETDEV_GEN_H */