etherdevice.hh revision 11260
112866Sgabeblack@google.com/*
212866Sgabeblack@google.com * Copyright (c) 2007 The Regents of The University of Michigan
312866Sgabeblack@google.com * All rights reserved.
412866Sgabeblack@google.com *
512866Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612866Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712866Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812866Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912866Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012866Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112866Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212866Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312866Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412866Sgabeblack@google.com * this software without specific prior written permission.
1512866Sgabeblack@google.com *
1612866Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712866Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812866Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912866Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012866Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112866Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212866Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312866Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412866Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512866Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612866Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712866Sgabeblack@google.com *
2812866Sgabeblack@google.com * Authors: Ali Saidi
2912866Sgabeblack@google.com */
3012866Sgabeblack@google.com
3112866Sgabeblack@google.com/**
3212866Sgabeblack@google.com * @file
3312866Sgabeblack@google.com * Base Ethernet Device declaration.
3412866Sgabeblack@google.com */
3512866Sgabeblack@google.com
3612866Sgabeblack@google.com#ifndef __DEV_ETHERDEVICE_HH__
3712866Sgabeblack@google.com#define __DEV_ETHERDEVICE_HH__
3812866Sgabeblack@google.com
3912866Sgabeblack@google.com#include "base/statistics.hh"
4012866Sgabeblack@google.com#include "dev/pci/device.hh"
4112866Sgabeblack@google.com#include "params/EtherDevice.hh"
4212866Sgabeblack@google.com#include "params/EtherDevBase.hh"
4312866Sgabeblack@google.com#include "sim/sim_object.hh"
4412866Sgabeblack@google.com
4512866Sgabeblack@google.comclass EtherInt;
4612866Sgabeblack@google.com
4713458Sgabeblack@google.com/**
4812866Sgabeblack@google.com * The base EtherObject class, allows for an accesor function to a
4912866Sgabeblack@google.com * simobj that returns the Port.
5012866Sgabeblack@google.com */
5112866Sgabeblack@google.comclass EtherDevice : public PciDevice
5212866Sgabeblack@google.com{
5312866Sgabeblack@google.com  public:
5412866Sgabeblack@google.com    typedef EtherDeviceParams Params;
5512866Sgabeblack@google.com    EtherDevice(const Params *params)
5612866Sgabeblack@google.com        : PciDevice(params)
5712866Sgabeblack@google.com    {}
5812866Sgabeblack@google.com
5912866Sgabeblack@google.com    const Params *
6012866Sgabeblack@google.com    params() const
6112866Sgabeblack@google.com    {
6213458Sgabeblack@google.com        return dynamic_cast<const Params *>(_params);
6313458Sgabeblack@google.com    }
6412866Sgabeblack@google.com
6512866Sgabeblack@google.com  public:
6612922Sgabeblack@google.com    /** Additional function to return the Port of a memory object. */
6712869Sgabeblack@google.com    virtual EtherInt *getEthPort(const std::string &if_name, int idx = -1) = 0;
6812866Sgabeblack@google.com
6912869Sgabeblack@google.com  public:
7013458Sgabeblack@google.com    void regStats();
7113458Sgabeblack@google.com
7212866Sgabeblack@google.com  protected:
7312866Sgabeblack@google.com    Stats::Scalar txBytes;
7412866Sgabeblack@google.com    Stats::Scalar rxBytes;
7512866Sgabeblack@google.com    Stats::Scalar txPackets;
7612866Sgabeblack@google.com    Stats::Scalar rxPackets;
7712866Sgabeblack@google.com    Stats::Scalar txIpChecksums;
7812866Sgabeblack@google.com    Stats::Scalar rxIpChecksums;
7912866Sgabeblack@google.com    Stats::Scalar txTcpChecksums;
8012866Sgabeblack@google.com    Stats::Scalar rxTcpChecksums;
8112866Sgabeblack@google.com    Stats::Scalar txUdpChecksums;
8212922Sgabeblack@google.com    Stats::Scalar rxUdpChecksums;
8312866Sgabeblack@google.com    Stats::Scalar descDmaReads;
8413098Sgabeblack@google.com    Stats::Scalar descDmaWrites;
8513098Sgabeblack@google.com    Stats::Scalar descDmaRdBytes;
8613098Sgabeblack@google.com    Stats::Scalar descDmaWrBytes;
8713098Sgabeblack@google.com    Stats::Formula totBandwidth;
8812866Sgabeblack@google.com    Stats::Formula totPackets;
8912866Sgabeblack@google.com    Stats::Formula totBytes;
9012869Sgabeblack@google.com    Stats::Formula totPacketRate;
9113098Sgabeblack@google.com    Stats::Formula txBandwidth;
9212869Sgabeblack@google.com    Stats::Formula rxBandwidth;
9312869Sgabeblack@google.com    Stats::Formula txPacketRate;
9413656Sgabeblack@google.com    Stats::Formula rxPacketRate;
9512869Sgabeblack@google.com    Stats::Scalar postedSwi;
9613098Sgabeblack@google.com    Stats::Formula coalescedSwi;
9713098Sgabeblack@google.com    Stats::Scalar totalSwi;
9813098Sgabeblack@google.com    Stats::Scalar postedRxIdle;
9913098Sgabeblack@google.com    Stats::Formula coalescedRxIdle;
10013098Sgabeblack@google.com    Stats::Scalar totalRxIdle;
10113655Sgabeblack@google.com    Stats::Scalar postedRxOk;
10213655Sgabeblack@google.com    Stats::Formula coalescedRxOk;
10313458Sgabeblack@google.com    Stats::Scalar totalRxOk;
10413458Sgabeblack@google.com    Stats::Scalar postedRxDesc;
10513458Sgabeblack@google.com    Stats::Formula coalescedRxDesc;
10613458Sgabeblack@google.com    Stats::Scalar totalRxDesc;
10713458Sgabeblack@google.com    Stats::Scalar postedTxOk;
10812869Sgabeblack@google.com    Stats::Formula coalescedTxOk;
10912866Sgabeblack@google.com    Stats::Scalar totalTxOk;
11012866Sgabeblack@google.com    Stats::Scalar postedTxIdle;
11112866Sgabeblack@google.com    Stats::Formula coalescedTxIdle;
11212866Sgabeblack@google.com    Stats::Scalar totalTxIdle;
11312866Sgabeblack@google.com    Stats::Scalar postedTxDesc;
11412866Sgabeblack@google.com    Stats::Formula coalescedTxDesc;
11512866Sgabeblack@google.com    Stats::Scalar totalTxDesc;
11612866Sgabeblack@google.com    Stats::Scalar postedRxOrn;
11712866Sgabeblack@google.com    Stats::Formula coalescedRxOrn;
11812866Sgabeblack@google.com    Stats::Scalar totalRxOrn;
11912866Sgabeblack@google.com    Stats::Formula coalescedTotal;
12012866Sgabeblack@google.com    Stats::Scalar postedInterrupts;
12112866Sgabeblack@google.com    Stats::Scalar droppedPackets;
12212866Sgabeblack@google.com};
12312866Sgabeblack@google.com
12412866Sgabeblack@google.com/**
12512866Sgabeblack@google.com * Dummy class to keep the Python class hierarchy in sync with the C++
12612866Sgabeblack@google.com * object hierarchy.
12712866Sgabeblack@google.com *
12812866Sgabeblack@google.com * The Python object hierarchy includes the EtherDevBase class which
12912866Sgabeblack@google.com * is used by some ethernet devices as a way to share common
13013458Sgabeblack@google.com * configuration information in the generated param structs. Since the
13113458Sgabeblack@google.com * Python hierarchy is used to generate a SWIG interface for all C++
13213458Sgabeblack@google.com * SimObjects, we need to reflect this in the C++ object hierarchy. If
13313458Sgabeblack@google.com * we don't, SWIG might end up doing 'bad things' when it down casts
13413458Sgabeblack@google.com * ethernet objects to their base class(es).
13513458Sgabeblack@google.com */
13613458Sgabeblack@google.comclass EtherDevBase : public EtherDevice
13713458Sgabeblack@google.com{
13813458Sgabeblack@google.com  public:
13912866Sgabeblack@google.com    EtherDevBase(const EtherDevBaseParams *params)
14012866Sgabeblack@google.com        : EtherDevice(params)
14112866Sgabeblack@google.com    {}
14212866Sgabeblack@google.com
14312866Sgabeblack@google.com    const EtherDevBaseParams *
14412866Sgabeblack@google.com    params() const
14512866Sgabeblack@google.com    {
14612866Sgabeblack@google.com        return dynamic_cast<const EtherDevBaseParams *>(_params);
14712866Sgabeblack@google.com    }
14812866Sgabeblack@google.com
14912866Sgabeblack@google.com};
15012866Sgabeblack@google.com
15112866Sgabeblack@google.com#endif //__DEV_ETHERDEVICE_HH__
15212866Sgabeblack@google.com