Skip to content

Commit 2ea32cd

Browse files
committed
Merge tag 'mlx5-updates-2018-02-28-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux into k.o/wip/dl-for-next
mlx5-updates-2018-02-28-2 (IPSec-2) This series follows our previous one to lay out the foundations for IPSec in user-space and extend current kernel netdev IPSec support. As noted in our previous pull request cover letter "mlx5-updates-2018-02-28-1 (IPSec-1)", the IPSec mechanism will be supported through our flow steering mechanism. Therefore, we need to change the initialization order. Furthermore, IPsec is also supported in both egress and ingress. Since our current flow steering is egress only, we add an empty (only implemented through FPGA steering ops) egress namespace to handle that case. We also implement the required flow steering callbacks and logic in our FPGA driver. We extend the FPGA support for ESN and modifying a xfrm too. Therefore, we add support for some new FPGA command interface that supports them. The other required bits are added too. The new features and requirements are advertised via cap bits. Last but not least, we revise our driver's accel_esp API. This API will be shared between our netdev and IB driver, so we need to have all the required functionality from both worlds. Regards, Aviad and Matan Signed-off-by: Doug Ledford <[email protected]>
2 parents 29cf135 + 31135eb commit 2ea32cd

File tree

14 files changed

+1858
-279
lines changed

14 files changed

+1858
-279
lines changed

drivers/net/ethernet/mellanox/mlx5/core/accel/ipsec.c

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,11 @@
3737
#include "mlx5_core.h"
3838
#include "fpga/ipsec.h"
3939

40-
void *mlx5_accel_ipsec_sa_cmd_exec(struct mlx5_core_dev *mdev,
41-
struct mlx5_accel_ipsec_sa *cmd)
42-
{
43-
if (!MLX5_IPSEC_DEV(mdev))
44-
return ERR_PTR(-EOPNOTSUPP);
45-
46-
return mlx5_fpga_ipsec_sa_cmd_exec(mdev, cmd);
47-
}
48-
49-
int mlx5_accel_ipsec_sa_cmd_wait(void *ctx)
50-
{
51-
return mlx5_fpga_ipsec_sa_cmd_wait(ctx);
52-
}
53-
5440
u32 mlx5_accel_ipsec_device_caps(struct mlx5_core_dev *mdev)
5541
{
5642
return mlx5_fpga_ipsec_device_caps(mdev);
5743
}
44+
EXPORT_SYMBOL_GPL(mlx5_accel_ipsec_device_caps);
5845

5946
unsigned int mlx5_accel_ipsec_counters_count(struct mlx5_core_dev *mdev)
6047
{
@@ -67,6 +54,21 @@ int mlx5_accel_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
6754
return mlx5_fpga_ipsec_counters_read(mdev, counters, count);
6855
}
6956

57+
void *mlx5_accel_esp_create_hw_context(struct mlx5_core_dev *mdev,
58+
struct mlx5_accel_esp_xfrm *xfrm,
59+
const __be32 saddr[4],
60+
const __be32 daddr[4],
61+
const __be32 spi, bool is_ipv6)
62+
{
63+
return mlx5_fpga_ipsec_create_sa_ctx(mdev, xfrm, saddr, daddr,
64+
spi, is_ipv6);
65+
}
66+
67+
void mlx5_accel_esp_free_hw_context(void *context)
68+
{
69+
mlx5_fpga_ipsec_delete_sa_ctx(context);
70+
}
71+
7072
int mlx5_accel_ipsec_init(struct mlx5_core_dev *mdev)
7173
{
7274
return mlx5_fpga_ipsec_init(mdev);
@@ -76,3 +78,32 @@ void mlx5_accel_ipsec_cleanup(struct mlx5_core_dev *mdev)
7678
{
7779
mlx5_fpga_ipsec_cleanup(mdev);
7880
}
81+
82+
struct mlx5_accel_esp_xfrm *
83+
mlx5_accel_esp_create_xfrm(struct mlx5_core_dev *mdev,
84+
const struct mlx5_accel_esp_xfrm_attrs *attrs,
85+
u32 flags)
86+
{
87+
struct mlx5_accel_esp_xfrm *xfrm;
88+
89+
xfrm = mlx5_fpga_esp_create_xfrm(mdev, attrs, flags);
90+
if (IS_ERR(xfrm))
91+
return xfrm;
92+
93+
xfrm->mdev = mdev;
94+
return xfrm;
95+
}
96+
EXPORT_SYMBOL_GPL(mlx5_accel_esp_create_xfrm);
97+
98+
void mlx5_accel_esp_destroy_xfrm(struct mlx5_accel_esp_xfrm *xfrm)
99+
{
100+
mlx5_fpga_esp_destroy_xfrm(xfrm);
101+
}
102+
EXPORT_SYMBOL_GPL(mlx5_accel_esp_destroy_xfrm);
103+
104+
int mlx5_accel_esp_modify_xfrm(struct mlx5_accel_esp_xfrm *xfrm,
105+
const struct mlx5_accel_esp_xfrm_attrs *attrs)
106+
{
107+
return mlx5_fpga_esp_modify_xfrm(xfrm, attrs);
108+
}
109+
EXPORT_SYMBOL_GPL(mlx5_accel_esp_modify_xfrm);

drivers/net/ethernet/mellanox/mlx5/core/accel/ipsec.h

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -35,95 +35,45 @@
3535
#define __MLX5_ACCEL_IPSEC_H__
3636

3737
#include <linux/mlx5/driver.h>
38+
#include <linux/mlx5/accel.h>
3839

3940
#ifdef CONFIG_MLX5_ACCEL
4041

41-
enum {
42-
MLX5_ACCEL_IPSEC_DEVICE = BIT(1),
43-
MLX5_ACCEL_IPSEC_IPV6 = BIT(2),
44-
MLX5_ACCEL_IPSEC_ESP = BIT(3),
45-
MLX5_ACCEL_IPSEC_LSO = BIT(4),
46-
};
47-
48-
#define MLX5_IPSEC_SADB_IP_AH BIT(7)
49-
#define MLX5_IPSEC_SADB_IP_ESP BIT(6)
50-
#define MLX5_IPSEC_SADB_SA_VALID BIT(5)
51-
#define MLX5_IPSEC_SADB_SPI_EN BIT(4)
52-
#define MLX5_IPSEC_SADB_DIR_SX BIT(3)
53-
#define MLX5_IPSEC_SADB_IPV6 BIT(2)
54-
55-
enum {
56-
MLX5_IPSEC_CMD_ADD_SA = 0,
57-
MLX5_IPSEC_CMD_DEL_SA = 1,
58-
};
59-
60-
enum mlx5_accel_ipsec_enc_mode {
61-
MLX5_IPSEC_SADB_MODE_NONE = 0,
62-
MLX5_IPSEC_SADB_MODE_AES_GCM_128_AUTH_128 = 1,
63-
MLX5_IPSEC_SADB_MODE_AES_GCM_256_AUTH_128 = 3,
64-
};
65-
6642
#define MLX5_IPSEC_DEV(mdev) (mlx5_accel_ipsec_device_caps(mdev) & \
67-
MLX5_ACCEL_IPSEC_DEVICE)
68-
69-
struct mlx5_accel_ipsec_sa {
70-
__be32 cmd;
71-
u8 key_enc[32];
72-
u8 key_auth[32];
73-
__be32 sip[4];
74-
__be32 dip[4];
75-
union {
76-
struct {
77-
__be32 reserved;
78-
u8 salt_iv[8];
79-
__be32 salt;
80-
} __packed gcm;
81-
struct {
82-
u8 salt[16];
83-
} __packed cbc;
84-
};
85-
__be32 spi;
86-
__be32 sw_sa_handle;
87-
__be16 tfclen;
88-
u8 enc_mode;
89-
u8 sip_masklen;
90-
u8 dip_masklen;
91-
u8 flags;
92-
u8 reserved[2];
93-
} __packed;
94-
95-
/**
96-
* mlx5_accel_ipsec_sa_cmd_exec - Execute an IPSec SADB command
97-
* @mdev: mlx5 device
98-
* @cmd: command to execute
99-
* May be called from atomic context. Returns context pointer, or error
100-
* Caller must eventually call mlx5_accel_ipsec_sa_cmd_wait from non-atomic
101-
* context, to cleanup the context pointer
102-
*/
103-
void *mlx5_accel_ipsec_sa_cmd_exec(struct mlx5_core_dev *mdev,
104-
struct mlx5_accel_ipsec_sa *cmd);
105-
106-
/**
107-
* mlx5_accel_ipsec_sa_cmd_wait - Wait for command execution completion
108-
* @context: Context pointer returned from call to mlx5_accel_ipsec_sa_cmd_exec
109-
* Sleeps (killable) until command execution is complete.
110-
* Returns the command result, or -EINTR if killed
111-
*/
112-
int mlx5_accel_ipsec_sa_cmd_wait(void *context);
113-
114-
u32 mlx5_accel_ipsec_device_caps(struct mlx5_core_dev *mdev);
43+
MLX5_ACCEL_IPSEC_CAP_DEVICE)
11544

11645
unsigned int mlx5_accel_ipsec_counters_count(struct mlx5_core_dev *mdev);
11746
int mlx5_accel_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
11847
unsigned int count);
11948

49+
void *mlx5_accel_esp_create_hw_context(struct mlx5_core_dev *mdev,
50+
struct mlx5_accel_esp_xfrm *xfrm,
51+
const __be32 saddr[4],
52+
const __be32 daddr[4],
53+
const __be32 spi, bool is_ipv6);
54+
void mlx5_accel_esp_free_hw_context(void *context);
55+
12056
int mlx5_accel_ipsec_init(struct mlx5_core_dev *mdev);
12157
void mlx5_accel_ipsec_cleanup(struct mlx5_core_dev *mdev);
12258

12359
#else
12460

12561
#define MLX5_IPSEC_DEV(mdev) false
12662

63+
static inline void *
64+
mlx5_accel_esp_create_hw_context(struct mlx5_core_dev *mdev,
65+
struct mlx5_accel_esp_xfrm *xfrm,
66+
const __be32 saddr[4],
67+
const __be32 daddr[4],
68+
const __be32 spi, bool is_ipv6)
69+
{
70+
return NULL;
71+
}
72+
73+
static inline void mlx5_accel_esp_free_hw_context(void *context)
74+
{
75+
}
76+
12777
static inline int mlx5_accel_ipsec_init(struct mlx5_core_dev *mdev)
12878
{
12979
return 0;

drivers/net/ethernet/mellanox/mlx5/core/cq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
109109
cq->cons_index = 0;
110110
cq->arm_sn = 0;
111111
cq->eq = eq;
112-
refcount_set(&cq->refcount, 0);
113-
mlx5_cq_hold(cq);
112+
refcount_set(&cq->refcount, 1);
114113
init_completion(&cq->free);
115114
if (!cq->comp)
116115
cq->comp = mlx5_add_cq_to_tasklet;

0 commit comments

Comments
 (0)