aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2024-05-23 17:34:32 +0200
committerMichal Kubecek <mkubecek@suse.cz>2024-05-23 17:37:29 +0200
commitae1b9c65473b677503f71a36fb730115f9d978bb (patch)
tree91c0d9e548fbdf0ceda3246fe3ddecd706295189
parenta629bdabb75d557d84d7092502dc1b56c71ea746 (diff)
parentc1c17ce66bcdcd2ba43010fb5d1205f83e4ec557 (diff)
downloadethtool-next.tar.gz
Merge branch 'next' into masterHEADnextmaster
- take uapi/ contents from next
-rw-r--r--ethtool.c1
-rw-r--r--netlink/pse-pd.c66
-rw-r--r--netlink/tsinfo.c65
-rw-r--r--uapi/linux/ethtool.h55
-rw-r--r--uapi/linux/ethtool_netlink.h32
-rw-r--r--uapi/linux/if_link.h3
-rw-r--r--uapi/linux/stddef.h8
7 files changed, 223 insertions, 7 deletions
diff --git a/ethtool.c b/ethtool.c
index e587597..d85a57a 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6216,6 +6216,7 @@ static const struct option args[] = {
.nlfunc = nl_spse,
.help = "Set Power Sourcing Equipment settings",
.xhelp = " [ podl-pse-admin-control enable|disable ]\n"
+ " [ c33-pse-admin-control enable|disable ]\n"
},
{
.opts = "-h|--help",
diff --git a/netlink/pse-pd.c b/netlink/pse-pd.c
index d6faff8..2c8dd89 100644
--- a/netlink/pse-pd.c
+++ b/netlink/pse-pd.c
@@ -54,6 +54,41 @@ static const char *podl_pse_pw_d_status_name(u32 val)
}
}
+static const char *c33_pse_admin_state_name(u32 val)
+{
+ switch (val) {
+ case ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN:
+ return "unknown";
+ case ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED:
+ return "disabled";
+ case ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED:
+ return "enabled";
+ default:
+ return "unsupported";
+ }
+}
+
+static const char *c33_pse_pw_d_status_name(u32 val)
+{
+ switch (val) {
+ case ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN:
+ return "unknown";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED:
+ return "disabled";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING:
+ return "searching";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING:
+ return "delivering power";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_TEST:
+ return "test";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_FAULT:
+ return "fault";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT:
+ return "otherfault";
+ default:
+ return "unsupported";
+ }
+}
int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data)
{
const struct nlattr *tb[ETHTOOL_A_PSE_MAX + 1] = {};
@@ -98,6 +133,24 @@ int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data)
podl_pse_pw_d_status_name(val));
}
+ if (tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]);
+ print_string(PRINT_ANY, "c33-pse-admin-state",
+ "Clause 33 PSE Admin State: %s\n",
+ c33_pse_admin_state_name(val));
+ }
+
+ if (tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]);
+ print_string(PRINT_ANY, "c33-pse-power-detection-status",
+ "Clause 33 PSE Power Detection Status: %s\n",
+ c33_pse_pw_d_status_name(val));
+ }
+
close_json_object();
return MNL_CB_OK;
@@ -138,6 +191,12 @@ static const struct lookup_entry_u32 podl_pse_admin_control_values[] = {
{}
};
+static const struct lookup_entry_u32 c33_pse_admin_control_values[] = {
+ { .arg = "enable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED },
+ { .arg = "disable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED },
+ {}
+};
+
static const struct param_parser spse_params[] = {
{
.arg = "podl-pse-admin-control",
@@ -146,6 +205,13 @@ static const struct param_parser spse_params[] = {
.handler_data = podl_pse_admin_control_values,
.min_argc = 1,
},
+ {
+ .arg = "c33-pse-admin-control",
+ .type = ETHTOOL_A_C33_PSE_ADMIN_CONTROL,
+ .handler = nl_parse_lookup_u32,
+ .handler_data = c33_pse_admin_control_values,
+ .min_argc = 1,
+ },
{}
};
diff --git a/netlink/tsinfo.c b/netlink/tsinfo.c
index c6571ff..4df4141 100644
--- a/netlink/tsinfo.c
+++ b/netlink/tsinfo.c
@@ -5,6 +5,7 @@
*/
#include <errno.h>
+#include <inttypes.h>
#include <string.h>
#include <stdio.h>
@@ -15,6 +16,60 @@
/* TSINFO_GET */
+static int tsinfo_show_stats(const struct nlattr *nest)
+{
+ const struct nlattr *tb[ETHTOOL_A_TS_STAT_MAX + 1] = {};
+ DECLARE_ATTR_TB_INFO(tb);
+ static const struct {
+ unsigned int attr;
+ char *name;
+ } stats[] = {
+ { ETHTOOL_A_TS_STAT_TX_PKTS, "tx_pkts" },
+ { ETHTOOL_A_TS_STAT_TX_LOST, "tx_lost" },
+ { ETHTOOL_A_TS_STAT_TX_ERR, "tx_err" },
+ };
+ bool header = false;
+ unsigned int i;
+ __u64 val;
+ int ret;
+
+ ret = mnl_attr_parse_nested(nest, attr_cb, &tb_info);
+ if (ret < 0)
+ return ret;
+
+ open_json_object("statistics");
+ for (i = 0; i < ARRAY_SIZE(stats); i++) {
+ char fmt[64];
+
+ if (!tb[stats[i].attr])
+ continue;
+
+ if (!header && !is_json_context()) {
+ printf("Statistics:\n");
+ header = true;
+ }
+
+ if (!mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U32)) {
+ val = mnl_attr_get_u32(tb[stats[i].attr]);
+ } else if (!mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U64)) {
+ val = mnl_attr_get_u64(tb[stats[i].attr]);
+ } else {
+ fprintf(stderr, "malformed netlink message (statistic)\n");
+ goto err_close_stats;
+ }
+
+ snprintf(fmt, sizeof(fmt), " %s: %%" PRIu64 "\n", stats[i].name);
+ print_u64(PRINT_ANY, stats[i].name, fmt, val);
+ }
+ close_json_object();
+
+ return 0;
+
+err_close_stats:
+ close_json_object();
+ return -1;
+}
+
static void tsinfo_dump_cb(unsigned int idx, const char *name, bool val,
void *data __maybe_unused)
{
@@ -99,6 +154,12 @@ int tsinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
if (ret < 0)
return err_ret;
+ if (tb[ETHTOOL_A_TSINFO_STATS]) {
+ ret = tsinfo_show_stats(tb[ETHTOOL_A_TSINFO_STATS]);
+ if (ret < 0)
+ return err_ret;
+ }
+
return MNL_CB_OK;
}
@@ -106,6 +167,7 @@ int nl_tsinfo(struct cmd_context *ctx)
{
struct nl_context *nlctx = ctx->nlctx;
struct nl_socket *nlsk = nlctx->ethnl_socket;
+ u32 flags;
int ret;
if (netlink_cmd_check(ctx, ETHTOOL_MSG_TSINFO_GET, true))
@@ -116,8 +178,9 @@ int nl_tsinfo(struct cmd_context *ctx)
return 1;
}
+ flags = get_stats_flag(nlctx, ETHTOOL_MSG_TSINFO_GET, ETHTOOL_A_TSINFO_HEADER);
ret = nlsock_prep_get_request(nlsk, ETHTOOL_MSG_TSINFO_GET,
- ETHTOOL_A_TSINFO_HEADER, 0);
+ ETHTOOL_A_TSINFO_HEADER, flags);
if (ret < 0)
return ret;
return nlsock_send_get_request(nlsk, tsinfo_reply_cb);
diff --git a/uapi/linux/ethtool.h b/uapi/linux/ethtool.h
index 4d74ba0..bcec30c 100644
--- a/uapi/linux/ethtool.h
+++ b/uapi/linux/ethtool.h
@@ -751,6 +751,61 @@ enum ethtool_module_power_mode {
};
/**
+ * enum ethtool_pse_types - Types of PSE controller.
+ * @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown
+ * @ETHTOOL_PSE_PODL: PSE controller which support PoDL
+ * @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE)
+ */
+enum ethtool_pse_types {
+ ETHTOOL_PSE_UNKNOWN = 1 << 0,
+ ETHTOOL_PSE_PODL = 1 << 1,
+ ETHTOOL_PSE_C33 = 1 << 2,
+};
+
+/**
+ * enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE
+ * functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState
+ * @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown
+ * @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled
+ * @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled
+ */
+enum ethtool_c33_pse_admin_state {
+ ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN = 1,
+ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED,
+ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED,
+};
+
+/**
+ * enum ethtool_c33_pse_pw_d_status - power detection status of the PSE.
+ * IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus:
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled"
+ * indicates that the PSE State diagram is in the state DISABLED.
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching"
+ * indicates the PSE State diagram is in a state other than those
+ * listed.
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration
+ * "deliveringPower" indicates that the PSE State diagram is in the
+ * state POWER_ON.
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that
+ * the PSE State diagram is in the state TEST_MODE.
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates that
+ * the PSE State diagram is in the state TEST_ERROR.
+ * @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault"
+ * indicates that the PSE State diagram is in the state IDLE due to
+ * the variable error_condition = true.
+ */
+enum ethtool_c33_pse_pw_d_status {
+ ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN = 1,
+ ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED,
+ ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING,
+ ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING,
+ ETHTOOL_C33_PSE_PW_D_STATUS_TEST,
+ ETHTOOL_C33_PSE_PW_D_STATUS_FAULT,
+ ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT,
+};
+
+/**
* enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE
* functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
* @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are
diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h
index 447d922..c0be6e5 100644
--- a/uapi/linux/ethtool_netlink.h
+++ b/uapi/linux/ethtool_netlink.h
@@ -117,12 +117,11 @@ enum {
/* request header */
-/* use compact bitsets in reply */
-#define ETHTOOL_FLAG_COMPACT_BITSETS (1 << 0)
-/* provide optional reply for SET or ACT requests */
-#define ETHTOOL_FLAG_OMIT_REPLY (1 << 1)
-/* request statistics, if supported by the driver */
-#define ETHTOOL_FLAG_STATS (1 << 2)
+enum ethtool_header_flags {
+ ETHTOOL_FLAG_COMPACT_BITSETS = 1 << 0, /* use compact bitsets in reply */
+ ETHTOOL_FLAG_OMIT_REPLY = 1 << 1, /* provide optional reply for SET or ACT requests */
+ ETHTOOL_FLAG_STATS = 1 << 2, /* request statistics, if supported by the driver */
+};
#define ETHTOOL_FLAG_ALL (ETHTOOL_FLAG_COMPACT_BITSETS | \
ETHTOOL_FLAG_OMIT_REPLY | \
@@ -478,12 +477,26 @@ enum {
ETHTOOL_A_TSINFO_TX_TYPES, /* bitset */
ETHTOOL_A_TSINFO_RX_FILTERS, /* bitset */
ETHTOOL_A_TSINFO_PHC_INDEX, /* u32 */
+ ETHTOOL_A_TSINFO_STATS, /* nest - _A_TSINFO_STAT */
/* add new constants above here */
__ETHTOOL_A_TSINFO_CNT,
ETHTOOL_A_TSINFO_MAX = (__ETHTOOL_A_TSINFO_CNT - 1)
};
+enum {
+ ETHTOOL_A_TS_STAT_UNSPEC,
+
+ ETHTOOL_A_TS_STAT_TX_PKTS, /* uint */
+ ETHTOOL_A_TS_STAT_TX_LOST, /* uint */
+ ETHTOOL_A_TS_STAT_TX_ERR, /* uint */
+
+ /* add new constants above here */
+ __ETHTOOL_A_TS_STAT_CNT,
+ ETHTOOL_A_TS_STAT_MAX = (__ETHTOOL_A_TS_STAT_CNT - 1)
+
+};
+
/* PHC VCLOCKS */
enum {
@@ -515,6 +528,10 @@ enum {
ETHTOOL_A_CABLE_RESULT_CODE_OPEN,
ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT,
ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT,
+ /* detected reflection caused by the impedance discontinuity between
+ * a regular 100 Ohm cable and a part with the abnormal impedance value
+ */
+ ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH,
};
enum {
@@ -895,6 +912,9 @@ enum {
ETHTOOL_A_PODL_PSE_ADMIN_STATE, /* u32 */
ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, /* u32 */
ETHTOOL_A_PODL_PSE_PW_D_STATUS, /* u32 */
+ ETHTOOL_A_C33_PSE_ADMIN_STATE, /* u32 */
+ ETHTOOL_A_C33_PSE_ADMIN_CONTROL, /* u32 */
+ ETHTOOL_A_C33_PSE_PW_D_STATUS, /* u32 */
/* add new constants above here */
__ETHTOOL_A_PSE_CNT,
diff --git a/uapi/linux/if_link.h b/uapi/linux/if_link.h
index ff4ceea..987efed 100644
--- a/uapi/linux/if_link.h
+++ b/uapi/linux/if_link.h
@@ -1464,6 +1464,8 @@ enum {
IFLA_GTP_ROLE,
IFLA_GTP_CREATE_SOCKETS,
IFLA_GTP_RESTART_COUNT,
+ IFLA_GTP_LOCAL,
+ IFLA_GTP_LOCAL6,
__IFLA_GTP_MAX,
};
#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
@@ -1769,6 +1771,7 @@ enum {
IFLA_HSR_PROTOCOL, /* Indicate different protocol than
* HSR. For example PRP.
*/
+ IFLA_HSR_INTERLINK, /* HSR interlink network device */
__IFLA_HSR_MAX,
};
diff --git a/uapi/linux/stddef.h b/uapi/linux/stddef.h
index bf9749d..96aa341 100644
--- a/uapi/linux/stddef.h
+++ b/uapi/linux/stddef.h
@@ -55,4 +55,12 @@
#define __counted_by(m)
#endif
+#ifndef __counted_by_le
+#define __counted_by_le(m)
+#endif
+
+#ifndef __counted_by_be
+#define __counted_by_be(m)
+#endif
+
#endif /* _LINUX_STDDEF_H */