DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wiles, Keith" <keith.wiles@intel.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: dpdk-dev <dev@dpdk.org>,
	"akhil.goyal@nxp.com" <akhil.goyal@nxp.com>,
	"olivier.matz@6wind.com" <olivier.matz@6wind.com>
Subject: Re: [dpdk-dev] [PATCH v2 1/7] mbuf: new function to generate raw Tx	offload value
Date: Wed, 20 Mar 2019 17:53:01 +0000	[thread overview]
Message-ID: <96B7DD3D-3016-4C23-9BB0-DFB1F16B07A9@intel.com> (raw)
Message-ID: <20190320175301.wrr_OsN42tbGKv2LgsJb4DWLrrg6AN3ANkKa6yJLj58@z> (raw)
In-Reply-To: <1553102679-23576-2-git-send-email-konstantin.ananyev@intel.com>



> On Mar 20, 2019, at 10:24 AM, Konstantin Ananyev <konstantin.ananyev@intel.com> wrote:
> 
> Operations to set/update bit-fields often cause compilers
> to generate suboptimal code.
> To help avoid such situation for tx_offload fields:
> introduce new enum for tx_offload bit-fields lengths and offsets,
> and new function to generate raw tx_offload value.
> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> ---
> lib/librte_mbuf/rte_mbuf.h | 71 ++++++++++++++++++++++++++++++++++----
> 1 file changed, 64 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index d961ccaf6..b967ad17e 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -479,6 +479,26 @@ struct rte_mbuf_sched {
> 	uint16_t reserved;   /**< Reserved. */
> }; /**< Hierarchical scheduler */
> 
> +/** enum for the tx_offload bit-fields lenghts and offsets. */
> +enum {
> +	RTE_MBUF_L2_LEN_BITS = 7,
> +	RTE_MBUF_L3_LEN_BITS = 9,
> +	RTE_MBUF_L4_LEN_BITS = 8,
> +	RTE_MBUF_TSO_SEGSZ_BITS = 16,
> +	RTE_MBUF_OL3_LEN_BITS = 9,
> +	RTE_MBUF_OL2_LEN_BITS = 7,
> +	RTE_MBUF_L2_LEN_OFS = 0,
> +	RTE_MBUF_L3_LEN_OFS = RTE_MBUF_L2_LEN_OFS + RTE_MBUF_L2_LEN_BITS,
> +	RTE_MBUF_L4_LEN_OFS = RTE_MBUF_L3_LEN_OFS + RTE_MBUF_L3_LEN_BITS,
> +	RTE_MBUF_TSO_SEGSZ_OFS = RTE_MBUF_L4_LEN_OFS + RTE_MBUF_L4_LEN_BITS,
> +	RTE_MBUF_OL3_LEN_OFS = RTE_MBUF_TSO_SEGSZ_OFS + RTE_MBUF_TSO_SEGSZ_BITS,
> +	RTE_MBUF_OL2_LEN_OFS = RTE_MBUF_OL3_LEN_OFS + RTE_MBUF_OL3_LEN_BITS,
> +	RTE_MBUF_TXOFLD_UNUSED_OFS =
> +		RTE_MBUF_OL2_LEN_OFS + RTE_MBUF_OL2_LEN_BITS,
> +	RTE_MBUF_TXOFLD_UNUSED_BITS =
> +		sizeof(uint64_t) * CHAR_BIT - RTE_MBUF_TXOFLD_UNUSED_OFS,
> +};

The naming of these fields is a bit unreadable and why do we need to add RTE_MBUF_ to everything especially adding RTE_ to everything.
Then we have to shorten words like OFFSET to OFS, it would be much better for readability to use something like this

RTE_MBUF_OL3_LEN_OFS to MBUF_OL3_LEN_OFFSET, then we have OL3 or OL2, which does not jump out at me as well.
What does OL3 or OL2 mean? OffLoad-3 or OffLoad-2 this also needs to be clearly defined to improve the readability of the macros.
Also for TXOFLD needs to be clearer here to help the reader understand the mean of the defines.


> +
> /**
>  * The generic rte_mbuf, containing a packet mbuf.
>  */
> @@ -640,19 +660,24 @@ struct rte_mbuf {
> 		uint64_t tx_offload;       /**< combined for easy fetch */
> 		__extension__
> 		struct {
> -			uint64_t l2_len:7;
> +			uint64_t l2_len:RTE_MBUF_L2_LEN_BITS;
> 			/**< L2 (MAC) Header Length for non-tunneling pkt.
> 			 * Outer_L4_len + ... + Inner_L2_len for tunneling pkt.
> 			 */
> -			uint64_t l3_len:9; /**< L3 (IP) Header Length. */
> -			uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */
> -			uint64_t tso_segsz:16; /**< TCP TSO segment size */
> +			uint64_t l3_len:RTE_MBUF_L3_LEN_BITS;
> +			/**< L3 (IP) Header Length. */
> +			uint64_t l4_len:RTE_MBUF_L4_LEN_BITS;
> +			/**< L4 (TCP/UDP) Header Length. */
> +			uint64_t tso_segsz:RTE_MBUF_TSO_SEGSZ_BITS;
> +			/**< TCP TSO segment size */
> 
> 			/* fields for TX offloading of tunnels */
> -			uint64_t outer_l3_len:9; /**< Outer L3 (IP) Hdr Length. */
> -			uint64_t outer_l2_len:7; /**< Outer L2 (MAC) Hdr Length. */
> +			uint64_t outer_l3_len:RTE_MBUF_OL3_LEN_BITS;
> +			/**< Outer L3 (IP) Hdr Length. */
> +			uint64_t outer_l2_len:RTE_MBUF_OL2_LEN_BITS;
> +			/**< Outer L2 (MAC) Hdr Length. */
> 
> -			/* uint64_t unused:8; */
> +			/* uint64_t unused:RTE_MBUF_TXOFLD_UNUSED_BITS; */
> 		};
> 	};
> 
> @@ -2243,6 +2268,38 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail
> 	return 0;
> }
> 
> +/*
> + * @warning
> + * @b EXPERIMENTAL: This API may change without prior notice.
> + *
> + * For given input values generate raw tx_offload value.
> + * @param il2
> + *   l2_len value.
> + * @param il3
> + *   l3_len value.
> + * @param il4
> + *   l4_len value.
> + * @param tso
> + *   tso_segsz value.
> + * @param ol3
> + *   outer_l3_len value.
> + * @param ol2
> + *   outer_l2_len value.
> + * @return
> + *   raw tx_offload value.
> + */
> +static inline uint64_t
> +rte_mbuf_tx_offload(uint64_t il2, uint64_t il3, uint64_t il4, uint64_t tso,
> +	uint64_t ol3, uint64_t ol2)
> +{
> +	return il2 << RTE_MBUF_L2_LEN_OFS |
> +		il3 << RTE_MBUF_L3_LEN_OFS |
> +		il4 << RTE_MBUF_L4_LEN_OFS |
> +		tso << RTE_MBUF_TSO_SEGSZ_OFS |
> +		ol3 << RTE_MBUF_OL3_LEN_OFS |
> +		ol2 << RTE_MBUF_OL2_LEN_OFS;
> +}
> +
> /**
>  * Validate general requirements for Tx offload in mbuf.
>  *
> -- 
> 2.17.1
> 

Regards,
Keith


  parent reply	other threads:[~2019-03-20 17:53 UTC|newest]

Thread overview: 163+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 19:20 [dpdk-dev] [PATCH 0/6] Few small improvements for ipsec library Konstantin Ananyev
2019-02-28 19:20 ` [dpdk-dev] [PATCH 1/6] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-02-28 19:20 ` [dpdk-dev] [PATCH 2/6] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-02-28 19:20 ` [dpdk-dev] [PATCH 3/6] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-02-28 19:20 ` [dpdk-dev] [PATCH 4/6] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-02-28 19:21 ` [dpdk-dev] [PATCH 5/6] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-02-28 19:21 ` [dpdk-dev] [PATCH 6/6] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 0/7] Few small improvements for ipsec library Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 1/7] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:53   ` Wiles, Keith [this message]
2019-03-20 17:53     ` Wiles, Keith
2019-03-22 17:37     ` Ananyev, Konstantin
2019-03-22 17:37       ` Ananyev, Konstantin
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 2/7] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 3/7] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 4/7] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 5/7] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 6/7] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 17:24 ` [dpdk-dev] [PATCH v2 7/7] ipsec: reorder packet process " Konstantin Ananyev
2019-03-20 17:24   ` Konstantin Ananyev
2019-03-20 18:46 ` [dpdk-dev] [PATCH v2 0/7] Few small improvements for ipsec library Konstantin Ananyev
2019-03-20 18:46   ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 1/7] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-21  3:33     ` Jerin Jacob Kollanukkaran
2019-03-21  3:33       ` Jerin Jacob Kollanukkaran
2019-03-21  6:04     ` Shahaf Shuler
2019-03-21  6:04       ` Shahaf Shuler
2019-03-21 13:51       ` Ananyev, Konstantin
2019-03-21 13:51         ` Ananyev, Konstantin
2019-03-24  8:00         ` Shahaf Shuler
2019-03-24  8:00           ` Shahaf Shuler
2019-03-26 15:43     ` [dpdk-dev] [PATCH v3 0/8] Few small improvements for ipsec library Konstantin Ananyev
2019-03-26 15:43       ` Konstantin Ananyev
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 1/8] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28  8:16         ` Akhil Goyal
2019-03-28  8:16           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 2/8] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28  8:52         ` Akhil Goyal
2019-03-28  8:52           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 3/8] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28  9:02         ` Akhil Goyal
2019-03-28  9:02           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 4/8] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28 10:52         ` Akhil Goyal
2019-03-28 10:52           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 5/8] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28 11:20         ` Akhil Goyal
2019-03-28 11:20           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 6/8] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28 11:27         ` Akhil Goyal
2019-03-28 11:27           ` Akhil Goyal
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 7/8] ipsec: reorder packet process " Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-26 15:43       ` [dpdk-dev] [PATCH v3 8/8] ipsec: de-duplicate crypto op prepare code-path Konstantin Ananyev
2019-03-26 15:43         ` Konstantin Ananyev
2019-03-28 11:35         ` Akhil Goyal
2019-03-28 11:35           ` Akhil Goyal
2019-03-28 11:21       ` [dpdk-dev] [PATCH v3 0/8] Few small improvements for ipsec library Akhil Goyal
2019-03-28 11:21         ` Akhil Goyal
2019-03-28 11:49         ` Ananyev, Konstantin
2019-03-28 11:49           ` Ananyev, Konstantin
2019-03-29 10:27       ` [dpdk-dev] [PATCH v4 0/9] " Konstantin Ananyev
2019-03-29 10:27         ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 1/9] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 12:54           ` Olivier Matz
2019-03-29 12:54             ` Olivier Matz
2019-03-30 14:20             ` Ananyev, Konstantin
2019-03-30 14:20               ` Ananyev, Konstantin
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 2/9] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 3/9] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 4/9] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 5/9] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 6/9] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 7/9] ipsec: reorder packet process " Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 8/9] ipsec: de-duplicate crypto op prepare code-path Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 10:27         ` [dpdk-dev] [PATCH v4 9/9] doc: add ipsec lib into shared libraries list Konstantin Ananyev
2019-03-29 10:27           ` Konstantin Ananyev
2019-03-29 16:03           ` Akhil Goyal
2019-03-29 16:03             ` Akhil Goyal
2019-04-01 12:56         ` [dpdk-dev] [PATCH v5 0/9] Few small improvements for ipsec library Konstantin Ananyev
2019-04-01 12:56           ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 1/9] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 13:18             ` Akhil Goyal
2019-04-01 13:18               ` Akhil Goyal
2019-04-01 13:22             ` Olivier Matz
2019-04-01 13:22               ` Olivier Matz
2019-04-01 13:55               ` Ananyev, Konstantin
2019-04-01 13:55                 ` Ananyev, Konstantin
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 2/9] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 3/9] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 4/9] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 5/9] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 6/9] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 7/9] ipsec: reorder packet process " Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 8/9] ipsec: de-duplicate crypto op prepare code-path Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-01 12:56           ` [dpdk-dev] [PATCH v5 9/9] doc: add ipsec lib into shared libraries list Konstantin Ananyev
2019-04-01 12:56             ` Konstantin Ananyev
2019-04-02  8:34           ` [dpdk-dev] [PATCH v6 0/9] Few small improvements for ipsec library Konstantin Ananyev
2019-04-02  8:34             ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 1/9] mbuf: new function to generate raw Tx offload value Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:49               ` Olivier Matz
2019-04-02  8:49                 ` Olivier Matz
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 2/9] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 3/9] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 4/9] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 5/9] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 6/9] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 7/9] ipsec: reorder packet process " Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 8/9] ipsec: de-duplicate crypto op prepare code-path Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02  8:34             ` [dpdk-dev] [PATCH v6 9/9] doc: add ipsec lib into shared libraries list Konstantin Ananyev
2019-04-02  8:34               ` Konstantin Ananyev
2019-04-02 15:36             ` [dpdk-dev] [PATCH v6 0/9] Few small improvements for ipsec library Akhil Goyal
2019-04-02 15:36               ` Akhil Goyal
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 2/7] ipsec: add Tx offload template into SA Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 3/7] ipsec: change the order in filling crypto op Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 4/7] ipsec: change the way unprocessed mbufs are accounted Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 5/7] ipsec: move inbound and outbound code into different files Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 6/7] ipsec: reorder packet check for esp inbound Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev
2019-03-20 18:46   ` [dpdk-dev] [PATCH v2 7/7] ipsec: reorder packet process " Konstantin Ananyev
2019-03-20 18:46     ` Konstantin Ananyev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=96B7DD3D-3016-4C23-9BB0-DFB1F16B07A9@intel.com \
    --to=keith.wiles@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).