Skip to content

Commit

Permalink
RDMA/bnxt_re: Add Async event handling support
Browse files Browse the repository at this point in the history
Using the option provided by Ethernet driver, register for FW Async
event. During probe, while registeriung with Ethernet driver, provide
the ulp hook 'ulp_async_notifier' for receiving the firmware events.

Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Link: https://patch.msgid.link/20250107024553.2926983-3-kalesh-anakkur.purayil@broadcom.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
  • Loading branch information
Kalesh AP authored and Leon Romanovsky committed Jan 14, 2025
1 parent 184fe6f commit 7fea327
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
1 change: 1 addition & 0 deletions drivers/infiniband/hw/bnxt_re/bnxt_re.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct bnxt_re_dev {
DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS);
struct dentry *dbg_root;
struct dentry *qp_debugfs;
unsigned long event_bitmap;
};

#define to_bnxt_re_dev(ptr, member) \
Expand Down
39 changes: 39 additions & 0 deletions drivers/infiniband/hw/bnxt_re/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,20 @@ static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev)
&rdev->qplib_ctx);
}

static void bnxt_re_async_notifier(void *handle, struct hwrm_async_event_cmpl *cmpl)
{
struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle;
u32 data1, data2;
u16 event_id;

event_id = le16_to_cpu(cmpl->event_id);
data1 = le32_to_cpu(cmpl->event_data1);
data2 = le32_to_cpu(cmpl->event_data2);

ibdev_dbg(&rdev->ibdev, "Async event_id = %d data1 = %d data2 = %d",
event_id, data1, data2);
}

static void bnxt_re_stop_irq(void *handle)
{
struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
Expand Down Expand Up @@ -361,6 +375,7 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
}

static struct bnxt_ulp_ops bnxt_re_ulp_ops = {
.ulp_async_notifier = bnxt_re_async_notifier,
.ulp_irq_stop = bnxt_re_stop_irq,
.ulp_irq_restart = bnxt_re_start_irq
};
Expand Down Expand Up @@ -1785,6 +1800,26 @@ static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev)
return 0;
}

static void bnxt_re_net_unregister_async_event(struct bnxt_re_dev *rdev)
{
if (rdev->is_virtfn)
return;

memset(&rdev->event_bitmap, 0, sizeof(rdev->event_bitmap));
bnxt_register_async_events(rdev->en_dev, &rdev->event_bitmap,
ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE);
}

static void bnxt_re_net_register_async_event(struct bnxt_re_dev *rdev)
{
if (rdev->is_virtfn)
return;

rdev->event_bitmap |= (1 << ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE);
bnxt_register_async_events(rdev->en_dev, &rdev->event_bitmap,
ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE);
}

static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev)
{
struct bnxt_en_dev *en_dev = rdev->en_dev;
Expand Down Expand Up @@ -1864,6 +1899,8 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)

bnxt_re_debugfs_rem_pdev(rdev);

bnxt_re_net_unregister_async_event(rdev);

if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags))
cancel_delayed_work_sync(&rdev->worker);

Expand Down Expand Up @@ -2077,6 +2114,8 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)

bnxt_re_debugfs_add_pdev(rdev);

bnxt_re_net_register_async_event(rdev);

return 0;
free_sctx:
bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl)
rcu_read_unlock();
}

int bnxt_register_async_events(struct bnxt_en_dev *edev,
unsigned long *events_bmap,
u16 max_id)
void bnxt_register_async_events(struct bnxt_en_dev *edev,
unsigned long *events_bmap, u16 max_id)
{
struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev);
Expand All @@ -387,7 +386,6 @@ int bnxt_register_async_events(struct bnxt_en_dev *edev,
smp_wmb();
ulp->max_async_event_id = max_id;
bnxt_hwrm_func_drv_rgtr(bp, events_bmap, max_id + 1, true);
return 0;
}
EXPORT_SYMBOL(bnxt_register_async_events);

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ int bnxt_register_dev(struct bnxt_en_dev *edev, struct bnxt_ulp_ops *ulp_ops,
void *handle);
void bnxt_unregister_dev(struct bnxt_en_dev *edev);
int bnxt_send_msg(struct bnxt_en_dev *edev, struct bnxt_fw_msg *fw_msg);
int bnxt_register_async_events(struct bnxt_en_dev *edev,
unsigned long *events_bmap, u16 max_id);
void bnxt_register_async_events(struct bnxt_en_dev *edev,
unsigned long *events_bmap, u16 max_id);
#endif

0 comments on commit 7fea327

Please sign in to comment.