Skip to content

Commit 7a13a2e

Browse files
Yinjun Zhangkuba-moo
authored andcommitted
nfp: fix incorrect use of mbox in IPsec code
The mailbox configuration mechanism requires writing several registers, which shouldn't be interrupted, so need lock to avoid race condition. The base offset of mailbox configuration registers is not fixed, it depends on TLV caps read from application firmware. Fixes: 859a497 ("nfp: implement xfrm callbacks and expose ipsec offload feature to upper layer") Signed-off-by: Yinjun Zhang <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d61615c commit 7a13a2e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

drivers/net/ethernet/netronome/nfp/crypto/ipsec.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,32 @@ struct nfp_ipsec_cfg_mssg {
132132
static int nfp_ipsec_cfg_cmd_issue(struct nfp_net *nn, int type, int saidx,
133133
struct nfp_ipsec_cfg_mssg *msg)
134134
{
135+
unsigned int offset = nn->tlv_caps.mbox_off + NFP_NET_CFG_MBOX_SIMPLE_VAL;
135136
int i, msg_size, ret;
136137

138+
ret = nfp_net_mbox_lock(nn, sizeof(*msg));
139+
if (ret)
140+
return ret;
141+
137142
msg->cmd = type;
138143
msg->sa_idx = saidx;
139144
msg->rsp = 0;
140145
msg_size = ARRAY_SIZE(msg->raw);
141146

142147
for (i = 0; i < msg_size; i++)
143-
nn_writel(nn, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
148+
nn_writel(nn, offset + 4 * i, msg->raw[i]);
144149

145150
ret = nfp_net_mbox_reconfig(nn, NFP_NET_CFG_MBOX_CMD_IPSEC);
146-
if (ret < 0)
151+
if (ret < 0) {
152+
nn_ctrl_bar_unlock(nn);
147153
return ret;
154+
}
148155

149156
/* For now we always read the whole message response back */
150157
for (i = 0; i < msg_size; i++)
151-
msg->raw[i] = nn_readl(nn, NFP_NET_CFG_MBOX_VAL + 4 * i);
158+
msg->raw[i] = nn_readl(nn, offset + 4 * i);
159+
160+
nn_ctrl_bar_unlock(nn);
152161

153162
switch (msg->rsp) {
154163
case NFP_IPSEC_CFG_MSSG_OK:

drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@
403403
*/
404404
#define NFP_NET_CFG_MBOX_BASE 0x1800
405405
#define NFP_NET_CFG_MBOX_VAL_MAX_SZ 0x1F8
406-
#define NFP_NET_CFG_MBOX_VAL 0x1808
407406
#define NFP_NET_CFG_MBOX_SIMPLE_CMD 0x0
408407
#define NFP_NET_CFG_MBOX_SIMPLE_RET 0x4
409408
#define NFP_NET_CFG_MBOX_SIMPLE_VAL 0x8

0 commit comments

Comments
 (0)