policy_fixed_prio.cc revision 12968
112598Snikos.nikoleris@arm.com/* 27090SN/A * Copyright (c) 2018 ARM Limited 37090SN/A * All rights reserved 47090SN/A * 57090SN/A * The license below extends only to copyright in the software and shall 67090SN/A * not be construed as granting a license to any other intellectual 77090SN/A * property including but not limited to intellectual property relating 87090SN/A * to a hardware implementation of the functionality of the software 97090SN/A * licensed hereunder. You may use the software subject to the license 107090SN/A * terms below provided that you ensure that this notice is replicated 117090SN/A * unmodified and in its entirety in all distributions of the software, 127090SN/A * modified or unmodified, in source code or in binary form. 134486SN/A * 144486SN/A * Redistribution and use in source and binary forms, with or without 154486SN/A * modification, are permitted provided that the following conditions are 164486SN/A * met: redistributions of source code must retain the above copyright 174486SN/A * notice, this list of conditions and the following disclaimer; 184486SN/A * redistributions in binary form must reproduce the above copyright 194486SN/A * notice, this list of conditions and the following disclaimer in the 204486SN/A * documentation and/or other materials provided with the distribution; 214486SN/A * neither the name of the copyright holders nor the names of its 224486SN/A * contributors may be used to endorse or promote products derived from 234486SN/A * this software without specific prior written permission. 244486SN/A * 254486SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 264486SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 274486SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 284486SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 294486SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 304486SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 314486SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 324486SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 334486SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 344486SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 354486SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 364486SN/A * 374486SN/A * Author: Matteo Andreozzi 384486SN/A */ 397584SAli.Saidi@arm.com 407584SAli.Saidi@arm.com#include "mem/qos/policy_fixed_prio.hh" 417754SWilliam.Wang@arm.com 4212472Sglenn.bergmans@arm.com#include <algorithm> 434486SN/A#include <functional> 4412472Sglenn.bergmans@arm.com 453630SN/A#include "mem/request.hh" 463630SN/A 4712472Sglenn.bergmans@arm.comnamespace QoS { 4813665Sandreas.sandberg@arm.com 4913665Sandreas.sandberg@arm.comFixedPriorityPolicy::FixedPriorityPolicy(const Params* p) 5013665Sandreas.sandberg@arm.com : Policy(p), defaultPriority(p->qos_fixed_prio_default_prio) 5113665Sandreas.sandberg@arm.com{} 5213665Sandreas.sandberg@arm.com 5313665Sandreas.sandberg@arm.comFixedPriorityPolicy::~FixedPriorityPolicy() 5413665Sandreas.sandberg@arm.com{} 5513665Sandreas.sandberg@arm.com 5613665Sandreas.sandberg@arm.comvoid 5713665Sandreas.sandberg@arm.comFixedPriorityPolicy::init() 5813665Sandreas.sandberg@arm.com{ 5913665Sandreas.sandberg@arm.com} 6013665Sandreas.sandberg@arm.com 6113665Sandreas.sandberg@arm.comvoid 6213665Sandreas.sandberg@arm.comFixedPriorityPolicy::initMasterName(std::string master, uint8_t priority) 6313665Sandreas.sandberg@arm.com{ 6413665Sandreas.sandberg@arm.com priorityMap.insert( 6513665Sandreas.sandberg@arm.com this->pair<std::string, uint8_t>(master, priority)); 6613665Sandreas.sandberg@arm.com} 6713665Sandreas.sandberg@arm.com 683630SN/Avoid 6911841Sandreas.sandberg@arm.comFixedPriorityPolicy::initMasterObj(const SimObject* master, uint8_t priority) 7011841Sandreas.sandberg@arm.com{ 7111841Sandreas.sandberg@arm.com priorityMap.insert( 7211841Sandreas.sandberg@arm.com this->pair<const SimObject*, uint8_t>(master, priority)); 7313665Sandreas.sandberg@arm.com} 7411841Sandreas.sandberg@arm.com 7511841Sandreas.sandberg@arm.comuint8_t 7611841Sandreas.sandberg@arm.comFixedPriorityPolicy::schedule(const MasterID mId, const uint64_t data) 7711841Sandreas.sandberg@arm.com{ 7813505Sgiacomo.travaglini@arm.com // Reads a packet's MasterID contained in its encapsulated request 7911841Sandreas.sandberg@arm.com // if a match is found in the configured priority map, returns the 8011841Sandreas.sandberg@arm.com // matching priority, else returns zero 819806Sstever@gmail.com 829806Sstever@gmail.com auto ret = priorityMap.find(mId); 837584SAli.Saidi@arm.com 849338SAndreas.Sandberg@arm.com if (ret != priorityMap.end()) { 857584SAli.Saidi@arm.com return ret->second; 863898SN/A } else { 879806Sstever@gmail.com DPRINTF(QOS, "Master %s (MasterID %d) not present in priorityMap, " 887950SAli.Saidi@ARM.com "assigning default priority %d\n", 897950SAli.Saidi@ARM.com memCtrl->system()->getMasterName(mId), 909338SAndreas.Sandberg@arm.com mId, defaultPriority); 919525SAndreas.Sandberg@ARM.com return defaultPriority; 927950SAli.Saidi@ARM.com } 937950SAli.Saidi@ARM.com} 947950SAli.Saidi@ARM.com 957950SAli.Saidi@ARM.com} // namespace QoS 967587SAli.Saidi@arm.com 977587SAli.Saidi@arm.comQoS::FixedPriorityPolicy * 987587SAli.Saidi@arm.comQoSFixedPriorityPolicyParams::create() 999338SAndreas.Sandberg@arm.com{ 1007753SWilliam.Wang@arm.com return new QoS::FixedPriorityPolicy(this); 1017753SWilliam.Wang@arm.com} 1029525SAndreas.Sandberg@ARM.com