etherdevice.hh (11263:8dcc6b40f164) etherdevice.hh (11990:5fad911cc326)
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
47/**
48 * The base EtherObject class, allows for an accesor function to a
49 * simobj that returns the Port.
50 */
51class EtherDevice : public PciDevice
52{
53 public:
54 typedef EtherDeviceParams Params;
55 EtherDevice(const Params *params)
56 : PciDevice(params)
57 {}
58
59 const Params *
60 params() const
61 {
62 return dynamic_cast<const Params *>(_params);
63 }
64
65 public:
66 /** Additional function to return the Port of a memory object. */
67 virtual EtherInt *getEthPort(const std::string &if_name, int idx = -1) = 0;
68
69 public:
70 void regStats();
71
72 protected:
73 Stats::Scalar txBytes;
74 Stats::Scalar rxBytes;
75 Stats::Scalar txPackets;
76 Stats::Scalar rxPackets;
77 Stats::Scalar txIpChecksums;
78 Stats::Scalar rxIpChecksums;
79 Stats::Scalar txTcpChecksums;
80 Stats::Scalar rxTcpChecksums;
81 Stats::Scalar txUdpChecksums;
82 Stats::Scalar rxUdpChecksums;
83 Stats::Scalar descDmaReads;
84 Stats::Scalar descDmaWrites;
85 Stats::Scalar descDmaRdBytes;
86 Stats::Scalar descDmaWrBytes;
87 Stats::Formula totBandwidth;
88 Stats::Formula totPackets;
89 Stats::Formula totBytes;
90 Stats::Formula totPacketRate;
91 Stats::Formula txBandwidth;
92 Stats::Formula rxBandwidth;
93 Stats::Formula txPacketRate;
94 Stats::Formula rxPacketRate;
95 Stats::Scalar postedSwi;
96 Stats::Formula coalescedSwi;
97 Stats::Scalar totalSwi;
98 Stats::Scalar postedRxIdle;
99 Stats::Formula coalescedRxIdle;
100 Stats::Scalar totalRxIdle;
101 Stats::Scalar postedRxOk;
102 Stats::Formula coalescedRxOk;
103 Stats::Scalar totalRxOk;
104 Stats::Scalar postedRxDesc;
105 Stats::Formula coalescedRxDesc;
106 Stats::Scalar totalRxDesc;
107 Stats::Scalar postedTxOk;
108 Stats::Formula coalescedTxOk;
109 Stats::Scalar totalTxOk;
110 Stats::Scalar postedTxIdle;
111 Stats::Formula coalescedTxIdle;
112 Stats::Scalar totalTxIdle;
113 Stats::Scalar postedTxDesc;
114 Stats::Formula coalescedTxDesc;
115 Stats::Scalar totalTxDesc;
116 Stats::Scalar postedRxOrn;
117 Stats::Formula coalescedRxOrn;
118 Stats::Scalar totalRxOrn;
119 Stats::Formula coalescedTotal;
120 Stats::Scalar postedInterrupts;
121 Stats::Scalar droppedPackets;
122};
123
124/**
125 * Dummy class to keep the Python class hierarchy in sync with the C++
126 * object hierarchy.
127 *
128 * The Python object hierarchy includes the EtherDevBase class which
129 * is used by some ethernet devices as a way to share common
130 * configuration information in the generated param structs. Since the
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
47/**
48 * The base EtherObject class, allows for an accesor function to a
49 * simobj that returns the Port.
50 */
51class EtherDevice : public PciDevice
52{
53 public:
54 typedef EtherDeviceParams Params;
55 EtherDevice(const Params *params)
56 : PciDevice(params)
57 {}
58
59 const Params *
60 params() const
61 {
62 return dynamic_cast<const Params *>(_params);
63 }
64
65 public:
66 /** Additional function to return the Port of a memory object. */
67 virtual EtherInt *getEthPort(const std::string &if_name, int idx = -1) = 0;
68
69 public:
70 void regStats();
71
72 protected:
73 Stats::Scalar txBytes;
74 Stats::Scalar rxBytes;
75 Stats::Scalar txPackets;
76 Stats::Scalar rxPackets;
77 Stats::Scalar txIpChecksums;
78 Stats::Scalar rxIpChecksums;
79 Stats::Scalar txTcpChecksums;
80 Stats::Scalar rxTcpChecksums;
81 Stats::Scalar txUdpChecksums;
82 Stats::Scalar rxUdpChecksums;
83 Stats::Scalar descDmaReads;
84 Stats::Scalar descDmaWrites;
85 Stats::Scalar descDmaRdBytes;
86 Stats::Scalar descDmaWrBytes;
87 Stats::Formula totBandwidth;
88 Stats::Formula totPackets;
89 Stats::Formula totBytes;
90 Stats::Formula totPacketRate;
91 Stats::Formula txBandwidth;
92 Stats::Formula rxBandwidth;
93 Stats::Formula txPacketRate;
94 Stats::Formula rxPacketRate;
95 Stats::Scalar postedSwi;
96 Stats::Formula coalescedSwi;
97 Stats::Scalar totalSwi;
98 Stats::Scalar postedRxIdle;
99 Stats::Formula coalescedRxIdle;
100 Stats::Scalar totalRxIdle;
101 Stats::Scalar postedRxOk;
102 Stats::Formula coalescedRxOk;
103 Stats::Scalar totalRxOk;
104 Stats::Scalar postedRxDesc;
105 Stats::Formula coalescedRxDesc;
106 Stats::Scalar totalRxDesc;
107 Stats::Scalar postedTxOk;
108 Stats::Formula coalescedTxOk;
109 Stats::Scalar totalTxOk;
110 Stats::Scalar postedTxIdle;
111 Stats::Formula coalescedTxIdle;
112 Stats::Scalar totalTxIdle;
113 Stats::Scalar postedTxDesc;
114 Stats::Formula coalescedTxDesc;
115 Stats::Scalar totalTxDesc;
116 Stats::Scalar postedRxOrn;
117 Stats::Formula coalescedRxOrn;
118 Stats::Scalar totalRxOrn;
119 Stats::Formula coalescedTotal;
120 Stats::Scalar postedInterrupts;
121 Stats::Scalar droppedPackets;
122};
123
124/**
125 * Dummy class to keep the Python class hierarchy in sync with the C++
126 * object hierarchy.
127 *
128 * The Python object hierarchy includes the EtherDevBase class which
129 * is used by some ethernet devices as a way to share common
130 * configuration information in the generated param structs. Since the
131 * Python hierarchy is used to generate a SWIG interface for all C++
132 * SimObjects, we need to reflect this in the C++ object hierarchy. If
133 * we don't, SWIG might end up doing 'bad things' when it down casts
134 * ethernet objects to their base class(es).
131 * Python hierarchy is used to generate a Python interfaces for all C++
132 * SimObjects, we need to reflect this in the C++ object hierarchy.
135 */
136class EtherDevBase : public EtherDevice
137{
138 public:
139 EtherDevBase(const EtherDevBaseParams *params)
140 : EtherDevice(params)
141 {}
142
143 const EtherDevBaseParams *
144 params() const
145 {
146 return dynamic_cast<const EtherDevBaseParams *>(_params);
147 }
148
149};
150
151#endif // __DEV_NET_ETHERDEVICE_HH__
152
133 */
134class EtherDevBase : public EtherDevice
135{
136 public:
137 EtherDevBase(const EtherDevBaseParams *params)
138 : EtherDevice(params)
139 {}
140
141 const EtherDevBaseParams *
142 params() const
143 {
144 return dynamic_cast<const EtherDevBaseParams *>(_params);
145 }
146
147};
148
149#endif // __DEV_NET_ETHERDEVICE_HH__
150