process a set of packets to distribute them to workers */
| 439 | |
| 440 | /* process a set of packets to distribute them to workers */ |
| 441 | int |
| 442 | rte_distributor_process(struct rte_distributor *d, |
| 443 | struct rte_mbuf **mbufs, unsigned int num_mbufs) |
| 444 | { |
| 445 | unsigned int next_idx = 0; |
| 446 | static unsigned int wkr; |
| 447 | struct rte_mbuf *next_mb = NULL; |
| 448 | int64_t next_value = 0; |
| 449 | uint16_t new_tag = 0; |
| 450 | uint16_t flows[RTE_DIST_BURST_SIZE] __rte_cache_aligned; |
| 451 | unsigned int i, j, w, wid, matching_required; |
| 452 | |
| 453 | if (d->alg_type == RTE_DIST_ALG_SINGLE) { |
| 454 | /* Call the old API */ |
| 455 | return rte_distributor_process_single(d->d_single, |
| 456 | mbufs, num_mbufs); |
| 457 | } |
| 458 | |
| 459 | for (wid = 0 ; wid < d->num_workers; wid++) |
| 460 | handle_returns(d, wid); |
| 461 | |
| 462 | if (unlikely(num_mbufs == 0)) { |
| 463 | /* Flush out all non-full cache-lines to workers. */ |
| 464 | for (wid = 0 ; wid < d->num_workers; wid++) { |
| 465 | /* Sync with worker on GET_BUF flag. */ |
| 466 | if (rte_atomic_load_explicit(&(d->bufs[wid].bufptr64[0]), |
| 467 | rte_memory_order_acquire) & RTE_DISTRIB_GET_BUF) { |
| 468 | d->bufs[wid].count = 0; |
| 469 | release(d, wid); |
| 470 | handle_returns(d, wid); |
| 471 | } |
| 472 | } |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | if (unlikely(!d->activesum)) |
| 477 | return 0; |
| 478 | |
| 479 | while (next_idx < num_mbufs) { |
| 480 | uint16_t matches[RTE_DIST_BURST_SIZE] __rte_aligned(128); |
| 481 | unsigned int pkts; |
| 482 | |
| 483 | if ((num_mbufs - next_idx) < RTE_DIST_BURST_SIZE) |
| 484 | pkts = num_mbufs - next_idx; |
| 485 | else |
| 486 | pkts = RTE_DIST_BURST_SIZE; |
| 487 | |
| 488 | for (i = 0; i < pkts; i++) { |
| 489 | if (mbufs[next_idx + i]) { |
| 490 | /* flows have to be non-zero */ |
| 491 | flows[i] = mbufs[next_idx + i]->hash.usr | 1; |
| 492 | } else |
| 493 | flows[i] = 0; |
| 494 | } |
| 495 | for (; i < RTE_DIST_BURST_SIZE; i++) |
| 496 | flows[i] = 0; |
| 497 | |
| 498 | matching_required = 1; |