Commit 0f9008e5 authored by Steffen Klassert's avatar Steffen Klassert
Browse files

Merge branch 'Be explicit with XFRM offload direction'

Leon Romanovsky says:

====================
I may admit that the title of this series is not the best one as it
contains straightforward cleanups and code that converts flags to
something less confusing.

This series follows removal of FPGA IPsec code from the mlx5 driver and
based on net-next commit 4950b699 ("Merge branch
'ocelot-vcap-cleanups'").

As such, first two patches delete code that was used by mlx5 FPGA code
but isn't needed anymore.

Third patch is simple struct rename.

Rest of the patches separate user's provided flags variable from
driver's
usage. This allows us to created more simple in-kernel interface, that
supports type checking without blending different properties into one
variable. It is achieved by converting flags to specific bitfield
variables
with clear, meaningful names.

Such change allows us more clear addition of new input flags needed to
mark IPsec offload type.

The followup code uses this extensively:
https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=xfrm-next


====================

Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parents 949dfdcf 254c4a82
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -585,7 +585,7 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs)
		return -EINVAL;
	}

	if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) {
	if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
		struct rx_sa rsa;

		if (xs->calg) {
@@ -757,7 +757,7 @@ static void ixgbe_ipsec_del_sa(struct xfrm_state *xs)
	u32 zerobuf[4] = {0, 0, 0, 0};
	u16 sa_idx;

	if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) {
	if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
		struct rx_sa *rsa;
		u8 ipi;

@@ -903,8 +903,7 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
	/* Tx IPsec offload doesn't seem to work on this
	 * device, so block these requests for now.
	 */
	sam->flags = sam->flags & ~XFRM_OFFLOAD_IPV6;
	if (sam->flags != XFRM_OFFLOAD_INBOUND) {
	if (sam->dir != XFRM_DEV_OFFLOAD_IN) {
		err = -EOPNOTSUPP;
		goto err_out;
	}
@@ -915,7 +914,7 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
		goto err_out;
	}

	xs->xso.flags = sam->flags;
	xs->xso.dir = sam->dir;
	xs->id.spi = sam->spi;
	xs->id.proto = sam->proto;
	xs->props.family = sam->family;
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ struct ixgbe_ipsec {

struct sa_mbx_msg {
	__be32 spi;
	u8 flags;
	u8 dir;
	u8 proto;
	u16 family;
	__be32 addr[4];
+3 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ static int ixgbevf_ipsec_set_pf_sa(struct ixgbevf_adapter *adapter,

	/* send the important bits to the PF */
	sam = (struct sa_mbx_msg *)(&msgbuf[1]);
	sam->flags = xs->xso.flags;
	sam->dir = xs->xso.dir;
	sam->spi = xs->id.spi;
	sam->proto = xs->id.proto;
	sam->family = xs->props.family;
@@ -280,7 +280,7 @@ static int ixgbevf_ipsec_add_sa(struct xfrm_state *xs)
		return -EINVAL;
	}

	if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) {
	if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
		struct rx_sa rsa;

		if (xs->calg) {
@@ -394,7 +394,7 @@ static void ixgbevf_ipsec_del_sa(struct xfrm_state *xs)
	adapter = netdev_priv(dev);
	ipsec = adapter->ipsec;

	if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) {
	if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
		sa_idx = xs->xso.offload_handle - IXGBE_IPSEC_BASE_RX_INDEX;

		if (!ipsec->rx_tbl[sa_idx].used) {
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ struct ixgbevf_ipsec {

struct sa_mbx_msg {
	__be32 spi;
	u8 flags;
	u8 dir;
	u8 proto;
	u16 family;
	__be32 addr[4];
+5 −5
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
	}

	/* action */
	attrs->action = (!(x->xso.flags & XFRM_OFFLOAD_INBOUND)) ?
	attrs->action = (x->xso.dir == XFRM_DEV_OFFLOAD_OUT) ?
				MLX5_ACCEL_ESP_ACTION_ENCRYPT :
				      MLX5_ACCEL_ESP_ACTION_DECRYPT;
	/* flags */
@@ -306,7 +306,7 @@ static int mlx5e_xfrm_add_state(struct xfrm_state *x)
	if (err)
		goto err_hw_ctx;

	if (x->xso.flags & XFRM_OFFLOAD_INBOUND) {
	if (x->xso.dir == XFRM_DEV_OFFLOAD_IN) {
		err = mlx5e_ipsec_sadb_rx_add(sa_entry);
		if (err)
			goto err_add_rule;
@@ -333,7 +333,7 @@ static void mlx5e_xfrm_del_state(struct xfrm_state *x)
{
	struct mlx5e_ipsec_sa_entry *sa_entry = to_ipsec_sa_entry(x);

	if (x->xso.flags & XFRM_OFFLOAD_INBOUND)
	if (x->xso.dir == XFRM_DEV_OFFLOAD_IN)
		mlx5e_ipsec_sadb_rx_del(sa_entry);
}

Loading