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

📄 count.c

📁 ixp2400的一个小程序
💻 C
字号:
//  Permission is hereby granted to merge this program code with 
//  other program material to create a derivative work.  This 
//  derivative work may be distributed in compiled object form only.
//  Any other publication of this program, in any form, without the 
//  explicit permission of the copyright holder is prohibited.
//
//  Send questions and comments to erik.j.johnson@intel.com, 
//  aaron.kunze@intel.com

//-------------------------------------------------------------------
// count.c - Chapter 5
// Dequeues packets from receive, counts them, and enqueues them
// for transmit using a single thread
//

#include "ixp.h"
#include "count.h"
#include "dl_buf.h"
#include "dl_meta.h"


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

// Scratchpad addresses for total packet and byte counts
static __declspec(scratch) unsigned int *pkt_count = 
		(__declspec(scratch) unsigned int *)4;
static __declspec(scratch) unsigned int *byte_count = 
		(__declspec(scratch) unsigned int *)8;

//-------------------------------------------------------------------
// count_init
//
//    Description:
//       Initialize the packet and byte counters.
//
//    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 count_init()
{
	*pkt_count  = 0;
	*byte_count = 0;
}


//-------------------------------------------------------------------
// count
//
//    Description:
//       Update the packet and byte counters.
//
//    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 count()
{
	__declspec(sram_write_reg) unsigned int
		buf_length_wr;
	SIGNAL counter_sig;

	// Increment the counters
	scratch_incr(pkt_count);
	buf_length_wr = dlMeta.bufferSize;
	scratch_add(&buf_length_wr, byte_count, 
				ctx_swap, &counter_sig);

	dlNextBlock = COUNT_NEXT_BLOCK;
}

 

⌨️ 快捷键说明

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