diff --git a/home/nipa/nipa_out/920056/ynl/old-code/netdev-user.c b/home/nipa/nipa_out/920056/ynl/new-code/netdev-user.c index 1d3877ce20bb..288b3332d713 100644 --- a/home/nipa/nipa_out/920056/ynl/old-code/netdev-user.c +++ b/home/nipa/nipa_out/920056/ynl/new-code/netdev-user.c @@ -27,6 +27,7 @@ static const char * const netdev_op_strmap[] = { [NETDEV_CMD_QSTATS_GET] = "qstats-get", [NETDEV_CMD_BIND_RX] = "bind-rx", [NETDEV_CMD_NAPI_SET] = "napi-set", + [NETDEV_CMD_BIND_TX] = "bind-tx", }; const char *netdev_op_str(int op) @@ -1256,6 +1257,73 @@ int netdev_napi_set(struct ynl_sock *ys, struct netdev_napi_set_req *req) return 0; } +/* ============== NETDEV_CMD_BIND_TX ============== */ +/* NETDEV_CMD_BIND_TX - do */ +void netdev_bind_tx_req_free(struct netdev_bind_tx_req *req) +{ + free(req); +} + +void netdev_bind_tx_rsp_free(struct netdev_bind_tx_rsp *rsp) +{ + free(rsp); +} + +int netdev_bind_tx_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct netdev_bind_tx_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_tx_rsp * +netdev_bind_tx(struct ynl_sock *ys, struct netdev_bind_tx_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct netdev_bind_tx_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_BIND_TX, 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); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = netdev_bind_tx_rsp_parse; + yrs.rsp_cmd = NETDEV_CMD_BIND_TX; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + netdev_bind_tx_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/920056/ynl/old-code/netdev-user.h b/home/nipa/nipa_out/920056/ynl/new-code/netdev-user.h index bc103e532cb3..e66603d6c200 100644 --- a/home/nipa/nipa_out/920056/ynl/old-code/netdev-user.h +++ b/home/nipa/nipa_out/920056/ynl/new-code/netdev-user.h @@ -638,4 +638,51 @@ netdev_napi_set_req_set_irq_suspend_timeout(struct netdev_napi_set_req *req, */ int netdev_napi_set(struct ynl_sock *ys, struct netdev_napi_set_req *req); +/* ============== NETDEV_CMD_BIND_TX ============== */ +/* NETDEV_CMD_BIND_TX - do */ +struct netdev_bind_tx_req { + struct { + __u32 ifindex:1; + __u32 fd:1; + } _present; + + __u32 ifindex; + __u32 fd; +}; + +static inline struct netdev_bind_tx_req *netdev_bind_tx_req_alloc(void) +{ + return calloc(1, sizeof(struct netdev_bind_tx_req)); +} +void netdev_bind_tx_req_free(struct netdev_bind_tx_req *req); + +static inline void +netdev_bind_tx_req_set_ifindex(struct netdev_bind_tx_req *req, __u32 ifindex) +{ + req->_present.ifindex = 1; + req->ifindex = ifindex; +} +static inline void +netdev_bind_tx_req_set_fd(struct netdev_bind_tx_req *req, __u32 fd) +{ + req->_present.fd = 1; + req->fd = fd; +} + +struct netdev_bind_tx_rsp { + struct { + __u32 id:1; + } _present; + + __u32 id; +}; + +void netdev_bind_tx_rsp_free(struct netdev_bind_tx_rsp *rsp); + +/* + * Bind dmabuf to netdev for TX + */ +struct netdev_bind_tx_rsp * +netdev_bind_tx(struct ynl_sock *ys, struct netdev_bind_tx_req *req); + #endif /* _LINUX_NETDEV_GEN_H */