1 /* Broadcom NetXtreme-C/E network driver. 2 * 3 * Copyright (c) 2016 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_OTHER_ULP 1 15 #define BNXT_MAX_ULP 2 16 17 #define BNXT_MIN_ROCE_CP_RINGS 2 18 #define BNXT_MIN_ROCE_STAT_CTXS 1 19 20 struct hwrm_async_event_cmpl; 21 struct bnxt; 22 23 struct bnxt_ulp_ops { 24 /* async_notifier() cannot sleep (in BH context) */ 25 void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *); 26 void (*ulp_stop)(void *); 27 void (*ulp_start)(void *); 28 void (*ulp_sriov_config)(void *, int); 29 void (*ulp_shutdown)(void *); 30 }; 31 32 struct bnxt_msix_entry { 33 u32 vector; 34 u32 ring_idx; 35 u32 db_offset; 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 atomic_t ref_count; 53 }; 54 55 struct bnxt_en_dev { 56 struct net_device *net; 57 struct pci_dev *pdev; 58 u32 flags; 59 #define BNXT_EN_FLAG_ROCEV1_CAP 0x1 60 #define BNXT_EN_FLAG_ROCEV2_CAP 0x2 61 #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \ 62 BNXT_EN_FLAG_ROCEV2_CAP) 63 const struct bnxt_en_ops *en_ops; 64 struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP]; 65 }; 66 67 struct bnxt_en_ops { 68 int (*bnxt_register_device)(struct bnxt_en_dev *, int, 69 struct bnxt_ulp_ops *, void *); 70 int (*bnxt_unregister_device)(struct bnxt_en_dev *, int); 71 int (*bnxt_request_msix)(struct bnxt_en_dev *, int, 72 struct bnxt_msix_entry *, int); 73 int (*bnxt_free_msix)(struct bnxt_en_dev *, int); 74 int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int, 75 struct bnxt_fw_msg *); 76 int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int, 77 unsigned long *, u16); 78 }; 79 80 static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id) 81 { 82 if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops)) 83 return true; 84 return false; 85 } 86 87 void bnxt_subtract_ulp_resources(struct bnxt *bp, int ulp_id); 88 void bnxt_ulp_stop(struct bnxt *bp); 89 void bnxt_ulp_start(struct bnxt *bp); 90 void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs); 91 void bnxt_ulp_shutdown(struct bnxt *bp); 92 void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl); 93 struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev); 94 95 #endif 96