Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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#include <linux/auxiliary_bus.h>
14
15#define BNXT_MIN_ROCE_CP_RINGS 2
16#define BNXT_MIN_ROCE_STAT_CTXS 1
17
18#define BNXT_MAX_ROCE_MSIX_VF 2
19#define BNXT_MAX_ROCE_MSIX_NPAR_PF 5
20#define BNXT_MAX_ROCE_MSIX 64
21
22struct hwrm_async_event_cmpl;
23struct bnxt;
24
25enum bnxt_auxdev_type {
26 BNXT_AUXDEV_RDMA = 0,
27 BNXT_AUXDEV_FWCTL,
28 __BNXT_AUXDEV_MAX
29};
30
31struct bnxt_aux_priv {
32 struct auxiliary_device aux_dev;
33 struct bnxt_en_dev *edev;
34 int id;
35};
36
37struct bnxt_msix_entry {
38 u32 vector;
39 u32 ring_idx;
40 u32 db_offset;
41};
42
43struct bnxt_ulp_ops {
44 /* async_notifier() cannot sleep (in BH context) */
45 void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
46 void (*ulp_irq_stop)(void *, bool);
47 void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
48};
49
50struct bnxt_fw_msg {
51 void *msg;
52 int msg_len;
53 void *resp;
54 int resp_max_len;
55 int timeout;
56};
57
58struct bnxt_ulp {
59 void *handle;
60 struct bnxt_ulp_ops __rcu *ulp_ops;
61 unsigned long *async_events_bmap;
62 u16 max_async_event_id;
63 u16 msix_requested;
64};
65
66struct bnxt_en_dev {
67 struct net_device *net;
68 struct pci_dev *pdev;
69 struct bnxt_msix_entry msix_entries[BNXT_MAX_ROCE_MSIX];
70 u32 flags;
71 #define BNXT_EN_FLAG_ROCEV1_CAP 0x1
72 #define BNXT_EN_FLAG_ROCEV2_CAP 0x2
73 #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
74 BNXT_EN_FLAG_ROCEV2_CAP)
75 #define BNXT_EN_FLAG_ULP_STOPPED 0x8
76 #define BNXT_EN_FLAG_VF 0x10
77#define BNXT_EN_VF(edev) ((edev)->flags & BNXT_EN_FLAG_VF)
78 #define BNXT_EN_FLAG_ROCE_VF_RES_MGMT 0x20
79 #define BNXT_EN_FLAG_SW_RES_LMT 0x40
80#define BNXT_EN_SW_RES_LMT(edev) ((edev)->flags & BNXT_EN_FLAG_SW_RES_LMT)
81
82 struct bnxt_ulp *ulp_tbl;
83 int l2_db_size; /* Doorbell BAR size in
84 * bytes mapped by L2
85 * driver.
86 */
87 int l2_db_size_nc; /* Doorbell BAR size in
88 * bytes mapped as non-
89 * cacheable.
90 */
91 int l2_db_offset; /* Doorbell offset in
92 * bytes within
93 * l2_db_size_nc.
94 */
95 u16 chip_num;
96 u16 hw_ring_stats_size;
97 u16 pf_port_id;
98 unsigned long en_state; /* Could be checked in
99 * RoCE driver suspend
100 * mode only. Will be
101 * updated in resume.
102 */
103 void __iomem *bar0;
104
105 u16 ulp_num_msix_vec;
106 u16 ulp_num_ctxs;
107
108 /* serialize ulp operations */
109 struct mutex en_dev_lock;
110};
111
112static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
113{
114 if (edev && rcu_access_pointer(edev->ulp_tbl->ulp_ops))
115 return true;
116 return false;
117}
118
119int bnxt_get_ulp_msix_num(struct bnxt *bp);
120int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
121void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
122int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
123void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
124int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
125void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
126void bnxt_ulp_stop(struct bnxt *bp);
127void bnxt_ulp_start(struct bnxt *bp);
128void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
129void bnxt_ulp_irq_stop(struct bnxt *bp);
130void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
131void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
132void bnxt_aux_devices_uninit(struct bnxt *bp);
133void bnxt_aux_devices_del(struct bnxt *bp);
134void bnxt_aux_devices_add(struct bnxt *bp);
135void bnxt_aux_devices_init(struct bnxt *bp);
136int bnxt_register_dev(struct bnxt_en_dev *edev, struct bnxt_ulp_ops *ulp_ops,
137 void *handle);
138void bnxt_unregister_dev(struct bnxt_en_dev *edev);
139int bnxt_send_msg(struct bnxt_en_dev *edev, struct bnxt_fw_msg *fw_msg);
140void bnxt_register_async_events(struct bnxt_en_dev *edev,
141 unsigned long *events_bmap, u16 max_id);
142int bnxt_auxdev_id_alloc(struct bnxt *bp);
143void bnxt_auxdev_id_free(struct bnxt *bp, int id);
144#endif