mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Taking a stats snapshot differs between same families. Abstract this into an ops member. At the same time, move the code into global1.[ch], since the registers are in the global1 range. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
/*
|
|
* Marvell 88E6xxx Switch Global (1) Registers support
|
|
*
|
|
* Copyright (c) 2008 Marvell Semiconductor
|
|
*
|
|
* Copyright (c) 2016 Vivien Didelot <vivien.didelot@savoirfairelinux.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
#include "mv88e6xxx.h"
|
|
#include "global1.h"
|
|
|
|
int mv88e6xxx_g1_read(struct mv88e6xxx_chip *chip, int reg, u16 *val)
|
|
{
|
|
int addr = chip->info->global1_addr;
|
|
|
|
return mv88e6xxx_read(chip, addr, reg, val);
|
|
}
|
|
|
|
int mv88e6xxx_g1_write(struct mv88e6xxx_chip *chip, int reg, u16 val)
|
|
{
|
|
int addr = chip->info->global1_addr;
|
|
|
|
return mv88e6xxx_write(chip, addr, reg, val);
|
|
}
|
|
|
|
int mv88e6xxx_g1_wait(struct mv88e6xxx_chip *chip, int reg, u16 mask)
|
|
{
|
|
return mv88e6xxx_wait(chip, chip->info->global1_addr, reg, mask);
|
|
}
|
|
|
|
static int mv88e6xxx_g1_stats_wait(struct mv88e6xxx_chip *chip)
|
|
{
|
|
return mv88e6xxx_g1_wait(chip, GLOBAL_STATS_OP, GLOBAL_STATS_OP_BUSY);
|
|
}
|
|
|
|
int mv88e6xxx_g1_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
|
|
{
|
|
int err;
|
|
|
|
/* Snapshot the hardware statistics counters for this port. */
|
|
err = mv88e6xxx_g1_write(chip, GLOBAL_STATS_OP,
|
|
GLOBAL_STATS_OP_CAPTURE_PORT |
|
|
GLOBAL_STATS_OP_HIST_RX_TX | port);
|
|
if (err)
|
|
return err;
|
|
|
|
/* Wait for the snapshotting to complete. */
|
|
return mv88e6xxx_g1_stats_wait(chip);
|
|
}
|
|
|
|
int mv88e6320_g1_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
|
|
{
|
|
port = (port + 1) << 5;
|
|
|
|
return mv88e6xxx_g1_stats_snapshot(chip, port);
|
|
}
|