Get the interface speed related information using ethtool
Signed-off-by: Greg Armstrong <[email protected]>
Signed-off-by: Leon Goldin <[email protected]>
Signed-off-by: Devasish Dey <[email protected]>
Signed-off-by: Vipin Sharma <[email protected]>
---
clock.c | 2 ++
interface.c | 11 +++++++++++
interface.h | 14 ++++++++++++++
port.c | 5 +++++
4 files changed, 32 insertions(+)
diff --git a/clock.c b/clock.c
index d37bb87..de69c52 100644
--- a/clock.c
+++ b/clock.c
@@ -1004,6 +1004,8 @@ struct clock *clock_create(enum clock_type type, struct
config *config,
memset(ts_label, 0, sizeof(ts_label));
if (!rtnl_get_ts_device(interface_name(iface), ts_label))
interface_set_label(iface, ts_label);
+ /* Interface speed information */
+ interface_get_ifinfo(iface);
interface_get_tsinfo(iface);
if (interface_tsinfo_valid(iface) &&
!interface_tsmodes_supported(iface, required_modes)) {
diff --git a/interface.c b/interface.c
index 6c2630c..9bcb343 100644
--- a/interface.c
+++ b/interface.c
@@ -12,6 +12,7 @@ struct interface {
char name[MAX_IFNAME_SIZE + 1];
char ts_label[MAX_IFNAME_SIZE + 1];
struct sk_ts_info ts_info;
+ struct sk_if_info if_info;
int vclock;
};
@@ -40,6 +41,11 @@ int interface_get_tsinfo(struct interface *iface)
return sk_get_ts_info(iface->ts_label, &iface->ts_info);
}
+int interface_get_ifinfo(struct interface *iface)
+{
+ return sk_get_if_info(iface->ts_label, &iface->if_info);
+}
+
const char *interface_label(struct interface *iface)
{
return iface->ts_label;
@@ -65,6 +71,11 @@ bool interface_tsinfo_valid(struct interface *iface)
return iface->ts_info.valid ? true : false;
}
+bool interface_ifinfo_valid(struct interface *iface)
+{
+ return iface->if_info.valid ? true : false;
+}
+
bool interface_tsmodes_supported(struct interface *iface, int modes)
{
if ((iface->ts_info.so_timestamping & modes) == modes) {
diff --git a/interface.h b/interface.h
index 5fc7836..5289a7f 100644
--- a/interface.h
+++ b/interface.h
@@ -40,6 +40,13 @@ void interface_destroy(struct interface *iface);
*/
int interface_get_tsinfo(struct interface *iface);
+/**
+ * Populate the time stamping information of a given interface.
+ * @param iface The interface of interest.
+ * @return zero on success, negative on failure.
+ */
+int interface_get_ifinfo(struct interface *iface);
+
/**
* Obtain the time stamping label of a network interface. This can be
* different from the name of the interface when bonding is in effect.
@@ -77,6 +84,13 @@ void interface_set_label(struct interface *iface, const char
*label);
*/
bool interface_tsinfo_valid(struct interface *iface);
+/**
+ * Tests whether an interface's interface information is valid or not.
+ * @param iface The interface of interest.
+ * @return True if the interface information is valid, false otherwise.
+ */
+bool interface_ifinfo_valid(struct interface *iface);
+
/**
* Tests whether an interface supports a set of given time stamping modes.
* @param iface The interface of interest.
diff --git a/port.c b/port.c
index 871ad68..2232b69 100644
--- a/port.c
+++ b/port.c
@@ -2726,6 +2726,11 @@ void port_link_status(void *ctx, int linkup, int
ts_index)
p->link_status = link_state;
} else {
p->link_status = link_state | LINK_STATE_CHANGED;
+ /* Update Interface speed information on Link up*/
+ if (linkup) {
+ interface_get_ifinfo(p->iface);
+ }
+
pr_notice("%s: link %s", p->log_name, linkup ? "up" : "down");
}
--
2.17.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel