diff --git a/home/nipa/nipa_out/879373/ynl/old-code/netdev-user.c b/home/nipa/nipa_out/879373/ynl/new-code/netdev-user.c index 6b065df00b8e..eb5aa32d0bc6 100644 --- a/home/nipa/nipa_out/879373/ynl/old-code/netdev-user.c +++ b/home/nipa/nipa_out/879373/ynl/new-code/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/home/nipa/nipa_out/879373/ynl/old-code/netdev-user.h b/home/nipa/nipa_out/879373/ynl/new-code/netdev-user.h index 906271a8ba74..a407e22cb7eb 100644 --- a/home/nipa/nipa_out/879373/ynl/old-code/netdev-user.h +++ b/home/nipa/nipa_out/879373/ynl/new-code/netdev-user.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 */