| 1 |
/* Broadcom NetXtreme-C/E network driver. |
| 2 |
* |
| 3 |
* Copyright (c) 2016-2018 Broadcom Limited |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef BNXT_ULP_H |
| 11 |
#define BNXT_ULP_H |
| 12 |
|
| 13 |
#define BNXT_MIN_ROCE_CP_RINGS 2 |
| 14 |
#define BNXT_MIN_ROCE_STAT_CTXS 1 |
| 15 |
|
| 16 |
#define BNXT_MAX_ROCE_MSIX_VF 2 |
| 17 |
#define BNXT_MAX_ROCE_MSIX_NPAR_PF 5 |
| 18 |
#define BNXT_MAX_ROCE_MSIX 64 |
| 19 |
|
| 20 |
struct hwrm_async_event_cmpl; |
| 21 |
struct bnxt; |
| 22 |
|
| 23 |
struct bnxt_msix_entry { |
| 24 |
u32 vector; |
| 25 |
u32 ring_idx; |
| 26 |
u32 db_offset; |
| 27 |
}; |
| 28 |
|
| 29 |
struct bnxt_ulp_ops { |
| 30 |
/* async_notifier() cannot sleep (in BH context) */ |
| 31 |
void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *); |
| 32 |
void (*ulp_irq_stop)(void *, bool); |
| 33 |
void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *); |
| 34 |
}; |
| 35 |
|
| 36 |
struct bnxt_fw_msg { |
| 37 |
void *msg; |
| 38 |
int msg_len; |
| 39 |
void *resp; |
| 40 |
int resp_max_len; |
| 41 |
int timeout; |
| 42 |
}; |
| 43 |
|
| 44 |
struct bnxt_ulp { |
| 45 |
void *handle; |
| 46 |
struct bnxt_ulp_ops __rcu *ulp_ops; |
| 47 |
unsigned long *async_events_bmap; |
| 48 |
u16 max_async_event_id; |
| 49 |
u16 msix_requested; |
| 50 |
}; |
| 51 |
|
| 52 |
struct bnxt_en_dev { |
| 53 |
struct net_device *net; |
| 54 |
struct pci_dev *pdev; |
| 55 |
struct bnxt_msix_entry msix_entries[BNXT_MAX_ROCE_MSIX]; |
| 56 |
u32 flags; |
| 57 |
#define BNXT_EN_FLAG_ROCEV1_CAP 0x1 |
| 58 |
#define BNXT_EN_FLAG_ROCEV2_CAP 0x2 |
| 59 |
#define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \ |
| 60 |
BNXT_EN_FLAG_ROCEV2_CAP) |
| 61 |
#define BNXT_EN_FLAG_ULP_STOPPED 0x8 |
| 62 |
#define BNXT_EN_FLAG_VF 0x10 |
| 63 |
#define BNXT_EN_VF(edev) ((edev)->flags & BNXT_EN_FLAG_VF) |
| 64 |
#define BNXT_EN_FLAG_ROCE_VF_RES_MGMT 0x20 |
| 65 |
#define BNXT_EN_FLAG_SW_RES_LMT 0x40 |
| 66 |
#define BNXT_EN_SW_RES_LMT(edev) ((edev)->flags & BNXT_EN_FLAG_SW_RES_LMT) |
| 67 |
|
| 68 |
struct bnxt_ulp *ulp_tbl; |
| 69 |
int l2_db_size; /* Doorbell BAR size in |
| 70 |
* bytes mapped by L2 |
| 71 |
* driver. |
| 72 |
*/ |
| 73 |
int l2_db_size_nc; /* Doorbell BAR size in |
| 74 |
* bytes mapped as non- |
| 75 |
* cacheable. |
| 76 |
*/ |
| 77 |
int l2_db_offset; /* Doorbell offset in |
| 78 |
* bytes within |
| 79 |
* l2_db_size_nc. |
| 80 |
*/ |
| 81 |
u16 chip_num; |
| 82 |
u16 hw_ring_stats_size; |
| 83 |
u16 pf_port_id; |
| 84 |
unsigned long en_state; /* Could be checked in |
| 85 |
* RoCE driver suspend |
| 86 |
* mode only. Will be |
| 87 |
* updated in resume. |
| 88 |
*/ |
| 89 |
void __iomem *bar0; |
| 90 |
|
| 91 |
u16 ulp_num_msix_vec; |
| 92 |
u16 ulp_num_ctxs; |
| 93 |
|
| 94 |
/* serialize ulp operations */ |
| 95 |
struct mutex en_dev_lock; |
| 96 |
}; |
| 97 |
|
| 98 |
static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev) |
| 99 |
{ |
| 100 |
if (edev && rcu_access_pointer(edev->ulp_tbl->ulp_ops)) |
| 101 |
return true; |
| 102 |
return false; |
| 103 |
} |
| 104 |
|
| 105 |
int bnxt_get_ulp_msix_num(struct bnxt *bp); |
| 106 |
int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp); |
| 107 |
void bnxt_set_ulp_msix_num(struct bnxt *bp, int num); |
| 108 |
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp); |
| 109 |
void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs); |
| 110 |
int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp); |
| 111 |
void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp); |
| 112 |
void bnxt_ulp_stop(struct bnxt *bp); |
| 113 |
void bnxt_ulp_start(struct bnxt *bp, int err); |
| 114 |
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs); |
| 115 |
void bnxt_ulp_irq_stop(struct bnxt *bp); |
| 116 |
void bnxt_ulp_irq_restart(struct bnxt *bp, int err); |
| 117 |
void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl); |
| 118 |
void bnxt_rdma_aux_device_uninit(struct bnxt *bp); |
| 119 |
void bnxt_rdma_aux_device_del(struct bnxt *bp); |
| 120 |
void bnxt_rdma_aux_device_add(struct bnxt *bp); |
| 121 |
void bnxt_rdma_aux_device_init(struct bnxt *bp); |
| 122 |
int bnxt_register_dev(struct bnxt_en_dev *edev, struct bnxt_ulp_ops *ulp_ops, |
| 123 |
void *handle); |
| 124 |
void bnxt_unregister_dev(struct bnxt_en_dev *edev); |
| 125 |
int bnxt_send_msg(struct bnxt_en_dev *edev, struct bnxt_fw_msg *fw_msg); |
| 126 |
void bnxt_register_async_events(struct bnxt_en_dev *edev, |
| 127 |
unsigned long *events_bmap, u16 max_id); |
| 128 |
#endif |