⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dl_source.c

📁 ixp2400的一个小程序
💻 C
字号:
//------------------------------------------------------------------------------------
//                                                                      
//                   I N T E L   P R O P R I E T A R Y                   
//                                                                       
//      COPYRIGHT (c)  2001 BY  INTEL  CORPORATION.  ALL RIGHTS          
//      RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY      
//      BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A    
//      RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER    
//      LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,    
//      MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT    
//      THE PRIOR WRITTEN PERMISSION OF :                                
//                                                                       
//                         INTEL  CORPORATION                            
//                                                                      
//                      2200 MISSION COLLEGE BLVD                        
//                                                                       
//                SANTA  CLARA,  CALIFORNIA  95052-8119                  
//                                                                       
//------------------------------------------------------------------------------------

#include "dl_source.h"
#include "dl_buf.c"
#include "dl_meta.h"
#include "scratch_rings.h"

extern dl_buf_handle_t			dlBufHandle;
extern __declspec(gp_reg) int 	dlNextBlock;
extern dl_meta_t				dlMeta;

//-------------------------------------------------------------------
// dl_sink_init
//
//    Description:
//      Initialize the ring between rx and processing, or
//		processing and TX, depending on either
//		RX_TO_PROCESSING or PROCESSING_TO_TX being defined
//
//    Parameters:
//      Outputs: n/a
//      In/Outs: n.a
//      Inputs: n/a
//      Constants: n/a
//      Labels: n/a
//
//    Side effects: n/a
//
//    See also: n/a
//
void dl_sink_init()
{
	if (ctx() == 0)
	{
// The sink block code for RX to processing
#ifdef RX_DL
		// Initialize the ring between rx and processing
		scratch_ring_init(
			RX_TO_PROCESSING_RING,
			RX_TO_PROCESSING_RING_BASE,
			RX_TO_PROCESSING_RING_SIZE);

		// Send a singal to processing indicating the ring is ready
		cap_fast_write(
			(RING_CONSUMER_CTX<<4) |
		    (__signal_number(&rx_ring_ready_sig, 
							 RING_CONSUMER_ME)) |
			(RING_CONSUMER_ME<<7),
			csr_interthread_sig);
#endif

// The sink block code for processing to tx
#ifdef PROCESSING_DL
		// Fix the value of the incoming ring-ready signal so the
		// rx task can indicate when that ring is created.
		__assign_relative_register((void *)&rx_ring_ready_sig, 
								   2);

		// Initialize the ring between tx and processing
		scratch_ring_init(
			PROCESSING_TO_TX_RING,
			PROCESSING_TO_TX_RING_BASE,
			PROCESSING_TO_TX_RING_SIZE);

		// Send a singal to processing indicating the ring is ready
		cap_fast_write(
			(RING_CONSUMER_CTX<<4) |
		    (__signal_number(&tx_ring_ready_sig, 
							 RING_CONSUMER_ME)) |
			(RING_CONSUMER_ME<<7),
			csr_interthread_sig);
#endif

#ifdef TX_DL
		// Fix the value of the incoming ring-ready signal so the
		// rx task can indicate when that ring is created.
		__assign_relative_register((void *)&tx_ring_ready_sig, 
								   2);
#endif
	}
}

///////////////////////////////////////////////////////////////////////////////
// dl_sink:
//    Description:
//      Enqueue a packet from RX to processing or from processing
//		to TX, depending on a preprocessor constant of either
//		  RX_TO_PROCESSING or
//		  PROCESSING_TO_TX being defined.
//
//    Parameters:
//      Outputs: n/a
//      In/Outs: n.a
//      Inputs: n/a
//      Constants: n/a
//      Labels: n/a
//
//    Side effects: n/a
//
//    See also: n/a
void dl_sink()
{
	ring_data_t	r_data;

#ifdef RX_DL
#define __DL_SINK_RING		RX_TO_PROCESSING_RING
#endif

#ifdef PROCESSING_DL
#define __DL_SINK_RING		PROCESSING_TO_TX_RING
#endif

#ifndef TX_DL
   
	//	In the case of an exception packet, it needs to 
	//  be sent to the core (Xscale)
	//	through a different ring.
	// For now just drop the packet.
	if (dlNextBlock == IX_EXCEPTION)
	{
		Dl_BufDrop(dlBufHandle);
		return;
	}

	// Enqueue the packet on the appropriate
	// scratch ring.  First check if the ring 
	// is full, and if so drop the packet.
	if (scratch_ring_full(__DL_SINK_RING))
	{
		Dl_BufDrop(dlBufHandle);
		return;
	}

	// Enqueue the handle, length and offset
	// of the packet
	r_data.handle = dlBufHandle;
	r_data.length = dlMeta.bufferSize;
	r_data.offset = dlMeta.offset;
	scratch_ring_put_buffer(
			__DL_SINK_RING,
			r_data);
#endif

#undef __DL_SINK_RING
}

//-------------------------------------------------------------------
// dl_source_init
//
//    Description:
//		Wait for the upstream process to signal creation of
// 		the ring
//
//    Parameters:
//      Outputs: n/a
//      In/Outs: n.a
//      Inputs: n/a
//      Constants: n/a
//      Labels: n/a
//
//    Side effects: n/a
//
//    See also: n/a
//
void dl_source_init()
{
	if (ctx() == 0)
	{
#ifdef PROCESSING_DL

		// Wait for a singal from RX indicating the
		// incoming ring is ready
		wait_for_all(&rx_ring_ready_sig);

#endif

#ifdef TX_DL

		// Wait for the queue to be set up
		wait_for_all(&tx_ring_ready_sig);

#endif
	}
}

///////////////////////////////////////////////////////////////////////////////
// dl_source:
//    Description:
//      Dequeue a packet from either RX to processing, depending on either
//		  RX_TO_PROCESSING or
//		  PROCESSING_TO_TX being defined.
//
//    Parameters:
//      Outputs: n/a
//      In/Outs: n.a
//      Inputs: n/a
//      Constants: n/a
//      Labels: n/a
//
//    Side effects: n/a
//
//    See also: n/a
void dl_source()
{
	ring_data_t	r_data;

#ifdef PROCESSING_DL
#define __DL_SOURCE_RING		RX_TO_PROCESSING_RING
#endif

#ifdef TX_DL
#define __DL_SOURCE_RING		PROCESSING_TO_TX_RING
#endif

#ifndef RX_DL
	// Dequeue a packet from the appropriate ring


	scratch_ring_get_buffer(
		__DL_SOURCE_RING,
		&r_data);
	dlBufHandle       = r_data.handle;
	dlMeta.bufferSize = r_data.length;
	dlMeta.offset	  = r_data.offset;
#endif
		
#undef __DL_SOURCE_RING
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -