diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-11-01 11:08:06 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-11-30 10:32:09 +0200 |
commit | 05f20b780bf234a791f885fb0e0df49969bbd6c5 (patch) | |
tree | dfa3f467ed94618c9e8ef38d0ddac5e50bb1c82f /platform | |
parent | f94a1e914d2670a955f0c79596d7d528437a2a49 (diff) |
linux-gen: dpdk: implement new packet input queue size parameter
Implement new packet input queue size API for dpdk pktio.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linux-generic/include/odp_packet_io_internal.h | 4 | ||||
-rw-r--r-- | platform/linux-generic/pktio/dpdk.c | 57 |
2 files changed, 45 insertions, 16 deletions
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 73da0c2be..954602959 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -69,9 +69,9 @@ struct pktio_if_ops; #elif defined(_ODP_PKTIO_XDP) #define PKTIO_PRIVATE_SIZE 29696 #elif defined(_ODP_PKTIO_DPDK) && ODP_CACHE_LINE_SIZE == 128 -#define PKTIO_PRIVATE_SIZE 4032 +#define PKTIO_PRIVATE_SIZE 4160 #elif defined(_ODP_PKTIO_DPDK) -#define PKTIO_PRIVATE_SIZE 3840 +#define PKTIO_PRIVATE_SIZE 3968 #else #define PKTIO_PRIVATE_SIZE 384 #endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 205cf1075..7e9db90ce 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -104,7 +104,7 @@ ODP_STATIC_ASSERT(DPDK_MIN_RX_BURST <= UINT8_MAX, "DPDK_MIN_RX_BURST too large") /** DPDK runtime configuration options */ typedef struct { - int num_rx_desc; + int num_rx_desc_default; int num_tx_desc_default; uint8_t multicast_en; uint8_t rx_drop_en; @@ -161,6 +161,8 @@ typedef struct ODP_ALIGNED_CACHE { uint8_t mtu_set; /* Use system call to get/set vdev promisc mode */ uint8_t vdev_sysc_promisc; + /* Number of RX descriptors per queue */ + uint16_t num_rx_desc[ODP_PKTIN_MAX_QUEUES]; /* Number of TX descriptors per queue */ uint16_t num_tx_desc[ODP_PKTOUT_MAX_QUEUES]; @@ -227,14 +229,8 @@ static int init_options(pktio_entry_t *pktio_entry, int val; if (!lookup_opt("num_rx_desc", dev_info->driver_name, - &opt->num_rx_desc)) + &opt->num_rx_desc_default)) return -1; - if (opt->num_rx_desc < dev_info->rx_desc_lim.nb_min || - opt->num_rx_desc > dev_info->rx_desc_lim.nb_max || - opt->num_rx_desc % dev_info->rx_desc_lim.nb_align) { - _ODP_ERR("Invalid number of RX descriptors\n"); - return -1; - } if (!lookup_opt("num_tx_desc", dev_info->driver_name, &opt->num_tx_desc_default)) @@ -255,7 +251,7 @@ static int init_options(pktio_entry_t *pktio_entry, _ODP_DBG("DPDK interface (%s): %" PRIu16 "\n", dev_info->driver_name, pkt_priv(pktio_entry)->port_id); _ODP_DBG(" multicast_en: %d\n", opt->multicast_en); - _ODP_DBG(" num_rx_desc: %d\n", opt->num_rx_desc); + _ODP_DBG(" num_rx_desc: %d\n", opt->num_rx_desc_default); _ODP_DBG(" num_tx_desc: %d\n", opt->num_tx_desc_default); _ODP_DBG(" rx_drop_en: %d\n", opt->rx_drop_en); @@ -1493,21 +1489,51 @@ static void prepare_rss_conf(pktio_entry_t *pktio_entry, static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { + struct rte_eth_dev_info dev_info; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); odp_pktin_mode_t mode = pktio_entry->param.in_mode; uint8_t lockless; + int ret; prepare_rss_conf(pktio_entry, p); /** * Scheduler synchronizes input queue polls. Only single thread * at a time polls a queue */ - if (mode == ODP_PKTIN_MODE_SCHED || - p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) + if (mode == ODP_PKTIN_MODE_SCHED || p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) lockless = 1; else lockless = 0; - pkt_priv(pktio_entry)->flags.lockless_rx = lockless; + pkt_dpdk->flags.lockless_rx = lockless; + + ret = rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info); + if (ret) { + _ODP_ERR("DPDK: rte_eth_dev_info_get() failed: %d\n", ret); + return -1; + } + + /* Configure RX descriptors */ + for (uint32_t i = 0; i < p->num_queues; i++) { + uint16_t num_rx_desc = pkt_dpdk->opt.num_rx_desc_default; + + if (mode == ODP_PKTIN_MODE_DIRECT && p->queue_size[i] != 0) { + num_rx_desc = p->queue_size[i]; + /* Make sure correct alignment is used */ + if (dev_info.rx_desc_lim.nb_align) + num_rx_desc = RTE_ALIGN_MUL_CEIL(num_rx_desc, + dev_info.rx_desc_lim.nb_align); + } + + if (num_rx_desc < dev_info.rx_desc_lim.nb_min || + num_rx_desc > dev_info.rx_desc_lim.nb_max || + num_rx_desc % dev_info.rx_desc_lim.nb_align) { + _ODP_ERR("DPDK: invalid number of RX descriptors (%" PRIu16 ") for queue " + "%" PRIu32 "\n", num_rx_desc, i); + return -1; + } + pkt_dpdk->num_rx_desc[i] = num_rx_desc; + } return 0; } @@ -1548,7 +1574,8 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, if (num_tx_desc < dev_info.tx_desc_lim.nb_min || num_tx_desc > dev_info.tx_desc_lim.nb_max || num_tx_desc % dev_info.tx_desc_lim.nb_align) { - _ODP_ERR("DPDK: invalid number of TX descriptors\n"); + _ODP_ERR("DPDK: invalid number of TX descriptors (%" PRIu16 ") for queue " + "%" PRIu32 "\n", num_tx_desc, i); return -1; } pkt_dpdk->num_tx_desc[i] = num_tx_desc; @@ -1573,6 +1600,8 @@ static int dpdk_init_capability(pktio_entry_t *pktio_entry, capa->max_input_queues = RTE_MIN(dev_info->max_rx_queues, ODP_PKTIN_MAX_QUEUES); + capa->min_input_queue_size = dev_info->rx_desc_lim.nb_min; + capa->max_input_queue_size = dev_info->rx_desc_lim.nb_max; /* ixgbe devices support only 16 rx queues in RSS mode */ if (!strncmp(dev_info->driver_name, IXGBE_DRV_NAME, @@ -1904,7 +1933,7 @@ static int dpdk_setup_eth_rx(const pktio_entry_t *pktio_entry, for (i = 0; i < pktio_entry->num_in_queue; i++) { ret = rte_eth_rx_queue_setup(port_id, i, - pkt_dpdk->opt.num_rx_desc, + pkt_dpdk->num_rx_desc[i], rte_eth_dev_socket_id(port_id), &rxconf, pkt_dpdk->pkt_pool); if (ret < 0) { |