Skip to content

Commit af58de3

Browse files
committed
Merge branch 'eth-fbnic-add-network-driver-for-meta-platforms-host-network-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 <[email protected]>
2 parents dd3cd3c + 355440a commit af58de3

26 files changed

+7877
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14579,6 +14579,13 @@ T: git git://linuxtv.org/media_tree.git
1457914579
F: Documentation/devicetree/bindings/media/amlogic,gx-vdec.yaml
1458014580
F: drivers/staging/media/meson/vdec/
1458114581

14582+
META ETHERNET DRIVERS
14583+
M: Alexander Duyck <[email protected]>
14584+
M: Jakub Kicinski <[email protected]>
14585+
14586+
S: Supported
14587+
F: drivers/net/ethernet/meta/
14588+
1458214589
METHODE UDPU SUPPORT
1458314590
M: Robert Marko <[email protected]>
1458414591
S: Maintained

drivers/net/ethernet/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ source "drivers/net/ethernet/litex/Kconfig"
122122
source "drivers/net/ethernet/marvell/Kconfig"
123123
source "drivers/net/ethernet/mediatek/Kconfig"
124124
source "drivers/net/ethernet/mellanox/Kconfig"
125+
source "drivers/net/ethernet/meta/Kconfig"
125126
source "drivers/net/ethernet/micrel/Kconfig"
126127
source "drivers/net/ethernet/microchip/Kconfig"
127128
source "drivers/net/ethernet/mscc/Kconfig"

drivers/net/ethernet/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ obj-$(CONFIG_NET_VENDOR_LITEX) += litex/
5959
obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/
6060
obj-$(CONFIG_NET_VENDOR_MEDIATEK) += mediatek/
6161
obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/
62+
obj-$(CONFIG_NET_VENDOR_META) += meta/
6263
obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/
6364
obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/
6465
obj-$(CONFIG_NET_VENDOR_MICROSEMI) += mscc/

drivers/net/ethernet/meta/Kconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Meta Platforms network device configuration
4+
#
5+
6+
config NET_VENDOR_META
7+
bool "Meta Platforms devices"
8+
default y
9+
help
10+
If you have a network (Ethernet) card designed by Meta, say Y.
11+
That's Meta as in the parent company of Facebook.
12+
13+
Note that the answer to this question doesn't directly affect the
14+
kernel: saying N will just cause the configurator to skip all
15+
the questions about Meta cards. If you say Y, you will be asked for
16+
your specific card in the following questions.
17+
18+
if NET_VENDOR_META
19+
20+
config FBNIC
21+
tristate "Meta Platforms Host Network Interface"
22+
depends on X86_64 || COMPILE_TEST
23+
depends on PCI_MSI
24+
select PHYLINK
25+
help
26+
This driver supports Meta Platforms Host Network Interface.
27+
28+
To compile this driver as a module, choose M here. The module
29+
will be called fbnic. MSI-X interrupt support is required.
30+
31+
endif # NET_VENDOR_META

drivers/net/ethernet/meta/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Makefile for the Meta Platforms network device drivers.
4+
#
5+
6+
obj-$(CONFIG_FBNIC) += fbnic/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
4+
#
5+
# Makefile for the Meta(R) Host Network Interface
6+
#
7+
8+
obj-$(CONFIG_FBNIC) += fbnic.o
9+
10+
fbnic-y := fbnic_devlink.o \
11+
fbnic_fw.o \
12+
fbnic_irq.o \
13+
fbnic_mac.o \
14+
fbnic_netdev.o \
15+
fbnic_pci.o \
16+
fbnic_phylink.o \
17+
fbnic_rpc.o \
18+
fbnic_tlv.o \
19+
fbnic_txrx.o
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
3+
4+
#ifndef _FBNIC_H_
5+
#define _FBNIC_H_
6+
7+
#include <linux/interrupt.h>
8+
#include <linux/io.h>
9+
#include <linux/types.h>
10+
#include <linux/workqueue.h>
11+
12+
#include "fbnic_csr.h"
13+
#include "fbnic_fw.h"
14+
#include "fbnic_mac.h"
15+
#include "fbnic_rpc.h"
16+
17+
struct fbnic_dev {
18+
struct device *dev;
19+
struct net_device *netdev;
20+
21+
u32 __iomem *uc_addr0;
22+
u32 __iomem *uc_addr4;
23+
const struct fbnic_mac *mac;
24+
unsigned int fw_msix_vector;
25+
unsigned int pcs_msix_vector;
26+
unsigned short num_irqs;
27+
28+
struct delayed_work service_task;
29+
30+
struct fbnic_fw_mbx mbx[FBNIC_IPC_MBX_INDICES];
31+
struct fbnic_fw_cap fw_cap;
32+
/* Lock protecting Tx Mailbox queue to prevent possible races */
33+
spinlock_t fw_tx_lock;
34+
35+
unsigned long last_heartbeat_request;
36+
unsigned long last_heartbeat_response;
37+
u8 fw_heartbeat_enabled;
38+
39+
u64 dsn;
40+
u32 mps;
41+
u32 readrq;
42+
43+
/* Local copy of the devices TCAM */
44+
struct fbnic_act_tcam act_tcam[FBNIC_RPC_TCAM_ACT_NUM_ENTRIES];
45+
struct fbnic_mac_addr mac_addr[FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES];
46+
u8 mac_addr_boundary;
47+
48+
/* Number of TCQs/RCQs available on hardware */
49+
u16 max_num_queues;
50+
};
51+
52+
/* Reserve entry 0 in the MSI-X "others" array until we have filled all
53+
* 32 of the possible interrupt slots. By doing this we can avoid any
54+
* potential conflicts should we need to enable one of the debug interrupt
55+
* causes later.
56+
*/
57+
enum {
58+
FBNIC_FW_MSIX_ENTRY,
59+
FBNIC_PCS_MSIX_ENTRY,
60+
FBNIC_NON_NAPI_VECTORS
61+
};
62+
63+
static inline bool fbnic_present(struct fbnic_dev *fbd)
64+
{
65+
return !!READ_ONCE(fbd->uc_addr0);
66+
}
67+
68+
static inline void fbnic_wr32(struct fbnic_dev *fbd, u32 reg, u32 val)
69+
{
70+
u32 __iomem *csr = READ_ONCE(fbd->uc_addr0);
71+
72+
if (csr)
73+
writel(val, csr + reg);
74+
}
75+
76+
u32 fbnic_rd32(struct fbnic_dev *fbd, u32 reg);
77+
78+
static inline void fbnic_wrfl(struct fbnic_dev *fbd)
79+
{
80+
fbnic_rd32(fbd, FBNIC_MASTER_SPARE_0);
81+
}
82+
83+
static inline void
84+
fbnic_rmw32(struct fbnic_dev *fbd, u32 reg, u32 mask, u32 val)
85+
{
86+
u32 v;
87+
88+
v = fbnic_rd32(fbd, reg);
89+
v &= ~mask;
90+
v |= val;
91+
fbnic_wr32(fbd, reg, v);
92+
}
93+
94+
#define wr32(_f, _r, _v) fbnic_wr32(_f, _r, _v)
95+
#define rd32(_f, _r) fbnic_rd32(_f, _r)
96+
#define wrfl(_f) fbnic_wrfl(_f)
97+
98+
bool fbnic_fw_present(struct fbnic_dev *fbd);
99+
u32 fbnic_fw_rd32(struct fbnic_dev *fbd, u32 reg);
100+
void fbnic_fw_wr32(struct fbnic_dev *fbd, u32 reg, u32 val);
101+
102+
#define fw_rd32(_f, _r) fbnic_fw_rd32(_f, _r)
103+
#define fw_wr32(_f, _r, _v) fbnic_fw_wr32(_f, _r, _v)
104+
#define fw_wrfl(_f) fbnic_fw_rd32(_f, FBNIC_FW_ZERO_REG)
105+
106+
static inline bool fbnic_bmc_present(struct fbnic_dev *fbd)
107+
{
108+
return fbd->fw_cap.bmc_present;
109+
}
110+
111+
static inline bool fbnic_init_failure(struct fbnic_dev *fbd)
112+
{
113+
return !fbd->netdev;
114+
}
115+
116+
extern char fbnic_driver_name[];
117+
118+
void fbnic_devlink_free(struct fbnic_dev *fbd);
119+
struct fbnic_dev *fbnic_devlink_alloc(struct pci_dev *pdev);
120+
void fbnic_devlink_register(struct fbnic_dev *fbd);
121+
void fbnic_devlink_unregister(struct fbnic_dev *fbd);
122+
123+
int fbnic_fw_enable_mbx(struct fbnic_dev *fbd);
124+
void fbnic_fw_disable_mbx(struct fbnic_dev *fbd);
125+
126+
int fbnic_pcs_irq_enable(struct fbnic_dev *fbd);
127+
void fbnic_pcs_irq_disable(struct fbnic_dev *fbd);
128+
129+
int fbnic_request_irq(struct fbnic_dev *dev, int nr, irq_handler_t handler,
130+
unsigned long flags, const char *name, void *data);
131+
void fbnic_free_irq(struct fbnic_dev *dev, int nr, void *data);
132+
void fbnic_free_irqs(struct fbnic_dev *fbd);
133+
int fbnic_alloc_irqs(struct fbnic_dev *fbd);
134+
135+
enum fbnic_boards {
136+
fbnic_board_asic
137+
};
138+
139+
struct fbnic_info {
140+
unsigned int max_num_queues;
141+
unsigned int bar_mask;
142+
};
143+
144+
#endif /* _FBNIC_H_ */

0 commit comments

Comments
 (0)