Exemple #1
0
/*
 *  alloc a mbuf which can be used to describe the packet
 *  if work is error , return NULL
 *  then free wqe, reurn mbuf
 */
void *
oct_rx_process_work(cvmx_wqe_t *wq)
{
	void *pkt_virt;
	mbuf_t *m;

	if (wq->word2.s.rcv_error || cvmx_wqe_get_bufs(wq) > 1){
		/* 
		  *  Work has error, so drop
		  *  and now do not support jumbo packet
		  */
		printf("recv error\n");
		oct_packet_free(wq, wqe_pool);
		STAT_RECV_ERR;
		return NULL;
	}

	pkt_virt = (void *) cvmx_phys_to_ptr(wq->packet_ptr.s.addr);
	if(NULL == pkt_virt)
	{
		STAT_RECV_ADDR_ERR;
		return NULL;
	}
	
#ifdef SEC_RXTX_DEBUG
    printf("Received %u byte packet.\n", cvmx_wqe_get_len(wq));
    printf("Processing packet\n");
    cvmx_helper_dump_packet(wq);
#endif

	m = (mbuf_t *)MBUF_ALLOC();

	memset((void *)m, 0, sizeof(mbuf_t));

	m->magic_flag = MBUF_MAGIC_NUM;
	PKTBUF_SET_HW(m);
	
	m->packet_ptr.u64 = wq->packet_ptr.u64;

	m->input_port = cvmx_wqe_get_port(wq);
	
	m->pkt_totallen = cvmx_wqe_get_len(wq);
	m->pkt_ptr = pkt_virt;

	cvmx_fpa_free(wq, wqe_pool, 0);
	
	STAT_RECV_PC_ADD;
	STAT_RECV_PB_ADD(m->pkt_totallen);

	STAT_RECV_OK;
	return (void *)m;

}
Exemple #2
0
void oct_rx_process_command(cvmx_wqe_t *wq)
{
	uint16_t opcode = oct_rx_command_get(wq);
	void *data;
	if(opcode == COMMAND_INVALID)
	{
		oct_packet_free(wq, wqe_pool);
		return;
	}

	data = cvmx_phys_to_ptr(wq->packet_ptr.s.addr);
	
	switch(opcode)
	{
		case COMMAND_SHOW_BUILD_TIME:
		{
			dp_show_build_time(wq, data);
			break;
		}
		case COMMAND_SHOW_PKT_STAT:
		{
			dp_show_pkt_stat(wq, data);
			break;
		}
		case COMMAND_SHOW_MEM_POOL:
		{
			dp_show_mem_pool(wq, data);
			break;
		}
		case COMMAND_ACL_RULE_COMMIT:
		{
			dp_acl_rule_commit(wq, data);	
		}
		default:
		{
			printf("unsupport command\n");
			break;
		}
	}
}
/*
 *  alloc a mbuf which can be used to describe the packet
 *  if work is error , return NULL
 *  then free wqe, reurn mbuf
 */
void *
oct_rx_process_work(cvmx_wqe_t *wq, uint8_t src)
{
    void *pkt_virt;
    mbuf_t *m;

    if (wq->word2.s.rcv_error || oct_wqe_get_bufs(wq) > 1){
        /*
              *  Work has error, so drop
              *  and now do not support jumbo packet
              */
        oct_packet_free(wq, wqe_pool);
        if(FROMLINUX == src)
        {
            STAT_RECV_FROMLINUX_ERR;
        }
        else
        {
            STAT_RECV_FROMHWPORT_ERR;
        }

        return NULL;
    }

    pkt_virt = (void *) cvmx_phys_to_ptr(wq->packet_ptr.s.addr);
    if(NULL == pkt_virt)
    {
        STAT_RECV_ADDR_ERR;
        return NULL;
    }

    LOGDBG(SEC_PACKET_DUMP, "Received %u byte packet.\n", oct_wqe_get_len(wq));
    LOGDBG(SEC_PACKET_DUMP, "Processing packet\n");
    if(srv_dp_sync->dp_debugprint & SEC_PACKET_DUMP)
    {
        cvmx_helper_dump_packet(wq);
    }

    m = (mbuf_t *)MBUF_ALLOC();

    memset((void *)m, 0, sizeof(mbuf_t));

    m->magic_flag = MBUF_MAGIC_NUM;
    PKTBUF_SET_HW(m);

    m->packet_ptr.u64 = wq->packet_ptr.u64;

    m->input_port = oct_wqe_get_port(wq);

    m->pkt_totallen = oct_wqe_get_len(wq);
    m->pkt_ptr = pkt_virt;

    m->tag = cvmx_wqe_get_tag(wq);

    m->timestamp = OCT_TIME_SECONDS_SINCE1970;

    oct_fpa_free(wq, wqe_pool, 0);

    if(FROMPORT == src)
    {
        STAT_RECV_PC_ADD;
        STAT_RECV_PB_ADD(m->pkt_totallen);
    }

    if(FROMLINUX == src)
    {
        STAT_RECV_FROMLINUX_OK;
    }
    else
    {
        STAT_RECV_FROMHWPORT_OK;
    }

    return (void *)m;
}