Skip to content

Commit 5f6c2d4

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: add plumbing for changing and getting MAC merge layer state
The DSA core is in charge of the ethtool_ops of the net devices associated with switch ports, so in case a hardware driver supports the MAC merge layer, DSA must pass the callbacks through to the driver. Add support for precisely that. Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dd1c416 commit 5f6c2d4

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

include/net/dsa.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,17 @@ struct dsa_switch_ops {
937937
int (*get_ts_info)(struct dsa_switch *ds, int port,
938938
struct ethtool_ts_info *ts);
939939

940+
/*
941+
* ethtool MAC merge layer
942+
*/
943+
int (*get_mm)(struct dsa_switch *ds, int port,
944+
struct ethtool_mm_state *state);
945+
int (*set_mm)(struct dsa_switch *ds, int port,
946+
struct ethtool_mm_cfg *cfg,
947+
struct netlink_ext_ack *extack);
948+
void (*get_mm_stats)(struct dsa_switch *ds, int port,
949+
struct ethtool_mm_stats *stats);
950+
940951
/*
941952
* DCB ops
942953
*/

net/dsa/slave.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,40 @@ static void dsa_slave_net_selftest(struct net_device *ndev,
11171117
net_selftest(ndev, etest, buf);
11181118
}
11191119

1120+
static int dsa_slave_get_mm(struct net_device *dev,
1121+
struct ethtool_mm_state *state)
1122+
{
1123+
struct dsa_port *dp = dsa_slave_to_port(dev);
1124+
struct dsa_switch *ds = dp->ds;
1125+
1126+
if (!ds->ops->get_mm)
1127+
return -EOPNOTSUPP;
1128+
1129+
return ds->ops->get_mm(ds, dp->index, state);
1130+
}
1131+
1132+
static int dsa_slave_set_mm(struct net_device *dev, struct ethtool_mm_cfg *cfg,
1133+
struct netlink_ext_ack *extack)
1134+
{
1135+
struct dsa_port *dp = dsa_slave_to_port(dev);
1136+
struct dsa_switch *ds = dp->ds;
1137+
1138+
if (!ds->ops->set_mm)
1139+
return -EOPNOTSUPP;
1140+
1141+
return ds->ops->set_mm(ds, dp->index, cfg, extack);
1142+
}
1143+
1144+
static void dsa_slave_get_mm_stats(struct net_device *dev,
1145+
struct ethtool_mm_stats *stats)
1146+
{
1147+
struct dsa_port *dp = dsa_slave_to_port(dev);
1148+
struct dsa_switch *ds = dp->ds;
1149+
1150+
if (ds->ops->get_mm_stats)
1151+
ds->ops->get_mm_stats(ds, dp->index, stats);
1152+
}
1153+
11201154
static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
11211155
{
11221156
struct dsa_port *dp = dsa_slave_to_port(dev);
@@ -2205,6 +2239,9 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
22052239
.set_rxnfc = dsa_slave_set_rxnfc,
22062240
.get_ts_info = dsa_slave_get_ts_info,
22072241
.self_test = dsa_slave_net_selftest,
2242+
.get_mm = dsa_slave_get_mm,
2243+
.set_mm = dsa_slave_set_mm,
2244+
.get_mm_stats = dsa_slave_get_mm_stats,
22082245
};
22092246

22102247
static const struct dcbnl_rtnl_ops __maybe_unused dsa_slave_dcbnl_ops = {

0 commit comments

Comments
 (0)