blob: 28a0eda926809a573cbd9829e9310162d3cc9054 [file] [log] [blame]
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001/*
2 * Copyright (C) 2005 - 2009 ServerEngines
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17
18#include "be.h"
Sathya Perla8788fdc2009-07-27 22:52:03 +000019#include "be_cmds.h"
Sathya Perla6b7c5b92009-03-11 23:32:03 -070020
Sathya Perla8788fdc2009-07-27 22:52:03 +000021static void be_mcc_notify(struct be_adapter *adapter)
Sathya Perla5fb379e2009-06-18 00:02:59 +000022{
Sathya Perla8788fdc2009-07-27 22:52:03 +000023 struct be_queue_info *mccq = &adapter->mcc_obj.q;
Sathya Perla5fb379e2009-06-18 00:02:59 +000024 u32 val = 0;
25
26 val |= mccq->id & DB_MCCQ_RING_ID_MASK;
27 val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT;
Sathya Perla8788fdc2009-07-27 22:52:03 +000028 iowrite32(val, adapter->db + DB_MCCQ_OFFSET);
Sathya Perla5fb379e2009-06-18 00:02:59 +000029}
30
31/* To check if valid bit is set, check the entire word as we don't know
32 * the endianness of the data (old entry is host endian while a new entry is
33 * little endian) */
Sathya Perlaefd2e402009-07-27 22:53:10 +000034static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl)
Sathya Perla5fb379e2009-06-18 00:02:59 +000035{
36 if (compl->flags != 0) {
37 compl->flags = le32_to_cpu(compl->flags);
38 BUG_ON((compl->flags & CQE_FLAGS_VALID_MASK) == 0);
39 return true;
40 } else {
41 return false;
42 }
43}
44
45/* Need to reset the entire word that houses the valid bit */
Sathya Perlaefd2e402009-07-27 22:53:10 +000046static inline void be_mcc_compl_use(struct be_mcc_compl *compl)
Sathya Perla5fb379e2009-06-18 00:02:59 +000047{
48 compl->flags = 0;
49}
50
Sathya Perla8788fdc2009-07-27 22:52:03 +000051static int be_mcc_compl_process(struct be_adapter *adapter,
Sathya Perlaefd2e402009-07-27 22:53:10 +000052 struct be_mcc_compl *compl)
Sathya Perla5fb379e2009-06-18 00:02:59 +000053{
54 u16 compl_status, extd_status;
55
56 /* Just swap the status to host endian; mcc tag is opaquely copied
57 * from mcc_wrb */
58 be_dws_le_to_cpu(compl, 4);
59
60 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
61 CQE_STATUS_COMPL_MASK;
Sathya Perlab31c50a2009-09-17 10:30:13 -070062 if (compl_status == MCC_STATUS_SUCCESS) {
63 if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) {
64 struct be_cmd_resp_get_stats *resp =
65 adapter->stats.cmd.va;
66 be_dws_le_to_cpu(&resp->hw_stats,
67 sizeof(resp->hw_stats));
68 netdev_stats_update(adapter);
69 }
70 } else if (compl_status != MCC_STATUS_NOT_SUPPORTED) {
Sathya Perla5fb379e2009-06-18 00:02:59 +000071 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
72 CQE_STATUS_EXTD_MASK;
Sathya Perla5f0b8492009-07-27 22:52:56 +000073 dev_warn(&adapter->pdev->dev,
74 "Error in cmd completion: status(compl/extd)=%d/%d\n",
Sathya Perla5fb379e2009-06-18 00:02:59 +000075 compl_status, extd_status);
Sathya Perla5fb379e2009-06-18 00:02:59 +000076 }
Sathya Perlab31c50a2009-09-17 10:30:13 -070077 return compl_status;
Sathya Perla5fb379e2009-06-18 00:02:59 +000078}
79
Sathya Perlaa8f447bd2009-06-18 00:10:27 +000080/* Link state evt is a string of bytes; no need for endian swapping */
Sathya Perla8788fdc2009-07-27 22:52:03 +000081static void be_async_link_state_process(struct be_adapter *adapter,
Sathya Perlaa8f447bd2009-06-18 00:10:27 +000082 struct be_async_event_link_state *evt)
83{
Sathya Perla8788fdc2009-07-27 22:52:03 +000084 be_link_status_update(adapter,
85 evt->port_link_status == ASYNC_EVENT_LINK_UP);
Sathya Perlaa8f447bd2009-06-18 00:10:27 +000086}
87
88static inline bool is_link_state_evt(u32 trailer)
89{
90 return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
91 ASYNC_TRAILER_EVENT_CODE_MASK) ==
92 ASYNC_EVENT_CODE_LINK_STATE);
93}
Sathya Perla5fb379e2009-06-18 00:02:59 +000094
Sathya Perlaefd2e402009-07-27 22:53:10 +000095static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter)
Sathya Perla5fb379e2009-06-18 00:02:59 +000096{
Sathya Perla8788fdc2009-07-27 22:52:03 +000097 struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq;
Sathya Perlaefd2e402009-07-27 22:53:10 +000098 struct be_mcc_compl *compl = queue_tail_node(mcc_cq);
Sathya Perla5fb379e2009-06-18 00:02:59 +000099
100 if (be_mcc_compl_is_new(compl)) {
101 queue_tail_inc(mcc_cq);
102 return compl;
103 }
104 return NULL;
105}
106
Sathya Perlab31c50a2009-09-17 10:30:13 -0700107int be_process_mcc(struct be_adapter *adapter)
Sathya Perla5fb379e2009-06-18 00:02:59 +0000108{
Sathya Perlaefd2e402009-07-27 22:53:10 +0000109 struct be_mcc_compl *compl;
Sathya Perlab31c50a2009-09-17 10:30:13 -0700110 int num = 0, status = 0;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000111
Sathya Perla8788fdc2009-07-27 22:52:03 +0000112 spin_lock_bh(&adapter->mcc_cq_lock);
113 while ((compl = be_mcc_compl_get(adapter))) {
Sathya Perlaa8f447bd2009-06-18 00:10:27 +0000114 if (compl->flags & CQE_FLAGS_ASYNC_MASK) {
115 /* Interpret flags as an async trailer */
116 BUG_ON(!is_link_state_evt(compl->flags));
117
118 /* Interpret compl as a async link evt */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000119 be_async_link_state_process(adapter,
Sathya Perlaa8f447bd2009-06-18 00:10:27 +0000120 (struct be_async_event_link_state *) compl);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700121 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
122 status = be_mcc_compl_process(adapter, compl);
123 atomic_dec(&adapter->mcc_obj.q.used);
Sathya Perla5fb379e2009-06-18 00:02:59 +0000124 }
125 be_mcc_compl_use(compl);
126 num++;
127 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700128
Sathya Perla5fb379e2009-06-18 00:02:59 +0000129 if (num)
Sathya Perla8788fdc2009-07-27 22:52:03 +0000130 be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700131
Sathya Perla8788fdc2009-07-27 22:52:03 +0000132 spin_unlock_bh(&adapter->mcc_cq_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700133 return status;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000134}
135
Sathya Perla6ac7b682009-06-18 00:05:54 +0000136/* Wait till no more pending mcc requests are present */
Sathya Perlab31c50a2009-09-17 10:30:13 -0700137static int be_mcc_wait_compl(struct be_adapter *adapter)
Sathya Perla6ac7b682009-06-18 00:05:54 +0000138{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700139#define mcc_timeout 120000 /* 12s timeout */
140 int i, status;
Sathya Perla6ac7b682009-06-18 00:05:54 +0000141 for (i = 0; i < mcc_timeout; i++) {
Sathya Perlab31c50a2009-09-17 10:30:13 -0700142 status = be_process_mcc(adapter);
143 if (status)
144 return status;
145
Sathya Perla8788fdc2009-07-27 22:52:03 +0000146 if (atomic_read(&adapter->mcc_obj.q.used) == 0)
Sathya Perla6ac7b682009-06-18 00:05:54 +0000147 break;
148 udelay(100);
149 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700150 if (i == mcc_timeout) {
Sathya Perla5f0b8492009-07-27 22:52:56 +0000151 dev_err(&adapter->pdev->dev, "mccq poll timed out\n");
Sathya Perlab31c50a2009-09-17 10:30:13 -0700152 return -1;
153 }
154 return 0;
Sathya Perla6ac7b682009-06-18 00:05:54 +0000155}
156
157/* Notify MCC requests and wait for completion */
Sathya Perlab31c50a2009-09-17 10:30:13 -0700158static int be_mcc_notify_wait(struct be_adapter *adapter)
Sathya Perla6ac7b682009-06-18 00:05:54 +0000159{
Sathya Perla8788fdc2009-07-27 22:52:03 +0000160 be_mcc_notify(adapter);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700161 return be_mcc_wait_compl(adapter);
Sathya Perla6ac7b682009-06-18 00:05:54 +0000162}
163
Sathya Perla5f0b8492009-07-27 22:52:56 +0000164static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700165{
166 int cnt = 0, wait = 5;
167 u32 ready;
168
169 do {
170 ready = ioread32(db) & MPU_MAILBOX_DB_RDY_MASK;
171 if (ready)
172 break;
173
Ajit Khaparde84517482009-09-04 03:12:16 +0000174 if (cnt > 4000000) {
Sathya Perla5f0b8492009-07-27 22:52:56 +0000175 dev_err(&adapter->pdev->dev, "mbox poll timed out\n");
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700176 return -1;
177 }
178
179 if (cnt > 50)
180 wait = 200;
181 cnt += wait;
182 udelay(wait);
183 } while (true);
184
185 return 0;
186}
187
188/*
189 * Insert the mailbox address into the doorbell in two steps
Sathya Perla5fb379e2009-06-18 00:02:59 +0000190 * Polls on the mbox doorbell till a command completion (or a timeout) occurs
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700191 */
Sathya Perlab31c50a2009-09-17 10:30:13 -0700192static int be_mbox_notify_wait(struct be_adapter *adapter)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700193{
194 int status;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700195 u32 val = 0;
Sathya Perla8788fdc2009-07-27 22:52:03 +0000196 void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET;
197 struct be_dma_mem *mbox_mem = &adapter->mbox_mem;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700198 struct be_mcc_mailbox *mbox = mbox_mem->va;
Sathya Perlaefd2e402009-07-27 22:53:10 +0000199 struct be_mcc_compl *compl = &mbox->compl;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700200
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700201 val |= MPU_MAILBOX_DB_HI_MASK;
202 /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */
203 val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2;
204 iowrite32(val, db);
205
206 /* wait for ready to be set */
Sathya Perla5f0b8492009-07-27 22:52:56 +0000207 status = be_mbox_db_ready_wait(adapter, db);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700208 if (status != 0)
209 return status;
210
211 val = 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700212 /* at bits 2 - 31 place mbox dma addr lsb bits 4 - 33 */
213 val |= (u32)(mbox_mem->dma >> 4) << 2;
214 iowrite32(val, db);
215
Sathya Perla5f0b8492009-07-27 22:52:56 +0000216 status = be_mbox_db_ready_wait(adapter, db);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700217 if (status != 0)
218 return status;
219
Sathya Perla5fb379e2009-06-18 00:02:59 +0000220 /* A cq entry has been made now */
Sathya Perlaefd2e402009-07-27 22:53:10 +0000221 if (be_mcc_compl_is_new(compl)) {
222 status = be_mcc_compl_process(adapter, &mbox->compl);
223 be_mcc_compl_use(compl);
Sathya Perla5fb379e2009-06-18 00:02:59 +0000224 if (status)
225 return status;
226 } else {
Sathya Perla5f0b8492009-07-27 22:52:56 +0000227 dev_err(&adapter->pdev->dev, "invalid mailbox completion\n");
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700228 return -1;
229 }
Sathya Perla5fb379e2009-06-18 00:02:59 +0000230 return 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700231}
232
Sathya Perla8788fdc2009-07-27 22:52:03 +0000233static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700234{
Sathya Perla8788fdc2009-07-27 22:52:03 +0000235 u32 sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700236
237 *stage = sem & EP_SEMAPHORE_POST_STAGE_MASK;
238 if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK)
239 return -1;
240 else
241 return 0;
242}
243
Sathya Perla8788fdc2009-07-27 22:52:03 +0000244int be_cmd_POST(struct be_adapter *adapter)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700245{
Sathya Perla43a04fdc2009-10-14 20:21:17 +0000246 u16 stage;
247 int status, timeout = 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700248
Sathya Perla43a04fdc2009-10-14 20:21:17 +0000249 do {
250 status = be_POST_stage_get(adapter, &stage);
251 if (status) {
252 dev_err(&adapter->pdev->dev, "POST error; stage=0x%x\n",
253 stage);
254 return -1;
255 } else if (stage != POST_STAGE_ARMFW_RDY) {
256 set_current_state(TASK_INTERRUPTIBLE);
257 schedule_timeout(2 * HZ);
258 timeout += 2;
259 } else {
260 return 0;
261 }
262 } while (timeout < 20);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700263
Sathya Perla43a04fdc2009-10-14 20:21:17 +0000264 dev_err(&adapter->pdev->dev, "POST timeout; stage=0x%x\n", stage);
265 return -1;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700266}
267
268static inline void *embedded_payload(struct be_mcc_wrb *wrb)
269{
270 return wrb->payload.embedded_payload;
271}
272
273static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
274{
275 return &wrb->payload.sgl[0];
276}
277
278/* Don't touch the hdr after it's prepared */
279static void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
280 bool embedded, u8 sge_cnt)
281{
282 if (embedded)
283 wrb->embedded |= MCC_WRB_EMBEDDED_MASK;
284 else
285 wrb->embedded |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
286 MCC_WRB_SGE_CNT_SHIFT;
287 wrb->payload_length = payload_len;
288 be_dws_cpu_to_le(wrb, 20);
289}
290
291/* Don't touch the hdr after it's prepared */
292static void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
293 u8 subsystem, u8 opcode, int cmd_len)
294{
295 req_hdr->opcode = opcode;
296 req_hdr->subsystem = subsystem;
297 req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr));
298}
299
300static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages,
301 struct be_dma_mem *mem)
302{
303 int i, buf_pages = min(PAGES_4K_SPANNED(mem->va, mem->size), max_pages);
304 u64 dma = (u64)mem->dma;
305
306 for (i = 0; i < buf_pages; i++) {
307 pages[i].lo = cpu_to_le32(dma & 0xFFFFFFFF);
308 pages[i].hi = cpu_to_le32(upper_32_bits(dma));
309 dma += PAGE_SIZE_4K;
310 }
311}
312
313/* Converts interrupt delay in microseconds to multiplier value */
314static u32 eq_delay_to_mult(u32 usec_delay)
315{
316#define MAX_INTR_RATE 651042
317 const u32 round = 10;
318 u32 multiplier;
319
320 if (usec_delay == 0)
321 multiplier = 0;
322 else {
323 u32 interrupt_rate = 1000000 / usec_delay;
324 /* Max delay, corresponding to the lowest interrupt rate */
325 if (interrupt_rate == 0)
326 multiplier = 1023;
327 else {
328 multiplier = (MAX_INTR_RATE - interrupt_rate) * round;
329 multiplier /= interrupt_rate;
330 /* Round the multiplier to the closest value.*/
331 multiplier = (multiplier + round/2) / round;
332 multiplier = min(multiplier, (u32)1023);
333 }
334 }
335 return multiplier;
336}
337
Sathya Perlab31c50a2009-09-17 10:30:13 -0700338static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700339{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700340 struct be_dma_mem *mbox_mem = &adapter->mbox_mem;
341 struct be_mcc_wrb *wrb
342 = &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb;
343 memset(wrb, 0, sizeof(*wrb));
344 return wrb;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700345}
346
Sathya Perlab31c50a2009-09-17 10:30:13 -0700347static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)
Sathya Perla5fb379e2009-06-18 00:02:59 +0000348{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700349 struct be_queue_info *mccq = &adapter->mcc_obj.q;
350 struct be_mcc_wrb *wrb;
351
352 BUG_ON(atomic_read(&mccq->used) >= mccq->len);
353 wrb = queue_head_node(mccq);
354 queue_head_inc(mccq);
355 atomic_inc(&mccq->used);
356 memset(wrb, 0, sizeof(*wrb));
Sathya Perla5fb379e2009-06-18 00:02:59 +0000357 return wrb;
358}
359
Sathya Perla8788fdc2009-07-27 22:52:03 +0000360int be_cmd_eq_create(struct be_adapter *adapter,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700361 struct be_queue_info *eq, int eq_delay)
362{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700363 struct be_mcc_wrb *wrb;
364 struct be_cmd_req_eq_create *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700365 struct be_dma_mem *q_mem = &eq->dma_mem;
366 int status;
367
Sathya Perla8788fdc2009-07-27 22:52:03 +0000368 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700369
370 wrb = wrb_from_mbox(adapter);
371 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700372
373 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
374
375 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
376 OPCODE_COMMON_EQ_CREATE, sizeof(*req));
377
378 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
379
380 AMAP_SET_BITS(struct amap_eq_context, func, req->context,
Sathya Perlaeec368f2009-07-27 22:52:23 +0000381 be_pci_func(adapter));
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700382 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1);
383 /* 4byte eqe*/
384 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0);
385 AMAP_SET_BITS(struct amap_eq_context, count, req->context,
386 __ilog2_u32(eq->len/256));
387 AMAP_SET_BITS(struct amap_eq_context, delaymult, req->context,
388 eq_delay_to_mult(eq_delay));
389 be_dws_cpu_to_le(req->context, sizeof(req->context));
390
391 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
392
Sathya Perlab31c50a2009-09-17 10:30:13 -0700393 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700394 if (!status) {
Sathya Perlab31c50a2009-09-17 10:30:13 -0700395 struct be_cmd_resp_eq_create *resp = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700396 eq->id = le16_to_cpu(resp->eq_id);
397 eq->created = true;
398 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700399
Sathya Perla8788fdc2009-07-27 22:52:03 +0000400 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700401 return status;
402}
403
Sathya Perlab31c50a2009-09-17 10:30:13 -0700404/* Uses mbox */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000405int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700406 u8 type, bool permanent, u32 if_handle)
407{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700408 struct be_mcc_wrb *wrb;
409 struct be_cmd_req_mac_query *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700410 int status;
411
Sathya Perla8788fdc2009-07-27 22:52:03 +0000412 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700413
414 wrb = wrb_from_mbox(adapter);
415 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700416
417 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
418
419 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
420 OPCODE_COMMON_NTWK_MAC_QUERY, sizeof(*req));
421
422 req->type = type;
423 if (permanent) {
424 req->permanent = 1;
425 } else {
Sathya Perlab31c50a2009-09-17 10:30:13 -0700426 req->if_id = cpu_to_le16((u16) if_handle);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700427 req->permanent = 0;
428 }
429
Sathya Perlab31c50a2009-09-17 10:30:13 -0700430 status = be_mbox_notify_wait(adapter);
431 if (!status) {
432 struct be_cmd_resp_mac_query *resp = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700433 memcpy(mac_addr, resp->mac.addr, ETH_ALEN);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700434 }
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700435
Sathya Perla8788fdc2009-07-27 22:52:03 +0000436 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700437 return status;
438}
439
Sathya Perlab31c50a2009-09-17 10:30:13 -0700440/* Uses synchronous MCCQ */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000441int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700442 u32 if_id, u32 *pmac_id)
443{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700444 struct be_mcc_wrb *wrb;
445 struct be_cmd_req_pmac_add *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700446 int status;
447
Sathya Perlab31c50a2009-09-17 10:30:13 -0700448 spin_lock_bh(&adapter->mcc_lock);
449
450 wrb = wrb_from_mccq(adapter);
451 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700452
453 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
454
455 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
456 OPCODE_COMMON_NTWK_PMAC_ADD, sizeof(*req));
457
458 req->if_id = cpu_to_le32(if_id);
459 memcpy(req->mac_address, mac_addr, ETH_ALEN);
460
Sathya Perlab31c50a2009-09-17 10:30:13 -0700461 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700462 if (!status) {
463 struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb);
464 *pmac_id = le32_to_cpu(resp->pmac_id);
465 }
466
Sathya Perlab31c50a2009-09-17 10:30:13 -0700467 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700468 return status;
469}
470
Sathya Perlab31c50a2009-09-17 10:30:13 -0700471/* Uses synchronous MCCQ */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000472int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700473{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700474 struct be_mcc_wrb *wrb;
475 struct be_cmd_req_pmac_del *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700476 int status;
477
Sathya Perlab31c50a2009-09-17 10:30:13 -0700478 spin_lock_bh(&adapter->mcc_lock);
479
480 wrb = wrb_from_mccq(adapter);
481 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700482
483 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
484
485 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
486 OPCODE_COMMON_NTWK_PMAC_DEL, sizeof(*req));
487
488 req->if_id = cpu_to_le32(if_id);
489 req->pmac_id = cpu_to_le32(pmac_id);
490
Sathya Perlab31c50a2009-09-17 10:30:13 -0700491 status = be_mcc_notify_wait(adapter);
492
493 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700494
495 return status;
496}
497
Sathya Perlab31c50a2009-09-17 10:30:13 -0700498/* Uses Mbox */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000499int be_cmd_cq_create(struct be_adapter *adapter,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700500 struct be_queue_info *cq, struct be_queue_info *eq,
501 bool sol_evts, bool no_delay, int coalesce_wm)
502{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700503 struct be_mcc_wrb *wrb;
504 struct be_cmd_req_cq_create *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700505 struct be_dma_mem *q_mem = &cq->dma_mem;
Sathya Perlab31c50a2009-09-17 10:30:13 -0700506 void *ctxt;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700507 int status;
508
Sathya Perla8788fdc2009-07-27 22:52:03 +0000509 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700510
511 wrb = wrb_from_mbox(adapter);
512 req = embedded_payload(wrb);
513 ctxt = &req->context;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700514
515 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
516
517 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
518 OPCODE_COMMON_CQ_CREATE, sizeof(*req));
519
520 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
521
522 AMAP_SET_BITS(struct amap_cq_context, coalescwm, ctxt, coalesce_wm);
523 AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
524 AMAP_SET_BITS(struct amap_cq_context, count, ctxt,
525 __ilog2_u32(cq->len/256));
526 AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1);
527 AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts);
528 AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
529 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id);
Sathya Perla5fb379e2009-06-18 00:02:59 +0000530 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
Sathya Perlaeec368f2009-07-27 22:52:23 +0000531 AMAP_SET_BITS(struct amap_cq_context, func, ctxt, be_pci_func(adapter));
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700532 be_dws_cpu_to_le(ctxt, sizeof(req->context));
533
534 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
535
Sathya Perlab31c50a2009-09-17 10:30:13 -0700536 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700537 if (!status) {
Sathya Perlab31c50a2009-09-17 10:30:13 -0700538 struct be_cmd_resp_cq_create *resp = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700539 cq->id = le16_to_cpu(resp->cq_id);
540 cq->created = true;
541 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700542
Sathya Perla8788fdc2009-07-27 22:52:03 +0000543 spin_unlock(&adapter->mbox_lock);
Sathya Perla5fb379e2009-06-18 00:02:59 +0000544
545 return status;
546}
547
548static u32 be_encoded_q_len(int q_len)
549{
550 u32 len_encoded = fls(q_len); /* log2(len) + 1 */
551 if (len_encoded == 16)
552 len_encoded = 0;
553 return len_encoded;
554}
555
Sathya Perla8788fdc2009-07-27 22:52:03 +0000556int be_cmd_mccq_create(struct be_adapter *adapter,
Sathya Perla5fb379e2009-06-18 00:02:59 +0000557 struct be_queue_info *mccq,
558 struct be_queue_info *cq)
559{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700560 struct be_mcc_wrb *wrb;
561 struct be_cmd_req_mcc_create *req;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000562 struct be_dma_mem *q_mem = &mccq->dma_mem;
Sathya Perlab31c50a2009-09-17 10:30:13 -0700563 void *ctxt;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000564 int status;
565
Sathya Perla8788fdc2009-07-27 22:52:03 +0000566 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700567
568 wrb = wrb_from_mbox(adapter);
569 req = embedded_payload(wrb);
570 ctxt = &req->context;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000571
572 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
573
574 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
575 OPCODE_COMMON_MCC_CREATE, sizeof(*req));
576
577 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
578
Sathya Perlaeec368f2009-07-27 22:52:23 +0000579 AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, be_pci_func(adapter));
Sathya Perla5fb379e2009-06-18 00:02:59 +0000580 AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1);
581 AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt,
582 be_encoded_q_len(mccq->len));
583 AMAP_SET_BITS(struct amap_mcc_context, cq_id, ctxt, cq->id);
584
585 be_dws_cpu_to_le(ctxt, sizeof(req->context));
586
587 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
588
Sathya Perlab31c50a2009-09-17 10:30:13 -0700589 status = be_mbox_notify_wait(adapter);
Sathya Perla5fb379e2009-06-18 00:02:59 +0000590 if (!status) {
591 struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb);
592 mccq->id = le16_to_cpu(resp->id);
593 mccq->created = true;
594 }
Sathya Perla8788fdc2009-07-27 22:52:03 +0000595 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700596
597 return status;
598}
599
Sathya Perla8788fdc2009-07-27 22:52:03 +0000600int be_cmd_txq_create(struct be_adapter *adapter,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700601 struct be_queue_info *txq,
602 struct be_queue_info *cq)
603{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700604 struct be_mcc_wrb *wrb;
605 struct be_cmd_req_eth_tx_create *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700606 struct be_dma_mem *q_mem = &txq->dma_mem;
Sathya Perlab31c50a2009-09-17 10:30:13 -0700607 void *ctxt;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700608 int status;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700609
Sathya Perla8788fdc2009-07-27 22:52:03 +0000610 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700611
612 wrb = wrb_from_mbox(adapter);
613 req = embedded_payload(wrb);
614 ctxt = &req->context;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700615
616 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
617
618 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_TX_CREATE,
619 sizeof(*req));
620
621 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
622 req->ulp_num = BE_ULP1_NUM;
623 req->type = BE_ETH_TX_RING_TYPE_STANDARD;
624
Sathya Perlab31c50a2009-09-17 10:30:13 -0700625 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt,
626 be_encoded_q_len(txq->len));
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700627 AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt,
Sathya Perlaeec368f2009-07-27 22:52:23 +0000628 be_pci_func(adapter));
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700629 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1);
630 AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id);
631
632 be_dws_cpu_to_le(ctxt, sizeof(req->context));
633
634 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
635
Sathya Perlab31c50a2009-09-17 10:30:13 -0700636 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700637 if (!status) {
638 struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb);
639 txq->id = le16_to_cpu(resp->cid);
640 txq->created = true;
641 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700642
Sathya Perla8788fdc2009-07-27 22:52:03 +0000643 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700644
645 return status;
646}
647
Sathya Perlab31c50a2009-09-17 10:30:13 -0700648/* Uses mbox */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000649int be_cmd_rxq_create(struct be_adapter *adapter,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700650 struct be_queue_info *rxq, u16 cq_id, u16 frag_size,
651 u16 max_frame_size, u32 if_id, u32 rss)
652{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700653 struct be_mcc_wrb *wrb;
654 struct be_cmd_req_eth_rx_create *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700655 struct be_dma_mem *q_mem = &rxq->dma_mem;
656 int status;
657
Sathya Perla8788fdc2009-07-27 22:52:03 +0000658 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700659
660 wrb = wrb_from_mbox(adapter);
661 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700662
663 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
664
665 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_RX_CREATE,
666 sizeof(*req));
667
668 req->cq_id = cpu_to_le16(cq_id);
669 req->frag_size = fls(frag_size) - 1;
670 req->num_pages = 2;
671 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
672 req->interface_id = cpu_to_le32(if_id);
673 req->max_frame_size = cpu_to_le16(max_frame_size);
674 req->rss_queue = cpu_to_le32(rss);
675
Sathya Perlab31c50a2009-09-17 10:30:13 -0700676 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700677 if (!status) {
678 struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb);
679 rxq->id = le16_to_cpu(resp->id);
680 rxq->created = true;
681 }
Sathya Perlab31c50a2009-09-17 10:30:13 -0700682
Sathya Perla8788fdc2009-07-27 22:52:03 +0000683 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700684
685 return status;
686}
687
Sathya Perlab31c50a2009-09-17 10:30:13 -0700688/* Generic destroyer function for all types of queues
689 * Uses Mbox
690 */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000691int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700692 int queue_type)
693{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700694 struct be_mcc_wrb *wrb;
695 struct be_cmd_req_q_destroy *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700696 u8 subsys = 0, opcode = 0;
697 int status;
698
Sathya Perla8788fdc2009-07-27 22:52:03 +0000699 spin_lock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700700
Sathya Perlab31c50a2009-09-17 10:30:13 -0700701 wrb = wrb_from_mbox(adapter);
702 req = embedded_payload(wrb);
703
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700704 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
705
706 switch (queue_type) {
707 case QTYPE_EQ:
708 subsys = CMD_SUBSYSTEM_COMMON;
709 opcode = OPCODE_COMMON_EQ_DESTROY;
710 break;
711 case QTYPE_CQ:
712 subsys = CMD_SUBSYSTEM_COMMON;
713 opcode = OPCODE_COMMON_CQ_DESTROY;
714 break;
715 case QTYPE_TXQ:
716 subsys = CMD_SUBSYSTEM_ETH;
717 opcode = OPCODE_ETH_TX_DESTROY;
718 break;
719 case QTYPE_RXQ:
720 subsys = CMD_SUBSYSTEM_ETH;
721 opcode = OPCODE_ETH_RX_DESTROY;
722 break;
Sathya Perla5fb379e2009-06-18 00:02:59 +0000723 case QTYPE_MCCQ:
724 subsys = CMD_SUBSYSTEM_COMMON;
725 opcode = OPCODE_COMMON_MCC_DESTROY;
726 break;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700727 default:
Sathya Perla5f0b8492009-07-27 22:52:56 +0000728 BUG();
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700729 }
730 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req));
731 req->id = cpu_to_le16(q->id);
732
Sathya Perlab31c50a2009-09-17 10:30:13 -0700733 status = be_mbox_notify_wait(adapter);
Sathya Perla5f0b8492009-07-27 22:52:56 +0000734
Sathya Perla8788fdc2009-07-27 22:52:03 +0000735 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700736
737 return status;
738}
739
Sathya Perlab31c50a2009-09-17 10:30:13 -0700740/* Create an rx filtering policy configuration on an i/f
741 * Uses mbox
742 */
Sathya Perla73d540f2009-10-14 20:20:42 +0000743int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
744 u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700745{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700746 struct be_mcc_wrb *wrb;
747 struct be_cmd_req_if_create *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700748 int status;
749
Sathya Perla8788fdc2009-07-27 22:52:03 +0000750 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700751
752 wrb = wrb_from_mbox(adapter);
753 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700754
755 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
756
757 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
758 OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req));
759
Sathya Perla73d540f2009-10-14 20:20:42 +0000760 req->capability_flags = cpu_to_le32(cap_flags);
761 req->enable_flags = cpu_to_le32(en_flags);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700762 req->pmac_invalid = pmac_invalid;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700763 if (!pmac_invalid)
764 memcpy(req->mac_addr, mac, ETH_ALEN);
765
Sathya Perlab31c50a2009-09-17 10:30:13 -0700766 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700767 if (!status) {
768 struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
769 *if_handle = le32_to_cpu(resp->interface_id);
770 if (!pmac_invalid)
771 *pmac_id = le32_to_cpu(resp->pmac_id);
772 }
773
Sathya Perla8788fdc2009-07-27 22:52:03 +0000774 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700775 return status;
776}
777
Sathya Perlab31c50a2009-09-17 10:30:13 -0700778/* Uses mbox */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000779int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700780{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700781 struct be_mcc_wrb *wrb;
782 struct be_cmd_req_if_destroy *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700783 int status;
784
Sathya Perla8788fdc2009-07-27 22:52:03 +0000785 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700786
787 wrb = wrb_from_mbox(adapter);
788 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700789
790 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
791
792 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
793 OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req));
794
795 req->interface_id = cpu_to_le32(interface_id);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700796
797 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700798
Sathya Perla8788fdc2009-07-27 22:52:03 +0000799 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700800
801 return status;
802}
803
804/* Get stats is a non embedded command: the request is not embedded inside
805 * WRB but is a separate dma memory block
Sathya Perlab31c50a2009-09-17 10:30:13 -0700806 * Uses asynchronous MCC
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700807 */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000808int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700809{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700810 struct be_mcc_wrb *wrb;
811 struct be_cmd_req_get_stats *req;
812 struct be_sge *sge;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700813
Sathya Perlab31c50a2009-09-17 10:30:13 -0700814 spin_lock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700815
Sathya Perlab31c50a2009-09-17 10:30:13 -0700816 wrb = wrb_from_mccq(adapter);
817 req = nonemb_cmd->va;
818 sge = nonembedded_sgl(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700819
820 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700821 wrb->tag0 = OPCODE_ETH_GET_STATISTICS;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700822
823 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
824 OPCODE_ETH_GET_STATISTICS, sizeof(*req));
825 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
826 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
827 sge->len = cpu_to_le32(nonemb_cmd->size);
828
Sathya Perlab31c50a2009-09-17 10:30:13 -0700829 be_mcc_notify(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700830
Sathya Perlab31c50a2009-09-17 10:30:13 -0700831 spin_unlock_bh(&adapter->mcc_lock);
832 return 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700833}
834
Sathya Perlab31c50a2009-09-17 10:30:13 -0700835/* Uses synchronous mcc */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000836int be_cmd_link_status_query(struct be_adapter *adapter,
Sathya Perlaa8f447bd2009-06-18 00:10:27 +0000837 bool *link_up)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700838{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700839 struct be_mcc_wrb *wrb;
840 struct be_cmd_req_link_status *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700841 int status;
842
Sathya Perlab31c50a2009-09-17 10:30:13 -0700843 spin_lock_bh(&adapter->mcc_lock);
844
845 wrb = wrb_from_mccq(adapter);
846 req = embedded_payload(wrb);
Sathya Perlaa8f447bd2009-06-18 00:10:27 +0000847
848 *link_up = false;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700849
850 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
851
852 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
853 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req));
854
Sathya Perlab31c50a2009-09-17 10:30:13 -0700855 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700856 if (!status) {
857 struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
Sathya Perlaa8f447bd2009-06-18 00:10:27 +0000858 if (resp->mac_speed != PHY_LINK_SPEED_ZERO)
859 *link_up = true;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700860 }
861
Sathya Perlab31c50a2009-09-17 10:30:13 -0700862 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700863 return status;
864}
865
Sathya Perlab31c50a2009-09-17 10:30:13 -0700866/* Uses Mbox */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000867int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700868{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700869 struct be_mcc_wrb *wrb;
870 struct be_cmd_req_get_fw_version *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700871 int status;
872
Sathya Perla8788fdc2009-07-27 22:52:03 +0000873 spin_lock(&adapter->mbox_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700874
875 wrb = wrb_from_mbox(adapter);
876 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700877
878 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
879
880 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
881 OPCODE_COMMON_GET_FW_VERSION, sizeof(*req));
882
Sathya Perlab31c50a2009-09-17 10:30:13 -0700883 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700884 if (!status) {
885 struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb);
886 strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN);
887 }
888
Sathya Perla8788fdc2009-07-27 22:52:03 +0000889 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700890 return status;
891}
892
Sathya Perlab31c50a2009-09-17 10:30:13 -0700893/* set the EQ delay interval of an EQ to specified value
894 * Uses async mcc
895 */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000896int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700897{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700898 struct be_mcc_wrb *wrb;
899 struct be_cmd_req_modify_eq_delay *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700900
Sathya Perlab31c50a2009-09-17 10:30:13 -0700901 spin_lock_bh(&adapter->mcc_lock);
902
903 wrb = wrb_from_mccq(adapter);
904 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700905
906 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
907
908 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
909 OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req));
910
911 req->num_eq = cpu_to_le32(1);
912 req->delay[0].eq_id = cpu_to_le32(eq_id);
913 req->delay[0].phase = 0;
914 req->delay[0].delay_multiplier = cpu_to_le32(eqd);
915
Sathya Perlab31c50a2009-09-17 10:30:13 -0700916 be_mcc_notify(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700917
Sathya Perlab31c50a2009-09-17 10:30:13 -0700918 spin_unlock_bh(&adapter->mcc_lock);
919 return 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700920}
921
Sathya Perlab31c50a2009-09-17 10:30:13 -0700922/* Uses sycnhronous mcc */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000923int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700924 u32 num, bool untagged, bool promiscuous)
925{
Sathya Perlab31c50a2009-09-17 10:30:13 -0700926 struct be_mcc_wrb *wrb;
927 struct be_cmd_req_vlan_config *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700928 int status;
929
Sathya Perlab31c50a2009-09-17 10:30:13 -0700930 spin_lock_bh(&adapter->mcc_lock);
931
932 wrb = wrb_from_mccq(adapter);
933 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700934
935 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
936
937 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
938 OPCODE_COMMON_NTWK_VLAN_CONFIG, sizeof(*req));
939
940 req->interface_id = if_id;
941 req->promiscuous = promiscuous;
942 req->untagged = untagged;
943 req->num_vlan = num;
944 if (!promiscuous) {
945 memcpy(req->normal_vlan, vtag_array,
946 req->num_vlan * sizeof(vtag_array[0]));
947 }
948
Sathya Perlab31c50a2009-09-17 10:30:13 -0700949 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700950
Sathya Perlab31c50a2009-09-17 10:30:13 -0700951 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700952 return status;
953}
954
Sathya Perlab31c50a2009-09-17 10:30:13 -0700955/* Uses MCC for this command as it may be called in BH context
956 * Uses synchronous mcc
957 */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000958int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700959{
Sathya Perla6ac7b682009-06-18 00:05:54 +0000960 struct be_mcc_wrb *wrb;
961 struct be_cmd_req_promiscuous_config *req;
Sathya Perlab31c50a2009-09-17 10:30:13 -0700962 int status;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700963
Sathya Perla8788fdc2009-07-27 22:52:03 +0000964 spin_lock_bh(&adapter->mcc_lock);
Sathya Perla6ac7b682009-06-18 00:05:54 +0000965
Sathya Perlab31c50a2009-09-17 10:30:13 -0700966 wrb = wrb_from_mccq(adapter);
Sathya Perla6ac7b682009-06-18 00:05:54 +0000967 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700968
969 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
970
971 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
972 OPCODE_ETH_PROMISCUOUS, sizeof(*req));
973
974 if (port_num)
975 req->port1_promiscuous = en;
976 else
977 req->port0_promiscuous = en;
978
Sathya Perlab31c50a2009-09-17 10:30:13 -0700979 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700980
Sathya Perla8788fdc2009-07-27 22:52:03 +0000981 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perlab31c50a2009-09-17 10:30:13 -0700982 return status;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700983}
984
Sathya Perla6ac7b682009-06-18 00:05:54 +0000985/*
Sathya Perlab31c50a2009-09-17 10:30:13 -0700986 * Uses MCC for this command as it may be called in BH context
Sathya Perla6ac7b682009-06-18 00:05:54 +0000987 * (mc == NULL) => multicast promiscous
988 */
Sathya Perla8788fdc2009-07-27 22:52:03 +0000989int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
Sathya Perla24307ee2009-06-18 00:09:25 +0000990 struct dev_mc_list *mc_list, u32 mc_count)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700991{
Sathya Perla6ac7b682009-06-18 00:05:54 +0000992#define BE_MAX_MC 32 /* set mcast promisc if > 32 */
993 struct be_mcc_wrb *wrb;
994 struct be_cmd_req_mcast_mac_config *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700995
Sathya Perla8788fdc2009-07-27 22:52:03 +0000996 spin_lock_bh(&adapter->mcc_lock);
Sathya Perla6ac7b682009-06-18 00:05:54 +0000997
Sathya Perlab31c50a2009-09-17 10:30:13 -0700998 wrb = wrb_from_mccq(adapter);
Sathya Perla6ac7b682009-06-18 00:05:54 +0000999 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001000
1001 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1002
1003 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1004 OPCODE_COMMON_NTWK_MULTICAST_SET, sizeof(*req));
1005
1006 req->interface_id = if_id;
Sathya Perla24307ee2009-06-18 00:09:25 +00001007 if (mc_list && mc_count <= BE_MAX_MC) {
1008 int i;
1009 struct dev_mc_list *mc;
1010
1011 req->num_mac = cpu_to_le16(mc_count);
1012
1013 for (mc = mc_list, i = 0; mc; mc = mc->next, i++)
1014 memcpy(req->mac[i].byte, mc->dmi_addr, ETH_ALEN);
1015 } else {
1016 req->promiscuous = 1;
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001017 }
1018
Sathya Perla8788fdc2009-07-27 22:52:03 +00001019 be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001020
Sathya Perla8788fdc2009-07-27 22:52:03 +00001021 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6ac7b682009-06-18 00:05:54 +00001022
1023 return 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001024}
1025
Sathya Perlab31c50a2009-09-17 10:30:13 -07001026/* Uses synchrounous mcc */
Sathya Perla8788fdc2009-07-27 22:52:03 +00001027int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc)
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001028{
Sathya Perlab31c50a2009-09-17 10:30:13 -07001029 struct be_mcc_wrb *wrb;
1030 struct be_cmd_req_set_flow_control *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001031 int status;
1032
Sathya Perlab31c50a2009-09-17 10:30:13 -07001033 spin_lock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001034
Sathya Perlab31c50a2009-09-17 10:30:13 -07001035 wrb = wrb_from_mccq(adapter);
1036 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001037
1038 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1039
1040 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1041 OPCODE_COMMON_SET_FLOW_CONTROL, sizeof(*req));
1042
1043 req->tx_flow_control = cpu_to_le16((u16)tx_fc);
1044 req->rx_flow_control = cpu_to_le16((u16)rx_fc);
1045
Sathya Perlab31c50a2009-09-17 10:30:13 -07001046 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001047
Sathya Perlab31c50a2009-09-17 10:30:13 -07001048 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001049 return status;
1050}
1051
Sathya Perlab31c50a2009-09-17 10:30:13 -07001052/* Uses sycn mcc */
Sathya Perla8788fdc2009-07-27 22:52:03 +00001053int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc)
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001054{
Sathya Perlab31c50a2009-09-17 10:30:13 -07001055 struct be_mcc_wrb *wrb;
1056 struct be_cmd_req_get_flow_control *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001057 int status;
1058
Sathya Perlab31c50a2009-09-17 10:30:13 -07001059 spin_lock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001060
Sathya Perlab31c50a2009-09-17 10:30:13 -07001061 wrb = wrb_from_mccq(adapter);
1062 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001063
1064 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1065
1066 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1067 OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req));
1068
Sathya Perlab31c50a2009-09-17 10:30:13 -07001069 status = be_mcc_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001070 if (!status) {
1071 struct be_cmd_resp_get_flow_control *resp =
1072 embedded_payload(wrb);
1073 *tx_fc = le16_to_cpu(resp->tx_flow_control);
1074 *rx_fc = le16_to_cpu(resp->rx_flow_control);
1075 }
1076
Sathya Perlab31c50a2009-09-17 10:30:13 -07001077 spin_unlock_bh(&adapter->mcc_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001078 return status;
1079}
1080
Sathya Perlab31c50a2009-09-17 10:30:13 -07001081/* Uses mbox */
Ajit Khapardedcb9b562009-09-30 21:58:22 -07001082int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, u32 *cap)
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001083{
Sathya Perlab31c50a2009-09-17 10:30:13 -07001084 struct be_mcc_wrb *wrb;
1085 struct be_cmd_req_query_fw_cfg *req;
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001086 int status;
1087
Sathya Perla8788fdc2009-07-27 22:52:03 +00001088 spin_lock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001089
Sathya Perlab31c50a2009-09-17 10:30:13 -07001090 wrb = wrb_from_mbox(adapter);
1091 req = embedded_payload(wrb);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001092
1093 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1094
1095 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1096 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req));
1097
Sathya Perlab31c50a2009-09-17 10:30:13 -07001098 status = be_mbox_notify_wait(adapter);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001099 if (!status) {
1100 struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb);
1101 *port_num = le32_to_cpu(resp->phys_port);
Ajit Khapardedcb9b562009-09-30 21:58:22 -07001102 *cap = le32_to_cpu(resp->function_cap);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001103 }
1104
Sathya Perla8788fdc2009-07-27 22:52:03 +00001105 spin_unlock(&adapter->mbox_lock);
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001106 return status;
1107}
sarveshwarb14074ea2009-08-05 13:05:24 -07001108
Sathya Perlab31c50a2009-09-17 10:30:13 -07001109/* Uses mbox */
sarveshwarb14074ea2009-08-05 13:05:24 -07001110int be_cmd_reset_function(struct be_adapter *adapter)
1111{
Sathya Perlab31c50a2009-09-17 10:30:13 -07001112 struct be_mcc_wrb *wrb;
1113 struct be_cmd_req_hdr *req;
sarveshwarb14074ea2009-08-05 13:05:24 -07001114 int status;
1115
1116 spin_lock(&adapter->mbox_lock);
1117
Sathya Perlab31c50a2009-09-17 10:30:13 -07001118 wrb = wrb_from_mbox(adapter);
1119 req = embedded_payload(wrb);
sarveshwarb14074ea2009-08-05 13:05:24 -07001120
1121 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1122
1123 be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON,
1124 OPCODE_COMMON_FUNCTION_RESET, sizeof(*req));
1125
Sathya Perlab31c50a2009-09-17 10:30:13 -07001126 status = be_mbox_notify_wait(adapter);
sarveshwarb14074ea2009-08-05 13:05:24 -07001127
1128 spin_unlock(&adapter->mbox_lock);
1129 return status;
1130}
Ajit Khaparde84517482009-09-04 03:12:16 +00001131
1132int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1133 u32 flash_type, u32 flash_opcode, u32 buf_size)
1134{
Sathya Perlab31c50a2009-09-17 10:30:13 -07001135 struct be_mcc_wrb *wrb;
Ajit Khaparde84517482009-09-04 03:12:16 +00001136 struct be_cmd_write_flashrom *req = cmd->va;
Sathya Perlab31c50a2009-09-17 10:30:13 -07001137 struct be_sge *sge;
Ajit Khaparde84517482009-09-04 03:12:16 +00001138 int status;
1139
Sathya Perlab31c50a2009-09-17 10:30:13 -07001140 spin_lock_bh(&adapter->mcc_lock);
1141
1142 wrb = wrb_from_mccq(adapter);
Sathya Perlab31c50a2009-09-17 10:30:13 -07001143 sge = nonembedded_sgl(wrb);
1144
Ajit Khaparde84517482009-09-04 03:12:16 +00001145 be_wrb_hdr_prepare(wrb, cmd->size, false, 1);
1146
1147 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1148 OPCODE_COMMON_WRITE_FLASHROM, cmd->size);
1149 sge->pa_hi = cpu_to_le32(upper_32_bits(cmd->dma));
1150 sge->pa_lo = cpu_to_le32(cmd->dma & 0xFFFFFFFF);
1151 sge->len = cpu_to_le32(cmd->size);
1152
1153 req->params.op_type = cpu_to_le32(flash_type);
1154 req->params.op_code = cpu_to_le32(flash_opcode);
1155 req->params.data_buf_size = cpu_to_le32(buf_size);
1156
Sathya Perlab31c50a2009-09-17 10:30:13 -07001157 status = be_mcc_notify_wait(adapter);
Ajit Khaparde84517482009-09-04 03:12:16 +00001158
Sathya Perlab31c50a2009-09-17 10:30:13 -07001159 spin_unlock_bh(&adapter->mcc_lock);
Ajit Khaparde84517482009-09-04 03:12:16 +00001160 return status;
1161}