dpdk-kvs/cvmcs-kvs-main.c
/** 
 *
 * \brief Send the packet to the BGX  over pci queue.
 * @param wqe Work to send to host
 * @param ifidx physical interface index the packet belongs to
 * @param l3_offset Starting of the L3 header
 * @param l4_offset Starting of the L4 header
 * @param flags  Packet metadata flags. See cvmcs-nic-mdata.h for various
 * 		 possible metadata flags
 * @return 0 on success, -1 on failure
 */
\brief Send the packet to the BGX  over pci queue.
\ brief Send the packet to the BGX over pci queue .
int kvs_send_packet_to_phys_port(cvmx_wqe_t * wqe, int ifidx, int l3_offset,
				int l4_offset, int flags)
{
	int ret = -1;
	vnic_port_info_t *nicport = &octnic->port[ifidx];
	cvmcs_nic_metadata_t *mdata = CVMCS_NIC_METADATA(wqe);
	int len = cvmx_wqe_get_len(wqe);
	uint8_t from_if = mdata->from_interface;
	int from_idx = mdata->from_ifidx;
	int fromq_idx = 0;
	int port = nicport->linfo.gmxport;
	int queue = cvmx_pko_get_base_queue(nicport->linfo.gmxport);
	if(from_if == METADATA_PORT_DPI) {
		fromq_idx = (mdata->from_port-0x100) - octnic->port[mdata->from_ifidx].iq_base;
		 if(!((fromq_idx >= 0) && (fromq_idx < MAX_IOQS_PER_NICIF))) {
			printf("%s fromq_idx is invalid:%d\n", __func__, fromq_idx);
		}
	}
	if (cvmx_unlikely(port == -1 || queue == -1)) {
		cvm_free_wqe_wrapper(wqe);
		return ret;
	}
	ret =
	    cvmcs_kvs_send_to_pko3(wqe, 0, port, queue, l3_offset, l4_offset,
					flags, nicport);
	if(ret != 0) {
		kvsprintf("%s: core %d, PKO3 send on ifidx %d, phys port %d, queue %d, Failed\n", __func__,
		  cvmx_get_core_num(), ifidx, port, queue);
		cvm_free_wqe_wrapper(wqe);
		cvmcs_kvs_update_tx_err_stats(from_if, from_idx, ifidx);
		return -1;
	}
#ifdef OVS_IPSEC
	if((cvmx_wqe_get_pki_pkt_ptr(wqe).packet_outside_wqe))
	{
		cvmx_wqe_free(wqe);
		DBG("Freeing WQE %p\n", wqe);
	}
#endif
	cvmcs_kvs_update_tx_fwd_stats(from_if, from_idx, ifidx, len, fromq_idx);
	return ret;
}
int kvs_send_packet_to_phys_port ( cvmx_wqe_t * wqe , int ifidx , int l3_offset , int l4_offset , int flags ) { int ret = -1 ; vnic_port_info_t * nicport = & octnic -> port [ ifidx ] ; cvmcs_nic_metadata_t * mdata = CVMCS_NIC_METADATA ( wqe ) ; int len = cvmx_wqe_get_len ( wqe ) ; uint8_t from_if = mdata -> from_interface ; int from_idx = mdata -> from_ifidx ; int fromq_idx = 0 ; int port = nicport -> linfo . gmxport ; int queue = cvmx_pko_get_base_queue ( nicport -> linfo . gmxport ) ; if ( from_if == METADATA_PORT_DPI ) { fromq_idx = ( mdata -> from_port - 0x100 ) - octnic -> port [ mdata -> from_ifidx ] . iq_base ; if ( ! ( ( fromq_idx >= 0 ) && ( fromq_idx < MAX_IOQS_PER_NICIF ) ) ) { printf ( " \n " , __func__ , fromq_idx ) ; } } if ( cvmx_unlikely ( port == -1 || queue == -1 ) ) { cvm_free_wqe_wrapper ( wqe ) ; return ret ; } ret = cvmcs_kvs_send_to_pko3 ( wqe , 0 , port , queue , l3_offset , l4_offset , flags , nicport ) ; if ( ret != 0 ) { kvsprintf ( " \n " , __func__ , cvmx_get_core_num ( ) , ifidx , port , queue ) ; cvm_free_wqe_wrapper ( wqe ) ; cvmcs_kvs_update_tx_err_stats ( from_if , from_idx , ifidx ) ; return -1 ; } #ifdef OVS_IPSEC if ( ( cvmx_wqe_get_pki_pkt_ptr ( wqe ) . packet_outside_wqe ) ) { cvmx_wqe_free ( wqe ) ; DBG ( " \n " , wqe ) ; } #endif cvmcs_kvs_update_tx_fwd_stats ( from_if , from_idx , ifidx , len , fromq_idx ) ; return ret ; }
\brief Send the packet to the BGX  over pci queue.
\ brief Send the packet to the BGX over pci queue .