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()
168 * lanes and duplex values. Called when autonegotiation is on, speed, lanes or
176 unsigned long *advertising = ksettings->link_modes.advertising; in ethnl_auto_linkmodes()
177 unsigned long *supported = ksettings->link_modes.supported; in ethnl_auto_linkmodes()
186 if (info->speed == SPEED_UNKNOWN) in ethnl_auto_linkmodes()
189 (!req_speed || info->speed == ksettings->base.speed) && in ethnl_auto_linkmodes()
190 (!req_lanes || info->lanes == ksettings->lanes) && in ethnl_auto_linkmodes()
191 (!req_duplex || info->duplex == ksettings->base.duplex)) in ethnl_auto_linkmodes()
221 NL_SET_ERR_MSG_ATTR(info->extack, master_slave_cfg, in ethnl_check_linkmodes()
223 return -EOPNOTSUPP; in ethnl_check_linkmodes()
228 NL_SET_ERR_MSG_ATTR(info->extack, lanes_cfg, in ethnl_check_linkmodes()
229 "lanes value is invalid"); in ethnl_check_linkmodes()
230 return -EINVAL; in ethnl_check_linkmodes()
240 struct ethtool_link_settings *lsettings = &ksettings->base; in ethnl_update_linkmodes()
247 if (lsettings->master_slave_cfg == MASTER_SLAVE_CFG_UNSUPPORTED) { in ethnl_update_linkmodes()
248 NL_SET_ERR_MSG_ATTR(info->extack, master_slave_cfg, in ethnl_update_linkmodes()
250 return -EOPNOTSUPP; in ethnl_update_linkmodes()
259 ethnl_update_u8(&lsettings->autoneg, tb[ETHTOOL_A_LINKMODES_AUTONEG], in ethnl_update_linkmodes()
264 /* If autoneg is off and lanes parameter is not supported by the in ethnl_update_linkmodes()
267 if (!lsettings->autoneg && in ethnl_update_linkmodes()
268 !dev->ethtool_ops->cap_link_lanes_supported) { in ethnl_update_linkmodes()
269 NL_SET_ERR_MSG_ATTR(info->extack, lanes_cfg, in ethnl_update_linkmodes()
270 "lanes configuration not supported by device"); in ethnl_update_linkmodes()
271 return -EOPNOTSUPP; in ethnl_update_linkmodes()
273 } else if (!lsettings->autoneg && ksettings->lanes) { in ethnl_update_linkmodes()
274 /* If autoneg is off and lanes parameter is not passed from user but in ethnl_update_linkmodes()
275 * it was defined previously then set the lanes parameter to 0. in ethnl_update_linkmodes()
277 ksettings->lanes = 0; in ethnl_update_linkmodes()
281 ret = ethnl_update_bitset(ksettings->link_modes.advertising, in ethnl_update_linkmodes()
284 info->extack, mod); in ethnl_update_linkmodes()
287 ethnl_update_u32(&lsettings->speed, tb[ETHTOOL_A_LINKMODES_SPEED], in ethnl_update_linkmodes()
289 ethnl_update_u32(&ksettings->lanes, lanes_cfg, mod); in ethnl_update_linkmodes()
290 ethnl_update_u8(&lsettings->duplex, tb[ETHTOOL_A_LINKMODES_DUPLEX], in ethnl_update_linkmodes()
292 ethnl_update_u8(&lsettings->master_slave_cfg, master_slave_cfg, mod); in ethnl_update_linkmodes()
294 if (!tb[ETHTOOL_A_LINKMODES_OURS] && lsettings->autoneg && in ethnl_update_linkmodes()
306 const struct ethtool_ops *ops = req_info->dev->ethtool_ops; in ethnl_set_linkmodes_validate()
309 ret = ethnl_check_linkmodes(info, info->attrs); in ethnl_set_linkmodes_validate()
313 if (!ops->get_link_ksettings || !ops->set_link_ksettings) in ethnl_set_linkmodes_validate()
314 return -EOPNOTSUPP; in ethnl_set_linkmodes_validate()
322 struct net_device *dev = req_info->dev; in ethnl_set_linkmodes()
323 struct nlattr **tb = info->attrs; in ethnl_set_linkmodes()
339 ret = dev->ethtool_ops->set_link_ksettings(dev, &ksettings); in ethnl_set_linkmodes()