Skip to content

Commit e462960

Browse files
kmaincentkuba-moo
authored andcommitted
net: ethtool: pse-pd: Expand C33 PSE status with class, power and extended state
This update expands the status information provided by ethtool for PSE c33. It includes details such as the detected class, current power delivered, and extended state information. Reviewed-by: Oleksij Rempel <[email protected]> Signed-off-by: Kory Maincent <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 73d4d64 commit e462960

File tree

6 files changed

+286
-1
lines changed

6 files changed

+286
-1
lines changed

Documentation/networking/ethtool-netlink.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,13 @@ Kernel response contents:
17401740
PSE functions.
17411741
``ETHTOOL_A_C33_PSE_PW_D_STATUS`` u32 power detection status of the
17421742
PoE PSE.
1743+
``ETHTOOL_A_C33_PSE_PW_CLASS`` u32 power class of the PoE PSE.
1744+
``ETHTOOL_A_C33_PSE_ACTUAL_PW`` u32 actual power drawn on the
1745+
PoE PSE.
1746+
``ETHTOOL_A_C33_PSE_EXT_STATE`` u32 power extended state of the
1747+
PoE PSE.
1748+
``ETHTOOL_A_C33_PSE_EXT_SUBSTATE`` u32 power extended substatus of
1749+
the PoE PSE.
17431750
====================================== ====== =============================
17441751

17451752
When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` attribute identifies
@@ -1772,6 +1779,36 @@ The same goes for ``ETHTOOL_A_C33_PSE_ADMIN_PW_D_STATUS`` implementing
17721779
.. kernel-doc:: include/uapi/linux/ethtool.h
17731780
:identifiers: ethtool_c33_pse_pw_d_status
17741781

1782+
When set, the optional ``ETHTOOL_A_C33_PSE_PW_CLASS`` attribute identifies
1783+
the power class of the C33 PSE. It depends on the class negotiated between
1784+
the PSE and the PD. This option is corresponding to ``IEEE 802.3-2022``
1785+
30.9.1.1.8 aPSEPowerClassification.
1786+
1787+
When set, the optional ``ETHTOOL_A_C33_PSE_ACTUAL_PW`` attribute identifies
1788+
This option is corresponding to ``IEEE 802.3-2022`` 30.9.1.1.23 aPSEActualPower.
1789+
Actual power is reported in mW.
1790+
1791+
When set, the optional ``ETHTOOL_A_C33_PSE_EXT_STATE`` attribute identifies
1792+
the extended error state of the C33 PSE. Possible values are:
1793+
1794+
.. kernel-doc:: include/uapi/linux/ethtool.h
1795+
:identifiers: ethtool_c33_pse_ext_state
1796+
1797+
When set, the optional ``ETHTOOL_A_C33_PSE_EXT_SUBSTATE`` attribute identifies
1798+
the extended error state of the C33 PSE. Possible values are:
1799+
Possible values are:
1800+
1801+
.. kernel-doc:: include/uapi/linux/ethtool.h
1802+
:identifiers: ethtool_c33_pse_ext_substate_class_num_events
1803+
ethtool_c33_pse_ext_substate_error_condition
1804+
ethtool_c33_pse_ext_substate_mr_pse_enable
1805+
ethtool_c33_pse_ext_substate_option_detect_ted
1806+
ethtool_c33_pse_ext_substate_option_vport_lim
1807+
ethtool_c33_pse_ext_substate_ovld_detected
1808+
ethtool_c33_pse_ext_substate_pd_dll_power_type
1809+
ethtool_c33_pse_ext_substate_power_not_available
1810+
ethtool_c33_pse_ext_substate_short_detected
1811+
17751812
PSE_SET
17761813
=======
17771814

include/linux/ethtool.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,4 +1273,19 @@ struct ethtool_forced_speed_map {
12731273

12741274
void
12751275
ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size);
1276+
1277+
/* C33 PSE extended state and substate. */
1278+
struct ethtool_c33_pse_ext_state_info {
1279+
enum ethtool_c33_pse_ext_state c33_pse_ext_state;
1280+
union {
1281+
enum ethtool_c33_pse_ext_substate_error_condition error_condition;
1282+
enum ethtool_c33_pse_ext_substate_mr_pse_enable mr_pse_enable;
1283+
enum ethtool_c33_pse_ext_substate_option_detect_ted option_detect_ted;
1284+
enum ethtool_c33_pse_ext_substate_option_vport_lim option_vport_lim;
1285+
enum ethtool_c33_pse_ext_substate_ovld_detected ovld_detected;
1286+
enum ethtool_c33_pse_ext_substate_power_not_available power_not_available;
1287+
enum ethtool_c33_pse_ext_substate_short_detected short_detected;
1288+
u32 __c33_pse_ext_substate;
1289+
};
1290+
};
12761291
#endif /* _LINUX_ETHTOOL_H */

include/linux/pse-pd/pse.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ struct pse_control_config {
3636
* functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState
3737
* @c33_pw_status: power detection status of the PSE.
3838
* IEEE 802.3-2022 30.9.1.1.5 aPSEPowerDetectionStatus:
39+
* @c33_pw_class: detected class of a powered PD
40+
* IEEE 802.3-2022 30.9.1.1.8 aPSEPowerClassification
41+
* @c33_actual_pw: power currently delivered by the PSE in mW
42+
* IEEE 802.3-2022 30.9.1.1.23 aPSEActualPower
43+
* @c33_ext_state_info: extended state information of the PSE
3944
*/
4045
struct pse_control_status {
4146
enum ethtool_podl_pse_admin_state podl_admin_state;
4247
enum ethtool_podl_pse_pw_d_status podl_pw_status;
4348
enum ethtool_c33_pse_admin_state c33_admin_state;
4449
enum ethtool_c33_pse_pw_d_status c33_pw_status;
50+
u32 c33_pw_class;
51+
u32 c33_actual_pw;
52+
struct ethtool_c33_pse_ext_state_info c33_ext_state_info;
4553
};
4654

4755
/**

include/uapi/linux/ethtool.h

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,197 @@ enum ethtool_module_power_mode {
752752
ETHTOOL_MODULE_POWER_MODE_HIGH,
753753
};
754754

755+
/**
756+
* enum ethtool_c33_pse_ext_state - groups of PSE extended states
757+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
758+
*
759+
* @ETHTOOL_C33_PSE_EXT_STATE_ERROR_CONDITION: Group of error_condition states
760+
* @ETHTOOL_C33_PSE_EXT_STATE_MR_MPS_VALID: Group of mr_mps_valid states
761+
* @ETHTOOL_C33_PSE_EXT_STATE_MR_PSE_ENABLE: Group of mr_pse_enable states
762+
* @ETHTOOL_C33_PSE_EXT_STATE_OPTION_DETECT_TED: Group of option_detect_ted
763+
* states
764+
* @ETHTOOL_C33_PSE_EXT_STATE_OPTION_VPORT_LIM: Group of option_vport_lim states
765+
* @ETHTOOL_C33_PSE_EXT_STATE_OVLD_DETECTED: Group of ovld_detected states
766+
* @ETHTOOL_C33_PSE_EXT_STATE_PD_DLL_POWER_TYPE: Group of pd_dll_power_type
767+
* states
768+
* @ETHTOOL_C33_PSE_EXT_STATE_POWER_NOT_AVAILABLE: Group of power_not_available
769+
* states
770+
* @ETHTOOL_C33_PSE_EXT_STATE_SHORT_DETECTED: Group of short_detected states
771+
*/
772+
enum ethtool_c33_pse_ext_state {
773+
ETHTOOL_C33_PSE_EXT_STATE_ERROR_CONDITION = 1,
774+
ETHTOOL_C33_PSE_EXT_STATE_MR_MPS_VALID,
775+
ETHTOOL_C33_PSE_EXT_STATE_MR_PSE_ENABLE,
776+
ETHTOOL_C33_PSE_EXT_STATE_OPTION_DETECT_TED,
777+
ETHTOOL_C33_PSE_EXT_STATE_OPTION_VPORT_LIM,
778+
ETHTOOL_C33_PSE_EXT_STATE_OVLD_DETECTED,
779+
ETHTOOL_C33_PSE_EXT_STATE_PD_DLL_POWER_TYPE,
780+
ETHTOOL_C33_PSE_EXT_STATE_POWER_NOT_AVAILABLE,
781+
ETHTOOL_C33_PSE_EXT_STATE_SHORT_DETECTED,
782+
};
783+
784+
/**
785+
* enum ethtool_c33_pse_ext_substate_mr_mps_valid - mr_mps_valid states
786+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
787+
*
788+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_DETECTED_UNDERLOAD: Underload
789+
* state
790+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_CONNECTION_OPEN: Port is not
791+
* connected
792+
*
793+
* The PSE monitors either the DC or AC Maintain Power Signature
794+
* (MPS, see 33.2.9.1). This variable indicates the presence or absence of
795+
* a valid MPS.
796+
*/
797+
enum ethtool_c33_pse_ext_substate_mr_mps_valid {
798+
ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_DETECTED_UNDERLOAD = 1,
799+
ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_CONNECTION_OPEN,
800+
};
801+
802+
/**
803+
* enum ethtool_c33_pse_ext_substate_error_condition - error_condition states
804+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
805+
*
806+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_NON_EXISTING_PORT: Non-existing
807+
* port number
808+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNDEFINED_PORT: Undefined port
809+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_INTERNAL_HW_FAULT: Internal
810+
* hardware fault
811+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_COMM_ERROR_AFTER_FORCE_ON:
812+
* Communication error after force on
813+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNKNOWN_PORT_STATUS: Unknown
814+
* port status
815+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_TURN_OFF: Host
816+
* crash turn off
817+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_FORCE_SHUTDOWN:
818+
* Host crash force shutdown
819+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_CONFIG_CHANGE: Configuration
820+
* change
821+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_DETECTED_OVER_TEMP: Over
822+
* temperature detected
823+
*
824+
* error_condition is a variable indicating the status of
825+
* implementation-specific fault conditions or optionally other system faults
826+
* that prevent the PSE from meeting the specifications in Table 33–11 and that
827+
* require the PSE not to source power. These error conditions are different
828+
* from those monitored by the state diagrams in Figure 33–10.
829+
*/
830+
enum ethtool_c33_pse_ext_substate_error_condition {
831+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_NON_EXISTING_PORT = 1,
832+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNDEFINED_PORT,
833+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_INTERNAL_HW_FAULT,
834+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_COMM_ERROR_AFTER_FORCE_ON,
835+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNKNOWN_PORT_STATUS,
836+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_TURN_OFF,
837+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_FORCE_SHUTDOWN,
838+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_CONFIG_CHANGE,
839+
ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_DETECTED_OVER_TEMP,
840+
};
841+
842+
/**
843+
* enum ethtool_c33_pse_ext_substate_mr_pse_enable - mr_pse_enable states
844+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
845+
*
846+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_PSE_ENABLE_DISABLE_PIN_ACTIVE: Disable
847+
* pin active
848+
*
849+
* mr_pse_enable is control variable that selects PSE operation and test
850+
* functions.
851+
*/
852+
enum ethtool_c33_pse_ext_substate_mr_pse_enable {
853+
ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_PSE_ENABLE_DISABLE_PIN_ACTIVE = 1,
854+
};
855+
856+
/**
857+
* enum ethtool_c33_pse_ext_substate_option_detect_ted - option_detect_ted
858+
* states functions. IEEE 802.3-2022 33.2.4.4 Variables
859+
*
860+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_DET_IN_PROCESS: Detection
861+
* in process
862+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_CONNECTION_CHECK_ERROR:
863+
* Connection check error
864+
*
865+
* option_detect_ted is a variable indicating if detection can be performed
866+
* by the PSE during the ted_timer interval.
867+
*/
868+
enum ethtool_c33_pse_ext_substate_option_detect_ted {
869+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_DET_IN_PROCESS = 1,
870+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_CONNECTION_CHECK_ERROR,
871+
};
872+
873+
/**
874+
* enum ethtool_c33_pse_ext_substate_option_vport_lim - option_vport_lim states
875+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
876+
*
877+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_HIGH_VOLTAGE: Main supply
878+
* voltage is high
879+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_LOW_VOLTAGE: Main supply
880+
* voltage is low
881+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_VOLTAGE_INJECTION: Voltage
882+
* injection into the port
883+
*
884+
* option_vport_lim is an optional variable indicates if VPSE is out of the
885+
* operating range during normal operating state.
886+
*/
887+
enum ethtool_c33_pse_ext_substate_option_vport_lim {
888+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_HIGH_VOLTAGE = 1,
889+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_LOW_VOLTAGE,
890+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_VOLTAGE_INJECTION,
891+
};
892+
893+
/**
894+
* enum ethtool_c33_pse_ext_substate_ovld_detected - ovld_detected states
895+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
896+
*
897+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_OVLD_DETECTED_OVERLOAD: Overload state
898+
*
899+
* ovld_detected is a variable indicating if the PSE output current has been
900+
* in an overload condition (see 33.2.7.6) for at least TCUT of a one-second
901+
* sliding time.
902+
*/
903+
enum ethtool_c33_pse_ext_substate_ovld_detected {
904+
ETHTOOL_C33_PSE_EXT_SUBSTATE_OVLD_DETECTED_OVERLOAD = 1,
905+
};
906+
907+
/**
908+
* enum ethtool_c33_pse_ext_substate_power_not_available - power_not_available
909+
* states functions. IEEE 802.3-2022 33.2.4.4 Variables
910+
*
911+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_BUDGET_EXCEEDED: Power
912+
* budget exceeded for the controller
913+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PORT_PW_LIMIT_EXCEEDS_CONTROLLER_BUDGET:
914+
* Configured port power limit exceeded controller power budget
915+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PD_REQUEST_EXCEEDS_PORT_LIMIT:
916+
* Power request from PD exceeds port limit
917+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_HW_PW_LIMIT: Power
918+
* denied due to Hardware power limit
919+
*
920+
* power_not_available is a variable that is asserted in an
921+
* implementation-dependent manner when the PSE is no longer capable of
922+
* sourcing sufficient power to support the attached PD. Sufficient power
923+
* is defined by classification; see 33.2.6.
924+
*/
925+
enum ethtool_c33_pse_ext_substate_power_not_available {
926+
ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_BUDGET_EXCEEDED = 1,
927+
ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PORT_PW_LIMIT_EXCEEDS_CONTROLLER_BUDGET,
928+
ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PD_REQUEST_EXCEEDS_PORT_LIMIT,
929+
ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_HW_PW_LIMIT,
930+
};
931+
932+
/**
933+
* enum ethtool_c33_pse_ext_substate_short_detected - short_detected states
934+
* functions. IEEE 802.3-2022 33.2.4.4 Variables
935+
*
936+
* @ETHTOOL_C33_PSE_EXT_SUBSTATE_SHORT_DETECTED_SHORT_CONDITION: Short
937+
* condition was detected
938+
*
939+
* short_detected is a variable indicating if the PSE output current has been
940+
* in a short circuit condition for TLIM within a sliding window (see 33.2.7.7).
941+
*/
942+
enum ethtool_c33_pse_ext_substate_short_detected {
943+
ETHTOOL_C33_PSE_EXT_SUBSTATE_SHORT_DETECTED_SHORT_CONDITION = 1,
944+
};
945+
755946
/**
756947
* enum ethtool_pse_types - Types of PSE controller.
757948
* @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown

include/uapi/linux/ethtool_netlink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,10 @@ enum {
939939
ETHTOOL_A_C33_PSE_ADMIN_STATE, /* u32 */
940940
ETHTOOL_A_C33_PSE_ADMIN_CONTROL, /* u32 */
941941
ETHTOOL_A_C33_PSE_PW_D_STATUS, /* u32 */
942+
ETHTOOL_A_C33_PSE_PW_CLASS, /* u32 */
943+
ETHTOOL_A_C33_PSE_ACTUAL_PW, /* u32 */
944+
ETHTOOL_A_C33_PSE_EXT_STATE, /* u32 */
945+
ETHTOOL_A_C33_PSE_EXT_SUBSTATE, /* u32 */
942946

943947
/* add new constants above here */
944948
__ETHTOOL_A_PSE_CNT,

net/ethtool/pse-pd.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ static int pse_reply_size(const struct ethnl_req_info *req_base,
8686
len += nla_total_size(sizeof(u32)); /* _C33_PSE_ADMIN_STATE */
8787
if (st->c33_pw_status > 0)
8888
len += nla_total_size(sizeof(u32)); /* _C33_PSE_PW_D_STATUS */
89-
89+
if (st->c33_pw_class > 0)
90+
len += nla_total_size(sizeof(u32)); /* _C33_PSE_PW_CLASS */
91+
if (st->c33_actual_pw > 0)
92+
len += nla_total_size(sizeof(u32)); /* _C33_PSE_ACTUAL_PW */
93+
if (st->c33_ext_state_info.c33_pse_ext_state > 0) {
94+
len += nla_total_size(sizeof(u32)); /* _C33_PSE_EXT_STATE */
95+
if (st->c33_ext_state_info.__c33_pse_ext_substate > 0)
96+
/* _C33_PSE_EXT_SUBSTATE */
97+
len += nla_total_size(sizeof(u32));
98+
}
9099
return len;
91100
}
92101

@@ -117,6 +126,27 @@ static int pse_fill_reply(struct sk_buff *skb,
117126
st->c33_pw_status))
118127
return -EMSGSIZE;
119128

129+
if (st->c33_pw_class > 0 &&
130+
nla_put_u32(skb, ETHTOOL_A_C33_PSE_PW_CLASS,
131+
st->c33_pw_class))
132+
return -EMSGSIZE;
133+
134+
if (st->c33_actual_pw > 0 &&
135+
nla_put_u32(skb, ETHTOOL_A_C33_PSE_ACTUAL_PW,
136+
st->c33_actual_pw))
137+
return -EMSGSIZE;
138+
139+
if (st->c33_ext_state_info.c33_pse_ext_state > 0) {
140+
if (nla_put_u32(skb, ETHTOOL_A_C33_PSE_EXT_STATE,
141+
st->c33_ext_state_info.c33_pse_ext_state))
142+
return -EMSGSIZE;
143+
144+
if (st->c33_ext_state_info.__c33_pse_ext_substate > 0 &&
145+
nla_put_u32(skb, ETHTOOL_A_C33_PSE_EXT_SUBSTATE,
146+
st->c33_ext_state_info.__c33_pse_ext_substate))
147+
return -EMSGSIZE;
148+
}
149+
120150
return 0;
121151
}
122152

0 commit comments

Comments
 (0)