From b7b8ffa7b7800505f7008927bb3679a0ba9d5374 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 21 Oct 2005 20:28:21 -0400 Subject: Major changes to sinic device model. Rearrage read/write, better interrupts. dev/sinic.cc: - The prepareRead function sets all the variables in the register file that depend on various state bits that change on the fly. Includes RxDone, RxWait, TxDone, and TxWait - Use the new register information accessor functions to grab validity and size information for the read and write functions - read all registers directly from the register space by offset and size, not by actual name (less code) - The side effect of reading the interrupt status (clearing it) now happens outside the actual chunk of code where the value is loaded. - Add an iprRead function for when we may want speculative access to device registers through an ipr or special instruction. - When RxData or TxData are written, their busy flag is set to indicate that they have an outstanding transaction. - The RxHigh and TxLow interrupts are special, they only interrupt if the rxEmpty or txFull limits were hit - Move reset to the command register - Update more registers on reset, clear rxEmpty and txFull - Data dumps only happen if EthernetData trace flag set - When a DMA completes, kick the other engine if it was waiting - implement all of the new interrupts - serialize the new stuff dev/sinic.hh: - Put all registers with their proper size and alignment into the regs struct so that we can copy multiple at a time. - Provide accessor functions for accessing the registers with different sizes. - Flags to track when the rx fifo hit empty and the tx fifo became full. These flags are used to determine what to do when below the watermarks, and are reset when crossing the watermark. - the txDmaEvent should actually trigger the txDmaDone function - Add an iprRead function for when we may want speculative access to device registers through an ipr or special instruction. - The prepareRead function sets all the variables in the register file that depend on various state bits that change on the fly. - add rx_max_intr and dedicated (for dedicated thread) config params dev/sinicreg.hh: Add some new registers: Command, RxMaxIntr, RxFifoSize, TxFifoSize, rename XxThreshold to XxFifoMark Move Reset to the Command register Add Thread to the Config register New interrupts, better names More info in RxDone and TxDone Easier access to information on each register (size, read, write, name) python/m5/objects/Ethernet.py: Both sinic and nsgige have the dedicated thread Add a parameter to configure the maximum number for receive packets per interrupt --HG-- extra : convert_revision : 407c5a993b6fb17326b4c623ee5d4b25fd69ac80 --- python/m5/objects/Ethernet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/m5/objects/Ethernet.py b/python/m5/objects/Ethernet.py index c2f818325..a97e58bda 100644 --- a/python/m5/objects/Ethernet.py +++ b/python/m5/objects/Ethernet.py @@ -83,6 +83,7 @@ class EtherDevBase(PciDevice): rx_filter = Param.Bool(True, "Enable Receive Filter") intr_delay = Param.Latency('10us', "Interrupt Propagation Delay") + dedicated = Param.Bool(False, "dedicate a kernel thread to the driver") class NSGigE(EtherDevBase): type = 'NSGigE' @@ -90,7 +91,6 @@ class NSGigE(EtherDevBase): dma_data_free = Param.Bool(False, "DMA of Data is free") dma_desc_free = Param.Bool(False, "DMA of Descriptors is free") - dedicated = Param.Bool(False, "dedicate a kernel thread to the driver") class NSGigEInt(EtherInt): type = 'NSGigEInt' @@ -101,6 +101,7 @@ class Sinic(EtherDevBase): rx_max_copy = Param.MemorySize('1514B', "rx max copy") tx_max_copy = Param.MemorySize('16kB', "tx max copy") + rx_max_intr = Param.UInt32(10, "max rx packets per interrupt") rx_fifo_threshold = Param.MemorySize('48kB', "rx fifo high threshold") tx_fifo_threshold = Param.MemorySize('16kB', "tx fifo low threshold") -- cgit v1.2.3 From fb4f83809fd8a427503b109848ca7c8f3c179e8c Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 1 Nov 2005 14:11:54 -0500 Subject: Allow math on CheckedInt-derived ParamValue classes w/o losing type information. python/m5/config.py: Allow math on CheckedInt-derived ParamValue classes w/o losing type information. - Make CheckedInt derive from NumericParamValue, and *not* multiply inherit from long - Move CheckedInt bounds check to _check() hook so we can call it when value is updated (not just in constructor) python/m5/convert.py: - make toInteger() return a long, making toLong() unnecessary - toMemorySize should return long rather than float --HG-- extra : convert_revision : c1cf5e15b9ff35d9b573dd545e076fe68afef989 --- python/m5/config.py | 102 +++++++++++++++++++++++++++++++-------------------- python/m5/convert.py | 22 ++++------- 2 files changed, 69 insertions(+), 55 deletions(-) (limited to 'python') diff --git a/python/m5/config.py b/python/m5/config.py index 3c49421d3..86acb75f8 100644 --- a/python/m5/config.py +++ b/python/m5/config.py @@ -825,6 +825,40 @@ VectorParam = ParamFactory(VectorParamDesc) # ##################################################################### +# superclass for "numeric" parameter values, to emulate math +# operations in a type-safe way. e.g., a Latency times an int returns +# a new Latency object. +class NumericParamValue(ParamValue): + def __str__(self): + return str(self.value) + + def __float__(self): + return float(self.value) + + # hook for bounds checking + def _check(self): + return + + def __mul__(self, other): + newobj = self.__class__(self) + newobj.value *= other + newobj._check() + return newobj + + __rmul__ = __mul__ + + def __div__(self, other): + newobj = self.__class__(self) + newobj.value /= other + newobj._check() + return newobj + + def __sub__(self, other): + newobj = self.__class__(self) + newobj.value -= other + newobj._check() + return newobj + class Range(ParamValue): type = int # default; can be overridden in subclasses def __init__(self, *args, **kwargs): @@ -891,18 +925,20 @@ class CheckedIntType(type): # class is subclassed to generate parameter classes with specific # bounds. Initialization of the min and max bounds is done in the # metaclass CheckedIntType.__init__. -class CheckedInt(long,ParamValue): +class CheckedInt(NumericParamValue): __metaclass__ = CheckedIntType - def __new__(cls, value): - if isinstance(value, str): - value = toInteger(value) - - self = long.__new__(cls, value) - - if not cls.min <= self <= cls.max: + def _check(self): + if not self.min <= self.value <= self.max: raise TypeError, 'Integer param out of bounds %d < %d < %d' % \ - (cls.min, self, cls.max) + (self.min, self.value, self.max) + + def __init__(self, value): + if isinstance(value, str): + self.value = toInteger(value) + elif isinstance(value, (int, long)): + self.value = long(value) + self._check() return self class Int(CheckedInt): size = 32; unsigned = False @@ -930,19 +966,28 @@ class Float(ParamValue, float): class MemorySize(CheckedInt): size = 64 unsigned = True - def __new__(cls, value): - return super(MemorySize, cls).__new__(cls, toMemorySize(value)) + def __init__(self, value): + if isinstance(value, MemorySize): + self.value = value.value + else: + self.value = toMemorySize(value) + self._check() + return self class Addr(CheckedInt): size = 64 unsigned = True - def __new__(cls, value): - try: - value = long(toMemorySize(value)) - except TypeError: - value = long(value) - return super(Addr, cls).__new__(cls, value) + def __init__(self, value): + if isinstance(value, Addr): + self.value = value.value + else: + try: + self.value = toMemorySize(value) + except TypeError: + self.value = long(value) + self._check() + return self class AddrRange(Range): type = Addr @@ -1123,29 +1168,6 @@ def tick_check(float_ticks): #raise ValueError return int_ticks -# superclass for "numeric" parameter values, to emulate math -# operations in a type-safe way. e.g., a Latency times an int returns -# a new Latency object. -class NumericParamValue(ParamValue): - def __str__(self): - return str(self.value) - - def __float__(self): - return float(self.value) - - def __mul__(self, other): - newobj = self.__class__(self) - newobj.value *= other - return newobj - - __rmul__ = __mul__ - - def __div__(self, other): - newobj = self.__class__(self) - newobj.value /= other - return newobj - - def getLatency(value): if isinstance(value, Latency) or isinstance(value, Clock): return value.value diff --git a/python/m5/convert.py b/python/m5/convert.py index 9d9f4efa7..73181e985 100644 --- a/python/m5/convert.py +++ b/python/m5/convert.py @@ -89,17 +89,9 @@ def toFloat(value): else: return float(value) -def toLong(value): - value = toFloat(value) - result = int(value) - if value != result: - raise ValueError, "cannot convert '%s' to long" % value - - return result - def toInteger(value): value = toFloat(value) - result = int(value) + result = long(value) if value != result: raise ValueError, "cannot convert '%s' to integer" % value @@ -220,16 +212,16 @@ def toMemorySize(value): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('PB'): - return float(value[:-2]) * pebi + return long(value[:-2]) * pebi elif value.endswith('TB'): - return float(value[:-2]) * tebi + return long(value[:-2]) * tebi elif value.endswith('GB'): - return float(value[:-2]) * gibi + return long(value[:-2]) * gibi elif value.endswith('MB'): - return float(value[:-2]) * mebi + return long(value[:-2]) * mebi elif value.endswith('kB'): - return float(value[:-2]) * kibi + return long(value[:-2]) * kibi elif value.endswith('B'): - return float(value[:-1]) + return long(value[:-1]) raise ValueError, "cannot convert '%s' to memory size" % value -- cgit v1.2.3 From d238b6be9de143be6b1e1286e6040cbfc0085fd0 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 2 Nov 2005 10:20:39 -0500 Subject: Make vector params interact with proxies properly. --HG-- extra : convert_revision : a4067f07d71d2adc1ccbf4512a43ceee7b5cc3de --- python/m5/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') diff --git a/python/m5/config.py b/python/m5/config.py index 86acb75f8..33f3f5843 100644 --- a/python/m5/config.py +++ b/python/m5/config.py @@ -755,7 +755,7 @@ class ParamDesc(object): class VectorParamValue(list): def ini_str(self): - return ' '.join([str(v) for v in self]) + return ' '.join([v.ini_str() for v in self]) def unproxy(self, base): return [v.unproxy(base) for v in self] -- cgit v1.2.3 From dd46db1cb995ae2378b5331b78ec6606aec771d6 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 2 Nov 2005 12:14:26 -0500 Subject: __init__ should not return anything --HG-- extra : convert_revision : fb46eee741f4899d76bcf927523fa151d002decf --- python/m5/config.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'python') diff --git a/python/m5/config.py b/python/m5/config.py index 33f3f5843..e1970e672 100644 --- a/python/m5/config.py +++ b/python/m5/config.py @@ -939,7 +939,6 @@ class CheckedInt(NumericParamValue): elif isinstance(value, (int, long)): self.value = long(value) self._check() - return self class Int(CheckedInt): size = 32; unsigned = False class Unsigned(CheckedInt): size = 32; unsigned = True @@ -972,7 +971,6 @@ class MemorySize(CheckedInt): else: self.value = toMemorySize(value) self._check() - return self class Addr(CheckedInt): @@ -987,7 +985,6 @@ class Addr(CheckedInt): except TypeError: self.value = long(value) self._check() - return self class AddrRange(Range): type = Addr -- cgit v1.2.3