etherdevice.hh revision 13784
113514Sgabeblack@google.com/*
213514Sgabeblack@google.com * Copyright (c) 2007 The Regents of The University of Michigan
313514Sgabeblack@google.com * All rights reserved.
413514Sgabeblack@google.com *
513514Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
613514Sgabeblack@google.com * modification, are permitted provided that the following conditions are
713514Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
813514Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
913514Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1013514Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1113514Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1213514Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1313514Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1413514Sgabeblack@google.com * this software without specific prior written permission.
1513514Sgabeblack@google.com *
1613514Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713514Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813514Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913514Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013514Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113514Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213514Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313586Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413586Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513586Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613586Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713514Sgabeblack@google.com *
2813514Sgabeblack@google.com * Authors: Ali Saidi
2913514Sgabeblack@google.com */
3013514Sgabeblack@google.com
3113514Sgabeblack@google.com/**
3213514Sgabeblack@google.com * @file
3313514Sgabeblack@google.com * Base Ethernet Device declaration.
3413514Sgabeblack@google.com */
3513514Sgabeblack@google.com
3613514Sgabeblack@google.com#ifndef __DEV_NET_ETHERDEVICE_HH__
3713514Sgabeblack@google.com#define __DEV_NET_ETHERDEVICE_HH__
3813514Sgabeblack@google.com
3913514Sgabeblack@google.com#include "base/statistics.hh"
4013514Sgabeblack@google.com#include "dev/pci/device.hh"
4113514Sgabeblack@google.com#include "params/EtherDevBase.hh"
4213514Sgabeblack@google.com#include "params/EtherDevice.hh"
4313514Sgabeblack@google.com#include "sim/sim_object.hh"
4413514Sgabeblack@google.com
4513514Sgabeblack@google.comclass EtherInt;
4613514Sgabeblack@google.com
4713514Sgabeblack@google.comclass EtherDevice : public PciDevice
4813514Sgabeblack@google.com{
4913514Sgabeblack@google.com  public:
5013514Sgabeblack@google.com    typedef EtherDeviceParams Params;
5113514Sgabeblack@google.com    EtherDevice(const Params *params)
5213514Sgabeblack@google.com        : PciDevice(params)
5313514Sgabeblack@google.com    {}
5413514Sgabeblack@google.com
5513514Sgabeblack@google.com    const Params *
5613514Sgabeblack@google.com    params() const
5713514Sgabeblack@google.com    {
5813514Sgabeblack@google.com        return dynamic_cast<const Params *>(_params);
5913514Sgabeblack@google.com    }
6013514Sgabeblack@google.com
6113514Sgabeblack@google.com  public:
6213514Sgabeblack@google.com    void regStats();
6313514Sgabeblack@google.com
6413514Sgabeblack@google.com  protected:
6513514Sgabeblack@google.com    Stats::Scalar txBytes;
6613514Sgabeblack@google.com    Stats::Scalar rxBytes;
6713514Sgabeblack@google.com    Stats::Scalar txPackets;
6813514Sgabeblack@google.com    Stats::Scalar rxPackets;
6913514Sgabeblack@google.com    Stats::Scalar txIpChecksums;
7013514Sgabeblack@google.com    Stats::Scalar rxIpChecksums;
7113514Sgabeblack@google.com    Stats::Scalar txTcpChecksums;
7213514Sgabeblack@google.com    Stats::Scalar rxTcpChecksums;
7313514Sgabeblack@google.com    Stats::Scalar txUdpChecksums;
7413514Sgabeblack@google.com    Stats::Scalar rxUdpChecksums;
7513514Sgabeblack@google.com    Stats::Scalar descDmaReads;
7613514Sgabeblack@google.com    Stats::Scalar descDmaWrites;
7713514Sgabeblack@google.com    Stats::Scalar descDmaRdBytes;
7813514Sgabeblack@google.com    Stats::Scalar descDmaWrBytes;
7913514Sgabeblack@google.com    Stats::Formula totBandwidth;
8013514Sgabeblack@google.com    Stats::Formula totPackets;
8113514Sgabeblack@google.com    Stats::Formula totBytes;
8213514Sgabeblack@google.com    Stats::Formula totPacketRate;
8313514Sgabeblack@google.com    Stats::Formula txBandwidth;
8413514Sgabeblack@google.com    Stats::Formula rxBandwidth;
8513514Sgabeblack@google.com    Stats::Formula txPacketRate;
8613514Sgabeblack@google.com    Stats::Formula rxPacketRate;
8713514Sgabeblack@google.com    Stats::Scalar postedSwi;
8813514Sgabeblack@google.com    Stats::Formula coalescedSwi;
8913514Sgabeblack@google.com    Stats::Scalar totalSwi;
90    Stats::Scalar postedRxIdle;
91    Stats::Formula coalescedRxIdle;
92    Stats::Scalar totalRxIdle;
93    Stats::Scalar postedRxOk;
94    Stats::Formula coalescedRxOk;
95    Stats::Scalar totalRxOk;
96    Stats::Scalar postedRxDesc;
97    Stats::Formula coalescedRxDesc;
98    Stats::Scalar totalRxDesc;
99    Stats::Scalar postedTxOk;
100    Stats::Formula coalescedTxOk;
101    Stats::Scalar totalTxOk;
102    Stats::Scalar postedTxIdle;
103    Stats::Formula coalescedTxIdle;
104    Stats::Scalar totalTxIdle;
105    Stats::Scalar postedTxDesc;
106    Stats::Formula coalescedTxDesc;
107    Stats::Scalar totalTxDesc;
108    Stats::Scalar postedRxOrn;
109    Stats::Formula coalescedRxOrn;
110    Stats::Scalar totalRxOrn;
111    Stats::Formula coalescedTotal;
112    Stats::Scalar postedInterrupts;
113    Stats::Scalar droppedPackets;
114};
115
116/**
117 * Dummy class to keep the Python class hierarchy in sync with the C++
118 * object hierarchy.
119 *
120 * The Python object hierarchy includes the EtherDevBase class which
121 * is used by some ethernet devices as a way to share common
122 * configuration information in the generated param structs. Since the
123 * Python hierarchy is used to generate a Python interfaces for all C++
124 * SimObjects, we need to reflect this in the C++ object hierarchy.
125 */
126class EtherDevBase : public EtherDevice
127{
128  public:
129    EtherDevBase(const EtherDevBaseParams *params)
130        : EtherDevice(params)
131    {}
132
133    const EtherDevBaseParams *
134    params() const
135    {
136        return dynamic_cast<const EtherDevBaseParams *>(_params);
137    }
138
139};
140
141#endif // __DEV_NET_ETHERDEVICE_HH__
142
143