示例#1
0
/* Dump log history to file */
void
rte_log_dump_history(FILE *out)
{
	struct log_history_list tmp_log_history;
	struct log_history *hist_buf;
	unsigned i;

	/* only one dump at a time */
	rte_spinlock_lock(&log_dump_lock);

	/* save list, and re-init to allow logging during dump */
	rte_spinlock_lock(&log_list_lock);
	tmp_log_history = log_history;
	STAILQ_INIT(&log_history);
	rte_spinlock_unlock(&log_list_lock);

	for (i=0; i<RTE_LOG_HISTORY; i++) {

		/* remove one message from history list */
		hist_buf = STAILQ_FIRST(&tmp_log_history);

		if (hist_buf == NULL)
			break;

		STAILQ_REMOVE_HEAD(&tmp_log_history, next);

		/* write on stdout */
		if (fwrite(hist_buf->buf, hist_buf->size, 1, out) == 0) {
			rte_mempool_mp_put(log_history_mp, hist_buf);
			break;
		}

		/* put back message structure in pool */
		rte_mempool_mp_put(log_history_mp, hist_buf);
	}
	fflush(out);

	rte_spinlock_unlock(&log_dump_lock);
}
示例#2
0
static void session_hash_cache_release_fn(struct h_scalar *he)
{
	struct sft_fdb_entry *dc = container_of(he, struct sft_fdb_entry, h_scalar);

    struct sess_hash *hash = get_session_hash_by_lcore(dc->lcore_id);
    hash->curr_entry_count--;
    SESS_DEBUG_LOG("%s(%d),fdb[%p],%u.%u.%u.%u:%d-->%u.%u.%u.%u:%d,lcore_id:%d\n",\
                __FUNCTION__,__LINE__,dc,RTE_NIPQUAD(dc->sess_key.ip_src),ntohs(dc->sess_key.port_src),
                RTE_NIPQUAD(dc->sess_key.ip_dst),ntohs(dc->sess_key.port_dst), dc->lcore_id);
    
    tcp_ofo_list_packet_free(&dc->vars_dpi);
    
	rte_mempool_mp_put(hash->mem_cache, dc);
}
示例#3
0
int
rte_log_add_in_history(const char *buf, size_t size)
{
	struct log_history *hist_buf = NULL;
	static const unsigned hist_buf_size = LOG_ELT_SIZE - sizeof(*hist_buf);
	void *obj;

	if (history_enabled == 0)
		return 0;

	rte_spinlock_lock(&log_list_lock);

	/* get a buffer for adding in history */
	if (log_history_size > RTE_LOG_HISTORY) {
		hist_buf = STAILQ_FIRST(&log_history);
		STAILQ_REMOVE_HEAD(&log_history, next);
	}
	else {
		if (rte_mempool_mc_get(log_history_mp, &obj) < 0)
			obj = NULL;
		hist_buf = obj;
	}

	/* no buffer */
	if (hist_buf == NULL) {
		rte_spinlock_unlock(&log_list_lock);
		return -ENOBUFS;
	}

	/* not enough room for msg, buffer go back in mempool */
	if (size >= hist_buf_size) {
		rte_mempool_mp_put(log_history_mp, hist_buf);
		rte_spinlock_unlock(&log_list_lock);
		return -ENOBUFS;
	}

	/* add in history */
	memcpy(hist_buf->buf, buf, size);
	hist_buf->buf[size] = hist_buf->buf[hist_buf_size-1] = '\0';
	hist_buf->size = size;
	STAILQ_INSERT_TAIL(&log_history, hist_buf, next);
	log_history_size++;
	rte_spinlock_unlock(&log_list_lock);

	return 0;
}
示例#4
0
static void shared_user_cache_release_fn(struct h_scalar *he)
{
    struct shared_user_cache *dc = container_of(he, struct shared_user_cache, h_scalar);

    rte_mempool_mp_put(shared_user_cache_tbl.mem_cache, dc);
}
示例#5
0
文件: ftp.c 项目: zebra88/mycode
static void ftp_cache_release_fn(struct h_scalar *he)
{
	struct ftp_cache *fc = container_of(he, struct ftp_cache, h_scalar);
    rte_mempool_mp_put(ftp_cache_tbl.mem_cache[fc->lcore_id], fc);
}