Skip to content

Commit 3b12f00

Browse files
ahduyckPaolo Abeni
authored andcommitted
fbnic: Gate AXI read/write enabling on FW mailbox
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>
1 parent f34343c commit 3b12f00

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
@@ -796,8 +796,10 @@ enum {
796796
/* PUL User Registers */
797797
#define FBNIC_CSR_START_PUL_USER 0x31000 /* CSR section delimiter */
798798
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG 0x3103d /* 0xc40f4 */
799+
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH CSR_BIT(19)
799800
#define FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME CSR_BIT(18)
800801
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG 0x3103e /* 0xc40f8 */
802+
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG_FLUSH CSR_BIT(19)
801803
#define FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME CSR_BIT(18)
802804
#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
803805
0x3106e /* 0xc41b8 */

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);
@@ -354,7 +370,7 @@ static int fbnic_fw_xmit_cap_msg(struct fbnic_dev *fbd)
354370
return (err == -EOPNOTSUPP) ? 0 : err;
355371
}
356372

357-
static void fbnic_mbx_postinit_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
373+
static void fbnic_mbx_init_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
358374
{
359375
struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx];
360376

@@ -366,10 +382,18 @@ static void fbnic_mbx_postinit_desc_ring(struct fbnic_dev *fbd, int mbx_idx)
366382

367383
switch (mbx_idx) {
368384
case FBNIC_IPC_MBX_RX_IDX:
385+
/* Enable DMA writes from the device */
386+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG,
387+
FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME);
388+
369389
/* Make sure we have a page for the FW to write to */
370390
fbnic_mbx_alloc_rx_msgs(fbd);
371391
break;
372392
case FBNIC_IPC_MBX_TX_IDX:
393+
/* Enable DMA reads from the device */
394+
wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG,
395+
FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME);
396+
373397
/* Force version to 1 if we successfully requested an update
374398
* from the firmware. This should be overwritten once we get
375399
* the actual version from the firmware in the capabilities
@@ -386,7 +410,7 @@ static void fbnic_mbx_postinit(struct fbnic_dev *fbd)
386410
{
387411
int i;
388412

389-
/* We only need to do this on the first interrupt following init.
413+
/* We only need to do this on the first interrupt following reset.
390414
* this primes the mailbox so that we will have cleared all the
391415
* skip descriptors.
392416
*/
@@ -396,7 +420,7 @@ static void fbnic_mbx_postinit(struct fbnic_dev *fbd)
396420
wr32(fbd, FBNIC_INTR_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY);
397421

398422
for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++)
399-
fbnic_mbx_postinit_desc_ring(fbd, i);
423+
fbnic_mbx_init_desc_ring(fbd, i);
400424
}
401425

402426
/**
@@ -894,7 +918,7 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
894918
* avoid the mailbox getting stuck closed if the interrupt
895919
* is reset.
896920
*/
897-
fbnic_mbx_init_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX);
921+
fbnic_mbx_reset_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX);
898922

899923
msleep(200);
900924

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)