numam-dpdk/lib/ethdev
Yuan Wang 605975b8b3 ethdev: introduce protocol-based buffer split
Currently, Rx buffer split supports length based split. With Rx queue
offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment
configured, PMD will be able to split the received packets into
multiple segments.

However, length based buffer split is not suitable for NICs that do split
based on protocol headers. Given an arbitrarily variable length in Rx
packet segment, it is almost impossible to pass a fixed protocol header to
driver. Besides, the existence of tunneling results in the composition of
a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based
buffer split. A new proto_hdr field is introduced in the reserved field
of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr
field defines the split position of packet, splitting will always happen
after the protocol header defined in the Rx packet segment. When Rx queue
offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding
protocol header is configured, driver will split the ingress packets into
multiple segments.

Examples for proto_hdr field defines:
To split after ETH-IPV4-UDP, it should be defined as
proto_hdr = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
            RTE_PTYPE_L4_UDP

For inner ETH-IPV4-UDP, it should be defined as
proto_hdr = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
            RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP

If the protocol header is repeated with the previously defined one,
the repeated part should be omitted. For example, split after ETH, ETH-IPV4
and ETH-IPV4-UDP, it should be defined as
proto_hdr0 = RTE_PTYPE_L2_ETHER
proto_hdr1 = RTE_PTYPE_L3_IPV4_EXT_UNKNOWN
proto_hdr2 = RTE_PTYPE_L4_UDP

If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypes function can
be used to obtain a list of these protocol headers.

For example, let's suppose we configured the Rx queue with the
following segments:
        seg0 - pool0, proto_hdr0=RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4,
               off0=2B
        seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
        seg2 - pool2, proto_hdr2=0, off1=0B

The packet consists of ETH_IPV4_UDP_PAYLOAD will be split like
following:
        seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0
        seg1 - udp header @ 128 in mbuf from pool1
        seg2 - payload @ 0 in mbuf from pool2

Now buffer split can be configured in two modes. User can choose length
or protocol header to configure buffer split according to NIC's
capability. For length based buffer split, the mp, length, offset field
in Rx packet segment should be configured, while the proto_hdr field
must be 0. For protocol header based buffer split, the mp, offset,
proto_hdr field in Rx packet segment should be configured, while the
length field must be 0.

Note: When protocol header split is enabled, NIC may receive packets
which do not match all the protocol headers within the Rx segments.
At this point, NIC will have two possible split behaviors according to
matching results, one is exact match, another is longest match.
The split result of NIC must belong to one of them.

The exact match means NIC only do split when the packets exactly match all
the protocol headers in the segments. Otherwise, the whole packet will be
put into the last valid mempool. The longest match means NIC will do split
until packets mismatch the protocol header in the segments. The rest will
be put into the last valid pool.

Pseudo-code for exact match:
FOR each seg in segs except last one
    IF proto_hdr is not matched THEN
        BREAK
    END IF
END FOR
IF loop breaked THEN
    put whole pkt in last seg
ELSE
    put protocol header in each seg
    put everything else in last seg
END IF

Pseudo-code for longest match:
FOR each seg in segs except last one
    IF proto_hdr is matched THEN
        put protocol header in seg
    ELSE
        BREAK
    END IF
END FOR
put everything else in last seg

Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
Signed-off-by: Xuan Ding <xuan.ding@intel.com>
Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
2022-10-09 16:41:27 +02:00
..
ethdev_driver.c eal: deprecate RTE_FUNC_PTR_* macros 2022-09-23 16:14:34 +02:00
ethdev_driver.h ethdev: introduce protocol header API 2022-10-09 16:41:24 +02:00
ethdev_pci.h bus/pci: make driver-only headers private 2022-09-23 16:14:34 +02:00
ethdev_private.c remove extra blank line at EOF 2022-02-27 21:26:06 +01:00
ethdev_private.h ethdev: support congestion management 2022-10-07 11:50:28 +02:00
ethdev_profile.c ethdev: fix Ethernet spelling 2021-10-21 13:43:56 +02:00
ethdev_profile.h ethdev: fix build with vtune option 2022-05-12 10:23:52 +02:00
ethdev_trace_points.c
ethdev_vdev.h bus/vdev: make driver-only headers private 2022-09-23 16:14:34 +02:00
meson.build ethdev: support congestion management 2022-10-07 11:50:28 +02:00
rte_class_eth.c eal: remove unneeded includes from a public header 2022-09-21 15:31:03 +02:00
rte_cman.h ethdev: support congestion management 2022-10-07 11:50:28 +02:00
rte_dev_info.h ethdev: add missing C++ guards 2022-02-22 14:47:49 +01:00
rte_eth_ctrl.h ethdev: fix Rx/Tx spelling 2021-10-21 13:43:56 +02:00
rte_ethdev_cman.c ethdev: support congestion management 2022-10-07 11:50:28 +02:00
rte_ethdev_core.h ethdev: fix Rx/Tx spelling 2021-10-21 13:43:56 +02:00
rte_ethdev_trace_fp.h
rte_ethdev_trace.h ethdev: fix max Rx packet length 2021-10-18 19:20:20 +02:00
rte_ethdev.c ethdev: introduce protocol-based buffer split 2022-10-09 16:41:27 +02:00
rte_ethdev.h ethdev: introduce protocol-based buffer split 2022-10-09 16:41:27 +02:00
rte_flow_driver.h ethdev: add indirect action async query 2022-09-28 10:47:34 +02:00
rte_flow.c ethdev: add send to kernel action 2022-10-04 09:47:31 +02:00
rte_flow.h doc: relate bifurcated driver and flow isolated mode 2022-10-04 17:01:03 +02:00
rte_mtr_driver.h ethdev: add protocol parameter to color table update 2022-10-03 13:43:53 +02:00
rte_mtr.c ethdev: add protocol parameter to color table update 2022-10-03 13:43:53 +02:00
rte_mtr.h ethdev: add protocol parameter to color table update 2022-10-03 13:43:53 +02:00
rte_tm_driver.h
rte_tm.c
rte_tm.h ethdev: fix Rx/Tx spelling 2021-10-21 13:43:56 +02:00
sff_8079.c ethdev: support SFF-8079 module telemetry 2022-05-31 16:32:49 +02:00
sff_8472.c ethdev: support SFF-8472 module telemetry 2022-05-31 16:33:15 +02:00
sff_8636.c ethdev: support SFF-8636 module telemetry 2022-05-31 16:33:58 +02:00
sff_8636.h ethdev: support SFF-8636 module telemetry 2022-05-31 16:33:58 +02:00
sff_common.c ethdev: add common code for different SFF specs 2022-05-31 16:30:31 +02:00
sff_common.h ethdev: add common code for different SFF specs 2022-05-31 16:30:31 +02:00
sff_telemetry.c eal: remove unneeded includes from a public header 2022-09-21 15:31:03 +02:00
sff_telemetry.h ethdev: support SFF-8636 module telemetry 2022-05-31 16:33:58 +02:00
version.map ethdev: introduce protocol header API 2022-10-09 16:41:24 +02:00