private void TxExchange() { int toCount = 0; int fromCount = 0; NicDeviceContract /*.Imp*/ imp = (NicDeviceContract)nicChannel.Acquire(); try { PacketFifo src = this.txFifo.Acquire(); PacketFifo free = this.txFreeFifo.Acquire(); toCount = src.Count; try { src = imp.GiveTxPacketsToDevice(src); fromCount = src.Count; free.Push(src); } finally { this.txFreeFifo.Release(free); this.txFifo.Release(src); } } catch (Exception e) { DebugStub.Print("TxExchange FAILED arg {0}\n", DebugStub.ArgList(e.ToString())); DebugStub.Break(); } finally { nicChannel.Release(imp); } DebugPrint("TxExchange out: {0} in: {1}\n", toCount, fromCount); }
public Nic(NicDeviceContract /*.Imp*/ nicImp, NicDeviceProperties np, string nicName) { this.nicChannel = new TRef(nicImp); //assume np.DriverName != null; //assume np.MacAddress != null; this.driverName = np.DriverName; this.driverVersion = np.DriverName; this.macAddress = np.MacAddress; this.nicName = nicName; this.mtu = np.MtuBytes; this.maxTxPacketsInDevice = np.MaxTxPacketsInDevice; this.maxRxPacketsInDevice = np.MaxRxPacketsInDevice; this.maxTxFragmentsPerPacket = np.MaxTxFragmentsPerPacket; this.maxRxFragmentsPerPacket = np.MaxRxFragmentsPerPacket; this.muxEvent = new AutoResetEvent(false); // The following attributes are both integers yet // sgc is complaining it doesn't know to use // Math.Min(sbyte, sbyte) or Math.Min(byte, byte). int rxFifoSize = Math.Min(np.MaxRxPacketsInDevice, (int)Nic.MaxRxPacketsInDevice); this.rxFifo = new ExRefPacketFifo( new PacketFifo(rxFifoSize), false ); // The following attributes are both integers yet // sgc is complaining it doesn't know to use // Math.Min(sbyte, sbyte) or Math.Min(byte, byte). int txFifoSize = Math.Min(np.MaxTxPacketsInDevice, (int)Nic.MaxTxPacketsInDevice); this.txFifo = new ExRefPacketFifo( new PacketFifo(txFifoSize), true ); this.txFreeFifo = new ExRefPacketFifo( new PacketFifo(txFifoSize), true ); this.txCoalesceFifo = new ExRefPacketFifo( new PacketFifo(txFifoSize), true ); TxProvision(); RxProvision(); }
private void RxExchange() { NicDeviceContract /*.Imp*/ imp = (NicDeviceContract)nicChannel.Acquire(); try { RxExchangeInternal(imp); } finally { this.nicChannel.Release(imp); } }
private bool StopIO() { NicDeviceContract /*.Imp*/ imp = (NicDeviceContract)nicChannel.Acquire(); try { imp.StopIO(); return(true); } finally { nicChannel.Release(imp); } //return false; }
private bool StartIO() { NicDeviceContract /*.Imp*/ imp = (NicDeviceContract)nicChannel.Acquire(); try { imp.StartIO(); RxExchangeInternal(imp); return(true); } finally { nicChannel.Release(imp); } //DebugStub.Break(); //return false; }
//XXX On the first exchange we receive an empty fifo from the Nic //We fill it here...this should be special cased in the startio //routine... private void RxExchangeInternal(NicDeviceContract /*.Imp*/ imp) { int toCount, fromCount; PacketFifo exFifo = this.rxFifo.Acquire(); toCount = exFifo.Count; try { exFifo = imp.GiveRxPacketsToDevice(exFifo); fromCount = exFifo.Count; } finally { this.rxFifo.Release(exFifo); } DebugPrint("RxExchange out: {0} in: {1}\n", toCount, fromCount); }
CreateAndRegister(NicDeviceContract /*.Imp*/ imp, string nicName) { Nic nic = null; try { //imp.RecvSuccess(); DebugPrint("Nic channel transition\n"); NicDeviceProperties np = GetNicProperties(imp); if (np == null) { //delete imp; return(false); } nic = new Nic(imp, np, nicName); //delete np; if (nic.Configure() == false) { return(false); } DebugPrint("Nic.cs: Register adapter\n"); HostConfiguration hostConfiguration = IP.GetHostConfiguration(); // nic.filterAdapter= null; #if false nic.filterAdapter = new FilterAdapter(nic); hostConfiguration.RegisterAdapter(nic.filterAdapter); #endif hostConfiguration.RegisterAdapter(nic); nic.StartIO(); Thread muxThread = new Thread(nic); muxThread.Start(); return(true); } catch { //delete imp; DebugStub.Break(); return(false); } }
bool Start() { try { ipManager.Start(); routingManager.Start(); for (int i = 0; i < nicRefs.Length; i++) { NicDeviceContract /*.Imp*/ imp = (nicRefs[i]).Acquire(); Nic.CreateAndRegister(imp, String.Format("/dev/nic{0}", i)); } return(true); } catch (Exception ex) { Dbg("An exception occurred during service startup: " + ex.Message); return(false); } }
internal static int AppMain(ServiceParameters parameters) { NicDeviceContract /*.Imp*/ nicImp = parameters.NicEndpointRef.Acquire(); nicImp.RecvSuccess(); //delete nicImp; DebugStub.WriteLine("Closed nic contract via reflection\n"); ARP arp = new ARP(); IP.Initialize(arp); Ethernet.Initialize(arp); NetStackApplication app = new NetStackApplication(parameters); try { return(app.Run()); } finally { //delete app; Dbg("NetStack is terminating."); } }
private bool Configure() { NicDeviceContract /*.Imp*/ nicImp = (NicDeviceContract)nicChannel.Acquire(); try { nicImp.ConfigureIO(); if (ConfigureEventChannel(nicImp) == true && ConfigureChecksumProperties(nicImp) == true) { return(true); } } catch (SystemException e) { DebugStub.WriteLine("System exception occurred in Nic.Configure()."); DebugStub.WriteLine(e.ToString()); DebugStub.Break(); } finally { nicChannel.Release(nicImp); } DebugStub.Break(); return(false); }
GetNicProperties(NicDeviceContract /*.Imp*/ imp) { return(imp.GetDeviceProperties()); }
ConfigureChecksumProperties(NicDeviceContract /*.Imp*/ nicImp) { nicImp.SetChecksumProperties(0); return(true); }
ConfigureEventChannel(NicDeviceContract nicImp) { nicImp.RegisterForEvents(this); return(true); }