blob: 74f816e46a3359d07194dc67b6590e0079e76bd2 [file] [log] [blame]
Michael Chana588e452016-12-07 00:26:21 -05001/* 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
20struct hwrm_async_event_cmpl;
21struct bnxt;
22
23struct 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};
30
31struct bnxt_msix_entry {
32 u32 vector;
33 u32 ring_idx;
34 u32 db_offset;
35};
36
37struct bnxt_fw_msg {
38 void *msg;
39 int msg_len;
40 void *resp;
41 int resp_max_len;
42 int timeout;
43};
44
45struct bnxt_ulp {
46 void *handle;
47 struct bnxt_ulp_ops __rcu *ulp_ops;
48 unsigned long *async_events_bmap;
49 u16 max_async_event_id;
50 u16 msix_requested;
51 atomic_t ref_count;
52};
53
54struct bnxt_en_dev {
55 struct net_device *net;
56 struct pci_dev *pdev;
57 u32 flags;
58 #define BNXT_EN_FLAG_ROCEV1_CAP 0x1
59 #define BNXT_EN_FLAG_ROCEV2_CAP 0x2
60 #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
61 BNXT_EN_FLAG_ROCEV2_CAP)
62 const struct bnxt_en_ops *en_ops;
63 struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP];
64};
65
66struct bnxt_en_ops {
67 int (*bnxt_register_device)(struct bnxt_en_dev *, int,
68 struct bnxt_ulp_ops *, void *);
69 int (*bnxt_unregister_device)(struct bnxt_en_dev *, int);
70 int (*bnxt_request_msix)(struct bnxt_en_dev *, int,
71 struct bnxt_msix_entry *, int);
72 int (*bnxt_free_msix)(struct bnxt_en_dev *, int);
73 int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int,
74 struct bnxt_fw_msg *);
75 int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int,
76 unsigned long *, u16);
77};
78
79static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
80{
81 if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops))
82 return true;
83 return false;
84}
85
86void bnxt_subtract_ulp_resources(struct bnxt *bp, int ulp_id);
87void bnxt_ulp_stop(struct bnxt *bp);
88void bnxt_ulp_start(struct bnxt *bp);
89void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
90void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
91struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev);
92
93#endif