/* * Function: WaitReady * Description: Wait until the receiver is ready to accept data. */ private static void WaitReady() { while (!Emu.m_axis_tready) { Kiwi.Pause(); } }
static int EntryPoint() { // Create and start the thread for the CAM controller CAM_controller cam_controller = new CAM_controller(); Thread CAM_lookup_n_learn = new Thread(new ThreadStart(cam_controller.CAM_lookup_n_learn)); CAM_lookup_n_learn.Start(); // Create and start the thread for the ethernet parser Ethernet eth_controller = new Ethernet(); Thread eth_ctrl = new Thread(new ThreadStart(eth_controller.eth_parser)); eth_ctrl.Start(); // Create and start the thread for the FIFO controller FIFO_controller fifo_controller = new FIFO_controller(); // Thread FIFO_receive = new Thread(new ThreadStart(fifo_controller.FIFO_receive)); // FIFO_receive.Start(); Thread FIFO_send = new Thread(new ThreadStart(fifo_controller.FIFO_send)); FIFO_send.Start(); while (true) { Kiwi.Pause(); } ; return(0); }
/* * Function: CutThrough * Description: Continuously sends received data until end of frame. */ private static void CutThrough() { var done = false; do { Emu.Status = 4; Emu.m_axis_tvalid = Emu.s_axis_tvalid; Emu.s_axis_tready = Emu.m_axis_tready; Emu.m_axis_tdata_0 = Emu.s_axis_tdata_0; Emu.m_axis_tdata_1 = Emu.s_axis_tdata_1; Emu.m_axis_tdata_2 = Emu.s_axis_tdata_2; Emu.m_axis_tdata_3 = Emu.s_axis_tdata_3; Emu.m_axis_tkeep = Emu.s_axis_tkeep; Emu.m_axis_tlast = Emu.s_axis_tlast; Emu.m_axis_tuser_hi = 0U; Emu.m_axis_tuser_low = 0U; done = Emu.s_axis_tlast && Emu.s_axis_tvalid; Kiwi.Pause(); Emu.s_axis_tready = false; Emu.m_axis_tvalid = false; } while (!done); Emu.PktOut++; Reset(); Kiwi.Pause(); }
public void eth_parser() { byte state = 0x00; while (true) { switch (state) { // READ MAC ADDRESSES case 0x00: if (s_axis_tvalid & s_axis_tready) { Emu.metadata = s_axis_tuser_low; Emu.dst_mac = s_axis_tdata_0 << (byte)16; Emu.src_mac = ((s_axis_tdata_0 >> (byte)48) & (ulong)0x00ffff) | (s_axis_tdata_1 & (ulong)0x00ffffffff) << (byte)16; Emu.eth_header_rdy = true; Emu.broadcast_ports = ((s_axis_tuser_low & (ulong)0x00FF0000) ^ DEFAULT_oqs) << (byte)8; state = 0x01; } s_axis_tready = true; break; // WAIT EOP case 0x01: Emu.eth_header_rdy = false; state = (s_axis_tvalid & s_axis_tlast & s_axis_tready) ? (byte)0x00 : (byte)0x01; s_axis_tready = (s_axis_tvalid & s_axis_tlast) ? false : true; break; default: break; } Kiwi.Pause(); } }
// This procedure perform the calculation of the new checksum and verification // It returns the new checksum(on calculation process) or 0x00 if no-errors were detected(on verification process) static ulong calc_IP_checksum() { byte i; ulong data = 0x00, tmp0 = 0x00, tmp1 = 0x00, tmp2 = 0x00, tmp3 = 0x00; ulong sum0 = 0x00, sum1 = 0x00, sum = 0x00, sum2 = 0x00, sum3 = 0x00, carry; ulong sum_all = 0x00; for (i = 1; i <= 4; i++) { data = (i == 1) ? tdata[1] >> 48 : (i == 4) ? tdata[4] << 48 : (i == 2 || i == 3) ? tdata[i] : (ulong)0x00; Kiwi.Pause(); // extract every 16-bit from the stream for addition and reorder it to big endianess tmp0 = ((ulong)(data >> 0) & (ulong)0x00ff) << 8 | ((ulong)(data >> 0) & (ulong)0x00ff00) >> 8; tmp1 = ((ulong)(data >> 16) & (ulong)0x00ff) << 8 | ((ulong)(data >> 16) & (ulong)0x00ff00) >> 8; tmp2 = ((ulong)(data >> 32) & (ulong)0x00ff) << 8 | ((ulong)(data >> 32) & (ulong)0x00ff00) >> 8; tmp3 = ((ulong)(data >> 48) & (ulong)0x00ff) << 8 | ((ulong)(data >> 48) & (ulong)0x00ff00) >> 8; // check for carry and add it if its needed sum0 = (ulong)((tmp0 + tmp1) & (ulong)0x00ffff) + (ulong)((tmp0 + tmp1) >> 16); sum1 = (ulong)((tmp2 + tmp3) & (ulong)0x00ffff) + (ulong)((tmp2 + tmp3) >> 16); Kiwi.Pause(); // check for carry and add it if its needed sum = (ulong)((sum0 + sum1) & (ulong)0x00ffff) + (ulong)((sum0 + sum1) >> 16); // add the current sum to the previous sums sum_all = (ulong)((sum + sum_all) & (ulong)0x00ffff) + (ulong)((sum + sum_all) >> 16); } // //(ulong)(~sum0 & (ulong)0x00ffff); DOESNT WORK sum_all = (sum_all ^ ~(ulong)0x00) & (ulong)0x00ffff; return(sum_all); }
// This procedure calculates the checksum of a given byte stream // It returns the result in big endianess format // It doenst compute the 1's complement static public void calc_checksum(ulong data) { ulong tmp0 = 0x00, tmp1 = 0x00, tmp2 = 0x00, tmp3 = 0x00, sum0 = 0, sum1 = 0, sum = 0, chk = 0; byte i = 0; chk = chksum_UDP; // The ICMP header & payload start from this packet number if (true) //cnt > (uint)3 ) { // extract every 16-bit from the stream for addition and reorder it to big endianess tmp0 = ((ulong)(data >> 0) & (ulong)0x00ff) << 8 | ((ulong)(data >> 0) & (ulong)0x00ff00) >> 8; tmp1 = ((ulong)(data >> 16) & (ulong)0x00ff) << 8 | ((ulong)(data >> 16) & (ulong)0x00ff00) >> 8; tmp2 = ((ulong)(data >> 32) & (ulong)0x00ff) << 8 | ((ulong)(data >> 32) & (ulong)0x00ff00) >> 8; tmp3 = ((ulong)(data >> 48) & (ulong)0x00ff) << 8 | ((ulong)(data >> 48) & (ulong)0x00ff00) >> 8; // check for carry and add it if its needed sum0 = (ulong)((tmp0 + tmp1) & (ulong)0x00ffff) + (ulong)((tmp0 + tmp1) >> 16); sum1 = (ulong)((tmp2 + tmp3) & (ulong)0x00ffff) + (ulong)((tmp2 + tmp3) >> 16); Kiwi.Pause(); // check for carry and add it if its needed sum = (ulong)((sum0 + sum1) & (ulong)0x00ffff) + (ulong)((sum0 + sum1) >> 16); // add the current sum to the previous sums chksum_UDP = (ulong)((sum + chk) & (ulong)0x00ffff) + (ulong)((sum + chk) >> 16); } }
// This method describes the operations required to tx a frame over the AXI4-Stream. static void SendFrame(uint size) { // ############################# // # Transmit the frame // ############################# m_axis_tvalid = true; m_axis_tlast = false; m_axis_tdata = (ulong)0x0; m_axis_tkeep = (byte)0x0; m_axis_tuser_hi = (ulong)0x0; m_axis_tuser_low = (ulong)0x0; uint i = 0, packet_size = size; while (i <= packet_size) { if (m_axis_tready) { m_axis_tdata = tdata[i]; m_axis_tkeep = tkeep[i]; m_axis_tlast = i == (size); m_axis_tuser_hi = 0UL; m_axis_tuser_low = tuser_low[0]; i++; } Kiwi.Pause(); } m_axis_tvalid = false; m_axis_tlast = false; m_axis_tdata = (ulong)0x0; m_axis_tkeep = (byte)0x0; m_axis_tuser_hi = (ulong)0x0; m_axis_tuser_low = (ulong)0x0; Kiwi.Pause(); }
// This procedure perform swap of multiple fields // dst_mac<->src_mac, dst_ip<->src_ip, dst_port<->src_port static void swap_multiple_fields(bool udp, bool icmp) { ulong tmp = 0UL, tmp1 = 0UL, tmp3 = 0UL; bool udp_tmp, icmp_tmp; if (udp) { // Swap the ports, Memcached tmp = (tdata_0[1] & (ulong)0xffff000000000000) | src_ip >> 16 | app_src_port << 32 | app_dst_port << 16; } if (icmp) { // Set the ICMP echo reply type=0, code=0 and checksum=0x00 tmp = (tdata_0[1] & (ulong)0xffff000000000000) | src_ip >> 16; } // Ethernet header swap tdata_0[0] = src_mac | (dst_mac << 48); // Ethernet header swap tmp1 = (tdata_1[0] & (ulong)0xffffffff00000000) | dst_mac >> 16; // IP header swap + UDP header swap tmp3 = (tdata_3[0] & (ulong)0x00ffff) | dst_ip << 16 | src_ip << 48; Kiwi.Pause(); tdata_1[0] = tmp1; tdata_3[0] = tmp3; tdata_0[1] = tmp; Kiwi.Pause(); }
// This procedure perform swap of multiple fields // dst_mac<->src_mac, dst_ip<->src_ip, dst_port<->src_port static void swap_multiple_fields(bool udp, bool icmp) { ulong tmp; bool udp_tmp, icmp_tmp; udp_tmp = udp; icmp_tmp = icmp; // Ethernet header swap tdata[0] = src_mac | (dst_mac << 48); Kiwi.Pause(); tmp = (tdata[1] & (ulong)0xffffffff00000000) | dst_mac >> 16; Kiwi.Pause(); tdata[1] = tmp; Kiwi.Pause(); // IP header swap + UDP header swap tmp = (tdata[3] & (ulong)0x00ffff) | dst_ip << 16 | src_ip << 48; //tmp = dst_ip<<16 | src_ip<<48; Kiwi.Pause(); tdata[3] = tmp; Kiwi.Pause(); if (udp_tmp) { // Swap the ports tmp = (tdata[4] & (ulong)0xffff000000000000) | src_ip >> 16 | app_src_port << 32 | app_dst_port << 16; } if (icmp_tmp) { // Set the ICMP echo reply type=0, code=0 and checksum=0x00 tmp = (tdata[4] & (ulong)0xffff000000000000) | src_ip >> 16; } Kiwi.Pause(); tdata[4] = tmp; Kiwi.Pause(); }
static void DebugPrintData() { #if DEBUG Console.WriteLine("<><><>> tdata"); for (int i = 0; i < dataplane.tdata.Length; i++) { #if !KIWI Console.WriteLine("<><><>> {0:x16}", dataplane.tdata[i]); #else Console.WriteLine("<><><>> {0:x}", dataplane.tdata[i]); #endif if (dataplane.tlast[i]) { Console.WriteLine("<><><>> tkeep[{0}] = {1:x} (i tlast)", i, dataplane.tkeep[i]); break; } Kiwi.Pause(); } Console.WriteLine("<><><>> tuser_hi (non-zero)"); for (int i = 0; i < dataplane.tdata.Length; i++) { if (dataplane.tuser_hi[i] != 0) { Console.WriteLine("<><><>> {0}: {1:x}", i, dataplane.tuser_hi[i]); } Kiwi.Pause(); } Console.WriteLine("<><><>> tuser_low {0:x}", dataplane.tuser_low[0]); Kiwi.Pause(); #endif }
// This procedure calculates the checksum of a given byte stream // It returns the result in big endianess format // It doenst compute the 1's complement static public ulong calc_UDP_checksum(ulong data, ulong chksum_udp) { ulong tmp0 = 0x00, tmp1 = 0x00, tmp2 = 0x00, tmp3 = 0x00, sum0 = 0, sum1 = 0, sum = 0, chk = 0; chk = chksum_udp; // extract every 16-bit from the stream for addition and reorder it to big endianess tmp0 = ((ulong)(data >> 0) & (ulong)0x00ff) << 8 | ((ulong)(data >> 0) & (ulong)0x00ff00) >> 8; tmp1 = ((ulong)(data >> 16) & (ulong)0x00ff) << 8 | ((ulong)(data >> 16) & (ulong)0x00ff00) >> 8; tmp2 = ((ulong)(data >> 32) & (ulong)0x00ff) << 8 | ((ulong)(data >> 32) & (ulong)0x00ff00) >> 8; tmp3 = ((ulong)(data >> 48) & (ulong)0x00ff) << 8 | ((ulong)(data >> 48) & (ulong)0x00ff00) >> 8; Kiwi.Pause(); // check for carry and add it if its needed sum0 = (ulong)((tmp0 + tmp1) & (ulong)0x00ffff) + (ulong)((tmp0 + tmp1) >> 16); sum1 = (ulong)((tmp2 + tmp3) & (ulong)0x00ffff) + (ulong)((tmp2 + tmp3) >> 16); Kiwi.Pause(); // check for carry and add it if its needed sum = (ulong)((sum0 + sum1) & (ulong)0x00ffff) + (ulong)((sum0 + sum1) >> 16); Kiwi.Pause(); // add the current sum to the previous sums chksum_udp = (ulong)((sum + chk) & (ulong)0x00ffff) + (ulong)((sum + chk) >> 16); return(chksum_udp); }
// This procedure creates the SET response packet static public uint Memcached_SET() { ulong tmp0 = 0UL, tmp1 = 0UL, tmp2 = 0UL, tmp3 = 0UL; // Set the correct IP packet length (little endianess) // SET - Fixed size 44B tmp2 = tdata_2[0] & (ulong)0xffffffffffff0000; // Set the checksum to 0x00, calculate later tmp3 = tdata_3[0] & (ulong)0xffffffffffff0000; // Set the correct UDP packet length (little endianess) // SET - Fixed size 24B tmp0 = tdata_0[1] & (ulong)0x0000ffffffffffff; // Reset the UDP checksum tmp1 = tdata_1[1]; Kiwi.Pause(); tdata_2[0] = tmp2 | (ulong)0x002c00; // 44 Bytes tdata_3[0] = tmp3; tdata_1[1] = tmp1 & ~(ulong)0x00ffff; tdata_0[1] = tmp0 | (ulong)0x1800000000000000; // 24 Bytes Kiwi.Pause(); tmp2 = tdata_2[1] & (ulong)0x00ffff; Kiwi.Pause(); // ASCII response - STORED tdata_2[1] = tmp2 | (ulong)0x4445524f54530000; // ASCII response cont - \r\n tdata_3[1] = (ulong)0x000a0d; // Set the correct metadata for the datapath // Fixed size response packet for SET - DELETE success tuser_low[0] = dst_port | src_port | (ulong)58; tkeep[1] = (uint)0x03ffffff; return(1U); }
//static int debuglevel = 0; public static Complex CalcAmp(CircuitOp[] remaining_circuit, int circuitpos, int inital_state, int target_state) { // class-based dynamic dispatch errors out if the return value from this wunction is created with operator new inside a branch that is conditional on remaining_circuit.Length. // so double realpart, imagpart; if (circuitpos == 0) { //Console.WriteLine("{0}Base case for target {1}", new string (' ', debuglevel), target_state); realpart = (target_state == inital_state) ? 1.0 : 0.0; imagpart = 0.0; } else { //Console.WriteLine("{0}evaluating for lvl {1} target {2}", new string (' ', debuglevel), circuitpos, target_state); CircuitOp current_gate = remaining_circuit[circuitpos - 1]; int[] predecessors = state_ball(target_state, current_gate.qubits); Complex[] predecessor_amp = new Complex[predecessors.Length]; for (int i = 0; i < predecessors.Length; i++) { Kiwi.Pause(); //debuglevel += 1; predecessor_amp[i] = CalcAmp(remaining_circuit, circuitpos - 1, inital_state, predecessors[i]); //debuglevel -= 1; } Complex resamp = zero; for (int i = 0; i < predecessors.Length; i++) { switch (current_gate.op) { case Op.H: resamp = resamp + H_select( partial_trace(predecessors[i], current_gate.qubits), predecessor_amp[i], partial_trace(target_state, current_gate.qubits) ); break; case Op.CNOT: resamp = resamp + CNOT_select( partial_trace(predecessors[i], current_gate.qubits), predecessor_amp[i], partial_trace(target_state, current_gate.qubits) ); break; default: Console.WriteLine("UNKNOWN OPERATION!"); break; } } realpart = resamp.real; //(target_state == inital_state) ? 1.0 : 0.0; imagpart = resamp.imag; } return(new Complex(realpart, imagpart)); }
/// <summary>Change a value, removing the old and adding the new to the working value for a incremental checksum change.</summary> /// <returns>The new value</returns> public static ushort ChangeValueInChecksum(ushort oldVal, ushort newVal, ref int checksum) { RemoveFromChecksum(oldVal, ref checksum); AddToChecksum(newVal, ref checksum); Kiwi.Pause(); return(newVal); }
static void ReceiveFrameSegm() { // Procedure call for receiving the first frame of the packet m_axis_tdata_0 = (ulong)0x0; m_axis_tdata_1 = (ulong)0x0; m_axis_tdata_2 = (ulong)0x0; m_axis_tdata_3 = (ulong)0x0; m_axis_tkeep = (uint)0x0; m_axis_tlast = false; m_axis_tuser_hi = (ulong)0x0; m_axis_tuser_low = (ulong)0x0; m_axis_tvalid = false; s_axis_tready = false; bool doneReading = false; do { if (s_axis_tvalid) { // Read the first segment and pause metadata = s_axis_tuser_low; dst_mac = s_axis_tdata_0 << (byte)16; src_mac = ((s_axis_tdata_0 >> (byte)48) & (ulong)0x00ffff) | (s_axis_tdata_1 & (ulong)0x00ffffffff) << (byte)16; doneReading = true; } Kiwi.Pause(); }while (!doneReading); }
public void Load(uint index) { this.index = index; ips = ips_arr[index]; ports = ports_arr[index]; Kiwi.Pause(); }
public static void WriteUDPHeader(CircularFrameBuffer cfb, UDPParser up, EthernetParserGenerator ep, IPv4ParserGenerator ip, byte ports) { Emu.Status = 0xff0; ip.Protocol = 17; ip.AssembleHeader(); //Emu.PktIn = ip.CalculateCheckSum(); //ip.HeaderChecksum = ip.CalculateCheckSum(); //ip.AssembleHeader(); ep.WriteToBuffer(cfb.PushData); ip.WriteToBuffer(cfb.PushData, 0); InterfaceFunctions.SetDestInterface(ports, cfb.PushData); cfb.PushData.Tkeep = 0xFFFFFFFF; cfb.PushData.Tlast = false; Kiwi.Pause(); cfb.Push(cfb.PushData, true); Emu.Status = 0xff1; cfb.ResetPeek(); cfb.PushData.Reset(); ip.WriteToBuffer(cfb.PushData, 1); up.WriteToBuffer(cfb.PushData, (byte)(16 + (ip.IHL - 5) * 32)); cfb.PushData.Tkeep = 0x0000003FF; cfb.PushData.Tlast = true; Kiwi.Pause(); cfb.Push(cfb.PushData); Emu.Status = 0xff2; }
public bool sendOne(bool check_ready = true, bool check_updated = true) { if ((!check_updated || s_updated) && (!check_ready || Emu.axi_m_axis_tready)) { s_updated = false; Emu.axi_m_axis_tvalid = true; Emu.axi_m_axis_tdata_0 = axi_m_axis_tdata_0; Emu.axi_m_axis_tdata_1 = axi_m_axis_tdata_1; Emu.axi_m_axis_tdata_2 = axi_m_axis_tdata_2; Emu.axi_m_axis_tdata_3 = axi_m_axis_tdata_3; Emu.axi_m_axis_tstrb = axi_m_axis_tstrb; Emu.axi_m_axis_tkeep = axi_m_axis_tkeep; Emu.axi_m_axis_tlast = axi_m_axis_tlast; Emu.axi_m_axis_tid = axi_m_axis_tid; Emu.axi_m_axis_tdest = axi_m_axis_tdest; Emu.axi_m_axis_tuser_0 = axi_m_axis_tuser_0; Emu.axi_m_axis_tuser_1 = axi_m_axis_tuser_1; Kiwi.Pause(); Emu.axi_m_axis_tvalid = false; return(true); } if (check_ready && !Emu.axi_m_axis_tready) { DebugFunctions.push_interrupt(DebugFunctions.Errors.SEND_NOT_READY); return(false); } return(false); }
// This procedure creates the SET response packet static public uint Memcached_SET() { ulong tmp = 0x00, tmp2 = 0x00; // Set the correct IP packet length (little endianess) // SET - Fixed size of extras(8B) + key(6B) + value(8B) tmp = ((ulong)(ulong)((IP_total_length >> 8) | (IP_total_length << 8 & (ulong)0x00ff00)) - (ulong)22) & (ulong)0x00ffff; tmp2 = tdata[2] & (ulong)0xffffffffffff0000; Kiwi.Pause(); tdata[2] = tmp2 | (tmp >> 8) | (tmp << 8 & (ulong)0x00ff00); Kiwi.Pause(); // Set the checksum to 0x00, calculate later tmp = tdata[3] & (ulong)0xffffffffffff0000; Kiwi.Pause(); tdata[3] = tmp; // Set the correct UDP packet length (little endianess) // SET - Fixed size of extras(8B) + key(6B) + value(8B) tmp = ((ulong)(ulong)((UDP_total_length >> 8) | (UDP_total_length << 8 & (ulong)0x00ff00)) - (ulong)22); tmp2 = tdata[4] & (ulong)0x0000ffffffffffff; Kiwi.Pause(); tdata[4] = tmp2 | ((tmp & (ulong)0xff00) << 40) | (tmp << 56); Kiwi.Pause(); // Reset the UDP checksum tmp = tdata[5]; Kiwi.Pause(); tdata[5] = tmp & ~(ulong)0x00ffff; Kiwi.Pause(); tmp = tdata[6] & (ulong)0x00ffff; Kiwi.Pause(); tdata[6] = (ulong)SET << 24 | (ulong)RESPONSE << 16 | tmp; Kiwi.Pause(); // Set the opaque - SET response // SET response doesnt support error code tmp = tdata[7] & 0xffff000000000000; Kiwi.Pause(); tdata[7] = tmp; Kiwi.Pause(); tmp = tdata[8] & 0x000000000000ffff; Kiwi.Pause(); tdata[8] = tmp; Kiwi.Pause(); tdata[9] = (ulong)0x00; // Set the correct metadata for the datapath // Fixed size response packet for SET - DELETE success tuser_low[0] = (src_port << 24) | (src_port << 16) | (ulong)74; tkeep[9] = (byte)0x03; //pkt_size = 8; return(9U); }
public void update_bw_tmp() { while (true) { this.bw_tmp = new_bw_slot ? 0U : new_pkt_arrived ? this.bw_tmp + packet_size : this.bw_tmp; Kiwi.Pause(); } }
static void Main() { Console.WriteLine("Starting"); dsfmt = new dsfmt_t(); Kiwi.Pause(); testGaussian(); Console.WriteLine("Ending"); }
/// <summary>Change a value, removing the old and adding the new to both of the working values for an incremental checksum change that affects two checksums.</summary> /// <returns>The new value</returns> /// <remarks> /// This has the effect of calling <see cref="ChangeValueInChecksum(uint, uint, ref int)"/> twice, specifying <paramref name="checksum"/> /// the first time, and <paramref name="checksum2"/> the second. /// </remarks> public static uint ChangeValueInChecksum(uint oldVal, uint newVal, ref int checksum, ref int checksum2) { RemoveFromChecksum(oldVal, ref checksum); RemoveFromChecksum(oldVal, ref checksum2); AddToChecksum(newVal, ref checksum); AddToChecksum(newVal, ref checksum2); Kiwi.Pause(); return(newVal); }
static int EntryPoint() { var hub = new Frame_Processor(); while (true) { hub.Processor_Loop(); Kiwi.Pause(); } }
static int EntryPoint() { var processor = new Reference_Switch_Lite(); while (true) { processor.SwitchLogic(); Kiwi.Pause(); } }
public static void Main() { while (true) { Kiwi.Pause(); } Read(HashCAM.key_in); Write(HashCAM.key_in, HashCAM.value_in); }
static void SetSendIntf(byte intf) { ulong tuser_low0 = dataplane.tuser_low[0]; Kiwi.Pause(); tuser_low0 &= 0xFFFFFFFF00FFFFFFuL; tuser_low0 |= ((ulong)intf << 24); dataplane.tuser_low[0] = tuser_low0; Kiwi.Pause(); }
// This procedure creates the SET response packet static public uint Memcached_SET(ref ulong[] tdata, ulong IP_total_length, ulong UDP_total_length) { ulong tmp = 0x00, tmp2 = 0x00; // Set the correct IP packet length (little endianess) // SET - Fixed size of extras(8B) + key(6B) + value(8B) tmp = ((ulong)(ulong)((IP_total_length >> 8) | (IP_total_length << 8 & (ulong)0x00ff00)) - (ulong)22) & (ulong)0x00ffff; tmp2 = tdata[2] & (ulong)0xffffffffffff0000; Kiwi.Pause(); tdata[2] = tmp2 | (tmp >> 8) | (tmp << 8 & (ulong)0x00ff00); Kiwi.Pause(); // Set the checksum to 0x00, calculate later tmp = tdata[3] & (ulong)0xffffffffffff0000; Kiwi.Pause(); tdata[3] = tmp; // Set the correct UDP packet length (little endianess) // SET - Fixed size of extras(8B) + key(6B) + value(8B) tmp = ((ulong)(ulong)((UDP_total_length >> 8) | (UDP_total_length << 8 & (ulong)0x00ff00)) - (ulong)22); tmp2 = tdata[4] & (ulong)0x0000ffffffffffff; Kiwi.Pause(); tdata[4] = tmp2 | ((tmp & (ulong)0xff00) << 40) | (tmp << 56); Kiwi.Pause(); // Reset the UDP checksum tmp = tdata[5]; Kiwi.Pause(); tdata[5] = tmp & ~(ulong)0x00ffff; Kiwi.Pause(); tmp = tdata[6] & (ulong)0x00ffff; Kiwi.Pause(); tdata[6] = (ulong)SET_op << 24 | (ulong)RESPONSE << 16 | tmp; Kiwi.Pause(); // Set the opaque - SET response // SET response doesnt support error code tmp = tdata[7] & 0xffff000000000000; Kiwi.Pause(); tdata[7] = tmp; Kiwi.Pause(); tmp = tdata[8] & 0x000000000000ffff; Kiwi.Pause(); tdata[8] = tmp; Kiwi.Pause(); tdata[9] = (ulong)0x00; return(9U); }
public void start_timer() { while (true) { new_bw_slot = this.timer == timer_resolution; this.timer = (this.timer == timer_resolution) ? 0U : this.timer + 1U; Kiwi.Pause(); } }
public static void printa(float [] AA) { Console.Write("{"); for (int j = 0; j < AA.Length; j++) { // if (AA[j]==0.0) Console.Write("-.------ ", AA[j]); else Console.Write("{0:f} ", AA[j]); } Kiwi.Pause(); Console.WriteLine("}"); }
public static void Main() { while (true) { Kiwi.Pause(); } Enlist(NaughtyQ.data_in); BackOfQ(NaughtyQ.idx_in); Read(NaughtyQ.idx_in); }