114185Sgabeblack@google.com/*
214185Sgabeblack@google.com * Copyright (c) 2011-2012,2015,2017 ARM Limited
314185Sgabeblack@google.com * All rights reserved
414185Sgabeblack@google.com *
514185Sgabeblack@google.com * The license below extends only to copyright in the software and shall
614185Sgabeblack@google.com * not be construed as granting a license to any other intellectual
714185Sgabeblack@google.com * property including but not limited to intellectual property relating
814185Sgabeblack@google.com * to a hardware implementation of the functionality of the software
914185Sgabeblack@google.com * licensed hereunder.  You may use the software subject to the license
1014185Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated
1114185Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software,
1214185Sgabeblack@google.com * modified or unmodified, in source code or in binary form.
1314185Sgabeblack@google.com *
1414185Sgabeblack@google.com * Copyright (c) 2002-2005 The Regents of The University of Michigan
1514185Sgabeblack@google.com * All rights reserved.
1614185Sgabeblack@google.com *
1714185Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
1814185Sgabeblack@google.com * modification, are permitted provided that the following conditions are
1914185Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
2014185Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
2114185Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
2214185Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
2314185Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
2414185Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
2514185Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
2614185Sgabeblack@google.com * this software without specific prior written permission.
2714185Sgabeblack@google.com *
2814185Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2914185Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3014185Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3114185Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3214185Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3314185Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3414185Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3514185Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3614185Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3714185Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3814185Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3914185Sgabeblack@google.com *
4014185Sgabeblack@google.com * Authors: Ron Dreslinski
4114185Sgabeblack@google.com *          Andreas Hansson
4214185Sgabeblack@google.com *          William Wang
4314185Sgabeblack@google.com */
4414185Sgabeblack@google.com
4514185Sgabeblack@google.com#ifndef __MEM_GEM5_PROTOCOL_TIMING_HH__
4614185Sgabeblack@google.com#define __MEM_GEM5_PROTOCOL_TIMING_HH__
4714185Sgabeblack@google.com
4814185Sgabeblack@google.com#include "mem/packet.hh"
4914185Sgabeblack@google.com
5014185Sgabeblack@google.comclass TimingResponseProtocol;
5114185Sgabeblack@google.com
5214185Sgabeblack@google.comclass TimingRequestProtocol
5314185Sgabeblack@google.com{
5414185Sgabeblack@google.com    friend class TimingResponseProtocol;
5514185Sgabeblack@google.com
5614185Sgabeblack@google.com  protected:
5714185Sgabeblack@google.com    /**
5814185Sgabeblack@google.com     * Attempt to send a timing request to the peer by calling
5914185Sgabeblack@google.com     * its corresponding receive function. If the send does not
6014185Sgabeblack@google.com     * succeed, as indicated by the return value, then the sender must
6114185Sgabeblack@google.com     * wait for a recvReqRetry at which point it can re-issue a
6214185Sgabeblack@google.com     * sendTimingReq.
6314185Sgabeblack@google.com     *
6414185Sgabeblack@google.com     * @param peer Peer to send packet to.
6514185Sgabeblack@google.com     * @param pkt Packet to send.
6614185Sgabeblack@google.com     *
6714185Sgabeblack@google.com     * @return If the send was succesful or not.
6814185Sgabeblack@google.com     */
6914185Sgabeblack@google.com    bool sendReq(TimingResponseProtocol *peer, PacketPtr pkt);
7014185Sgabeblack@google.com
7114185Sgabeblack@google.com    /**
7214185Sgabeblack@google.com     * Check if the peer can handle a timing request.
7314185Sgabeblack@google.com     *
7414185Sgabeblack@google.com     * If the send cannot be handled at the moment, as indicated by
7514185Sgabeblack@google.com     * the return value, then the sender will receive a recvReqRetry
7614185Sgabeblack@google.com     * at which point it can re-issue a sendTimingReq.
7714185Sgabeblack@google.com     *
7814185Sgabeblack@google.com     * @param peer Peer to send packet to.
7914185Sgabeblack@google.com     * @param pkt Packet to send.
8014185Sgabeblack@google.com     *
8114185Sgabeblack@google.com     * @return If the send was succesful or not.
8214185Sgabeblack@google.com     */
8314185Sgabeblack@google.com    bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const;
8414185Sgabeblack@google.com
8514185Sgabeblack@google.com    /**
8614185Sgabeblack@google.com     * Attempt to send a timing snoop response packet to it's peer
8714185Sgabeblack@google.com     * by calling its corresponding receive function. If the send
8814185Sgabeblack@google.com     * does not succeed, as indicated by the return value, then the
8914185Sgabeblack@google.com     * sender must wait for a recvRetrySnoop at which point it can
9014185Sgabeblack@google.com     * re-issue a sendTimingSnoopResp.
9114185Sgabeblack@google.com     *
9214185Sgabeblack@google.com     * @param pkt Packet to send.
9314185Sgabeblack@google.com     */
9414185Sgabeblack@google.com    bool sendSnoopResp(TimingResponseProtocol *peer, PacketPtr pkt);
9514185Sgabeblack@google.com
9614185Sgabeblack@google.com    /**
9714185Sgabeblack@google.com     * Send a retry to the peer that previously attempted a
9814185Sgabeblack@google.com     * sendTimingResp to this protocol and failed.
9914185Sgabeblack@google.com     */
10014185Sgabeblack@google.com    void sendRetryResp(TimingResponseProtocol *peer);
10114185Sgabeblack@google.com
10214185Sgabeblack@google.com    /**
10314185Sgabeblack@google.com     * Receive a timing response from the peer.
10414185Sgabeblack@google.com     */
10514185Sgabeblack@google.com    virtual bool recvTimingResp(PacketPtr pkt) = 0;
10614185Sgabeblack@google.com
10714185Sgabeblack@google.com    /**
10814185Sgabeblack@google.com     * Receive a timing snoop request from the peer.
10914185Sgabeblack@google.com     */
11014185Sgabeblack@google.com    virtual void recvTimingSnoopReq(PacketPtr pkt) = 0;
11114185Sgabeblack@google.com
11214185Sgabeblack@google.com    /**
11314185Sgabeblack@google.com     * Called by the peer if sendTimingReq was called on this peer (causing
11414185Sgabeblack@google.com     * recvTimingReq to be called on the peer) and was unsuccessful.
11514185Sgabeblack@google.com     */
11614185Sgabeblack@google.com    virtual void recvReqRetry() = 0;
11714185Sgabeblack@google.com
11814185Sgabeblack@google.com    /**
11914185Sgabeblack@google.com     * Called by the peer if sendTimingSnoopResp was called on this
12014185Sgabeblack@google.com     * protocol (causing recvTimingSnoopResp to be called on the peer)
12114185Sgabeblack@google.com     * and was unsuccessful.
12214185Sgabeblack@google.com     */
12314185Sgabeblack@google.com    virtual void recvRetrySnoopResp() = 0;
12414185Sgabeblack@google.com};
12514185Sgabeblack@google.com
12614185Sgabeblack@google.comclass TimingResponseProtocol
12714185Sgabeblack@google.com{
12814185Sgabeblack@google.com    friend class TimingRequestProtocol;
12914185Sgabeblack@google.com
13014185Sgabeblack@google.com  protected:
13114185Sgabeblack@google.com    /**
13214185Sgabeblack@google.com     * Attempt to send a timing response to the peer by calling
13314185Sgabeblack@google.com     * its corresponding receive function. If the send does not
13414185Sgabeblack@google.com     * succeed, as indicated by the return value, then the sender must
13514185Sgabeblack@google.com     * wait for a recvRespRetry at which point it can re-issue a
13614185Sgabeblack@google.com     * sendTimingResp.
13714185Sgabeblack@google.com     *
13814185Sgabeblack@google.com     * @param peer Peer to send the packet to.
13914185Sgabeblack@google.com     * @param pkt Packet to send.
14014185Sgabeblack@google.com     *
14114185Sgabeblack@google.com     * @return If the send was succesful or not.
14214185Sgabeblack@google.com    */
14314185Sgabeblack@google.com    bool sendResp(TimingRequestProtocol *peer, PacketPtr pkt);
14414185Sgabeblack@google.com
14514185Sgabeblack@google.com    /**
14614185Sgabeblack@google.com     * Attempt to send a timing snoop request packet to the peer
14714185Sgabeblack@google.com     * by calling its corresponding receive function. Snoop requests
14814185Sgabeblack@google.com     * always succeed and hence no return value is needed.
14914185Sgabeblack@google.com     *
15014185Sgabeblack@google.com     * @param peer Peer to send the packet to.
15114185Sgabeblack@google.com     * @param pkt Packet to send.
15214185Sgabeblack@google.com     */
15314185Sgabeblack@google.com    void sendSnoopReq(TimingRequestProtocol *peer, PacketPtr pkt);
15414185Sgabeblack@google.com
15514185Sgabeblack@google.com    /**
15614185Sgabeblack@google.com     * Send a retry to the peer that previously attempted a
15714185Sgabeblack@google.com     * sendTimingReq to this protocol and failed.
15814185Sgabeblack@google.com     */
15914185Sgabeblack@google.com    void sendRetryReq(TimingRequestProtocol *peer);
16014185Sgabeblack@google.com
16114185Sgabeblack@google.com    /**
16214185Sgabeblack@google.com     * Send a retry to the peer that previously attempted a
16314185Sgabeblack@google.com     * sendTimingSnoopResp to this peer and failed.
16414185Sgabeblack@google.com     */
16514185Sgabeblack@google.com    void sendRetrySnoopResp(TimingRequestProtocol *peer);
16614185Sgabeblack@google.com
16714185Sgabeblack@google.com    /**
16814185Sgabeblack@google.com     * Receive a timing request from the peer.
16914185Sgabeblack@google.com     */
17014185Sgabeblack@google.com    virtual bool recvTimingReq(PacketPtr pkt) = 0;
17114185Sgabeblack@google.com
17214185Sgabeblack@google.com    /**
17314185Sgabeblack@google.com     * Availability request from the peer.
17414185Sgabeblack@google.com     */
17514185Sgabeblack@google.com    virtual bool tryTiming(PacketPtr pkt) = 0;
17614185Sgabeblack@google.com
17714185Sgabeblack@google.com    /**
17814185Sgabeblack@google.com     * Receive a timing snoop response from the peer.
17914185Sgabeblack@google.com     */
18014185Sgabeblack@google.com    virtual bool recvTimingSnoopResp(PacketPtr pkt) = 0;
18114185Sgabeblack@google.com
18214185Sgabeblack@google.com    /**
18314185Sgabeblack@google.com     * Called by the peer if sendTimingResp was called on this
18414185Sgabeblack@google.com     * protocol (causing recvTimingResp to be called on the peer)
18514185Sgabeblack@google.com     * and was unsuccessful.
18614185Sgabeblack@google.com     */
18714185Sgabeblack@google.com    virtual void recvRespRetry() = 0;
18814185Sgabeblack@google.com};
18914185Sgabeblack@google.com
19014185Sgabeblack@google.com#endif //__MEM_GEM5_PROTOCOL_TIMING_HH__
191