etherdevice.hh revision 13767:85278a98657c
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/net/etherobject.hh"
41#include "dev/pci/device.hh"
42#include "params/EtherDevBase.hh"
43#include "params/EtherDevice.hh"
44#include "sim/sim_object.hh"
45
46class EtherInt;
47
48class EtherDevice : public PciDevice, public EtherObject
49{
50  public:
51    typedef EtherDeviceParams Params;
52    EtherDevice(const Params *params)
53        : PciDevice(params)
54    {}
55
56    const Params *
57    params() const
58    {
59        return dynamic_cast<const Params *>(_params);
60    }
61
62  public:
63    void regStats();
64
65  protected:
66    Stats::Scalar txBytes;
67    Stats::Scalar rxBytes;
68    Stats::Scalar txPackets;
69    Stats::Scalar rxPackets;
70    Stats::Scalar txIpChecksums;
71    Stats::Scalar rxIpChecksums;
72    Stats::Scalar txTcpChecksums;
73    Stats::Scalar rxTcpChecksums;
74    Stats::Scalar txUdpChecksums;
75    Stats::Scalar rxUdpChecksums;
76    Stats::Scalar descDmaReads;
77    Stats::Scalar descDmaWrites;
78    Stats::Scalar descDmaRdBytes;
79    Stats::Scalar descDmaWrBytes;
80    Stats::Formula totBandwidth;
81    Stats::Formula totPackets;
82    Stats::Formula totBytes;
83    Stats::Formula totPacketRate;
84    Stats::Formula txBandwidth;
85    Stats::Formula rxBandwidth;
86    Stats::Formula txPacketRate;
87    Stats::Formula rxPacketRate;
88    Stats::Scalar postedSwi;
89    Stats::Formula coalescedSwi;
90    Stats::Scalar totalSwi;
91    Stats::Scalar postedRxIdle;
92    Stats::Formula coalescedRxIdle;
93    Stats::Scalar totalRxIdle;
94    Stats::Scalar postedRxOk;
95    Stats::Formula coalescedRxOk;
96    Stats::Scalar totalRxOk;
97    Stats::Scalar postedRxDesc;
98    Stats::Formula coalescedRxDesc;
99    Stats::Scalar totalRxDesc;
100    Stats::Scalar postedTxOk;
101    Stats::Formula coalescedTxOk;
102    Stats::Scalar totalTxOk;
103    Stats::Scalar postedTxIdle;
104    Stats::Formula coalescedTxIdle;
105    Stats::Scalar totalTxIdle;
106    Stats::Scalar postedTxDesc;
107    Stats::Formula coalescedTxDesc;
108    Stats::Scalar totalTxDesc;
109    Stats::Scalar postedRxOrn;
110    Stats::Formula coalescedRxOrn;
111    Stats::Scalar totalRxOrn;
112    Stats::Formula coalescedTotal;
113    Stats::Scalar postedInterrupts;
114    Stats::Scalar droppedPackets;
115};
116
117/**
118 * Dummy class to keep the Python class hierarchy in sync with the C++
119 * object hierarchy.
120 *
121 * The Python object hierarchy includes the EtherDevBase class which
122 * is used by some ethernet devices as a way to share common
123 * configuration information in the generated param structs. Since the
124 * Python hierarchy is used to generate a Python interfaces for all C++
125 * SimObjects, we need to reflect this in the C++ object hierarchy.
126 */
127class EtherDevBase : public EtherDevice
128{
129  public:
130    EtherDevBase(const EtherDevBaseParams *params)
131        : EtherDevice(params)
132    {}
133
134    const EtherDevBaseParams *
135    params() const
136    {
137        return dynamic_cast<const EtherDevBaseParams *>(_params);
138    }
139
140};
141
142#endif // __DEV_NET_ETHERDEVICE_HH__
143
144