NetworkInterface.hh revision 11762:29d401db3746
1/* 2 * Copyright (c) 2008 Princeton University 3 * Copyright (c) 2016 Georgia Institute of Technology 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * Authors: Niket Agarwal 30 * Tushar Krishna 31 */ 32 33 34#ifndef __MEM_RUBY_NETWORK_GARNET_NETWORK_INTERFACE_HH__ 35#define __MEM_RUBY_NETWORK_GARNET_NETWORK_INTERFACE_HH__ 36 37#include <iostream> 38#include <vector> 39 40#include "mem/ruby/common/Consumer.hh" 41#include "mem/ruby/network/garnet2.0/CommonTypes.hh" 42#include "mem/ruby/network/garnet2.0/CreditLink.hh" 43#include "mem/ruby/network/garnet2.0/GarnetNetwork.hh" 44#include "mem/ruby/network/garnet2.0/NetworkLink.hh" 45#include "mem/ruby/network/garnet2.0/OutVcState.hh" 46#include "mem/ruby/slicc_interface/Message.hh" 47#include "params/GarnetNetworkInterface.hh" 48 49class MessageBuffer; 50class flitBuffer; 51 52class NetworkInterface : public ClockedObject, public Consumer 53{ 54 public: 55 typedef GarnetNetworkInterfaceParams Params; 56 NetworkInterface(const Params *p); 57 ~NetworkInterface(); 58 59 void init(); 60 61 void addInPort(NetworkLink *in_link, CreditLink *credit_link); 62 void addOutPort(NetworkLink *out_link, CreditLink *credit_link, 63 SwitchID router_id); 64 65 void wakeup(); 66 void addNode(std::vector<MessageBuffer *> &inNode, 67 std::vector<MessageBuffer *> &outNode); 68 69 void print(std::ostream& out) const; 70 int get_vnet(int vc); 71 int get_router_id() { return m_router_id; } 72 void init_net_ptr(GarnetNetwork *net_ptr) { m_net_ptr = net_ptr; } 73 74 uint32_t functionalWrite(Packet *); 75 76 private: 77 GarnetNetwork *m_net_ptr; 78 const NodeID m_id; 79 const int m_virtual_networks, m_vc_per_vnet, m_num_vcs; 80 int m_router_id; // id of my router 81 std::vector<OutVcState *> m_out_vc_state; 82 std::vector<int> m_vc_allocator; 83 int m_vc_round_robin; // For round robin scheduling 84 flitBuffer *outFlitQueue; // For modeling link contention 85 flitBuffer *outCreditQueue; 86 int m_deadlock_threshold; 87 88 NetworkLink *inNetLink; 89 NetworkLink *outNetLink; 90 CreditLink *inCreditLink; 91 CreditLink *outCreditLink; 92 93 // Input Flit Buffers 94 // The flit buffers which will serve the Consumer 95 std::vector<flitBuffer *> m_ni_out_vcs; 96 std::vector<Cycles> m_ni_out_vcs_enqueue_time; 97 98 // The Message buffers that takes messages from the protocol 99 std::vector<MessageBuffer *> inNode_ptr; 100 // The Message buffers that provides messages to the protocol 101 std::vector<MessageBuffer *> outNode_ptr; 102 // When a vc stays busy for a long time, it indicates a deadlock 103 std::vector<int> vc_busy_counter; 104 105 bool flitisizeMessage(MsgPtr msg_ptr, int vnet); 106 int calculateVC(int vnet); 107 void scheduleOutputLink(); 108 void checkReschedule(); 109}; 110 111#endif // __MEM_RUBY_NETWORK_GARNET_NETWORK_INTERFACE_HH__ 112