Re: [PATCH net-next v5 15/16] net ethtool: net: Let the active time stamping layer be selectable

From
Köry Maincent <kory.maincent@bootlin.com>
Date
2023-10-10 08:32:08
Also in
linux-doc, lkml
Reply to
Florian Fainelli, 2023-10-09
On Mon, 9 Oct 2023 14:28:38 -0700
Florian Fainelli [off-list ref] wrote:
quoted
+static int ethnl_set_ts_validate(struct ethnl_req_info *req_info,
+				 struct genl_info *info)
+{
+	struct nlattr **tb = info->attrs;
+	const struct net_device_ops *ops = req_info->dev->netdev_ops;
+
+	if (!tb[ETHTOOL_A_TS_LAYER])
+		return 0;
+
+	if (!ops->ndo_hwtstamp_set)
+		return -EOPNOTSUPP;  
I would check for this first, in all likelihood this is what most 
drivers currently do not support, no need to event de-reference the 
array of attributes.
Indeed seems more logical.
quoted
+static int ethnl_set_ts(struct ethnl_req_info *req_info, struct genl_info
*info) +{
+	struct net_device *dev = req_info->dev;
+	const struct ethtool_ops *ops = dev->ethtool_ops;
+	struct kernel_hwtstamp_config config = {0};
+	struct nlattr **tb = info->attrs;
+	bool mod = false;
+	u32 ts_layer;
+	int ret;
+
+	ts_layer = dev->ts_layer;
quoted
+
+	if (ts_layer & NETDEV_TIMESTAMPING && !ops->get_ts_info) {
+		NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_TS_LAYER],
+				    "this device cannot support
timestamping");  
Maybe expand the extended ack with "this devices does not support 
MAC-based timestamping"
Ok.
quoted
+	/* Disable time stamping in the current layer. */
+	if (netif_device_present(dev) &&
+	    dev->ts_layer & (PHYLIB_TIMESTAMPING | NETDEV_TIMESTAMPING)) {
+		ret = dev_set_hwtstamp_phylib(dev, &config, info->extack);
 
Can we still land in this function even if no changes to the 
timestamping configuration has been made? 
We land in this function every time we change the timestamp from a valid
one.  
If so, would suggest first 
getting the current configuration and compare it with the user-supplied 
configuration if there are no changes, return.
It is already done at the beginning of the function:
quoted
+	ethnl_update_u32(&ts_layer, tb[ETHTOOL_A_TS_LAYER], &mod);
+
+	if (!mod)
+		return 0;
Thread (61 messages) 61 messages, 11 authors, last reply 2023-10-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help