Skip to content

Commit cf718ea

Browse files
Srikanth, Jampalaherbertx
authored andcommitted
crypto: cavium/nitrox - Enabled Mailbox support
Enabled the PF->VF Mailbox support. Mailbox message are interpreted as {type, opcode, data}. Supported message types are REQ, ACK and NACK. Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 19c11c9 commit cf718ea

File tree

11 files changed

+441
-54
lines changed

11 files changed

+441
-54
lines changed

drivers/crypto/cavium/nitrox/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ n5pf-objs := nitrox_main.o \
66
nitrox_lib.o \
77
nitrox_hal.o \
88
nitrox_reqmgr.o \
9-
nitrox_algs.o
9+
nitrox_algs.o \
10+
nitrox_mbx.o
1011

1112
n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
1213
n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o

drivers/crypto/cavium/nitrox/nitrox_csr.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@
5454
#define NPS_STATS_PKT_DMA_WR_CNT 0x1000190
5555

5656
/* NPS packet registers */
57-
#define NPS_PKT_INT 0x1040018
57+
#define NPS_PKT_INT 0x1040018
58+
#define NPS_PKT_MBOX_INT_LO 0x1040020
59+
#define NPS_PKT_MBOX_INT_LO_ENA_W1C 0x1040030
60+
#define NPS_PKT_MBOX_INT_LO_ENA_W1S 0x1040038
61+
#define NPS_PKT_MBOX_INT_HI 0x1040040
62+
#define NPS_PKT_MBOX_INT_HI_ENA_W1C 0x1040050
63+
#define NPS_PKT_MBOX_INT_HI_ENA_W1S 0x1040058
5864
#define NPS_PKT_IN_RERR_HI 0x1040108
5965
#define NPS_PKT_IN_RERR_HI_ENA_W1S 0x1040120
6066
#define NPS_PKT_IN_RERR_LO 0x1040128
@@ -74,6 +80,10 @@
7480
#define NPS_PKT_SLC_RERR_LO_ENA_W1S 0x1040240
7581
#define NPS_PKT_SLC_ERR_TYPE 0x1040248
7682
#define NPS_PKT_SLC_ERR_TYPE_ENA_W1S 0x1040260
83+
/* Mailbox PF->VF PF Accessible Data registers */
84+
#define NPS_PKT_MBOX_PF_VF_PFDATAX(_i) (0x1040800 + ((_i) * 0x8))
85+
#define NPS_PKT_MBOX_VF_PF_PFDATAX(_i) (0x1040C00 + ((_i) * 0x8))
86+
7787
#define NPS_PKT_SLC_CTLX(_i) (0x10000 + ((_i) * 0x40000))
7888
#define NPS_PKT_SLC_CNTSX(_i) (0x10008 + ((_i) * 0x40000))
7989
#define NPS_PKT_SLC_INT_LEVELSX(_i) (0x10010 + ((_i) * 0x40000))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#ifndef __NITROX_DEBUGFS_H
3+
#define __NITROX_DEBUGFS_H
4+
5+
#include "nitrox_dev.h"
6+
7+
#ifdef CONFIG_DEBUG_FS
8+
int nitrox_debugfs_init(struct nitrox_device *ndev);
9+
void nitrox_debugfs_exit(struct nitrox_device *ndev);
10+
#else
11+
static inline int nitrox_debugfs_init(struct nitrox_device *ndev)
12+
{
13+
return 0;
14+
}
15+
16+
static inline int nitrox_sriov_debugfs_init(struct nitrox_device *ndev)
17+
{
18+
return 0;
19+
}
20+
#endif /* !CONFIG_DEBUG_FS */
21+
22+
#endif /* __NITROX_DEBUGFS_H */

drivers/crypto/cavium/nitrox/nitrox_dev.h

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/if.h>
99

1010
#define VERSION_LEN 32
11+
/* Maximum queues in PF mode */
12+
#define MAX_PF_QUEUES 64
1113

1214
/**
1315
* struct nitrox_cmdq - NITROX command queue
@@ -103,13 +105,58 @@ struct nitrox_q_vector {
103105
};
104106
};
105107

108+
/**
109+
* mbox_msg - Mailbox message data
110+
* @type: message type
111+
* @opcode: message opcode
112+
* @data: message data
113+
*/
114+
union mbox_msg {
115+
u64 value;
116+
struct {
117+
u64 type: 2;
118+
u64 opcode: 6;
119+
u64 data: 58;
120+
};
121+
struct {
122+
u64 type: 2;
123+
u64 opcode: 6;
124+
u64 chipid: 8;
125+
u64 vfid: 8;
126+
} id;
127+
};
128+
129+
/**
130+
* nitrox_vfdev - NITROX VF device instance in PF
131+
* @state: VF device state
132+
* @vfno: VF number
133+
* @nr_queues: number of queues enabled in VF
134+
* @ring: ring to communicate with VF
135+
* @msg: Mailbox message data from VF
136+
* @mbx_resp: Mailbox counters
137+
*/
138+
struct nitrox_vfdev {
139+
atomic_t state;
140+
int vfno;
141+
int nr_queues;
142+
int ring;
143+
union mbox_msg msg;
144+
atomic64_t mbx_resp;
145+
};
146+
106147
/**
107148
* struct nitrox_iov - SR-IOV information
108149
* @num_vfs: number of VF(s) enabled
109-
* @msix: MSI-X for PF in SR-IOV case
150+
* @max_vf_queues: Maximum number of queues allowed for VF
151+
* @vfdev: VF(s) devices
152+
* @pf2vf_wq: workqueue for PF2VF communication
153+
* @msix: MSI-X entry for PF in SR-IOV case
110154
*/
111155
struct nitrox_iov {
112156
int num_vfs;
157+
int max_vf_queues;
158+
struct nitrox_vfdev *vfdev;
159+
struct workqueue_struct *pf2vf_wq;
113160
struct msix_entry msix;
114161
};
115162

@@ -226,17 +273,9 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
226273
return atomic_read(&ndev->state) == __NDEV_READY;
227274
}
228275

229-
#ifdef CONFIG_DEBUG_FS
230-
int nitrox_debugfs_init(struct nitrox_device *ndev);
231-
void nitrox_debugfs_exit(struct nitrox_device *ndev);
232-
#else
233-
static inline int nitrox_debugfs_init(struct nitrox_device *ndev)
276+
static inline bool nitrox_vfdev_ready(struct nitrox_vfdev *vfdev)
234277
{
235-
return 0;
278+
return atomic_read(&vfdev->state) == __NDEV_READY;
236279
}
237280

238-
static inline void nitrox_debugfs_exit(struct nitrox_device *ndev)
239-
{ }
240-
#endif
241-
242281
#endif /* __NITROX_DEV_H */

0 commit comments

Comments
 (0)