18c2ecf20Sopenharmony_ci/* Broadcom NetXtreme-C/E network driver. 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright (c) 2016-2018 Broadcom Limited 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 78c2ecf20Sopenharmony_ci * the Free Software Foundation. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef BNXT_ULP_H 118c2ecf20Sopenharmony_ci#define BNXT_ULP_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define BNXT_ROCE_ULP 0 148c2ecf20Sopenharmony_ci#define BNXT_OTHER_ULP 1 158c2ecf20Sopenharmony_ci#define BNXT_MAX_ULP 2 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define BNXT_MIN_ROCE_CP_RINGS 2 188c2ecf20Sopenharmony_ci#define BNXT_MIN_ROCE_STAT_CTXS 1 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistruct hwrm_async_event_cmpl; 218c2ecf20Sopenharmony_cistruct bnxt; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistruct bnxt_msix_entry { 248c2ecf20Sopenharmony_ci u32 vector; 258c2ecf20Sopenharmony_ci u32 ring_idx; 268c2ecf20Sopenharmony_ci u32 db_offset; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct bnxt_ulp_ops { 308c2ecf20Sopenharmony_ci /* async_notifier() cannot sleep (in BH context) */ 318c2ecf20Sopenharmony_ci void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *); 328c2ecf20Sopenharmony_ci void (*ulp_stop)(void *); 338c2ecf20Sopenharmony_ci void (*ulp_start)(void *); 348c2ecf20Sopenharmony_ci void (*ulp_sriov_config)(void *, int); 358c2ecf20Sopenharmony_ci void (*ulp_shutdown)(void *); 368c2ecf20Sopenharmony_ci void (*ulp_irq_stop)(void *); 378c2ecf20Sopenharmony_ci void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *); 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct bnxt_fw_msg { 418c2ecf20Sopenharmony_ci void *msg; 428c2ecf20Sopenharmony_ci int msg_len; 438c2ecf20Sopenharmony_ci void *resp; 448c2ecf20Sopenharmony_ci int resp_max_len; 458c2ecf20Sopenharmony_ci int timeout; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct bnxt_ulp { 498c2ecf20Sopenharmony_ci void *handle; 508c2ecf20Sopenharmony_ci struct bnxt_ulp_ops __rcu *ulp_ops; 518c2ecf20Sopenharmony_ci unsigned long *async_events_bmap; 528c2ecf20Sopenharmony_ci u16 max_async_event_id; 538c2ecf20Sopenharmony_ci u16 msix_requested; 548c2ecf20Sopenharmony_ci u16 msix_base; 558c2ecf20Sopenharmony_ci atomic_t ref_count; 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct bnxt_en_dev { 598c2ecf20Sopenharmony_ci struct net_device *net; 608c2ecf20Sopenharmony_ci struct pci_dev *pdev; 618c2ecf20Sopenharmony_ci u32 flags; 628c2ecf20Sopenharmony_ci #define BNXT_EN_FLAG_ROCEV1_CAP 0x1 638c2ecf20Sopenharmony_ci #define BNXT_EN_FLAG_ROCEV2_CAP 0x2 648c2ecf20Sopenharmony_ci #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \ 658c2ecf20Sopenharmony_ci BNXT_EN_FLAG_ROCEV2_CAP) 668c2ecf20Sopenharmony_ci #define BNXT_EN_FLAG_MSIX_REQUESTED 0x4 678c2ecf20Sopenharmony_ci #define BNXT_EN_FLAG_ULP_STOPPED 0x8 688c2ecf20Sopenharmony_ci const struct bnxt_en_ops *en_ops; 698c2ecf20Sopenharmony_ci struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP]; 708c2ecf20Sopenharmony_ci int l2_db_size; /* Doorbell BAR size in 718c2ecf20Sopenharmony_ci * bytes mapped by L2 728c2ecf20Sopenharmony_ci * driver. 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci int l2_db_size_nc; /* Doorbell BAR size in 758c2ecf20Sopenharmony_ci * bytes mapped as non- 768c2ecf20Sopenharmony_ci * cacheable. 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistruct bnxt_en_ops { 818c2ecf20Sopenharmony_ci int (*bnxt_register_device)(struct bnxt_en_dev *, int, 828c2ecf20Sopenharmony_ci struct bnxt_ulp_ops *, void *); 838c2ecf20Sopenharmony_ci int (*bnxt_unregister_device)(struct bnxt_en_dev *, int); 848c2ecf20Sopenharmony_ci int (*bnxt_request_msix)(struct bnxt_en_dev *, int, 858c2ecf20Sopenharmony_ci struct bnxt_msix_entry *, int); 868c2ecf20Sopenharmony_ci int (*bnxt_free_msix)(struct bnxt_en_dev *, int); 878c2ecf20Sopenharmony_ci int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int, 888c2ecf20Sopenharmony_ci struct bnxt_fw_msg *); 898c2ecf20Sopenharmony_ci int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int, 908c2ecf20Sopenharmony_ci unsigned long *, u16); 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops)) 968c2ecf20Sopenharmony_ci return true; 978c2ecf20Sopenharmony_ci return false; 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciint bnxt_get_ulp_msix_num(struct bnxt *bp); 1018c2ecf20Sopenharmony_ciint bnxt_get_ulp_msix_base(struct bnxt *bp); 1028c2ecf20Sopenharmony_ciint bnxt_get_ulp_stat_ctxs(struct bnxt *bp); 1038c2ecf20Sopenharmony_civoid bnxt_ulp_stop(struct bnxt *bp); 1048c2ecf20Sopenharmony_civoid bnxt_ulp_start(struct bnxt *bp, int err); 1058c2ecf20Sopenharmony_civoid bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs); 1068c2ecf20Sopenharmony_civoid bnxt_ulp_shutdown(struct bnxt *bp); 1078c2ecf20Sopenharmony_civoid bnxt_ulp_irq_stop(struct bnxt *bp); 1088c2ecf20Sopenharmony_civoid bnxt_ulp_irq_restart(struct bnxt *bp, int err); 1098c2ecf20Sopenharmony_civoid bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl); 1108c2ecf20Sopenharmony_cistruct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#endif 113