summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/meta/fbnic/fbnic.h
diff options
context:
space:
mode:
authorAlexander Duyck <alexanderduyck@fb.com>2024-07-12 08:49:31 -0700
committerJakub Kicinski <kuba@kernel.org>2024-07-15 12:50:43 -0700
commitda3cde08209ec1c915195c2331c275397f34a731 (patch)
tree377529e3aa1b1e5f9c5df5b9b8cf2954d2197e17 /drivers/net/ethernet/meta/fbnic/fbnic.h
parentc6203e678cc9a5bf01ec7ae382851f504870777f (diff)
eth: fbnic: Add FW communication mechanism
Add a mechanism for sending messages to and receiving messages from the FW. The FW has fairly limited functionality, so the mechanism doesn't have to support high message rate. Use device mailbox registers to form two rings, one "to" and one "from" the device. The rings are just a convention between driver and FW, not a HW construct. We don't expect messages larger than 4k so use page-sized buffers. Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Link: https://patch.msgid.link/172079937113.1778861.10669864213768701947.stgit@ahduyck-xeon-server.home.arpa Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/meta/fbnic/fbnic.h')
-rw-r--r--drivers/net/ethernet/meta/fbnic/fbnic.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic.h b/drivers/net/ethernet/meta/fbnic/fbnic.h
index af863dfabd82..42e2744cfe10 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic.h
@@ -7,6 +7,7 @@
#include <linux/io.h>
#include "fbnic_csr.h"
+#include "fbnic_fw.h"
#include "fbnic_mac.h"
struct fbnic_dev {
@@ -15,8 +16,13 @@ struct fbnic_dev {
u32 __iomem *uc_addr0;
u32 __iomem *uc_addr4;
const struct fbnic_mac *mac;
+ unsigned int fw_msix_vector;
unsigned short num_irqs;
+ struct fbnic_fw_mbx mbx[FBNIC_IPC_MBX_INDICES];
+ /* Lock protecting Tx Mailbox queue to prevent possible races */
+ spinlock_t fw_tx_lock;
+
u64 dsn;
u32 mps;
u32 readrq;
@@ -28,6 +34,7 @@ struct fbnic_dev {
* causes later.
*/
enum {
+ FBNIC_FW_MSIX_ENTRY,
FBNIC_NON_NAPI_VECTORS
};
@@ -66,6 +73,14 @@ fbnic_rmw32(struct fbnic_dev *fbd, u32 reg, u32 mask, u32 val)
#define rd32(_f, _r) fbnic_rd32(_f, _r)
#define wrfl(_f) fbnic_wrfl(_f)
+bool fbnic_fw_present(struct fbnic_dev *fbd);
+u32 fbnic_fw_rd32(struct fbnic_dev *fbd, u32 reg);
+void fbnic_fw_wr32(struct fbnic_dev *fbd, u32 reg, u32 val);
+
+#define fw_rd32(_f, _r) fbnic_fw_rd32(_f, _r)
+#define fw_wr32(_f, _r, _v) fbnic_fw_wr32(_f, _r, _v)
+#define fw_wrfl(_f) fbnic_fw_rd32(_f, FBNIC_FW_ZERO_REG)
+
extern char fbnic_driver_name[];
void fbnic_devlink_free(struct fbnic_dev *fbd);
@@ -73,6 +88,9 @@ struct fbnic_dev *fbnic_devlink_alloc(struct pci_dev *pdev);
void fbnic_devlink_register(struct fbnic_dev *fbd);
void fbnic_devlink_unregister(struct fbnic_dev *fbd);
+int fbnic_fw_enable_mbx(struct fbnic_dev *fbd);
+void fbnic_fw_disable_mbx(struct fbnic_dev *fbd);
+
void fbnic_free_irqs(struct fbnic_dev *fbd);
int fbnic_alloc_irqs(struct fbnic_dev *fbd);