static int pcie_setup_tx(unsigned int iface_id, unsigned int *tx_id, unsigned int cluster_id, unsigned int min_rx, unsigned int max_rx) { mppa_noc_ret_t nret; mppa_routing_ret_t rret; mppa_dnoc_header_t header; mppa_dnoc_channel_config_t config; /* Configure the TX for PCIe */ nret = mppa_noc_dnoc_tx_alloc_auto(iface_id, tx_id, MPPA_NOC_NON_BLOCKING); if (nret) { dbg_printf("Tx alloc failed\n"); return 1; } MPPA_NOC_DNOC_TX_CONFIG_INITIALIZER_DEFAULT(config, 0); rret = mppa_routing_get_dnoc_unicast_route(odp_rpc_get_cluster_id(iface_id), cluster_id, &config, &header); if (rret) { dbg_printf("Routing failed\n"); return 1; } header._.multicast = 0; header._.tag = min_rx; header._.valid = 1; nret = mppa_noc_dnoc_tx_configure(iface_id, *tx_id, header, config); if (nret) { dbg_printf("Tx configure failed\n"); return 1; } volatile mppa_dnoc_min_max_task_id_t *context = &mppa_dnoc[iface_id]->tx_chan_route[*tx_id].min_max_task_id[0]; context->_.current_task_id = min_rx; context->_.min_task_id = min_rx; context->_.max_task_id = max_rx; context->_.min_max_task_id_en = 1; return 0; }
int main() { int ret, status; unsigned nocTx; mppa_dnoc_header_t header = { 0 }; mppa_dnoc_channel_config_t config = { 0 }; mppa_ethernet_header_t eth_header; memset(ð_header, 0, sizeof(eth_header)); ret = odp_rpc_server_start(); if (ret) { fprintf(stderr, "[RPC] Error: Failed to start server\n"); exit(EXIT_FAILURE); } printf("CNOC setup\n"); if (cluster_init_cnoc_rx() < 0){ fprintf(stderr, "Failed to setup CNoC\n"); exit(EXIT_FAILURE); } printf("CNOC setup done\n"); printf("Spawning clusters\n"); { static char const * _argv[] = { "pktio-ddr", "-i", "ioddr0:min_rx=" TOSTRING(MIN_TAG) ":max_rx=" TOSTRING(MAX_TAG) ":tags=" TOSTRING(N_RX) ":log2fragments=" TOSTRING(_ODP_LOG2MAX_FRAGS) ":cnoc=2:rrpolicy=20:rroffset=20:fc=1,drop", "-m", "0", "-s", "0", "-t", "15", "-c", "2", NULL }; boot_cluster(0, _argv[0], _argv); } printf("Cluster booted\n"); for (int i = 0; i < DATA_SIZE; ++i) data[i] = i; ret = mppa_routing_get_dnoc_unicast_route(128, 0, &config, &header); if (ret != MPPA_ROUTING_RET_SUCCESS) { fprintf(stderr, "Failed to route to cluster 0\n"); return -1; } config._.loopback_multicast = 0; config._.cfg_pe_en = 1; config._.cfg_user_en = 1; config._.write_pe_en = 1; config._.write_user_en = 1; config._.decounter_id = 0; config._.decounted = 0; config._.payload_min = 0; config._.payload_max = 32; config._.bw_current_credit = 0xff; config._.bw_max_credit = 0xff; config._.bw_fast_delay = 0x00; config._.bw_slow_delay = 0x00; header._.multicast = 0; header._.valid = 1; ret = mppa_noc_dnoc_tx_alloc_auto(0, &nocTx, MPPA_NOC_BLOCKING); if (ret != MPPA_NOC_RET_SUCCESS) { fprintf(stderr, "Failed to find an available Tx on DMA 0\n"); return -1; } sleep(10); header._.tag = MIN_TAG; eth_header.timestamp = 0; eth_header.info._.pkt_id = 0; eth_header.info._.pkt_size = PKTIO_MTU + sizeof(eth_header); uint64_t pkt_count = 0; printf("Start sending\n"); while(pkt_count < 1200000) { for( int i = 0; i < DATA_SIZE / PKTIO_MTU; i ++) { uint64_t remote_pkt_count; ret = mppa_noc_dnoc_tx_configure(0, nocTx, header, config); if (ret != MPPA_NOC_RET_SUCCESS) { fprintf(stderr, "Failed to configure Tx\n"); return -1; } eth_header.timestamp++; eth_header.info._.pkt_id++; do { remote_pkt_count = mppa_noc_cnoc_rx_get_value(0, CNOC_RX); } while(pkt_count > remote_pkt_count + (MAX_TAG - MIN_TAG + 1)); mppa_noc_dnoc_tx_send_data(0, nocTx, sizeof(eth_header), ð_header); mppa_noc_dnoc_tx_send_data_eot(0, nocTx, PKTIO_MTU, &data[i * PKTIO_MTU]); header._.tag++; if (header._.tag > MAX_TAG) header._.tag = MIN_TAG; pkt_count++; } } if ((ret = join_clusters(&status)) != 0) { fprintf(stderr, "Failed to joined clusters\n"); return ret; } if (status){ fprintf(stderr, "Clusters returned with errors: %d\n", status); fflush(stderr); return status; } return 0; }