Commit fbcf9381 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

devlink: use xa_for_each_start() helper in devlink_nl_cmd_port_get_dump_one()

As xarray has an iterator helper that allows to start from specified
index, use this directly and avoid repeated iteration from 0.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 94ba1c31
...@@ -1110,24 +1110,18 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink, ...@@ -1110,24 +1110,18 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct devlink_nl_dump_state *state = devlink_dump_state(cb); struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_port *devlink_port; struct devlink_port *devlink_port;
unsigned long port_index; unsigned long port_index;
int idx = 0;
int err = 0; int err = 0;
xa_for_each(&devlink->ports, port_index, devlink_port) { xa_for_each_start(&devlink->ports, port_index, devlink_port, state->idx) {
if (idx < state->idx) {
idx++;
continue;
}
err = devlink_nl_port_fill(msg, devlink_port, err = devlink_nl_port_fill(msg, devlink_port,
DEVLINK_CMD_NEW, DEVLINK_CMD_NEW,
NETLINK_CB(cb->skb).portid, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, cb->nlh->nlmsg_seq,
NLM_F_MULTI, cb->extack); NLM_F_MULTI, cb->extack);
if (err) { if (err) {
state->idx = idx; state->idx = port_index;
break; break;
} }
idx++;
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment