Skip to content

Commit 436fe17

Browse files
lunndavem330
authored andcommitted
net: dsa: mv88e6xxx: Allow the SERDES interfaces to have statistics
When gettting the number of statistics, the strings and the actual statistics, call the SERDES ops if implemented. This means the stats code needs to return the number of strings/stats they have placed into the data, so that the SERDES strings/stats can follow on. Signed-off-by: Andrew Lunn <[email protected]> Tested-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c6c8cd5 commit 436fe17

File tree

2 files changed

+62
-27
lines changed

2 files changed

+62
-27
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
689689
return value;
690690
}
691691

692-
static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
693-
uint8_t *data, int types)
692+
static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
693+
uint8_t *data, int types)
694694
{
695695
struct mv88e6xxx_hw_stat *stat;
696696
int i, j;
@@ -703,31 +703,39 @@ static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
703703
j++;
704704
}
705705
}
706+
707+
return j;
706708
}
707709

708-
static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
709-
uint8_t *data)
710+
static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
711+
uint8_t *data)
710712
{
711-
mv88e6xxx_stats_get_strings(chip, data,
712-
STATS_TYPE_BANK0 | STATS_TYPE_PORT);
713+
return mv88e6xxx_stats_get_strings(chip, data,
714+
STATS_TYPE_BANK0 | STATS_TYPE_PORT);
713715
}
714716

715-
static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
716-
uint8_t *data)
717+
static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
718+
uint8_t *data)
717719
{
718-
mv88e6xxx_stats_get_strings(chip, data,
719-
STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
720+
return mv88e6xxx_stats_get_strings(chip, data,
721+
STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
720722
}
721723

722724
static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
723725
uint8_t *data)
724726
{
725727
struct mv88e6xxx_chip *chip = ds->priv;
728+
int count = 0;
726729

727730
mutex_lock(&chip->reg_lock);
728731

729732
if (chip->info->ops->stats_get_strings)
730-
chip->info->ops->stats_get_strings(chip, data);
733+
count = chip->info->ops->stats_get_strings(chip, data);
734+
735+
if (chip->info->ops->serdes_get_strings) {
736+
data += count * ETH_GSTRING_LEN;
737+
chip->info->ops->serdes_get_strings(chip, port, data);
738+
}
731739

732740
mutex_unlock(&chip->reg_lock);
733741
}
@@ -761,19 +769,31 @@ static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
761769
static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port)
762770
{
763771
struct mv88e6xxx_chip *chip = ds->priv;
764-
int ret = 0;
772+
int serdes_count = 0;
773+
int count = 0;
765774

766775
mutex_lock(&chip->reg_lock);
767776
if (chip->info->ops->stats_get_sset_count)
768-
ret = chip->info->ops->stats_get_sset_count(chip);
777+
count = chip->info->ops->stats_get_sset_count(chip);
778+
if (count < 0)
779+
goto out;
780+
781+
if (chip->info->ops->serdes_get_sset_count)
782+
serdes_count = chip->info->ops->serdes_get_sset_count(chip,
783+
port);
784+
if (serdes_count < 0)
785+
count = serdes_count;
786+
else
787+
count += serdes_count;
788+
out:
769789
mutex_unlock(&chip->reg_lock);
770790

771-
return ret;
791+
return count;
772792
}
773793

774-
static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
775-
uint64_t *data, int types,
776-
u16 bank1_select, u16 histogram)
794+
static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
795+
uint64_t *data, int types,
796+
u16 bank1_select, u16 histogram)
777797
{
778798
struct mv88e6xxx_hw_stat *stat;
779799
int i, j;
@@ -790,27 +810,28 @@ static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
790810
j++;
791811
}
792812
}
813+
return j;
793814
}
794815

795-
static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
796-
uint64_t *data)
816+
static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
817+
uint64_t *data)
797818
{
798819
return mv88e6xxx_stats_get_stats(chip, port, data,
799820
STATS_TYPE_BANK0 | STATS_TYPE_PORT,
800821
0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
801822
}
802823

803-
static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
804-
uint64_t *data)
824+
static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
825+
uint64_t *data)
805826
{
806827
return mv88e6xxx_stats_get_stats(chip, port, data,
807828
STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
808829
MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
809830
MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
810831
}
811832

812-
static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
813-
uint64_t *data)
833+
static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
834+
uint64_t *data)
814835
{
815836
return mv88e6xxx_stats_get_stats(chip, port, data,
816837
STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
@@ -821,8 +842,15 @@ static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
821842
static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
822843
uint64_t *data)
823844
{
845+
int count = 0;
846+
824847
if (chip->info->ops->stats_get_stats)
825-
chip->info->ops->stats_get_stats(chip, port, data);
848+
count = chip->info->ops->stats_get_stats(chip, port, data);
849+
850+
if (chip->info->ops->serdes_get_stats) {
851+
data += count;
852+
chip->info->ops->serdes_get_stats(chip, port, data);
853+
}
826854
}
827855

828856
static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,

drivers/net/dsa/mv88e6xxx/chip.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ struct mv88e6xxx_ops {
386386

387387
/* Return the number of strings describing statistics */
388388
int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
389-
void (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
390-
void (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
391-
uint64_t *data);
389+
int (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
390+
int (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
391+
uint64_t *data);
392392
int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
393393
int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
394394
const struct mv88e6xxx_irq_ops *watchdog_ops;
@@ -398,6 +398,13 @@ struct mv88e6xxx_ops {
398398
/* Power on/off a SERDES interface */
399399
int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on);
400400

401+
/* Statistics from the SERDES interface */
402+
int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port);
403+
void (*serdes_get_strings)(struct mv88e6xxx_chip *chip, int port,
404+
uint8_t *data);
405+
void (*serdes_get_stats)(struct mv88e6xxx_chip *chip, int port,
406+
uint64_t *data);
407+
401408
/* VLAN Translation Unit operations */
402409
int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
403410
struct mv88e6xxx_vtu_entry *entry);

0 commit comments

Comments
 (0)