-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'eth-fbnic-add-network-driver-for-meta-platforms-host-ne…
…twork-interface' Alexander Duyck says: ==================== eth: fbnic: Add network driver for Meta Platforms Host Network Interface This patch set includes the necessary patches to enable basic Tx and Rx over the Meta Platforms Host Network Interface. To do this we introduce a new driver and driver directories in the form of "drivers/net/ethernet/meta/fbnic". The NIC itself is fairly simplistic. As far as speeds we support 25Gb, 50Gb, and 100Gb and we are mostly focused on speeds and feeds. As far as future patch sets we will be supporting the basic Rx/Tx offloads such as header/payload data split, TSO, checksum, and timestamp offloads. We have access to the MAC and PCS from the NIC, however the PHY and QSFP are hidden behind a FW layer as it is shared between 4 slices and the BMC. Due to submission limits the general plan to submit a minimal driver for now almost equivalent to a UEFI driver in functionality, and then follow up over the coming months enabling additional offloads and enabling more features for the device. ==================== Link: https://patch.msgid.link/172079913640.1778861.11459276843992867323.stgit@ahduyck-xeon-server.home.arpa Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Showing
26 changed files
with
7,877 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
# Meta Platforms network device configuration | ||
# | ||
|
||
config NET_VENDOR_META | ||
bool "Meta Platforms devices" | ||
default y | ||
help | ||
If you have a network (Ethernet) card designed by Meta, say Y. | ||
That's Meta as in the parent company of Facebook. | ||
|
||
Note that the answer to this question doesn't directly affect the | ||
kernel: saying N will just cause the configurator to skip all | ||
the questions about Meta cards. If you say Y, you will be asked for | ||
your specific card in the following questions. | ||
|
||
if NET_VENDOR_META | ||
|
||
config FBNIC | ||
tristate "Meta Platforms Host Network Interface" | ||
depends on X86_64 || COMPILE_TEST | ||
depends on PCI_MSI | ||
select PHYLINK | ||
help | ||
This driver supports Meta Platforms Host Network Interface. | ||
|
||
To compile this driver as a module, choose M here. The module | ||
will be called fbnic. MSI-X interrupt support is required. | ||
|
||
endif # NET_VENDOR_META |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# | ||
# Makefile for the Meta Platforms network device drivers. | ||
# | ||
|
||
obj-$(CONFIG_FBNIC) += fbnic/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
# | ||
# Makefile for the Meta(R) Host Network Interface | ||
# | ||
|
||
obj-$(CONFIG_FBNIC) += fbnic.o | ||
|
||
fbnic-y := fbnic_devlink.o \ | ||
fbnic_fw.o \ | ||
fbnic_irq.o \ | ||
fbnic_mac.o \ | ||
fbnic_netdev.o \ | ||
fbnic_pci.o \ | ||
fbnic_phylink.o \ | ||
fbnic_rpc.o \ | ||
fbnic_tlv.o \ | ||
fbnic_txrx.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) Meta Platforms, Inc. and affiliates. */ | ||
|
||
#ifndef _FBNIC_H_ | ||
#define _FBNIC_H_ | ||
|
||
#include <linux/interrupt.h> | ||
#include <linux/io.h> | ||
#include <linux/types.h> | ||
#include <linux/workqueue.h> | ||
|
||
#include "fbnic_csr.h" | ||
#include "fbnic_fw.h" | ||
#include "fbnic_mac.h" | ||
#include "fbnic_rpc.h" | ||
|
||
struct fbnic_dev { | ||
struct device *dev; | ||
struct net_device *netdev; | ||
|
||
u32 __iomem *uc_addr0; | ||
u32 __iomem *uc_addr4; | ||
const struct fbnic_mac *mac; | ||
unsigned int fw_msix_vector; | ||
unsigned int pcs_msix_vector; | ||
unsigned short num_irqs; | ||
|
||
struct delayed_work service_task; | ||
|
||
struct fbnic_fw_mbx mbx[FBNIC_IPC_MBX_INDICES]; | ||
struct fbnic_fw_cap fw_cap; | ||
/* Lock protecting Tx Mailbox queue to prevent possible races */ | ||
spinlock_t fw_tx_lock; | ||
|
||
unsigned long last_heartbeat_request; | ||
unsigned long last_heartbeat_response; | ||
u8 fw_heartbeat_enabled; | ||
|
||
u64 dsn; | ||
u32 mps; | ||
u32 readrq; | ||
|
||
/* Local copy of the devices TCAM */ | ||
struct fbnic_act_tcam act_tcam[FBNIC_RPC_TCAM_ACT_NUM_ENTRIES]; | ||
struct fbnic_mac_addr mac_addr[FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES]; | ||
u8 mac_addr_boundary; | ||
|
||
/* Number of TCQs/RCQs available on hardware */ | ||
u16 max_num_queues; | ||
}; | ||
|
||
/* Reserve entry 0 in the MSI-X "others" array until we have filled all | ||
* 32 of the possible interrupt slots. By doing this we can avoid any | ||
* potential conflicts should we need to enable one of the debug interrupt | ||
* causes later. | ||
*/ | ||
enum { | ||
FBNIC_FW_MSIX_ENTRY, | ||
FBNIC_PCS_MSIX_ENTRY, | ||
FBNIC_NON_NAPI_VECTORS | ||
}; | ||
|
||
static inline bool fbnic_present(struct fbnic_dev *fbd) | ||
{ | ||
return !!READ_ONCE(fbd->uc_addr0); | ||
} | ||
|
||
static inline void fbnic_wr32(struct fbnic_dev *fbd, u32 reg, u32 val) | ||
{ | ||
u32 __iomem *csr = READ_ONCE(fbd->uc_addr0); | ||
|
||
if (csr) | ||
writel(val, csr + reg); | ||
} | ||
|
||
u32 fbnic_rd32(struct fbnic_dev *fbd, u32 reg); | ||
|
||
static inline void fbnic_wrfl(struct fbnic_dev *fbd) | ||
{ | ||
fbnic_rd32(fbd, FBNIC_MASTER_SPARE_0); | ||
} | ||
|
||
static inline void | ||
fbnic_rmw32(struct fbnic_dev *fbd, u32 reg, u32 mask, u32 val) | ||
{ | ||
u32 v; | ||
|
||
v = fbnic_rd32(fbd, reg); | ||
v &= ~mask; | ||
v |= val; | ||
fbnic_wr32(fbd, reg, v); | ||
} | ||
|
||
#define wr32(_f, _r, _v) fbnic_wr32(_f, _r, _v) | ||
#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) | ||
|
||
static inline bool fbnic_bmc_present(struct fbnic_dev *fbd) | ||
{ | ||
return fbd->fw_cap.bmc_present; | ||
} | ||
|
||
static inline bool fbnic_init_failure(struct fbnic_dev *fbd) | ||
{ | ||
return !fbd->netdev; | ||
} | ||
|
||
extern char fbnic_driver_name[]; | ||
|
||
void fbnic_devlink_free(struct fbnic_dev *fbd); | ||
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); | ||
|
||
int fbnic_pcs_irq_enable(struct fbnic_dev *fbd); | ||
void fbnic_pcs_irq_disable(struct fbnic_dev *fbd); | ||
|
||
int fbnic_request_irq(struct fbnic_dev *dev, int nr, irq_handler_t handler, | ||
unsigned long flags, const char *name, void *data); | ||
void fbnic_free_irq(struct fbnic_dev *dev, int nr, void *data); | ||
void fbnic_free_irqs(struct fbnic_dev *fbd); | ||
int fbnic_alloc_irqs(struct fbnic_dev *fbd); | ||
|
||
enum fbnic_boards { | ||
fbnic_board_asic | ||
}; | ||
|
||
struct fbnic_info { | ||
unsigned int max_num_queues; | ||
unsigned int bar_mask; | ||
}; | ||
|
||
#endif /* _FBNIC_H_ */ |
Oops, something went wrong.