Skip to content

Commit a588e45

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add interface to support RDMA driver.
Since the network driver and RDMA driver operate on the same PCI function, we need to create an interface to allow the RDMA driver to share resources with the network driver. 1. Create a new bnxt_en_dev struct which will be returned by bnxt_ulp_probe() upon success. After that, all calls from the RDMA driver to bnxt_en will pass a pointer to this struct. 2. This struct contains additional function pointers to register, request msix, send fw messages, register for async events. 3. If the RDMA driver wants to enable RDMA on the function, it needs to call the function pointer bnxt_register_device(). A ulp_ops structure is passed for RCU protected upcalls from bnxt_en to the RDMA driver. 4. The RDMA driver can call firmware APIs using the bnxt_send_fw_msg() function pointer. 5. 1 stats context is reserved when the RDMA driver registers. MSIX and completion rings are reserved when the RDMA driver calls bnxt_request_msix() function pointer. 6. When the RDMA driver calls bnxt_unregister_device(), all RDMA resources will be cleaned up. v2: Fixed 2 uninitialized variable warnings. Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a1653b1 commit a588e45

File tree

5 files changed

+483
-5
lines changed

5 files changed

+483
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
obj-$(CONFIG_BNXT) += bnxt_en.o
22

3-
bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o
3+
bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
#include "bnxt_hsi.h"
5454
#include "bnxt.h"
55+
#include "bnxt_ulp.h"
5556
#include "bnxt_sriov.h"
5657
#include "bnxt_ethtool.h"
5758
#include "bnxt_dcb.h"
@@ -1528,12 +1529,11 @@ static int bnxt_async_event_process(struct bnxt *bp,
15281529
set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event);
15291530
break;
15301531
default:
1531-
netdev_err(bp->dev, "unhandled ASYNC event (id 0x%x)\n",
1532-
event_id);
15331532
goto async_event_process_exit;
15341533
}
15351534
schedule_work(&bp->sp_task);
15361535
async_event_process_exit:
1536+
bnxt_ulp_async_events(bp, cmpl);
15371537
return 0;
15381538
}
15391539

@@ -3547,7 +3547,7 @@ static int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, u16 vnic_id, u16 ctx_idx)
35473547
return rc;
35483548
}
35493549

3550-
static int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)
3550+
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)
35513551
{
35523552
unsigned int ring = 0, grp_idx;
35533553
struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];
@@ -3595,6 +3595,9 @@ static int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)
35953595
#endif
35963596
if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan)
35973597
req.flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE);
3598+
if (!vnic_id && bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
3599+
req.flags |=
3600+
cpu_to_le32(VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE);
35983601

35993602
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
36003603
}
@@ -4842,6 +4845,16 @@ unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp)
48424845
return bp->pf.max_stat_ctxs;
48434846
}
48444847

4848+
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max)
4849+
{
4850+
#if defined(CONFIG_BNXT_SRIOV)
4851+
if (BNXT_VF(bp))
4852+
bp->vf.max_stat_ctxs = max;
4853+
else
4854+
#endif
4855+
bp->pf.max_stat_ctxs = max;
4856+
}
4857+
48454858
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
48464859
{
48474860
#if defined(CONFIG_BNXT_SRIOV)
@@ -4851,6 +4864,16 @@ unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
48514864
return bp->pf.max_cp_rings;
48524865
}
48534866

4867+
void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max)
4868+
{
4869+
#if defined(CONFIG_BNXT_SRIOV)
4870+
if (BNXT_VF(bp))
4871+
bp->vf.max_cp_rings = max;
4872+
else
4873+
#endif
4874+
bp->pf.max_cp_rings = max;
4875+
}
4876+
48544877
static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
48554878
{
48564879
#if defined(CONFIG_BNXT_SRIOV)
@@ -6767,6 +6790,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)
67676790
pci_iounmap(pdev, bp->bar2);
67686791
pci_iounmap(pdev, bp->bar1);
67696792
pci_iounmap(pdev, bp->bar0);
6793+
kfree(bp->edev);
6794+
bp->edev = NULL;
67706795
free_netdev(dev);
67716796

67726797
pci_release_regions(pdev);
@@ -6936,6 +6961,7 @@ void bnxt_restore_pf_fw_resources(struct bnxt *bp)
69366961
{
69376962
ASSERT_RTNL();
69386963
bnxt_hwrm_func_qcaps(bp);
6964+
bnxt_subtract_ulp_resources(bp, BNXT_ROCE_ULP);
69396965
}
69406966

69416967
static void bnxt_parse_log_pcie_link(struct bnxt *bp)
@@ -7047,6 +7073,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
70477073
if (rc)
70487074
goto init_err;
70497075

7076+
bp->ulp_probe = bnxt_ulp_probe;
7077+
70507078
/* Get the MAX capabilities for this function */
70517079
rc = bnxt_hwrm_func_qcaps(bp);
70527080
if (rc) {
@@ -7144,12 +7172,15 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
71447172
pci_channel_state_t state)
71457173
{
71467174
struct net_device *netdev = pci_get_drvdata(pdev);
7175+
struct bnxt *bp = netdev_priv(netdev);
71477176

71487177
netdev_info(netdev, "PCI I/O error detected\n");
71497178

71507179
rtnl_lock();
71517180
netif_device_detach(netdev);
71527181

7182+
bnxt_ulp_stop(bp);
7183+
71537184
if (state == pci_channel_io_perm_failure) {
71547185
rtnl_unlock();
71557186
return PCI_ERS_RESULT_DISCONNECT;
@@ -7195,8 +7226,10 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
71957226
if (!err && netif_running(netdev))
71967227
err = bnxt_open(netdev);
71977228

7198-
if (!err)
7229+
if (!err) {
71997230
result = PCI_ERS_RESULT_RECOVERED;
7231+
bnxt_ulp_start(bp);
7232+
}
72007233
}
72017234

72027235
if (result != PCI_ERS_RESULT_RECOVERED && netif_running(netdev))

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ struct bnxt {
972972
#define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp))
973973
#define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
974974

975+
struct bnxt_en_dev *edev;
976+
struct bnxt_en_dev * (*ulp_probe)(struct net_device *);
977+
975978
struct bnxt_napi **bnapi;
976979

977980
struct bnxt_rx_ring_info *rx_ring;
@@ -1242,9 +1245,12 @@ int hwrm_send_message(struct bnxt *, void *, u32, int);
12421245
int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
12431246
int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
12441247
int bmap_size);
1248+
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
12451249
int bnxt_hwrm_set_coal(struct bnxt *);
12461250
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
1251+
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
12471252
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
1253+
void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max);
12481254
void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max);
12491255
void bnxt_tx_disable(struct bnxt *bp);
12501256
void bnxt_tx_enable(struct bnxt *bp);

0 commit comments

Comments
 (0)