diff --git a/home/nipa/nipa_out/857457/ynl/old-code/netdev-user.c b/home/nipa/nipa_out/857457/ynl/new-code/netdev-user.c index 782863334893..e48a792d9e3b 100644 --- a/home/nipa/nipa_out/857457/ynl/old-code/netdev-user.c +++ b/home/nipa/nipa_out/857457/ynl/new-code/netdev-user.c @@ -23,6 +23,7 @@ static const char * const netdev_op_strmap[] = { [NETDEV_CMD_PAGE_POOL_CHANGE_NTF] = "page-pool-change-ntf", [NETDEV_CMD_PAGE_POOL_STATS_GET] = "page-pool-stats-get", [NETDEV_CMD_QUEUE_GET] = "queue-get", + [NETDEV_CMD_BIND_RX] = "bind-rx", [NETDEV_CMD_NAPI_GET] = "napi-get", [NETDEV_CMD_QSTATS_GET] = "qstats-get", }; @@ -114,6 +115,16 @@ struct ynl_policy_nest netdev_page_pool_info_nest = { .table = netdev_page_pool_info_policy, }; +struct ynl_policy_attr netdev_queue_dmabuf_policy[NETDEV_A_QUEUE_DMABUF_MAX + 1] = { + [NETDEV_A_QUEUE_DMABUF_TYPE] = { .name = "type", .type = YNL_PT_U8, }, + [NETDEV_A_QUEUE_DMABUF_IDX] = { .name = "idx", .type = YNL_PT_U32, }, +}; + +struct ynl_policy_nest netdev_queue_dmabuf_nest = { + .max_attr = NETDEV_A_QUEUE_DMABUF_MAX, + .table = netdev_queue_dmabuf_policy, +}; + 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, }, @@ -174,6 +185,18 @@ struct ynl_policy_nest netdev_queue_nest = { .table = netdev_queue_policy, }; +struct ynl_policy_attr netdev_bind_dmabuf_policy[NETDEV_A_BIND_DMABUF_MAX + 1] = { + [NETDEV_A_BIND_DMABUF_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, + [NETDEV_A_BIND_DMABUF_QUEUES] = { .name = "queues", .type = YNL_PT_NEST, .nest = &netdev_queue_dmabuf_nest, }, + [NETDEV_A_BIND_DMABUF_DMABUF_FD] = { .name = "dmabuf-fd", .type = YNL_PT_U32, }, + [NETDEV_A_BIND_DMABUF_DMABUF_ID] = { .name = "dmabuf-id", .type = YNL_PT_U32, }, +}; + +struct ynl_policy_nest netdev_bind_dmabuf_nest = { + .max_attr = NETDEV_A_BIND_DMABUF_MAX, + .table = netdev_bind_dmabuf_policy, +}; + struct ynl_policy_attr netdev_napi_policy[NETDEV_A_NAPI_MAX + 1] = { [NETDEV_A_NAPI_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, [NETDEV_A_NAPI_ID] = { .name = "id", .type = YNL_PT_U32, }, @@ -269,6 +292,25 @@ int netdev_page_pool_info_parse(struct ynl_parse_arg *yarg, return 0; } +void netdev_queue_dmabuf_free(struct netdev_queue_dmabuf *obj) +{ +} + +int netdev_queue_dmabuf_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct netdev_queue_dmabuf *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.type) + ynl_attr_put_u8(nlh, NETDEV_A_QUEUE_DMABUF_TYPE, obj->type); + if (obj->_present.idx) + ynl_attr_put_u32(nlh, NETDEV_A_QUEUE_DMABUF_IDX, obj->idx); + 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) @@ -842,6 +884,80 @@ netdev_queue_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_dmabuf_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_BIND_DMABUF_DMABUF_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dmabuf_id = 1; + dst->dmabuf_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_bind_dmabuf_nest; + yrs.yarg.rsp_policy = &netdev_bind_dmabuf_nest; + + if (req->_present.ifindex) + ynl_attr_put_u32(nlh, NETDEV_A_BIND_DMABUF_IFINDEX, req->ifindex); + if (req->_present.dmabuf_fd) + ynl_attr_put_u32(nlh, NETDEV_A_BIND_DMABUF_DMABUF_FD, req->dmabuf_fd); + for (unsigned int i = 0; i < req->n_queues; i++) + netdev_queue_dmabuf_put(nlh, NETDEV_A_BIND_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; +} + /* ============== NETDEV_CMD_NAPI_GET ============== */ /* NETDEV_CMD_NAPI_GET - do */ void netdev_napi_get_req_free(struct netdev_napi_get_req *req) diff --git a/home/nipa/nipa_out/857457/ynl/old-code/netdev-user.h b/home/nipa/nipa_out/857457/ynl/new-code/netdev-user.h index 906271a8ba74..d379c761d2e9 100644 --- a/home/nipa/nipa_out/857457/ynl/old-code/netdev-user.h +++ b/home/nipa/nipa_out/857457/ynl/new-code/netdev-user.h @@ -34,6 +34,16 @@ struct netdev_page_pool_info { __u32 ifindex; }; +struct netdev_queue_dmabuf { + struct { + __u32 type:1; + __u32 idx:1; + } _present; + + enum netdev_queue_type type; + __u32 idx; +}; + /* ============== NETDEV_CMD_DEV_GET ============== */ /* NETDEV_CMD_DEV_GET - do */ struct netdev_dev_get_req { @@ -361,6 +371,65 @@ struct netdev_queue_get_list * netdev_queue_get_dump(struct ynl_sock *ys, struct netdev_queue_get_req_dump *req); +/* ============== NETDEV_CMD_BIND_RX ============== */ +/* NETDEV_CMD_BIND_RX - do */ +struct netdev_bind_rx_req { + struct { + __u32 ifindex:1; + __u32 dmabuf_fd:1; + } _present; + + __u32 ifindex; + __u32 dmabuf_fd; + unsigned int n_queues; + struct netdev_queue_dmabuf *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_dmabuf_fd(struct netdev_bind_rx_req *req, + __u32 dmabuf_fd) +{ + req->_present.dmabuf_fd = 1; + req->dmabuf_fd = dmabuf_fd; +} +static inline void +__netdev_bind_rx_req_set_queues(struct netdev_bind_rx_req *req, + struct netdev_queue_dmabuf *queues, + unsigned int n_queues) +{ + free(req->queues); + req->queues = queues; + req->n_queues = n_queues; +} + +struct netdev_bind_rx_rsp { + struct { + __u32 dmabuf_id:1; + } _present; + + __u32 dmabuf_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); + /* ============== NETDEV_CMD_NAPI_GET ============== */ /* NETDEV_CMD_NAPI_GET - do */ struct netdev_napi_get_req {