Skip to content

Commit 4238cbf

Browse files
committed
Merge branch 'add-more-functionality-to-bnge'
Bhargava Marreddy says: ==================== Add more functionality to BNGE This patch series adds the infrastructure to make the netdevice functional. It allocates data structures for core resources, followed by their initialisation and registration with the firmware. The core resources include the RX, TX, AGG, CMPL, and NQ rings, as well as the VNIC. RX/TX functionality will be introduced in the next patch series to keep this one at a reviewable size. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents c5aaf02 + 9afad4a commit 4238cbf

File tree

12 files changed

+3140
-7
lines changed

12 files changed

+3140
-7
lines changed

drivers/net/ethernet/broadcom/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ config BNGE
257257
tristate "Broadcom Ethernet device support"
258258
depends on PCI
259259
select NET_DEVLINK
260+
select PAGE_POOL
260261
help
261262
This driver supports Broadcom 50/100/200/400/800 gigabit Ethernet cards.
262263
The module will be called bng_en. To compile this driver as a module,

drivers/net/ethernet/broadcom/bnge/bnge.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ struct bnge_dev {
102102
u16 chip_num;
103103
u8 chip_rev;
104104

105+
#if BITS_PER_LONG == 32
106+
/* ensure atomic 64-bit doorbell writes on 32-bit systems. */
107+
spinlock_t db_lock;
108+
#endif
105109
int db_offset; /* db_offset within db_size */
106110
int db_size;
107111

@@ -129,6 +133,7 @@ struct bnge_dev {
129133

130134
unsigned long state;
131135
#define BNGE_STATE_DRV_REGISTERED 0
136+
#define BNGE_STATE_OPEN 1
132137

133138
u64 fw_cap;
134139

@@ -155,6 +160,7 @@ struct bnge_dev {
155160
u16 rss_indir_tbl_entries;
156161

157162
u32 rss_cap;
163+
u32 rss_hash_cfg;
158164

159165
u16 rx_nr_rings;
160166
u16 tx_nr_rings;
@@ -213,6 +219,27 @@ static inline bool bnge_is_agg_reqd(struct bnge_dev *bd)
213219
return true;
214220
}
215221

222+
static inline void bnge_writeq(struct bnge_dev *bd, u64 val,
223+
void __iomem *addr)
224+
{
225+
#if BITS_PER_LONG == 32
226+
spin_lock(&bd->db_lock);
227+
lo_hi_writeq(val, addr);
228+
spin_unlock(&bd->db_lock);
229+
#else
230+
writeq(val, addr);
231+
#endif
232+
}
233+
234+
/* For TX and RX ring doorbells */
235+
static inline void bnge_db_write(struct bnge_dev *bd, struct bnge_db_info *db,
236+
u32 idx)
237+
{
238+
bnge_writeq(bd, db->db_key64 | DB_RING_IDX(db, idx),
239+
db->doorbell);
240+
}
241+
216242
bool bnge_aux_registered(struct bnge_dev *bd);
243+
u16 bnge_aux_get_msix(struct bnge_dev *bd);
217244

218245
#endif /* _BNGE_H_ */

drivers/net/ethernet/broadcom/bnge/bnge_core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ static void bnge_fw_unregister_dev(struct bnge_dev *bd)
9696
bnge_free_ctx_mem(bd);
9797
}
9898

99+
static void bnge_set_dflt_rss_hash_type(struct bnge_dev *bd)
100+
{
101+
bd->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 |
102+
VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4 |
103+
VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6 |
104+
VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6 |
105+
VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 |
106+
VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6;
107+
}
108+
99109
static int bnge_fw_register_dev(struct bnge_dev *bd)
100110
{
101111
int rc;
@@ -137,6 +147,8 @@ static int bnge_fw_register_dev(struct bnge_dev *bd)
137147
goto err_func_unrgtr;
138148
}
139149

150+
bnge_set_dflt_rss_hash_type(bd);
151+
140152
return 0;
141153

142154
err_func_unrgtr:
@@ -296,6 +308,10 @@ static int bnge_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
296308
goto err_config_uninit;
297309
}
298310

311+
#if BITS_PER_LONG == 32
312+
spin_lock_init(&bd->db_lock);
313+
#endif
314+
299315
rc = bnge_alloc_irqs(bd);
300316
if (rc) {
301317
dev_err(&pdev->dev, "Error IRQ allocation rc = %d\n", rc);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2025 Broadcom */
3+
4+
#ifndef _BNGE_DB_H_
5+
#define _BNGE_DB_H_
6+
7+
/* 64-bit doorbell */
8+
#define DBR_EPOCH_SFT 24
9+
#define DBR_TOGGLE_SFT 25
10+
#define DBR_XID_SFT 32
11+
#define DBR_PATH_L2 (0x1ULL << 56)
12+
#define DBR_VALID (0x1ULL << 58)
13+
#define DBR_TYPE_SQ (0x0ULL << 60)
14+
#define DBR_TYPE_SRQ (0x2ULL << 60)
15+
#define DBR_TYPE_CQ (0x4ULL << 60)
16+
#define DBR_TYPE_CQ_ARMALL (0x6ULL << 60)
17+
#define DBR_TYPE_NQ (0xaULL << 60)
18+
#define DBR_TYPE_NQ_ARM (0xbULL << 60)
19+
#define DBR_TYPE_NQ_MASK (0xeULL << 60)
20+
21+
struct bnge_db_info {
22+
void __iomem *doorbell;
23+
u64 db_key64;
24+
u32 db_ring_mask;
25+
u32 db_epoch_mask;
26+
u8 db_epoch_shift;
27+
};
28+
29+
#define DB_EPOCH(db, idx) (((idx) & (db)->db_epoch_mask) << \
30+
((db)->db_epoch_shift))
31+
#define DB_RING_IDX(db, idx) (((idx) & (db)->db_ring_mask) | \
32+
DB_EPOCH(db, idx))
33+
34+
#endif /* _BNGE_DB_H_ */

0 commit comments

Comments
 (0)