From: Boris Pismenny <borisp@mellanox.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, davejwatson@fb.com, aviadye@mellanox.com,
borisp@mellanox.com, saeedm@mellanox.com
Subject: [PATCH v3 net-next 17/19] net/mlx5: Accel, add common metadata functions
Date: Wed, 11 Jul 2018 22:54:31 +0300 [thread overview]
Message-ID: <1531338873-18466-18-git-send-email-borisp@mellanox.com> (raw)
In-Reply-To: <1531338873-18466-1-git-send-email-borisp@mellanox.com>
This patch adds common functions to handle mellanox metadata headers.
These functions are used by IPsec and TLS to process FPGA metadata.
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/accel/accel.h | 37 ++++++++++++++++++++++
.../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 19 +++--------
.../mellanox/mlx5/core/en_accel/tls_rxtx.c | 18 +++--------
3 files changed, 45 insertions(+), 29 deletions(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/accel/accel.h
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/accel/accel.h b/drivers/net/ethernet/mellanox/mlx5/core/accel/accel.h
new file mode 100644
index 0000000..c132604
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/accel/accel.h
@@ -0,0 +1,37 @@
+#ifndef __MLX5E_ACCEL_H__
+#define __MLX5E_ACCEL_H__
+
+#ifdef CONFIG_MLX5_ACCEL
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "en.h"
+
+static inline bool is_metadata_hdr_valid(struct sk_buff *skb)
+{
+ __be16 *ethtype;
+
+ if (unlikely(skb->len < ETH_HLEN + MLX5E_METADATA_ETHER_LEN))
+ return false;
+ ethtype = (__be16 *)(skb->data + ETH_ALEN * 2);
+ if (*ethtype != cpu_to_be16(MLX5E_METADATA_ETHER_TYPE))
+ return false;
+ return true;
+}
+
+static inline void remove_metadata_hdr(struct sk_buff *skb)
+{
+ struct ethhdr *old_eth;
+ struct ethhdr *new_eth;
+
+ /* Remove the metadata from the buffer */
+ old_eth = (struct ethhdr *)skb->data;
+ new_eth = (struct ethhdr *)(skb->data + MLX5E_METADATA_ETHER_LEN);
+ memmove(new_eth, old_eth, 2 * ETH_ALEN);
+ /* Ethertype is already in its new place */
+ skb_pull_inline(skb, MLX5E_METADATA_ETHER_LEN);
+}
+
+#endif /* CONFIG_MLX5_ACCEL */
+
+#endif /* __MLX5E_EN_ACCEL_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
index c245d8e..fda7929 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
@@ -37,6 +37,7 @@
#include "en_accel/ipsec_rxtx.h"
#include "en_accel/ipsec.h"
+#include "accel/accel.h"
#include "en.h"
enum {
@@ -346,19 +347,12 @@ struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
}
struct sk_buff *mlx5e_ipsec_handle_rx_skb(struct net_device *netdev,
- struct sk_buff *skb)
+ struct sk_buff *skb, u32 *cqe_bcnt)
{
struct mlx5e_ipsec_metadata *mdata;
- struct ethhdr *old_eth;
- struct ethhdr *new_eth;
struct xfrm_state *xs;
- __be16 *ethtype;
- /* Detect inline metadata */
- if (skb->len < ETH_HLEN + MLX5E_METADATA_ETHER_LEN)
- return skb;
- ethtype = (__be16 *)(skb->data + ETH_ALEN * 2);
- if (*ethtype != cpu_to_be16(MLX5E_METADATA_ETHER_TYPE))
+ if (!is_metadata_hdr_valid(skb))
return skb;
/* Use the metadata */
@@ -369,12 +363,7 @@ struct sk_buff *mlx5e_ipsec_handle_rx_skb(struct net_device *netdev,
return NULL;
}
- /* Remove the metadata from the buffer */
- old_eth = (struct ethhdr *)skb->data;
- new_eth = (struct ethhdr *)(skb->data + MLX5E_METADATA_ETHER_LEN);
- memmove(new_eth, old_eth, 2 * ETH_ALEN);
- /* Ethertype is already in its new place */
- skb_pull_inline(skb, MLX5E_METADATA_ETHER_LEN);
+ remove_metadata_hdr(skb);
return skb;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c
index ecfc764..92d3745 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c
@@ -33,6 +33,8 @@
#include "en_accel/tls.h"
#include "en_accel/tls_rxtx.h"
+#include "accel/accel.h"
+
#include <net/inet6_hashtables.h>
#include <linux/ipv6.h>
@@ -350,16 +352,9 @@ void mlx5e_tls_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
u32 *cqe_bcnt)
{
struct mlx5e_tls_metadata *mdata;
- struct ethhdr *old_eth;
- struct ethhdr *new_eth;
- __be16 *ethtype;
struct mlx5e_priv *priv;
- /* Detect inline metadata */
- if (skb->len < ETH_HLEN + MLX5E_METADATA_ETHER_LEN)
- return;
- ethtype = (__be16 *)(skb->data + ETH_ALEN * 2);
- if (*ethtype != cpu_to_be16(MLX5E_METADATA_ETHER_TYPE))
+ if (!is_metadata_hdr_valid(skb))
return;
/* Use the metadata */
@@ -383,11 +378,6 @@ void mlx5e_tls_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
return;
}
- /* Remove the metadata from the buffer */
- old_eth = (struct ethhdr *)skb->data;
- new_eth = (struct ethhdr *)(skb->data + MLX5E_METADATA_ETHER_LEN);
- memmove(new_eth, old_eth, 2 * ETH_ALEN);
- /* Ethertype is already in its new place */
- skb_pull_inline(skb, MLX5E_METADATA_ETHER_LEN);
+ remove_metadata_hdr(skb);
*cqe_bcnt -= MLX5E_METADATA_ETHER_LEN;
}
--
1.8.3.1
next prev parent reply other threads:[~2018-07-11 20:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 19:54 [PATCH v3 net-next 00/19] TLS offload rx, netdev & mlx5 Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 01/19] net: Add decrypted field to skb Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 02/19] net: Add TLS RX offload feature Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 03/19] net: Add TLS rx resync NDO Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 04/19] tcp: Don't coalesce decrypted and encrypted SKBs Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 05/19] tls: Refactor tls_offload variable names Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 06/19] tls: Split decrypt_skb to two functions Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 07/19] tls: Split tls_sw_release_resources_rx Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 08/19] tls: Fill software context without allocation Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 09/19] tls: Add rx inline crypto offload Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 10/19] tls: Fix zerocopy_from_iter iov handling Boris Pismenny
2018-07-12 16:46 ` Dave Watson
2018-07-12 19:28 ` Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 11/19] net/mlx5e: TLS, refactor variable names Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 12/19] net/mlx5: Accel, add TLS rx offload routines Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 13/19] net/mlx5e: TLS, add innova rx support Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 14/19] net/mlx5e: TLS, add Innova TLS rx data path Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 15/19] net/mlx5e: TLS, add software statistics Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 16/19] net/mlx5e: TLS, build TLS netdev from capabilities Boris Pismenny
2018-07-11 19:54 ` Boris Pismenny [this message]
2018-07-11 19:54 ` [PATCH v3 net-next 18/19] net/mlx5e: IPsec, fix byte count in CQE Boris Pismenny
2018-07-11 19:54 ` [PATCH v3 net-next 19/19] net/mlx5e: Kconfig, mutually exclude compilation of TLS and IPsec accel Boris Pismenny
2018-07-12 16:54 ` [PATCH v3 net-next 00/19] TLS offload rx, netdev & mlx5 Dave Watson
2018-07-12 19:20 ` Boris Pismenny
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=1531338873-18466-18-git-send-email-borisp@mellanox.com \
--to=borisp@mellanox.com \
--cc=aviadye@mellanox.com \
--cc=davejwatson@fb.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.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).