2
* Linux network driver for Brocade Converged Network Adapter.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License (GPL) Version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
14
* Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
23
static void bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg *lldp_cfg);
24
static void bfa_cee_format_cee_cfg(void *buffer);
27
bfa_cee_format_cee_cfg(void *buffer)
29
struct bfa_cee_attr *cee_cfg = buffer;
30
bfa_cee_format_lldp_cfg(&cee_cfg->lldp_remote);
34
bfa_cee_stats_swap(struct bfa_cee_stats *stats)
36
u32 *buffer = (u32 *)stats;
39
for (i = 0; i < (sizeof(struct bfa_cee_stats) / sizeof(u32));
41
buffer[i] = ntohl(buffer[i]);
46
bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg *lldp_cfg)
48
lldp_cfg->time_to_live =
49
ntohs(lldp_cfg->time_to_live);
50
lldp_cfg->enabled_system_cap =
51
ntohs(lldp_cfg->enabled_system_cap);
55
* bfa_cee_attr_meminfo()
57
* @brief Returns the size of the DMA memory needed by CEE attributes
61
* @return Size of DMA region
64
bfa_cee_attr_meminfo(void)
66
return roundup(sizeof(struct bfa_cee_attr), BFA_DMA_ALIGN_SZ);
69
* bfa_cee_stats_meminfo()
71
* @brief Returns the size of the DMA memory needed by CEE stats
75
* @return Size of DMA region
78
bfa_cee_stats_meminfo(void)
80
return roundup(sizeof(struct bfa_cee_stats), BFA_DMA_ALIGN_SZ);
84
* bfa_cee_get_attr_isr()
86
* @brief CEE ISR for get-attributes responses from f/w
88
* @param[in] cee - Pointer to the CEE module
89
* status - Return status from the f/w
94
bfa_cee_get_attr_isr(struct bfa_cee *cee, enum bfa_status status)
96
cee->get_attr_status = status;
97
if (status == BFA_STATUS_OK) {
98
memcpy(cee->attr, cee->attr_dma.kva,
99
sizeof(struct bfa_cee_attr));
100
bfa_cee_format_cee_cfg(cee->attr);
102
cee->get_attr_pending = false;
103
if (cee->cbfn.get_attr_cbfn)
104
cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
108
* bfa_cee_get_attr_isr()
110
* @brief CEE ISR for get-stats responses from f/w
112
* @param[in] cee - Pointer to the CEE module
113
* status - Return status from the f/w
118
bfa_cee_get_stats_isr(struct bfa_cee *cee, enum bfa_status status)
120
cee->get_stats_status = status;
121
if (status == BFA_STATUS_OK) {
122
memcpy(cee->stats, cee->stats_dma.kva,
123
sizeof(struct bfa_cee_stats));
124
bfa_cee_stats_swap(cee->stats);
126
cee->get_stats_pending = false;
127
if (cee->cbfn.get_stats_cbfn)
128
cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
132
* bfa_cee_get_attr_isr()
134
* @brief CEE ISR for reset-stats responses from f/w
136
* @param[in] cee - Pointer to the CEE module
137
* status - Return status from the f/w
142
bfa_cee_reset_stats_isr(struct bfa_cee *cee, enum bfa_status status)
144
cee->reset_stats_status = status;
145
cee->reset_stats_pending = false;
146
if (cee->cbfn.reset_stats_cbfn)
147
cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
150
* bfa_nw_cee_meminfo()
152
* @brief Returns the size of the DMA memory needed by CEE module
156
* @return Size of DMA region
159
bfa_nw_cee_meminfo(void)
161
return bfa_cee_attr_meminfo() + bfa_cee_stats_meminfo();
165
* bfa_nw_cee_mem_claim()
167
* @brief Initialized CEE DMA Memory
169
* @param[in] cee CEE module pointer
170
* dma_kva Kernel Virtual Address of CEE DMA Memory
171
* dma_pa Physical Address of CEE DMA Memory
176
bfa_nw_cee_mem_claim(struct bfa_cee *cee, u8 *dma_kva, u64 dma_pa)
178
cee->attr_dma.kva = dma_kva;
179
cee->attr_dma.pa = dma_pa;
180
cee->stats_dma.kva = dma_kva + bfa_cee_attr_meminfo();
181
cee->stats_dma.pa = dma_pa + bfa_cee_attr_meminfo();
182
cee->attr = (struct bfa_cee_attr *) dma_kva;
183
cee->stats = (struct bfa_cee_stats *)
184
(dma_kva + bfa_cee_attr_meminfo());
190
* @brief Handles Mail-box interrupts for CEE module.
192
* @param[in] Pointer to the CEE module data structure.
198
bfa_cee_isr(void *cbarg, struct bfi_mbmsg *m)
200
union bfi_cee_i2h_msg_u *msg;
201
struct bfi_cee_get_rsp *get_rsp;
202
struct bfa_cee *cee = (struct bfa_cee *) cbarg;
203
msg = (union bfi_cee_i2h_msg_u *) m;
204
get_rsp = (struct bfi_cee_get_rsp *) m;
205
switch (msg->mh.msg_id) {
206
case BFI_CEE_I2H_GET_CFG_RSP:
207
bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
209
case BFI_CEE_I2H_GET_STATS_RSP:
210
bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
212
case BFI_CEE_I2H_RESET_STATS_RSP:
213
bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
223
* @brief CEE module heart-beat failure handler.
224
* @brief CEE module IOC event handler.
226
* @param[in] IOC event type
232
bfa_cee_notify(void *arg, enum bfa_ioc_event event)
235
cee = (struct bfa_cee *) arg;
238
case BFA_IOC_E_DISABLED:
239
case BFA_IOC_E_FAILED:
240
if (cee->get_attr_pending == true) {
241
cee->get_attr_status = BFA_STATUS_FAILED;
242
cee->get_attr_pending = false;
243
if (cee->cbfn.get_attr_cbfn) {
244
cee->cbfn.get_attr_cbfn(
245
cee->cbfn.get_attr_cbarg,
249
if (cee->get_stats_pending == true) {
250
cee->get_stats_status = BFA_STATUS_FAILED;
251
cee->get_stats_pending = false;
252
if (cee->cbfn.get_stats_cbfn) {
253
cee->cbfn.get_stats_cbfn(
254
cee->cbfn.get_stats_cbarg,
258
if (cee->reset_stats_pending == true) {
259
cee->reset_stats_status = BFA_STATUS_FAILED;
260
cee->reset_stats_pending = false;
261
if (cee->cbfn.reset_stats_cbfn) {
262
cee->cbfn.reset_stats_cbfn(
263
cee->cbfn.reset_stats_cbarg,
275
* bfa_nw_cee_attach()
277
* @brief CEE module-attach API
279
* @param[in] cee - Pointer to the CEE module data structure
280
* ioc - Pointer to the ioc module data structure
281
* dev - Pointer to the device driver module data structure
282
* The device driver specific mbox ISR functions have
283
* this pointer as one of the parameters.
288
bfa_nw_cee_attach(struct bfa_cee *cee, struct bfa_ioc *ioc,
291
BUG_ON(!(cee != NULL));
295
bfa_nw_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
296
bfa_q_qe_init(&cee->ioc_notify);
297
bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
298
bfa_nw_ioc_notify_register(cee->ioc, &cee->ioc_notify);