[dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation
Hi Thomas, > -Original Message- > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com] > Sent: Friday, October 14, 2016 16:20 > To: Kulasek, TomaszX > Cc: dev at dpdk.org; Ananyev, Konstantin ; > olivier.matz at 6wind.com > Subject: Re: [dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation > > 2016-10-14 14:02, Kulasek, TomaszX: > > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com] > > > 2016-10-13 19:36, Tomasz Kulasek: > > > > +/** > > > > + * Fix pseudo header checksum for TSO and non-TSO tcp/udp packets > > > before > > > > + * hardware tx checksum. > > > > + * For non-TSO tcp/udp packets full pseudo-header checksum is > > > > + counted > > > and set. > > > > + * For TSO the IP payload length is not included. > > > > + */ > > > > +static inline int > > > > +rte_phdr_cksum_fix(struct rte_mbuf *m) > > > > > > You probably don't need this function since the recent improvements > > > from Olivier. > > > > Do you mean this improvement: "net: add function to calculate a checksum > in a mbuf" > > http://dpdk.org/dev/patchwork/patch/16542/ > > > > I see only full raw checksum computation on mbuf in Olivier patches, > while this function counts only pseudo-header checksum to be used with tx > offload. > > OK. Please check what exists already in librte_net (especially rte_ip.h) > and try to re-use code if possible. Thanks I have already sent v6 with requested changes in Friday. There's no equivalent of rte_phdr_cksum_fix in librte_net. This function already uses rte_ipv4_phdr_cksum and rte_ipv6_phdr_cksum and there's nothing similar on the higher level to simplify it even more. Tomasz
[dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation
Hi Thomas, > -Original Message- > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com] > Sent: Thursday, October 13, 2016 21:21 > To: Kulasek, TomaszX > Cc: dev at dpdk.org; Ananyev, Konstantin > Subject: Re: [PATCH v5 1/6] ethdev: add Tx preparation > > Hi, > > 2016-10-13 19:36, Tomasz Kulasek: > > Added API for `rte_eth_tx_prep` > > > > uint16_t rte_eth_tx_prep(uint8_t port_id, uint16_t queue_id, > > struct rte_mbuf **tx_pkts, uint16_t nb_pkts) > > > > Added fields to the `struct rte_eth_desc_lim`: > > > > uint16_t nb_seg_max; > > /**< Max number of segments per whole packet. */ > > > > uint16_t nb_mtu_seg_max; > > /**< Max number of segments per one MTU */ > > > > Created `rte_pkt.h` header with common used functions: > > Same comment as in previous revision: > this description lacks the usability and performance considerations. > > > +static inline uint16_t > > +rte_eth_tx_prep(uint8_t port_id __rte_unused, uint16_t queue_id > __rte_unused, > > + struct rte_mbuf **tx_pkts __rte_unused, uint16_t nb_pkts) > > Doxygen still do not parse it well (same issue as previous revision). > > > +/** > > + * Fix pseudo header checksum for TSO and non-TSO tcp/udp packets > before > > + * hardware tx checksum. > > + * For non-TSO tcp/udp packets full pseudo-header checksum is counted > and set. > > + * For TSO the IP payload length is not included. > > + */ > > +static inline int > > +rte_phdr_cksum_fix(struct rte_mbuf *m) > > You probably don't need this function since the recent improvements from > Olivier. Do you mean this improvement: "net: add function to calculate a checksum in a mbuf" http://dpdk.org/dev/patchwork/patch/16542/ I see only full raw checksum computation on mbuf in Olivier patches, while this function counts only pseudo-header checksum to be used with tx offload. Tomasz
[dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation
2016-10-14 14:02, Kulasek, TomaszX: > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com] > > 2016-10-13 19:36, Tomasz Kulasek: > > > +/** > > > + * Fix pseudo header checksum for TSO and non-TSO tcp/udp packets > > before > > > + * hardware tx checksum. > > > + * For non-TSO tcp/udp packets full pseudo-header checksum is counted > > and set. > > > + * For TSO the IP payload length is not included. > > > + */ > > > +static inline int > > > +rte_phdr_cksum_fix(struct rte_mbuf *m) > > > > You probably don't need this function since the recent improvements from > > Olivier. > > Do you mean this improvement: "net: add function to calculate a checksum in a > mbuf" > http://dpdk.org/dev/patchwork/patch/16542/ > > I see only full raw checksum computation on mbuf in Olivier patches, while > this function counts only pseudo-header checksum to be used with tx offload. OK. Please check what exists already in librte_net (especially rte_ip.h) and try to re-use code if possible. Thanks
[dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation
Hi, 2016-10-13 19:36, Tomasz Kulasek: > Added API for `rte_eth_tx_prep` > > uint16_t rte_eth_tx_prep(uint8_t port_id, uint16_t queue_id, > struct rte_mbuf **tx_pkts, uint16_t nb_pkts) > > Added fields to the `struct rte_eth_desc_lim`: > > uint16_t nb_seg_max; > /**< Max number of segments per whole packet. */ > > uint16_t nb_mtu_seg_max; > /**< Max number of segments per one MTU */ > > Created `rte_pkt.h` header with common used functions: Same comment as in previous revision: this description lacks the usability and performance considerations. > +static inline uint16_t > +rte_eth_tx_prep(uint8_t port_id __rte_unused, uint16_t queue_id __rte_unused, > + struct rte_mbuf **tx_pkts __rte_unused, uint16_t nb_pkts) Doxygen still do not parse it well (same issue as previous revision). > +/** > + * Fix pseudo header checksum for TSO and non-TSO tcp/udp packets before > + * hardware tx checksum. > + * For non-TSO tcp/udp packets full pseudo-header checksum is counted and > set. > + * For TSO the IP payload length is not included. > + */ > +static inline int > +rte_phdr_cksum_fix(struct rte_mbuf *m) You probably don't need this function since the recent improvements from Olivier.
[dpdk-dev] [PATCH v5 1/6] ethdev: add Tx preparation
Added API for `rte_eth_tx_prep` uint16_t rte_eth_tx_prep(uint8_t port_id, uint16_t queue_id, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) Added fields to the `struct rte_eth_desc_lim`: uint16_t nb_seg_max; /**< Max number of segments per whole packet. */ uint16_t nb_mtu_seg_max; /**< Max number of segments per one MTU */ Created `rte_pkt.h` header with common used functions: int rte_validate_tx_offload(struct rte_mbuf *m) to validate general requirements for tx offload in packet such a flag completness. In current implementation this function is called optionaly when RTE_LIBRTE_ETHDEV_DEBUG is enabled. int rte_phdr_cksum_fix(struct rte_mbuf *m) to fix pseudo header checksum for TSO and non-TSO tcp/udp packets before hardware tx checksum offload. - for non-TSO tcp/udp packets full pseudo-header checksum is counted and set. - for TSO the IP payload length is not included. Signed-off-by: Tomasz Kulasek --- config/common_base|1 + lib/librte_ether/rte_ethdev.h | 85 + lib/librte_mbuf/rte_mbuf.h|9 +++ lib/librte_net/Makefile |3 +- lib/librte_net/rte_pkt.h | 139 + 5 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_pkt.h diff --git a/config/common_base b/config/common_base index f5d2eff..0af6481 100644 --- a/config/common_base +++ b/config/common_base @@ -120,6 +120,7 @@ CONFIG_RTE_MAX_QUEUES_PER_PORT=1024 CONFIG_RTE_LIBRTE_IEEE1588=n CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y +CONFIG_RTE_ETHDEV_TX_PREP=y # # Support NIC bypass logic diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 0a32ebb..db5dc93 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -182,6 +182,7 @@ extern "C" { #include #include #include +#include #include "rte_ether.h" #include "rte_eth_ctrl.h" #include "rte_dev_info.h" @@ -699,6 +700,8 @@ struct rte_eth_desc_lim { uint16_t nb_max; /**< Max allowed number of descriptors. */ uint16_t nb_min; /**< Min allowed number of descriptors. */ uint16_t nb_align; /**< Number of descriptors should be aligned to. */ + uint16_t nb_seg_max; /**< Max number of segments per whole packet. */ + uint16_t nb_mtu_seg_max; /**< Max number of segments per one MTU */ }; /** @@ -1188,6 +1191,11 @@ typedef uint16_t (*eth_tx_burst_t)(void *txq, uint16_t nb_pkts); /**< @internal Send output packets on a transmit queue of an Ethernet device. */ +typedef uint16_t (*eth_tx_prep_t)(void *txq, + struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); +/**< @internal Prepare output packets on a transmit queue of an Ethernet device. */ + typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); /**< @internal Get current flow control parameter on an Ethernet device */ @@ -1622,6 +1630,7 @@ struct rte_eth_rxtx_callback { struct rte_eth_dev { eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */ eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */ + eth_tx_prep_t tx_pkt_prep; /**< Pointer to PMD transmit prepare function. */ struct rte_eth_dev_data *data; /**< Pointer to device data */ const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ @@ -2816,6 +2825,82 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id, return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts); } +/** + * Process a burst of output packets on a transmit queue of an Ethernet device. + * + * The rte_eth_tx_prep() function is invoked to prepare output packets to be + * transmitted on the output queue *queue_id* of the Ethernet device designated + * by its *port_id*. + * The *nb_pkts* parameter is the number of packets to be prepared which are + * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them + * allocated from a pool created with rte_pktmbuf_pool_create(). + * For each packet to send, the rte_eth_tx_prep() function performs + * the following operations: + * + * - Check if packet meets devices requirements for tx offloads. + * + * - Check limitations about number of segments. + * + * - Check additional requirements when debug is enabled. + * + * - Update and/or reset required checksums when tx offload is set for packet. + * + * The rte_eth_tx_prep() function returns the number of packets ready to be + * sent. A return value equal to *nb_pkts* means that all packets are valid and + * ready to be sent. + * + * @param port_id + * The port identifier of the