2016-12-07 00:26:21 -05:00
|
|
|
/* Broadcom NetXtreme-C/E network driver.
|
|
|
|
*
|
2018-03-31 13:54:21 -04:00
|
|
|
* Copyright (c) 2016-2018 Broadcom Limited
|
2016-12-07 00:26:21 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BNXT_ULP_H
|
|
|
|
#define BNXT_ULP_H
|
|
|
|
|
|
|
|
#define BNXT_MIN_ROCE_CP_RINGS 2
|
|
|
|
#define BNXT_MIN_ROCE_STAT_CTXS 1
|
2024-09-09 13:27:35 -07:00
|
|
|
|
|
|
|
#define BNXT_MAX_ROCE_MSIX_VF 2
|
|
|
|
#define BNXT_MAX_ROCE_MSIX_NPAR_PF 5
|
|
|
|
#define BNXT_MAX_ROCE_MSIX 64
|
2016-12-07 00:26:21 -05:00
|
|
|
|
|
|
|
struct hwrm_async_event_cmpl;
|
|
|
|
struct bnxt;
|
|
|
|
|
2018-03-31 13:54:21 -04:00
|
|
|
struct bnxt_msix_entry {
|
|
|
|
u32 vector;
|
|
|
|
u32 ring_idx;
|
|
|
|
u32 db_offset;
|
|
|
|
};
|
|
|
|
|
2016-12-07 00:26:21 -05:00
|
|
|
struct bnxt_ulp_ops {
|
2025-01-07 08:15:49 +05:30
|
|
|
/* async_notifier() cannot sleep (in BH context) */
|
|
|
|
void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
|
2025-01-09 10:18:12 -08:00
|
|
|
void (*ulp_irq_stop)(void *, bool);
|
2018-03-31 13:54:21 -04:00
|
|
|
void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
|
2016-12-07 00:26:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bnxt_fw_msg {
|
|
|
|
void *msg;
|
|
|
|
int msg_len;
|
|
|
|
void *resp;
|
|
|
|
int resp_max_len;
|
|
|
|
int timeout;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bnxt_ulp {
|
|
|
|
void *handle;
|
|
|
|
struct bnxt_ulp_ops __rcu *ulp_ops;
|
|
|
|
unsigned long *async_events_bmap;
|
|
|
|
u16 max_async_event_id;
|
|
|
|
u16 msix_requested;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bnxt_en_dev {
|
|
|
|
struct net_device *net;
|
|
|
|
struct pci_dev *pdev;
|
2022-12-12 10:36:29 -08:00
|
|
|
struct bnxt_msix_entry msix_entries[BNXT_MAX_ROCE_MSIX];
|
2016-12-07 00:26:21 -05:00
|
|
|
u32 flags;
|
|
|
|
#define BNXT_EN_FLAG_ROCEV1_CAP 0x1
|
|
|
|
#define BNXT_EN_FLAG_ROCEV2_CAP 0x2
|
|
|
|
#define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
|
|
|
|
BNXT_EN_FLAG_ROCEV2_CAP)
|
2018-03-31 13:54:21 -04:00
|
|
|
#define BNXT_EN_FLAG_MSIX_REQUESTED 0x4
|
2019-10-31 01:07:49 -04:00
|
|
|
#define BNXT_EN_FLAG_ULP_STOPPED 0x8
|
2022-10-14 16:31:31 -07:00
|
|
|
#define BNXT_EN_FLAG_VF 0x10
|
|
|
|
#define BNXT_EN_VF(edev) ((edev)->flags & BNXT_EN_FLAG_VF)
|
2024-11-06 00:44:35 -08:00
|
|
|
#define BNXT_EN_FLAG_ROCE_VF_RES_MGMT 0x20
|
2024-12-17 10:26:15 -08:00
|
|
|
#define BNXT_EN_FLAG_SW_RES_LMT 0x40
|
|
|
|
#define BNXT_EN_SW_RES_LMT(edev) ((edev)->flags & BNXT_EN_FLAG_SW_RES_LMT)
|
2022-10-14 16:31:31 -07:00
|
|
|
|
2022-09-01 16:43:46 -07:00
|
|
|
struct bnxt_ulp *ulp_tbl;
|
2020-05-04 04:50:38 -04:00
|
|
|
int l2_db_size; /* Doorbell BAR size in
|
|
|
|
* bytes mapped by L2
|
|
|
|
* driver.
|
|
|
|
*/
|
|
|
|
int l2_db_size_nc; /* Doorbell BAR size in
|
|
|
|
* bytes mapped as non-
|
|
|
|
* cacheable.
|
|
|
|
*/
|
2023-12-01 14:39:13 -08:00
|
|
|
int l2_db_offset; /* Doorbell offset in
|
|
|
|
* bytes within
|
|
|
|
* l2_db_size_nc.
|
|
|
|
*/
|
2022-10-14 16:31:31 -07:00
|
|
|
u16 chip_num;
|
|
|
|
u16 hw_ring_stats_size;
|
|
|
|
u16 pf_port_id;
|
|
|
|
unsigned long en_state; /* Could be checked in
|
|
|
|
* RoCE driver suspend
|
|
|
|
* mode only. Will be
|
|
|
|
* updated in resume.
|
|
|
|
*/
|
2023-07-18 22:02:52 -07:00
|
|
|
void __iomem *bar0;
|
2024-04-09 14:54:29 -07:00
|
|
|
|
|
|
|
u16 ulp_num_msix_vec;
|
|
|
|
u16 ulp_num_ctxs;
|
2024-04-30 17:30:54 -07:00
|
|
|
|
|
|
|
/* serialize ulp operations */
|
|
|
|
struct mutex en_dev_lock;
|
2016-12-07 00:26:21 -05:00
|
|
|
};
|
|
|
|
|
2022-09-01 16:43:46 -07:00
|
|
|
static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
|
2016-12-07 00:26:21 -05:00
|
|
|
{
|
2024-04-09 14:54:29 -07:00
|
|
|
if (edev && rcu_access_pointer(edev->ulp_tbl->ulp_ops))
|
2016-12-07 00:26:21 -05:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-31 13:54:17 -04:00
|
|
|
int bnxt_get_ulp_msix_num(struct bnxt *bp);
|
2024-04-09 14:54:30 -07:00
|
|
|
int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
|
2024-04-09 14:54:29 -07:00
|
|
|
void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
|
2018-12-16 18:46:21 -05:00
|
|
|
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
|
2024-04-09 14:54:29 -07:00
|
|
|
void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
|
2024-04-09 14:54:30 -07:00
|
|
|
int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
|
2024-04-09 14:54:29 -07:00
|
|
|
void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
|
2016-12-07 00:26:21 -05:00
|
|
|
void bnxt_ulp_stop(struct bnxt *bp);
|
2019-10-31 01:07:49 -04:00
|
|
|
void bnxt_ulp_start(struct bnxt *bp, int err);
|
2016-12-07 00:26:21 -05:00
|
|
|
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
|
2018-03-31 13:54:21 -04:00
|
|
|
void bnxt_ulp_irq_stop(struct bnxt *bp);
|
|
|
|
void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
|
2016-12-07 00:26:21 -05:00
|
|
|
void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
|
2022-03-06 20:01:30 -08:00
|
|
|
void bnxt_rdma_aux_device_uninit(struct bnxt *bp);
|
2024-04-09 14:54:28 -07:00
|
|
|
void bnxt_rdma_aux_device_del(struct bnxt *bp);
|
|
|
|
void bnxt_rdma_aux_device_add(struct bnxt *bp);
|
2022-03-06 20:01:30 -08:00
|
|
|
void bnxt_rdma_aux_device_init(struct bnxt *bp);
|
2022-09-05 17:16:51 -07:00
|
|
|
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);
|
2025-01-07 08:15:50 +05:30
|
|
|
void bnxt_register_async_events(struct bnxt_en_dev *edev,
|
|
|
|
unsigned long *events_bmap, u16 max_id);
|
2016-12-07 00:26:21 -05:00
|
|
|
#endif
|