Skip to content

Commit 5f3043d

Browse files
init flow steering even when autoscaling disabled
Signed-off-by: Rajath Shashidhara <rajaths@cs.utexas.edu>
1 parent d3926ba commit 5f3043d

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

tas/fast/fast_kernel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void fast_kernel_packet(struct dataplane_context *ctx,
123123
len = network_buf_len(nbh);
124124
dma_write(krx->addr, len, network_buf_bufoff(nbh));
125125

126-
if (network_buf_flowgroup(nbh, &krx->msg.packet.flow_group)) {
126+
if (network_buf_flowgroup(nbh, &krx->msg.packet.flow_group, ctx->id)) {
127127
fprintf(stderr, "fast_kernel_packet: network_buf_flowgroup failed\n");
128128
abort();
129129
}

tas/fast/network.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ int network_init(unsigned n_threads)
160160
goto error_exit;
161161
}
162162

163-
164163
/* workaround for mlx5. */
165164
if (config.fp_autoscale) {
166165
if (reta_mlx5_resize() != 0) {
@@ -270,11 +269,9 @@ int network_thread_init(struct dataplane_context *ctx)
270269
}
271270

272271
/* setting up RETA failed */
273-
if (config.fp_autoscale) {
274-
if (reta_setup() != 0) {
275-
fprintf(stderr, "RETA setup failed\n");
276-
goto error_tx_queue;
277-
}
272+
if (reta_setup() != 0) {
273+
fprintf(stderr, "RETA setup failed\n");
274+
goto error_tx_queue;
278275
}
279276
start_done = 1;
280277
}
@@ -438,6 +435,20 @@ static int reta_setup()
438435

439436
/* allocate RSS redirection table and core-bucket count table */
440437
rss_reta_size = eth_devinfo.reta_size;
438+
if (rss_reta_size == 0) {
439+
fprintf(stderr, "Warning: NIC does not expose reta size\n");
440+
rss_reta_size = rte_align32pow2(fp_cores_cur); /* map groups to fp cores in this case */
441+
}
442+
if (rss_reta_size > FLEXNIC_PL_MAX_FLOWGROUPS) {
443+
fprintf(stderr, "reta_setup: reta size (%u) greater than maximum supported"
444+
" (%u)\n", rss_reta_size, FLEXNIC_PL_MAX_FLOWGROUPS);
445+
abort();
446+
}
447+
if (!rte_is_power_of_2(rss_reta_size)) {
448+
fprintf(stderr, "reta_setup: reta size (%u) is not a power of 2\n", rss_reta_size);
449+
abort();
450+
}
451+
441452
rss_reta = rte_calloc("rss reta", ((rss_reta_size + RTE_RETA_GROUP_SIZE - 1) /
442453
RTE_RETA_GROUP_SIZE), sizeof(*rss_reta), 0);
443454
rss_core_buckets = rte_calloc("rss core buckets", fp_cores_max,
@@ -448,12 +459,6 @@ static int reta_setup()
448459
goto error_exit;
449460
}
450461

451-
if (rss_reta_size > FLEXNIC_PL_MAX_FLOWGROUPS) {
452-
fprintf(stderr, "reta_setup: reta size (%u) greater than maximum supported"
453-
" (%u)\n", rss_reta_size, FLEXNIC_PL_MAX_FLOWGROUPS);
454-
abort();
455-
}
456-
457462
/* initialize reta */
458463
for (i = 0, c = 0; i < rss_reta_size; i++) {
459464
rss_core_buckets[c]++;
@@ -463,9 +468,9 @@ static int reta_setup()
463468
c = (c + 1) % fp_cores_cur;
464469
}
465470

466-
if (rte_eth_dev_rss_reta_update(net_port_id, rss_reta, rss_reta_size) != 0) {
471+
if (rte_eth_dev_rss_reta_update(net_port_id, rss_reta, rss_reta_size) != 0 && config.fp_autoscale) {
467472
fprintf(stderr, "reta_setup: rte_eth_dev_rss_reta_update failed\n");
468-
return -1;
473+
goto error_exit;
469474
}
470475

471476
return 0;

tas/fast/network.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ static inline uint16_t network_buf_tcpxsums(struct network_buf_handle *bh, uint8
187187
}
188188

189189
static inline int network_buf_flowgroup(struct network_buf_handle *bh,
190-
uint16_t *fg)
190+
uint16_t *fg, uint16_t core)
191191
{
192192
struct rte_mbuf *mb = (struct rte_mbuf *) bh;
193193
if (!(mb->ol_flags & PKT_RX_RSS_HASH)) {
194-
*fg = 0;
194+
*fg = core;
195195
return 0;
196196
}
197197

198-
*fg = mb->hash.rss & (rss_reta_size - 1);
198+
*fg = mb->hash.rss & (rss_reta_size - 1); // NOTE: assume rte_is_power_of_2(rss_reta_size)
199199
return 0;
200200
}
201201

tas/tas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
8080
res = EXIT_FAILURE;
8181
goto error_exit;
8282
}
83-
fp_cores_max = config.fp_cores_max;
83+
fp_cores_max = fp_cores_cur = config.fp_cores_max;
8484

8585
/* allocate shared memory before dpdk grabs all huge pages */
8686
if (shm_preinit() != 0) {

0 commit comments

Comments
 (0)