etherint.hh revision 11263
14479Sbinkertn@umich.edu/*
24479Sbinkertn@umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan
34479Sbinkertn@umich.edu * All rights reserved.
44479Sbinkertn@umich.edu *
54479Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without
64479Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are
74479Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright
84479Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer;
94479Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright
104479Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the
114479Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution;
124479Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its
134479Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from
144479Sbinkertn@umich.edu * this software without specific prior written permission.
154479Sbinkertn@umich.edu *
164479Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176498Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186498Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196498Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204479Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214479Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224479Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234479Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244479Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254479Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264479Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274479Sbinkertn@umich.edu *
284479Sbinkertn@umich.edu * Authors: Nathan Binkert
294479Sbinkertn@umich.edu */
304479Sbinkertn@umich.edu
314479Sbinkertn@umich.edu/* @file
324479Sbinkertn@umich.edu * Class representing the actual interface between two ethernet
334479Sbinkertn@umich.edu * components.
344479Sbinkertn@umich.edu */
354479Sbinkertn@umich.edu
364479Sbinkertn@umich.edu#ifndef __DEV_NET_ETHERINT_HH__
374479Sbinkertn@umich.edu#define __DEV_NET_ETHERINT_HH__
384479Sbinkertn@umich.edu
394479Sbinkertn@umich.edu#include <string>
404479Sbinkertn@umich.edu
414479Sbinkertn@umich.edu#include "dev/net/etherpkt.hh"
424479Sbinkertn@umich.edu
434479Sbinkertn@umich.edu/*
444479Sbinkertn@umich.edu * Class representing the actual interface between two ethernet
454479Sbinkertn@umich.edu * components.  These components are intended to attach to another
464479Sbinkertn@umich.edu * ethernet interface on one side and whatever device on the other.
474479Sbinkertn@umich.edu */
484479Sbinkertn@umich.educlass EtherInt
494479Sbinkertn@umich.edu{
504479Sbinkertn@umich.edu  protected:
514479Sbinkertn@umich.edu    mutable std::string portName;
524479Sbinkertn@umich.edu    EtherInt *peer;
534479Sbinkertn@umich.edu
544479Sbinkertn@umich.edu  public:
554479Sbinkertn@umich.edu    EtherInt(const std::string &name)
566498Snate@binkert.org        : portName(name), peer(NULL) {}
574479Sbinkertn@umich.edu    virtual ~EtherInt() {}
584479Sbinkertn@umich.edu
596498Snate@binkert.org    /** Return port name (for DPRINTF). */
604479Sbinkertn@umich.edu    const std::string &name() const { return portName; }
614479Sbinkertn@umich.edu
624479Sbinkertn@umich.edu    void setPeer(EtherInt *p);
634479Sbinkertn@umich.edu    EtherInt* getPeer() { return peer; }
644479Sbinkertn@umich.edu
654479Sbinkertn@umich.edu    void recvDone() { peer->sendDone(); }
664479Sbinkertn@umich.edu    virtual void sendDone() = 0;
674479Sbinkertn@umich.edu
684479Sbinkertn@umich.edu    bool sendPacket(EthPacketPtr packet)
694479Sbinkertn@umich.edu    { return peer ? peer->recvPacket(packet) : true; }
704479Sbinkertn@umich.edu    virtual bool recvPacket(EthPacketPtr packet) = 0;
714479Sbinkertn@umich.edu
724479Sbinkertn@umich.edu    bool askBusy() {return peer->isBusy(); }
734479Sbinkertn@umich.edu    virtual bool isBusy() { return false; }
744479Sbinkertn@umich.edu};
754479Sbinkertn@umich.edu
764479Sbinkertn@umich.edu#endif // __DEV_NET_ETHERINT_HH__
774479Sbinkertn@umich.edu