Lines Matching +full:ethernet +full:- +full:pse
1 // SPDX-License-Identifier: GPL-2.0-only
3 // ethtool interface for Ethernet PSE (Power Sourcing Equipment)
10 #include "linux/pse-pd/pse.h"
40 return -EOPNOTSUPP; in pse_get_pse_attributes()
43 if (!phydev->psec) { in pse_get_pse_attributes()
44 NL_SET_ERR_MSG(extack, "No PSE is attached"); in pse_get_pse_attributes()
45 return -EOPNOTSUPP; in pse_get_pse_attributes()
48 memset(&data->status, 0, sizeof(data->status)); in pse_get_pse_attributes()
50 return pse_ethtool_get_status(phydev->psec, extack, &data->status); in pse_get_pse_attributes()
58 struct net_device *dev = reply_base->dev; in pse_prepare_data()
59 struct nlattr **tb = info->attrs; in pse_prepare_data()
68 info->extack); in pse_prepare_data()
70 return -ENODEV; in pse_prepare_data()
72 ret = pse_get_pse_attributes(phydev, info->extack, data); in pse_prepare_data()
83 const struct ethtool_pse_control_status *st = &data->status; in pse_reply_size()
86 if (st->podl_admin_state > 0) in pse_reply_size()
88 if (st->podl_pw_status > 0) in pse_reply_size()
90 if (st->c33_admin_state > 0) in pse_reply_size()
92 if (st->c33_pw_status > 0) in pse_reply_size()
94 if (st->c33_pw_class > 0) in pse_reply_size()
96 if (st->c33_actual_pw > 0) in pse_reply_size()
98 if (st->c33_ext_state_info.c33_pse_ext_state > 0) { in pse_reply_size()
100 if (st->c33_ext_state_info.__c33_pse_ext_substate > 0) in pse_reply_size()
104 if (st->c33_avail_pw_limit > 0) in pse_reply_size()
107 if (st->c33_pw_limit_nb_ranges > 0) in pse_reply_size()
109 len += st->c33_pw_limit_nb_ranges * in pse_reply_size()
122 pw_limit_ranges = st->c33_pw_limit_ranges; in pse_put_pw_limit_ranges()
123 for (i = 0; i < st->c33_pw_limit_nb_ranges; i++) { in pse_put_pw_limit_ranges()
128 return -EMSGSIZE; in pse_put_pw_limit_ranges()
131 pw_limit_ranges->min) || in pse_put_pw_limit_ranges()
133 pw_limit_ranges->max)) { in pse_put_pw_limit_ranges()
135 return -EMSGSIZE; in pse_put_pw_limit_ranges()
149 const struct ethtool_pse_control_status *st = &data->status; in pse_fill_reply()
151 if (st->podl_admin_state > 0 && in pse_fill_reply()
153 st->podl_admin_state)) in pse_fill_reply()
154 return -EMSGSIZE; in pse_fill_reply()
156 if (st->podl_pw_status > 0 && in pse_fill_reply()
158 st->podl_pw_status)) in pse_fill_reply()
159 return -EMSGSIZE; in pse_fill_reply()
161 if (st->c33_admin_state > 0 && in pse_fill_reply()
163 st->c33_admin_state)) in pse_fill_reply()
164 return -EMSGSIZE; in pse_fill_reply()
166 if (st->c33_pw_status > 0 && in pse_fill_reply()
168 st->c33_pw_status)) in pse_fill_reply()
169 return -EMSGSIZE; in pse_fill_reply()
171 if (st->c33_pw_class > 0 && in pse_fill_reply()
173 st->c33_pw_class)) in pse_fill_reply()
174 return -EMSGSIZE; in pse_fill_reply()
176 if (st->c33_actual_pw > 0 && in pse_fill_reply()
178 st->c33_actual_pw)) in pse_fill_reply()
179 return -EMSGSIZE; in pse_fill_reply()
181 if (st->c33_ext_state_info.c33_pse_ext_state > 0) { in pse_fill_reply()
183 st->c33_ext_state_info.c33_pse_ext_state)) in pse_fill_reply()
184 return -EMSGSIZE; in pse_fill_reply()
186 if (st->c33_ext_state_info.__c33_pse_ext_substate > 0 && in pse_fill_reply()
188 st->c33_ext_state_info.__c33_pse_ext_substate)) in pse_fill_reply()
189 return -EMSGSIZE; in pse_fill_reply()
192 if (st->c33_avail_pw_limit > 0 && in pse_fill_reply()
194 st->c33_avail_pw_limit)) in pse_fill_reply()
195 return -EMSGSIZE; in pse_fill_reply()
197 if (st->c33_pw_limit_nb_ranges > 0 && in pse_fill_reply()
199 return -EMSGSIZE; in pse_fill_reply()
208 kfree(data->status.c33_pw_limit_ranges); in pse_cleanup_data()
227 struct nlattr **tb = info->attrs; in ethnl_set_pse_validate()
230 NL_SET_ERR_MSG(info->extack, "No PHY is attached"); in ethnl_set_pse_validate()
231 return -EOPNOTSUPP; in ethnl_set_pse_validate()
234 if (!phydev->psec) { in ethnl_set_pse_validate()
235 NL_SET_ERR_MSG(info->extack, "No PSE is attached"); in ethnl_set_pse_validate()
236 return -EOPNOTSUPP; in ethnl_set_pse_validate()
240 !pse_has_podl(phydev->psec)) { in ethnl_set_pse_validate()
241 NL_SET_ERR_MSG_ATTR(info->extack, in ethnl_set_pse_validate()
243 "setting PoDL PSE admin control not supported"); in ethnl_set_pse_validate()
244 return -EOPNOTSUPP; in ethnl_set_pse_validate()
247 !pse_has_c33(phydev->psec)) { in ethnl_set_pse_validate()
248 NL_SET_ERR_MSG_ATTR(info->extack, in ethnl_set_pse_validate()
250 "setting C33 PSE admin control not supported"); in ethnl_set_pse_validate()
251 return -EOPNOTSUPP; in ethnl_set_pse_validate()
260 struct nlattr **tb = info->attrs; in ethnl_set_pse()
265 info->extack); in ethnl_set_pse()
274 ret = pse_ethtool_set_pw_limit(phydev->psec, info->extack, in ethnl_set_pse()
293 ret = pse_ethtool_set_config(phydev->psec, info->extack, in ethnl_set_pse()
299 /* Return errno or zero - PSE has no notification */ in ethnl_set_pse()
316 /* PSE has no notification */