Commit f02bac9a authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by Saeed Mahameed
Browse files

net/mlx5e: Return bool from TLS and IPSEC offloads



TLS and IPSEC offloads currently return struct sk_buff *, but the value
is either NULL or the same skb that was passed as a parameter. Return
bool instead to provide stronger guarantees to the calling code (it
won't need to support handling a different SKB that could be potentially
returned before this change) and to simplify restructuring this code in
the following commits.

Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 76cd622f
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -102,8 +102,7 @@ mlx5e_udp_gso_handle_tx_skb(struct sk_buff *skb)
	udp_hdr(skb)->len = htons(payload_len);
}

static inline struct sk_buff *
mlx5e_accel_handle_tx(struct sk_buff *skb,
static inline bool mlx5e_accel_handle_tx(struct sk_buff *skb,
					 struct mlx5e_txqsq *sq,
					 struct net_device *dev,
					 struct mlx5e_tx_wqe **wqe,
@@ -111,24 +110,22 @@ mlx5e_accel_handle_tx(struct sk_buff *skb,
{
#ifdef CONFIG_MLX5_EN_TLS
	if (test_bit(MLX5E_SQ_STATE_TLS, &sq->state)) {
		skb = mlx5e_tls_handle_tx_skb(dev, sq, skb, wqe, pi);
		if (unlikely(!skb))
			return NULL;
		if (unlikely(!mlx5e_tls_handle_tx_skb(dev, sq, skb, wqe, pi)))
			return false;
	}
#endif

#ifdef CONFIG_MLX5_EN_IPSEC
	if (test_bit(MLX5E_SQ_STATE_IPSEC, &sq->state)) {
		skb = mlx5e_ipsec_handle_tx_skb(dev, *wqe, skb);
		if (unlikely(!skb))
			return NULL;
		if (unlikely(!mlx5e_ipsec_handle_tx_skb(dev, *wqe, skb)))
			return false;
	}
#endif

	if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
		mlx5e_udp_gso_handle_tx_skb(skb);

	return skb;
	return true;
}

#endif /* __MLX5E_EN_ACCEL_H__ */
+6 −6
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ static void mlx5e_ipsec_set_metadata(struct sk_buff *skb,
		   ntohs(mdata->content.tx.seq));
}

struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
bool mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
			       struct mlx5e_tx_wqe *wqe,
			       struct sk_buff *skb)
{
@@ -245,7 +245,7 @@ struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
	struct sec_path *sp;

	if (!xo)
		return skb;
		return true;

	sp = skb_sec_path(skb);
	if (unlikely(sp->len != 1)) {
@@ -281,11 +281,11 @@ struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
	sa_entry->set_iv_op(skb, x, xo);
	mlx5e_ipsec_set_metadata(skb, mdata, xo);

	return skb;
	return true;

drop:
	kfree_skb(skb);
	return NULL;
	return false;
}

static inline struct xfrm_state *
+3 −3
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ void mlx5e_ipsec_set_iv_esn(struct sk_buff *skb, struct xfrm_state *x,
			    struct xfrm_offload *xo);
void mlx5e_ipsec_set_iv(struct sk_buff *skb, struct xfrm_state *x,
			struct xfrm_offload *xo);
struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
bool mlx5e_ipsec_handle_tx_skb(struct net_device *netdev,
			       struct mlx5e_tx_wqe *wqe,
			       struct sk_buff *skb);

+3 −4
Original line number Diff line number Diff line
@@ -95,10 +95,9 @@ mlx5e_get_ktls_tx_priv_ctx(struct tls_context *tls_ctx)
void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv);
void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx);

struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
					 struct mlx5e_txqsq *sq,
					 struct sk_buff *skb,
					 struct mlx5e_tx_wqe **wqe, u16 *pi);
bool mlx5e_ktls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,
			      struct sk_buff *skb, struct mlx5e_tx_wqe **wqe,
			      u16 *pi);
void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
					   struct mlx5e_tx_wqe_info *wi,
					   u32 *dma_fifo_cc);
+5 −6
Original line number Diff line number Diff line
@@ -413,10 +413,9 @@ err_out:
	return MLX5E_KTLS_SYNC_FAIL;
}

struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
					 struct mlx5e_txqsq *sq,
					 struct sk_buff *skb,
					 struct mlx5e_tx_wqe **wqe, u16 *pi)
bool mlx5e_ktls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,
			      struct sk_buff *skb, struct mlx5e_tx_wqe **wqe,
			      u16 *pi)
{
	struct mlx5e_ktls_offload_context_tx *priv_tx;
	struct mlx5e_sq_stats *stats = sq->stats;
@@ -474,9 +473,9 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
	stats->tls_encrypted_bytes   += datalen;

out:
	return skb;
	return true;

err_out:
	dev_kfree_skb_any(skb);
	return NULL;
	return false;
}
Loading