Lines Matching +full:data +full:- +full:lanes
1 // SPDX-License-Identifier: GPL-2.0-only
32 struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base); in linkmodes_prepare_data() local
33 struct net_device *dev = reply_base->dev; in linkmodes_prepare_data()
36 data->lsettings = &data->ksettings.base; in linkmodes_prepare_data()
42 ret = __ethtool_get_link_ksettings(dev, &data->ksettings); in linkmodes_prepare_data()
48 if (!dev->ethtool_ops->cap_link_lanes_supported) in linkmodes_prepare_data()
49 data->ksettings.lanes = 0; in linkmodes_prepare_data()
51 data->peer_empty = in linkmodes_prepare_data()
52 bitmap_empty(data->ksettings.link_modes.lp_advertising, in linkmodes_prepare_data()
63 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base); in linkmodes_reply_size() local
64 const struct ethtool_link_ksettings *ksettings = &data->ksettings; in linkmodes_reply_size()
65 const struct ethtool_link_settings *lsettings = &ksettings->base; in linkmodes_reply_size()
66 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; in linkmodes_reply_size()
75 ret = ethnl_bitset_size(ksettings->link_modes.advertising, in linkmodes_reply_size()
76 ksettings->link_modes.supported, in linkmodes_reply_size()
82 if (!data->peer_empty) { in linkmodes_reply_size()
83 ret = ethnl_bitset_size(ksettings->link_modes.lp_advertising, in linkmodes_reply_size()
91 if (lsettings->master_slave_cfg != MASTER_SLAVE_CFG_UNSUPPORTED) in linkmodes_reply_size()
94 if (lsettings->master_slave_state != MASTER_SLAVE_STATE_UNSUPPORTED) in linkmodes_reply_size()
104 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base); in linkmodes_fill_reply() local
105 const struct ethtool_link_ksettings *ksettings = &data->ksettings; in linkmodes_fill_reply()
106 const struct ethtool_link_settings *lsettings = &ksettings->base; in linkmodes_fill_reply()
107 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; in linkmodes_fill_reply()
110 if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg)) in linkmodes_fill_reply()
111 return -EMSGSIZE; in linkmodes_fill_reply()
114 ksettings->link_modes.advertising, in linkmodes_fill_reply()
115 ksettings->link_modes.supported, in linkmodes_fill_reply()
119 return -EMSGSIZE; in linkmodes_fill_reply()
120 if (!data->peer_empty) { in linkmodes_fill_reply()
122 ksettings->link_modes.lp_advertising, in linkmodes_fill_reply()
126 return -EMSGSIZE; in linkmodes_fill_reply()
129 if (nla_put_u32(skb, ETHTOOL_A_LINKMODES_SPEED, lsettings->speed) || in linkmodes_fill_reply()
130 nla_put_u8(skb, ETHTOOL_A_LINKMODES_DUPLEX, lsettings->duplex)) in linkmodes_fill_reply()
131 return -EMSGSIZE; in linkmodes_fill_reply()
133 if (ksettings->lanes && in linkmodes_fill_reply()
134 nla_put_u32(skb, ETHTOOL_A_LINKMODES_LANES, ksettings->lanes)) in linkmodes_fill_reply()
135 return -EMSGSIZE; in linkmodes_fill_reply()
137 if (lsettings->master_slave_cfg != MASTER_SLAVE_CFG_UNSUPPORTED && in linkmodes_fill_reply()
139 lsettings->master_slave_cfg)) in linkmodes_fill_reply()
140 return -EMSGSIZE; in linkmodes_fill_reply()
142 if (lsettings->master_slave_state != MASTER_SLAVE_STATE_UNSUPPORTED && in linkmodes_fill_reply()
144 lsettings->master_slave_state)) in linkmodes_fill_reply()
145 return -EMSGSIZE; in linkmodes_fill_reply()
148 lsettings->rate_matching)) in linkmodes_fill_reply()
149 return -EMSGSIZE; in linkmodes_fill_reply()
180 * lanes and duplex values. Called when autonegotiation is on, speed, lanes or
188 unsigned long *advertising = ksettings->link_modes.advertising; in ethnl_auto_linkmodes()
189 unsigned long *supported = ksettings->link_modes.supported; in ethnl_auto_linkmodes()
198 if (info->speed == SPEED_UNKNOWN) in ethnl_auto_linkmodes()
201 (!req_speed || info->speed == ksettings->base.speed) && in ethnl_auto_linkmodes()
202 (!req_lanes || info->lanes == ksettings->lanes) && in ethnl_auto_linkmodes()
203 (!req_duplex || info->duplex == ksettings->base.duplex)) in ethnl_auto_linkmodes()
233 NL_SET_ERR_MSG_ATTR(info->extack, master_slave_cfg, in ethnl_check_linkmodes()
235 return -EOPNOTSUPP; in ethnl_check_linkmodes()
240 NL_SET_ERR_MSG_ATTR(info->extack, lanes_cfg, in ethnl_check_linkmodes()
241 "lanes value is invalid"); in ethnl_check_linkmodes()
242 return -EINVAL; in ethnl_check_linkmodes()
252 struct ethtool_link_settings *lsettings = &ksettings->base; in ethnl_update_linkmodes()
259 if (lsettings->master_slave_cfg == MASTER_SLAVE_CFG_UNSUPPORTED) { in ethnl_update_linkmodes()
260 NL_SET_ERR_MSG_ATTR(info->extack, master_slave_cfg, in ethnl_update_linkmodes()
262 return -EOPNOTSUPP; in ethnl_update_linkmodes()
271 ethnl_update_u8(&lsettings->autoneg, tb[ETHTOOL_A_LINKMODES_AUTONEG], in ethnl_update_linkmodes()
276 /* If autoneg is off and lanes parameter is not supported by the in ethnl_update_linkmodes()
279 if (!lsettings->autoneg && in ethnl_update_linkmodes()
280 !dev->ethtool_ops->cap_link_lanes_supported) { in ethnl_update_linkmodes()
281 NL_SET_ERR_MSG_ATTR(info->extack, lanes_cfg, in ethnl_update_linkmodes()
282 "lanes configuration not supported by device"); in ethnl_update_linkmodes()
283 return -EOPNOTSUPP; in ethnl_update_linkmodes()
285 } else if (!lsettings->autoneg) { in ethnl_update_linkmodes()
286 /* If autoneg is off and lanes parameter is not passed from user, in ethnl_update_linkmodes()
287 * set the lanes parameter to 0. in ethnl_update_linkmodes()
289 ksettings->lanes = 0; in ethnl_update_linkmodes()
292 ret = ethnl_update_bitset(ksettings->link_modes.advertising, in ethnl_update_linkmodes()
295 info->extack, mod); in ethnl_update_linkmodes()
298 ethnl_update_u32(&lsettings->speed, tb[ETHTOOL_A_LINKMODES_SPEED], in ethnl_update_linkmodes()
300 ethnl_update_u32(&ksettings->lanes, lanes_cfg, mod); in ethnl_update_linkmodes()
301 ethnl_update_u8(&lsettings->duplex, tb[ETHTOOL_A_LINKMODES_DUPLEX], in ethnl_update_linkmodes()
303 ethnl_update_u8(&lsettings->master_slave_cfg, master_slave_cfg, mod); in ethnl_update_linkmodes()
305 if (!tb[ETHTOOL_A_LINKMODES_OURS] && lsettings->autoneg && in ethnl_update_linkmodes()
317 struct nlattr **tb = info->attrs; in ethnl_set_linkmodes()
328 genl_info_net(info), info->extack, in ethnl_set_linkmodes()
333 ret = -EOPNOTSUPP; in ethnl_set_linkmodes()
334 if (!dev->ethtool_ops->get_link_ksettings || in ethnl_set_linkmodes()
335 !dev->ethtool_ops->set_link_ksettings) in ethnl_set_linkmodes()
354 ret = dev->ethtool_ops->set_link_ksettings(dev, &ksettings); in ethnl_set_linkmodes()