etherdevice.hh revision 13784
1/*
2 * Copyright (c) 2007 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ali Saidi
29 */
30
31/**
32 * @file
33 * Base Ethernet Device declaration.
34 */
35
36#ifndef __DEV_NET_ETHERDEVICE_HH__
37#define __DEV_NET_ETHERDEVICE_HH__
38
39#include "base/statistics.hh"
40#include "dev/pci/device.hh"
41#include "params/EtherDevBase.hh"
42#include "params/EtherDevice.hh"
43#include "sim/sim_object.hh"
44
45class EtherInt;
46
47class EtherDevice : public PciDevice
48{
49  public:
50    typedef EtherDeviceParams Params;
51    EtherDevice(const Params *params)
52        : PciDevice(params)
53    {}
54
55    const Params *
56    params() const
57    {
58        return dynamic_cast<const Params *>(_params);
59    }
60
61  public:
62    void regStats();
63
64  protected:
65    Stats::Scalar txBytes;
66    Stats::Scalar rxBytes;
67    Stats::Scalar txPackets;
68    Stats::Scalar rxPackets;
69    Stats::Scalar txIpChecksums;
70    Stats::Scalar rxIpChecksums;
71    Stats::Scalar txTcpChecksums;
72    Stats::Scalar rxTcpChecksums;
73    Stats::Scalar txUdpChecksums;
74    Stats::Scalar rxUdpChecksums;
75    Stats::Scalar descDmaReads;
76    Stats::Scalar descDmaWrites;
77    Stats::Scalar descDmaRdBytes;
78    Stats::Scalar descDmaWrBytes;
79    Stats::Formula totBandwidth;
80    Stats::Formula totPackets;
81    Stats::Formula totBytes;
82    Stats::Formula totPacketRate;
83    Stats::Formula txBandwidth;
84    Stats::Formula rxBandwidth;
85    Stats::Formula txPacketRate;
86    Stats::Formula rxPacketRate;
87    Stats::Scalar postedSwi;
88    Stats::Formula coalescedSwi;
89    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