tport.cc revision 3263
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 343091Sstever@eecs.umich.eduSimpleTimingPort::recvFunctional(Packet *pkt) 353091Sstever@eecs.umich.edu{ 363091Sstever@eecs.umich.edu // just do an atomic access and throw away the returned latency 373091Sstever@eecs.umich.edu recvAtomic(pkt); 383091Sstever@eecs.umich.edu} 393091Sstever@eecs.umich.edu 403091Sstever@eecs.umich.edubool 413091Sstever@eecs.umich.eduSimpleTimingPort::recvTiming(Packet *pkt) 423091Sstever@eecs.umich.edu{ 433091Sstever@eecs.umich.edu // If the device is only a slave, it should only be sending 443091Sstever@eecs.umich.edu // responses, which should never get nacked. There used to be 453091Sstever@eecs.umich.edu // code to hanldle nacks here, but I'm pretty sure it didn't work 463091Sstever@eecs.umich.edu // correctly with the drain code, so that would need to be fixed 473091Sstever@eecs.umich.edu // if we ever added it back. 483091Sstever@eecs.umich.edu assert(pkt->result != Packet::Nacked); 493091Sstever@eecs.umich.edu Tick latency = recvAtomic(pkt); 503175Srdreslin@umich.edu // turn packet around to go back to requester if response expected 513175Srdreslin@umich.edu if (pkt->needsResponse()) { 523175Srdreslin@umich.edu pkt->makeTimingResponse(); 533175Srdreslin@umich.edu sendTimingLater(pkt, latency); 543175Srdreslin@umich.edu } 553091Sstever@eecs.umich.edu return true; 563091Sstever@eecs.umich.edu} 573091Sstever@eecs.umich.edu 583091Sstever@eecs.umich.eduvoid 592914Ssaidi@eecs.umich.eduSimpleTimingPort::recvRetry() 602914Ssaidi@eecs.umich.edu{ 613263Srdreslin@umich.edu assert(outTiming > 0); 623263Srdreslin@umich.edu assert(!transmitList.empty()); 633263Srdreslin@umich.edu if (sendTiming(transmitList.front())) { 643263Srdreslin@umich.edu transmitList.pop_front(); 653263Srdreslin@umich.edu outTiming--; 663263Srdreslin@umich.edu DPRINTF(Bus, "No Longer waiting on retry\n"); 673263Srdreslin@umich.edu if (!transmitList.empty()) 683263Srdreslin@umich.edu sendTimingLater(transmitList.front(), 1); 693263Srdreslin@umich.edu } 703219Sgblack@eecs.umich.edu 713263Srdreslin@umich.edu if (transmitList.empty() && drainEvent) { 723091Sstever@eecs.umich.edu drainEvent->process(); 733091Sstever@eecs.umich.edu drainEvent = NULL; 743091Sstever@eecs.umich.edu } 752914Ssaidi@eecs.umich.edu} 762914Ssaidi@eecs.umich.edu 772914Ssaidi@eecs.umich.eduvoid 782914Ssaidi@eecs.umich.eduSimpleTimingPort::SendEvent::process() 792914Ssaidi@eecs.umich.edu{ 803263Srdreslin@umich.edu assert(port->outTiming > 0); 813263Srdreslin@umich.edu if (!port->transmitList.empty() && port->transmitList.front() != packet) { 823263Srdreslin@umich.edu //We are not the head of the list 833219Sgblack@eecs.umich.edu port->transmitList.push_back(packet); 843241Sgblack@eecs.umich.edu } else if (port->sendTiming(packet)) { 853219Sgblack@eecs.umich.edu // send successful 863263Srdreslin@umich.edu if (port->transmitList.size()) { 873263Srdreslin@umich.edu port->transmitList.pop_front(); 883263Srdreslin@umich.edu port->outTiming--; 893263Srdreslin@umich.edu if (!port->transmitList.empty()) 903263Srdreslin@umich.edu port->sendTimingLater(port->transmitList.front(), 1); 913263Srdreslin@umich.edu } 923263Srdreslin@umich.edu if (port->transmitList.empty() && port->drainEvent) { 933091Sstever@eecs.umich.edu port->drainEvent->process(); 943091Sstever@eecs.umich.edu port->drainEvent = NULL; 953091Sstever@eecs.umich.edu } 963091Sstever@eecs.umich.edu } else { 973091Sstever@eecs.umich.edu // send unsuccessful (due to flow control). Will get retry 983263Srdreslin@umich.edu // callback later; save for then if not already 993263Srdreslin@umich.edu DPRINTF(Bus, "Waiting on retry\n"); 1003263Srdreslin@umich.edu if (!(port->transmitList.front() == packet)) 1013263Srdreslin@umich.edu port->transmitList.push_back(packet); 1023091Sstever@eecs.umich.edu } 1032914Ssaidi@eecs.umich.edu} 1042914Ssaidi@eecs.umich.edu 1052914Ssaidi@eecs.umich.edu 1062914Ssaidi@eecs.umich.eduunsigned int 1072914Ssaidi@eecs.umich.eduSimpleTimingPort::drain(Event *de) 1082914Ssaidi@eecs.umich.edu{ 1092914Ssaidi@eecs.umich.edu if (outTiming == 0 && transmitList.size() == 0) 1102914Ssaidi@eecs.umich.edu return 0; 1112914Ssaidi@eecs.umich.edu drainEvent = de; 1122914Ssaidi@eecs.umich.edu return 1; 1132914Ssaidi@eecs.umich.edu} 114