From 5f3043d61f8335fabab95c5321e1ba55b2dfdfff Mon Sep 17 00:00:00 2001 From: Rajath Shashidhara Date: Tue, 22 Jun 2021 18:31:49 +0000 Subject: [PATCH] init flow steering even when autoscaling disabled Signed-off-by: Rajath Shashidhara --- tas/fast/fast_kernel.c | 2 +- tas/fast/network.c | 33 +++++++++++++++++++-------------- tas/fast/network.h | 6 +++--- tas/tas.c | 2 +- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/tas/fast/fast_kernel.c b/tas/fast/fast_kernel.c index d92f1270..af1afffd 100644 --- a/tas/fast/fast_kernel.c +++ b/tas/fast/fast_kernel.c @@ -123,7 +123,7 @@ void fast_kernel_packet(struct dataplane_context *ctx, len = network_buf_len(nbh); dma_write(krx->addr, len, network_buf_bufoff(nbh)); - if (network_buf_flowgroup(nbh, &krx->msg.packet.flow_group)) { + if (network_buf_flowgroup(nbh, &krx->msg.packet.flow_group, ctx->id)) { fprintf(stderr, "fast_kernel_packet: network_buf_flowgroup failed\n"); abort(); } diff --git a/tas/fast/network.c b/tas/fast/network.c index 1f8c5f57..7037d571 100644 --- a/tas/fast/network.c +++ b/tas/fast/network.c @@ -160,7 +160,6 @@ int network_init(unsigned n_threads) goto error_exit; } - /* workaround for mlx5. */ if (config.fp_autoscale) { if (reta_mlx5_resize() != 0) { @@ -270,11 +269,9 @@ int network_thread_init(struct dataplane_context *ctx) } /* setting up RETA failed */ - if (config.fp_autoscale) { - if (reta_setup() != 0) { - fprintf(stderr, "RETA setup failed\n"); - goto error_tx_queue; - } + if (reta_setup() != 0) { + fprintf(stderr, "RETA setup failed\n"); + goto error_tx_queue; } start_done = 1; } @@ -438,6 +435,20 @@ static int reta_setup() /* allocate RSS redirection table and core-bucket count table */ rss_reta_size = eth_devinfo.reta_size; + if (rss_reta_size == 0) { + fprintf(stderr, "Warning: NIC does not expose reta size\n"); + rss_reta_size = rte_align32pow2(fp_cores_cur); /* map groups to fp cores in this case */ + } + if (rss_reta_size > FLEXNIC_PL_MAX_FLOWGROUPS) { + fprintf(stderr, "reta_setup: reta size (%u) greater than maximum supported" + " (%u)\n", rss_reta_size, FLEXNIC_PL_MAX_FLOWGROUPS); + abort(); + } + if (!rte_is_power_of_2(rss_reta_size)) { + fprintf(stderr, "reta_setup: reta size (%u) is not a power of 2\n", rss_reta_size); + abort(); + } + rss_reta = rte_calloc("rss reta", ((rss_reta_size + RTE_RETA_GROUP_SIZE - 1) / RTE_RETA_GROUP_SIZE), sizeof(*rss_reta), 0); rss_core_buckets = rte_calloc("rss core buckets", fp_cores_max, @@ -448,12 +459,6 @@ static int reta_setup() goto error_exit; } - if (rss_reta_size > FLEXNIC_PL_MAX_FLOWGROUPS) { - fprintf(stderr, "reta_setup: reta size (%u) greater than maximum supported" - " (%u)\n", rss_reta_size, FLEXNIC_PL_MAX_FLOWGROUPS); - abort(); - } - /* initialize reta */ for (i = 0, c = 0; i < rss_reta_size; i++) { rss_core_buckets[c]++; @@ -463,9 +468,9 @@ static int reta_setup() c = (c + 1) % fp_cores_cur; } - if (rte_eth_dev_rss_reta_update(net_port_id, rss_reta, rss_reta_size) != 0) { + if (rte_eth_dev_rss_reta_update(net_port_id, rss_reta, rss_reta_size) != 0 && config.fp_autoscale) { fprintf(stderr, "reta_setup: rte_eth_dev_rss_reta_update failed\n"); - return -1; + goto error_exit; } return 0; diff --git a/tas/fast/network.h b/tas/fast/network.h index fe18e767..297a5d10 100644 --- a/tas/fast/network.h +++ b/tas/fast/network.h @@ -187,15 +187,15 @@ static inline uint16_t network_buf_tcpxsums(struct network_buf_handle *bh, uint8 } static inline int network_buf_flowgroup(struct network_buf_handle *bh, - uint16_t *fg) + uint16_t *fg, uint16_t core) { struct rte_mbuf *mb = (struct rte_mbuf *) bh; if (!(mb->ol_flags & PKT_RX_RSS_HASH)) { - *fg = 0; + *fg = core; return 0; } - *fg = mb->hash.rss & (rss_reta_size - 1); + *fg = mb->hash.rss & (rss_reta_size - 1); // NOTE: assume rte_is_power_of_2(rss_reta_size) return 0; } diff --git a/tas/tas.c b/tas/tas.c index c0647096..34461179 100644 --- a/tas/tas.c +++ b/tas/tas.c @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) res = EXIT_FAILURE; goto error_exit; } - fp_cores_max = config.fp_cores_max; + fp_cores_max = fp_cores_cur = config.fp_cores_max; /* allocate shared memory before dpdk grabs all huge pages */ if (shm_preinit() != 0) {