tport.cc (4435:7da241055348) | tport.cc (4490:f9d3db907eec) |
---|---|
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; --- 17 unchanged lines hidden (view full) --- 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 */ 30 31#include "mem/tport.hh" 32 33void | 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; --- 17 unchanged lines hidden (view full) --- 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 */ 30 31#include "mem/tport.hh" 32 33void |
34SimpleTimingPort::recvFunctional(PacketPtr pkt) | 34SimpleTimingPort::checkFunctional(PacketPtr pkt) |
35{ | 35{ |
36 std::list<std::pair<Tick,PacketPtr> >::iterator i = transmitList.begin(); 37 std::list<std::pair<Tick,PacketPtr> >::iterator end = transmitList.end(); 38 bool notDone = true; | 36 DeferredPacketIterator i = transmitList.begin(); 37 DeferredPacketIterator end = transmitList.end(); |
39 | 38 |
40 while (i != end && notDone) { 41 PacketPtr target = i->second; | 39 while (i != end) { 40 PacketPtr target = i->pkt; |
42 // If the target contains data, and it overlaps the 43 // probed request, need to update data | 41 // If the target contains data, and it overlaps the 42 // probed request, need to update data |
44 if (target->intersect(pkt)) 45 notDone = fixPacket(pkt, target); | 43 if (target->intersect(pkt)) { 44 if (!fixPacket(pkt, target)) { 45 // fixPacket returns true for continue, false for done 46 return; 47 } 48 } |
46 47 i++; 48 } | 49 50 i++; 51 } |
52} |
|
49 | 53 |
50 //Then just do an atomic access and throw away the returned latency | 54void 55SimpleTimingPort::recvFunctional(PacketPtr pkt) 56{ 57 checkFunctional(pkt); 58 59 // Just do an atomic access and throw away the returned latency |
51 if (pkt->result != Packet::Success) 52 recvAtomic(pkt); 53} 54 55bool 56SimpleTimingPort::recvTiming(PacketPtr pkt) 57{ 58 // If the device is only a slave, it should only be sending 59 // responses, which should never get nacked. There used to be 60 // code to hanldle nacks here, but I'm pretty sure it didn't work 61 // correctly with the drain code, so that would need to be fixed 62 // if we ever added it back. 63 assert(pkt->result != Packet::Nacked); 64 Tick latency = recvAtomic(pkt); 65 // turn packet around to go back to requester if response expected 66 if (pkt->needsResponse()) { 67 pkt->makeTimingResponse(); 68 sendTiming(pkt, latency); 69 } | 60 if (pkt->result != Packet::Success) 61 recvAtomic(pkt); 62} 63 64bool 65SimpleTimingPort::recvTiming(PacketPtr pkt) 66{ 67 // If the device is only a slave, it should only be sending 68 // responses, which should never get nacked. There used to be 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(); 77 sendTiming(pkt, latency); 78 } |
70 else { 71 if (pkt->cmd != MemCmd::UpgradeReq) 72 { 73 delete pkt->req; 74 delete pkt; 75 } | 79 else if (pkt->cmd != MemCmd::UpgradeReq) { 80 delete pkt->req; 81 delete pkt; |
76 } 77 return true; 78} 79 80void 81SimpleTimingPort::recvRetry() 82{ 83 assert(!transmitList.empty()); | 82 } 83 return true; 84} 85 86void 87SimpleTimingPort::recvRetry() 88{ 89 assert(!transmitList.empty()); |
84 if (Port::sendTiming(transmitList.front().second)) { | 90 if (Port::sendTiming(transmitList.front().pkt)) { |
85 transmitList.pop_front(); 86 DPRINTF(Bus, "No Longer waiting on retry\n"); 87 if (!transmitList.empty()) { | 91 transmitList.pop_front(); 92 DPRINTF(Bus, "No Longer waiting on retry\n"); 93 if (!transmitList.empty()) { |
88 Tick time = transmitList.front().first; 89 sendEvent.schedule(time <= curTick ? curTick+1 : time); | 94 Tick time = transmitList.front().tick; 95 sendEvent->schedule(time <= curTick ? curTick+1 : time); |
90 } 91 } 92 93 if (transmitList.empty() && drainEvent) { 94 drainEvent->process(); 95 drainEvent = NULL; 96 } 97} 98 99void 100SimpleTimingPort::sendTiming(PacketPtr pkt, Tick time) 101{ 102 // Nothing is on the list: add it and schedule an event 103 if (transmitList.empty()) { | 96 } 97 } 98 99 if (transmitList.empty() && drainEvent) { 100 drainEvent->process(); 101 drainEvent = NULL; 102 } 103} 104 105void 106SimpleTimingPort::sendTiming(PacketPtr pkt, Tick time) 107{ 108 // Nothing is on the list: add it and schedule an event 109 if (transmitList.empty()) { |
104 assert(!sendEvent.scheduled()); 105 sendEvent.schedule(curTick+time); 106 transmitList.push_back(std::pair<Tick,PacketPtr>(time+curTick,pkt)); | 110 assert(!sendEvent->scheduled()); 111 sendEvent->schedule(curTick+time); 112 transmitList.push_back(DeferredPacket(time+curTick, pkt)); |
107 return; 108 } 109 110 // something is on the list and this belongs at the end | 113 return; 114 } 115 116 // something is on the list and this belongs at the end |
111 if (time+curTick >= transmitList.back().first) { 112 transmitList.push_back(std::pair<Tick,PacketPtr>(time+curTick,pkt)); | 117 if (time+curTick >= transmitList.back().tick) { 118 transmitList.push_back(DeferredPacket(time+curTick, pkt)); |
113 return; 114 } 115 // Something is on the list and this belongs somewhere else | 119 return; 120 } 121 // Something is on the list and this belongs somewhere else |
116 std::list<std::pair<Tick,PacketPtr> >::iterator i = transmitList.begin(); 117 std::list<std::pair<Tick,PacketPtr> >::iterator end = transmitList.end(); | 122 DeferredPacketIterator i = transmitList.begin(); 123 DeferredPacketIterator end = transmitList.end(); |
118 bool done = false; 119 120 while (i != end && !done) { | 124 bool done = false; 125 126 while (i != end && !done) { |
121 if (time+curTick < i->first) { | 127 if (time+curTick < i->tick) { |
122 if (i == transmitList.begin()) { 123 //Inserting at begining, reschedule | 128 if (i == transmitList.begin()) { 129 //Inserting at begining, reschedule |
124 sendEvent.reschedule(time+curTick); | 130 sendEvent->reschedule(time+curTick); |
125 } | 131 } |
126 transmitList.insert(i,std::pair<Tick,PacketPtr>(time+curTick,pkt)); | 132 transmitList.insert(i, DeferredPacket(time+curTick, pkt)); |
127 done = true; 128 } 129 i++; 130 } 131 assert(done); 132} 133 134void | 133 done = true; 134 } 135 i++; 136 } 137 assert(done); 138} 139 140void |
135SimpleTimingPort::SendEvent::process() | 141SimpleTimingPort::processSendEvent() |
136{ | 142{ |
137 assert(port->transmitList.size()); 138 assert(port->transmitList.front().first <= curTick); 139 if (port->Port::sendTiming(port->transmitList.front().second)) { | 143 assert(transmitList.size()); 144 assert(transmitList.front().tick <= curTick); 145 if (Port::sendTiming(transmitList.front().pkt)) { |
140 //send successful, remove packet | 146 //send successful, remove packet |
141 port->transmitList.pop_front(); 142 if (!port->transmitList.empty()) { 143 Tick time = port->transmitList.front().first; 144 schedule(time <= curTick ? curTick+1 : time); | 147 transmitList.pop_front(); 148 if (!transmitList.empty()) { 149 Tick time = transmitList.front().tick; 150 sendEvent->schedule(time <= curTick ? curTick+1 : time); |
145 } | 151 } |
146 if (port->transmitList.empty() && port->drainEvent) { 147 port->drainEvent->process(); 148 port->drainEvent = NULL; | 152 if (transmitList.empty() && drainEvent) { 153 drainEvent->process(); 154 drainEvent = NULL; |
149 } 150 return; 151 } 152 // send unsuccessful (due to flow control). Will get retry 153 // callback later; save for then if not already 154 DPRINTF(Bus, "Waiting on retry\n"); 155} 156 157 158unsigned int 159SimpleTimingPort::drain(Event *de) 160{ 161 if (transmitList.size() == 0) 162 return 0; 163 drainEvent = de; 164 return 1; 165} | 155 } 156 return; 157 } 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"); 161} 162 163 164unsigned int 165SimpleTimingPort::drain(Event *de) 166{ 167 if (transmitList.size() == 0) 168 return 0; 169 drainEvent = de; 170 return 1; 171} |