support protocol based buffer split
cover support protocol based buffer split
Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 123 +++++++++++++- app/test-pmd/config.c | 70 ++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 6 +- app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 14 ++ drivers/net/ice/ice_ethdev.c | 35 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 88 ++++++++-- lib/ethdev/rte_ethdev.h | 41 ++++- lib/ethdev/version.map | 3 + 14 files changed, 606 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 24 +++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 80 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1054,6 +1054,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1301,6 +1313,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -5917,6 +5917,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL " +"when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get, -ENOTSUP ); + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +24 -0
@@ -6206,6 +6206,30 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 happens 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.
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
*/
};
If protocol header split can be supported by a PMD. The rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L3_IPV4, off0=2B
seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe packet consists of MAC_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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. Removed Items -------------
lib/ethdev/rte_ethdev.c +44 -11
79 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +16 -1
@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
PATCH 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=mac,[ipv4,udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs mac,ipv4,tcp,udp,sctp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs mac,ipv4 (default protocols of testpmd : mac|icmp|ipv4|ipv6|tcp|udp| sctp|inner_mac|inner_ipv4|inner_ipv6| inner_tcp|inner_udp|inner_sctp)
Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 123 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 70 ++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 6 +- app/test-pmd/testpmd.h | 6 ++ 5 files changed, 215 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +120 -3
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -307,6 +307,14 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (mac[,ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n\n" +" Supported proto header: mac|ipv4|ipv6|tcp|udp|sctp|" +"inner_mac|inner_ipv4|inner_ipv6|inner_tcp|inner_udp|inner_sctp\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3456,6 +3464,68 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"mac" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L3_IPV4 ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L3_IPV6 ; +else if (!strcmp (value,"tcp" )) + protocol =RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"udp" )) + protocol =RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"sctp" )) + protocol =RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"inner_mac" )) + protocol =RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner_ipv4" )) + protocol =RTE_PTYPE_INNER_L3_IPV4 ; +else if (!strcmp (value,"inner_ipv6" )) + protocol =RTE_PTYPE_INNER_L3_IPV6 ; +else if (!strcmp (value,"inner_tcp" )) + protocol =RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner_udp" )) + protocol =RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner_sctp" )) + protocol =RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3825,6 +3895,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <mac[,ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6918,6 +7032,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6930,12 +7046,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -14166,6 +14282,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +70 -0
76 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -164,6 +164,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -676,6 +677,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1331,7 +1333,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1341,6 +1342,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >=1 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +4 -2
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2680,11 +2681,12 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, mpx =mbuf_pool_find (socket_id, mp_n);/* Handle zero as mbuf data buffer size. */ rx_seg->length = rx_pkt_seg_lengths[i] ? - rx_pkt_seg_lengths[i] : - mbuf_data_size[mp_n]; + rx_pkt_seg_lengths[i] : + mbuf_data_size[mp_n]; rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -562,6 +562,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -892,6 +893,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmdline_read_from_file (const char *filename);int init_cmdline (void );
@@ -1049,6 +1053,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of ice pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 35 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 246 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -66,6 +66,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +33 -2
@@ -169,6 +169,7 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,static int ice_timesync_write_time (struct rte_eth_dev *dev,const struct timespec *timestamp);static int ice_timesync_disable (struct rte_eth_dev *dev); +static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get (struct rte_eth_dev *dev);static const struct rte_pci_id pci_id_ice_map[] = { {RTE_PCI_DEVICE (ICE_INTEL_VENDOR_ID ,ICE_DEV_ID_E823L_BACKPLANE ) },
@@ -280,6 +281,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = { .timesync_write_time = ice_timesync_write_time, .timesync_disable = ice_timesync_disable, .tm_ops_get = ice_tm_ops_get, + .buffer_split_supported_hdr_ptypes_get = ice_buffer_split_supported_hdr_ptypes_get, };/* store statistics names and its offset in stats structure */
@@ -3749,7 +3751,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |RTE_ETH_RX_OFFLOAD_RSS_HASH | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_QINQ_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3761,7 +3764,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->flow_type_rss_offloads |=ICE_RSS_OFFLOAD_ALL ; } - dev_info->rx_queue_offload_capa =0 ; + dev_info->rx_queue_offload_capa =RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_queue_offload_capa =RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ; dev_info->reta_size = pf->hash_lut_size;
@@ -3830,6 +3833,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->default_rxportconf.ring_size =ICE_BUF_SIZE_MIN ; dev_info->default_txportconf.ring_size =ICE_BUF_SIZE_MIN ; + dev_info->rx_seg_capa.max_nseg =ICE_RX_MAX_NSEG ; + dev_info->rx_seg_capa.multi_pools =1 ; + dev_info->rx_seg_capa.offset_allowed =0 ; + dev_info->rx_seg_capa.offset_align_log2 =0 ; +return 0 ; }
@@ -5886,6 +5894,29 @@ ice_timesync_disable(struct rte_eth_dev *dev)return 0 ; } +static const uint32_t * +ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +/* Buffer split protocol header capability. */ +static const uint32_t ptypes[] = { +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_L3_IPV4 , +RTE_PTYPE_L3_IPV6 , +RTE_PTYPE_L4_TCP , +RTE_PTYPE_L4_UDP , +RTE_PTYPE_L4_SCTP , +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_UNKNOWN + }; + +return ptypes; +} +static int ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev)
drivers/net/ice/ice_rxtx.c +190 -30
362 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -98,6 +112,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v2 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 123 +++++++++++++- app/test-pmd/config.c | 70 ++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 14 ++ drivers/net/ice/ice_ethdev.c | 30 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 88 ++++++++-- lib/ethdev/rte_ethdev.h | 41 ++++- lib/ethdev/version.map | 3 + 15 files changed, 600 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/4 ethdev: introduce protocol header API
In reply to Yuan WangAdd a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 24 +++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 80 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1054,6 +1054,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1301,6 +1313,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -5917,6 +5917,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL " +"when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get, -ENOTSUP ); + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +24 -0
@@ -6206,6 +6206,30 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH v2 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 happens 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.
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
*/
};
If protocol header split can be supported by a PMD. The rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L3_IPV4, off0=2B
seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe packet consists of MAC_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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. Removed Items -------------
lib/ethdev/rte_ethdev.c +44 -11
79 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +16 -1
@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
PATCH v2 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=mac,[ipv4,udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs mac,ipv4,tcp,udp,sctp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs mac,ipv4 (default protocols of testpmd : mac|icmp|ipv4|ipv6|tcp|udp| sctp|inner_mac|inner_ipv4|inner_ipv6| inner_tcp|inner_udp|inner_sctp)
Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 123 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 70 ++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 213 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +120 -3
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -307,6 +307,14 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (mac[,ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n\n" +" Supported proto header: mac|ipv4|ipv6|tcp|udp|sctp|" +"inner_mac|inner_ipv4|inner_ipv6|inner_tcp|inner_udp|inner_sctp\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3456,6 +3464,68 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"mac" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L3_IPV4 ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L3_IPV6 ; +else if (!strcmp (value,"tcp" )) + protocol =RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"udp" )) + protocol =RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"sctp" )) + protocol =RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"inner_mac" )) + protocol =RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner_ipv4" )) + protocol =RTE_PTYPE_INNER_L3_IPV4 ; +else if (!strcmp (value,"inner_ipv6" )) + protocol =RTE_PTYPE_INNER_L3_IPV6 ; +else if (!strcmp (value,"inner_tcp" )) + protocol =RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner_udp" )) + protocol =RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner_sctp" )) + protocol =RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3825,6 +3895,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <mac[,ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6918,6 +7032,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6930,12 +7046,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -14166,6 +14282,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +70 -0
76 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -164,6 +164,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -676,6 +677,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1331,7 +1333,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1341,6 +1342,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >=1 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2685,6 +2686,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -562,6 +562,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -892,6 +893,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmdline_read_from_file (const char *filename);int init_cmdline (void );
@@ -1049,6 +1053,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v2 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of ice pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 30 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 6 files changed, 242 insertions(+), 32 deletions(-)
doc/guides/nics/features/ice.ini +1 -0
@@ -7,6 +7,7 @@ ; is selected. ; [Features] +Buffer split = P Speed capabilities = Y Link status = Y Link status event = Y
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -66,6 +66,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +28 -2
@@ -169,6 +169,7 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,static int ice_timesync_write_time (struct rte_eth_dev *dev,const struct timespec *timestamp);static int ice_timesync_disable (struct rte_eth_dev *dev); +static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get (struct rte_eth_dev *dev);static const struct rte_pci_id pci_id_ice_map[] = { {RTE_PCI_DEVICE (ICE_INTEL_VENDOR_ID ,ICE_DEV_ID_E823L_BACKPLANE ) },
@@ -280,6 +281,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = { .timesync_write_time = ice_timesync_write_time, .timesync_disable = ice_timesync_disable, .tm_ops_get = ice_tm_ops_get, + .buffer_split_supported_hdr_ptypes_get = ice_buffer_split_supported_hdr_ptypes_get, };/* store statistics names and its offset in stats structure */
@@ -3749,7 +3751,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |RTE_ETH_RX_OFFLOAD_RSS_HASH | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_QINQ_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3761,7 +3764,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->flow_type_rss_offloads |=ICE_RSS_OFFLOAD_ALL ; } - dev_info->rx_queue_offload_capa =0 ; + dev_info->rx_queue_offload_capa =RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_queue_offload_capa =RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ; dev_info->reta_size = pf->hash_lut_size;
@@ -3830,6 +3833,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->default_rxportconf.ring_size =ICE_BUF_SIZE_MIN ; dev_info->default_txportconf.ring_size =ICE_BUF_SIZE_MIN ; + dev_info->rx_seg_capa.max_nseg =ICE_RX_MAX_NSEG ; + dev_info->rx_seg_capa.multi_pools =1 ; + dev_info->rx_seg_capa.offset_allowed =0 ; + dev_info->rx_seg_capa.offset_align_log2 =0 ; +return 0 ; }
@@ -5886,6 +5894,24 @@ ice_timesync_disable(struct rte_eth_dev *dev)return 0 ; } +static const uint32_t * +ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +/* Buffer split protocol header capability. */ +static const uint32_t ptypes[] = { +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_UNKNOWN + }; + +return ptypes; +} +static int ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev)
drivers/net/ice/ice_rxtx.c +190 -30
362 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -98,6 +112,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v3 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 123 +++++++++++++- app/test-pmd/config.c | 70 ++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 14 ++ drivers/net/ice/ice_ethdev.c | 30 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 88 ++++++++-- lib/ethdev/rte_ethdev.h | 41 ++++- lib/ethdev/version.map | 3 + 15 files changed, 600 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 24 +++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 80 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1054,6 +1054,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1301,6 +1313,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -5917,6 +5917,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL " +"when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get, -ENOTSUP ); + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +24 -0
@@ -6206,6 +6206,30 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
Re: [PATCH v3 1/4] ethdev: introduce protocol header API
Quoted 6 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>
Nit below. Other than that:
Quoted 12 lines
lib/ethdev/rte_ethdev.c +4
-0@@ -5917,6 +5917,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j;
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5933
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { + RTE_ETHDEV_LOG(ERR, + "Cannot get ethdev port %u supported header protocol types to NULL " + "when array size is non zero\n",
Do not split log message across many lines. Too long line is a less evil which is accepted by checkpatches.
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+ port_id); +return -EINVAL ; + }
[snip]
RE: [PATCH v3 1/4] ethdev: introduce protocol header API
Hi Andrew,
Quoted 50 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, September 12, 2022 7:25 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Ray Kinsella <[email protected]>
Cc: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v3 1/4] ethdev: introduce protocol header APIQuoted 6 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Nit below. Other than that:
Reviewed-by Andrew Rybchenko <[email protected]>lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE
Quoted 5 lines
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
1979dc0850..093c577add100644lib/ethdev/rte_ethdev.c +0
-0@@ -5917,6 +5917,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE*file)
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE · line 5917
Quoted 1 line
lib/ethdev/rte_ethdev.c +0
-0return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,file));
Quoted 5 lines
lib/ethdev/rte_ethdev.c +3
-0} +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id, +uint32_t *ptypes,int num) {lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { + RTE_ETHDEV_LOG(ERR, + "Cannot get ethdev port %u supported headerprotocol types to NULL "
Quoted 4 lines
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5933
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+ "when array size is non zero\n",Do not split log message across many lines. Too long line is a less evil which is accepted by checkpatches.
Thanks, will update in v4.
Thanks,
Yuan
Quoted 6 lines
Quoted 4 lines
lib/ethdev/rte_ethdev.c +3
-0+ port_id); +return -EINVAL ; + }[snip]
PATCH v3 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 happens 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.
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
*/
};
If protocol header split can be supported by a PMD. The rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L3_IPV4, off0=2B
seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe packet consists of MAC_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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. Removed Items -------------
lib/ethdev/rte_ethdev.c +44 -11
79 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +16 -1
@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
Quoted 20 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled 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_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.
Quoted 9 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from */uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
uint32_tproto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
If I understand correctly, the statement is a bit misleading since it should be a bit mask of RTE_PTYPE_* defines. Not exactly one RTE_PTYPE_*.
Quoted 7 lines
*/ };If protocol header split can be supported by a PMD. The
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use to obtain a list of these protocol headers.
Quoted 7 lines
For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BThe packet consists of
MAC_IPV4_UDP_PAYLOADwill be split like
What is MAC_IPV4_UDP_PAYLOAD? Do you mean ETH_IPV4_UDP_PAYLOAD?
Quoted 9 lines
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 pool2Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
You must define which mempool is used in the case.
Quoted 26 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0
doc/guides/rel_notes/release_22_11.rst New Features · line 67
Quoted 8 lines
doc/guides/rel_notes/release_22_11.rst +5
-0@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability.
Add one more empty line to have two before the next sectoin.
Quoted 32 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Items -------------lib/ethdev/rte_ethdev.c +5
-3@@ -1635,9 +1635,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa;struct rte_mempool *mp_first;@@ -1660,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1693,13 +1695,44 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ;
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1699
Quoted 10 lines
lib/ethdev/rte_ethdev.c +2
-7*mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , -"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n" , - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + +int ret =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 );
Do not mix variable declaration and code.
It is better to give the variable some sensible name. Otherwise else branch code is hard to read.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1700
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+if (ret <=0 ) {
May be I'm missing something, but nothing prevetns a driver/HW to support both protocol-based and fixed-length split. So, ability to support protocol based split should be treated as a request to do it. It must be based on rx_seg->proto_hdr content (for all segments).
Also nothing should prevent to mix protocol and fixed-length split. I.e. split just after UDP in the first segment, 40 bytes in the second segment, everything else in the third.
Quoted 5 lines
lib/ethdev/rte_ethdev.c +5
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1715
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id, ptypes, ret);
In theory, the funciton could fail since input arguments differ. So, it should be handled.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr)
IMHO it should be ==, not &. I think that rte_eth_buffer_split_get_supported_hdr_ptypes() should define points at which split could happen and we should match the point exactly.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1721
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+break ; + +if (i == ret) { +#define PTYPE_NAMESIZE 256
Why? It is looks really strange that it is defined here.
Quoted 66 lines
lib/ethdev/rte_ethdev.c +15
-1+char ptype_name[PTYPE_NAMESIZE ]; +rte_get_ptype_name (proto_hdr, ptype_name,sizeof (ptype_name)); +RTE_ETHDEV_LOG (ERR , +"Protocol header %s is not supported.\n" , + ptype_name); +return -EINVAL ; + } +if (*mbp_buf_size < offset) { +RTE_ETHDEV_LOG (ERR , +"%s mbuf_data_room_size %u < %u segment offset)\n" , + mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } } }return 0 ;@@ -1778,7 +1811,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) { - ret =rte_eth_rx_queue_check_split (rx_seg, n_seg, + ret =rte_eth_rx_queue_check_split (port_id, rx_seg, n_seg, &mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h +16
-1@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
RE: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Quoted 49 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, September 12, 2022 7:47 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 2 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled and Rx packetsegment
Quoted 9 lines
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.
Quoted 7 lines
This patch extends current buffer split to support protocol header based buffer split. A new
proto_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and correspondingprotocol
Quoted 1 line
header is configured, driver will split the ingress packets into multiple
segments.
Quoted 3 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from*/
Quoted 7 lines
uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
uint32_tproto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
Quoted 2 lines
If I understand correctly, the statement is a bit misleading since it should be a bit mask of RTE_PTYPE_* defines. Not exactly one RTE_PTYPE_*.
Do you mean that a segment should support multiple protocol headers, such as splitting both tcp and udp headers?
Quoted 14 lines
Quoted 14 lines
*/ };If protocol header split can be supported by a PMD. The
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L3_IPV4, off0=2B seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0B
Quoted 3 lines
Quoted 1 line
The packet consists of
MAC_IPV4_UDP_PAYLOADwill be split likeWhat is
MAC_IPV4_UDP_PAYLOAD? Do you meanETH_IPV4_UDP_PAYLOAD?
Thanks for your correction, it should be ETH_IPV4_UDP_PAYLOAD.
Quoted 7 lines
Quoted 3 lines
following:
seg0 - ipv4 header @RTE_PKTMBUF_HEADROOM+ 2 in mbuf frompool0
Quoted 3 lines
seg1 - udp header @ 128 in mbuf from pool1 seg2 - payload @ 0 in mbuf from pool2
Quoted 6 lines
Quoted 4 lines
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
You must define which mempool is used in the case.
IMHO I don't think we can define which mempool to use, it depends on NIC behavior. For our NIC, packets that are unable to split will be put into the last valid pool, with zero offset. So here we would like to define to put these packets into the last valid mempool, with zero offset.
Quoted 33 lines
Quoted 9 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.Quoted 3 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory,respectively.
Quoted 16 lines
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 60
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +0
-0header protocols of a PMD to split.
Quoted 8 lines
doc/guides/rel_notes/release_22_11.rst New Features · line 67
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst +6
-0+* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` +structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability.Add one more empty line to have two before the next sectoin.
Thanks for your catch.
Quoted 49 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct
Quoted 24 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
093c577add..dfceb723ee100644lib/ethdev/rte_ethdev.c +4
-3@@ -1635,9 +1635,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- rx_seg_capa;struct
rte_mempool*mp_first;lib/ethdev/rte_ethdev.c +0
-0@@ -1660,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667
Quoted 7 lines
lib/ethdev/rte_ethdev.c +1
-0struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1693,13
Quoted 1 line
+1695,44 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
} offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);lib/ethdev/rte_ethdev.c +0
-4- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 5 lines
lib/ethdev/rte_ethdev.c +2
-3- mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + int ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 5 lines
Quoted 1 line
+NULL, 0);
Do not mix variable declaration and code.
It is better to give the variable some sensible name. Otherwise else branch code is hard to read.
Thanks for the suggestion, will take care of naming.
Quoted 11 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1700
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-0+if (ret <=0 ) {May be I'm missing something, but nothing prevetns a driver/HW to support both protocol-based and fixed-length split.
So, ability to support protocol based split should be treated as a request to do it. It must be based onrx_seg->proto_hdrcontent (for all segments).Also nothing should prevent to mix protocol and fixed-length split. I.e. split just after UDP in the first segment,
40 bytes in the second segment, everything else in the third.
Mix mode is an interesting idea. Currently testpmd and driver do not support mixed mode, but it does not affect the library to support this mode.
Quoted 18 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 6 lines
lib/ethdev/rte_ethdev.c +5
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 4 lines
Quoted 1 line
+ptypes, ret);
In theory, the funciton could fail since input arguments differ. So, it should be handled.
Thanks for your catch, will fix in the next version.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr)IMHO it should be ==, not &. I think that
rte_eth_buffer_split_get_supported_hdr_ptypes()should define points at which split could happen and we should match the point exactly.
Sure, == is better. Thanks for the suggestion.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1721
Quoted 5 lines
lib/ethdev/rte_ethdev.c +4
-0+break ; + +if (i == ret) { +#define PTYPE_NAMESIZE 256Why? It is looks really strange that it is defined here.
I intend to display the protocol name in the log, but if the proto_hdr is a bit mask, can I just show the number? Please see v4 for this modification.
Quoted 75 lines
lib/ethdev/rte_ethdev.c
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+char ptype_name[PTYPE_NAMESIZE ]; + rte_get_ptype_name(proto_hdr,
ptype_name,sizeof(ptype_name));lib/ethdev/rte_ethdev.c
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+ RTE_ETHDEV_LOG(ERR, + "Protocol header %s is notsupported.\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 6 lines
lib/ethdev/rte_ethdev.c +6
-0+ ptype_name); +return -EINVAL ; + } +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_ethdev.c +4
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } } }return 0 ;@@ -1778,7 +1811,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,
uint16_trx_queue_id,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +0
-0n_seg = rx_conf->rx_nseg; if (rx_conf->offloads &
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1814
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-1- ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg,
n_seg,Quoted 22 lines
lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
c58c908c3a..410fba5eab100644lib/ethdev/rte_ethdev.h +4
-0@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1212
Quoted 10 lines
lib/ethdev/rte_ethdev.h +7
-0+* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1214
Quoted 2 lines
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
Quoted 9 lines
lib/ethdev/rte_ethdev.h +5
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
Quoted 51 lines · YuanX
Hi Andrew,
Quoted 49 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, September 12, 2022 7:47 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 2 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled and Rx packetsegment
Quoted 9 lines
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.
Quoted 7 lines
This patch extends current buffer split to support protocol header based buffer split. A new
proto_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and correspondingprotocol
Quoted 1 line
header is configured, driver will split the ingress packets into multiple
segments.
Quoted 3 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from*/
Quoted 7 lines
uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
uint32_tproto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*
Quoted 4 lines
Quoted 2 lines
If I understand correctly, the statement is a bit misleading since it should be a bit mask of RTE_PTYPE_* defines. Not exactly one RTE_PTYPE_*.
Do you mean that a segment should support multiple protocol headers, such as splitting both tcp and udp headers?
No-no. Look. In order to split after some protocol, for example UDP, NIC should recognice all previous protocols. Moreover, in the case of a tunenl UDP could be inner and outer. At which point would you like to split if NIC supports both? Another example, if NIC support stplit after Eth-IPv4-UDP and after Eth-IPv6-UDP, how to request to split just after Eth-IPv4-UDP, but not Eth-IPv6-UDP?
Quoted 33 lines
Quoted 15 lines
Quoted 15 lines
*/ };If protocol header split can be supported by a PMD. The
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L3_IPV4, off0=2B seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BQuoted 3 lines
Quoted 1 line
The packet consists of
MAC_IPV4_UDP_PAYLOADwill be split likeWhat is
MAC_IPV4_UDP_PAYLOAD? Do you meanETH_IPV4_UDP_PAYLOAD?Thanks for your correction, it should be
ETH_IPV4_UDP_PAYLOAD.Quoted 12 lines
Quoted 3 lines
following:
seg0 - ipv4 header @RTE_PKTMBUF_HEADROOM+ 2 in mbuf frompool0
Quoted 7 lines
seg1 - udp header @ 128 in mbuf from pool1 seg2 - payload @ 0 in mbuf from pool2
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
Quoted 5 lines
Quoted 1 line
You must define which mempool is used in the case.
IMHO I don't think we can define which mempool to use, it depends on NIC behavior. For our NIC, packets that are unable to split will be put into the last valid pool, with zero offset. So here we would like to define to put these packets into the last valid mempool, with zero offset.
Anyway API should not be silent about the case since it is the first question at least in my head. IMHO the last segment is the only sensible option since it is typically will be big enough. Other mempool for protocol headers are likely to be small. So, I suggest to define this way.
Quoted 109 lines
Quoted 33 lines
Quoted 9 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.Quoted 3 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory,respectively.
Quoted 16 lines
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 60
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +0
-0header protocols of a PMD to split.Quoted 8 lines
doc/guides/rel_notes/release_22_11.rst New Features · line 67
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst +6
-0+* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` +structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability.Add one more empty line to have two before the next sectoin.
Thanks for your catch.
Quoted 49 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct
Quoted 24 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
093c577add..dfceb723ee100644lib/ethdev/rte_ethdev.c +4
-3@@ -1635,9 +1635,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- rx_seg_capa;struct rte_mempool *mp_first;lib/ethdev/rte_ethdev.c +0
-0@@ -1660,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667
Quoted 7 lines
lib/ethdev/rte_ethdev.c +1
-0struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1693,13
Quoted 1 line
+1695,44 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
} offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);lib/ethdev/rte_ethdev.c +0
-4- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 5 lines
lib/ethdev/rte_ethdev.c +2
-3- mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + int ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 5 lines
Quoted 1 line
+NULL, 0);
Do not mix variable declaration and code.
It is better to give the variable some sensible name. Otherwise else branch code is hard to read.Thanks for the suggestion, will take care of naming.
Quoted 8 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1700
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-0+if (ret <=0 ) {May be I'm missing something, but nothing prevetns a driver/HW to support both protocol-based and fixed-length split.
So, ability to support protocol based split should be treated as a request to do it. It must be based onrx_seg->proto_hdrcontent (for all segments).
Quoted 5 lines
Quoted 3 lines
Also nothing should prevent to mix protocol and fixed-length split. I.e. split just after UDP in the first segment,
40 bytes in the second segment, everything else in the third.Mix mode is an interesting idea. Currently testpmd and driver do not support mixed mode, but it does not affect the library to support this mode.
That's OK.
Quoted 123 lines
Quoted 19 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
lib/ethdev/rte_ethdev.c +5
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 4 lines
Quoted 1 line
+ptypes, ret);
In theory, the funciton could fail since input arguments differ. So, it should be handled.
Thanks for your catch, will fix in the next version.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr)IMHO it should be ==, not &. I think that
rte_eth_buffer_split_get_supported_hdr_ptypes()should define points at which split could happen and we should match the point exactly.Sure, == is better. Thanks for the suggestion.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1721
Quoted 5 lines
lib/ethdev/rte_ethdev.c +4
-0+break ; + +if (i == ret) { +#define PTYPE_NAMESIZE 256Why? It is looks really strange that it is defined here.
I intend to display the protocol name in the log, but if the
proto_hdris a bit mask, can I just show the number? Please see v4 for this modification.Quoted 75 lines
lib/ethdev/rte_ethdev.c
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+char ptype_name[PTYPE_NAMESIZE ]; + rte_get_ptype_name(proto_hdr,
ptype_name,sizeof(ptype_name));lib/ethdev/rte_ethdev.c
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+ RTE_ETHDEV_LOG(ERR, + "Protocol header %s is notsupported.\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 6 lines
lib/ethdev/rte_ethdev.c +6
-0+ ptype_name); +return -EINVAL ; + } +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_ethdev.c +4
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } } }return 0 ;@@ -1778,7 +1811,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,
uint16_trx_queue_id,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +0
-0n_seg = rx_conf->rx_nseg; if (rx_conf->offloads &
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1814
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-1- ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg,
n_seg,Quoted 22 lines
lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
c58c908c3a..410fba5eab100644lib/ethdev/rte_ethdev.h +4
-0@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1212
Quoted 10 lines
lib/ethdev/rte_ethdev.h +7
-0+* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1214
Quoted 2 lines
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
Quoted 9 lines
lib/ethdev/rte_ethdev.h +5
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
RE: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Quoted 77 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, September 20, 2022 1:35 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 6 lines · YuanX
Hi Andrew,
Quoted 4 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, September 12, 2022 7:47 PM
To: Wang, YuanX <[email protected]>; [email protected]; ThomasMonjalon
Quoted 11 lines
Quoted 11 lines
<[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 3 lines
Quoted 3 lines · Yuan Wang
Quoted 2 lines
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled and Rxpacket
Quoted 9 lines
Quoted 9 lines
segment
Quoted 8 lines
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.
Quoted 25 lines
Quoted 25 lines
Quoted 8 lines
This patch extends current buffer split to support protocol header based buffer split. A new
proto_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and correspondingprotocol
Quoted 2 lines
header is configured, driver will split the ingress packets into multiple
segments.
Quoted 4 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate
segment from*/
Quoted 7 lines
uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
uint32_tproto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be defined by RTE_PTYPE_*Quoted 2 lines
Quoted 2 lines
If I understand correctly, the statement is a bit misleading since it should be a bit mask of RTE_PTYPE_* defines. Not exactly one
RTE_PTYPE_*.
Quoted 2 lines
Do you mean that a segment should support multiple protocol headers,
Quoted 8 lines
such as splitting both tcp and udp headers?
No-no. Look. In order to split after some protocol, for example UDP, NIC should recognice all previous protocols. Moreover, in the case of a tunenl UDP could be inner and outer. At which point would you like to split if NIC supports both?
Another example, if NIC support stplit after Eth-IPv4-UDP and after Eth-IPv6- UDP, how to request to split just after Eth-IPv4-UDP, but not Eth-IPv6-UDP?
Thank you for your patience.
We have a proposal to solve this problem.
We define the proto_hdr as a bit mask. Each mask should contain the composition of the packet, but inner and outer are written separately (to avoid unnecessary trouble). We use the highest RTE_PTYPE* in the mask to define the split position.
For the first example, since ptype has distinguished between outer and inner, external UDP can be simply written as RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP. The inner UDP can be simply written as RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP.
For the second example, Eth-IPv4-UDP can be written as RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP. Eth-IPv6-UDP can be written as RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP.
What do you think?
Thanks,
Yuan
Quoted 298 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
*/ };If protocol header split can be supported by a PMD. The
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be useto
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
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_L3_IPV4, off0=2B seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BThe packet consists of
MAC_IPV4_UDP_PAYLOADwill be split likeWhat is
MAC_IPV4_UDP_PAYLOAD? Do you mean
ETH_IPV4_UDP_PAYLOAD?Quoted 10 lines
Thanks for your correction, it should be
ETH_IPV4_UDP_PAYLOAD.Quoted 7 lines
Quoted 3 lines
following:
seg0 - ipv4 header @RTE_PKTMBUF_HEADROOM+ 2 in mbuf frompool0
Quoted 3 lines
seg1 - udp header @ 128 in mbuf from pool1 seg2 - payload @ 0 in mbuf from pool2
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header.
You must define which mempool is used in the case.
IMHO I don't think we can define which mempool to use, it depends on NIC
behavior.
Quoted 1 line
For our NIC, packets that are unable to split will be put into the last valid
pool, with zero offset.
Quoted 1 line
So here we would like to define to put these packets into the last valid
mempool, with zero offset.
Anyway API should not be silent about the case since it is the first question at least in my head. IMHO the last segment is the only sensible option since it is typically will be big enough. Other mempool for protocol headers are likely to be small. So, I suggest to define this way.
Quoted 32 lines
Quoted 32 lines
Quoted 9 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.Quoted 3 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory,respectively.
Quoted 17 lines
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 +++ lib/ethdev/rte_ethdev.c | 55 ++++++++++++++++++++------ lib/ethdev/rte_ethdev.h | 17 +++++++- 3 files changed, 65 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0@@ -60,6 +60,11 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, toQuoted 1 line
get
supported
Quoted 6 lines
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst
Quoted 6 lines
header protocols of a PMD to split.
doc/guides/rel_notes/release_22_11.rst +4
-0+* **Added protocol header based buffer split.** + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` +structure is + replaced with ``proto_hdr`` to support protocol header based buffersplit.
Quoted 19 lines
Quoted 5 lines
doc/guides/rel_notes/release_22_11.rst
Quoted 3 lines
doc/guides/rel_notes/release_22_11.rst +3
-0+ User can choose length or protocol header to configure buffer +split + according to NIC's capability.Add one more empty line to have two before the next sectoin.
Thanks for your catch.
Quoted 11 lines
Quoted 11 lines
Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
093c577add..dfceb723ee100644lib/ethdev/rte_ethdev.c +0
-0@@ -1635,9 +1635,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }Quoted 2 lines
Quoted 2 lines
lib/ethdev/rte_ethdev.c rte_eth_dev_is_removed(uint16_t port_id) · line 1638
Quoted 2 lines
lib/ethdev/rte_ethdev.c +0
-1static int -rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split
*rx_seg,Quoted 36 lines
Quoted 36 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct
Quoted 11 lines
lib/ethdev/rte_ethdev.c +4
-2- uint16_t n_seg, uint32_t *mbp_buf_size, - const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split(uint16_t port_id, + const struct rte_eth_rxseg_split *rx_seg, + uint16_t n_seg, uint32_t *mbp_buf_size, + const struct rte_eth_dev_info *dev_info) { const struct rte_eth_rxseg_capa *seg_capa = &dev_info- rx_seg_capa;struct rte_mempool *mp_first;lib/ethdev/rte_ethdev.c +0
-0@@ -1660,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667
Quoted 7 lines
lib/ethdev/rte_ethdev.c +1
-0struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1693,13
Quoted 1 line
+1695,44 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
} offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);lib/ethdev/rte_ethdev.c +0
-4- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 5 lines
lib/ethdev/rte_ethdev.c +2
-3- mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + int ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 15 lines
Quoted 5 lines
Quoted 1 line
+NULL, 0);
Do not mix variable declaration and code.
It is better to give the variable some sensible name. Otherwise else branch code is hard to read.Thanks for the suggestion, will take care of naming.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1700
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-0+if (ret <=0 ) {May be I'm missing something, but nothing prevetns a driver/HW to support both protocol-based and fixed-length split.
So, ability to support protocol based split should be treated as a request to do it. It must be based onrx_seg->proto_hdrcontent (for allsegments).
Quoted 6 lines
Quoted 4 lines
Also nothing should prevent to mix protocol and fixed-length split. I.e. split just after UDP in the first segment,
40 bytes in the second segment, everything else in the third.Mix mode is an interesting idea. Currently testpmd and driver do not
support mixed mode, but it does not affect the library to support this mode.
That's OK.
Quoted 37 lines
Quoted 19 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
lib/ethdev/rte_ethdev.c +5
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 4 lines
Quoted 1 line
+ptypes, ret);
In theory, the funciton could fail since input arguments differ. So, it should be handled.
Thanks for your catch, will fix in the next version.
Quoted 7 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr)IMHO it should be ==, not &. I think that
rte_eth_buffer_split_get_supported_hdr_ptypes()should define points at which split could happen and we should match the point exactly.Sure, == is better. Thanks for the suggestion.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1721
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+break ; + +if (i == ret) { +#define PTYPE_NAMESIZE 256Why? It is looks really strange that it is defined here.
I intend to display the protocol name in the log, but if the
proto_hdris a bitmask, can I just show the number?
Quoted 78 lines
Please see v4 for this modification.
Quoted 75 lines
lib/ethdev/rte_ethdev.c
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+char ptype_name[PTYPE_NAMESIZE ]; + rte_get_ptype_name(proto_hdr,
ptype_name,sizeof(ptype_name));lib/ethdev/rte_ethdev.c
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+ RTE_ETHDEV_LOG(ERR, + "Protocol header %s is notsupported.\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 6 lines
lib/ethdev/rte_ethdev.c +6
-0+ ptype_name); +return -EINVAL ; + } +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_ethdev.c +4
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } } }return 0 ;@@ -1778,7 +1811,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,
uint16_trx_queue_id,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +0
-0n_seg = rx_conf->rx_nseg; if (rx_conf->offloads &
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1814
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-1- ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg,
n_seg,Quoted 22 lines
lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
c58c908c3a..410fba5eab100644lib/ethdev/rte_ethdev.h +4
-0@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1196,12 +1199,24 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1212
Quoted 10 lines
lib/ethdev/rte_ethdev.h +7
-0+* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1214
Quoted 2 lines
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
Quoted 9 lines
lib/ethdev/rte_ethdev.h +5
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be defined by RTE_PTYPE_*. +*/ +uint32_t proto_hdr; };/**
RE: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangHi
Quoted 14 lines
-----Original Message-----
From: Yuan Wang <[email protected]>
Sent: Saturday, September 3, 2022 3:10 AM
To: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Yuan Wang <[email protected]>; Wenxuan Wu <[email protected]>
Subject: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
snip
Quoted 6 lines
lib/ethdev/rte_ethdev.c +0
-1@@ -1693,13 +1695,44 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ; *mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size;
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct · line 1702
Quoted 10 lines
lib/ethdev/rte_ethdev.c +2
-6-if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , - "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n", - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + int ret =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 );
One small question, since the ptypes == NULL and num == 0, I assume ret will always be <=0, right?
Quoted 22 lines
lib/ethdev/rte_ethdev.c +6
-0+if (ret <=0 ) { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =
rte_eth_buffer_split_get_supported_hdr_ptypes(port_id, ptypes, ret);lib/ethdev/rte_ethdev.c +4
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr) +break ; +
snip
RE: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer split
Hi
Quoted 48 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Tuesday, September 13, 2022 3:57 PM
To: Wang, YuanX <[email protected]>; [email protected]; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; Slava Ovsiienko <[email protected]>; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: RE: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitHi
Quoted 10 lines
-----Original Message-----
From: Yuan Wang <[email protected]>
Sent: Saturday, September 3, 2022 3:10 AM
To: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; [email protected]; [email protected];Quoted 5 lines
[email protected]; Yuan Wang <[email protected]>; Wenxuan Wu <[email protected]>
Subject: [PATCH v3 2/4] ethdev: introduce protocol hdr based buffer splitsnip
Quoted 11 lines
lib/ethdev/rte_ethdev.c +0
-5@@ -1693,13 +1695,44 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ; *mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n", - mpl->name, *mbp_buf_size,
Quoted 8 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 5 lines
lib/ethdev/rte_ethdev.c +2
-2- length + offset, length, offset); -return -EINVAL ; + +int ret =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 );One small question, since the ptypes == NULL and num == 0, I assume ret will always be <=0, right?
The usage of rte_eth_buffer_split_get_supported_hdr_ptypes is the same as rte_eth_dev_get_supported_ptypes.
In this scenario, the function returns the total number of supported ptypes, or an error code less than 0.
Quoted 25 lines
Quoted 23 lines
lib/ethdev/rte_ethdev.c +6
-0+if (ret <=0 ) { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } + }else { +/* Split after specified protocol header. */ +uint32_t ptypes[ret]; +int i; + + ret =
rte_eth_buffer_split_get_supported_hdr_ptypes(port_id, ptypes, ret);lib/ethdev/rte_ethdev.c +4
-0+for (i =0 ; i < ret; i++) +if (ptypes[i] & proto_hdr) +break ; +snip
PATCH v3 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=mac,[ipv4,udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs mac,ipv4,tcp,udp,sctp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs mac,ipv4 (default protocols of testpmd : mac|icmp|ipv4|ipv6|tcp|udp| sctp|inner_mac|inner_ipv4|inner_ipv6| inner_tcp|inner_udp|inner_sctp)
Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 123 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 70 ++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 213 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +120 -3
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -307,6 +307,14 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (mac[,ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n\n" +" Supported proto header: mac|ipv4|ipv6|tcp|udp|sctp|" +"inner_mac|inner_ipv4|inner_ipv6|inner_tcp|inner_udp|inner_sctp\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3456,6 +3464,68 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"mac" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L3_IPV4 ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L3_IPV6 ; +else if (!strcmp (value,"tcp" )) + protocol =RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"udp" )) + protocol =RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"sctp" )) + protocol =RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"inner_mac" )) + protocol =RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner_ipv4" )) + protocol =RTE_PTYPE_INNER_L3_IPV4 ; +else if (!strcmp (value,"inner_ipv6" )) + protocol =RTE_PTYPE_INNER_L3_IPV6 ; +else if (!strcmp (value,"inner_tcp" )) + protocol =RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner_udp" )) + protocol =RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner_sctp" )) + protocol =RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3825,6 +3895,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <mac[,ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6918,6 +7032,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6930,12 +7046,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -14166,6 +14282,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +70 -0
76 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -164,6 +164,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -676,6 +677,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1331,7 +1333,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1341,6 +1342,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >=1 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2685,6 +2686,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -562,6 +562,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -892,6 +893,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmdline_read_from_file (const char *filename);int init_cmdline (void );
@@ -1049,6 +1053,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v3 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of ice pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 30 +++- drivers/net/ice/ice_rxtx.c | 220 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 6 files changed, 242 insertions(+), 32 deletions(-)
doc/guides/nics/features/ice.ini +1 -0
@@ -7,6 +7,7 @@ ; is selected. ; [Features] +Buffer split = P Speed capabilities = Y Link status = Y Link status event = Y
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -66,6 +66,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +28 -2
@@ -169,6 +169,7 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,static int ice_timesync_write_time (struct rte_eth_dev *dev,const struct timespec *timestamp);static int ice_timesync_disable (struct rte_eth_dev *dev); +static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get (struct rte_eth_dev *dev);static const struct rte_pci_id pci_id_ice_map[] = { {RTE_PCI_DEVICE (ICE_INTEL_VENDOR_ID ,ICE_DEV_ID_E823L_BACKPLANE ) },
@@ -280,6 +281,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = { .timesync_write_time = ice_timesync_write_time, .timesync_disable = ice_timesync_disable, .tm_ops_get = ice_tm_ops_get, + .buffer_split_supported_hdr_ptypes_get = ice_buffer_split_supported_hdr_ptypes_get, };/* store statistics names and its offset in stats structure */
@@ -3749,7 +3751,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |RTE_ETH_RX_OFFLOAD_RSS_HASH | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_QINQ_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3761,7 +3764,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->flow_type_rss_offloads |=ICE_RSS_OFFLOAD_ALL ; } - dev_info->rx_queue_offload_capa =0 ; + dev_info->rx_queue_offload_capa =RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_queue_offload_capa =RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ; dev_info->reta_size = pf->hash_lut_size;
@@ -3830,6 +3833,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->default_rxportconf.ring_size =ICE_BUF_SIZE_MIN ; dev_info->default_txportconf.ring_size =ICE_BUF_SIZE_MIN ; + dev_info->rx_seg_capa.max_nseg =ICE_RX_MAX_NSEG ; + dev_info->rx_seg_capa.multi_pools =1 ; + dev_info->rx_seg_capa.offset_allowed =0 ; + dev_info->rx_seg_capa.offset_align_log2 =0 ; +return 0 ; }
@@ -5886,6 +5894,24 @@ ice_timesync_disable(struct rte_eth_dev *dev)return 0 ; } +static const uint32_t * +ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +/* Buffer split protocol header capability. */ +static const uint32_t ptypes[] = { +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_UNKNOWN + }; + +return ptypes; +} +static int ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev)
drivers/net/ice/ice_rxtx.c +190 -30
362 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -98,6 +112,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v4 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 124 +++++++++++++- app/test-pmd/config.c | 70 ++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 16 ++ drivers/net/ice/ice_ethdev.c | 32 +++- drivers/net/ice/ice_rxtx.c | 215 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 106 ++++++++++-- lib/ethdev/rte_ethdev.h | 49 +++++- lib/ethdev/version.map | 3 + 14 files changed, 625 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 32 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 24 +++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 79 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1054,6 +1054,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1301,6 +1313,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +32 -0
@@ -5917,6 +5917,38 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get, -ENOTSUP ); + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +24 -0
@@ -6206,6 +6206,30 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH v4 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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.
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* supported ptype of a specific pmd,
configures split point.
It should be a bit mask of RTE_PTYPE_* defines
*/
};
If protocol header split can be supported by a PMD. The rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L3_IPV4, off0=2B
seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe 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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 25 ++++++++- 3 files changed, 94 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +7 -0
@@ -60,6 +60,13 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------
lib/ethdev/rte_ethdev.c +63 -11
98 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +24 -1
@@ -1175,6 +1175,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1196,12 +1199,32 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Supported ptype of a specific pmd, configures split point. +* It should be a bit mask of RTE_PTYPE_* defines. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
PATCH v4 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth,[ipv4,udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,ipv4,udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,ipv4 (default protocols of testpmd : eth|ipv4|ipv6|tcp|udp|sctp| inner_eth|inner_ipv4|inner_ipv6| inner_tcp|inner_udp|inner_sctp)
Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 124 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 70 +++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 214 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +121 -3
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -307,6 +307,15 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|ipv4|ipv6|tcp|udp|sctp|" +"inner_eth|inner_ipv4|inner_ipv6|inner_tcp|inner_udp|" +"inner_sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3456,6 +3465,68 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L3_IPV4 ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L3_IPV6 ; +else if (!strcmp (value,"tcp" )) + protocol =RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"udp" )) + protocol =RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"sctp" )) + protocol =RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"inner_eth" )) + protocol =RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner_ipv4" )) + protocol =RTE_PTYPE_INNER_L3_IPV4 ; +else if (!strcmp (value,"inner_ipv6" )) + protocol =RTE_PTYPE_INNER_L3_IPV6 ; +else if (!strcmp (value,"inner_tcp" )) + protocol =RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner_udp" )) + protocol =RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner_sctp" )) + protocol =RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3825,6 +3896,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6918,6 +7033,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6930,12 +7047,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -14166,6 +14283,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +70 -0
76 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -164,6 +164,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -676,6 +677,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1331,7 +1333,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1341,6 +1342,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2685,6 +2686,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -562,6 +562,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -892,6 +893,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmdline_read_from_file (const char *filename);int init_cmdline (void );
@@ -1049,6 +1053,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v4 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 32 +++- drivers/net/ice/ice_rxtx.c | 215 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 238 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -67,6 +67,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +30 -2
@@ -169,6 +169,7 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,static int ice_timesync_write_time (struct rte_eth_dev *dev,const struct timespec *timestamp);static int ice_timesync_disable (struct rte_eth_dev *dev); +static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get (struct rte_eth_dev *dev);static const struct rte_pci_id pci_id_ice_map[] = { {RTE_PCI_DEVICE (ICE_INTEL_VENDOR_ID ,ICE_DEV_ID_E823L_BACKPLANE ) },
@@ -280,6 +281,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = { .timesync_write_time = ice_timesync_write_time, .timesync_disable = ice_timesync_disable, .tm_ops_get = ice_tm_ops_get, + .buffer_split_supported_hdr_ptypes_get = ice_buffer_split_supported_hdr_ptypes_get, };/* store statistics names and its offset in stats structure */
@@ -3749,7 +3751,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |RTE_ETH_RX_OFFLOAD_RSS_HASH | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_QINQ_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3761,7 +3764,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->flow_type_rss_offloads |=ICE_RSS_OFFLOAD_ALL ; } - dev_info->rx_queue_offload_capa =0 ; + dev_info->rx_queue_offload_capa =RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ; dev_info->tx_queue_offload_capa =RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ; dev_info->reta_size = pf->hash_lut_size;
@@ -3830,6 +3833,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->default_rxportconf.ring_size =ICE_BUF_SIZE_MIN ; dev_info->default_txportconf.ring_size =ICE_BUF_SIZE_MIN ; + dev_info->rx_seg_capa.max_nseg =ICE_RX_MAX_NSEG ; + dev_info->rx_seg_capa.multi_pools =1 ; + dev_info->rx_seg_capa.offset_allowed =0 ; + dev_info->rx_seg_capa.offset_align_log2 =0 ; +return 0 ; }
@@ -5886,6 +5894,26 @@ ice_timesync_disable(struct rte_eth_dev *dev)return 0 ; } +static const uint32_t * +ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +/* Buffer split protocol header capability. */ +static const uint32_t ptypes[] = { +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L3_IPV4 |RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_TCP |RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_UNKNOWN + }; + +return ptypes; +} +static int ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev)
drivers/net/ice/ice_rxtx.c +185 -30
357 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -98,6 +112,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v5 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v5:
Define proto_hdr to use mask instead of single protocol type. Define PMD to return protocol header mask.
Refine the doc and commit log.
Remove deprecated RTE_FUNC_PTR_OR_ERR_RET.
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 146 ++++++++++++++++- app/test-pmd/config.c | 88 ++++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 16 ++ drivers/net/ice/ice_ethdev.c | 55 ++++++- drivers/net/ice/ice_rxtx.c | 218 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 107 ++++++++++-- lib/ethdev/rte_ethdev.h | 59 ++++++- lib/ethdev/version.map | 3 + 14 files changed, 702 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -59,6 +59,11 @@ New Features * Added support to set device link down/up. +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1302,6 +1314,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +30 -0
@@ -5924,6 +5924,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* When a packet type is announced to be split, it *must* be supported by +* the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must +* return the following packet types for these packets: +* - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 +* - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH v5 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP
For inner ETH-IPV4-UDP, it should be defined as RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
/**
* Proto_hdr defines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_t proto_hdr;
};
If protocol header split can be supported by a PMD, the rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4
| RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe 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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +7 -0
@@ -64,6 +64,13 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------
lib/ethdev/rte_ethdev.c +63 -11
98 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +28 -1
@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* For non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
RE: [PATCH v5 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Did you get a chance to review this patch? Please let me know your thoughts on it.
Regards,
Yuan
Quoted 304 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Monday, September 26, 2022 5:41 PM
To: [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wang, YuanX <[email protected]>; Wenxuan Wu <[email protected]>
Subject: [PATCH v5 2/4] ethdev: introduce protocol hdr based buffer splitCurrently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled 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_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asRTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_L4_UDPFor inner ETH-IPV4-UDP, it should be defined as
RTE_PTYPE_TUNNEL_GRENAT|RTE_PTYPE_INNER_L2_ETHER|RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_INNER_L4_UDPstruct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from */uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_tproto_hdr;
};If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BThe packet consists of
ETH_IPV4_UDP_PAYLOADwill 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 pool2Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored.
For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0@@ -64,6 +64,13 @@ New Features Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
header protocols of a PMD to split.doc/guides/rel_notes/release_22_11.rst +4
-0+* **Added protocol header based buffer split.** + + Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` + structure is replaced with ``proto_hdr`` to support protocol header basedbuffer split.
doc/guides/rel_notes/release_22_11.rst +3
-0+ User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
1f0a7f8f3f..27ec19faed100644lib/ethdev/rte_ethdev.c +5
-3@@ -1649,9 +1649,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- >rx_seg_capa;struct rte_mempool *mp_first;@@ -1674,6 +1675,7 @@ rte_eth_rx_queue_check_split(const structrte_eth_rxseg_split *rx_seg, struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {lib/ethdev/rte_ethdev.c +14
-7RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1707,13 +1709,63 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ; *mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , - "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n", - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + if (proto_hdr > 0) { +/* Split based on protocol headers. */ + +/* skip the payload */ +if (proto_hdr ==RTE_PTYPE_ALL_MASK ) +continue ; + +int ptype_cnt; + + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 ); +if (ptype_cnt <=0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c +8
-0+ port_id); +return -EINVAL ; + } + +uint32_t ptypes[ptype_cnt]; +int i; + + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id, +
ptypes, ptype_cnt);lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c +10
-0+ port_id); +return -EINVAL ; + } + +for (i =0 ; i < ptype_cnt; i++) +if (ptypes[i] == proto_hdr) +break ; +if (i == ptype_cnt) { + RTE_ETHDEV_LOG(ERR, + "Requested Rx split header protocols0x%x is not supported.\n",
lib/ethdev/rte_ethdev.c +7
-0+ proto_hdr); +return -EINVAL ; + } + +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } + }else { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c +5
-1+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } } }return 0 ;@@ -1793,7 +1845,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) { - ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg, n_seg,lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
c440e3863a..ba7c11f735100644lib/ethdev/rte_ethdev.h +19
-0@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
lib/ethdev/rte_ethdev.h +2
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*,
lib/ethdev/rte_ethdev.h +1
-0+* configures split point. The last RTE_PTYPE* in the mask indicates the
lib/ethdev/rte_ethdev.h +2
-0+* split position. +* For non-tunneling packets, the complete protocol sequence should be defined.
lib/ethdev/rte_ethdev.h +4
-1+* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/** -- 2.25.1
PATCH v5 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth,[eth-ipv4,eth-ipv4-udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,eth-ipv4,eth-ipv4-udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4
(default protocols of testpmd : eth|eth-ipv4|eth-ipv6|
eth-ipv4-tcp|eth-ipv6-tcp|eth-ipv4-udp|eth-ipv6-udp|
eth-ipv4-sctp|eth-ipv6-sctp|grenat-eth|grenat-eth-ipv4|
grenat-eth-ipv6|grenat-eth-ipv4-tcp|grenat-eth-ipv6-tcp|
grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|grenat-eth-ipv4-sctp|
grenat-eth-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 146 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 88 +++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 254 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +143 -3
@@ -181,7 +181,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -305,6 +305,17 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,eth-ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|eth-ipv4|eth-ipv6|eth-ipv4-tcp|eth-ipv6-tcp|" +"eth-ipv4-udp|eth-ipv6-udp|eth-ipv4-sctp|eth-ipv6-sctp|" +"grenat-eth|grenat-eth-ipv4|grenat-eth-ipv6|grenat-eth-ipv4-tcp|" +"grenat-eth-ipv6-tcp|grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|" +"grenat-eth-ipv4-sctp|grenat-eth-ipv6-sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3366,6 +3377,88 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"eth-ipv4" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv6" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv4-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv6-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv4-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv6-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv4-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"eth-ipv6-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"grenat-eth" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"grenat-eth-ipv4" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv6" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv4-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv6-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv4-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv6-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv4-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"grenat-eth-ipv6-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3735,6 +3828,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,eth-ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6487,6 +6624,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6499,12 +6638,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -12455,6 +12594,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +88 -0
94 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -152,6 +152,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -660,6 +661,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1254,7 +1256,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1264,6 +1265,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2652,6 +2653,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -554,6 +554,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -825,6 +826,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmd_reconfig_device_queue (portid_t id,uint8_t dev,uint8_t queue);void cmdline_read_from_file (const char *filename);
@@ -974,6 +978,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v5 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 55 ++++++- drivers/net/ice/ice_rxtx.c | 218 +++++++++++++++++++++---- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 264 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -71,6 +71,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +53 -2
91 lines not on this page · raw message
drivers/net/ice/ice_rxtx.c +188 -30
360 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -98,6 +112,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v6 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v6:
ice: Fix proto_hdr mappings to NIC configuration.
v5:
Define proto_hdr to use mask instead of single protocol type. Define PMD to return protocol header mask.
Refine the doc and commit log.
Remove deprecated RTE_FUNC_PTR_OR_ERR_RET.
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 146 +++++++++++++- app/test-pmd/config.c | 88 +++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 16 ++ drivers/net/ice/ice_ethdev.c | 55 +++++- drivers/net/ice/ice_rxtx.c | 257 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 107 ++++++++-- lib/ethdev/rte_ethdev.h | 59 +++++- lib/ethdev/version.map | 3 + 14 files changed, 741 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v6 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the Tx Adapter from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1302,6 +1314,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +30 -0
@@ -6017,6 +6017,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* When a packet type is announced to be split, it *must* be supported by +* the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must +* return the following packet types for these packets: +* - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 +* - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH v6 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP
For inner ETH-IPV4-UDP, it should be defined as RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
/**
* Proto_hdr defines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_t proto_hdr;
};
If protocol header split can be supported by a PMD, the rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4
| RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe 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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +7 -0
@@ -101,6 +101,13 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------
lib/ethdev/rte_ethdev.c +63 -11
98 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +28 -1
@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* For non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
PATCH v6 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth,[eth-ipv4,eth-ipv4-udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,eth-ipv4,eth-ipv4-udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4
(default protocols of testpmd : eth|eth-ipv4|eth-ipv6|
eth-ipv4-tcp|eth-ipv6-tcp|eth-ipv4-udp|eth-ipv6-udp|
eth-ipv4-sctp|eth-ipv6-sctp|grenat-eth|grenat-eth-ipv4|
grenat-eth-ipv6|grenat-eth-ipv4-tcp|grenat-eth-ipv6-tcp|
grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|grenat-eth-ipv4-sctp|
grenat-eth-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 146 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 88 +++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 254 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +143 -3
@@ -181,7 +181,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -305,6 +305,17 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,eth-ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|eth-ipv4|eth-ipv6|eth-ipv4-tcp|eth-ipv6-tcp|" +"eth-ipv4-udp|eth-ipv6-udp|eth-ipv4-sctp|eth-ipv6-sctp|" +"grenat-eth|grenat-eth-ipv4|grenat-eth-ipv6|grenat-eth-ipv4-tcp|" +"grenat-eth-ipv6-tcp|grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|" +"grenat-eth-ipv4-sctp|grenat-eth-ipv6-sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3366,6 +3377,88 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"eth-ipv4" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv6" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv4-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv6-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv4-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv6-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv4-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"eth-ipv6-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"grenat-eth" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"grenat-eth-ipv4" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv6" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv4-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv6-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv4-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv6-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv4-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"grenat-eth-ipv6-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3735,6 +3828,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,eth-ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6487,6 +6624,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6499,12 +6638,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -12455,6 +12594,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +88 -0
94 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -152,6 +152,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -660,6 +661,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1254,7 +1256,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1264,6 +1265,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2652,6 +2653,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -554,6 +554,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -825,6 +826,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmd_reconfig_device_queue (portid_t id,uint8_t dev,uint8_t queue);void cmdline_read_from_file (const char *filename);
@@ -974,6 +978,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v6 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 55 +++++- drivers/net/ice/ice_rxtx.c | 257 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 303 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -108,6 +108,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + * Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +53 -2
91 lines not on this page · raw message
drivers/net/ice/ice_rxtx.c +227 -30
399 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -99,6 +113,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
RE: [PATCH v6 4/4] net/ice: support buffer split in Rx path
Quoted 23 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Friday, September 30, 2022 2:59 AM
To: [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wang, YuanX <[email protected]>; Wenxuan Wu <[email protected]>
Subject: [PATCH v6 4/4] net/ice: support buffer split in Rx pathThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
Quoted 7 lines
A new api
ice_buffer_split_supported_hdr_ptypes_get()has been introduced, it will return the supported header protocols of ice PMD to app for splitting.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>---
v7 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v7:
ice: Fix CI issue.
v6:
ice: Fix proto_hdr mappings to NIC configuration.
v5:
Define proto_hdr to use mask instead of single protocol type. Define PMD to return protocol header mask.
Refine the doc and commit log.
Remove deprecated RTE_FUNC_PTR_OR_ERR_RET.
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 146 +++++++++++++- app/test-pmd/config.c | 88 +++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 16 ++ drivers/net/ice/ice_ethdev.c | 55 +++++- drivers/net/ice/ice_rxtx.c | 259 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 107 ++++++++-- lib/ethdev/rte_ethdev.h | 59 +++++- lib/ethdev/version.map | 3 + 14 files changed, 743 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH v7 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the Tx Adapter from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1302,6 +1314,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +30 -0
@@ -6017,6 +6017,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* When a packet type is announced to be split, it *must* be supported by +* the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must +* return the following packet types for these packets: +* - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 +* - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +3 -0
@@ -285,6 +285,9 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
Re: [PATCH v7 1/4] ethdev: introduce protocol header API
Quoted 20 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)doc/guides/rel_notes/release_22_11.rst +0
-0
doc/guides/rel_notes/release_22_11.rst New Features · line 103
Quoted 8 lines
doc/guides/rel_notes/release_22_11.rst +5
-0@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the Tx Adapter from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. +
ethdev features should be grouped together in release notes. I'll fix it on applying if a new version is not required.
[snip]
Quoted 20 lines
lib/ethdev/rte_ethdev.c +12
-0@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { + RTE_ETHDEV_LOG(ERR,
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 6026
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types)
Should be compared with NULL explicitly as coding standard says. I can fix it on applying as well.
[snip]
RE: [PATCH v7 1/4] ethdev: introduce protocol header API
Hi Andrew,
Quoted 46 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 3:04 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v7 1/4] ethdev: introduce protocol header APIQuoted 21 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 96
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the TxAdapter
doc/guides/rel_notes/release_22_11.rst New Features
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst +4
-0from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported +protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
Quoted 5 lines
doc/guides/rel_notes/release_22_11.rst New Features · line 103
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +2
-0+ header protocols of a PMD to split. +ethdev features should be grouped together in release notes. I'll fix it on applying if a new version is not required.
We will send a new version. For the doc changes, I don't understand your point very well. Since will be no new changes to the code within this patch, could you help to adjust the doc? Thanks very much.
Quoted 27 lines
[snip]
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE
Quoted 5 lines
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
0c2c1088c0..1f0a7f8f3f100644lib/ethdev/rte_ethdev.c +0
-0@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE*file)
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE · line 6002
Quoted 1 line
lib/ethdev/rte_ethdev.c +0
-0return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,file));
Quoted 5 lines
lib/ethdev/rte_ethdev.c +3
-0} +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id, +uint32_t *ptypes,int num) {lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { + RTE_ETHDEV_LOG(ERR, + "Cannot get ethdev port %u supported headerprotocol types to NULL when array size is non zero\n",
Quoted 13 lines
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 6026
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = +(*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types)Should be compared with NULL explicitly as coding standard says. I can fix it on applying as well.
Sure, I will fix in v8.
Quoted 2 lines
[snip]
Re: [PATCH v7 1/4] ethdev: introduce protocol header API
Quoted 51 lines · YuanX
Hi Andrew,
Quoted 49 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 3:04 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v7 1/4] ethdev: introduce protocol header APIQuoted 21 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 96
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the TxAdapter
doc/guides/rel_notes/release_22_11.rst New Features
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst +4
-0from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported +protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +2
-0+ header protocols of a PMD to split. +
Quoted 6 lines
Quoted 2 lines
ethdev features should be grouped together in release notes. I'll fix it on applying if a new version is not required.
We will send a new version. For the doc changes, I don't understand your point very well. Since will be no new changes to the code within this patch, could you help to adjust the doc? Thanks very much.
Please, read a comment just after 'New Features' section start. Hopefully it will make my note clearer.
Anyway, don't worry about it a lot. I can easily fix it on applying.
Quoted 46 lines
Quoted 28 lines
[snip]
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE
Quoted 5 lines
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
0c2c1088c0..1f0a7f8f3f100644lib/ethdev/rte_ethdev.c +0
-0@@ -6002,6 +6002,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE*file)
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE · line 6002
Quoted 1 line
lib/ethdev/rte_ethdev.c +0
-0return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,file));
Quoted 5 lines
lib/ethdev/rte_ethdev.c +3
-0} +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id, +uint32_t *ptypes,int num) {lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { + RTE_ETHDEV_LOG(ERR, + "Cannot get ethdev port %u supported headerprotocol types to NULL when array size is non zero\n",
Quoted 13 lines
lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 6026
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = +(*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (!all_types)Should be compared with NULL explicitly as coding standard says. I can fix it on applying as well.
Sure, I will fix in v8.
Quoted 2 lines
[snip]
RE: [PATCH v7 1/4] ethdev: introduce protocol header API
Hi Andrew,
Quoted 73 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, October 4, 2022 3:53 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v7 1/4] ethdev: introduce protocol header APIQuoted 6 lines · YuanX
Hi Andrew,
Quoted 4 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 3:04 PM
To: Wang, YuanX <[email protected]>; [email protected]; ThomasMonjalon
Quoted 43 lines
Quoted 43 lines
<[email protected]>; Ferruh Yigit <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v7 1/4] ethdev: introduce protocol header APIQuoted 21 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 86 insertions(+)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 96
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -96,6 +96,11 @@ New Features * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the TxAdapter
doc/guides/rel_notes/release_22_11.rst New Features · line 103
Quoted 7 lines
doc/guides/rel_notes/release_22_11.rst +5
-0from enqueueing any packets to the Tx queue. +* **Added new ethdev API for PMD to get buffer split supported +protocol types.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to + getsupported
Quoted 7 lines
Quoted 5 lines
doc/guides/rel_notes/release_22_11.rst New Features · line 103
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +2
-0+ header protocols of a PMD to split. +ethdev features should be grouped together in release notes. I'll fix it on applying if a new version is not required.
We will send a new version. For the doc changes, I don't understand your
Quoted 8 lines
point very well.
Quoted 1 line
Since will be no new changes to the code within this patch, could you help
to adjust the doc?
Quoted 1 line
Thanks very much.
Please, read a comment just after 'New Features' section start. Hopefully it will make my note clearer.
Anyway, don't worry about it a lot. I can easily fix it on applying.
Is it written like the following, if it is not correct please help to fix.
* **Added protocol header based buffer split.**
* Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split.
* Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is replaced with ``proto_hdr`` to support protocol header based buffer split. User can choose length or protocol header to configure buffer split according to NIC's capability.
Thanks,
Yuan
[snip]
PATCH v7 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP
For inner ETH-IPV4-UDP, it should be defined as RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
/**
* Proto_hdr defines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_t proto_hdr;
};
If protocol header split can be supported by a PMD, the rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4
| RTE_PTYPE_L4_UDP, off1=128B
seg2 - pool2, off1=0BThe 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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +7 -0
@@ -101,6 +101,13 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------
lib/ethdev/rte_ethdev.c +63 -11
98 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +28 -1
@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* For non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
RE: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer split
Hi All,
Could you please review and provide suggestions if any.
Thanks,
Yuan
Quoted 305 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Sunday, October 2, 2022 5:05 AM
To: [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wang, YuanX <[email protected]>; Wenxuan Wu <[email protected]>
Subject: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer splitCurrently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled 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_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asRTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_L4_UDPFor inner ETH-IPV4-UDP, it should be defined as
RTE_PTYPE_TUNNEL_GRENAT|RTE_PTYPE_INNER_L2_ETHER|RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_INNER_L4_UDPstruct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from */uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_tproto_hdr;
};If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BThe packet consists of
ETH_IPV4_UDP_PAYLOADwill 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 pool2Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored.
For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0@@ -101,6 +101,13 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
header protocols of a PMD to split.doc/guides/rel_notes/release_22_11.rst +7
-0+* **Added protocol header based buffer split.** + + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
1f0a7f8f3f..27ec19faed100644lib/ethdev/rte_ethdev.c +5
-3@@ -1649,9 +1649,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- >rx_seg_capa;struct rte_mempool *mp_first;@@ -1674,6 +1675,7 @@ rte_eth_rx_queue_check_split(const structrte_eth_rxseg_split *rx_seg, struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {lib/ethdev/rte_ethdev.c +14
-7RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1707,13 +1709,63 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ; *mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , - "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n", - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + + if (proto_hdr > 0) { +/* Split based on protocol headers. */ + +/* skip the payload */ +if (proto_hdr ==RTE_PTYPE_ALL_MASK ) +continue ; + +int ptype_cnt; + + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 ); +if (ptype_cnt <=0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c +8
-0+ port_id); +return -EINVAL ; + } + +uint32_t ptypes[ptype_cnt]; +int i; + + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id, +
ptypes, ptype_cnt);lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c +10
-0+ port_id); +return -EINVAL ; + } + +for (i =0 ; i < ptype_cnt; i++) +if (ptypes[i] == proto_hdr) +break ; +if (i == ptype_cnt) { + RTE_ETHDEV_LOG(ERR, + "Requested Rx split header protocols0x%x is not supported.\n",
lib/ethdev/rte_ethdev.c +7
-0+ proto_hdr); +return -EINVAL ; + } + +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } + }else { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c +5
-1+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } } }return 0 ;@@ -1793,7 +1845,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) { - ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg, n_seg,lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
cf14e04010..a5f9647bd3100644lib/ethdev/rte_ethdev.h +19
-0@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
lib/ethdev/rte_ethdev.h +2
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*,
lib/ethdev/rte_ethdev.h +1
-0+* configures split point. The last RTE_PTYPE* in the mask indicates the
lib/ethdev/rte_ethdev.h +2
-0+* split position. +* For non-tunneling packets, the complete protocol sequence should be defined.
lib/ethdev/rte_ethdev.h +4
-1+* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/** -- 2.25.1
Re: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangQuoted 77 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled 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_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asRTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_L4_UDPFor inner ETH-IPV4-UDP, it should be defined as
RTE_PTYPE_TUNNEL_GRENAT|RTE_PTYPE_INNER_L2_ETHER|RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_INNER_L4_UDPstruct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from */uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_tproto_hdr;
};If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BThe packet consists of
ETH_IPV4_UDP_PAYLOADwill 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 pool2Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.
Quoted 7 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>
I apologize for delay with review. Overall LGTM now. See few notes below.
Quoted 11 lines
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0
doc/guides/rel_notes/release_22_11.rst New Features · line 110
Quoted 10 lines
doc/guides/rel_notes/release_22_11.rst +7
-0@@ -101,6 +101,13 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. +
It should be grouped together with other ethdev features.
Quoted 33 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Items -------------lib/ethdev/rte_ethdev.c +5
-3@@ -1649,9 +1649,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa;struct rte_mempool *mp_first;@@ -1674,6 +1675,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1707,13 +1709,63 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ; *mbp_buf_size =rte_pktmbuf_data_room_size (mpl);
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1714
Quoted 10 lines
lib/ethdev/rte_ethdev.c +3
-7- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , -"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n" , - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + +if (proto_hdr >0 ) { +/* Split based on protocol headers. */
Isn't safer here to ensure that segment length is set to 0? Just to protect agains misusage etc.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1716
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+ +/* skip the payload */
Sorry, it is confusing. What do you mean here?
Quoted 5 lines
lib/ethdev/rte_ethdev.c +5
-0+if (proto_hdr ==RTE_PTYPE_ALL_MASK ) +continue ; + +int ptype_cnt; +
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1731
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 ); +if (ptype_cnt <=0 ) { +RTE_ETHDEV_LOG (ERR , +"Port %u failed to supported buffer split header protocols\n" , + port_id); +return -EINVAL ; + } + +uint32_t ptypes[ptype_cnt]; +int i;
First of all do no mix code and variable declaration. It significantly complicates code reading. Second creation of an array on stack based on function return value is very dangerours from security point of view - potential stack overflow and corresponding vulnerabilities.
Quoted 11 lines
lib/ethdev/rte_ethdev.c +11
-0+ + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id, + ptypes, ptype_cnt); +if (ptype_cnt <0 ) { +RTE_ETHDEV_LOG (ERR , +"Port %u failed to supported buffer split header protocols\n" , + port_id); +return -EINVAL ; + } + +for (i =0 ; i < ptype_cnt; i++)
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1752
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+if (ptypes[i] == proto_hdr) +break ; +if (i == ptype_cnt) { +RTE_ETHDEV_LOG (ERR , +"Requested Rx split header protocols 0x%x is not supported.\n" , + proto_hdr); +return -EINVAL ; + } + +if (*mbp_buf_size < offset) {
The check is obviously insufficient, but I agree that it should be driver reponsibility to do extra checks for required space in mbuf.
Quoted 43 lines
lib/ethdev/rte_ethdev.c +17
-1+RTE_ETHDEV_LOG (ERR , +"%s mbuf_data_room_size %u < %u segment offset)\n" , + mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } + }else { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { +RTE_ETHDEV_LOG (ERR , +"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n" , + mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } } }return 0 ;@@ -1793,7 +1845,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) { - ret =rte_eth_rx_queue_check_split (rx_seg, n_seg, + ret =rte_eth_rx_queue_check_split (port_id, rx_seg, n_seg, &mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h +3
-0@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1024
Quoted 7 lines
lib/ethdev/rte_ethdev.h +4
-0@@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored.
Looking at the code above I think proto_hdr must be 0.
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1028
Quoted 4 lines
lib/ethdev/rte_ethdev.h +4
-0+* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored.
I'd require length to be 0 to avoid misusage of the API.
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1036
Quoted 8 lines
lib/ethdev/rte_ethdev.h +8
-0+* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset
Shoundl't be check that dataroom in the last segment mempool is sufficient for up to MTU packet if Rx scatter is disabled?
Quoted 18 lines
lib/ethdev/rte_ethdev.h +9
-1*/ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* For non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/**
RE: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Quoted 102 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 3:47 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 2 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled and Rx packetsegment
Quoted 9 lines
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.
Quoted 7 lines
This patch extends current buffer split to support protocol header based buffer split. A new
proto_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and correspondingprotocol
Quoted 1 line
header is configured, driver will split the ingress packets into multiple
segments.
Quoted 4 lines
Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asRTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|
RTE_PTYPE_L4_UDPQuoted 7 lines
For inner ETH-IPV4-UDP, it should be defined as
RTE_PTYPE_TUNNEL_GRENAT|RTE_PTYPE_INNER_L2_ETHER|RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_INNER_L4_UDPstruct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from*/
Quoted 28 lines
uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* For non-tunneling packets, the complete protocol sequence
* should be defined.
* For tunneling packets, for simplicity, only the tunnel and
* inner protocol sequence should be defined.
*/
uint32_tproto_hdr;
};If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, off1=128B seg2 - pool2, off1=0BQuoted 3 lines
The packet consists of
ETH_IPV4_UDP_PAYLOADwill be split like following:
seg0 - ipv4 header @RTE_PKTMBUF_HEADROOM+ 2 in mbuf frompool0
Quoted 16 lines
seg1 - udp header @ 128 in mbuf from pool1 seg2 - payload @ 0 in mbuf from pool2
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.Quoted 3 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory,
Quoted 7 lines
respectively.
Quoted 4 lines
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>I apologize for delay with review. Overall LGTM now. See few notes below.
Thanks so much for your time and patience for this patch series.
Quoted 22 lines
Quoted 13 lines
--- doc/guides/rel_notes/release_22_11.rst | 7 +++ lib/ethdev/rte_ethdev.c | 74 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 29 +++++++++- 3 files changed, 98 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 101
Quoted 1 line
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -101,6 +101,13 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
doc/guides/rel_notes/release_22_11.rst New Features
Quoted 6 lines
doc/guides/rel_notes/release_22_11.rst +4
-0header protocols of a PMD to split. +* **Added protocol header based buffer split.** + + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffersplit.
Quoted 5 lines
doc/guides/rel_notes/release_22_11.rst New Features · line 110
Quoted 3 lines
doc/guides/rel_notes/release_22_11.rst +3
-0+ User can choose length or protocol header to configure buffer split + according to NIC's capability. +It should be grouped together with other ethdev features.
We will send a new version. For the doc changes, the same as patch 1, could you help to adjust the doc? Thanks very much.
Quoted 43 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct
Quoted 24 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Items -------------lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
1f0a7f8f3f..27ec19faed100644lib/ethdev/rte_ethdev.c +4
-3@@ -1649,9 +1649,10 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- rx_seg_capa;struct
rte_mempool*mp_first;lib/ethdev/rte_ethdev.c +0
-0@@ -1674,6 +1675,7 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1681
Quoted 7 lines
lib/ethdev/rte_ethdev.c +1
-0struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1707,13
Quoted 1 line
+1709,63 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
} offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);lib/ethdev/rte_ethdev.c +0
-4- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
Quoted 9 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1714
Quoted 6 lines
lib/ethdev/rte_ethdev.c +3
-3- mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + +if (proto_hdr >0 ) { +/* Split based on protocol headers. */ Isn't safer here to ensure that segment length is set to 0? Just to protect agains misusage etc.
It's a reasonable suggestion, I will take it, please see v8.
Quoted 5 lines
lib/ethdev/rte_ethdev.c
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+ +/* skip the payload */ Sorry, it is confusing. What do you mean here?
Because setting n proto_hdr will generate (n+1) segments. If we want to split the packet into n segments, we only need to check the first (n-1) proto_hdr. For example, for ETH-IPV4-UDP-PAYLOAD, if we want to split after the UDP header, we only need to set and check the UDP header in the first segment.
Maybe mask is not a good way, so we will use index to filter out the check of proto_hdr inside the last segment.
Quoted 12 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
lib/ethdev/rte_ethdev.c +6
-0+if (proto_hdr ==RTE_PTYPE_ALL_MASK ) +continue ; + +int ptype_cnt; + + ptype_cnt =
rte_eth_buffer_split_get_supported_hdr_ptypes(port_id, NULL, 0);lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <=0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
Quoted 9 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1731
Quoted 6 lines
lib/ethdev/rte_ethdev.c +6
-0+ port_id); +return -EINVAL ; + } + +uint32_t ptypes[ptype_cnt]; +int i;First of all do no mix code and variable declaration. It significantly complicates code reading.
Thanks, the code and variable declaration will be separated.
Quoted 3 lines
Second creation of an array on stack based on function return value is very dangerours from security point of view - potential stack overflow and corresponding vulnerabilities.
The function value is used for defining how much space is needed to store ptypes. Thanks for your correction of stack overflow, we will use heap instead.
Quoted 88 lines
lib/ethdev/rte_ethdev.c
Quoted 3 lines
lib/ethdev/rte_ethdev.c +2
-0+ + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 1 line
+
ptypes, ptype_cnt);lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ port_id); +return -EINVAL ; + } + +for (i =0 ; i < ptype_cnt; i++) +if (ptypes[i] == proto_hdr) +break ; +if (i == ptype_cnt) { + RTE_ETHDEV_LOG(ERR, + "Requested Rx split header protocols0x%x is not supported.\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1752
Quoted 5 lines
lib/ethdev/rte_ethdev.c +5
-0+ proto_hdr); +return -EINVAL ; + } + +if (*mbp_buf_size < offset) {The check is obviously insufficient, but I agree that it should be driver reponsibility to do extra checks for required space in mbuf.
lib/ethdev/rte_ethdev.c
Quoted 2 lines
lib/ethdev/rte_ethdev.c +2
-0+ RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } + }else { +/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_ethdev.c +4
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + } } }return 0 ;@@ -1793,7 +1845,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,
uint16_trx_queue_id,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +0
-0n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ){
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1848
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-1- ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg,
n_seg,Quoted 18 lines
lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
cf14e04010..a5f9647bd3100644lib/ethdev/rte_ethdev.h +3
-0@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1024
Quoted 7 lines
lib/ethdev/rte_ethdev.h +4
-0@@ -1015,12 +1018,36 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field will be ignored. Looking at the code above I think
proto_hdrmust be 0.
Quoted 6 lines
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1028
Quoted 4 lines
lib/ethdev/rte_ethdev.h +4
-0+* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field will be ignored. I'd require length to be 0 to avoid misusage of the API.
Sure, we will fix them in v8.
Quoted 10 lines
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1036
Quoted 9 lines
lib/ethdev/rte_ethdev.h +8
-0+* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset
Quoted 2 lines
Shoundl't be check that dataroom in the last segment mempool is sufficient for up to MTU packet if Rx scatter is disabled?
Yes, we will add this check in the last segment.
Thanks,
Yuan
Quoted 24 lines
lib/ethdev/rte_ethdev.h struct rte_eth_txmode {
Quoted 4 lines
lib/ethdev/rte_ethdev.h +0
-0*/ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1041
Quoted 2 lines
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode {
Quoted 3 lines
lib/ethdev/rte_ethdev.h +2
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*,
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1044
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+* configures split point. The last RTE_PTYPE* in the mask indicates the
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1046
Quoted 2 lines
lib/ethdev/rte_ethdev.h +2
-0+* split position. +* For non-tunneling packets, the complete protocol sequence should be defined.
Quoted 7 lines
lib/ethdev/rte_ethdev.h +4
-0+* For tunneling packets, for simplicity, only the tunnel and inner +* protocol sequence should be defined. +*/ +uint32_t proto_hdr; };/**
Re: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer split
Quoted 9 lines · YuanX
Hi Andrew,
Quoted 6 lines
-----Original Message-----
Review
Quoted 2 lines · Yuan Wang
(quoted diff) +2
-0+ + /* skip the payload */Sorry, it is confusing. What do you mean here?
Quoted 4 lines
Because setting n
proto_hdrwill generate (n+1) segments. If we want to split the packet into n segments, we only need to check the first (n-1)proto_hdr. For example, for ETH-IPV4-UDP-PAYLOAD, if we want to split after the UDP header, we only need to set and check the UDP header in the first segment.Maybe mask is not a good way, so we will use index to filter out the check of
proto_hdrinside the last segment.
I see your point and understand the problem now.
Thinking a bit more about it I realize that consistency check here should be more sophisticated.
It should not allow:
- seg1 - length-based, seg2 - proto-based, seg3 - payload
- seg1 - proto-based, seg2 - legnth-based, seg3 - proto-based, seg4 -
payload
I.e. no protocol-based split after length-based.
But should allow:
- seg1 - proto-based, seg2 - legnth-based, seg3 - payload
I.e. length based split after protocol-based.
Taking the last point above into account, proto_hdr in the last segment should be 0 like in length-based split (not RTE_PTYPE_ALL_MASK).
It is an interesting question how to request:
- seg1 - ETH, seg2 - IPv4, seg3 - UDP, seg4 - payload
Should we really repeat ETH in seg2->proto_hdr and seg3->proto_hdr header and IPv4 in seg3->proto_hdr again? I tend to say no since when packet comes to seg2 it already has no ETH header.
If so, how to handle configuration when ETH is repeat in seg2? For example,
- seg1 ETH+IPv4+UDP
- seg2 ETH+IPv6+UDP
- seg2 0
Should we deny it or should we define behaviour like. If a packet does not match segX proto_hdr, the segment is skipped and segX+1 considered.
Of course, not all drivers/HW supports it. If so, such configuration should be just discarded by the driver itself.
RE: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Quoted 44 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, October 4, 2022 4:23 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>
Subject: Re: [PATCH v7 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 10 lines · YuanX
Hi Andrew,
Quoted 6 lines
-----Original Message-----
Review
Quoted 2 lines · Yuan Wang
(quoted diff) +2
-0+ + /* skip the payload */Sorry, it is confusing. What do you mean here?
Because setting n
proto_hdrwill generate (n+1) segments. If we want tosplit the packet into n segments, we only need to check the first (n-1)
proto_hdr.Quoted 1 line
For example, for ETH-IPV4-UDP-PAYLOAD, if we want to split after the UDP
header, we only need to set and check the UDP header in the first segment.
Quoted 2 lines
Maybe mask is not a good way, so we will use index to filter out the check
of
proto_hdrinside the last segment.I see your point and understand the problem now.
Thinking a bit more about it I realize that consistency check here should be more sophisticated.
It should not allow:
- seg1 - length-based, seg2 - proto-based, seg3 - payload
- seg1 - proto-based, seg2 - legnth-based, seg3 - proto-based, seg4 - payload
I.e. no protocol-based split after length-based.
But should allow:
- seg1 - proto-based, seg2 - legnth-based, seg3 - payload I.e. length based
split after protocol-based.
Quoted 2 lines
Taking the last point above into account,
proto_hdrin the last segment should be 0 like in length-based split (notRTE_PTYPE_ALL_MASK).
Just to confirm, do you mean that the payload as last segment should be treated as a length-based split(proto_hdr == 0)?
If so, for this question, 'check that dataroom in the last segment mempool is sufficient> for up to MTU packet if Rx scatter is disabled'
Is it not necessary to compare MTU size and mbuf_size? Because the check in length based split is sufficient. We will send v8 soon with above thought, please help to check.
Quoted 8 lines
It is an interesting question how to request:
- seg1 - ETH, seg2 - IPv4, seg3 - UDP, seg4 - payload Should we really repeat
ETH inseg2->proto_hdrandseg3->proto_hdrheader and IPv4 inseg3->proto_hdragain?
I tend to say no since when packet comes to seg2 it already has no ETH header.
Quoted 10 lines
If so, how to handle configuration when ETH is repeat in seg2? For example,
- seg1 ETH+IPv4+UDP
- seg2 ETH+IPv6+UDP
- seg2 0
Should we deny it or should we define behaviour like.
If a packet does not match segXproto_hdr, the segment is skipped and segX+1 considered.
Of course, not alldrivers/HWsupports it. If so, such configuration should be just discarded by the driver itself.
Here a question that needs to be clarified, whether the segments are sequential or independent. I prefer the former because it's more readable. Furthermore, it consists with length based split, which also configures the lengths sequentially. In this case, the following situation does not exist:
- seg1 ETH+IPv4+UDP
- seg2 ETH+IPv6+UDP
- seg3 0
For the case of repeating ETH, such as - seg1 - ETH, seg2 - IPv4, seg3 - UDP, seg4 - payload, as you suggested, we can omit ETH in the following segment. but IPV4-UDP and IPV6-UDP still need to be distinguished, follow our previous discussion (user wants to split at IPV4-UDP rather than IPV6-UDP although driver supports both). In this case, seg1 - ETH, seg2 - IPv4, seg3 - UDP, seg4 - payload, we set proto_hdr with:
seg1 proto_hdr1=RTE_PTYPE_L2_ETHER
seg2 proto_hdr2=RTE_PTYPE_L3_IPV4
seg3 proto_hdr3=RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP
Thanks,
Yuan
PATCH v7 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth,[eth-ipv4,eth-ipv4-udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,eth-ipv4,eth-ipv4-udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4
(default protocols of testpmd : eth|eth-ipv4|eth-ipv6|
eth-ipv4-tcp|eth-ipv6-tcp|eth-ipv4-udp|eth-ipv6-udp|
eth-ipv4-sctp|eth-ipv6-sctp|grenat-eth|grenat-eth-ipv4|
grenat-eth-ipv6|grenat-eth-ipv4-tcp|grenat-eth-ipv6-tcp|
grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|grenat-eth-ipv4-sctp|
grenat-eth-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 146 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 88 +++++++++++++++++++++++ app/test-pmd/parameters.c | 16 ++++- app/test-pmd/testpmd.c | 2 + app/test-pmd/testpmd.h | 6 ++ 5 files changed, 254 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +143 -3
@@ -181,7 +181,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -305,6 +305,17 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,eth-ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|eth-ipv4|eth-ipv6|eth-ipv4-tcp|eth-ipv6-tcp|" +"eth-ipv4-udp|eth-ipv6-udp|eth-ipv4-sctp|eth-ipv6-sctp|" +"grenat-eth|grenat-eth-ipv4|grenat-eth-ipv6|grenat-eth-ipv4-tcp|" +"grenat-eth-ipv6-tcp|grenat-eth-ipv4-udp|grenat-eth-ipv6-udp|" +"grenat-eth-ipv4-sctp|grenat-eth-ipv6-sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3366,6 +3377,88 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"eth-ipv4" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv6" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"eth-ipv4-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv6-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"eth-ipv4-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv6-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"eth-ipv4-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"eth-ipv6-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"grenat-eth" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"grenat-eth-ipv4" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv6" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"grenat-eth-ipv4-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv6-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"grenat-eth-ipv4-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv6-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"grenat-eth-ipv4-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"grenat-eth-ipv6-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3735,6 +3828,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,eth-ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6487,6 +6624,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6499,12 +6638,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -12455,6 +12594,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +88 -0
94 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -152,6 +152,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -660,6 +661,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1254,7 +1256,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1264,6 +1265,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2652,6 +2653,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -554,6 +554,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -825,6 +826,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmd_reconfig_device_queue (portid_t id,uint8_t dev,uint8_t queue);void cmdline_read_from_file (const char *filename);
@@ -974,6 +978,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
PATCH v7 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 55 +++++- drivers/net/ice/ice_rxtx.c | 259 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 305 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -108,6 +108,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + * Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +53 -2
91 lines not on this page · raw message
drivers/net/ice/ice_rxtx.c +229 -30
401 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -43,6 +46,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -99,6 +113,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
v8 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v8:
Restrict length == 0 and proto_hdr == 0 in another buffer split. Add check for proto_hdr == 0 in last segment.
Use heap instead of stack for array to avoid vulnerabilities. Define the proto_hdr for two segments and multi-segments, respectively. Separate variable definition and code.
Refine the doc and commit log.
v7:
ice: Fix CI issue.
v6:
ice: Fix proto_hdr mappings to NIC configuration.
v5:
Define proto_hdr to use mask instead of single protocol type. Define PMD to return protocol header mask.
Refine the doc and commit log.
Remove deprecated RTE_FUNC_PTR_OR_ERR_RET.
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 152 +++++++++++++- app/test-pmd/config.c | 95 +++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 11 +- app/test-pmd/testpmd.h | 6 + doc/guides/rel_notes/release_22_11.rst | 13 ++ drivers/net/ice/ice_ethdev.c | 97 ++++++++- drivers/net/ice/ice_rxtx.c | 266 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 122 +++++++++++- lib/ethdev/rte_ethdev.h | 64 +++++- lib/ethdev/version.map | 1 + 14 files changed, 826 insertions(+), 51 deletions(-)
Signature · 1 line
2.25.1
PATCH v8 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 1 + 5 files changed, 84 insertions(+)
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -123,6 +123,11 @@ New Features into single event containing ``rte_event_vector`` whose event type is ``RTE_EVENT_TYPE_CRYPTODEV_VECTOR``. +* **Added protocol header based buffer split.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1302,6 +1314,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -6045,6 +6045,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)return eth_err (port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (all_types ==NULL ) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +30 -0
@@ -6025,6 +6025,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* When a packet type is announced to be split, it *must* be supported by +* the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must +* return the following packet types for these packets: +* - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 +* - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +1 -0
@@ -288,6 +288,7 @@ EXPERIMENTAL { # added in 22.11 rte_flow_async_action_handle_query; + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
Re: [PATCH v8 1/4] ethdev: introduce protocol header API
Quoted 7 lines · Yuan Wang
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
New function should be mentioned in the doc/guides/nics/features.rst in Buffer Split on Rx feature definition.
PATCH v8 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 asproto_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 can be omitted. For example, split after ETH, ETH-IPV4 and ETH-IPV4-UDP, it should be defined asproto_hdr0 = RTE_PTYPE_L2_ETHERproto_hdr1 = RTE_PTYPE_L3_IPV4_EXT_UNKNOWNproto_hdr2 = RTE_PTYPE_L4_UDP
struct rte_eth_rxseg_split {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures split point */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
/**
* Proto_hdr defines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* If one protocol header is defined to split packets into two
* segments, for non-tunneling packets, the complete protocol
* sequence should be defined.
* For tunneling packets, for simplicity,
* only the tunnel and inner part of comple protocol sequence
* is required.
* If several protocol headers are defined to split packets into
* multi-segments, the repeated parts of adjacent segments
* should be omitted.
*/
uint32_t proto_hdr;
};
If protocol header split can be supported by a PMD, the rte_eth_buffer_split_get_supported_hdr_ptypes function can be use 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, off1=0BThe 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
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put into the last valid mempool, with zero offset.
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field will be ignored. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field will be ignored.
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 4 ++ lib/ethdev/rte_ethdev.c | 89 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 34 +++++++++- 3 files changed, 115 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -127,6 +127,10 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. Removed Items
lib/ethdev/rte_ethdev.c +78 -11
118 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +33 -1
@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1015,12 +1018,41 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field must be 0. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field must be 0. +* - The proto_hdr field in the last segment should be 0. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* +* If one protocol header is defined to split packets into two segments, +* for non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner part of +* comple protocol sequence is required. +* If several protocol headers are defined to split packets into multi-segments, +* the repeated parts of adjacent segments should be omitted. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
Re: [PATCH v8 2/4] ethdev: introduce protocol hdr based buffer split
Quoted 29 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled 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_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asproto_hdr=RTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|
RTE_PTYPE_L4_UDPFor 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
Quoted 6 lines
If the protocol header is repeated with the previously defined one, the repeated part can be omitted. For example, split after ETH, ETH-IPV4 and ETH-IPV4-UDP, it should be defined as
proto_hdr0=RTE_PTYPE_L2_ETHERproto_hdr1=RTE_PTYPE_L3_IPV4_EXT_UNKNOWNproto_hdr2=RTE_PTYPE_L4_UDP
Ack
Quoted 15 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from */uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* If one protocol header is defined to split packets into two
* segments, for non-tunneling packets, the complete protocol
* sequence should be defined.
* For tunneling packets, for simplicity,
Quoted 8 lines
* only the tunnel and inner part of comple protocol sequence
* is required.
* If several protocol headers are defined to split packets into
* multi-segments, the repeated parts of adjacent segments
* should be omitted.
*/
uint32_tproto_hdr;
};
Sorry, but I see no reason to repeat in the descrtion. What is the purpose of the duplication?
Quoted 18 lines
If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use 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, off1=0BThe packet consists of
ETH_IPV4_UDP_PAYLOADwill 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
Quoted 4 lines
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put
ipv4 -> IPv4, udp -> UDP.
Quoted 1 line
into the last valid mempool, with zero offset.
What should happen if we have seg1 -> ETH, seg2 -> IPv4, seg3 - remaining and receive ARP? Will we see ETH header split in seg1 and everything else in the seg3? I would say yes.
May be we should define intended behavior using pseudo-code?
Quoted 26 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 4 ++ lib/ethdev/rte_ethdev.c | 89 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 34 +++++++++- 3 files changed, 115 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0
doc/guides/rel_notes/release_22_11.rst New Features · line 133
Quoted 7 lines
doc/guides/rel_notes/release_22_11.rst +4
-0@@ -127,6 +127,10 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability.
It sounds like it should be mentioned in API change section as well. Here I'd concentrate on top level feature overview only. I.e. Supported protocol-based buffer split using added ``proto_hdr`` in structure ``rte_eth_rxseg_split``.
Quoted 40 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Itemslib/ethdev/rte_ethdev.c +8
-3@@ -1650,14 +1650,18 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa;struct rte_mempool *mp_first;uint32_t offset_mask;uint16_t seg_idx; +int ptype_cnt; +uint32_t *ptypes; +int i;if (n_seg > seg_capa->max_nseg) { RTE_ETHDEV_LOG(ERR,@@ -1675,6 +1679,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1708,13 +1713,75 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx !=0 ?0 :RTE_PKTMBUF_HEADROOM ;
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 10 lines
lib/ethdev/rte_ethdev.c +2
-7*mbp_buf_size =rte_pktmbuf_data_room_size (mpl); - length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { -RTE_ETHDEV_LOG (ERR , -"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n" , - mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + +if (proto_hdr >0 ) {
proto_hdr != 0, please. I know that it is the same, but != 0 raises a bit less question if the field is signed or unsigned.
As the first condition here we should check if protocol-based split is supported at all (see note about separate helper function below).
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+/* Split based on protocol headers. */ +if (length !=0 ) { +RTE_ETHDEV_LOG (ERR , + "Do not set length split and protocol split within a segment\n"
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1731
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ ); +return -EINVAL ; + } + +if (seg_idx == n_seg -1 ) { +RTE_ETHDEV_LOG (ERR , +"The proto_hdr in the last segment should be 0\n" + ); +return -EINVAL ; + }
I think here we should check if we have seen any segment with proto_hdr == 0 before. If so, we can't do protocol based split any more. Since we need to collect already split protcols (prev_proto_hdrs), I would use the variable as a marker and set it to all 1's MASK as soon as proto_hdr==0 met.
So, the condition will be
if ((proto_hdr & prev_proto_hdrs) != 0)
So, it will check two since no repeat of previou
protocol headers which are already split and no
ptoto-split after length-based split.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1740
Quoted 9 lines
lib/ethdev/rte_ethdev.c +9
-0+ +if (*mbp_buf_size < offset) { +RTE_ETHDEV_LOG (ERR , +"%s mbuf_data_room_size %u < %u segment offset)\n" , + mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } +
(separate helper function starts here)
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1741
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+ ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id,NULL ,0 );
Three is no point to do it in a loop. It should be done outside. Moreover, it should be a helper function which does it to make this functionshort.
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+if (ptype_cnt <=0 ) { +RTE_ETHDEV_LOG (ERR , +"Port %u failed to supported buffer split header protocols\n" , + port_id); +return -EINVAL ; + } + + ptypes =malloc (sizeof (uint32_t ) * ptype_cnt); +if (ptypes ==NULL ) +return -ENOMEM ;
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1761
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+ + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes (port_id, + ptypes, ptype_cnt); +if (ptype_cnt <0 ) { +RTE_ETHDEV_LOG (ERR , +"Port %u failed to supported buffer split header protocols\n" , + port_id); +free (ptypes); +return -EINVAL ; + }
(separate helper function ends here)
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1764
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+ +for (i =0 ; i < ptype_cnt; i++) +if (ptypes[i] == proto_hdr)
It should be if ((prev_proto_hdrs | proto_hdr) == ptypes[i])
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1774
Quoted 10 lines
lib/ethdev/rte_ethdev.c +10
-0+break ; + +free (ptypes); + +if (i == ptype_cnt) { +RTE_ETHDEV_LOG (ERR , +"Requested Rx split header protocols 0x%x is not supported.\n" , + proto_hdr); +return -EINVAL ; + }
prev_proto_hdrs |= proto_hdr;
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1775
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+ }else {
NOTE If driver does not support length-based split, it should reject such configuration itself.
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1784
Quoted 9 lines
lib/ethdev/rte_ethdev.c +9
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { +RTE_ETHDEV_LOG (ERR , +"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n" , + mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + }
prev_proto_hdrs = RTE_PTYPE_ALL_MASK;
Quoted 69 lines
lib/ethdev/rte_ethdev.c +1
-1} }return 0 ;@@ -1794,7 +1861,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg;if (rx_conf->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) { - ret =rte_eth_rx_queue_check_split (rx_seg, n_seg, + ret =rte_eth_rx_queue_check_split (port_id, rx_seg, n_seg, &mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h +33
-1@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1015,12 +1018,41 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field must be 0. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field must be 0. +* - The proto_hdr field in the last segment should be 0. +* +* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* +* If one protocol header is defined to split packets into two segments, +* for non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner part of +* comple protocol sequence is required. +* If several protocol headers are defined to split packets into multi-segments, +* the repeated parts of adjacent segments should be omitted. +*/ +uint32_t proto_hdr; };/**
RE: [PATCH v8 2/4] ethdev: introduce protocol hdr based buffer split
Hi Andrew,
Quoted 83 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 6, 2022 6:12 PM
To: Wang, YuanX <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>; Wenxuan Wu <[email protected]>
Subject: Re: [PATCH v8 2/4] ethdev: introduce protocol hdr based buffer splitQuoted 2 lines · Yuan Wang
Currently, Rx buffer split supports length based split. With Rx queue offload
RTE_ETH_RX_OFFLOAD_BUFFER_SPLITenabled and Rx packetsegment
Quoted 9 lines
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.
Quoted 7 lines
This patch extends current buffer split to support protocol header based buffer split. A new
proto_hdrfield is introduced in the reserved field ofrte_eth_rxseg_splitstructure to specify protocol header. Theproto_hdrfield defines the split position of packet, splitting will always happen after the protocol header defined in the Rx packet segment. When Rx queue offloadRTE_ETH_RX_OFFLOAD_BUFFER_SPLITis enabled and correspondingprotocol
Quoted 1 line
header is configured, driver will split the ingress packets into multiple
segments.
Quoted 11 lines
Examples for
proto_hdrfield defines:
To split after ETH-IPV4-UDP, it should be defined asproto_hdr=RTE_PTYPE_L2_ETHER|RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|
RTE_PTYPE_L4_UDPFor 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_UDPQuoted 6 lines
If the protocol header is repeated with the previously defined one, the repeated part can be omitted. For example, split after ETH, ETH-IPV4 and ETH-IPV4-UDP, it should be defined as
proto_hdr0=RTE_PTYPE_L2_ETHERproto_hdr1=RTE_PTYPE_L3_IPV4_EXT_UNKNOWNproto_hdr2=RTE_PTYPE_L4_UDPAck
Quoted 3 lines
struct
rte_eth_rxseg_split{
structrte_mempool*mp; /* memory pools to allocate segment from*/
Quoted 12 lines
uint16_tlength; /* segment maximal data length,
configures split point */
uint16_toffset; /* data offset from beginning
of mbuf data buffer */
/**
*Proto_hdrdefines a bit mask of the protocol sequence as
* RTE_PTYPE_*, configures split point. The last RTE_PTYPE*
* in the mask indicates the split position.
* If one protocol header is defined to split packets into two
* segments, for non-tunneling packets, the complete protocol
* sequence should be defined.
* For tunneling packets, for simplicity,Quoted 8 lines
* only the tunnel and inner part of comple protocol sequence
* is required.
* If several protocol headers are defined to split packets into
* multi-segments, the repeated parts of adjacent segments
* should be omitted.
*/
uint32_tproto_hdr;
};
Quoted 2 lines
Sorry, but I see no reason to repeat in the descrtion. What is the purpose of the duplication?
The intension for repeating here is to make the commit log more comprehensive. We can remove these lines to make log cleaner.
Quoted 28 lines
Quoted 8 lines
If protocol header split can be supported by a PMD, the
rte_eth_buffer_split_get_supported_hdr_ptypesfunction can be use to obtain a list of these protocol headers.For example, let's suppose we configured the Rx queue with the following segments:
Quoted 8 lines
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, off1=0BThe packet consists of
ETH_IPV4_UDP_PAYLOADwill be split like following:
seg0 - ipv4 header @RTE_PKTMBUF_HEADROOM+ 2 in mbuf frompool0
Quoted 8 lines
seg1 - udp header @ 128 in mbuf from pool1 seg2 - payload @ 0 in mbuf from pool2
Note: NIC will only do split when the packets exactly match all the protocol headers in the segments. For example, if ARP packets received with above config, the NIC won't do split for ARP packets since it does not contains ipv4 header and udp header. These packets will be put
ipv4 -> IPv4, udp -> UDP.
Quoted 7 lines
Quoted 1 line
into the last valid mempool, with zero offset.
What should happen if we have seg1 -> ETH, seg2 -> IPv4, seg3 - remaining and receive ARP? Will we see ETH header split in seg1 and everything else in the seg3? I would say yes.
May be we should define intended behavior using pseudo-code?
When NIC receives these packets (like ARP), we think the expected split behavior is not decided by library, but the driver itself. It is possible for NIC to do split in exact match and longest match cases.
The exact match means NIC only do split when the packets exactly match all the protocol headers in the segments. Otherwise, these packets won't be split and the whole packet will be put into the last valid mempool, that's what we defined. The longest match means NIC will split as long as the packets meet some of the protocol headers.
Since both cases are possible, so IMO the two scenarios should be both defined. The final result of split will always be one of them. Hope to get your insights.
Attached pseudo-code for two cases below:
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
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
Quoted 35 lines
Quoted 9 lines
Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the
proto_hdrfield will be ignored. For protocol header based buffer split, the mp, offset,proto_hdrfield in Rx packet segment should be configured, while the length field will be ignored.Quoted 3 lines
The split limitations imposed by underlying driver is reported in the
rte_eth_dev_info->rx_seg_capafield. The memory attributes for the split parts may differ either, dpdk memory and external memory,respectively.
Quoted 16 lines
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>--- doc/guides/rel_notes/release_22_11.rst | 4 ++ lib/ethdev/rte_ethdev.c | 89 ++++++++++++++++++++++---- lib/ethdev/rte_ethdev.h | 34 +++++++++- 3 files changed, 115 insertions(+), 12 deletions(-)doc/guides/rel_notes/release_22_11.rst +0
-0doc/guides/rel_notes/release_22_11.rst New Features · line 128
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +0
-0@@ -127,6 +127,10 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to getsupported
doc/guides/rel_notes/release_22_11.rst New Features
Quoted 3 lines
doc/guides/rel_notes/release_22_11.rst +2
-0header protocols of a PMD to split. + * Ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer
Quoted 8 lines
split.
doc/guides/rel_notes/release_22_11.rst New Features · line 133
Quoted 2 lines
doc/guides/rel_notes/release_22_11.rst +2
-0+ User can choose length or protocol header to configure buffer split + according to NIC's capability.It sounds like it should be mentioned in API change section as well. Here I'd concentrate on top level feature overview only.
I.e. Supported protocol-based buffer split using added ``proto_hdr`` in structure ``rte_eth_rxseg_split``.
Thanks for your suggestion, please see next version.
Quoted 51 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct
Quoted 32 lines
doc/guides/rel_notes/release_22_11.rst +0
-0Removed Itemslib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0
-0
ee3b490889..60fe6eb2bd100644lib/ethdev/rte_ethdev.c +7
-3@@ -1650,14 +1650,18 @@ rte_eth_dev_is_removed(uint16_t port_id) }static int -rte_eth_rx_queue_check_split (const struct rte_eth_rxseg_split *rx_seg, -uint16_t n_seg,uint32_t *mbp_buf_size, -const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split (uint16_t port_id, +const struct rte_eth_rxseg_split *rx_seg, +uint16_t n_seg,uint32_t *mbp_buf_size, +const struct rte_eth_dev_info *dev_info) {const struct rte_eth_rxseg_capa *seg_capa = &dev_info- rx_seg_capa;struct rte_mempool *mp_first;uint32_t offset_mask;uint16_t seg_idx; +int ptype_cnt; +uint32_t *ptypes; +int i;if (n_seg > seg_capa->max_nseg) {RTE_ETHDEV_LOG(ERR,
lib/ethdev/rte_ethdev.c +0
-0@@ -1675,6 +1679,7 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1685
Quoted 7 lines
lib/ethdev/rte_ethdev.c +1
-0struct rte_mempool *mpl = rx_seg[seg_idx].mp;uint32_t length = rx_seg[seg_idx].length;uint32_t offset = rx_seg[seg_idx].offset; +uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;if (mpl ==NULL ) {RTE_ETHDEV_LOG (ERR ,"null mempool pointer\n" );@@ -1708,13
Quoted 1 line
+1713,75 @@ rte_eth_rx_queue_check_split(const struct
rte_eth_rxseg_split*rx_seg,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
} offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);lib/ethdev/rte_ethdev.c +0
-4- length = length !=0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
Quoted 8 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1717
Quoted 5 lines
lib/ethdev/rte_ethdev.c +2
-3- mpl->name, *mbp_buf_size, - length + offset, length, offset); -return -EINVAL ; + +if (proto_hdr >0 ) {
proto_hdr!= 0, please. I know that it is the same, but != 0 raises a bit less question if the field is signed or unsigned.
Get it.
Quoted 27 lines
As the first condition here we should check if protocol-based split is supported at all (see note about separate helper function below).
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+/* Split based on protocol headers. */ +if (length !=0 ) { + RTE_ETHDEV_LOG(ERR, + "Do not set length split and protocolsplit within a segment\n"
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
lib/ethdev/rte_ethdev.c +7
-0+ ); +return -EINVAL ; + } + +if (seg_idx == n_seg -1 ) { + RTE_ETHDEV_LOG(ERR, + "The proto_hdr in the last segmentshould be 0\n"
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1724
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+ ); +return -EINVAL ; + }I think here we should check if we have seen any segment with
proto_hdr== 0 before. If so, we can't do protocol based split any more. Since we need to collect already split protcols (prev_proto_hdrs), I would use the variable as a marker and set it to all 1's MASK as soon as
proto_hdr==0 met.
Quoted 5 lines
So, the condition will be
if ((proto_hdr&prev_proto_hdrs) != 0)So, it will check two since no repeat of previou protocol headers which are already split and no ptoto-split after length-based split.
Thanks for your suggestion.
The introduction of prev_proto_hdrs is a good idea, which helps to solve the two issues above. We will adopt this implementation, please see next version.
Quoted 14 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 5 lines
lib/ethdev/rte_ethdev.c +4
-0+ +if (*mbp_buf_size < offset) { + RTE_ETHDEV_LOG(ERR, + "%s
mbuf_data_room_size%u < %u segment offset)\n",lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1740
Quoted 5 lines
lib/ethdev/rte_ethdev.c +5
-0+ mpl->name, *mbp_buf_size, + offset); +return -EINVAL ; + } +(separate helper function starts here)
Quoted 6 lines
lib/ethdev/rte_ethdev.c
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+ ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 1 line
+NULL, 0);
Three is no point to do it in a loop. It should be done outside. Moreover, it should be a helper function which does it to make this functionshort.
A new helper function eth_dev_buffer_split_get_supported_hdrs_helper() will be added in next version.
Quoted 48 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 4 lines
lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <=0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 9 lines
lib/ethdev/rte_ethdev.c +9
-0+ port_id); +return -EINVAL ; + } + + ptypes =malloc (sizeof (uint32_t ) * ptype_cnt); +if (ptypes ==NULL ) +return -ENOMEM ; + + ptype_cnt =rte_eth_buffer_split_get_supported_hdr_ptypes(port_id,
Quoted 1 line
+
ptypes, ptype_cnt);lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+if (ptype_cnt <0 ) { + RTE_ETHDEV_LOG(ERR, + "Port %u failed to supported buffersplit header protocols\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1761
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+ port_id); +free (ptypes); +return -EINVAL ; + }(separate helper function ends here)
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1764
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+ +for (i =0 ; i < ptype_cnt; i++) +if (ptypes[i] == proto_hdr)It should be if ((
prev_proto_hdrs|proto_hdr) == ptypes[i])lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 7 lines
lib/ethdev/rte_ethdev.c +7
-0+break ; + +free (ptypes); + +if (i == ptype_cnt) { + RTE_ETHDEV_LOG(ERR, + "Requested Rx split header protocols0x%x is not supported.\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1774
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3
-0+ proto_hdr); +return -EINVAL ; + }
prev_proto_hdrs|=proto_hdr;
Quoted 4 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1775
Quoted 1 line
lib/ethdev/rte_ethdev.c +1
-0+ }else {NOTE If driver does not support length-based split, it should reject such configuration itself.
Here we have a question. From the code perspective, how to know
whether length-based split is supported by driver, thus to reject such configuration.
Because we have get_support_ptypes() API for driver to know proto-based split, but no API for length-based split. Or are you referring to a doc update?
Thanks,
Xuan
Quoted 94 lines
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
Quoted 6 lines
lib/ethdev/rte_ethdev.c +5
-0+/* Split at fixed length. */ + length = length !=0 ? length : *mbp_buf_size; +if (*mbp_buf_size < length + offset) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u(segment length=%u + segment offset=%u)\n",
lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1784
Quoted 4 lines
lib/ethdev/rte_ethdev.c +4
-0+ mpl->name, *mbp_buf_size, + length + offset, length, offset); +return -EINVAL ; + }
prev_proto_hdrs=RTE_PTYPE_ALL_MASK;lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,
Quoted 4 lines
} } return 0;lib/ethdev/rte_ethdev.c +0
-0@@ -1794,7 +1861,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,
uint16_trx_queue_id,lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
Quoted 3 lines
lib/ethdev/rte_ethdev.c +0
-0n_seg = rx_conf->rx_nseg; if (rx_conf->offloads &
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1864
Quoted 2 lines
lib/ethdev/rte_ethdev.c +1
-1- ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg,
n_seg,Quoted 31 lines
lib/ethdev/rte_ethdev.c +0
-0&mbp_buf_size, &dev_info);if (ret !=0 )lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0
-0
c51c1f3fa0..4c9b121355100644lib/ethdev/rte_ethdev.h +13
-0@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM. @@ -1015,12 +1018,41 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field must be 0. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field must be 0. +* - The proto_hdr field in the last segment should be 0. +* lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1040
Quoted 10 lines
lib/ethdev/rte_ethdev.h +7
-0+* - For Protocol header based buffer split, if the received packets +* don't exactly match all protocol headers in the elements, packets +* will not be split. +* These packets will be put into: +* - pool from the last valid element +* - the buffer size from this pool +* - zero offset */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1042
Quoted 2 lines
lib/ethdev/rte_ethdev.h +0
-0uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */
lib/ethdev/rte_ethdev.h struct rte_eth_txmode {
Quoted 3 lines
lib/ethdev/rte_ethdev.h +2
-1-uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*,
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1045
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+* configures split point. The last RTE_PTYPE* in the mask indicates the
lib/ethdev/rte_ethdev.h struct rte_eth_txmode {
Quoted 3 lines
lib/ethdev/rte_ethdev.h +3
-0+* split position. +* +* If one protocol header is defined to split packets into two segments,
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1049
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+* for non-tunneling packets, the complete protocol sequence should be defined.
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1050
Quoted 1 line
lib/ethdev/rte_ethdev.h +1
-0+* For tunneling packets, for simplicity, only the tunnel and inner part of
lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1052
Quoted 2 lines
lib/ethdev/rte_ethdev.h +2
-0+* comple protocol sequence is required. +* If several protocol headers are defined to split packets into multi- segments,
Quoted 6 lines
lib/ethdev/rte_ethdev.h +3
-0+* the repeated parts of adjacent segments should be omitted. +*/ +uint32_t proto_hdr; };/**
PATCH v8 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth[,ipv4,udp]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,ipv4,udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4
(default protocols of testpmd : eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|
ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|grenat|inner-eth|
inner-ipv4|inner-ipv6|inner-ipv4-tcp|inner-ipv6-tcp|
inner-ipv4-udp|inner-ipv6-udp|inner-ipv4-sctp|inner-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 152 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 95 ++++++++++++++++++++++++ app/test-pmd/parameters.c | 16 +++- app/test-pmd/testpmd.c | 11 ++- app/test-pmd/testpmd.h | 6 ++ 5 files changed, 273 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +149 -3
@@ -181,7 +181,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -305,6 +305,17 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,ipv4,udp])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|" +"ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|" +"grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|" +"inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|" +"inner-ipv4-sctp|inner-ipv6-sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3366,6 +3377,94 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"ipv4-tcp" )) + protocol =RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"ipv6-tcp" )) + protocol =RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"ipv4-udp" )) + protocol =RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"ipv6-udp" )) + protocol =RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"ipv4-sctp" )) + protocol =RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"ipv6-sctp" )) + protocol =RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"tcp" )) + protocol =RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"udp" )) + protocol =RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"sctp" )) + protocol =RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"grenat" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT ; +else if (!strcmp (value,"inner-eth" )) + protocol =RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner-ipv4" )) + protocol =RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"inner-ipv6" )) + protocol =RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"inner-ipv4-tcp" )) + protocol =RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner-ipv6-tcp" )) + protocol =RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner-ipv4-udp" )) + protocol =RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner-ipv6-udp" )) + protocol =RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner-ipv4-sctp" )) + protocol =RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"inner-ipv6-sctp" )) + protocol =RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"inner-tcp" )) + protocol =RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner-udp" )) + protocol =RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner-sctp" )) + protocol =RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + parsed_items[nb_item] =get_ptype (cur); + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3735,6 +3834,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,ipv4,udp]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6487,6 +6630,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6499,12 +6644,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -12455,6 +12600,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +95 -0
101 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -152,6 +152,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -660,6 +661,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1254,7 +1256,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1264,6 +1265,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +8 -3
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2646,12 +2647,16 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, mp_n = (i >= mbuf_data_size_n) ? mbuf_data_size_n -1 : i; mpx =mbuf_pool_find (socket_id, mp_n);/* Handle zero as mbuf data buffer size. */ - rx_seg->length = rx_pkt_seg_lengths[i] ? - rx_pkt_seg_lengths[i] : - mbuf_data_size[mp_n]; rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; +if (rx_pkt_hdr_protos[i] !=0 && rx_pkt_seg_lengths[i] ==0 ) { + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; + }else { + rx_seg->length = rx_pkt_seg_lengths[i] ? + rx_pkt_seg_lengths[i] : + mbuf_data_size[mp_n]; + } } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -580,6 +580,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -851,6 +852,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmd_reconfig_device_queue (portid_t id,uint8_t dev,uint8_t queue);void cmdline_read_from_file (const char *filename);
@@ -1002,6 +1006,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
Signature · 1 line
2.25.1
Re: [PATCH v8 3/4] app/testpmd: add rxhdrs commands and parameters
Quoted 25 lines · Yuan Wang
Add command line parameter:
--rxhdrs=eth[,ipv4,udp]Set the
protocol_hdrof segments to scatter packets on receiving if split feature is engaged. And the queues withBUFFER_SPLITflag.Add interactive mode command:
testpmd>set rxhdrs eth,ipv4,udp
(protocol sequence should be valid)The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue withrx_offloadbuffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4(default protocols of testpmd : eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp| ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|grenat|inner-eth| inner-ipv4|inner-ipv6|inner-ipv4-tcp|inner-ipv6-tcp| inner-ipv4-udp|inner-ipv6-udp|inner-ipv4-sctp|inner-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>
Quoted 7 lines
--- app/test-pmd/cmdline.c | 152 +++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 95 ++++++++++++++++++++++++ app/test-pmd/parameters.c | 16 +++- app/test-pmd/testpmd.c | 11 ++- app/test-pmd/testpmd.h | 6 ++ 5 files changed, 273 insertions(+), 7 deletions(-)
testpmd documentaion must be updated:doc/guides/testpmd_app_ug/testpmd_funcs.rst
PATCH v8 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangThis patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 97 ++++++++- drivers/net/ice/ice_rxtx.c | 266 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 5 files changed, 354 insertions(+), 32 deletions(-)
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -132,6 +132,10 @@ New Features User can choose length or protocol header to configure buffer split according to NIC's capability. +* **Updated Intel ice driver.** + + * Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +95 -2
133 lines not on this page · raw message
drivers/net/ice/ice_rxtx.c +236 -30
408 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -45,6 +48,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -55,6 +63,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -101,6 +115,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
Re: [PATCH v8 4/4] net/ice: support buffer split in Rx path
Quoted 1 line · Yuan Wang
This patch adds support for protocol based buffer split in normal Rx
"This patch adds" -> "Add"
Quoted 3 lines
data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of pmd. And the two parts will be
pmd -> PMD
Quoted 6 lines
put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new api
ice_buffer_split_supported_hdr_ptypes_get()has been
api -> API
Quoted 6 lines
introduced, it will return the supported header protocols of ice PMD to app for splitting.
Signed-off-by Yuan Wang <[email protected]>Signed-off-by Xuan Ding <[email protected]>Signed-off-by Wenxuan Wu <[email protected]>
The patch should update doc/guides/nics/features/ice.ini to list Buffer Split on Rx feature.
Quoted 10 lines · Yuan Wang
Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIToffload and corresponding protocol, packets received will be directly split into different mempools.
Quoted 8 lines
Change log:
v8:
Restrict length == 0 andproto_hdr== 0 in another buffer split. Add check forproto_hdr== 0 in last segment.
Use heap instead of stack for array to avoid vulnerabilities. Define theproto_hdrfor two segments and multi-segments, respectively. Separate variable definition and code.
Refine the doc and commit log.
Overall LGTM, please, process review notes and I think it will be ready to be accepted.
v9 cover support protocol based buffer split
In reply to Yuan WangProtocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.
Change log:
v9:
Define the intend behaviors for exact match and longest match. Add protocol headers repeat check.
Add no proto-split after length-based split check. Add a helper function to short the check function. Refine the doc and commit log.
v8:
Restrict length == 0 and proto_hdr == 0 in another buffer split. Add check for proto_hdr == 0 in last segment.
Use heap instead of stack for array to avoid vulnerabilities. Define the proto_hdr for two segments and multi-segments, respectively. Separate variable definition and code.
Refine the doc and commit log.
v7:
ice: Fix CI issue.
v6:
ice: Fix proto_hdr mappings to NIC configuration.
v5:
Define proto_hdr to use mask instead of single protocol type. Define PMD to return protocol header mask.
Refine the doc and commit log.
Remove deprecated RTE_FUNC_PTR_OR_ERR_RET.
v4:
Change proto_hdr to a bit mask of RTE_PTYPE_*.
Add the description on how to put the unsplit packages. Use proto_hdr to determine whether to use protocol based split.
v3:
Fix mail thread.
v2:
Add mbuf dump to the driver's buffer split path. Add buffer split to the driver feature list. Remove unsupported header protocols from the driver.
Yuan Wang (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path
app/test-pmd/cmdline.c | 152 ++++++++++- app/test-pmd/config.c | 108 ++++++++ app/test-pmd/parameters.c | 16 +- app/test-pmd/testpmd.c | 11 +- app/test-pmd/testpmd.h | 6 + doc/guides/nics/features.rst | 2 +- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 16 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 19 +- drivers/net/ice/ice_ethdev.c | 58 ++++- drivers/net/ice/ice_rxtx.c | 263 +++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + lib/ethdev/ethdev_driver.h | 15 ++ lib/ethdev/rte_ethdev.c | 128 +++++++++- lib/ethdev/rte_ethdev.h | 67 ++++- lib/ethdev/version.map | 1 + 18 files changed, 829 insertions(+), 54 deletions(-)
Signature · 1 line
2.25.1
PATCH v9 1/4 ethdev: introduce protocol header API
Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split.
--- doc/guides/nics/features.rst | 2 +- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 1 + 6 files changed, 85 insertions(+), 1 deletion(-)
doc/guides/nics/features.rst +1 -1
@@ -183,7 +183,7 @@ Scatters the packets being received on specified boundaries to segmented mbufs. * **[uses] rte_eth_rxconf**: ``rx_conf.rx_seg, rx_conf.rx_nseg``. * **[implements] datapath**: ``Buffer Split functionality``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``. -* **[related] API**: ``rte_eth_rx_queue_setup()``. +* **[related] API**: ``rte_eth_rx_queue_setup()``, ``rte_eth_buffer_split_get_supported_hdr_ptypes()``. .. _nic_features_lro:
doc/guides/rel_notes/release_22_11.rst +5 -0
@@ -189,6 +189,11 @@ New Features into single event containing ``rte_event_vector`` whose event type is ``RTE_EVENT_TYPE_CRYPTODEV_VECTOR``. +* **Added protocol header based buffer split.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items -------------
lib/ethdev/ethdev_driver.h +15 -0
@@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,typedef int (*eth_ip_reassembly_conf_set_t )(struct rte_eth_dev *dev,const struct rte_eth_ip_reassembly_params *conf); +/** +* @internal +* Get supported header protocols of a PMD to split. +* +* @param dev +* Ethdev handle of port. +* +* @return +* An array pointer to store supported protocol headers. +*/ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t )(struct rte_eth_dev *dev); +/** * @internal * Dump private info from device to a file.
@@ -1366,6 +1378,9 @@ struct eth_dev_ops {/** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; +/** Get supported header ptypes to split */ +eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; +/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump;
lib/ethdev/rte_ethdev.c +33 -0
@@ -6209,6 +6209,39 @@ rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id, queue_id, offset, num, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes (uint16_t port_id,uint32_t *ptypes,int num) +{ +int i, j; +struct rte_eth_dev *dev; +const uint32_t *all_types; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + +if (ptypes ==NULL && num >0 ) { +RTE_ETHDEV_LOG (ERR , +"Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n" , + port_id); +return -EINVAL ; + } + +if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get ==NULL ) +return -ENOTSUP ; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + +if (all_types ==NULL ) +return 0 ; + +for (i =0 , j =0 ; all_types[i] !=RTE_PTYPE_UNKNOWN ; ++i) { +if (j < num) + ptypes[j] = all_types[i]; + j++; + } + +return j; +} +RTE_LOG_REGISTER_DEFAULT (rte_eth_dev_logtype,INFO );RTE_INIT (ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +30 -0
@@ -6337,6 +6337,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Get supported header protocols to split on Rx. +* +* When a packet type is announced to be split, it *must* be supported by +* the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must +* return the following packet types for these packets: +* - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 +* - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP +* +* @param port_id +* The port identifier of the device. +* @param[out] ptypes +* An array pointer to store supported protocol headers, allocated by caller. +* These ptypes are composed with RTE_PTYPE_*. +* @param num +* Size of the array pointed by param ptypes. +* @return +* - (>=0) Number of supported ptypes. If the number of types exceeds num, +* only num entries will be filled into the ptypes array, but the full +* count of supported ptypes will be returned. +* - (-ENOTSUP) if header protocol is not supported by device. +* - (-ENODEV) if *port_id* invalid. +* - (-EINVAL) if bad parameter. +*/ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus }#endif
lib/ethdev/version.map +1 -0
@@ -296,6 +296,7 @@ EXPERIMENTAL { rte_flow_async_action_handle_query; rte_mtr_meter_policy_get; rte_mtr_meter_profile_get; + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {
Signature · 1 line
2.25.1
PATCH v9 2/4 ethdev: introduce protocol hdr based buffer split
In reply to Yuan WangCurrently, 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 asproto_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 asproto_hdr0 = RTE_PTYPE_L2_ETHERproto_hdr1 = RTE_PTYPE_L3_IPV4_EXT_UNKNOWNproto_hdr2 = RTE_PTYPE_L4_UDP
struct rte_eth_rxseg_split {
struct rte_mempool *mp;
uint16_t length;
uint16_t offset;
uint32_t proto_hdr;
};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=0BThe 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
The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.
--- doc/guides/rel_notes/release_22_11.rst | 7 ++ lib/ethdev/rte_ethdev.c | 95 +++++++++++++++++++++++--- lib/ethdev/rte_ethdev.h | 37 +++++++++- 3 files changed, 127 insertions(+), 12 deletions(-)
doc/guides/rel_notes/release_22_11.rst +7 -0
@@ -193,6 +193,8 @@ New Features * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported header protocols of a PMD to split. + * Supported protocol-based buffer split using added ``proto_hdr`` + in structure ``rte_eth_rxseg_split``. Removed Items
@@ -338,6 +340,11 @@ API Changes for per-queue packet split offload, which is configured by ``rte_eth_rxseg_split``. +* ethdev: The ``reserved`` field in the ``rte_eth_rxseg_split`` structure is + replaced with ``proto_hdr`` to support protocol header based buffer split. + User can choose length or protocol header to configure buffer split + according to NIC's capability. + * ethdev: Changed the type of the parameter ``rate`` of the function ``rte_eth_set_queue_rate_limit()`` from ``uint16_t`` to ``uint32_t`` to support more than 64 Gbps.
lib/ethdev/rte_ethdev.c +84 -11
148 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +36 -1
@@ -994,6 +994,9 @@ struct rte_eth_txmode {* specified in the first array element, the second buffer, from the * pool in the second element, and so on. * +* - The proto_hdrs in the elements define the split position of +* received packets. +* * - The offsets from the segment description elements specify * the data offset from the buffer beginning except the first mbuf. * The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1015,12 +1018,44 @@ struct rte_eth_txmode {* - pool from the last valid element * - the buffer size from this pool * - zero offset +* +* - Length based buffer split: +* - mp, length, offset should be configured. +* - The proto_hdr field must be 0. +* +* - Protocol header based buffer split: +* - mp, offset, proto_hdr should be configured. +* - The length field must be 0. +* - The proto_hdr field in the last segment should be 0. +* +* - 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. */ struct rte_eth_rxseg_split {struct rte_mempool *mp;/**< Memory pool to allocate segment from. */ uint16_t length;/**< Segment data length, configures split point. */ uint16_t offset;/**< Data offset from beginning of mbuf data buffer. */ -uint32_t reserved;/**< Reserved field. */ +/** +* Proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*, +* configures split point. The last RTE_PTYPE* in the mask indicates the +* split position. +* +* If one protocol header is defined to split packets into two segments, +* for non-tunneling packets, the complete protocol sequence should be defined. +* For tunneling packets, for simplicity, only the tunnel and inner part of +* comple protocol sequence is required. +* If several protocol headers are defined to split packets into multi-segments, +* the repeated parts of adjacent segments should be omitted. +*/ +uint32_t proto_hdr; };/**
Signature · 1 line
2.25.1
PATCH v9 3/4 app/testpmd: add rxhdrs commands and parameters
In reply to Yuan WangAdd command line parameter:
--rxhdrs=eth[,ipv4]
Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.
Add interactive mode command:
testpmd>set rxhdrs eth,ipv4,ipv4-udp
(protocol sequence should be valid)
The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with multiple mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs eth,eth-ipv4
(default protocols of testpmd : eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|
ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|grenat|inner-eth|
inner-ipv4|inner-ipv6|inner-ipv4-tcp|inner-ipv6-tcp|
inner-ipv4-udp|inner-ipv6-udp|inner-ipv4-sctp|inner-ipv6-sctp)Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.
--- app/test-pmd/cmdline.c | 152 +++++++++++++++++++- app/test-pmd/config.c | 108 ++++++++++++++ app/test-pmd/parameters.c | 16 ++- app/test-pmd/testpmd.c | 11 +- app/test-pmd/testpmd.h | 6 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 19 ++- 6 files changed, 303 insertions(+), 9 deletions(-)
app/test-pmd/cmdline.c +149 -3
@@ -181,7 +181,7 @@ static void cmd_help_long_parsed(void *parsed_result,"show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" -"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n" +"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -305,6 +305,17 @@ static void cmd_help_long_parsed(void *parsed_result," Affects only the queues configured with split" " offloads.\n\n" +"set rxhdrs (eth[,ipv4])*\n" +" Set the protocol hdr of each segment to scatter" +" packets on receiving if split feature is engaged." +" Affects only the queues configured with split" +" offloads.\n" +" Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|" +"ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|" +"grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|" +"inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|" +"inner-ipv4-sctp|inner-ipv6-sctp\n\n" +"set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n"
@@ -3366,6 +3377,94 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +static unsigned int +get_ptype (char *value) +{ +uint32_t protocol; + +if (!strcmp (value,"eth" )) + protocol =RTE_PTYPE_L2_ETHER ; +else if (!strcmp (value,"ipv4" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"ipv6" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"ipv4-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"ipv4-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"ipv4-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"ipv6-tcp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_TCP ; +else if (!strcmp (value,"ipv6-udp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_UDP ; +else if (!strcmp (value,"ipv6-sctp" )) + protocol =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_L4_SCTP ; +else if (!strcmp (value,"grenat" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT ; +else if (!strcmp (value,"inner-eth" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER ; +else if (!strcmp (value,"inner-ipv4" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN ; +else if (!strcmp (value,"inner-ipv6" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ; +else if (!strcmp (value,"inner-ipv4-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner-ipv4-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner-ipv4-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else if (!strcmp (value,"inner-ipv6-tcp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_TCP ; +else if (!strcmp (value,"inner-ipv6-udp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_UDP ; +else if (!strcmp (value,"inner-ipv6-sctp" )) + protocol =RTE_PTYPE_TUNNEL_GRENAT |RTE_PTYPE_INNER_L2_ETHER | +RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |RTE_PTYPE_INNER_L4_SCTP ; +else { +fprintf (stderr,"Unsupported protocol: %s\n" , value); + protocol =RTE_PTYPE_UNKNOWN ; + } + +return protocol; +} +/* *** SET RXHDRSLIST *** */ + +unsigned int +parse_hdrs_list (const char *str,const char *item_name,unsigned int max_items, +unsigned int *parsed_items,int check_hdrs_sequence) +{ +unsigned int nb_item; +char *cur; +char *tmp; +unsigned int cur_item, prev_items =0 ; + + nb_item =0 ; +char *str2 =strdup (str); + cur =strtok_r (str2,"," , &tmp); +while (cur !=NULL ) { + cur_item =get_ptype (cur); + cur_item &= ~prev_items; + parsed_items[nb_item] = cur_item; + cur =strtok_r (NULL ,"," , &tmp); + nb_item++; + prev_items |= cur_item; + } +if (nb_item > max_items) +fprintf (stderr,"Number of %s = %u > %u (maximum items)\n" , + item_name, nb_item +1 , max_items); +free (str2); +if (!check_hdrs_sequence) +return nb_item; +return nb_item; +}/* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int
@@ -3735,6 +3834,50 @@ static cmdline_parse_inst_t cmd_set_rxpkts = { }, }; +/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ +struct cmd_set_rxhdrs_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t rxhdrs; +cmdline_fixed_string_t values; +}; + +static void +cmd_set_rxhdrs_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxhdrs_result *res; +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + res = parsed_result; + nb_segs =parse_hdrs_list (res->values,"segment hdrs" , +MAX_SEGS_BUFFER_SPLIT , seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +cmd_reconfig_device_queue (RTE_PORT_ALL ,0 ,1 ); +} +static cmdline_parse_token_string_t cmd_set_rxhdrs_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + rxhdrs,"rxhdrs" ); +static cmdline_parse_token_string_t cmd_set_rxhdrs_values = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, + values,NULL ); + +static cmdline_parse_inst_t cmd_set_rxhdrs = { + .f = cmd_set_rxhdrs_parsed, + .data =NULL , + .help_str ="set rxhdrs <eth[,ipv4]*>" , + .tokens = { + (void *)&cmd_set_rxhdrs_set, + (void *)&cmd_set_rxhdrs_rxhdrs, + (void *)&cmd_set_rxhdrs_values, +NULL , + }, +};/* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result {
@@ -6487,6 +6630,8 @@ static void cmd_showcfg_parsed(void *parsed_result,show_rx_pkt_offsets (); else if (!strcmp(res->what, "rxpkts"))show_rx_pkt_segments (); + else if (!strcmp(res->what, "rxhdrs")) +show_rx_pkt_hdrs (); else if (!strcmp(res->what, "txpkts"))show_tx_pkt_segments (); else if (!strcmp(res->what, "txtimes"))
@@ -6499,12 +6644,12 @@ static cmdline_parse_token_string_t cmd_showcfg_port = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");static cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, -"rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes" ); +"rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes" );static cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data =NULL , - .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes" , + .help_str ="show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes" , .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port,
@@ -12455,6 +12600,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, + (cmdline_parse_inst_t *)&cmd_set_rxhdrs, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +108 -0
114 lines not on this page · raw message
app/test-pmd/parameters.c +15 -1
@@ -152,6 +152,7 @@ usage(char* progname) " Used mainly with PCAP drivers.\n");printf (" --rxoffs=X[,Y]*: set RX segment offsets for split.\n" );printf (" --rxpkts=X[,Y]*: set RX segment sizes to split.\n" ); +printf (" --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n" );printf (" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n" );printf (" --txonly-multi-flow: generate multiple flows in txonly mode\n" );
@@ -660,6 +661,7 @@ launch_args_parse(int argc, char** argv) { "flow-isolate-all", 0, 0, 0 }, { "rxoffs", 1, 0, 0 }, { "rxpkts", 1, 0, 0 }, + { "rxhdrs", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "rxq-share", 2, 0, 0 },
@@ -1254,7 +1256,6 @@ launch_args_parse(int argc, char** argv)if (!strcmp (lgopts[opt_idx].name,"rxpkts" )) {unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT ];unsigned int nb_segs; - nb_segs = parse_item_list (optarg, "rxpkt segments", MAX_SEGS_BUFFER_SPLIT,
@@ -1264,6 +1265,19 @@ launch_args_parse(int argc, char** argv)else rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); } +if (!strcmp (lgopts[opt_idx].name,"rxhdrs" )) { +unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT ]; +unsigned int nb_segs; + + nb_segs =parse_hdrs_list + (optarg,"rxpkt segments" , +MAX_SEGS_BUFFER_SPLIT , + seg_hdrs,0 ); +if (nb_segs >0 ) +set_rx_pkt_hdrs (seg_hdrs, nb_segs); +else +rte_exit (EXIT_FAILURE ,"bad rxpkts\n" ); + }if (!strcmp (lgopts[opt_idx].name,"txpkts" )) {unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT ];unsigned int nb_segs;
app/test-pmd/testpmd.c +8 -3
@@ -247,6 +247,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];uint8_t rx_pkt_nb_offs;/**< Number of specified offsets */ +uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];/* * Configuration of packet segments used by the "txonly" processing engine.
@@ -2668,12 +2669,16 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, mp_n = (i >= mbuf_data_size_n) ? mbuf_data_size_n -1 : i; mpx =mbuf_pool_find (socket_id, mp_n);/* Handle zero as mbuf data buffer size. */ - rx_seg->length = rx_pkt_seg_lengths[i] ? - rx_pkt_seg_lengths[i] : - mbuf_data_size[mp_n]; rx_seg->offset = i < rx_pkt_nb_offs ? rx_pkt_seg_offsets[i] :0 ; rx_seg->mp = mpx ? mpx : mp; +if (rx_pkt_hdr_protos[i] !=0 && rx_pkt_seg_lengths[i] ==0 ) { + rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; + }else { + rx_seg->length = rx_pkt_seg_lengths[i] ? + rx_pkt_seg_lengths[i] : + mbuf_data_size[mp_n]; + } } rx_conf->rx_nseg = rx_pkt_nb_segs; rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
@@ -580,6 +580,7 @@ extern uint32_t max_rx_pkt_len;* Configuration of packet segments used to scatter received packets * if some of split features is configured. */ +extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT ];extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT ];extern uint8_t rx_pkt_nb_segs;/**< Number of segments to split */ extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT ];
@@ -851,6 +852,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)unsigned int parse_item_list (const char *str,const char *item_name,unsigned int max_items,unsigned int *parsed_items,int check_unique_values); +unsigned int parse_hdrs_list (const char *str,const char *item_name, +unsigned int max_item, +unsigned int *parsed_items,int check_unique_values);void launch_args_parse (int argc,char ** argv);void cmd_reconfig_device_queue (portid_t id,uint8_t dev,uint8_t queue);void cmdline_read_from_file (const char *filename);
@@ -1006,6 +1010,8 @@ void set_record_core_cycles(uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs); +void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs); +void show_rx_pkt_hdrs (void );void show_rx_pkt_segments (void );void set_rx_pkt_offsets (unsigned int *seg_offsets,unsigned int nb_offs);void show_rx_pkt_offsets (void );
doc/guides/testpmd_app_ug/testpmd_funcs.rst +17 -2
@@ -278,7 +278,7 @@ show config Displays the configuration of the application. The configuration comes from the command-line, the runtime or the application defaults:: - testpmd> show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes) + testpmd> show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes) The available information categories are:
@@ -290,7 +290,9 @@ The available information categories are: * ``rxoffs``: Packet offsets for RX split. -* ``rxpkts``: Packets to RX split configuration. +* ``rxpkts``: Packets to RX length-based split configuration. + +* ``rxhdrs``: Packets to RX proto-based split configuration. * ``txpkts``: Packets to TX configuration.
@@ -799,6 +801,19 @@ mbuf for remaining segments will be allocated from the last valid pool). Where x[,y]* represents a CSV list of values, without white space. Zero value means to use the corresponding memory pool data buffer size. +set rxhdrs +~~~~~~~~~~ + +Set the protocol headers of segments to scatter packets on receiving if split +feature is engaged. Affects only the queues configured with split +offloads (currently BUFFER_SPLIT is supported only). + + testpmd> set rxhdrs (eth[,ipv4]*) + +Where eth[,ipv4]* represents a CSV list of values, without white space. If the list +of offsets is shorter than the list of segments the zero offsets will be used +for the remaining segments. + set txpkts ~~~~~~~~~~
Signature · 1 line
2.25.1
PATCH v9 4/4 net/ice: support buffer split in Rx path
In reply to Yuan WangAdd support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts. And the two parts will be put into different mempools.
Currently, protocol based buffer split is not supported in vectorized paths.
A new API ice_buffer_split_supported_hdr_ptypes_get() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.
--- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ice.ini | 1 + doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/ice/ice_ethdev.c | 58 +++++- drivers/net/ice/ice_rxtx.c | 263 ++++++++++++++++++++++--- drivers/net/ice/ice_rxtx.h | 16 ++ drivers/net/ice/ice_rxtx_vec_common.h | 3 + 7 files changed, 314 insertions(+), 32 deletions(-)
doc/guides/nics/features/default.ini +1 -0
@@ -7,6 +7,7 @@ ; string should not exceed feature_str_len defined in conf.py. ; [Features] +Buffer Split on Rx = Speed capabilities = Link status = Link status event =
doc/guides/nics/features/ice.ini +1 -0
@@ -7,6 +7,7 @@ ; is selected. ; [Features] +Buffer Split on Rx = P Speed capabilities = Y Link status = Y Link status event = Y
doc/guides/rel_notes/release_22_11.rst +4 -0
@@ -196,6 +196,10 @@ New Features * Supported protocol-based buffer split using added ``proto_hdr`` in structure ``rte_eth_rxseg_split``. +* **Updated Intel ice driver.** + + * Added protocol based buffer split support in scalar path. + Removed Items -------------
drivers/net/ice/ice_ethdev.c +56 -2
94 lines not on this page · raw message
drivers/net/ice/ice_rxtx.c +233 -30
405 lines not on this page · raw message
drivers/net/ice/ice_rxtx.h +16 -0
@@ -16,6 +16,9 @@#define ICE_RX_MAX_BURST 32#define ICE_TX_MAX_BURST 32 +/* Maximal number of segments to split. */ +#define ICE_RX_MAX_NSEG 2 +#define ICE_CHK_Q_ENA_COUNT 100#define ICE_CHK_Q_ENA_INTERVAL_US 100
@@ -45,6 +48,11 @@extern uint64_t ice_timestamp_dynflag;extern int ice_timestamp_dynfield_offset; +/* Max header size can be 2K - 64 bytes */ +#define ICE_RX_HDR_BUF_SIZE (2048 - 64) + +#define ICE_HEADER_SPLIT_ENA BIT(0) +typedef void (*ice_rx_release_mbufs_t )(struct ice_rx_queue *rxq);typedef void (*ice_tx_release_mbufs_t )(struct ice_tx_queue *txq); typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -55,6 +63,12 @@ struct ice_rx_entry {struct rte_mbuf *mbuf; }; +enum ice_rx_dtype { +ICE_RX_DTYPE_NO_SPLIT =0 , +ICE_RX_DTYPE_HEADER_SPLIT =1 , +ICE_RX_DTYPE_SPLIT_ALWAYS =2 , +}; +struct ice_rx_queue {struct rte_mempool *mp;/* mbuf pool to populate RX ring */ volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -101,6 +115,8 @@ struct ice_rx_queue {uint32_t hw_time_high;/* high 32 bits of timestamp */ uint32_t hw_time_low;/* low 32 bits of timestamp */ uint64_t hw_time_update;/* SW time of HW record updating */ +struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG ]; +uint32_t rxseg_nb; };struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP )return -1 ; +if (rxq->offloads &RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ) +return -1 ; +if (rxq->offloads &ICE_RX_VECTOR_OFFLOAD )return ICE_VECTOR_OFFLOAD_PATH ;
Signature · 1 line
2.25.1
Quoted 10 lines · Yuan Wang
Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIToffload and corresponding protocol, packets received will be directly split into different mempools.
Quoted 7 lines
Change log:
v9:
Define the intend behaviors for exact match and longest match. Add protocol headers repeat check.
Add no proto-split after length-based split check. Add a helper function to short the check function. Refine the doc and commit log.
With few minor fixes, applied to dpdk-next-net/main, thanks.
Quoted 33 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Sunday, October 9, 2022 10:59 PM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; [email protected]; [email protected]; Ding, Xuan <[email protected]>; [email protected]; Tang, Yaqi <[email protected]>
Subject: Re: [PATCH v9 0/4] support protocol based buffer splitQuoted 4 lines · Yuan Wang
Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance
significantly.
Quoted 6 lines
This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIToffload and corresponding protocol, packets received will be directly split into different mempools.Quoted 7 lines
Change log:
v9:
Define the intend behaviors for exact match and longest match. Add protocol headers repeat check.
Add no proto-split after length-based split check. Add a helper function to short the check function. Refine the doc and commit log.
Quoted 1 line
With few minor fixes, applied to dpdk-next-net/main, thanks.
Sincere thanks to all the reviewers who provided valuable comments on this patch series.
Regards,
Xuan