diff mbox series

[net-next] net: dsa: dont use generic selftest strings for custom selftests

Message ID 20231214142136.17564-1-ante.knezic@helmholz.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: dsa: dont use generic selftest strings for custom selftests | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ante Knezic Dec. 14, 2023, 2:21 p.m. UTC
if dsa device supports custom selftests than we should use custom
selftest strings for ethtool.

Signed-off-by: Ante Knezic <ante.knezic@helmholz.de>
---
 net/dsa/user.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Vladimir Oltean Dec. 14, 2023, 2:25 p.m. UTC | #1
On Thu, Dec 14, 2023 at 03:21:36PM +0100, Ante Knezic wrote:
> if dsa device supports custom selftests than we should use custom
> selftest strings for ethtool.
> 
> Signed-off-by: Ante Knezic <ante.knezic@helmholz.de>
> ---

I didn't notice when the selftest support was added that there is no
implementation in DSA drivers of custom ds->ops->self_test(). Adding
interfaces with no users is frowned upon, precisely because it doesn't
show the big picture.

You must have noticed this because you do have a driver implementation,
so would you mind posting it together with this fix?
Ante Knezic Dec. 14, 2023, 2:47 p.m. UTC | #2
Indeed I do have a custom implementation for the mv88e6xxx chip, but its not
come to state to be posted because of test/chip specifics.

> I didn't notice when the selftest support was added that there is no
> implementation in DSA drivers of custom ds->ops->self_test(). Adding
> interfaces with no users is frowned upon, precisely because it doesn't
> show the big picture.

I was not aware of this, I apologize. If this is the case, perhaps this patch
should wait for the first custom self test implementation and be reposted as
a part of bigger series.

Thanks,
Ante
Vladimir Oltean Dec. 14, 2023, 2:56 p.m. UTC | #3
On Thu, Dec 14, 2023 at 03:47:51PM +0100, Ante Knezic wrote:
> Indeed I do have a custom implementation for the mv88e6xxx chip, but its not
> come to state to be posted because of test/chip specifics.
> 
> > I didn't notice when the selftest support was added that there is no
> > implementation in DSA drivers of custom ds->ops->self_test(). Adding
> > interfaces with no users is frowned upon, precisely because it doesn't
> > show the big picture.
> 
> I was not aware of this, I apologize. If this is the case, perhaps this patch
> should wait for the first custom self test implementation and be reposted as
> a part of bigger series.
> 
> Thanks,
> Ante
> 

I agree this should be resubmitted with a user of the API. Looking
forward to seeing it. Thanks for the understanding.

The only thing I would want to comment on the patch as it is is to avoid
the pattern of:

	if (a)
		return x;
	else
		return y;

and formulate it as:

	if (a)
		return x;

	return y;

instead. The "else" is redundant for an "if" that ends with a return statement.

---
pw-bot: changes-requested
diff mbox series

Patch

diff --git a/net/dsa/user.c b/net/dsa/user.c
index d438884a4eb0..d0e0d1a2bff7 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -1072,7 +1072,11 @@  static void dsa_user_get_strings(struct net_device *dev,
 			ds->ops->get_strings(ds, dp->index, stringset,
 					     data + 4 * len);
 	} else if (stringset ==  ETH_SS_TEST) {
-		net_selftest_get_strings(data);
+		if (ds->ops->self_test && ds->ops->get_strings)
+			ds->ops->get_strings(ds, dp->index, stringset,
+					     data);
+		else
+			net_selftest_get_strings(data);
 	}
 
 }
@@ -1123,7 +1127,10 @@  static int dsa_user_get_sset_count(struct net_device *dev, int sset)
 
 		return count + 4;
 	} else if (sset ==  ETH_SS_TEST) {
-		return net_selftest_get_count();
+		if (ds->ops->self_test && ds->ops->get_sset_count)
+			return ds->ops->get_sset_count(ds, dp->index, sset);
+		else
+			return net_selftest_get_count();
 	}
 
 	return -EOPNOTSUPP;