dpdk-kvs/cvmcs-kvs-main.c
/**
 * \brief Process the packets received from the wire over
 * BGX.
 *
 * @param wqe Work
 * @return COMP_CONSUMED is the packet was successfully switched in the
 *         FastPath.
 *         COMP_NOT_HANDLED if the packet was not handled.
 */
\brief Process the packets received from the wire over
BGX.

@param wqe Work
@return COMP_CONSUMED is the packet was successfully switched in the
FastPath.
COMP_NOT_HANDLED if the packet was not handled.
\ brief Process the packets received from the wire over BGX . @param wqe Work @return COMP_CONSUMED is the packet was successfully switched in the FastPath . COMP_NOT_HANDLED if the packet was not handled .
int kvs_process_wire_packet(cvmx_wqe_t ** wqe_ref, int * pci_idx)
{
    printf("Wire packet received in KVS component\n");
	int err = 0, qidx;
	cvmx_wqe_t *wqe = *wqe_ref;
	cvmcs_nic_metadata_t *mdata = CVMCS_NIC_METADATA(wqe);
	int err_code = cvmx_wqe_get_rcv_err(wqe);
	pkt_proc_flags_t flags;
	memset(&flags,0,sizeof(flags));
	cvmcs_kvs_mdata_wire_init(wqe);
	if (mdata->from_ifidx == -1) {
		printf(" %s : invalid ifidx = %d, port %d\n",
			  __func__, mdata->from_ifidx, mdata->from_port);
		cvmx_helper_dump_packet(wqe);
		return COMP_DROP;
	}
	if (cvmx_unlikely(err_code)) {
		if (cvmcs_nic_opcode_to_stats(mdata->from_ifidx, err_code)) {
			printf("L2/L1 error from port %d. Error code=%x\n",
					cvmx_wqe_get_port(wqe), err_code);
			return COMP_DROP;;
		}
	}
	if (!octnic->port[mdata->from_ifidx].state.active) {
		return COMP_DROP;
    }
	per_core_stats[cvmx_get_core_num()].link_stats[mdata->from_ifidx].fromwire.fw_total_rcvd += 1;
	err = cvmcs_nic_validate_rx_frame_len(wqe, mdata->from_ifidx); 
	if (err) {
		cvm_free_wqe_wrapper(wqe);
		return err;
	}
    qidx = 0;
    printf("Packet received: length correct. sending to if: %d, queue: %d\n", mdata->from_ifidx, qidx);
	kvs_send_packet_to_pci_port(wqe, mdata->from_ifidx, qidx,
			CVMCS_NIC_METADATA_L3_OFFSET(mdata), 
			CVMCS_NIC_METADATA_L4_OFFSET(mdata),
			mdata->flags);
	return COMP_CONSUMED;
}
int kvs_process_wire_packet ( cvmx_wqe_t * * wqe_ref , int * pci_idx ) { printf ( " \n " ) ; int err = 0 , qidx ; cvmx_wqe_t * wqe = * wqe_ref ; cvmcs_nic_metadata_t * mdata = CVMCS_NIC_METADATA ( wqe ) ; int err_code = cvmx_wqe_get_rcv_err ( wqe ) ; pkt_proc_flags_t flags ; memset ( & flags , 0 , sizeof ( flags ) ) ; cvmcs_kvs_mdata_wire_init ( wqe ) ; if ( mdata -> from_ifidx == -1 ) { printf ( " \n " , __func__ , mdata -> from_ifidx , mdata -> from_port ) ; cvmx_helper_dump_packet ( wqe ) ; return COMP_DROP ; } if ( cvmx_unlikely ( err_code ) ) { if ( cvmcs_nic_opcode_to_stats ( mdata -> from_ifidx , err_code ) ) { printf ( " \n " , cvmx_wqe_get_port ( wqe ) , err_code ) ; return COMP_DROP ; ; } } if ( ! octnic -> port [ mdata -> from_ifidx ] . state . active ) { return COMP_DROP ; } per_core_stats [ cvmx_get_core_num ( ) ] . link_stats [ mdata -> from_ifidx ] . fromwire . fw_total_rcvd += 1 ; err = cvmcs_nic_validate_rx_frame_len ( wqe , mdata -> from_ifidx ) ; if ( err ) { cvm_free_wqe_wrapper ( wqe ) ; return err ; } qidx = 0 ; printf ( " \n " , mdata -> from_ifidx , qidx ) ; kvs_send_packet_to_pci_port ( wqe , mdata -> from_ifidx , qidx , CVMCS_NIC_METADATA_L3_OFFSET ( mdata ) , CVMCS_NIC_METADATA_L4_OFFSET ( mdata ) , mdata -> flags ) ; return COMP_CONSUMED ; }
\brief Process the packets received from the wire over
 BGX.
\ brief Process the packets received from the wire over BGX .
//return COMP_NOT_HANDLED; /* Init metadata before main processing */ /* Drop the packet */ // TODO: Steer packets to proper VFs and Queues //Start Doing KV stuff here