Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1 | /* |
| 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 19 | #include "be_cmds.h" |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 20 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 21 | static void be_mcc_notify(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 22 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 23 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 24 | u32 val = 0; |
| 25 | |
| 26 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; |
| 27 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 28 | iowrite32(val, adapter->db + DB_MCCQ_OFFSET); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 29 | } |
| 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 Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 34 | static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 35 | { |
| 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 Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 46 | static inline void be_mcc_compl_use(struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 47 | { |
| 48 | compl->flags = 0; |
| 49 | } |
| 50 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 51 | static int be_mcc_compl_process(struct be_adapter *adapter, |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 52 | struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 53 | { |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 62 | 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 71 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & |
| 72 | CQE_STATUS_EXTD_MASK; |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 73 | dev_warn(&adapter->pdev->dev, |
| 74 | "Error in cmd completion: status(compl/extd)=%d/%d\n", |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 75 | compl_status, extd_status); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 76 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 77 | return compl_status; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 80 | /* Link state evt is a string of bytes; no need for endian swapping */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 81 | static void be_async_link_state_process(struct be_adapter *adapter, |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 82 | struct be_async_event_link_state *evt) |
| 83 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 84 | be_link_status_update(adapter, |
| 85 | evt->port_link_status == ASYNC_EVENT_LINK_UP); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 94 | |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 95 | static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 96 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 97 | struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 98 | struct be_mcc_compl *compl = queue_tail_node(mcc_cq); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 99 | |
| 100 | if (be_mcc_compl_is_new(compl)) { |
| 101 | queue_tail_inc(mcc_cq); |
| 102 | return compl; |
| 103 | } |
| 104 | return NULL; |
| 105 | } |
| 106 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 107 | int be_process_mcc(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 108 | { |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 109 | struct be_mcc_compl *compl; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 110 | int num = 0, status = 0; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 111 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 112 | spin_lock_bh(&adapter->mcc_cq_lock); |
| 113 | while ((compl = be_mcc_compl_get(adapter))) { |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 114 | 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 119 | be_async_link_state_process(adapter, |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 120 | (struct be_async_event_link_state *) compl); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 121 | } 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 124 | } |
| 125 | be_mcc_compl_use(compl); |
| 126 | num++; |
| 127 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 128 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 129 | if (num) |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 130 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 131 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 132 | spin_unlock_bh(&adapter->mcc_cq_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 133 | return status; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 136 | /* Wait till no more pending mcc requests are present */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 137 | static int be_mcc_wait_compl(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 138 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 139 | #define mcc_timeout 120000 /* 12s timeout */ |
| 140 | int i, status; |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 141 | for (i = 0; i < mcc_timeout; i++) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 142 | status = be_process_mcc(adapter); |
| 143 | if (status) |
| 144 | return status; |
| 145 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 146 | if (atomic_read(&adapter->mcc_obj.q.used) == 0) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 147 | break; |
| 148 | udelay(100); |
| 149 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 150 | if (i == mcc_timeout) { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 151 | dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 152 | return -1; |
| 153 | } |
| 154 | return 0; |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | /* Notify MCC requests and wait for completion */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 158 | static int be_mcc_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 159 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 160 | be_mcc_notify(adapter); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 161 | return be_mcc_wait_compl(adapter); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 164 | static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 165 | { |
| 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 Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 174 | if (cnt > 4000000) { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 175 | dev_err(&adapter->pdev->dev, "mbox poll timed out\n"); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 176 | 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 190 | * Polls on the mbox doorbell till a command completion (or a timeout) occurs |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 191 | */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 192 | static int be_mbox_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 193 | { |
| 194 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 195 | u32 val = 0; |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 196 | void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET; |
| 197 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 198 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 199 | struct be_mcc_compl *compl = &mbox->compl; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 200 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 201 | 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 Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 207 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 208 | if (status != 0) |
| 209 | return status; |
| 210 | |
| 211 | val = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 212 | /* 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 Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 216 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 217 | if (status != 0) |
| 218 | return status; |
| 219 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 220 | /* A cq entry has been made now */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 221 | if (be_mcc_compl_is_new(compl)) { |
| 222 | status = be_mcc_compl_process(adapter, &mbox->compl); |
| 223 | be_mcc_compl_use(compl); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 224 | if (status) |
| 225 | return status; |
| 226 | } else { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 227 | dev_err(&adapter->pdev->dev, "invalid mailbox completion\n"); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 228 | return -1; |
| 229 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 230 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 233 | static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 234 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 235 | u32 sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 236 | |
| 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 244 | int be_cmd_POST(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 245 | { |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame^] | 246 | u16 stage; |
| 247 | int status, timeout = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 248 | |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame^] | 249 | 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 Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 263 | |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame^] | 264 | dev_err(&adapter->pdev->dev, "POST timeout; stage=0x%x\n", stage); |
| 265 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static inline void *embedded_payload(struct be_mcc_wrb *wrb) |
| 269 | { |
| 270 | return wrb->payload.embedded_payload; |
| 271 | } |
| 272 | |
| 273 | static 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 */ |
| 279 | static 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 */ |
| 292 | static 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 | |
| 300 | static 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 */ |
| 314 | static 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 338 | static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 339 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 340 | 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 Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 347 | static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 348 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 349 | 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 357 | return wrb; |
| 358 | } |
| 359 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 360 | int be_cmd_eq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 361 | struct be_queue_info *eq, int eq_delay) |
| 362 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 363 | struct be_mcc_wrb *wrb; |
| 364 | struct be_cmd_req_eq_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 365 | struct be_dma_mem *q_mem = &eq->dma_mem; |
| 366 | int status; |
| 367 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 368 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 369 | |
| 370 | wrb = wrb_from_mbox(adapter); |
| 371 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 372 | |
| 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 Perla | eec368f | 2009-07-27 22:52:23 +0000 | [diff] [blame] | 381 | be_pci_func(adapter)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 382 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 393 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 394 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 395 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 396 | eq->id = le16_to_cpu(resp->eq_id); |
| 397 | eq->created = true; |
| 398 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 399 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 400 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 401 | return status; |
| 402 | } |
| 403 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 404 | /* Uses mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 405 | int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 406 | u8 type, bool permanent, u32 if_handle) |
| 407 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 408 | struct be_mcc_wrb *wrb; |
| 409 | struct be_cmd_req_mac_query *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 410 | int status; |
| 411 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 412 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 413 | |
| 414 | wrb = wrb_from_mbox(adapter); |
| 415 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 416 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 426 | req->if_id = cpu_to_le16((u16) if_handle); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 427 | req->permanent = 0; |
| 428 | } |
| 429 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 430 | status = be_mbox_notify_wait(adapter); |
| 431 | if (!status) { |
| 432 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 433 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 434 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 435 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 436 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 437 | return status; |
| 438 | } |
| 439 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 440 | /* Uses synchronous MCCQ */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 441 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 442 | u32 if_id, u32 *pmac_id) |
| 443 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 444 | struct be_mcc_wrb *wrb; |
| 445 | struct be_cmd_req_pmac_add *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 446 | int status; |
| 447 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 448 | spin_lock_bh(&adapter->mcc_lock); |
| 449 | |
| 450 | wrb = wrb_from_mccq(adapter); |
| 451 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 452 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 461 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 462 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 467 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 468 | return status; |
| 469 | } |
| 470 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 471 | /* Uses synchronous MCCQ */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 472 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 473 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 474 | struct be_mcc_wrb *wrb; |
| 475 | struct be_cmd_req_pmac_del *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 476 | int status; |
| 477 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 478 | spin_lock_bh(&adapter->mcc_lock); |
| 479 | |
| 480 | wrb = wrb_from_mccq(adapter); |
| 481 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 482 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 491 | status = be_mcc_notify_wait(adapter); |
| 492 | |
| 493 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 494 | |
| 495 | return status; |
| 496 | } |
| 497 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 498 | /* Uses Mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 499 | int be_cmd_cq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 500 | struct be_queue_info *cq, struct be_queue_info *eq, |
| 501 | bool sol_evts, bool no_delay, int coalesce_wm) |
| 502 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 503 | struct be_mcc_wrb *wrb; |
| 504 | struct be_cmd_req_cq_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 505 | struct be_dma_mem *q_mem = &cq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 506 | void *ctxt; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 507 | int status; |
| 508 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 509 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 510 | |
| 511 | wrb = wrb_from_mbox(adapter); |
| 512 | req = embedded_payload(wrb); |
| 513 | ctxt = &req->context; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 514 | |
| 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 530 | AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); |
Sathya Perla | eec368f | 2009-07-27 22:52:23 +0000 | [diff] [blame] | 531 | AMAP_SET_BITS(struct amap_cq_context, func, ctxt, be_pci_func(adapter)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 532 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 536 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 537 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 538 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 539 | cq->id = le16_to_cpu(resp->cq_id); |
| 540 | cq->created = true; |
| 541 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 542 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 543 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 544 | |
| 545 | return status; |
| 546 | } |
| 547 | |
| 548 | static 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 556 | int be_cmd_mccq_create(struct be_adapter *adapter, |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 557 | struct be_queue_info *mccq, |
| 558 | struct be_queue_info *cq) |
| 559 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 560 | struct be_mcc_wrb *wrb; |
| 561 | struct be_cmd_req_mcc_create *req; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 562 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 563 | void *ctxt; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 564 | int status; |
| 565 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 566 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 567 | |
| 568 | wrb = wrb_from_mbox(adapter); |
| 569 | req = embedded_payload(wrb); |
| 570 | ctxt = &req->context; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 571 | |
| 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 Perla | eec368f | 2009-07-27 22:52:23 +0000 | [diff] [blame] | 579 | AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, be_pci_func(adapter)); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 580 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 589 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 590 | 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 595 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 596 | |
| 597 | return status; |
| 598 | } |
| 599 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 600 | int be_cmd_txq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 601 | struct be_queue_info *txq, |
| 602 | struct be_queue_info *cq) |
| 603 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 604 | struct be_mcc_wrb *wrb; |
| 605 | struct be_cmd_req_eth_tx_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 606 | struct be_dma_mem *q_mem = &txq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 607 | void *ctxt; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 608 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 609 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 610 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 611 | |
| 612 | wrb = wrb_from_mbox(adapter); |
| 613 | req = embedded_payload(wrb); |
| 614 | ctxt = &req->context; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 615 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 625 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, |
| 626 | be_encoded_q_len(txq->len)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 627 | AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, |
Sathya Perla | eec368f | 2009-07-27 22:52:23 +0000 | [diff] [blame] | 628 | be_pci_func(adapter)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 629 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 636 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 637 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 642 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 643 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 644 | |
| 645 | return status; |
| 646 | } |
| 647 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 648 | /* Uses mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 649 | int be_cmd_rxq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 650 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, |
| 651 | u16 max_frame_size, u32 if_id, u32 rss) |
| 652 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 653 | struct be_mcc_wrb *wrb; |
| 654 | struct be_cmd_req_eth_rx_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 655 | struct be_dma_mem *q_mem = &rxq->dma_mem; |
| 656 | int status; |
| 657 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 658 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 659 | |
| 660 | wrb = wrb_from_mbox(adapter); |
| 661 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 662 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 676 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 677 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 682 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 683 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 684 | |
| 685 | return status; |
| 686 | } |
| 687 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 688 | /* Generic destroyer function for all types of queues |
| 689 | * Uses Mbox |
| 690 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 691 | int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 692 | int queue_type) |
| 693 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 694 | struct be_mcc_wrb *wrb; |
| 695 | struct be_cmd_req_q_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 696 | u8 subsys = 0, opcode = 0; |
| 697 | int status; |
| 698 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 699 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 700 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 701 | wrb = wrb_from_mbox(adapter); |
| 702 | req = embedded_payload(wrb); |
| 703 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 704 | 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 Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 723 | case QTYPE_MCCQ: |
| 724 | subsys = CMD_SUBSYSTEM_COMMON; |
| 725 | opcode = OPCODE_COMMON_MCC_DESTROY; |
| 726 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 727 | default: |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 728 | BUG(); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 729 | } |
| 730 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); |
| 731 | req->id = cpu_to_le16(q->id); |
| 732 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 733 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 734 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 735 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 736 | |
| 737 | return status; |
| 738 | } |
| 739 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 740 | /* Create an rx filtering policy configuration on an i/f |
| 741 | * Uses mbox |
| 742 | */ |
Sathya Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 743 | int 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 Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 745 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 746 | struct be_mcc_wrb *wrb; |
| 747 | struct be_cmd_req_if_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 748 | int status; |
| 749 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 750 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 751 | |
| 752 | wrb = wrb_from_mbox(adapter); |
| 753 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 754 | |
| 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 Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 760 | req->capability_flags = cpu_to_le32(cap_flags); |
| 761 | req->enable_flags = cpu_to_le32(en_flags); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 762 | req->pmac_invalid = pmac_invalid; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 763 | if (!pmac_invalid) |
| 764 | memcpy(req->mac_addr, mac, ETH_ALEN); |
| 765 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 766 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 767 | 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 774 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 775 | return status; |
| 776 | } |
| 777 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 778 | /* Uses mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 779 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 780 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 781 | struct be_mcc_wrb *wrb; |
| 782 | struct be_cmd_req_if_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 783 | int status; |
| 784 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 785 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 786 | |
| 787 | wrb = wrb_from_mbox(adapter); |
| 788 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 789 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 796 | |
| 797 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 798 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 799 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 800 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 806 | * Uses asynchronous MCC |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 807 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 808 | int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 809 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 810 | struct be_mcc_wrb *wrb; |
| 811 | struct be_cmd_req_get_stats *req; |
| 812 | struct be_sge *sge; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 813 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 814 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 815 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 816 | wrb = wrb_from_mccq(adapter); |
| 817 | req = nonemb_cmd->va; |
| 818 | sge = nonembedded_sgl(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 819 | |
| 820 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 821 | wrb->tag0 = OPCODE_ETH_GET_STATISTICS; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 822 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 829 | be_mcc_notify(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 830 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 831 | spin_unlock_bh(&adapter->mcc_lock); |
| 832 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 833 | } |
| 834 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 835 | /* Uses synchronous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 836 | int be_cmd_link_status_query(struct be_adapter *adapter, |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 837 | bool *link_up) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 838 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 839 | struct be_mcc_wrb *wrb; |
| 840 | struct be_cmd_req_link_status *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 841 | int status; |
| 842 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 843 | spin_lock_bh(&adapter->mcc_lock); |
| 844 | |
| 845 | wrb = wrb_from_mccq(adapter); |
| 846 | req = embedded_payload(wrb); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 847 | |
| 848 | *link_up = false; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 849 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 855 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 856 | if (!status) { |
| 857 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 858 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) |
| 859 | *link_up = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 860 | } |
| 861 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 862 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 863 | return status; |
| 864 | } |
| 865 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 866 | /* Uses Mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 867 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 868 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 869 | struct be_mcc_wrb *wrb; |
| 870 | struct be_cmd_req_get_fw_version *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 871 | int status; |
| 872 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 873 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 874 | |
| 875 | wrb = wrb_from_mbox(adapter); |
| 876 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 877 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 883 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 884 | 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 889 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 890 | return status; |
| 891 | } |
| 892 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 893 | /* set the EQ delay interval of an EQ to specified value |
| 894 | * Uses async mcc |
| 895 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 896 | int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 897 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 898 | struct be_mcc_wrb *wrb; |
| 899 | struct be_cmd_req_modify_eq_delay *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 900 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 901 | spin_lock_bh(&adapter->mcc_lock); |
| 902 | |
| 903 | wrb = wrb_from_mccq(adapter); |
| 904 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 905 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 916 | be_mcc_notify(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 917 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 918 | spin_unlock_bh(&adapter->mcc_lock); |
| 919 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 922 | /* Uses sycnhronous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 923 | int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 924 | u32 num, bool untagged, bool promiscuous) |
| 925 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 926 | struct be_mcc_wrb *wrb; |
| 927 | struct be_cmd_req_vlan_config *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 928 | int status; |
| 929 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 930 | spin_lock_bh(&adapter->mcc_lock); |
| 931 | |
| 932 | wrb = wrb_from_mccq(adapter); |
| 933 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 934 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 949 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 950 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 951 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 952 | return status; |
| 953 | } |
| 954 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 955 | /* Uses MCC for this command as it may be called in BH context |
| 956 | * Uses synchronous mcc |
| 957 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 958 | int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 959 | { |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 960 | struct be_mcc_wrb *wrb; |
| 961 | struct be_cmd_req_promiscuous_config *req; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 962 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 963 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 964 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 965 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 966 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 967 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 968 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 979 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 980 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 981 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 982 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 983 | } |
| 984 | |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 985 | /* |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 986 | * Uses MCC for this command as it may be called in BH context |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 987 | * (mc == NULL) => multicast promiscous |
| 988 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 989 | int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, |
Sathya Perla | 24307ee | 2009-06-18 00:09:25 +0000 | [diff] [blame] | 990 | struct dev_mc_list *mc_list, u32 mc_count) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 991 | { |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 992 | #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 Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 995 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 996 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 997 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 998 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 999 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1000 | |
| 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 Perla | 24307ee | 2009-06-18 00:09:25 +0000 | [diff] [blame] | 1007 | 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 Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1019 | be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1020 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1021 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 1022 | |
| 1023 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1026 | /* Uses synchrounous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1027 | int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1028 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1029 | struct be_mcc_wrb *wrb; |
| 1030 | struct be_cmd_req_set_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1031 | int status; |
| 1032 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1033 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1034 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1035 | wrb = wrb_from_mccq(adapter); |
| 1036 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1037 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1046 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1047 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1048 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1049 | return status; |
| 1050 | } |
| 1051 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1052 | /* Uses sycn mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1053 | int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1054 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1055 | struct be_mcc_wrb *wrb; |
| 1056 | struct be_cmd_req_get_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1057 | int status; |
| 1058 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1059 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1060 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1061 | wrb = wrb_from_mccq(adapter); |
| 1062 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1063 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1069 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1070 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1077 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1078 | return status; |
| 1079 | } |
| 1080 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1081 | /* Uses mbox */ |
Ajit Khaparde | dcb9b56 | 2009-09-30 21:58:22 -0700 | [diff] [blame] | 1082 | int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, u32 *cap) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1083 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1084 | struct be_mcc_wrb *wrb; |
| 1085 | struct be_cmd_req_query_fw_cfg *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1086 | int status; |
| 1087 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1088 | spin_lock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1089 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1090 | wrb = wrb_from_mbox(adapter); |
| 1091 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1092 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1098 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1099 | if (!status) { |
| 1100 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); |
| 1101 | *port_num = le32_to_cpu(resp->phys_port); |
Ajit Khaparde | dcb9b56 | 2009-09-30 21:58:22 -0700 | [diff] [blame] | 1102 | *cap = le32_to_cpu(resp->function_cap); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1105 | spin_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1106 | return status; |
| 1107 | } |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1108 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1109 | /* Uses mbox */ |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1110 | int be_cmd_reset_function(struct be_adapter *adapter) |
| 1111 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1112 | struct be_mcc_wrb *wrb; |
| 1113 | struct be_cmd_req_hdr *req; |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1114 | int status; |
| 1115 | |
| 1116 | spin_lock(&adapter->mbox_lock); |
| 1117 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1118 | wrb = wrb_from_mbox(adapter); |
| 1119 | req = embedded_payload(wrb); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1120 | |
| 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1126 | status = be_mbox_notify_wait(adapter); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1127 | |
| 1128 | spin_unlock(&adapter->mbox_lock); |
| 1129 | return status; |
| 1130 | } |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1131 | |
| 1132 | int 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1135 | struct be_mcc_wrb *wrb; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1136 | struct be_cmd_write_flashrom *req = cmd->va; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1137 | struct be_sge *sge; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1138 | int status; |
| 1139 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1140 | spin_lock_bh(&adapter->mcc_lock); |
| 1141 | |
| 1142 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1143 | sge = nonembedded_sgl(wrb); |
| 1144 | |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1145 | 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 Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1157 | status = be_mcc_notify_wait(adapter); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1158 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1159 | spin_unlock_bh(&adapter->mcc_lock); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1160 | return status; |
| 1161 | } |