tport.cc (4490:f9d3db907eec) tport.cc (4492:75dabb0392ee)
1/*
2 * Copyright (c) 2006 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;

--- 22 unchanged lines hidden (view full) ---

31#include "mem/tport.hh"
32
33void
34SimpleTimingPort::checkFunctional(PacketPtr pkt)
35{
36 DeferredPacketIterator i = transmitList.begin();
37 DeferredPacketIterator end = transmitList.end();
38
1/*
2 * Copyright (c) 2006 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;

--- 22 unchanged lines hidden (view full) ---

31#include "mem/tport.hh"
32
33void
34SimpleTimingPort::checkFunctional(PacketPtr pkt)
35{
36 DeferredPacketIterator i = transmitList.begin();
37 DeferredPacketIterator end = transmitList.end();
38
39 while (i != end) {
39 for (; i != end; ++i) {
40 PacketPtr target = i->pkt;
41 // If the target contains data, and it overlaps the
42 // probed request, need to update data
43 if (target->intersect(pkt)) {
44 if (!fixPacket(pkt, target)) {
45 // fixPacket returns true for continue, false for done
46 return;
47 }
48 }
40 PacketPtr target = i->pkt;
41 // If the target contains data, and it overlaps the
42 // probed request, need to update data
43 if (target->intersect(pkt)) {
44 if (!fixPacket(pkt, target)) {
45 // fixPacket returns true for continue, false for done
46 return;
47 }
48 }
49
50 i++;
51 }
52}
53
54void
55SimpleTimingPort::recvFunctional(PacketPtr pkt)
56{
57 checkFunctional(pkt);
58

--- 10 unchanged lines hidden (view full) ---

69 // code to hanldle nacks here, but I'm pretty sure it didn't work
70 // correctly with the drain code, so that would need to be fixed
71 // if we ever added it back.
72 assert(pkt->result != Packet::Nacked);
73 Tick latency = recvAtomic(pkt);
74 // turn packet around to go back to requester if response expected
75 if (pkt->needsResponse()) {
76 pkt->makeTimingResponse();
49 }
50}
51
52void
53SimpleTimingPort::recvFunctional(PacketPtr pkt)
54{
55 checkFunctional(pkt);
56

--- 10 unchanged lines hidden (view full) ---

67 // code to hanldle nacks here, but I'm pretty sure it didn't work
68 // correctly with the drain code, so that would need to be fixed
69 // if we ever added it back.
70 assert(pkt->result != Packet::Nacked);
71 Tick latency = recvAtomic(pkt);
72 // turn packet around to go back to requester if response expected
73 if (pkt->needsResponse()) {
74 pkt->makeTimingResponse();
77 sendTiming(pkt, latency);
75 schedSendTiming(pkt, latency);
78 }
79 else if (pkt->cmd != MemCmd::UpgradeReq) {
80 delete pkt->req;
81 delete pkt;
82 }
83 return true;
84}
85
76 }
77 else if (pkt->cmd != MemCmd::UpgradeReq) {
78 delete pkt->req;
79 delete pkt;
80 }
81 return true;
82}
83
86void
87SimpleTimingPort::recvRetry()
88{
89 assert(!transmitList.empty());
90 if (Port::sendTiming(transmitList.front().pkt)) {
91 transmitList.pop_front();
92 DPRINTF(Bus, "No Longer waiting on retry\n");
93 if (!transmitList.empty()) {
94 Tick time = transmitList.front().tick;
95 sendEvent->schedule(time <= curTick ? curTick+1 : time);
96 }
97 }
98
84
99 if (transmitList.empty() && drainEvent) {
100 drainEvent->process();
101 drainEvent = NULL;
102 }
103}
104
105void
85void
106SimpleTimingPort::sendTiming(PacketPtr pkt, Tick time)
86SimpleTimingPort::schedSendTiming(PacketPtr pkt, Tick when)
107{
87{
88 assert(when > curTick);
89
108 // Nothing is on the list: add it and schedule an event
109 if (transmitList.empty()) {
110 assert(!sendEvent->scheduled());
90 // Nothing is on the list: add it and schedule an event
91 if (transmitList.empty()) {
92 assert(!sendEvent->scheduled());
111 sendEvent->schedule(curTick+time);
112 transmitList.push_back(DeferredPacket(time+curTick, pkt));
93 sendEvent->schedule(when);
94 transmitList.push_back(DeferredPacket(when, pkt));
113 return;
114 }
115
116 // something is on the list and this belongs at the end
95 return;
96 }
97
98 // something is on the list and this belongs at the end
117 if (time+curTick >= transmitList.back().tick) {
118 transmitList.push_back(DeferredPacket(time+curTick, pkt));
99 if (when >= transmitList.back().tick) {
100 transmitList.push_back(DeferredPacket(when, pkt));
119 return;
120 }
121 // Something is on the list and this belongs somewhere else
122 DeferredPacketIterator i = transmitList.begin();
123 DeferredPacketIterator end = transmitList.end();
101 return;
102 }
103 // Something is on the list and this belongs somewhere else
104 DeferredPacketIterator i = transmitList.begin();
105 DeferredPacketIterator end = transmitList.end();
124 bool done = false;
125
106
126 while (i != end && !done) {
127 if (time+curTick < i->tick) {
107 for (; i != end; ++i) {
108 if (when < i->tick) {
128 if (i == transmitList.begin()) {
129 //Inserting at begining, reschedule
109 if (i == transmitList.begin()) {
110 //Inserting at begining, reschedule
130 sendEvent->reschedule(time+curTick);
111 sendEvent->reschedule(when);
131 }
112 }
132 transmitList.insert(i, DeferredPacket(time+curTick, pkt));
133 done = true;
113 transmitList.insert(i, DeferredPacket(when, pkt));
114 return;
134 }
115 }
135 i++;
136 }
116 }
137 assert(done);
117 assert(false); // should never get here
138}
139
118}
119
120
140void
121void
141SimpleTimingPort::processSendEvent()
122SimpleTimingPort::sendDeferredPacket()
142{
123{
143 assert(transmitList.size());
144 assert(transmitList.front().tick <= curTick);
145 if (Port::sendTiming(transmitList.front().pkt)) {
124 assert(deferredPacketReady());
125 bool success = sendTiming(transmitList.front().pkt);
126
127 if (success) {
146 //send successful, remove packet
147 transmitList.pop_front();
148 if (!transmitList.empty()) {
149 Tick time = transmitList.front().tick;
150 sendEvent->schedule(time <= curTick ? curTick+1 : time);
151 }
128 //send successful, remove packet
129 transmitList.pop_front();
130 if (!transmitList.empty()) {
131 Tick time = transmitList.front().tick;
132 sendEvent->schedule(time <= curTick ? curTick+1 : time);
133 }
134
152 if (transmitList.empty() && drainEvent) {
153 drainEvent->process();
154 drainEvent = NULL;
155 }
135 if (transmitList.empty() && drainEvent) {
136 drainEvent->process();
137 drainEvent = NULL;
138 }
156 return;
157 }
139 }
158 // send unsuccessful (due to flow control). Will get retry
159 // callback later; save for then if not already
160 DPRINTF(Bus, "Waiting on retry\n");
140
141 waitingOnRetry = !success;
142
143 if (waitingOnRetry) {
144 DPRINTF(Bus, "Send failed, waiting on retry\n");
145 }
161}
162
163
146}
147
148
149void
150SimpleTimingPort::recvRetry()
151{
152 DPRINTF(Bus, "Received retry\n");
153 assert(waitingOnRetry);
154 sendDeferredPacket();
155}
156
157
158void
159SimpleTimingPort::processSendEvent()
160{
161 assert(!waitingOnRetry);
162 sendDeferredPacket();
163}
164
165
164unsigned int
165SimpleTimingPort::drain(Event *de)
166{
167 if (transmitList.size() == 0)
168 return 0;
169 drainEvent = de;
170 return 1;
171}
166unsigned int
167SimpleTimingPort::drain(Event *de)
168{
169 if (transmitList.size() == 0)
170 return 0;
171 drainEvent = de;
172 return 1;
173}