static int exec_burst(uint32_t flags, int lcore) { unsigned i, portid, nb_tx = 0; struct lcore_conf *conf; uint32_t pkt_per_port; int num, idx = 0; int diff_tsc; conf = &lcore_conf[lcore]; pkt_per_port = MAX_TRAFFIC_BURST; num = pkt_per_port; rte_atomic64_init(&start); /* start polling thread, but not actually poll yet */ rte_eal_remote_launch(poll_burst, (void *)&pkt_per_port, lcore); /* Only when polling first */ if (flags == SC_BURST_POLL_FIRST) rte_atomic64_set(&start, 1); /* start xmit */ while (num) { nb_tx = RTE_MIN(MAX_PKT_BURST, num); for (i = 0; i < conf->nb_ports; i++) { portid = conf->portlist[i]; rte_eth_tx_burst(portid, 0, &tx_burst[idx], nb_tx); idx += nb_tx; } num -= nb_tx; } sleep(5); /* only when polling second */ if (flags == SC_BURST_XMIT_FIRST) rte_atomic64_set(&start, 1); /* wait for polling finished */ diff_tsc = rte_eal_wait_lcore(lcore); if (diff_tsc < 0) { printf("exec_burst: Failed to measure cycles per packet\n"); return -1; } printf("Result: %d cycles per packet\n", diff_tsc); return 0; }
static void cn23xx_pfvf_hs_callback(struct lio_device *lio_dev, struct lio_mbox_cmd *cmd, void *arg) { uint32_t major = 0; PMD_INIT_FUNC_TRACE(); rte_memcpy((uint8_t *)&lio_dev->pfvf_hsword, cmd->msg.s.params, 6); if (cmd->recv_len > 1) { struct lio_version *lio_ver = (struct lio_version *)cmd->data; major = lio_ver->major; major = major << 16; } rte_atomic64_set((rte_atomic64_t *)arg, major | 1); }
int cn23xx_pfvf_handshake(struct lio_device *lio_dev) { struct lio_mbox_cmd mbox_cmd; struct lio_version *lio_ver = (struct lio_version *)&mbox_cmd.data[0]; uint32_t q_no, count = 0; rte_atomic64_t status; uint32_t pfmajor; uint32_t vfmajor; uint32_t ret; PMD_INIT_FUNC_TRACE(); /* Sending VF_ACTIVE indication to the PF driver */ lio_dev_dbg(lio_dev, "requesting info from PF\n"); mbox_cmd.msg.mbox_msg64 = 0; mbox_cmd.msg.s.type = LIO_MBOX_REQUEST; mbox_cmd.msg.s.resp_needed = 1; mbox_cmd.msg.s.cmd = LIO_VF_ACTIVE; mbox_cmd.msg.s.len = 2; mbox_cmd.data[0] = 0; lio_ver->major = LIO_BASE_MAJOR_VERSION; lio_ver->minor = LIO_BASE_MINOR_VERSION; lio_ver->micro = LIO_BASE_MICRO_VERSION; mbox_cmd.q_no = 0; mbox_cmd.recv_len = 0; mbox_cmd.recv_status = 0; mbox_cmd.fn = (lio_mbox_callback)cn23xx_pfvf_hs_callback; mbox_cmd.fn_arg = (void *)&status; if (lio_mbox_write(lio_dev, &mbox_cmd)) { lio_dev_err(lio_dev, "Write to mailbox failed\n"); return -1; } rte_atomic64_set(&status, 0); do { rte_delay_ms(1); } while ((rte_atomic64_read(&status) == 0) && (count++ < 10000)); ret = rte_atomic64_read(&status); if (ret == 0) { lio_dev_err(lio_dev, "cn23xx_pfvf_handshake timeout\n"); return -1; } for (q_no = 0; q_no < lio_dev->num_iqs; q_no++) lio_dev->instr_queue[q_no]->txpciq.s.pkind = lio_dev->pfvf_hsword.pkind; vfmajor = LIO_BASE_MAJOR_VERSION; pfmajor = ret >> 16; if (pfmajor != vfmajor) { lio_dev_err(lio_dev, "VF LiquidIO driver (major version %d) is not compatible with LiquidIO PF driver (major version %d)\n", vfmajor, pfmajor); ret = -EPERM; } else { lio_dev_dbg(lio_dev, "VF LiquidIO driver (major version %d), LiquidIO PF driver (major version %d)\n", vfmajor, pfmajor); ret = 0; } lio_dev_dbg(lio_dev, "got data from PF pkind is %d\n", lio_dev->pfvf_hsword.pkind); return ret; }