Skip to content

Commit 5ac3e65

Browse files
ahduyckSasha Levin
authored andcommitted
fbnic: Gate AXI read/write enabling on FW mailbox
[ Upstream commit 3b12f00 ] In order to prevent the device from throwing spurious writes and/or reads at us we need to gate the AXI fabric interface to the PCIe until such time as we know the FW is in a known good state. To accomplish this we use the mailbox as a mechanism for us to recognize that the FW has acknowledged our presence and is no longer sending any stale message data to us. We start in fbnic_mbx_init by calling fbnic_mbx_reset_desc_ring function, disabling the DMA in both directions, and then invalidating all the descriptors in each ring. We then poll the mailbox in fbnic_mbx_poll_tx_ready and when the interrupt is set by the FW we pick it up and mark the mailboxes as ready, while also enabling the DMA. Once we have completed all the transactions and need to shut down we call into fbnic_mbx_clean which will in turn call fbnic_mbx_reset_desc_ring for each ring and shut down the DMA and once again invalidate the descriptors. Fixes: 3646153 ("eth: fbnic: Add register init to set PCIe/Ethernet device config") Fixes: da3cde0 ("eth: fbnic: Add FW communication mechanism") Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/174654718623.499179.7445197308109347982.stgit@ahduyck-xeon-server.home.arpa Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f6bd3a3 commit 5ac3e65

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_csr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,10 @@ enum {
700700
/* PUL User Registers */
701701
#define FBNIC_CSR_START_PUL_USER 0x31000 /* CSR section delimiter */
702702
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG 0x3103d /* 0xc40f4 */
703+
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH CSR_BIT(19)
703704
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME CSR_BIT(18)
704705
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG 0x3103e /* 0xc40f8 */
706+
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG_FLUSH CSR_BIT(19)
705707
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME CSR_BIT(18)
706708
#define FBNIC_CSR_END_PUL_USER 0x31080 /* CSR section delimiter */
707709

drivers/net/ethernet/meta/fbnic/fbnic_fw.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,26 @@ static u64 __fbnic_mbx_rd_desc(struct fbnic_dev *fbd, int mbx_idx, int desc_idx)
5151
return desc;
5252
}
5353

54-
static void fbnic_mbx_init_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
54+
static void fbnic_mbx_reset_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
5555
{
5656
int desc_idx;
5757

58+
/* Disable DMA transactions from the device,
59+
* and flush any transactions triggered during cleaning
60+
*/
61+
switch (mbx_idx) {
62+
case FBNIC_IPC_MBX_RX_IDX:
63+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG,
64+
FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH);
65+
break;
66+
case FBNIC_IPC_MBX_TX_IDX:
67+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG,
68+
FBNIC_PUL_OB_TLP_HDR_AR_CFG_FLUSH);
69+
break;
70+
}
71+
72+
wrfl(fbd);
73+
5874
/* Initialize first descriptor to all 0s. Doing this gives us a
5975
* solid stop for the firmware to hit when it is done looping
6076
* through the ring.
@@ -90,7 +106,7 @@ void fbnic_mbx_init(struct fbnic_dev *fbd)
90106
wr32(fbd, FBNIC_INTR_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY);
91107

92108
for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++)
93-
fbnic_mbx_init_desc_ring(fbd, i);
109+
fbnic_mbx_reset_desc_ring(fbd, i);
94110
}
95111

96112
static int fbnic_mbx_map_msg(struct fbnic_dev *fbd, int mbx_idx,
@@ -155,7 +171,7 @@ static void fbnic_mbx_clean_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
155171
{
156172
int i;
157173

158-
fbnic_mbx_init_desc_ring(fbd, mbx_idx);
174+
fbnic_mbx_reset_desc_ring(fbd, mbx_idx);
159175

160176
for (i = FBNIC_IPC_MBX_DESC_LEN; i--;)
161177
fbnic_mbx_unmap_and_free_msg(fbd, mbx_idx, i);
@@ -297,7 +313,7 @@ static int fbnic_fw_xmit_cap_msg(struct fbnic_dev *fbd)
297313
return (err == -EOPNOTSUPP) ? 0 : err;
298314
}
299315

300-
static void fbnic_mbx_postinit_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
316+
static void fbnic_mbx_init_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
301317
{
302318
struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx];
303319

@@ -309,10 +325,18 @@ static void fbnic_mbx_postinit_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
309325

310326
switch (mbx_idx) {
311327
case FBNIC_IPC_MBX_RX_IDX:
328+
/* Enable DMA writes from the device */
329+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG,
330+
FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME);
331+
312332
/* Make sure we have a page for the FW to write to */
313333
fbnic_mbx_alloc_rx_msgs(fbd);
314334
break;
315335
case FBNIC_IPC_MBX_TX_IDX:
336+
/* Enable DMA reads from the device */
337+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG,
338+
FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME);
339+
316340
/* Force version to 1 if we successfully requested an update
317341
* from the firmware. This should be overwritten once we get
318342
* the actual version from the firmware in the capabilities
@@ -329,7 +353,7 @@ static void fbnic_mbx_postinit(struct fbnic_dev *fbd)
329353
{
330354
int i;
331355

332-
/* We only need to do this on the first interrupt following init.
356+
/* We only need to do this on the first interrupt following reset.
333357
* this primes the mailbox so that we will have cleared all the
334358
* skip descriptors.
335359
*/
@@ -339,7 +363,7 @@ static void fbnic_mbx_postinit(struct fbnic_dev *fbd)
339363
wr32(fbd, FBNIC_INTR_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY);
340364

341365
for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++)
342-
fbnic_mbx_postinit_desc_ring(fbd, i);
366+
fbnic_mbx_init_desc_ring(fbd, i);
343367
}
344368

345369
/**
@@ -761,7 +785,7 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
761785
* avoid the mailbox getting stuck closed if the interrupt
762786
* is reset.
763787
*/
764-
fbnic_mbx_init_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX);
788+
fbnic_mbx_reset_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX);
765789

766790
msleep(200);
767791

drivers/net/ethernet/meta/fbnic/fbnic_mac.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ static void fbnic_mac_init_axi(struct fbnic_dev *fbd)
7979
fbnic_init_readrq(fbd, FBNIC_QM_RNI_RBP_CTL, cls, readrq);
8080
fbnic_init_mps(fbd, FBNIC_QM_RNI_RDE_CTL, cls, mps);
8181
fbnic_init_mps(fbd, FBNIC_QM_RNI_RCM_CTL, cls, mps);
82-
83-
/* Enable XALI AR/AW outbound */
84-
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG,
85-
FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME);
86-
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG,
87-
FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME);
8882
}
8983

9084
static void fbnic_mac_init_qm(struct fbnic_dev *fbd)

0 commit comments

Comments
 (0)