internal unsafe NetMapReceiveRing(RxTxPair rxTxPair, byte *memoryRegion, long queueOffset, TPacketReceiver receiver, NetMapTransmitRing hostTxRing) : base(rxTxPair, memoryRegion, queueOffset) { _hostTxRing = hostTxRing; _receiver = receiver; _worker = new Thread(new ThreadStart(ThreadLoop)); }
protected NetMapRing(RxTxPair rxTxPair, byte *memoryRegion, long queueOffset) { _rxTxPair = rxTxPair; _queueOffset = queueOffset; _memoryRegion = memoryRegion; var ringInfo = RingInfo; _bufferSize = (int)ringInfo.BufferSize; _numberOfSlots = (int)ringInfo.NumberOfSlotsPerRing; _bufferStart = _memoryRegion + _queueOffset + ringInfo.BuffersOffset; _ringId = ringInfo.RingId; _rxRing = (NetmapSlot *)((long)(_memoryRegion + queueOffset + Unsafe.SizeOf <NetmapRing>() + 127 + 128) & (~0xFF)); }
private unsafe void SetupRings() { var txOffsets = new long[_netmapInterface.NumberOfTXRings]; var rxOffsets = new long[_netmapInterface.NumberOfRXRings]; _rxTxPairs = new RxTxPair[txOffsets.Length + 1]; var span = new Span <long>(IntPtr.Add(NetMapInterfaceAddress, Unsafe.SizeOf <NetMapInterface>()).ToPointer(), _netmapInterface.NumberOfRXRings + _netmapInterface.NumberOfTXRings + 2); for (var i = 0; i < txOffsets.Length; i++) { txOffsets[i] = span[0]; span = span.Slice(1); _rxTxPairs[i] = new RxTxPair(_interfaceName, i, false); } _rxTxPairs[txOffsets.Length] = new RxTxPair(_interfaceName, txOffsets.Length, true); var txHost = span[0]; span = span.Slice(1); for (var i = 0; i < rxOffsets.Length; i++) { rxOffsets[i] = span[0]; span = span.Slice(1); } var rxHost = span[0]; _hostTxRing = new NetMapTransmitRing(_rxTxPairs[_rxTxPairs.Length - 1], (byte *)_mappedRegion.ToPointer(), txHost); _allRings.Add(_hostTxRing); _transmitRings = new NetMapTransmitRing[txOffsets.Length]; _receiveRings = new NetMapReceiveRing <TPacketReceiver> [rxOffsets.Length]; for (var i = 0; i < txOffsets.Length; i++) { _transmitRings[i] = new NetMapTransmitRing(_rxTxPairs[i], (byte *)_mappedRegion.ToPointer(), txOffsets[i]); _allRings.Add(_transmitRings[i]); _receiveRings[i] = new NetMapReceiveRing <TPacketReceiver>(_rxTxPairs[i], (byte *)_mappedRegion.ToPointer(), rxOffsets[i], _createReceiver(_transmitRings[i]), _hostTxRing); _allRings.Add(_receiveRings[i]); } _hostRxRing = new NetMapHostRxRing(_rxTxPairs[_rxTxPairs.Length - 1], (byte *)_mappedRegion.ToPointer(), rxHost, _transmitRings[0]); _allRings.Add(_hostRxRing); }
internal unsafe NetMapHostRxRing(RxTxPair rxTxPair, byte *memoryRegion, long rxQueueOffset, NetMapTransmitRing transmitRing) : base(rxTxPair, memoryRegion, rxQueueOffset) { _transmitRing = transmitRing; _worker = new Thread(new ThreadStart(ThreadLoop)); }