Commit dafcdf5e authored by Ajit Khaparde's avatar Ajit Khaparde

bnxt_en: Remove usage of ulp_id

Since the driver continues to use the single ULP model,
the extra complexity and indirection is unnecessary.
Remove the usage of ulp_id from the code.
Suggested-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarAjit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: default avatarAndy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 6d758147
...@@ -363,8 +363,7 @@ static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev) ...@@ -363,8 +363,7 @@ static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev)
en_dev = rdev->en_dev; en_dev = rdev->en_dev;
rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev, rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev);
BNXT_ROCE_ULP);
return rc; return rc;
} }
...@@ -375,7 +374,7 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev) ...@@ -375,7 +374,7 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev)
en_dev = rdev->en_dev; en_dev = rdev->en_dev;
rc = en_dev->en_ops->bnxt_register_device(en_dev, BNXT_ROCE_ULP, rc = en_dev->en_ops->bnxt_register_device(en_dev,
&bnxt_re_ulp_ops, rdev); &bnxt_re_ulp_ops, rdev);
rdev->qplib_res.pdev = rdev->en_dev->pdev; rdev->qplib_res.pdev = rdev->en_dev->pdev;
return rc; return rc;
...@@ -384,16 +383,15 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev) ...@@ -384,16 +383,15 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev)
static int bnxt_re_free_msix(struct bnxt_re_dev *rdev) static int bnxt_re_free_msix(struct bnxt_re_dev *rdev)
{ {
struct bnxt_en_dev *en_dev; struct bnxt_en_dev *en_dev;
int rc;
if (!rdev) if (!rdev)
return -EINVAL; return -EINVAL;
en_dev = rdev->en_dev; en_dev = rdev->en_dev;
rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP); en_dev->en_ops->bnxt_free_msix(rdev->en_dev);
return rc; return 0;
} }
static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) static int bnxt_re_request_msix(struct bnxt_re_dev *rdev)
...@@ -405,7 +403,7 @@ static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) ...@@ -405,7 +403,7 @@ static int bnxt_re_request_msix(struct bnxt_re_dev *rdev)
num_msix_want = min_t(u32, BNXT_RE_MAX_MSIX, num_online_cpus()); num_msix_want = min_t(u32, BNXT_RE_MAX_MSIX, num_online_cpus());
num_msix_got = en_dev->en_ops->bnxt_request_msix(en_dev, BNXT_ROCE_ULP, num_msix_got = en_dev->en_ops->bnxt_request_msix(en_dev,
rdev->msix_entries, rdev->msix_entries,
num_msix_want); num_msix_want);
if (num_msix_got < BNXT_RE_MIN_MSIX) { if (num_msix_got < BNXT_RE_MIN_MSIX) {
...@@ -468,7 +466,7 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, ...@@ -468,7 +466,7 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
req.ring_id = cpu_to_le16(fw_ring_id); req.ring_id = cpu_to_le16(fw_ring_id);
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (rc) if (rc)
ibdev_err(&rdev->ibdev, "Failed to free HW ring:%d :%#x", ibdev_err(&rdev->ibdev, "Failed to free HW ring:%d :%#x",
req.ring_id, rc); req.ring_id, rc);
...@@ -505,7 +503,7 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, ...@@ -505,7 +503,7 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev,
req.int_mode = ring_attr->mode; req.int_mode = ring_attr->mode;
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (!rc) if (!rc)
*fw_ring_id = le16_to_cpu(resp.ring_id); *fw_ring_id = le16_to_cpu(resp.ring_id);
...@@ -533,7 +531,7 @@ static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, ...@@ -533,7 +531,7 @@ static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev,
req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id); req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id);
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (rc) if (rc)
ibdev_err(&rdev->ibdev, "Failed to free HW stats context %#x", ibdev_err(&rdev->ibdev, "Failed to free HW stats context %#x",
rc); rc);
...@@ -566,7 +564,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, ...@@ -566,7 +564,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev,
req.stat_ctx_flags = STAT_CTX_ALLOC_REQ_STAT_CTX_FLAGS_ROCE; req.stat_ctx_flags = STAT_CTX_ALLOC_REQ_STAT_CTX_FLAGS_ROCE;
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (!rc) if (!rc)
*fw_stats_ctx_id = le32_to_cpu(resp.stat_ctx_id); *fw_stats_ctx_id = le32_to_cpu(resp.stat_ctx_id);
...@@ -1052,7 +1050,7 @@ static int bnxt_re_query_hwrm_pri2cos(struct bnxt_re_dev *rdev, u8 dir, ...@@ -1052,7 +1050,7 @@ static int bnxt_re_query_hwrm_pri2cos(struct bnxt_re_dev *rdev, u8 dir,
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (rc) if (rc)
return rc; return rc;
...@@ -1235,7 +1233,7 @@ static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev) ...@@ -1235,7 +1233,7 @@ static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev)
req.hwrm_intf_upd = HWRM_VERSION_UPDATE; req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg); rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, &fw_msg);
if (rc) { if (rc) {
ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x", ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x",
rc); rc);
......
...@@ -5538,7 +5538,7 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id) ...@@ -5538,7 +5538,7 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)
#endif #endif
if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan)
req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE);
if (!vnic_id && bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) if (!vnic_id && bnxt_ulp_registered(bp->edev))
req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp));
return hwrm_req_send(bp, req); return hwrm_req_send(bp, req);
......
...@@ -28,59 +28,44 @@ ...@@ -28,59 +28,44 @@
static DEFINE_IDA(bnxt_aux_dev_ids); static DEFINE_IDA(bnxt_aux_dev_ids);
static int bnxt_register_dev(struct bnxt_en_dev *edev, unsigned int ulp_id, static int bnxt_register_dev(struct bnxt_en_dev *edev,
struct bnxt_ulp_ops *ulp_ops, void *handle) struct bnxt_ulp_ops *ulp_ops,
void *handle)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
unsigned int max_stat_ctxs;
struct bnxt_ulp *ulp; struct bnxt_ulp *ulp;
if (ulp_id >= BNXT_MAX_ULP) max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
return -EINVAL; if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS ||
bp->cp_nr_rings == max_stat_ctxs)
ulp = &edev->ulp_tbl[ulp_id]; return -ENOMEM;
if (rcu_access_pointer(ulp->ulp_ops)) {
netdev_err(bp->dev, "ulp id %d already registered\n", ulp_id);
return -EBUSY;
}
if (ulp_id == BNXT_ROCE_ULP) {
unsigned int max_stat_ctxs;
max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp); ulp = kzalloc(sizeof(*ulp), GFP_KERNEL);
if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS || if (!ulp)
bp->cp_nr_rings == max_stat_ctxs) return -ENOMEM;
return -ENOMEM;
}
atomic_set(&ulp->ref_count, 0); edev->ulp_tbl = ulp;
ulp->handle = handle; ulp->handle = handle;
rcu_assign_pointer(ulp->ulp_ops, ulp_ops); rcu_assign_pointer(ulp->ulp_ops, ulp_ops);
if (ulp_id == BNXT_ROCE_ULP) { if (test_bit(BNXT_STATE_OPEN, &bp->state))
if (test_bit(BNXT_STATE_OPEN, &bp->state)) bnxt_hwrm_vnic_cfg(bp, 0);
bnxt_hwrm_vnic_cfg(bp, 0);
}
return 0; return 0;
} }
static int bnxt_unregister_dev(struct bnxt_en_dev *edev, unsigned int ulp_id) static int bnxt_unregister_dev(struct bnxt_en_dev *edev)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
struct bnxt_ulp *ulp; struct bnxt_ulp *ulp;
int i = 0; int i = 0;
if (ulp_id >= BNXT_MAX_ULP) ulp = edev->ulp_tbl;
return -EINVAL; if (ulp->msix_requested)
edev->en_ops->bnxt_free_msix(edev);
ulp = &edev->ulp_tbl[ulp_id];
if (!rcu_access_pointer(ulp->ulp_ops)) {
netdev_err(bp->dev, "ulp id %d not registered\n", ulp_id);
return -EINVAL;
}
if (ulp_id == BNXT_ROCE_ULP && ulp->msix_requested)
edev->en_ops->bnxt_free_msix(edev, ulp_id);
if (ulp->max_async_event_id) if (ulp->max_async_event_id)
bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, true); bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, true);
...@@ -93,6 +78,8 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, unsigned int ulp_id) ...@@ -93,6 +78,8 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, unsigned int ulp_id)
msleep(100); msleep(100);
i++; i++;
} }
kfree(ulp);
edev->ulp_tbl = NULL;
return 0; return 0;
} }
...@@ -101,8 +88,8 @@ static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent) ...@@ -101,8 +88,8 @@ static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent)
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
int num_msix, idx, i; int num_msix, idx, i;
num_msix = edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested; num_msix = edev->ulp_tbl->msix_requested;
idx = edev->ulp_tbl[BNXT_ROCE_ULP].msix_base; idx = edev->ulp_tbl->msix_base;
for (i = 0; i < num_msix; i++) { for (i = 0; i < num_msix; i++) {
ent[i].vector = bp->irq_tbl[idx + i].vector; ent[i].vector = bp->irq_tbl[idx + i].vector;
ent[i].ring_idx = idx + i; ent[i].ring_idx = idx + i;
...@@ -116,8 +103,9 @@ static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent) ...@@ -116,8 +103,9 @@ static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent)
} }
} }
static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id, static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev,
struct bnxt_msix_entry *ent, int num_msix) struct bnxt_msix_entry *ent,
int num_msix)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
...@@ -127,13 +115,10 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id, ...@@ -127,13 +115,10 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id,
int total_vecs; int total_vecs;
int rc = 0; int rc = 0;
if (ulp_id != BNXT_ROCE_ULP)
return -EINVAL;
if (!(bp->flags & BNXT_FLAG_USING_MSIX)) if (!(bp->flags & BNXT_FLAG_USING_MSIX))
return -ENODEV; return -ENODEV;
if (edev->ulp_tbl[ulp_id].msix_requested) if (edev->ulp_tbl->msix_requested)
return -EAGAIN; return -EAGAIN;
max_cp_rings = bnxt_get_max_func_cp_rings(bp); max_cp_rings = bnxt_get_max_func_cp_rings(bp);
...@@ -149,8 +134,8 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id, ...@@ -149,8 +134,8 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id,
max_idx = min_t(int, bp->total_irqs, max_cp_rings); max_idx = min_t(int, bp->total_irqs, max_cp_rings);
idx = max_idx - avail_msix; idx = max_idx - avail_msix;
} }
edev->ulp_tbl[ulp_id].msix_base = idx; edev->ulp_tbl->msix_base = idx;
edev->ulp_tbl[ulp_id].msix_requested = avail_msix; edev->ulp_tbl->msix_requested = avail_msix;
hw_resc = &bp->hw_resc; hw_resc = &bp->hw_resc;
total_vecs = idx + avail_msix; total_vecs = idx + avail_msix;
rtnl_lock(); rtnl_lock();
...@@ -165,7 +150,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id, ...@@ -165,7 +150,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id,
} }
rtnl_unlock(); rtnl_unlock();
if (rc) { if (rc) {
edev->ulp_tbl[ulp_id].msix_requested = 0; edev->ulp_tbl->msix_requested = 0;
return -EAGAIN; return -EAGAIN;
} }
...@@ -174,25 +159,22 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id, ...@@ -174,25 +159,22 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id,
resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings; resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
avail_msix = min_t(int, resv_msix, avail_msix); avail_msix = min_t(int, resv_msix, avail_msix);
edev->ulp_tbl[ulp_id].msix_requested = avail_msix; edev->ulp_tbl->msix_requested = avail_msix;
} }
bnxt_fill_msix_vecs(bp, ent); bnxt_fill_msix_vecs(bp, ent);
edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED; edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
return avail_msix; return avail_msix;
} }
static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id) static void bnxt_free_msix_vecs(struct bnxt_en_dev *edev)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
if (ulp_id != BNXT_ROCE_ULP)
return -EINVAL;
if (!(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED)) if (!(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
return 0; return;
edev->ulp_tbl[ulp_id].msix_requested = 0; edev->ulp_tbl->msix_requested = 0;
edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED; edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
rtnl_lock(); rtnl_lock();
if (netif_running(dev) && !(edev->flags & BNXT_EN_FLAG_ULP_STOPPED)) { if (netif_running(dev) && !(edev->flags & BNXT_EN_FLAG_ULP_STOPPED)) {
...@@ -201,43 +183,43 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id) ...@@ -201,43 +183,43 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, unsigned int ulp_id)
} }
rtnl_unlock(); rtnl_unlock();
return 0; return;
} }
int bnxt_get_ulp_msix_num(struct bnxt *bp) int bnxt_get_ulp_msix_num(struct bnxt *bp)
{ {
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) { if (bnxt_ulp_registered(bp->edev)) {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
return edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested; return edev->ulp_tbl->msix_requested;
} }
return 0; return 0;
} }
int bnxt_get_ulp_msix_base(struct bnxt *bp) int bnxt_get_ulp_msix_base(struct bnxt *bp)
{ {
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) { if (bnxt_ulp_registered(bp->edev)) {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested) if (edev->ulp_tbl->msix_requested)
return edev->ulp_tbl[BNXT_ROCE_ULP].msix_base; return edev->ulp_tbl->msix_base;
} }
return 0; return 0;
} }
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp) int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
{ {
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) { if (bnxt_ulp_registered(bp->edev)) {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested) if (edev->ulp_tbl->msix_requested)
return BNXT_MIN_ROCE_STAT_CTXS; return BNXT_MIN_ROCE_STAT_CTXS;
} }
return 0; return 0;
} }
static int bnxt_send_msg(struct bnxt_en_dev *edev, unsigned int ulp_id, static int bnxt_send_msg(struct bnxt_en_dev *edev,
struct bnxt_fw_msg *fw_msg) struct bnxt_fw_msg *fw_msg)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
...@@ -247,7 +229,7 @@ static int bnxt_send_msg(struct bnxt_en_dev *edev, unsigned int ulp_id, ...@@ -247,7 +229,7 @@ static int bnxt_send_msg(struct bnxt_en_dev *edev, unsigned int ulp_id,
u32 resp_len; u32 resp_len;
int rc; int rc;
if (ulp_id != BNXT_ROCE_ULP && bp->fw_reset_state) if (bp->fw_reset_state)
return -EBUSY; return -EBUSY;
rc = hwrm_req_init(bp, req, 0 /* don't care */); rc = hwrm_req_init(bp, req, 0 /* don't care */);
...@@ -286,27 +268,24 @@ void bnxt_ulp_stop(struct bnxt *bp) ...@@ -286,27 +268,24 @@ void bnxt_ulp_stop(struct bnxt *bp)
{ {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
struct bnxt_ulp_ops *ops; struct bnxt_ulp_ops *ops;
int i; struct bnxt_ulp *ulp;
if (!edev) if (!edev)
return; return;
edev->flags |= BNXT_EN_FLAG_ULP_STOPPED; edev->flags |= BNXT_EN_FLAG_ULP_STOPPED;
for (i = 0; i < BNXT_MAX_ULP; i++) { ulp = edev->ulp_tbl;
struct bnxt_ulp *ulp = &edev->ulp_tbl[i]; ops = rtnl_dereference(ulp->ulp_ops);
if (!ops || !ops->ulp_stop)
ops = rtnl_dereference(ulp->ulp_ops); return;
if (!ops || !ops->ulp_stop) ops->ulp_stop(ulp->handle);
continue;
ops->ulp_stop(ulp->handle);
}
} }
void bnxt_ulp_start(struct bnxt *bp, int err) void bnxt_ulp_start(struct bnxt *bp, int err)
{ {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
struct bnxt_ulp_ops *ops; struct bnxt_ulp_ops *ops;
int i; struct bnxt_ulp *ulp;
if (!edev) if (!edev)
return; return;
...@@ -316,39 +295,33 @@ void bnxt_ulp_start(struct bnxt *bp, int err) ...@@ -316,39 +295,33 @@ void bnxt_ulp_start(struct bnxt *bp, int err)
if (err) if (err)
return; return;
for (i = 0; i < BNXT_MAX_ULP; i++) { ulp = edev->ulp_tbl;
struct bnxt_ulp *ulp = &edev->ulp_tbl[i]; ops = rtnl_dereference(ulp->ulp_ops);
if (!ops || !ops->ulp_start)
ops = rtnl_dereference(ulp->ulp_ops); return;
if (!ops || !ops->ulp_start) ops->ulp_start(ulp->handle);
continue;
ops->ulp_start(ulp->handle);
}
} }
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs) void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs)
{ {
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
struct bnxt_ulp_ops *ops; struct bnxt_ulp_ops *ops;
int i; struct bnxt_ulp *ulp;
if (!edev) if (!edev)
return; return;
ulp = edev->ulp_tbl;
for (i = 0; i < BNXT_MAX_ULP; i++) { rcu_read_lock();
struct bnxt_ulp *ulp = &edev->ulp_tbl[i]; ops = rcu_dereference(ulp->ulp_ops);
if (!ops || !ops->ulp_sriov_config) {
rcu_read_lock();
ops = rcu_dereference(ulp->ulp_ops);
if (!ops || !ops->ulp_sriov_config) {
rcu_read_unlock();
continue;
}
bnxt_ulp_get(ulp);
rcu_read_unlock(); rcu_read_unlock();
ops->ulp_sriov_config(ulp->handle, num_vfs); return;
bnxt_ulp_put(ulp);
} }
bnxt_ulp_get(ulp);
rcu_read_unlock();
ops->ulp_sriov_config(ulp->handle, num_vfs);
bnxt_ulp_put(ulp);
} }
void bnxt_ulp_irq_stop(struct bnxt *bp) void bnxt_ulp_irq_stop(struct bnxt *bp)
...@@ -359,8 +332,8 @@ void bnxt_ulp_irq_stop(struct bnxt *bp) ...@@ -359,8 +332,8 @@ void bnxt_ulp_irq_stop(struct bnxt *bp)
if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED)) if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
return; return;
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) { if (bnxt_ulp_registered(bp->edev)) {
struct bnxt_ulp *ulp = &edev->ulp_tbl[BNXT_ROCE_ULP]; struct bnxt_ulp *ulp = edev->ulp_tbl;
if (!ulp->msix_requested) if (!ulp->msix_requested)
return; return;
...@@ -380,8 +353,8 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err) ...@@ -380,8 +353,8 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED)) if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
return; return;
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) { if (bnxt_ulp_registered(bp->edev)) {
struct bnxt_ulp *ulp = &edev->ulp_tbl[BNXT_ROCE_ULP]; struct bnxt_ulp *ulp = edev->ulp_tbl;
struct bnxt_msix_entry *ent = NULL; struct bnxt_msix_entry *ent = NULL;
if (!ulp->msix_requested) if (!ulp->msix_requested)
...@@ -408,41 +381,38 @@ void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl) ...@@ -408,41 +381,38 @@ void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl)
u16 event_id = le16_to_cpu(cmpl->event_id); u16 event_id = le16_to_cpu(cmpl->event_id);
struct bnxt_en_dev *edev = bp->edev; struct bnxt_en_dev *edev = bp->edev;
struct bnxt_ulp_ops *ops; struct bnxt_ulp_ops *ops;
int i; struct bnxt_ulp *ulp;
if (!edev) if (!bnxt_ulp_registered(edev))
return; return;
ulp = edev->ulp_tbl;
rcu_read_lock(); rcu_read_lock();
for (i = 0; i < BNXT_MAX_ULP; i++) {
struct bnxt_ulp *ulp = &edev->ulp_tbl[i]; ops = rcu_dereference(ulp->ulp_ops);
if (!ops || !ops->ulp_async_notifier)
ops = rcu_dereference(ulp->ulp_ops); goto exit;
if (!ops || !ops->ulp_async_notifier) if (!ulp->async_events_bmap || event_id > ulp->max_async_event_id)
continue; goto exit;
if (!ulp->async_events_bmap ||
event_id > ulp->max_async_event_id) /* Read max_async_event_id first before testing the bitmap. */
continue; smp_rmb();
if (test_bit(event_id, ulp->async_events_bmap))
/* Read max_async_event_id first before testing the bitmap. */ ops->ulp_async_notifier(ulp->handle, cmpl);
smp_rmb(); exit:
if (test_bit(event_id, ulp->async_events_bmap))
ops->ulp_async_notifier(ulp->handle, cmpl);
}
rcu_read_unlock(); rcu_read_unlock();
} }
static int bnxt_register_async_events(struct bnxt_en_dev *edev, unsigned int ulp_id, static int bnxt_register_async_events(struct bnxt_en_dev *edev,
unsigned long *events_bmap, u16 max_id) unsigned long *events_bmap,
u16 max_id)
{ {
struct net_device *dev = edev->net; struct net_device *dev = edev->net;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
struct bnxt_ulp *ulp; struct bnxt_ulp *ulp;
if (ulp_id >= BNXT_MAX_ULP) ulp = edev->ulp_tbl;
return -EINVAL;
ulp = &edev->ulp_tbl[ulp_id];
ulp->async_events_bmap = events_bmap; ulp->async_events_bmap = events_bmap;
/* Make sure bnxt_ulp_async_events() sees this order */ /* Make sure bnxt_ulp_async_events() sees this order */
smp_wmb(); smp_wmb();
......
...@@ -64,7 +64,7 @@ struct bnxt_en_dev { ...@@ -64,7 +64,7 @@ struct bnxt_en_dev {
#define BNXT_EN_FLAG_MSIX_REQUESTED 0x4 #define BNXT_EN_FLAG_MSIX_REQUESTED 0x4
#define BNXT_EN_FLAG_ULP_STOPPED 0x8 #define BNXT_EN_FLAG_ULP_STOPPED 0x8
const struct bnxt_en_ops *en_ops; const struct bnxt_en_ops *en_ops;
struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP]; struct bnxt_ulp *ulp_tbl;
int l2_db_size; /* Doorbell BAR size in int l2_db_size; /* Doorbell BAR size in
* bytes mapped by L2 * bytes mapped by L2
* driver. * driver.
...@@ -76,21 +76,21 @@ struct bnxt_en_dev { ...@@ -76,21 +76,21 @@ struct bnxt_en_dev {
}; };
struct bnxt_en_ops { struct bnxt_en_ops {
int (*bnxt_register_device)(struct bnxt_en_dev *, unsigned int, int (*bnxt_register_device)(struct bnxt_en_dev *edev,
struct bnxt_ulp_ops *, void *); struct bnxt_ulp_ops *ulp_ops, void *handle);
int (*bnxt_unregister_device)(struct bnxt_en_dev *, unsigned int); int (*bnxt_unregister_device)(struct bnxt_en_dev *edev);
int (*bnxt_request_msix)(struct bnxt_en_dev *, unsigned int, int (*bnxt_request_msix)(struct bnxt_en_dev *edev,
struct bnxt_msix_entry *, int); struct bnxt_msix_entry *ent, int num_msix);
int (*bnxt_free_msix)(struct bnxt_en_dev *, unsigned int); void (*bnxt_free_msix)(struct bnxt_en_dev *edev);
int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, unsigned int, int (*bnxt_send_fw_msg)(struct bnxt_en_dev *edev,
struct bnxt_fw_msg *); struct bnxt_fw_msg *fw_msg);
int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, unsigned int, int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *edev,
unsigned long *, u16); unsigned long *events_bmap, u16 max_id);
}; };
static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id) static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
{ {
if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops)) if (edev && edev->ulp_tbl)
return true; return true;
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment