Skip to content

Commit d3c1647

Browse files
hgao656kuba-moo
authored andcommitted
bnxt_en: Consolidate DB offset calculation
The doorbell offset on P5 chips is hard coded. On the new P7 chips, it is returned by the firmware. Simplify the logic that determines this offset and store it in a new db_offset field in struct bnxt. Also, provide this offset to the RoCE driver in struct bnxt_en_dev. Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Signed-off-by: Hongguang Gao <hongguang.gao@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://lore.kernel.org/r/20231201223924.26955-5-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a432a45 commit d3c1647

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6031,10 +6031,6 @@ static void bnxt_set_db(struct bnxt *bp, struct bnxt_db_info *db, u32 ring_type,
60316031
u32 map_idx, u32 xid)
60326032
{
60336033
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
6034-
if (BNXT_PF(bp))
6035-
db->doorbell = bp->bar1 + DB_PF_OFFSET_P5;
6036-
else
6037-
db->doorbell = bp->bar1 + DB_VF_OFFSET_P5;
60386034
switch (ring_type) {
60396035
case HWRM_RING_ALLOC_TX:
60406036
db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ;
@@ -6054,6 +6050,8 @@ static void bnxt_set_db(struct bnxt *bp, struct bnxt_db_info *db, u32 ring_type,
60546050

60556051
if (bp->flags & BNXT_FLAG_CHIP_P7)
60566052
db->db_key64 |= DBR_VALID;
6053+
6054+
db->doorbell = bp->bar1 + bp->db_offset;
60576055
} else {
60586056
db->doorbell = bp->bar1 + map_idx * 0x80;
60596057
switch (ring_type) {
@@ -7146,7 +7144,6 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
71467144
{
71477145
struct hwrm_func_qcfg_output *resp;
71487146
struct hwrm_func_qcfg_input *req;
7149-
u32 min_db_offset = 0;
71507147
u16 flags;
71517148
int rc;
71527149

@@ -7204,16 +7201,17 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
72047201
if (bp->db_size)
72057202
goto func_qcfg_exit;
72067203

7207-
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
7204+
bp->db_offset = le16_to_cpu(resp->legacy_l2_db_size_kb) * 1024;
7205+
if (BNXT_CHIP_P5(bp)) {
72087206
if (BNXT_PF(bp))
7209-
min_db_offset = DB_PF_OFFSET_P5;
7207+
bp->db_offset = DB_PF_OFFSET_P5;
72107208
else
7211-
min_db_offset = DB_VF_OFFSET_P5;
7209+
bp->db_offset = DB_VF_OFFSET_P5;
72127210
}
72137211
bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) *
72147212
1024);
72157213
if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) ||
7216-
bp->db_size <= min_db_offset)
7214+
bp->db_size <= bp->db_offset)
72177215
bp->db_size = pci_resource_len(bp->pdev, 2);
72187216

72197217
func_qcfg_exit:

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,6 +2216,7 @@ struct bnxt {
22162216
/* ensure atomic 64-bit doorbell writes on 32-bit systems. */
22172217
spinlock_t db_lock;
22182218
#endif
2219+
int db_offset; /* db_offset within db_size */
22192220
int db_size;
22202221

22212222
#define BNXT_NTP_FLTR_MAX_FLTR 4096

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent)
4242
for (i = 0; i < num_msix; i++) {
4343
ent[i].vector = bp->irq_tbl[idx + i].vector;
4444
ent[i].ring_idx = idx + i;
45-
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
46-
ent[i].db_offset = DB_PF_OFFSET_P5;
47-
if (BNXT_VF(bp))
48-
ent[i].db_offset = DB_VF_OFFSET_P5;
49-
} else {
45+
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
46+
ent[i].db_offset = bp->db_offset;
47+
else
5048
ent[i].db_offset = (idx + i) * 0x80;
51-
}
5249
}
5350
}
5451

@@ -333,6 +330,7 @@ static void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt *bp)
333330
edev->pdev = bp->pdev;
334331
edev->l2_db_size = bp->db_size;
335332
edev->l2_db_size_nc = bp->db_size;
333+
edev->l2_db_offset = bp->db_offset;
336334

337335
if (bp->flags & BNXT_FLAG_ROCEV1_CAP)
338336
edev->flags |= BNXT_EN_FLAG_ROCEV1_CAP;

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ struct bnxt_en_dev {
7373
* bytes mapped as non-
7474
* cacheable.
7575
*/
76+
int l2_db_offset; /* Doorbell offset in
77+
* bytes within
78+
* l2_db_size_nc.
79+
*/
7680
u16 chip_num;
7781
u16 hw_ring_stats_size;
7882
u16 pf_port_id;

0 commit comments

Comments
 (0)