Skip to content

Commit 15f0a39

Browse files
Ben Hutchingsdavem330
authored andcommitted
net: Convert ethtool {get_stats, self_test}_count() ops to get_sset_count()
These string query operations were supposed to be replaced by the generic get_sset_count() starting in 2007. Convert the remaining implementations. Also remove calls to these operations to initialise drvinfo->n_stats. The ethtool core code already does that. Signed-off-by: Ben Hutchings <[email protected]> Acked-by: Eilon Greenstein <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1ddee09 commit 15f0a39

File tree

6 files changed

+70
-55
lines changed

6 files changed

+70
-55
lines changed

drivers/infiniband/hw/nes/nes_nic.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,11 +1080,14 @@ static int nes_netdev_set_rx_csum(struct net_device *netdev, u32 enable)
10801080

10811081

10821082
/**
1083-
* nes_netdev_get_stats_count
1083+
* nes_netdev_get_sset_count
10841084
*/
1085-
static int nes_netdev_get_stats_count(struct net_device *netdev)
1085+
static int nes_netdev_get_sset_count(struct net_device *netdev, int stringset)
10861086
{
1087-
return NES_ETHTOOL_STAT_COUNT;
1087+
if (stringset == ETH_SS_STATS)
1088+
return NES_ETHTOOL_STAT_COUNT;
1089+
else
1090+
return -EINVAL;
10881091
}
10891092

10901093

@@ -1264,7 +1267,6 @@ static void nes_netdev_get_drvinfo(struct net_device *netdev,
12641267
sprintf(drvinfo->fw_version, "%u.%u", nesadapter->firmware_version>>16,
12651268
nesadapter->firmware_version & 0x000000ff);
12661269
strcpy(drvinfo->version, DRV_VERSION);
1267-
drvinfo->n_stats = nes_netdev_get_stats_count(netdev);
12681270
drvinfo->testinfo_len = 0;
12691271
drvinfo->eedump_len = 0;
12701272
drvinfo->regdump_len = 0;
@@ -1516,7 +1518,7 @@ static const struct ethtool_ops nes_ethtool_ops = {
15161518
.get_rx_csum = nes_netdev_get_rx_csum,
15171519
.get_sg = ethtool_op_get_sg,
15181520
.get_strings = nes_netdev_get_strings,
1519-
.get_stats_count = nes_netdev_get_stats_count,
1521+
.get_sset_count = nes_netdev_get_sset_count,
15201522
.get_ethtool_stats = nes_netdev_get_ethtool_stats,
15211523
.get_drvinfo = nes_netdev_get_drvinfo,
15221524
.get_coalesce = nes_netdev_get_coalesce,

drivers/net/benet/be_ethtool.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,14 @@ be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
281281
}
282282
}
283283

284-
static int be_get_stats_count(struct net_device *netdev)
284+
static int be_get_sset_count(struct net_device *netdev, int stringset)
285285
{
286-
return ETHTOOL_STATS_NUM;
286+
switch (stringset) {
287+
case ETH_SS_STATS:
288+
return ETHTOOL_STATS_NUM;
289+
default:
290+
return -EINVAL;
291+
}
287292
}
288293

289294
static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
@@ -364,7 +369,7 @@ const struct ethtool_ops be_ethtool_ops = {
364369
.get_tso = ethtool_op_get_tso,
365370
.set_tso = ethtool_op_set_tso,
366371
.get_strings = be_get_stat_strings,
367-
.get_stats_count = be_get_stats_count,
372+
.get_sset_count = be_get_sset_count,
368373
.get_ethtool_stats = be_get_ethtool_stats,
369374
.flash_device = be_do_flash,
370375
};

drivers/net/bnx2x_main.c

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9818,11 +9818,6 @@ static const struct {
98189818
{ "idle check (online)" }
98199819
};
98209820

9821-
static int bnx2x_self_test_count(struct net_device *dev)
9822-
{
9823-
return BNX2X_NUM_TESTS;
9824-
}
9825-
98269821
static int bnx2x_test_registers(struct bnx2x *bp)
98279822
{
98289823
int idx, i, rc = -ENODEV;
@@ -10436,6 +10431,36 @@ static const struct {
1043610431
#define IS_E1HMF_MODE_STAT(bp) \
1043710432
(IS_E1HMF(bp) && !(bp->msglevel & BNX2X_MSG_STATS))
1043810433

10434+
static int bnx2x_get_sset_count(struct net_device *dev, int stringset)
10435+
{
10436+
struct bnx2x *bp = netdev_priv(dev);
10437+
int i, num_stats;
10438+
10439+
switch(stringset) {
10440+
case ETH_SS_STATS:
10441+
if (is_multi(bp)) {
10442+
num_stats = BNX2X_NUM_Q_STATS * bp->num_rx_queues;
10443+
if (!IS_E1HMF_MODE_STAT(bp))
10444+
num_stats += BNX2X_NUM_STATS;
10445+
} else {
10446+
if (IS_E1HMF_MODE_STAT(bp)) {
10447+
num_stats = 0;
10448+
for (i = 0; i < BNX2X_NUM_STATS; i++)
10449+
if (IS_FUNC_STAT(i))
10450+
num_stats++;
10451+
} else
10452+
num_stats = BNX2X_NUM_STATS;
10453+
}
10454+
return num_stats;
10455+
10456+
case ETH_SS_TEST:
10457+
return BNX2X_NUM_TESTS;
10458+
10459+
default:
10460+
return -EINVAL;
10461+
}
10462+
}
10463+
1043910464
static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
1044010465
{
1044110466
struct bnx2x *bp = netdev_priv(dev);
@@ -10473,28 +10498,6 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
1047310498
}
1047410499
}
1047510500

10476-
static int bnx2x_get_stats_count(struct net_device *dev)
10477-
{
10478-
struct bnx2x *bp = netdev_priv(dev);
10479-
int i, num_stats;
10480-
10481-
if (is_multi(bp)) {
10482-
num_stats = BNX2X_NUM_Q_STATS * bp->num_rx_queues;
10483-
if (!IS_E1HMF_MODE_STAT(bp))
10484-
num_stats += BNX2X_NUM_STATS;
10485-
} else {
10486-
if (IS_E1HMF_MODE_STAT(bp)) {
10487-
num_stats = 0;
10488-
for (i = 0; i < BNX2X_NUM_STATS; i++)
10489-
if (IS_FUNC_STAT(i))
10490-
num_stats++;
10491-
} else
10492-
num_stats = BNX2X_NUM_STATS;
10493-
}
10494-
10495-
return num_stats;
10496-
}
10497-
1049810501
static void bnx2x_get_ethtool_stats(struct net_device *dev,
1049910502
struct ethtool_stats *stats, u64 *buf)
1050010503
{
@@ -10637,11 +10640,10 @@ static const struct ethtool_ops bnx2x_ethtool_ops = {
1063710640
.set_sg = ethtool_op_set_sg,
1063810641
.get_tso = ethtool_op_get_tso,
1063910642
.set_tso = bnx2x_set_tso,
10640-
.self_test_count = bnx2x_self_test_count,
1064110643
.self_test = bnx2x_self_test,
10644+
.get_sset_count = bnx2x_get_sset_count,
1064210645
.get_strings = bnx2x_get_strings,
1064310646
.phys_id = bnx2x_phys_id,
10644-
.get_stats_count = bnx2x_get_stats_count,
1064510647
.get_ethtool_stats = bnx2x_get_ethtool_stats,
1064610648
};
1064710649

drivers/net/ibm_newemac/core.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,9 +2145,12 @@ static int emac_ethtool_nway_reset(struct net_device *ndev)
21452145
return res;
21462146
}
21472147

2148-
static int emac_ethtool_get_stats_count(struct net_device *ndev)
2148+
static int emac_ethtool_get_sset_count(struct net_device *ndev, int stringset)
21492149
{
2150-
return EMAC_ETHTOOL_STATS_COUNT;
2150+
if (stringset == ETH_SS_STATS)
2151+
return EMAC_ETHTOOL_STATS_COUNT;
2152+
else
2153+
return -EINVAL;
21512154
}
21522155

21532156
static void emac_ethtool_get_strings(struct net_device *ndev, u32 stringset,
@@ -2178,7 +2181,6 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev,
21782181
info->fw_version[0] = '\0';
21792182
sprintf(info->bus_info, "PPC 4xx EMAC-%d %s",
21802183
dev->cell_index, dev->ofdev->node->full_name);
2181-
info->n_stats = emac_ethtool_get_stats_count(ndev);
21822184
info->regdump_len = emac_ethtool_get_regs_len(ndev);
21832185
}
21842186

@@ -2198,7 +2200,7 @@ static const struct ethtool_ops emac_ethtool_ops = {
21982200
.get_rx_csum = emac_ethtool_get_rx_csum,
21992201

22002202
.get_strings = emac_ethtool_get_strings,
2201-
.get_stats_count = emac_ethtool_get_stats_count,
2203+
.get_sset_count = emac_ethtool_get_sset_count,
22022204
.get_ethtool_stats = emac_ethtool_get_ethtool_stats,
22032205

22042206
.get_link = ethtool_op_get_link,

drivers/net/igbvf/ethtool.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,6 @@ static int igbvf_link_test(struct igbvf_adapter *adapter, u64 *data)
363363
return *data;
364364
}
365365

366-
static int igbvf_get_self_test_count(struct net_device *netdev)
367-
{
368-
return IGBVF_TEST_LEN;
369-
}
370-
371-
static int igbvf_get_stats_count(struct net_device *netdev)
372-
{
373-
return IGBVF_GLOBAL_STATS_LEN;
374-
}
375-
376366
static void igbvf_diag_test(struct net_device *netdev,
377367
struct ethtool_test *eth_test, u64 *data)
378368
{
@@ -480,6 +470,18 @@ static void igbvf_get_ethtool_stats(struct net_device *netdev,
480470

481471
}
482472

473+
static int igbvf_get_sset_count(struct net_device *dev, int stringset)
474+
{
475+
switch(stringset) {
476+
case ETH_SS_TEST:
477+
return IGBVF_TEST_LEN;
478+
case ETH_SS_STATS:
479+
return IGBVF_GLOBAL_STATS_LEN;
480+
default:
481+
return -EINVAL;
482+
}
483+
}
484+
483485
static void igbvf_get_strings(struct net_device *netdev, u32 stringset,
484486
u8 *data)
485487
{
@@ -528,11 +530,10 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
528530
.get_tso = ethtool_op_get_tso,
529531
.set_tso = igbvf_set_tso,
530532
.self_test = igbvf_diag_test,
533+
.get_sset_count = igbvf_get_sset_count,
531534
.get_strings = igbvf_get_strings,
532535
.phys_id = igbvf_phys_id,
533536
.get_ethtool_stats = igbvf_get_ethtool_stats,
534-
.self_test_count = igbvf_get_self_test_count,
535-
.get_stats_count = igbvf_get_stats_count,
536537
.get_coalesce = igbvf_get_coalesce,
537538
.set_coalesce = igbvf_set_coalesce,
538539
};

drivers/net/niu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7855,10 +7855,13 @@ static void niu_get_strings(struct net_device *dev, u32 stringset, u8 *data)
78557855
}
78567856
}
78577857

7858-
static int niu_get_stats_count(struct net_device *dev)
7858+
static int niu_get_sset_count(struct net_device *dev, int stringset)
78597859
{
78607860
struct niu *np = netdev_priv(dev);
78617861

7862+
if (stringset != ETH_SS_STATS)
7863+
return -EINVAL;
7864+
78627865
return ((np->flags & NIU_FLAGS_XMAC ?
78637866
NUM_XMAC_STAT_KEYS :
78647867
NUM_BMAC_STAT_KEYS) +
@@ -7978,7 +7981,7 @@ static const struct ethtool_ops niu_ethtool_ops = {
79787981
.get_settings = niu_get_settings,
79797982
.set_settings = niu_set_settings,
79807983
.get_strings = niu_get_strings,
7981-
.get_stats_count = niu_get_stats_count,
7984+
.get_sset_count = niu_get_sset_count,
79827985
.get_ethtool_stats = niu_get_ethtool_stats,
79837986
.phys_id = niu_phys_id,
79847987
.get_rxnfc = niu_get_nfc,

0 commit comments

Comments
 (0)