From: Shivani Date: Tue, 28 Jul 2020 21:00:38 +0000 (-0700) Subject: mem: Deprecate SlavePort and MasterPort classes X-Git-Tag: v20.1.0.0~229 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e1f6d22234f461c6de1b932868f5658aed821dad;p=gem5.git mem: Deprecate SlavePort and MasterPort classes After this change, if you use these classes or inherit from these classes, the compiler will now give you a warning that these names are deprecated. Instead, you should use ResponsePort and RequestPort, respectively. This patch simply deprecates these names. The following patches will convert all of the code in gem5 to use these new names. The first step is converting the class names and the uses of these classes, then we will update the variable names to be more precise as well. Change-Id: I5e6e90b2916df4dbfccdaabe97423f377a1f6e3f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32308 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/mem/port.cc b/src/mem/port.cc index 47e94f471..6460b5943 100644 --- a/src/mem/port.cc +++ b/src/mem/port.cc @@ -50,7 +50,7 @@ namespace { -class DefaultMasterPort : public MasterPort +class DefaultRequestPort : public RequestPort { protected: [[noreturn]] void @@ -60,7 +60,7 @@ class DefaultMasterPort : public MasterPort } public: - DefaultMasterPort() : MasterPort("default_master_port", nullptr) {} + DefaultRequestPort() : RequestPort("default_request_port", nullptr) {} // Atomic protocol. Tick recvAtomicSnoop(PacketPtr) override { blowUp(); } @@ -75,7 +75,7 @@ class DefaultMasterPort : public MasterPort void recvFunctionalSnoop(PacketPtr) override { blowUp(); } }; -class DefaultSlavePort : public SlavePort +class DefaultResponsePort : public ResponsePort { protected: [[noreturn]] void @@ -85,7 +85,7 @@ class DefaultSlavePort : public SlavePort } public: - DefaultSlavePort() : SlavePort("default_slave_port", nullptr) {} + DefaultResponsePort() : ResponsePort("default_response_port", nullptr) {} // Atomic protocol. Tick recvAtomic(PacketPtr) override { blowUp(); } @@ -103,54 +103,55 @@ class DefaultSlavePort : public SlavePort AddrRangeList getAddrRanges() const override { return AddrRangeList(); } }; -DefaultMasterPort defaultMasterPort; -DefaultSlavePort defaultSlavePort; +DefaultRequestPort defaultRequestPort; +DefaultResponsePort defaultResponsePort; } // anonymous namespace /** - * Master port + * Request port */ -MasterPort::MasterPort(const std::string& name, SimObject* _owner, PortID _id) - : Port(name, _id), _slavePort(&defaultSlavePort), owner(*_owner) +RequestPort::RequestPort(const std::string& name, SimObject* _owner, + PortID _id) : Port(name, _id), _responsePort(&defaultResponsePort), + owner(*_owner) { } -MasterPort::~MasterPort() +RequestPort::~RequestPort() { } void -MasterPort::bind(Port &peer) +RequestPort::bind(Port &peer) { - auto *slave_port = dynamic_cast(&peer); - fatal_if(!slave_port, "Can't bind port %s to non-slave port %s.", + auto *response_port = dynamic_cast(&peer); + fatal_if(!response_port, "Can't bind port %s to non-response port %s.", name(), peer.name()); - // master port keeps track of the slave port - _slavePort = slave_port; + // request port keeps track of the response port + _responsePort = response_port; Port::bind(peer); - // slave port also keeps track of master port - _slavePort->slaveBind(*this); + // response port also keeps track of request port + _responsePort->slaveBind(*this); } void -MasterPort::unbind() +RequestPort::unbind() { - panic_if(!isConnected(), "Can't unbind master port %s which is not bound.", - name()); - _slavePort->slaveUnbind(); - _slavePort = &defaultSlavePort; + panic_if(!isConnected(), "Can't unbind request port %s which is " + "not bound.", name()); + _responsePort->slaveUnbind(); + _responsePort = &defaultResponsePort; Port::unbind(); } AddrRangeList -MasterPort::getAddrRanges() const +RequestPort::getAddrRanges() const { - return _slavePort->getAddrRanges(); + return _responsePort->getAddrRanges(); } void -MasterPort::printAddr(Addr a) +RequestPort::printAddr(Addr a) { auto req = std::make_shared( a, 1, 0, Request::funcMasterId); @@ -165,32 +166,32 @@ MasterPort::printAddr(Addr a) /** * Slave port */ -SlavePort::SlavePort(const std::string& name, SimObject* _owner, PortID id) - : Port(name, id), _masterPort(&defaultMasterPort), +ResponsePort::ResponsePort(const std::string& name, SimObject* _owner, + PortID id) : Port(name, id), _requestPort(&defaultRequestPort), defaultBackdoorWarned(false), owner(*_owner) { } -SlavePort::~SlavePort() +ResponsePort::~ResponsePort() { } void -SlavePort::slaveUnbind() +ResponsePort::slaveUnbind() { - _masterPort = &defaultMasterPort; + _requestPort = &defaultRequestPort; Port::unbind(); } void -SlavePort::slaveBind(MasterPort& master_port) +ResponsePort::slaveBind(RequestPort& request_port) { - _masterPort = &master_port; - Port::bind(master_port); + _requestPort = &request_port; + Port::bind(request_port); } Tick -SlavePort::recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) +ResponsePort::recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) { if (!defaultBackdoorWarned) { warn("Port %s doesn't support requesting a back door.", name()); diff --git a/src/mem/port.hh b/src/mem/port.hh index eadf7f44a..f378f0780 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -56,10 +56,13 @@ class SimObject; /** Forward declaration */ +class MasterPort; class SlavePort; +class ResponsePort; + /** - * A MasterPort is a specialisation of a BaseMasterPort, which + * A RequestPort is a specialisation of a Port, which * implements the default protocol for the three different level of * transport functions. In addition to the basic functionality of * sending packets, it also has functions to receive range changes or @@ -68,37 +71,37 @@ class SlavePort; * The three protocols are atomic, timing, and functional, each with its own * header file. */ -class MasterPort : public Port, public AtomicRequestProtocol, +class RequestPort: public Port, public AtomicRequestProtocol, public TimingRequestProtocol, public FunctionalRequestProtocol { - friend class SlavePort; + friend class ResponsePort; private: - SlavePort *_slavePort; + ResponsePort *_responsePort; protected: SimObject &owner; public: - MasterPort(const std::string& name, SimObject* _owner, + RequestPort(const std::string& name, SimObject* _owner, PortID id=InvalidPortID); - virtual ~MasterPort(); + virtual ~RequestPort(); /** - * Bind this master port to a slave port. This also does the - * mirror action and binds the slave port to the master port. + * Bind this request port to a response port. This also does the + * mirror action and binds the response port to the request port. */ void bind(Port &peer) override; /** - * Unbind this master port and the associated slave port. + * Unbind this request port and the associated response port. */ void unbind() override; /** - * Determine if this master port is snooping or not. The default + * Determine if this request port is snooping or not. The default * implementation returns false and thus tells the neighbour we - * are not snooping. Any master port that wants to receive snoop + * are not snooping. Any request port that wants to receive snoop * requests (e.g. a cache connected to a bus) has to override this * function. * @@ -107,7 +110,7 @@ class MasterPort : public Port, public AtomicRequestProtocol, virtual bool isSnooping() const { return false; } /** - * Get the address ranges of the connected slave port. + * Get the address ranges of the connected responder port. */ AddrRangeList getAddrRanges() const; @@ -159,7 +162,7 @@ class MasterPort : public Port, public AtomicRequestProtocol, /* The timing protocol. */ /** - * Attempt to send a timing request to the slave port by calling + * Attempt to send a timing request to the responder port by calling * its corresponding receive function. If the send does not * succeed, as indicated by the return value, then the sender must * wait for a recvReqRetry at which point it can re-issue a @@ -172,7 +175,7 @@ class MasterPort : public Port, public AtomicRequestProtocol, bool sendTimingReq(PacketPtr pkt); /** - * Check if the slave can handle a timing request. + * Check if the responder can handle a timing request. * * If the send cannot be handled at the moment, as indicated by * the return value, then the sender will receive a recvReqRetry @@ -180,12 +183,12 @@ class MasterPort : public Port, public AtomicRequestProtocol, * * @param pkt Packet to send. * - * @return If the send was succesful or not. + * @return If the send was successful or not. */ bool tryTiming(PacketPtr pkt) const; /** - * Attempt to send a timing snoop response packet to the slave + * Attempt to send a timing snoop response packet to the response * port by calling its corresponding receive function. If the send * does not succeed, as indicated by the return value, then the * sender must wait for a recvRetrySnoop at which point it can @@ -196,8 +199,8 @@ class MasterPort : public Port, public AtomicRequestProtocol, bool sendTimingSnoopResp(PacketPtr pkt); /** - * Send a retry to the slave port that previously attempted a - * sendTimingResp to this master port and failed. Note that this + * Send a retry to the response port that previously attempted a + * sendTimingResp to this request port and failed. Note that this * is virtual so that the "fake" snoop response port in the * coherent crossbar can override the behaviour. */ @@ -205,7 +208,7 @@ class MasterPort : public Port, public AtomicRequestProtocol, protected: /** - * Called to receive an address range change from the peer slave + * Called to receive an address range change from the peer response * port. The default implementation ignores the change and does * nothing. Override this function in a derived class if the owner * needs to be aware of the address ranges, e.g. in an @@ -242,22 +245,30 @@ class MasterPort : public Port, public AtomicRequestProtocol, } }; +class M5_DEPRECATED MasterPort : public RequestPort +{ + public: + MasterPort(const std::string& name, SimObject* _owner, + PortID id=InvalidPortID) : RequestPort(name, _owner, id) + {} +}; + /** - * A SlavePort is a specialisation of a port. In addition to the - * basic functionality of sending packets to its master peer, it also - * has functions specific to a slave, e.g. to send range changes + * A ResponsePort is a specialization of a port. In addition to the + * basic functionality of sending packets to its requestor peer, it also + * has functions specific to a responder, e.g. to send range changes * and get the address ranges that the port responds to. * * The three protocols are atomic, timing, and functional, each with its own * header file. */ -class SlavePort : public Port, public AtomicResponseProtocol, +class ResponsePort : public Port, public AtomicResponseProtocol, public TimingResponseProtocol, public FunctionalResponseProtocol { - friend class MasterPort; + friend class RequestPort; private: - MasterPort* _masterPort; + RequestPort* _requestPort; bool defaultBackdoorWarned; @@ -265,25 +276,25 @@ class SlavePort : public Port, public AtomicResponseProtocol, SimObject& owner; public: - SlavePort(const std::string& name, SimObject* _owner, + ResponsePort(const std::string& name, SimObject* _owner, PortID id=InvalidPortID); - virtual ~SlavePort(); + virtual ~ResponsePort(); /** - * Find out if the peer master port is snooping or not. + * Find out if the peer request port is snooping or not. * - * @return true if the peer master port is snooping + * @return true if the peer request port is snooping */ - bool isSnooping() const { return _masterPort->isSnooping(); } + bool isSnooping() const { return _requestPort->isSnooping(); } /** * Called by the owner to send a range change */ - void sendRangeChange() const { _masterPort->recvRangeChange(); } + void sendRangeChange() const { _requestPort->recvRangeChange(); } /** * Get a list of the non-overlapping address ranges the owner is - * responsible for. All slave ports must override this function + * responsible for. All response ports must override this function * and return a populated list with at least one item. * * @return a list of ranges responded to @@ -291,7 +302,7 @@ class SlavePort : public Port, public AtomicResponseProtocol, virtual AddrRangeList getAddrRanges() const = 0; /** - * We let the master port do the work, so these don't do anything. + * We let the request port do the work, so these don't do anything. */ void unbind() override {} void bind(Port &peer) override {} @@ -312,7 +323,7 @@ class SlavePort : public Port, public AtomicResponseProtocol, sendAtomicSnoop(PacketPtr pkt) { try { - return AtomicResponseProtocol::sendSnoop(_masterPort, pkt); + return AtomicResponseProtocol::sendSnoop(_requestPort, pkt); } catch (UnboundPortException) { reportUnbound(); } @@ -332,7 +343,7 @@ class SlavePort : public Port, public AtomicResponseProtocol, sendFunctionalSnoop(PacketPtr pkt) const { try { - FunctionalResponseProtocol::sendSnoop(_masterPort, pkt); + FunctionalResponseProtocol::sendSnoop(_requestPort, pkt); } catch (UnboundPortException) { reportUnbound(); } @@ -342,7 +353,7 @@ class SlavePort : public Port, public AtomicResponseProtocol, /* The timing protocol. */ /** - * Attempt to send a timing response to the master port by calling + * Attempt to send a timing response to the request port by calling * its corresponding receive function. If the send does not * succeed, as indicated by the return value, then the sender must * wait for a recvRespRetry at which point it can re-issue a @@ -350,20 +361,20 @@ class SlavePort : public Port, public AtomicResponseProtocol, * * @param pkt Packet to send. * - * @return If the send was succesful or not. + * @return If the send was successful or not. */ bool sendTimingResp(PacketPtr pkt) { try { - return TimingResponseProtocol::sendResp(_masterPort, pkt); + return TimingResponseProtocol::sendResp(_requestPort, pkt); } catch (UnboundPortException) { reportUnbound(); } } /** - * Attempt to send a timing snoop request packet to the master port + * Attempt to send a timing snoop request packet to the request port * by calling its corresponding receive function. Snoop requests * always succeed and hence no return value is needed. * @@ -373,35 +384,35 @@ class SlavePort : public Port, public AtomicResponseProtocol, sendTimingSnoopReq(PacketPtr pkt) { try { - TimingResponseProtocol::sendSnoopReq(_masterPort, pkt); + TimingResponseProtocol::sendSnoopReq(_requestPort, pkt); } catch (UnboundPortException) { reportUnbound(); } } /** - * Send a retry to the master port that previously attempted a - * sendTimingReq to this slave port and failed. + * Send a retry to the request port that previously attempted a + * sendTimingReq to this response port and failed. */ void sendRetryReq() { try { - TimingResponseProtocol::sendRetryReq(_masterPort); + TimingResponseProtocol::sendRetryReq(_requestPort); } catch (UnboundPortException) { reportUnbound(); } } /** - * Send a retry to the master port that previously attempted a - * sendTimingSnoopResp to this slave port and failed. + * Send a retry to the request port that previously attempted a + * sendTimingSnoopResp to this response port and failed. */ void sendRetrySnoopResp() { try { - TimingResponseProtocol::sendRetrySnoopResp(_masterPort); + TimingResponseProtocol::sendRetrySnoopResp(_requestPort); } catch (UnboundPortException) { reportUnbound(); } @@ -409,16 +420,16 @@ class SlavePort : public Port, public AtomicResponseProtocol, protected: /** - * Called by the master port to unbind. Should never be called + * Called by the request port to unbind. Should never be called * directly. */ void slaveUnbind(); /** - * Called by the master port to bind. Should never be called + * Called by the request port to bind. Should never be called * directly. */ - void slaveBind(MasterPort& master_port); + void slaveBind(RequestPort& request_port); /** * Default implementations. @@ -438,71 +449,80 @@ class SlavePort : public Port, public AtomicResponseProtocol, } }; +class M5_DEPRECATED SlavePort : public ResponsePort +{ + public: + SlavePort(const std::string& name, SimObject* _owner, + PortID id=InvalidPortID) : ResponsePort(name, _owner, id) + {} +}; + inline Tick -MasterPort::sendAtomic(PacketPtr pkt) +RequestPort::sendAtomic(PacketPtr pkt) { try { - return AtomicRequestProtocol::send(_slavePort, pkt); + return AtomicRequestProtocol::send(_responsePort, pkt); } catch (UnboundPortException) { reportUnbound(); } } inline Tick -MasterPort::sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) +RequestPort::sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) { try { - return AtomicRequestProtocol::sendBackdoor(_slavePort, pkt, backdoor); + return AtomicRequestProtocol::sendBackdoor(_responsePort, + pkt, backdoor); } catch (UnboundPortException) { reportUnbound(); } } inline void -MasterPort::sendFunctional(PacketPtr pkt) const +RequestPort::sendFunctional(PacketPtr pkt) const { try { - return FunctionalRequestProtocol::send(_slavePort, pkt); + return FunctionalRequestProtocol::send(_responsePort, pkt); } catch (UnboundPortException) { reportUnbound(); } } inline bool -MasterPort::sendTimingReq(PacketPtr pkt) +RequestPort::sendTimingReq(PacketPtr pkt) { try { - return TimingRequestProtocol::sendReq(_slavePort, pkt); + return TimingRequestProtocol::sendReq(_responsePort, pkt); } catch (UnboundPortException) { reportUnbound(); } } inline bool -MasterPort::tryTiming(PacketPtr pkt) const +RequestPort::tryTiming(PacketPtr pkt) const { try { - return TimingRequestProtocol::trySend(_slavePort, pkt); + return TimingRequestProtocol::trySend(_responsePort, pkt); } catch (UnboundPortException) { reportUnbound(); } } inline bool -MasterPort::sendTimingSnoopResp(PacketPtr pkt) +RequestPort::sendTimingSnoopResp(PacketPtr pkt) { try { - return TimingRequestProtocol::sendSnoopResp(_slavePort, pkt); + return TimingRequestProtocol::sendSnoopResp(_responsePort, pkt); } catch (UnboundPortException) { reportUnbound(); } } inline void -MasterPort::sendRetryResp() +RequestPort::sendRetryResp() { try { - TimingRequestProtocol::sendRetryResp(_slavePort); + TimingRequestProtocol::sendRetryResp(_responsePort); } catch (UnboundPortException) { reportUnbound(); }