* Copy pattern item specification. * * @param[out] buf * Output buffer. Can be NULL if @p size is zero. * @param size * Size of @p buf in bytes. * @param[in] item * Pattern item to copy specification from. * @param type * Specification selector for either @p spec, @p last or @p mask. * * @return * Number of bytes needed to store pattern item specification regardless * of @
| 602 | * enough. |
| 603 | */ |
| 604 | static size_t |
| 605 | rte_flow_conv_item_spec(void *buf, const size_t size, |
| 606 | const struct rte_flow_item *item, |
| 607 | enum rte_flow_conv_item_spec_type type) |
| 608 | { |
| 609 | size_t off; |
| 610 | const void *data = |
| 611 | type == RTE_FLOW_CONV_ITEM_SPEC ? item->spec : |
| 612 | type == RTE_FLOW_CONV_ITEM_LAST ? item->last : |
| 613 | type == RTE_FLOW_CONV_ITEM_MASK ? item->mask : |
| 614 | NULL; |
| 615 | |
| 616 | switch (item->type) { |
| 617 | union { |
| 618 | const struct rte_flow_item_raw *raw; |
| 619 | const struct rte_flow_item_geneve_opt *geneve_opt; |
| 620 | } spec; |
| 621 | union { |
| 622 | const struct rte_flow_item_raw *raw; |
| 623 | } last; |
| 624 | union { |
| 625 | const struct rte_flow_item_raw *raw; |
| 626 | } mask; |
| 627 | union { |
| 628 | const struct rte_flow_item_raw *raw; |
| 629 | const struct rte_flow_item_geneve_opt *geneve_opt; |
| 630 | } src; |
| 631 | union { |
| 632 | struct rte_flow_item_raw *raw; |
| 633 | struct rte_flow_item_geneve_opt *geneve_opt; |
| 634 | } dst; |
| 635 | void *deep_src; |
| 636 | size_t tmp; |
| 637 | |
| 638 | case RTE_FLOW_ITEM_TYPE_RAW: |
| 639 | spec.raw = item->spec; |
| 640 | last.raw = item->last ? item->last : item->spec; |
| 641 | mask.raw = item->mask ? item->mask : &rte_flow_item_raw_mask; |
| 642 | src.raw = data; |
| 643 | dst.raw = buf; |
| 644 | rte_memcpy(dst.raw, |
| 645 | (&(struct rte_flow_item_raw){ |
| 646 | .relative = src.raw->relative, |
| 647 | .search = src.raw->search, |
| 648 | .reserved = src.raw->reserved, |
| 649 | .offset = src.raw->offset, |
| 650 | .limit = src.raw->limit, |
| 651 | .length = src.raw->length, |
| 652 | }), |
| 653 | size > sizeof(*dst.raw) ? sizeof(*dst.raw) : size); |
| 654 | off = sizeof(*dst.raw); |
| 655 | if (type == RTE_FLOW_CONV_ITEM_SPEC || |
| 656 | (type == RTE_FLOW_CONV_ITEM_MASK && |
| 657 | ((spec.raw->length & mask.raw->length) >= |
| 658 | (last.raw->length & mask.raw->length)))) |
| 659 | tmp = spec.raw->length & mask.raw->length; |
| 660 | else |
| 661 | tmp = last.raw->length & mask.raw->length; |
no test coverage detected