tport.cc revision 3349
12914Ssaidi@eecs.umich.edu/* 22914Ssaidi@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan 32914Ssaidi@eecs.umich.edu * All rights reserved. 42914Ssaidi@eecs.umich.edu * 52914Ssaidi@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 62914Ssaidi@eecs.umich.edu * modification, are permitted provided that the following conditions are 72914Ssaidi@eecs.umich.edu * met: redistributions of source code must retain the above copyright 82914Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 92914Ssaidi@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 102914Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 112914Ssaidi@eecs.umich.edu * documentation and/or other materials provided with the distribution; 122914Ssaidi@eecs.umich.edu * neither the name of the copyright holders nor the names of its 132914Ssaidi@eecs.umich.edu * contributors may be used to endorse or promote products derived from 142914Ssaidi@eecs.umich.edu * this software without specific prior written permission. 152914Ssaidi@eecs.umich.edu * 162914Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172914Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182914Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192914Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202914Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212914Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222914Ssaidi@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232914Ssaidi@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242914Ssaidi@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252914Ssaidi@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262914Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272914Ssaidi@eecs.umich.edu * 282914Ssaidi@eecs.umich.edu * Authors: Ali Saidi 292914Ssaidi@eecs.umich.edu */ 302914Ssaidi@eecs.umich.edu 312914Ssaidi@eecs.umich.edu#include "mem/tport.hh" 322914Ssaidi@eecs.umich.edu 332914Ssaidi@eecs.umich.eduvoid 343349Sbinkertn@umich.eduSimpleTimingPort::recvFunctional(PacketPtr pkt) 353091Sstever@eecs.umich.edu{ 363284Srdreslin@umich.edu //First check queued events 373349Sbinkertn@umich.edu std::list<PacketPtr>::iterator i = transmitList.begin(); 383349Sbinkertn@umich.edu std::list<PacketPtr>::iterator end = transmitList.end(); 393296Ssaidi@eecs.umich.edu bool cont = true; 403296Ssaidi@eecs.umich.edu 413296Ssaidi@eecs.umich.edu while (i != end && cont) { 423349Sbinkertn@umich.edu PacketPtr target = *i; 433284Srdreslin@umich.edu // If the target contains data, and it overlaps the 443284Srdreslin@umich.edu // probed request, need to update data 453296Ssaidi@eecs.umich.edu if (target->intersect(pkt)) 463296Ssaidi@eecs.umich.edu fixPacket(pkt, target); 473284Srdreslin@umich.edu 483284Srdreslin@umich.edu } 493284Srdreslin@umich.edu //Then just do an atomic access and throw away the returned latency 503296Ssaidi@eecs.umich.edu if (cont) 513296Ssaidi@eecs.umich.edu recvAtomic(pkt); 523091Sstever@eecs.umich.edu} 533091Sstever@eecs.umich.edu 543091Sstever@eecs.umich.edubool 553349Sbinkertn@umich.eduSimpleTimingPort::recvTiming(PacketPtr pkt) 563091Sstever@eecs.umich.edu{ 573091Sstever@eecs.umich.edu // If the device is only a slave, it should only be sending 583091Sstever@eecs.umich.edu // responses, which should never get nacked. There used to be 593091Sstever@eecs.umich.edu // code to hanldle nacks here, but I'm pretty sure it didn't work 603091Sstever@eecs.umich.edu // correctly with the drain code, so that would need to be fixed 613091Sstever@eecs.umich.edu // if we ever added it back. 623091Sstever@eecs.umich.edu assert(pkt->result != Packet::Nacked); 633091Sstever@eecs.umich.edu Tick latency = recvAtomic(pkt); 643175Srdreslin@umich.edu // turn packet around to go back to requester if response expected 653175Srdreslin@umich.edu if (pkt->needsResponse()) { 663175Srdreslin@umich.edu pkt->makeTimingResponse(); 673175Srdreslin@umich.edu sendTimingLater(pkt, latency); 683175Srdreslin@umich.edu } 693309Srdreslin@umich.edu else { 703309Srdreslin@umich.edu if (pkt->cmd != Packet::UpgradeReq) 713309Srdreslin@umich.edu { 723309Srdreslin@umich.edu delete pkt->req; 733309Srdreslin@umich.edu delete pkt; 743309Srdreslin@umich.edu } 753309Srdreslin@umich.edu } 763091Sstever@eecs.umich.edu return true; 773091Sstever@eecs.umich.edu} 783091Sstever@eecs.umich.edu 793091Sstever@eecs.umich.eduvoid 802914Ssaidi@eecs.umich.eduSimpleTimingPort::recvRetry() 812914Ssaidi@eecs.umich.edu{ 823263Srdreslin@umich.edu assert(outTiming > 0); 833263Srdreslin@umich.edu assert(!transmitList.empty()); 843263Srdreslin@umich.edu if (sendTiming(transmitList.front())) { 853263Srdreslin@umich.edu transmitList.pop_front(); 863263Srdreslin@umich.edu outTiming--; 873263Srdreslin@umich.edu DPRINTF(Bus, "No Longer waiting on retry\n"); 883263Srdreslin@umich.edu if (!transmitList.empty()) 893263Srdreslin@umich.edu sendTimingLater(transmitList.front(), 1); 903263Srdreslin@umich.edu } 913219Sgblack@eecs.umich.edu 923263Srdreslin@umich.edu if (transmitList.empty() && drainEvent) { 933091Sstever@eecs.umich.edu drainEvent->process(); 943091Sstever@eecs.umich.edu drainEvent = NULL; 953091Sstever@eecs.umich.edu } 962914Ssaidi@eecs.umich.edu} 972914Ssaidi@eecs.umich.edu 982914Ssaidi@eecs.umich.eduvoid 992914Ssaidi@eecs.umich.eduSimpleTimingPort::SendEvent::process() 1002914Ssaidi@eecs.umich.edu{ 1013263Srdreslin@umich.edu assert(port->outTiming > 0); 1023263Srdreslin@umich.edu if (!port->transmitList.empty() && port->transmitList.front() != packet) { 1033263Srdreslin@umich.edu //We are not the head of the list 1043219Sgblack@eecs.umich.edu port->transmitList.push_back(packet); 1053241Sgblack@eecs.umich.edu } else if (port->sendTiming(packet)) { 1063219Sgblack@eecs.umich.edu // send successful 1073263Srdreslin@umich.edu if (port->transmitList.size()) { 1083263Srdreslin@umich.edu port->transmitList.pop_front(); 1093263Srdreslin@umich.edu port->outTiming--; 1103263Srdreslin@umich.edu if (!port->transmitList.empty()) 1113263Srdreslin@umich.edu port->sendTimingLater(port->transmitList.front(), 1); 1123263Srdreslin@umich.edu } 1133263Srdreslin@umich.edu if (port->transmitList.empty() && port->drainEvent) { 1143091Sstever@eecs.umich.edu port->drainEvent->process(); 1153091Sstever@eecs.umich.edu port->drainEvent = NULL; 1163091Sstever@eecs.umich.edu } 1173091Sstever@eecs.umich.edu } else { 1183091Sstever@eecs.umich.edu // send unsuccessful (due to flow control). Will get retry 1193263Srdreslin@umich.edu // callback later; save for then if not already 1203263Srdreslin@umich.edu DPRINTF(Bus, "Waiting on retry\n"); 1213263Srdreslin@umich.edu if (!(port->transmitList.front() == packet)) 1223263Srdreslin@umich.edu port->transmitList.push_back(packet); 1233091Sstever@eecs.umich.edu } 1242914Ssaidi@eecs.umich.edu} 1252914Ssaidi@eecs.umich.edu 1262914Ssaidi@eecs.umich.edu 1272914Ssaidi@eecs.umich.eduunsigned int 1282914Ssaidi@eecs.umich.eduSimpleTimingPort::drain(Event *de) 1292914Ssaidi@eecs.umich.edu{ 1302914Ssaidi@eecs.umich.edu if (outTiming == 0 && transmitList.size() == 0) 1312914Ssaidi@eecs.umich.edu return 0; 1322914Ssaidi@eecs.umich.edu drainEvent = de; 1332914Ssaidi@eecs.umich.edu return 1; 1342914Ssaidi@eecs.umich.edu} 135