static int parse_arg_rsz(const char *arg) { if (strnlen(arg, APP_ARG_RSZ_CHARS + 1) == APP_ARG_RSZ_CHARS + 1) { return -1; } if (str_to_unsigned_vals(arg, APP_ARG_RSZ_CHARS, ',', 4, &app.nic_rx_ring_size, &app.ring_rx_size, &app.ring_tx_size, &app.nic_tx_ring_size) != 4) { return -2; } if ((app.nic_rx_ring_size == 0) || (app.nic_tx_ring_size == 0) || (app.ring_rx_size == 0) || (app.ring_tx_size == 0)) { return -3; } return 0; }
static int parse_arg_tx(const char *arg) { const char *p0 = arg, *p = arg; uint32_t n_tuples; if (strnlen(arg, APP_ARG_TX_MAX_CHARS + 1) == APP_ARG_TX_MAX_CHARS + 1) { return -1; } n_tuples = 0; while ((p = strchr(p0,'(')) != NULL) { struct app_lcore_params *lp; uint32_t port, lcore, i; p0 = strchr(p++, ')'); if ((p0 == NULL) || (str_to_unsigned_vals(p, p0 - p, ',', 2, &port, &lcore) != 2)) { return -2; } /* Enable port and queue for later initialization */ if (port >= APP_MAX_NIC_PORTS) { return -3; } if (app.nic_tx_port_mask[port] != 0) { return -4; } app.nic_tx_port_mask[port] = 1; /* Check and assign (port, queue) to I/O lcore */ if (rte_lcore_is_enabled(lcore) == 0) { return -5; } if (lcore >= APP_MAX_LCORES) { return -6; } lp = &app.lcore_params[lcore]; if (lp->type == e_APP_LCORE_WORKER) { return -7; } lp->type = e_APP_LCORE_IO; for (i = 0; i < lp->io.tx.n_nic_ports; i ++) { if (lp->io.tx.nic_ports[i] == port) { return -8; } } if (lp->io.tx.n_nic_ports >= APP_MAX_NIC_TX_PORTS_PER_IO_LCORE) { return -9; } lp->io.tx.nic_ports[lp->io.tx.n_nic_ports] = (uint8_t) port; lp->io.tx.n_nic_ports ++; n_tuples ++; if (n_tuples > APP_ARG_TX_MAX_TUPLES) { return -10; } } if (n_tuples == 0) { return -11; } return 0; }
static int parse_arg_bsz(const char *arg) { const char *p = arg, *p0; if (strnlen(arg, APP_ARG_BSZ_CHARS + 1) == APP_ARG_BSZ_CHARS + 1) { return -1; } p0 = strchr(p++, ')'); if ((p0 == NULL) || (str_to_unsigned_vals(p, (size_t)(p0 - p), ',', 2, &app.burst_size_io_rx_read, &app.burst_size_io_rx_write) != 2)) { return -2; } p = strchr(p0, '('); if (p == NULL) { return -3; } p0 = strchr(p++, ')'); if ((p0 == NULL) || (str_to_unsigned_vals(p, (size_t)(p0 - p), ',', 2, &app.burst_size_worker_read, &app.burst_size_worker_write) != 2)) { return -4; } p = strchr(p0, '('); if (p == NULL) { return -5; } p0 = strchr(p++, ')'); if ((p0 == NULL) || (str_to_unsigned_vals(p, (size_t)(p0 - p), ',', 2, &app.burst_size_io_tx_read, &app.burst_size_io_tx_write) != 2)) { return -6; } if ((app.burst_size_io_rx_read == 0) || (app.burst_size_io_rx_write == 0) || (app.burst_size_worker_read == 0) || (app.burst_size_worker_write == 0) || (app.burst_size_io_tx_read == 0) || (app.burst_size_io_tx_write == 0)) { return -7; } if ((app.burst_size_io_rx_read > APP_MBUF_ARRAY_SIZE) || (app.burst_size_io_rx_write > APP_MBUF_ARRAY_SIZE) || (app.burst_size_worker_read > APP_MBUF_ARRAY_SIZE) || (app.burst_size_worker_write > APP_MBUF_ARRAY_SIZE) || ((2 * app.burst_size_io_tx_read) > APP_MBUF_ARRAY_SIZE) || (app.burst_size_io_tx_write > APP_MBUF_ARRAY_SIZE)) { return -8; } return 0; }
static int parse_arg_rx(const char *arg) { const char *p0 = arg, *p = arg; uint32_t n_tuples; if (strnlen(arg, APP_ARG_RX_MAX_CHARS + 1) == APP_ARG_RX_MAX_CHARS + 1) { return -1; } n_tuples = 0; while ((p = strchr(p0,'(')) != NULL) { struct app_lcore_params *lp; const char *p1, *p2; uint32_t port, queue, lcore, i, queue_min, queue_max; p0 = strchr(p++, ')'); if (p0 == NULL) { return -2; } if (str_to_unsigned_vals(p, (size_t)(p0 - p), ',', 3, &port, &queue, &lcore) != 3) { p1 = strchr(p, ','); if (p1++ == NULL) { return -2; } port = atoi(p); p2 = strchr(p1, ','); if (p2 == NULL || str_to_unsigned_vals(p1, (size_t)(p2 - p1), '-', 2, &queue_min, &queue_max) != 2) { return -2; } p2++; lcore = atoi(p2); if (queue_min > queue_max) { return -2; } } else { queue_min = queue_max = queue; } /* Enable port and queue for later initialization */ for (queue = queue_min; queue <= queue_max; queue++) { if ((port >= APP_MAX_NIC_PORTS) || (queue >= APP_MAX_RX_QUEUES_PER_NIC_PORT)) { return -3; } if (app.nic_rx_queue_mask[port][queue] != NIC_RX_QUEUE_UNCONFIGURED) { return -4; } app.nic_rx_queue_mask[port][queue] = NIC_RX_QUEUE_ENABLED; /* Check and assign (port, queue) to I/O lcore */ if (rte_lcore_is_enabled(lcore) == 0) { return -5; } if (lcore >= APP_MAX_LCORES) { return -6; } lp = &app.lcore_params[lcore]; if (lp->type == e_APP_LCORE_WORKER) { return -7; } lp->type = e_APP_LCORE_IO; for (i = 0; i < lp->io.rx.n_nic_queues; i ++) { if ((lp->io.rx.nic_queues[i].port == port) && (lp->io.rx.nic_queues[i].queue == queue)) { return -8; } } if (lp->io.rx.n_nic_queues >= APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE) { return -9; } lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].port = (uint8_t) port; lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].queue = (uint8_t) queue; lp->io.rx.n_nic_queues ++; } n_tuples ++; if (n_tuples > APP_ARG_RX_MAX_TUPLES) { return -10; } } if (n_tuples == 0) { return -11; } return 0; }