changeset fc4c90a7d2f5 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=fc4c90a7d2f5
description:
        mem: Relax packet src/dest check and shift onus to crossbar

        This patch allows objects to get the src/dest of a packet even if it
        is not set to a valid port id. This simplifies (ab)using the bridge as
        a buffer and latency adapter in situations where the neighbouring
        MemObjects are not crossbars.

        The checks that were done in the packet are now shifted to the
        crossbar where the fields are used to index into the port
        arrays. Thus, the carrier of the information is not burdened with
        checking, and the crossbar can check not only that the destination is
        set, but also that the port index is within limits.

diffstat:

 src/mem/bridge.cc           |  5 ++---
 src/mem/coherent_xbar.cc    |  5 +++++
 src/mem/noncoherent_xbar.cc |  2 ++
 src/mem/packet.hh           |  6 ++----
 4 files changed, 11 insertions(+), 7 deletions(-)

diffs (84 lines):

diff -r c848de089432 -r fc4c90a7d2f5 src/mem/bridge.cc
--- a/src/mem/bridge.cc Tue Dec 02 06:07:54 2014 -0500
+++ b/src/mem/bridge.cc Tue Dec 02 06:07:56 2014 -0500
@@ -242,9 +242,8 @@
     pkt->setDest(req_state->origSrc);
     delete req_state;
 
-    // the bridge assumes that at least one crossbar has set the
-    // destination field of the packet
-    assert(pkt->isDestValid());
+    // the bridge sets the destination irrespective of it is valid or
+    // not, as it is checked in the crossbar
     DPRINTF(Bridge, "response, new dest %d\n", pkt->getDest());
 
     // If we're about to put this packet at the head of the queue, we
diff -r c848de089432 -r fc4c90a7d2f5 src/mem/coherent_xbar.cc
--- a/src/mem/coherent_xbar.cc  Tue Dec 02 06:07:54 2014 -0500
+++ b/src/mem/coherent_xbar.cc  Tue Dec 02 06:07:56 2014 -0500
@@ -272,6 +272,8 @@
 
     // determine the destination based on what is stored in the packet
     PortID slave_port_id = pkt->getDest();
+    assert(slave_port_id != InvalidPortID);
+    assert(slave_port_id < respLayers.size());
 
     // test if the crossbar should be considered occupied for the
     // current port
@@ -369,6 +371,7 @@
 
     // get the destination from the packet
     PortID dest_port_id = pkt->getDest();
+    assert(dest_port_id != InvalidPortID);
 
     // determine if the response is from a snoop request we
     // created as the result of a normal request (in which case it
@@ -382,6 +385,7 @@
     // is being passed on as a normal response since this is occupying
     // the response layer rather than the snoop response layer
     if (forwardAsSnoop) {
+        assert(dest_port_id < snoopLayers.size());
         if (!snoopLayers[dest_port_id]->tryTiming(src_port)) {
             DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n",
                     src_port->name(), pkt->cmdString(), pkt->getAddr());
@@ -390,6 +394,7 @@
     } else {
         // get the master port that mirrors this slave port internally
         MasterPort* snoop_port = snoopRespPorts[slave_port_id];
+        assert(dest_port_id < respLayers.size());
         if (!respLayers[dest_port_id]->tryTiming(snoop_port)) {
             DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n",
                     snoop_port->name(), pkt->cmdString(), pkt->getAddr());
diff -r c848de089432 -r fc4c90a7d2f5 src/mem/noncoherent_xbar.cc
--- a/src/mem/noncoherent_xbar.cc       Tue Dec 02 06:07:54 2014 -0500
+++ b/src/mem/noncoherent_xbar.cc       Tue Dec 02 06:07:56 2014 -0500
@@ -171,6 +171,8 @@
 
     // determine the destination based on what is stored in the packet
     PortID slave_port_id = pkt->getDest();
+    assert(slave_port_id != InvalidPortID);
+    assert(slave_port_id < respLayers.size());
 
     // test if the layer should be considered occupied for the current
     // port
diff -r c848de089432 -r fc4c90a7d2f5 src/mem/packet.hh
--- a/src/mem/packet.hh Tue Dec 02 06:07:54 2014 -0500
+++ b/src/mem/packet.hh Tue Dec 02 06:07:56 2014 -0500
@@ -544,15 +544,13 @@
     bool hadBadAddress() const { return cmd == MemCmd::BadAddressError; }
     void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
 
-    bool isSrcValid() const { return src != InvalidPortID; }
     /// Accessor function to get the source index of the packet.
-    PortID getSrc() const { assert(isSrcValid()); return src; }
+    PortID getSrc() const { return src; }
     /// Accessor function to set the source index of the packet.
     void setSrc(PortID _src) { src = _src; }
 
-    bool isDestValid() const { return dest != InvalidPortID; }
     /// Accessor function for the destination index of the packet.
-    PortID getDest() const { assert(isDestValid()); return dest; }
+    PortID getDest() const { return dest; }
     /// Accessor function to set the destination index of the packet.
     void setDest(PortID _dest) { dest = _dest; }
     /// Reset destination field, e.g. to turn a response into a request again.
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to