diff --git a/home/nipa/nipa_out/896930/ynl/old-code/netdev-user.c b/home/nipa/nipa_out/896930/ynl/new-code/netdev-user.c index eb5aa32d0bc6..81af84a84e3f 100644 --- a/home/nipa/nipa_out/896930/ynl/old-code/netdev-user.c +++ b/home/nipa/nipa_out/896930/ynl/new-code/netdev-user.c @@ -26,6 +26,7 @@ static const char * const netdev_op_strmap[] = { [NETDEV_CMD_NAPI_GET] = "napi-get", [NETDEV_CMD_QSTATS_GET] = "qstats-get", [NETDEV_CMD_BIND_RX] = "bind-rx", + [NETDEV_CMD_NAPI_SET] = "napi-set", }; const char *netdev_op_str(int op) @@ -192,6 +193,8 @@ const struct ynl_policy_attr netdev_napi_policy[NETDEV_A_NAPI_MAX + 1] = { [NETDEV_A_NAPI_ID] = { .name = "id", .type = YNL_PT_U32, }, [NETDEV_A_NAPI_IRQ] = { .name = "irq", .type = YNL_PT_U32, }, [NETDEV_A_NAPI_PID] = { .name = "pid", .type = YNL_PT_U32, }, + [NETDEV_A_NAPI_DEFER_HARD_IRQS] = { .name = "defer-hard-irqs", .type = YNL_PT_U32, }, + [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] = { .name = "gro-flush-timeout", .type = YNL_PT_UINT, }, }; const struct ynl_policy_nest netdev_napi_nest = { @@ -940,6 +943,16 @@ int netdev_napi_get_rsp_parse(const struct nlmsghdr *nlh, return YNL_PARSE_CB_ERROR; dst->_present.pid = 1; dst->pid = ynl_attr_get_u32(attr); + } else if (type == NETDEV_A_NAPI_DEFER_HARD_IRQS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.defer_hard_irqs = 1; + dst->defer_hard_irqs = ynl_attr_get_u32(attr); + } else if (type == NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gro_flush_timeout = 1; + dst->gro_flush_timeout = ynl_attr_get_uint(attr); } } @@ -1205,6 +1218,36 @@ netdev_bind_rx(struct ynl_sock *ys, struct netdev_bind_rx_req *req) return NULL; } +/* ============== NETDEV_CMD_NAPI_SET ============== */ +/* NETDEV_CMD_NAPI_SET - do */ +void netdev_napi_set_req_free(struct netdev_napi_set_req *req) +{ + free(req); +} + +int netdev_napi_set(struct ynl_sock *ys, struct netdev_napi_set_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_NAPI_SET, 1); + ys->req_policy = &netdev_napi_nest; + + if (req->_present.id) + ynl_attr_put_u32(nlh, NETDEV_A_NAPI_ID, req->id); + if (req->_present.defer_hard_irqs) + ynl_attr_put_u32(nlh, NETDEV_A_NAPI_DEFER_HARD_IRQS, req->defer_hard_irqs); + if (req->_present.gro_flush_timeout) + ynl_attr_put_uint(nlh, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, req->gro_flush_timeout); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + 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/896930/ynl/old-code/netdev-user.h b/home/nipa/nipa_out/896930/ynl/new-code/netdev-user.h index a407e22cb7eb..747b7745dd65 100644 --- a/home/nipa/nipa_out/896930/ynl/old-code/netdev-user.h +++ b/home/nipa/nipa_out/896930/ynl/new-code/netdev-user.h @@ -404,12 +404,16 @@ struct netdev_napi_get_rsp { __u32 ifindex:1; __u32 irq:1; __u32 pid:1; + __u32 defer_hard_irqs:1; + __u32 gro_flush_timeout:1; } _present; __u32 id; __u32 ifindex; __u32 irq; __u32 pid; + __u32 defer_hard_irqs; + __u64 gro_flush_timeout; }; void netdev_napi_get_rsp_free(struct netdev_napi_get_rsp *rsp); @@ -577,4 +581,50 @@ void netdev_bind_rx_rsp_free(struct netdev_bind_rx_rsp *rsp); struct netdev_bind_rx_rsp * netdev_bind_rx(struct ynl_sock *ys, struct netdev_bind_rx_req *req); +/* ============== NETDEV_CMD_NAPI_SET ============== */ +/* NETDEV_CMD_NAPI_SET - do */ +struct netdev_napi_set_req { + struct { + __u32 id:1; + __u32 defer_hard_irqs:1; + __u32 gro_flush_timeout:1; + } _present; + + __u32 id; + __u32 defer_hard_irqs; + __u64 gro_flush_timeout; +}; + +static inline struct netdev_napi_set_req *netdev_napi_set_req_alloc(void) +{ + return calloc(1, sizeof(struct netdev_napi_set_req)); +} +void netdev_napi_set_req_free(struct netdev_napi_set_req *req); + +static inline void +netdev_napi_set_req_set_id(struct netdev_napi_set_req *req, __u32 id) +{ + req->_present.id = 1; + req->id = id; +} +static inline void +netdev_napi_set_req_set_defer_hard_irqs(struct netdev_napi_set_req *req, + __u32 defer_hard_irqs) +{ + req->_present.defer_hard_irqs = 1; + req->defer_hard_irqs = defer_hard_irqs; +} +static inline void +netdev_napi_set_req_set_gro_flush_timeout(struct netdev_napi_set_req *req, + __u64 gro_flush_timeout) +{ + req->_present.gro_flush_timeout = 1; + req->gro_flush_timeout = gro_flush_timeout; +} + +/* + * Set configurable NAPI instance settings. + */ +int netdev_napi_set(struct ynl_sock *ys, struct netdev_napi_set_req *req); + #endif /* _LINUX_NETDEV_GEN_H */