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_ROCE_ULP 0 14 #define BNXT_MAX_ULP 1 15 16 #define BNXT_MIN_ROCE_CP_RINGS 2 17 #define BNXT_MIN_ROCE_STAT_CTXS 1 18 19 struct hwrm_async_event_cmpl; 20 struct bnxt; 21 22 struct bnxt_msix_entry { 23 u32 vector; 24 u32 ring_idx; 25 u32 db_offset; 26 }; 27 28 struct bnxt_ulp_ops { 29 /* async_notifier() cannot sleep (in BH context) */ 30 void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *); 31 void (*ulp_stop)(void *); 32 void (*ulp_start)(void *); 33 void (*ulp_sriov_config)(void *, int); 34 void (*ulp_irq_stop)(void *); 35 void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *); 36 }; 37 38 struct bnxt_fw_msg { 39 void *msg; 40 int msg_len; 41 void *resp; 42 int resp_max_len; 43 int timeout; 44 }; 45 46 struct bnxt_ulp { 47 void *handle; 48 struct bnxt_ulp_ops __rcu *ulp_ops; 49 unsigned long *async_events_bmap; 50 u16 max_async_event_id; 51 u16 msix_requested; 52 u16 msix_base; 53 atomic_t ref_count; 54 }; 55 56 struct bnxt_en_dev { 57 struct net_device *net; 58 struct pci_dev *pdev; 59 u32 flags; 60 #define BNXT_EN_FLAG_ROCEV1_CAP 0x1 61 #define BNXT_EN_FLAG_ROCEV2_CAP 0x2 62 #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \ 63 BNXT_EN_FLAG_ROCEV2_CAP) 64 #define BNXT_EN_FLAG_MSIX_REQUESTED 0x4 65 #define BNXT_EN_FLAG_ULP_STOPPED 0x8 66 const struct bnxt_en_ops *en_ops; 67 struct bnxt_ulp *ulp_tbl; 68 int l2_db_size; /* Doorbell BAR size in 69 * bytes mapped by L2 70 * driver. 71 */ 72 int l2_db_size_nc; /* Doorbell BAR size in 73 * bytes mapped as non- 74 * cacheable. 75 */ 76 }; 77 78 struct bnxt_en_ops { 79 int (*bnxt_register_device)(struct bnxt_en_dev *edev, 80 struct bnxt_ulp_ops *ulp_ops, void *handle); 81 int (*bnxt_unregister_device)(struct bnxt_en_dev *edev); 82 int (*bnxt_request_msix)(struct bnxt_en_dev *edev, 83 struct bnxt_msix_entry *ent, int num_msix); 84 void (*bnxt_free_msix)(struct bnxt_en_dev *edev); 85 int (*bnxt_send_fw_msg)(struct bnxt_en_dev *edev, 86 struct bnxt_fw_msg *fw_msg); 87 int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *edev, 88 unsigned long *events_bmap, u16 max_id); 89 }; 90 91 static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev) 92 { 93 if (edev && edev->ulp_tbl) 94 return true; 95 return false; 96 } 97 98 int bnxt_get_ulp_msix_num(struct bnxt *bp); 99 int bnxt_get_ulp_msix_base(struct bnxt *bp); 100 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp); 101 void bnxt_ulp_stop(struct bnxt *bp); 102 void bnxt_ulp_start(struct bnxt *bp, int err); 103 void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs); 104 void bnxt_ulp_irq_stop(struct bnxt *bp); 105 void bnxt_ulp_irq_restart(struct bnxt *bp, int err); 106 void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl); 107 void bnxt_rdma_aux_device_uninit(struct bnxt *bp); 108 void bnxt_rdma_aux_device_init(struct bnxt *bp); 109 #endif 110