Shivani Parekh has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/32308 )

Change subject: mem: Deprecate SlavePort and MasterPort classes
......................................................................

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
---
M src/mem/port.cc
M src/mem/port.hh
2 files changed, 114 insertions(+), 95 deletions(-)



diff --git a/src/mem/port.cc b/src/mem/port.cc
index 47e94f4..6460b59 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 @@
     }

   public:
-    DefaultMasterPort() : MasterPort("default_master_port", nullptr) {}
+    DefaultRequestPort() : RequestPort("default_request_port", nullptr) {}

     // Atomic protocol.
     Tick recvAtomicSnoop(PacketPtr) override { blowUp(); }
@@ -75,7 +75,7 @@
     void recvFunctionalSnoop(PacketPtr) override { blowUp(); }
 };

-class DefaultSlavePort : public SlavePort
+class DefaultResponsePort : public ResponsePort
 {
   protected:
     [[noreturn]] void
@@ -85,7 +85,7 @@
     }

   public:
-    DefaultSlavePort() : SlavePort("default_slave_port", nullptr) {}
+ DefaultResponsePort() : ResponsePort("default_response_port", nullptr) {}

     // Atomic protocol.
     Tick recvAtomic(PacketPtr) override { blowUp(); }
@@ -103,54 +103,55 @@
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<SlavePort *>(&peer);
-    fatal_if(!slave_port, "Can't bind port %s to non-slave port %s.",
+    auto *response_port = dynamic_cast<ResponsePort *>(&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<Request>(
         a, 1, 0, Request::funcMasterId);
@@ -165,32 +166,32 @@
 /**
  * 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 eadf7f4..16ca5d7 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 @@
* 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 responder port to the requestor port.
      */
     void bind(Port &peer) override;

     /**
-     * Unbind this master port and the associated slave port.
+     * Unbind this requestor port and the associated responder port.
      */
     void unbind() override;

     /**
-     * Determine if this master port is snooping or not. The default
+     * Determine if this requestor 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 requestor port that wants to receive snoop
      * requests (e.g. a cache connected to a bus) has to override this
      * function.
      *
@@ -107,7 +110,7 @@
     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 @@
     /* 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 @@
     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
@@ -185,7 +188,7 @@
     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 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 recvRetrySnoop at which point it can
@@ -196,8 +199,8 @@
     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 responder port that previously attempted a
+     * sendTimingResp to this requestor 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 @@

   protected:
     /**
-     * Called to receive an address range change from the peer slave
+     * Called to receive an address range change from the peer responder
      * 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,29 @@
     }
 };

+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 specialisation 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 +275,25 @@
     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 requestor port is snooping or not.
      *
-     * @return true if the peer master port is snooping
+     * @return true if the peer requestor 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 +301,7 @@
     virtual AddrRangeList getAddrRanges() const = 0;

     /**
-     * We let the master port do the work, so these don't do anything.
+     * We let the requestor port do the work, so these don't do anything.
      */
     void unbind() override {}
     void bind(Port &peer) override {}
@@ -312,7 +322,7 @@
     sendAtomicSnoop(PacketPtr pkt)
     {
         try {
-            return AtomicResponseProtocol::sendSnoop(_masterPort, pkt);
+            return AtomicResponseProtocol::sendSnoop(_requestPort, pkt);
         } catch (UnboundPortException) {
             reportUnbound();
         }
@@ -332,7 +342,7 @@
     sendFunctionalSnoop(PacketPtr pkt) const
     {
         try {
-            FunctionalResponseProtocol::sendSnoop(_masterPort, pkt);
+            FunctionalResponseProtocol::sendSnoop(_requestPort, pkt);
         } catch (UnboundPortException) {
             reportUnbound();
         }
@@ -342,7 +352,7 @@
     /* The timing protocol. */

     /**
-     * Attempt to send a timing response to the master port by calling
+     * Attempt to send a timing response to the requestor 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
@@ -356,14 +366,14 @@
     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 requestor port
      * by calling its corresponding receive function. Snoop requests
      * always succeed and hence no return value is needed.
      *
@@ -373,35 +383,35 @@
     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 requestor 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 requestor 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 +419,16 @@

   protected:
     /**
-     * Called by the master port to unbind. Should never be called
+     * Called by the requestor port to unbind. Should never be called
      * directly.
      */
     void slaveUnbind();

     /**
-     * Called by the master port to bind. Should never be called
+     * Called by the requestor port to bind. Should never be called
      * directly.
      */
-    void slaveBind(MasterPort& master_port);
+    void slaveBind(RequestPort& request_port);

     /**
      * Default implementations.
@@ -438,71 +448,79 @@
     }
 };

+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();
     }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32308
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I5e6e90b2916df4dbfccdaabe97423f377a1f6e3f
Gerrit-Change-Number: 32308
Gerrit-PatchSet: 1
Gerrit-Owner: Shivani Parekh <shpar...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to