Re: [PATCH net-next v13 07/13] net: ethtool: Introduce a command to list PHYs on an interface

From: Jakub Kicinski
Date: Thu Jun 13 2024 - 21:18:24 EST


On Fri, 7 Jun 2024 09:18:20 +0200 Maxime Chevallier wrote:
> + it's parent PHY through an SFP

its

> +static int ethnl_phy_parse_request(struct ethnl_req_info *req_base,
> + struct nlattr **tb)
> +{
> + struct phy_link_topology *topo = req_base->dev->link_topo;
> + struct phy_req_info *req_info = PHY_REQINFO(req_base);
> + struct phy_device_node *pdn;
> +
> + if (!req_base->phydev)
> + return 0;
> +
> + if (!topo)
> + return 0;
> +
> + pdn = xa_load(&topo->phys, req_base->phydev->phyindex);
> + memcpy(&req_info->pdn, pdn, sizeof(*pdn));

> + xa_for_each_start(&dev->link_topo->phys, ctx->phy_index, pdn, ctx->phy_index) {
> + ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_PHY_GET_REPLY);
> + if (!ehdr) {
> + ret = -EMSGSIZE;
> + break;
> + }
> +
> + ret = ethnl_fill_reply_header(skb, dev, ETHTOOL_A_PHY_HEADER);
> + if (ret < 0) {
> + genlmsg_cancel(skb, ehdr);
> + break;
> + }
> +
> + memcpy(&pri->pdn, pdn, sizeof(*pdn));

Why do you copy the pdn each time 🤔️

> + return ret;
> +}
> +

double new line at the end