etherint.hh revision 13782
11049Sbinkertn@umich.edu/* 21049Sbinkertn@umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan 31049Sbinkertn@umich.edu * All rights reserved. 41049Sbinkertn@umich.edu * 51049Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without 61049Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are 71049Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright 81049Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer; 91049Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright 101049Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the 111049Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution; 121049Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its 131049Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from 141049Sbinkertn@umich.edu * this software without specific prior written permission. 151049Sbinkertn@umich.edu * 161049Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171049Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181049Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191049Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201049Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211049Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221049Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231049Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241049Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251049Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261049Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271049Sbinkertn@umich.edu * 281049Sbinkertn@umich.edu * Authors: Nathan Binkert 291049Sbinkertn@umich.edu */ 301049Sbinkertn@umich.edu 311049Sbinkertn@umich.edu/* @file 321049Sbinkertn@umich.edu * Class representing the actual interface between two ethernet 331049Sbinkertn@umich.edu * components. 341049Sbinkertn@umich.edu */ 351049Sbinkertn@umich.edu 361049Sbinkertn@umich.edu#ifndef __DEV_NET_ETHERINT_HH__ 371049Sbinkertn@umich.edu#define __DEV_NET_ETHERINT_HH__ 381049Sbinkertn@umich.edu 391049Sbinkertn@umich.edu#include <string> 401049Sbinkertn@umich.edu 411049Sbinkertn@umich.edu#include "dev/net/etherpkt.hh" 421269Sbinkertn@umich.edu#include "mem/port.hh" 431049Sbinkertn@umich.edu 441269Sbinkertn@umich.edu/* 451269Sbinkertn@umich.edu * Class representing the actual interface between two ethernet 461269Sbinkertn@umich.edu * components. These components are intended to attach to another 471269Sbinkertn@umich.edu * ethernet interface on one side and whatever device on the other. 481269Sbinkertn@umich.edu */ 491269Sbinkertn@umich.educlass EtherInt : public Port 501162Sbinkertn@umich.edu{ 511049Sbinkertn@umich.edu protected: 521049Sbinkertn@umich.edu mutable std::string portName; 531269Sbinkertn@umich.edu EtherInt *peer; 541269Sbinkertn@umich.edu 551269Sbinkertn@umich.edu public: 561269Sbinkertn@umich.edu EtherInt(const std::string &name, int idx=InvalidPortID) 571269Sbinkertn@umich.edu : Port(name, idx), portName(name), peer(NULL) {} 581269Sbinkertn@umich.edu virtual ~EtherInt() {} 591269Sbinkertn@umich.edu 601269Sbinkertn@umich.edu /** Return port name (for DPRINTF). */ 611269Sbinkertn@umich.edu const std::string &name() const { return portName; } 621269Sbinkertn@umich.edu 631269Sbinkertn@umich.edu void bind(Port &peer) override; 641269Sbinkertn@umich.edu void unbind() override; 651269Sbinkertn@umich.edu 661269Sbinkertn@umich.edu void setPeer(EtherInt *p); 671269Sbinkertn@umich.edu EtherInt* getPeer() { return peer; } 681269Sbinkertn@umich.edu 691269Sbinkertn@umich.edu void recvDone() { peer->sendDone(); } 701269Sbinkertn@umich.edu virtual void sendDone() = 0; 711269Sbinkertn@umich.edu 721269Sbinkertn@umich.edu bool sendPacket(EthPacketPtr packet) 731269Sbinkertn@umich.edu { return peer ? peer->recvPacket(packet) : true; } 741269Sbinkertn@umich.edu virtual bool recvPacket(EthPacketPtr packet) = 0; 751269Sbinkertn@umich.edu 761049Sbinkertn@umich.edu bool askBusy() {return peer->isBusy(); } 771269Sbinkertn@umich.edu virtual bool isBusy() { return false; } 781269Sbinkertn@umich.edu}; 791269Sbinkertn@umich.edu 801049Sbinkertn@umich.edu#endif // __DEV_NET_ETHERINT_HH__ 811049Sbinkertn@umich.edu