Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1 | /* |
Ajit Khaparde | d2145cd | 2011-03-16 08:20:46 +0000 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2011 Emulex |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 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: |
Ajit Khaparde | d2145cd | 2011-03-16 08:20:46 +0000 | [diff] [blame] | 11 | * linux-drivers@emulex.com |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 12 | * |
Ajit Khaparde | d2145cd | 2011-03-16 08:20:46 +0000 | [diff] [blame] | 13 | * Emulex |
| 14 | * 3333 Susan Street |
| 15 | * Costa Mesa, CA 92626 |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 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 | |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 21 | /* Must be a power of 2 or else MODULO will BUG_ON */ |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 22 | static int be_get_temp_freq = 64; |
| 23 | |
| 24 | static inline void *embedded_payload(struct be_mcc_wrb *wrb) |
| 25 | { |
| 26 | return wrb->payload.embedded_payload; |
| 27 | } |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 28 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 29 | static void be_mcc_notify(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 30 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 31 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 32 | u32 val = 0; |
| 33 | |
Ajit Khaparde | 7acc208 | 2011-02-11 13:38:17 +0000 | [diff] [blame] | 34 | if (adapter->eeh_err) { |
| 35 | dev_info(&adapter->pdev->dev, |
| 36 | "Error in Card Detected! Cannot issue commands\n"); |
| 37 | return; |
| 38 | } |
| 39 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 40 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; |
| 41 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; |
Sathya Perla | f3eb62d | 2010-06-29 00:11:17 +0000 | [diff] [blame] | 42 | |
| 43 | wmb(); |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 44 | iowrite32(val, adapter->db + DB_MCCQ_OFFSET); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /* To check if valid bit is set, check the entire word as we don't know |
| 48 | * the endianness of the data (old entry is host endian while a new entry is |
| 49 | * little endian) */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 50 | 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] | 51 | { |
| 52 | if (compl->flags != 0) { |
| 53 | compl->flags = le32_to_cpu(compl->flags); |
| 54 | BUG_ON((compl->flags & CQE_FLAGS_VALID_MASK) == 0); |
| 55 | return true; |
| 56 | } else { |
| 57 | return false; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /* Need to reset the entire word that houses the valid bit */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 62 | static inline void be_mcc_compl_use(struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 63 | { |
| 64 | compl->flags = 0; |
| 65 | } |
| 66 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 67 | static int be_mcc_compl_process(struct be_adapter *adapter, |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 68 | struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 69 | { |
| 70 | u16 compl_status, extd_status; |
| 71 | |
| 72 | /* Just swap the status to host endian; mcc tag is opaquely copied |
| 73 | * from mcc_wrb */ |
| 74 | be_dws_le_to_cpu(compl, 4); |
| 75 | |
| 76 | compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & |
| 77 | CQE_STATUS_COMPL_MASK; |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 78 | |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 79 | if (((compl->tag0 == OPCODE_COMMON_WRITE_FLASHROM) || |
| 80 | (compl->tag0 == OPCODE_COMMON_WRITE_OBJECT)) && |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 81 | (compl->tag1 == CMD_SUBSYSTEM_COMMON)) { |
| 82 | adapter->flash_status = compl_status; |
| 83 | complete(&adapter->flash_compl); |
| 84 | } |
| 85 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 86 | if (compl_status == MCC_STATUS_SUCCESS) { |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 87 | if (((compl->tag0 == OPCODE_ETH_GET_STATISTICS) || |
| 88 | (compl->tag0 == OPCODE_ETH_GET_PPORT_STATS)) && |
Ajit Khaparde | 6349935 | 2011-04-19 12:11:02 +0000 | [diff] [blame] | 89 | (compl->tag1 == CMD_SUBSYSTEM_ETH)) { |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 90 | be_parse_stats(adapter); |
Ajit Khaparde | b2aebe6 | 2011-02-20 11:41:39 +0000 | [diff] [blame] | 91 | adapter->stats_cmd_sent = false; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 92 | } |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 93 | if (compl->tag0 == |
| 94 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES) { |
| 95 | struct be_mcc_wrb *mcc_wrb = |
| 96 | queue_index_node(&adapter->mcc_obj.q, |
| 97 | compl->tag1); |
| 98 | struct be_cmd_resp_get_cntl_addnl_attribs *resp = |
| 99 | embedded_payload(mcc_wrb); |
| 100 | adapter->drv_stats.be_on_die_temperature = |
| 101 | resp->on_die_temperature; |
| 102 | } |
Sathya Perla | 2b3f291 | 2011-06-29 23:32:56 +0000 | [diff] [blame] | 103 | } else { |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 104 | if (compl->tag0 == OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES) |
| 105 | be_get_temp_freq = 0; |
| 106 | |
Sathya Perla | 2b3f291 | 2011-06-29 23:32:56 +0000 | [diff] [blame] | 107 | if (compl_status == MCC_STATUS_NOT_SUPPORTED || |
| 108 | compl_status == MCC_STATUS_ILLEGAL_REQUEST) |
| 109 | goto done; |
| 110 | |
| 111 | if (compl_status == MCC_STATUS_UNAUTHORIZED_REQUEST) { |
| 112 | dev_warn(&adapter->pdev->dev, "This domain(VM) is not " |
| 113 | "permitted to execute this cmd (opcode %d)\n", |
| 114 | compl->tag0); |
| 115 | } else { |
| 116 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & |
| 117 | CQE_STATUS_EXTD_MASK; |
| 118 | dev_err(&adapter->pdev->dev, "Cmd (opcode %d) failed:" |
| 119 | "status %d, extd-status %d\n", |
| 120 | compl->tag0, compl_status, extd_status); |
| 121 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 122 | } |
Sathya Perla | 2b3f291 | 2011-06-29 23:32:56 +0000 | [diff] [blame] | 123 | done: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 124 | return compl_status; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 127 | /* 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] | 128 | static void be_async_link_state_process(struct be_adapter *adapter, |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 129 | struct be_async_event_link_state *evt) |
| 130 | { |
Sathya Perla | ea172a0 | 2011-08-02 19:57:42 +0000 | [diff] [blame] | 131 | be_link_status_update(adapter, evt->port_link_status); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 134 | /* Grp5 CoS Priority evt */ |
| 135 | static void be_async_grp5_cos_priority_process(struct be_adapter *adapter, |
| 136 | struct be_async_event_grp5_cos_priority *evt) |
| 137 | { |
| 138 | if (evt->valid) { |
| 139 | adapter->vlan_prio_bmap = evt->available_priority_bmap; |
Ajit Khaparde | 60964dd | 2011-02-11 13:37:25 +0000 | [diff] [blame] | 140 | adapter->recommended_prio &= ~VLAN_PRIO_MASK; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 141 | adapter->recommended_prio = |
| 142 | evt->reco_default_priority << VLAN_PRIO_SHIFT; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /* Grp5 QOS Speed evt */ |
| 147 | static void be_async_grp5_qos_speed_process(struct be_adapter *adapter, |
| 148 | struct be_async_event_grp5_qos_link_speed *evt) |
| 149 | { |
| 150 | if (evt->physical_port == adapter->port_num) { |
| 151 | /* qos_link_speed is in units of 10 Mbps */ |
| 152 | adapter->link_speed = evt->qos_link_speed * 10; |
| 153 | } |
| 154 | } |
| 155 | |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 156 | /*Grp5 PVID evt*/ |
| 157 | static void be_async_grp5_pvid_state_process(struct be_adapter *adapter, |
| 158 | struct be_async_event_grp5_pvid_state *evt) |
| 159 | { |
| 160 | if (evt->enabled) |
Somnath Kotur | 939cf30 | 2011-08-18 21:51:49 -0700 | [diff] [blame] | 161 | adapter->pvid = le16_to_cpu(evt->tag) & VLAN_VID_MASK; |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 162 | else |
| 163 | adapter->pvid = 0; |
| 164 | } |
| 165 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 166 | static void be_async_grp5_evt_process(struct be_adapter *adapter, |
| 167 | u32 trailer, struct be_mcc_compl *evt) |
| 168 | { |
| 169 | u8 event_type = 0; |
| 170 | |
| 171 | event_type = (trailer >> ASYNC_TRAILER_EVENT_TYPE_SHIFT) & |
| 172 | ASYNC_TRAILER_EVENT_TYPE_MASK; |
| 173 | |
| 174 | switch (event_type) { |
| 175 | case ASYNC_EVENT_COS_PRIORITY: |
| 176 | be_async_grp5_cos_priority_process(adapter, |
| 177 | (struct be_async_event_grp5_cos_priority *)evt); |
| 178 | break; |
| 179 | case ASYNC_EVENT_QOS_SPEED: |
| 180 | be_async_grp5_qos_speed_process(adapter, |
| 181 | (struct be_async_event_grp5_qos_link_speed *)evt); |
| 182 | break; |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 183 | case ASYNC_EVENT_PVID_STATE: |
| 184 | be_async_grp5_pvid_state_process(adapter, |
| 185 | (struct be_async_event_grp5_pvid_state *)evt); |
| 186 | break; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 187 | default: |
| 188 | dev_warn(&adapter->pdev->dev, "Unknown grp5 event!\n"); |
| 189 | break; |
| 190 | } |
| 191 | } |
| 192 | |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 193 | static inline bool is_link_state_evt(u32 trailer) |
| 194 | { |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 195 | return ((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) & |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 196 | ASYNC_TRAILER_EVENT_CODE_MASK) == |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 197 | ASYNC_EVENT_CODE_LINK_STATE; |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 198 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 199 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 200 | static inline bool is_grp5_evt(u32 trailer) |
| 201 | { |
| 202 | return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) & |
| 203 | ASYNC_TRAILER_EVENT_CODE_MASK) == |
| 204 | ASYNC_EVENT_CODE_GRP_5); |
| 205 | } |
| 206 | |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 207 | 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] | 208 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 209 | struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 210 | struct be_mcc_compl *compl = queue_tail_node(mcc_cq); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 211 | |
| 212 | if (be_mcc_compl_is_new(compl)) { |
| 213 | queue_tail_inc(mcc_cq); |
| 214 | return compl; |
| 215 | } |
| 216 | return NULL; |
| 217 | } |
| 218 | |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 219 | void be_async_mcc_enable(struct be_adapter *adapter) |
| 220 | { |
| 221 | spin_lock_bh(&adapter->mcc_cq_lock); |
| 222 | |
| 223 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, 0); |
| 224 | adapter->mcc_obj.rearm_cq = true; |
| 225 | |
| 226 | spin_unlock_bh(&adapter->mcc_cq_lock); |
| 227 | } |
| 228 | |
| 229 | void be_async_mcc_disable(struct be_adapter *adapter) |
| 230 | { |
| 231 | adapter->mcc_obj.rearm_cq = false; |
| 232 | } |
| 233 | |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 234 | int be_process_mcc(struct be_adapter *adapter, int *status) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 235 | { |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 236 | struct be_mcc_compl *compl; |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 237 | int num = 0; |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 238 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 239 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 240 | spin_lock_bh(&adapter->mcc_cq_lock); |
| 241 | while ((compl = be_mcc_compl_get(adapter))) { |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 242 | if (compl->flags & CQE_FLAGS_ASYNC_MASK) { |
| 243 | /* Interpret flags as an async trailer */ |
Ajit Khaparde | 323f30b | 2010-09-03 06:24:13 +0000 | [diff] [blame] | 244 | if (is_link_state_evt(compl->flags)) |
| 245 | be_async_link_state_process(adapter, |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 246 | (struct be_async_event_link_state *) compl); |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 247 | else if (is_grp5_evt(compl->flags)) |
| 248 | be_async_grp5_evt_process(adapter, |
| 249 | compl->flags, compl); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 250 | } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 251 | *status = be_mcc_compl_process(adapter, compl); |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 252 | atomic_dec(&mcc_obj->q.used); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 253 | } |
| 254 | be_mcc_compl_use(compl); |
| 255 | num++; |
| 256 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 257 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 258 | spin_unlock_bh(&adapter->mcc_cq_lock); |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 259 | return num; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 262 | /* Wait till no more pending mcc requests are present */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 263 | static int be_mcc_wait_compl(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 264 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 265 | #define mcc_timeout 120000 /* 12s timeout */ |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 266 | int i, num, status = 0; |
| 267 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 268 | |
Ajit Khaparde | 7acc208 | 2011-02-11 13:38:17 +0000 | [diff] [blame] | 269 | if (adapter->eeh_err) |
| 270 | return -EIO; |
| 271 | |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 272 | for (i = 0; i < mcc_timeout; i++) { |
| 273 | num = be_process_mcc(adapter, &status); |
| 274 | if (num) |
| 275 | be_cq_notify(adapter, mcc_obj->cq.id, |
| 276 | mcc_obj->rearm_cq, num); |
| 277 | |
| 278 | if (atomic_read(&mcc_obj->q.used) == 0) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 279 | break; |
| 280 | udelay(100); |
| 281 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 282 | if (i == mcc_timeout) { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 283 | dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 284 | return -1; |
| 285 | } |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 286 | return status; |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /* Notify MCC requests and wait for completion */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 290 | static int be_mcc_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 291 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 292 | be_mcc_notify(adapter); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 293 | return be_mcc_wait_compl(adapter); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 296 | 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] | 297 | { |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 298 | int msecs = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 299 | u32 ready; |
| 300 | |
Ajit Khaparde | 7acc208 | 2011-02-11 13:38:17 +0000 | [diff] [blame] | 301 | if (adapter->eeh_err) { |
| 302 | dev_err(&adapter->pdev->dev, |
| 303 | "Error detected in card.Cannot issue commands\n"); |
| 304 | return -EIO; |
| 305 | } |
| 306 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 307 | do { |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 308 | ready = ioread32(db); |
| 309 | if (ready == 0xffffffff) { |
| 310 | dev_err(&adapter->pdev->dev, |
| 311 | "pci slot disconnected\n"); |
| 312 | return -1; |
| 313 | } |
| 314 | |
| 315 | ready &= MPU_MAILBOX_DB_RDY_MASK; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 316 | if (ready) |
| 317 | break; |
| 318 | |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 319 | if (msecs > 4000) { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 320 | dev_err(&adapter->pdev->dev, "mbox poll timed out\n"); |
Padmanabh Ratnakar | 18a91e6 | 2011-05-10 05:13:01 +0000 | [diff] [blame] | 321 | if (!lancer_chip(adapter)) |
| 322 | be_detect_dump_ue(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 323 | return -1; |
| 324 | } |
| 325 | |
Sathya Perla | 1dbf53a | 2011-05-12 19:32:16 +0000 | [diff] [blame] | 326 | msleep(1); |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 327 | msecs++; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 328 | } while (true); |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * Insert the mailbox address into the doorbell in two steps |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 335 | * 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] | 336 | */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 337 | static int be_mbox_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 338 | { |
| 339 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 340 | u32 val = 0; |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 341 | void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET; |
| 342 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 343 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 344 | struct be_mcc_compl *compl = &mbox->compl; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 345 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 346 | /* wait for ready to be set */ |
| 347 | status = be_mbox_db_ready_wait(adapter, db); |
| 348 | if (status != 0) |
| 349 | return status; |
| 350 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 351 | val |= MPU_MAILBOX_DB_HI_MASK; |
| 352 | /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */ |
| 353 | val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; |
| 354 | iowrite32(val, db); |
| 355 | |
| 356 | /* wait for ready to be set */ |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 357 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 358 | if (status != 0) |
| 359 | return status; |
| 360 | |
| 361 | val = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 362 | /* at bits 2 - 31 place mbox dma addr lsb bits 4 - 33 */ |
| 363 | val |= (u32)(mbox_mem->dma >> 4) << 2; |
| 364 | iowrite32(val, db); |
| 365 | |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 366 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 367 | if (status != 0) |
| 368 | return status; |
| 369 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 370 | /* A cq entry has been made now */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 371 | if (be_mcc_compl_is_new(compl)) { |
| 372 | status = be_mcc_compl_process(adapter, &mbox->compl); |
| 373 | be_mcc_compl_use(compl); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 374 | if (status) |
| 375 | return status; |
| 376 | } else { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 377 | dev_err(&adapter->pdev->dev, "invalid mailbox completion\n"); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 378 | return -1; |
| 379 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 380 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 383 | static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 384 | { |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 385 | u32 sem; |
| 386 | |
| 387 | if (lancer_chip(adapter)) |
| 388 | sem = ioread32(adapter->db + MPU_EP_SEMAPHORE_IF_TYPE2_OFFSET); |
| 389 | else |
| 390 | sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 391 | |
| 392 | *stage = sem & EP_SEMAPHORE_POST_STAGE_MASK; |
| 393 | if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK) |
| 394 | return -1; |
| 395 | else |
| 396 | return 0; |
| 397 | } |
| 398 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 399 | int be_cmd_POST(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 400 | { |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 401 | u16 stage; |
| 402 | int status, timeout = 0; |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 403 | struct device *dev = &adapter->pdev->dev; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 404 | |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 405 | do { |
| 406 | status = be_POST_stage_get(adapter, &stage); |
| 407 | if (status) { |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 408 | dev_err(dev, "POST error; stage=0x%x\n", stage); |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 409 | return -1; |
| 410 | } else if (stage != POST_STAGE_ARMFW_RDY) { |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 411 | if (msleep_interruptible(2000)) { |
| 412 | dev_err(dev, "Waiting for POST aborted\n"); |
| 413 | return -EINTR; |
| 414 | } |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 415 | timeout += 2; |
| 416 | } else { |
| 417 | return 0; |
| 418 | } |
Somnath Kotur | 3ab81b5 | 2011-10-03 08:10:57 +0000 | [diff] [blame] | 419 | } while (timeout < 60); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 420 | |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 421 | dev_err(dev, "POST timeout; stage=0x%x\n", stage); |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 422 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 425 | |
| 426 | static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb) |
| 427 | { |
| 428 | return &wrb->payload.sgl[0]; |
| 429 | } |
| 430 | |
| 431 | /* Don't touch the hdr after it's prepared */ |
| 432 | static void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 433 | bool embedded, u8 sge_cnt, u32 opcode) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 434 | { |
| 435 | if (embedded) |
| 436 | wrb->embedded |= MCC_WRB_EMBEDDED_MASK; |
| 437 | else |
| 438 | wrb->embedded |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) << |
| 439 | MCC_WRB_SGE_CNT_SHIFT; |
| 440 | wrb->payload_length = payload_len; |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 441 | wrb->tag0 = opcode; |
Sathya Perla | fa4281b | 2010-01-21 22:51:36 +0000 | [diff] [blame] | 442 | be_dws_cpu_to_le(wrb, 8); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /* Don't touch the hdr after it's prepared */ |
| 446 | static void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, |
| 447 | u8 subsystem, u8 opcode, int cmd_len) |
| 448 | { |
| 449 | req_hdr->opcode = opcode; |
| 450 | req_hdr->subsystem = subsystem; |
| 451 | req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr)); |
Ajit Khaparde | 07793d3 | 2010-02-16 00:18:46 +0000 | [diff] [blame] | 452 | req_hdr->version = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages, |
| 456 | struct be_dma_mem *mem) |
| 457 | { |
| 458 | int i, buf_pages = min(PAGES_4K_SPANNED(mem->va, mem->size), max_pages); |
| 459 | u64 dma = (u64)mem->dma; |
| 460 | |
| 461 | for (i = 0; i < buf_pages; i++) { |
| 462 | pages[i].lo = cpu_to_le32(dma & 0xFFFFFFFF); |
| 463 | pages[i].hi = cpu_to_le32(upper_32_bits(dma)); |
| 464 | dma += PAGE_SIZE_4K; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | /* Converts interrupt delay in microseconds to multiplier value */ |
| 469 | static u32 eq_delay_to_mult(u32 usec_delay) |
| 470 | { |
| 471 | #define MAX_INTR_RATE 651042 |
| 472 | const u32 round = 10; |
| 473 | u32 multiplier; |
| 474 | |
| 475 | if (usec_delay == 0) |
| 476 | multiplier = 0; |
| 477 | else { |
| 478 | u32 interrupt_rate = 1000000 / usec_delay; |
| 479 | /* Max delay, corresponding to the lowest interrupt rate */ |
| 480 | if (interrupt_rate == 0) |
| 481 | multiplier = 1023; |
| 482 | else { |
| 483 | multiplier = (MAX_INTR_RATE - interrupt_rate) * round; |
| 484 | multiplier /= interrupt_rate; |
| 485 | /* Round the multiplier to the closest value.*/ |
| 486 | multiplier = (multiplier + round/2) / round; |
| 487 | multiplier = min(multiplier, (u32)1023); |
| 488 | } |
| 489 | } |
| 490 | return multiplier; |
| 491 | } |
| 492 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 493 | 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] | 494 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 495 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
| 496 | struct be_mcc_wrb *wrb |
| 497 | = &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; |
| 498 | memset(wrb, 0, sizeof(*wrb)); |
| 499 | return wrb; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 502 | static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 503 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 504 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
| 505 | struct be_mcc_wrb *wrb; |
| 506 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 507 | if (atomic_read(&mccq->used) >= mccq->len) { |
| 508 | dev_err(&adapter->pdev->dev, "Out of MCCQ wrbs\n"); |
| 509 | return NULL; |
| 510 | } |
| 511 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 512 | wrb = queue_head_node(mccq); |
| 513 | queue_head_inc(mccq); |
| 514 | atomic_inc(&mccq->used); |
| 515 | memset(wrb, 0, sizeof(*wrb)); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 516 | return wrb; |
| 517 | } |
| 518 | |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 519 | /* Tell fw we're about to start firing cmds by writing a |
| 520 | * special pattern across the wrb hdr; uses mbox |
| 521 | */ |
| 522 | int be_cmd_fw_init(struct be_adapter *adapter) |
| 523 | { |
| 524 | u8 *wrb; |
| 525 | int status; |
| 526 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 527 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 528 | return -1; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 529 | |
| 530 | wrb = (u8 *)wrb_from_mbox(adapter); |
Sathya Perla | 359a972 | 2010-12-01 01:03:36 +0000 | [diff] [blame] | 531 | *wrb++ = 0xFF; |
| 532 | *wrb++ = 0x12; |
| 533 | *wrb++ = 0x34; |
| 534 | *wrb++ = 0xFF; |
| 535 | *wrb++ = 0xFF; |
| 536 | *wrb++ = 0x56; |
| 537 | *wrb++ = 0x78; |
| 538 | *wrb = 0xFF; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 539 | |
| 540 | status = be_mbox_notify_wait(adapter); |
| 541 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 542 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 543 | return status; |
| 544 | } |
| 545 | |
| 546 | /* Tell fw we're done with firing cmds by writing a |
| 547 | * special pattern across the wrb hdr; uses mbox |
| 548 | */ |
| 549 | int be_cmd_fw_clean(struct be_adapter *adapter) |
| 550 | { |
| 551 | u8 *wrb; |
| 552 | int status; |
| 553 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 554 | if (adapter->eeh_err) |
| 555 | return -EIO; |
| 556 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 557 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 558 | return -1; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 559 | |
| 560 | wrb = (u8 *)wrb_from_mbox(adapter); |
| 561 | *wrb++ = 0xFF; |
| 562 | *wrb++ = 0xAA; |
| 563 | *wrb++ = 0xBB; |
| 564 | *wrb++ = 0xFF; |
| 565 | *wrb++ = 0xFF; |
| 566 | *wrb++ = 0xCC; |
| 567 | *wrb++ = 0xDD; |
| 568 | *wrb = 0xFF; |
| 569 | |
| 570 | status = be_mbox_notify_wait(adapter); |
| 571 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 572 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 573 | return status; |
| 574 | } |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 575 | int be_cmd_eq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 576 | struct be_queue_info *eq, int eq_delay) |
| 577 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 578 | struct be_mcc_wrb *wrb; |
| 579 | struct be_cmd_req_eq_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 580 | struct be_dma_mem *q_mem = &eq->dma_mem; |
| 581 | int status; |
| 582 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 583 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 584 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 585 | |
| 586 | wrb = wrb_from_mbox(adapter); |
| 587 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 588 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 589 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, OPCODE_COMMON_EQ_CREATE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 590 | |
| 591 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 592 | OPCODE_COMMON_EQ_CREATE, sizeof(*req)); |
| 593 | |
| 594 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
| 595 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 596 | AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); |
| 597 | /* 4byte eqe*/ |
| 598 | AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); |
| 599 | AMAP_SET_BITS(struct amap_eq_context, count, req->context, |
| 600 | __ilog2_u32(eq->len/256)); |
| 601 | AMAP_SET_BITS(struct amap_eq_context, delaymult, req->context, |
| 602 | eq_delay_to_mult(eq_delay)); |
| 603 | be_dws_cpu_to_le(req->context, sizeof(req->context)); |
| 604 | |
| 605 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 606 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 607 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 608 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 609 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 610 | eq->id = le16_to_cpu(resp->eq_id); |
| 611 | eq->created = true; |
| 612 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 613 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 614 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 615 | return status; |
| 616 | } |
| 617 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 618 | /* Use MCC */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 619 | 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] | 620 | u8 type, bool permanent, u32 if_handle) |
| 621 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 622 | struct be_mcc_wrb *wrb; |
| 623 | struct be_cmd_req_mac_query *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 624 | int status; |
| 625 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 626 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 627 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 628 | wrb = wrb_from_mccq(adapter); |
| 629 | if (!wrb) { |
| 630 | status = -EBUSY; |
| 631 | goto err; |
| 632 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 633 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 634 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 635 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 636 | OPCODE_COMMON_NTWK_MAC_QUERY); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 637 | |
| 638 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 639 | OPCODE_COMMON_NTWK_MAC_QUERY, sizeof(*req)); |
| 640 | |
| 641 | req->type = type; |
| 642 | if (permanent) { |
| 643 | req->permanent = 1; |
| 644 | } else { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 645 | req->if_id = cpu_to_le16((u16) if_handle); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 646 | req->permanent = 0; |
| 647 | } |
| 648 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 649 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 650 | if (!status) { |
| 651 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 652 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 653 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 654 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 655 | err: |
| 656 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 657 | return status; |
| 658 | } |
| 659 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 660 | /* Uses synchronous MCCQ */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 661 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 662 | u32 if_id, u32 *pmac_id, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 663 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 664 | struct be_mcc_wrb *wrb; |
| 665 | struct be_cmd_req_pmac_add *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 666 | int status; |
| 667 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 668 | spin_lock_bh(&adapter->mcc_lock); |
| 669 | |
| 670 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 671 | if (!wrb) { |
| 672 | status = -EBUSY; |
| 673 | goto err; |
| 674 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 675 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 676 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 677 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 678 | OPCODE_COMMON_NTWK_PMAC_ADD); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 679 | |
| 680 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 681 | OPCODE_COMMON_NTWK_PMAC_ADD, sizeof(*req)); |
| 682 | |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 683 | req->hdr.domain = domain; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 684 | req->if_id = cpu_to_le32(if_id); |
| 685 | memcpy(req->mac_address, mac_addr, ETH_ALEN); |
| 686 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 687 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 688 | if (!status) { |
| 689 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); |
| 690 | *pmac_id = le32_to_cpu(resp->pmac_id); |
| 691 | } |
| 692 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 693 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 694 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 695 | return status; |
| 696 | } |
| 697 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 698 | /* Uses synchronous MCCQ */ |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 699 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id, u32 dom) |
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 | struct be_mcc_wrb *wrb; |
| 702 | struct be_cmd_req_pmac_del *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 703 | int status; |
| 704 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 705 | spin_lock_bh(&adapter->mcc_lock); |
| 706 | |
| 707 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 708 | if (!wrb) { |
| 709 | status = -EBUSY; |
| 710 | goto err; |
| 711 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 712 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 713 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 714 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 715 | OPCODE_COMMON_NTWK_PMAC_DEL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 716 | |
| 717 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 718 | OPCODE_COMMON_NTWK_PMAC_DEL, sizeof(*req)); |
| 719 | |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 720 | req->hdr.domain = dom; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 721 | req->if_id = cpu_to_le32(if_id); |
| 722 | req->pmac_id = cpu_to_le32(pmac_id); |
| 723 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 724 | status = be_mcc_notify_wait(adapter); |
| 725 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 726 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 727 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 728 | return status; |
| 729 | } |
| 730 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 731 | /* Uses Mbox */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 732 | int be_cmd_cq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 733 | struct be_queue_info *cq, struct be_queue_info *eq, |
| 734 | bool sol_evts, bool no_delay, int coalesce_wm) |
| 735 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 736 | struct be_mcc_wrb *wrb; |
| 737 | struct be_cmd_req_cq_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 738 | struct be_dma_mem *q_mem = &cq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 739 | void *ctxt; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 740 | int status; |
| 741 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 742 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 743 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 744 | |
| 745 | wrb = wrb_from_mbox(adapter); |
| 746 | req = embedded_payload(wrb); |
| 747 | ctxt = &req->context; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 748 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 749 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 750 | OPCODE_COMMON_CQ_CREATE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 751 | |
| 752 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 753 | OPCODE_COMMON_CQ_CREATE, sizeof(*req)); |
| 754 | |
| 755 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 756 | if (lancer_chip(adapter)) { |
Padmanabh Ratnakar | 8b7756c | 2011-03-07 03:08:52 +0000 | [diff] [blame] | 757 | req->hdr.version = 2; |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 758 | req->page_size = 1; /* 1 for 4K */ |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 759 | AMAP_SET_BITS(struct amap_cq_context_lancer, nodelay, ctxt, |
| 760 | no_delay); |
| 761 | AMAP_SET_BITS(struct amap_cq_context_lancer, count, ctxt, |
| 762 | __ilog2_u32(cq->len/256)); |
| 763 | AMAP_SET_BITS(struct amap_cq_context_lancer, valid, ctxt, 1); |
| 764 | AMAP_SET_BITS(struct amap_cq_context_lancer, eventable, |
| 765 | ctxt, 1); |
| 766 | AMAP_SET_BITS(struct amap_cq_context_lancer, eqid, |
| 767 | ctxt, eq->id); |
| 768 | AMAP_SET_BITS(struct amap_cq_context_lancer, armed, ctxt, 1); |
| 769 | } else { |
| 770 | AMAP_SET_BITS(struct amap_cq_context_be, coalescwm, ctxt, |
| 771 | coalesce_wm); |
| 772 | AMAP_SET_BITS(struct amap_cq_context_be, nodelay, |
| 773 | ctxt, no_delay); |
| 774 | AMAP_SET_BITS(struct amap_cq_context_be, count, ctxt, |
| 775 | __ilog2_u32(cq->len/256)); |
| 776 | AMAP_SET_BITS(struct amap_cq_context_be, valid, ctxt, 1); |
| 777 | AMAP_SET_BITS(struct amap_cq_context_be, solevent, |
| 778 | ctxt, sol_evts); |
| 779 | AMAP_SET_BITS(struct amap_cq_context_be, eventable, ctxt, 1); |
| 780 | AMAP_SET_BITS(struct amap_cq_context_be, eqid, ctxt, eq->id); |
| 781 | AMAP_SET_BITS(struct amap_cq_context_be, armed, ctxt, 1); |
| 782 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 783 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 784 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 785 | |
| 786 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 787 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 788 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 789 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 790 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 791 | cq->id = le16_to_cpu(resp->cq_id); |
| 792 | cq->created = true; |
| 793 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 794 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 795 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 796 | |
| 797 | return status; |
| 798 | } |
| 799 | |
| 800 | static u32 be_encoded_q_len(int q_len) |
| 801 | { |
| 802 | u32 len_encoded = fls(q_len); /* log2(len) + 1 */ |
| 803 | if (len_encoded == 16) |
| 804 | len_encoded = 0; |
| 805 | return len_encoded; |
| 806 | } |
| 807 | |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 808 | int be_cmd_mccq_ext_create(struct be_adapter *adapter, |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 809 | struct be_queue_info *mccq, |
| 810 | struct be_queue_info *cq) |
| 811 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 812 | struct be_mcc_wrb *wrb; |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 813 | struct be_cmd_req_mcc_ext_create *req; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 814 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 815 | void *ctxt; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 816 | int status; |
| 817 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 818 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 819 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 820 | |
| 821 | wrb = wrb_from_mbox(adapter); |
| 822 | req = embedded_payload(wrb); |
| 823 | ctxt = &req->context; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 824 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 825 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 826 | OPCODE_COMMON_MCC_CREATE_EXT); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 827 | |
| 828 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 829 | OPCODE_COMMON_MCC_CREATE_EXT, sizeof(*req)); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 830 | |
Ajit Khaparde | d4a2ac3 | 2010-03-11 01:35:59 +0000 | [diff] [blame] | 831 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 832 | if (lancer_chip(adapter)) { |
| 833 | req->hdr.version = 1; |
| 834 | req->cq_id = cpu_to_le16(cq->id); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 835 | |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 836 | AMAP_SET_BITS(struct amap_mcc_context_lancer, ring_size, ctxt, |
| 837 | be_encoded_q_len(mccq->len)); |
| 838 | AMAP_SET_BITS(struct amap_mcc_context_lancer, valid, ctxt, 1); |
| 839 | AMAP_SET_BITS(struct amap_mcc_context_lancer, async_cq_id, |
| 840 | ctxt, cq->id); |
| 841 | AMAP_SET_BITS(struct amap_mcc_context_lancer, async_cq_valid, |
| 842 | ctxt, 1); |
| 843 | |
| 844 | } else { |
| 845 | AMAP_SET_BITS(struct amap_mcc_context_be, valid, ctxt, 1); |
| 846 | AMAP_SET_BITS(struct amap_mcc_context_be, ring_size, ctxt, |
| 847 | be_encoded_q_len(mccq->len)); |
| 848 | AMAP_SET_BITS(struct amap_mcc_context_be, cq_id, ctxt, cq->id); |
| 849 | } |
| 850 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 851 | /* Subscribe to Link State and Group 5 Events(bits 1 and 5 set) */ |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 852 | req->async_event_bitmap[0] = cpu_to_le32(0x00000022); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 853 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 854 | |
| 855 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 856 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 857 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 858 | if (!status) { |
| 859 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
| 860 | mccq->id = le16_to_cpu(resp->id); |
| 861 | mccq->created = true; |
| 862 | } |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 863 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 864 | |
| 865 | return status; |
| 866 | } |
| 867 | |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 868 | int be_cmd_mccq_org_create(struct be_adapter *adapter, |
| 869 | struct be_queue_info *mccq, |
| 870 | struct be_queue_info *cq) |
| 871 | { |
| 872 | struct be_mcc_wrb *wrb; |
| 873 | struct be_cmd_req_mcc_create *req; |
| 874 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
| 875 | void *ctxt; |
| 876 | int status; |
| 877 | |
| 878 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 879 | return -1; |
| 880 | |
| 881 | wrb = wrb_from_mbox(adapter); |
| 882 | req = embedded_payload(wrb); |
| 883 | ctxt = &req->context; |
| 884 | |
| 885 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 886 | OPCODE_COMMON_MCC_CREATE); |
| 887 | |
| 888 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 889 | OPCODE_COMMON_MCC_CREATE, sizeof(*req)); |
| 890 | |
| 891 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
| 892 | |
| 893 | AMAP_SET_BITS(struct amap_mcc_context_be, valid, ctxt, 1); |
| 894 | AMAP_SET_BITS(struct amap_mcc_context_be, ring_size, ctxt, |
| 895 | be_encoded_q_len(mccq->len)); |
| 896 | AMAP_SET_BITS(struct amap_mcc_context_be, cq_id, ctxt, cq->id); |
| 897 | |
| 898 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 899 | |
| 900 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 901 | |
| 902 | status = be_mbox_notify_wait(adapter); |
| 903 | if (!status) { |
| 904 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
| 905 | mccq->id = le16_to_cpu(resp->id); |
| 906 | mccq->created = true; |
| 907 | } |
| 908 | |
| 909 | mutex_unlock(&adapter->mbox_lock); |
| 910 | return status; |
| 911 | } |
| 912 | |
| 913 | int be_cmd_mccq_create(struct be_adapter *adapter, |
| 914 | struct be_queue_info *mccq, |
| 915 | struct be_queue_info *cq) |
| 916 | { |
| 917 | int status; |
| 918 | |
| 919 | status = be_cmd_mccq_ext_create(adapter, mccq, cq); |
| 920 | if (status && !lancer_chip(adapter)) { |
| 921 | dev_warn(&adapter->pdev->dev, "Upgrade to F/W ver 2.102.235.0 " |
| 922 | "or newer to avoid conflicting priorities between NIC " |
| 923 | "and FCoE traffic"); |
| 924 | status = be_cmd_mccq_org_create(adapter, mccq, cq); |
| 925 | } |
| 926 | return status; |
| 927 | } |
| 928 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 929 | int be_cmd_txq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 930 | struct be_queue_info *txq, |
| 931 | struct be_queue_info *cq) |
| 932 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 933 | struct be_mcc_wrb *wrb; |
| 934 | struct be_cmd_req_eth_tx_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 935 | struct be_dma_mem *q_mem = &txq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 936 | void *ctxt; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 937 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 938 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 939 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 940 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 941 | |
| 942 | wrb = wrb_from_mbox(adapter); |
| 943 | req = embedded_payload(wrb); |
| 944 | ctxt = &req->context; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 945 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 946 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 947 | OPCODE_ETH_TX_CREATE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 948 | |
| 949 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_TX_CREATE, |
| 950 | sizeof(*req)); |
| 951 | |
Padmanabh Ratnakar | 8b7756c | 2011-03-07 03:08:52 +0000 | [diff] [blame] | 952 | if (lancer_chip(adapter)) { |
| 953 | req->hdr.version = 1; |
| 954 | AMAP_SET_BITS(struct amap_tx_context, if_id, ctxt, |
| 955 | adapter->if_handle); |
| 956 | } |
| 957 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 958 | req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); |
| 959 | req->ulp_num = BE_ULP1_NUM; |
| 960 | req->type = BE_ETH_TX_RING_TYPE_STANDARD; |
| 961 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 962 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, |
| 963 | be_encoded_q_len(txq->len)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 964 | AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); |
| 965 | AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id); |
| 966 | |
| 967 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 968 | |
| 969 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 970 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 971 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 972 | if (!status) { |
| 973 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); |
| 974 | txq->id = le16_to_cpu(resp->cid); |
| 975 | txq->created = true; |
| 976 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 977 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 978 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 979 | |
| 980 | return status; |
| 981 | } |
| 982 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 983 | /* Uses MCC */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 984 | int be_cmd_rxq_create(struct be_adapter *adapter, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 985 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 986 | u16 max_frame_size, u32 if_id, u32 rss, u8 *rss_id) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 987 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 988 | struct be_mcc_wrb *wrb; |
| 989 | struct be_cmd_req_eth_rx_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 990 | struct be_dma_mem *q_mem = &rxq->dma_mem; |
| 991 | int status; |
| 992 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 993 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 994 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 995 | wrb = wrb_from_mccq(adapter); |
| 996 | if (!wrb) { |
| 997 | status = -EBUSY; |
| 998 | goto err; |
| 999 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1000 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1001 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1002 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1003 | OPCODE_ETH_RX_CREATE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1004 | |
| 1005 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_RX_CREATE, |
| 1006 | sizeof(*req)); |
| 1007 | |
| 1008 | req->cq_id = cpu_to_le16(cq_id); |
| 1009 | req->frag_size = fls(frag_size) - 1; |
| 1010 | req->num_pages = 2; |
| 1011 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 1012 | req->interface_id = cpu_to_le32(if_id); |
| 1013 | req->max_frame_size = cpu_to_le16(max_frame_size); |
| 1014 | req->rss_queue = cpu_to_le32(rss); |
| 1015 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1016 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1017 | if (!status) { |
| 1018 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); |
| 1019 | rxq->id = le16_to_cpu(resp->id); |
| 1020 | rxq->created = true; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1021 | *rss_id = resp->rss_id; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1022 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1023 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1024 | err: |
| 1025 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1026 | return status; |
| 1027 | } |
| 1028 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1029 | /* Generic destroyer function for all types of queues |
| 1030 | * Uses Mbox |
| 1031 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1032 | 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] | 1033 | int queue_type) |
| 1034 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1035 | struct be_mcc_wrb *wrb; |
| 1036 | struct be_cmd_req_q_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1037 | u8 subsys = 0, opcode = 0; |
| 1038 | int status; |
| 1039 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 1040 | if (adapter->eeh_err) |
| 1041 | return -EIO; |
| 1042 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1043 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1044 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1045 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1046 | wrb = wrb_from_mbox(adapter); |
| 1047 | req = embedded_payload(wrb); |
| 1048 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1049 | switch (queue_type) { |
| 1050 | case QTYPE_EQ: |
| 1051 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1052 | opcode = OPCODE_COMMON_EQ_DESTROY; |
| 1053 | break; |
| 1054 | case QTYPE_CQ: |
| 1055 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1056 | opcode = OPCODE_COMMON_CQ_DESTROY; |
| 1057 | break; |
| 1058 | case QTYPE_TXQ: |
| 1059 | subsys = CMD_SUBSYSTEM_ETH; |
| 1060 | opcode = OPCODE_ETH_TX_DESTROY; |
| 1061 | break; |
| 1062 | case QTYPE_RXQ: |
| 1063 | subsys = CMD_SUBSYSTEM_ETH; |
| 1064 | opcode = OPCODE_ETH_RX_DESTROY; |
| 1065 | break; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1066 | case QTYPE_MCCQ: |
| 1067 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1068 | opcode = OPCODE_COMMON_MCC_DESTROY; |
| 1069 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1070 | default: |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 1071 | BUG(); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1072 | } |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1073 | |
| 1074 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, opcode); |
| 1075 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1076 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); |
| 1077 | req->id = cpu_to_le16(q->id); |
| 1078 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1079 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1080 | if (!status) |
| 1081 | q->created = false; |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 1082 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1083 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1084 | return status; |
| 1085 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1086 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1087 | /* Uses MCC */ |
| 1088 | int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q) |
| 1089 | { |
| 1090 | struct be_mcc_wrb *wrb; |
| 1091 | struct be_cmd_req_q_destroy *req; |
| 1092 | int status; |
| 1093 | |
| 1094 | spin_lock_bh(&adapter->mcc_lock); |
| 1095 | |
| 1096 | wrb = wrb_from_mccq(adapter); |
| 1097 | if (!wrb) { |
| 1098 | status = -EBUSY; |
| 1099 | goto err; |
| 1100 | } |
| 1101 | req = embedded_payload(wrb); |
| 1102 | |
| 1103 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, OPCODE_ETH_RX_DESTROY); |
| 1104 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_RX_DESTROY, |
| 1105 | sizeof(*req)); |
| 1106 | req->id = cpu_to_le16(q->id); |
| 1107 | |
| 1108 | status = be_mcc_notify_wait(adapter); |
| 1109 | if (!status) |
| 1110 | q->created = false; |
| 1111 | |
| 1112 | err: |
| 1113 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1114 | return status; |
| 1115 | } |
| 1116 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1117 | /* Create an rx filtering policy configuration on an i/f |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1118 | * Uses MCCQ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1119 | */ |
Sathya Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 1120 | int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1121 | u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1122 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1123 | struct be_mcc_wrb *wrb; |
| 1124 | struct be_cmd_req_if_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1125 | int status; |
| 1126 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1127 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1128 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1129 | wrb = wrb_from_mccq(adapter); |
| 1130 | if (!wrb) { |
| 1131 | status = -EBUSY; |
| 1132 | goto err; |
| 1133 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1134 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1135 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1136 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1137 | OPCODE_COMMON_NTWK_INTERFACE_CREATE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1138 | |
| 1139 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1140 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); |
| 1141 | |
Sarveshwar Bandi | ba343c7 | 2010-03-31 02:56:12 +0000 | [diff] [blame] | 1142 | req->hdr.domain = domain; |
Sathya Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 1143 | req->capability_flags = cpu_to_le32(cap_flags); |
| 1144 | req->enable_flags = cpu_to_le32(en_flags); |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1145 | if (mac) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1146 | memcpy(req->mac_addr, mac, ETH_ALEN); |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1147 | else |
| 1148 | req->pmac_invalid = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1149 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1150 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1151 | if (!status) { |
| 1152 | struct be_cmd_resp_if_create *resp = embedded_payload(wrb); |
| 1153 | *if_handle = le32_to_cpu(resp->interface_id); |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1154 | if (mac) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1155 | *pmac_id = le32_to_cpu(resp->pmac_id); |
| 1156 | } |
| 1157 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1158 | err: |
| 1159 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1160 | return status; |
| 1161 | } |
| 1162 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1163 | /* Uses MCCQ */ |
Ajit Khaparde | 658681f | 2011-02-11 13:34:46 +0000 | [diff] [blame] | 1164 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1165 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1166 | struct be_mcc_wrb *wrb; |
| 1167 | struct be_cmd_req_if_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1168 | int status; |
| 1169 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 1170 | if (adapter->eeh_err) |
| 1171 | return -EIO; |
| 1172 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1173 | if (!interface_id) |
| 1174 | return 0; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1175 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1176 | spin_lock_bh(&adapter->mcc_lock); |
| 1177 | |
| 1178 | wrb = wrb_from_mccq(adapter); |
| 1179 | if (!wrb) { |
| 1180 | status = -EBUSY; |
| 1181 | goto err; |
| 1182 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1183 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1184 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1185 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1186 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1187 | |
| 1188 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1189 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); |
| 1190 | |
Ajit Khaparde | 658681f | 2011-02-11 13:34:46 +0000 | [diff] [blame] | 1191 | req->hdr.domain = domain; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1192 | req->interface_id = cpu_to_le32(interface_id); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1193 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1194 | status = be_mcc_notify_wait(adapter); |
| 1195 | err: |
| 1196 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1197 | return status; |
| 1198 | } |
| 1199 | |
| 1200 | /* Get stats is a non embedded command: the request is not embedded inside |
| 1201 | * WRB but is a separate dma memory block |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1202 | * Uses asynchronous MCC |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1203 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1204 | 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] | 1205 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1206 | struct be_mcc_wrb *wrb; |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1207 | struct be_cmd_req_hdr *hdr; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1208 | struct be_sge *sge; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1209 | int status = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1210 | |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1211 | if (MODULO(adapter->work_counter, be_get_temp_freq) == 0) |
| 1212 | be_cmd_get_die_temperature(adapter); |
| 1213 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1214 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1215 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1216 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1217 | if (!wrb) { |
| 1218 | status = -EBUSY; |
| 1219 | goto err; |
| 1220 | } |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1221 | hdr = nonemb_cmd->va; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1222 | sge = nonembedded_sgl(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1223 | |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1224 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1, |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1225 | OPCODE_ETH_GET_STATISTICS); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1226 | |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1227 | be_cmd_hdr_prepare(hdr, CMD_SUBSYSTEM_ETH, |
| 1228 | OPCODE_ETH_GET_STATISTICS, nonemb_cmd->size); |
| 1229 | |
| 1230 | if (adapter->generation == BE_GEN3) |
| 1231 | hdr->version = 1; |
| 1232 | |
Ajit Khaparde | 6349935 | 2011-04-19 12:11:02 +0000 | [diff] [blame] | 1233 | wrb->tag1 = CMD_SUBSYSTEM_ETH; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1234 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 1235 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 1236 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 1237 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1238 | be_mcc_notify(adapter); |
Ajit Khaparde | b2aebe6 | 2011-02-20 11:41:39 +0000 | [diff] [blame] | 1239 | adapter->stats_cmd_sent = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1240 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1241 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1242 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1243 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1244 | } |
| 1245 | |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1246 | /* Lancer Stats */ |
| 1247 | int lancer_cmd_get_pport_stats(struct be_adapter *adapter, |
| 1248 | struct be_dma_mem *nonemb_cmd) |
| 1249 | { |
| 1250 | |
| 1251 | struct be_mcc_wrb *wrb; |
| 1252 | struct lancer_cmd_req_pport_stats *req; |
| 1253 | struct be_sge *sge; |
| 1254 | int status = 0; |
| 1255 | |
| 1256 | spin_lock_bh(&adapter->mcc_lock); |
| 1257 | |
| 1258 | wrb = wrb_from_mccq(adapter); |
| 1259 | if (!wrb) { |
| 1260 | status = -EBUSY; |
| 1261 | goto err; |
| 1262 | } |
| 1263 | req = nonemb_cmd->va; |
| 1264 | sge = nonembedded_sgl(wrb); |
| 1265 | |
| 1266 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1, |
| 1267 | OPCODE_ETH_GET_PPORT_STATS); |
| 1268 | |
| 1269 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
| 1270 | OPCODE_ETH_GET_PPORT_STATS, nonemb_cmd->size); |
| 1271 | |
| 1272 | |
| 1273 | req->cmd_params.params.pport_num = cpu_to_le16(adapter->port_num); |
| 1274 | req->cmd_params.params.reset_stats = 0; |
| 1275 | |
| 1276 | wrb->tag1 = CMD_SUBSYSTEM_ETH; |
| 1277 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 1278 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 1279 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 1280 | |
| 1281 | be_mcc_notify(adapter); |
| 1282 | adapter->stats_cmd_sent = true; |
| 1283 | |
| 1284 | err: |
| 1285 | spin_unlock_bh(&adapter->mcc_lock); |
| 1286 | return status; |
| 1287 | } |
| 1288 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1289 | /* Uses synchronous mcc */ |
Sathya Perla | ea172a0 | 2011-08-02 19:57:42 +0000 | [diff] [blame] | 1290 | int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, |
| 1291 | u16 *link_speed, u32 dom) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1292 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1293 | struct be_mcc_wrb *wrb; |
| 1294 | struct be_cmd_req_link_status *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1295 | int status; |
| 1296 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1297 | spin_lock_bh(&adapter->mcc_lock); |
| 1298 | |
| 1299 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1300 | if (!wrb) { |
| 1301 | status = -EBUSY; |
| 1302 | goto err; |
| 1303 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1304 | req = embedded_payload(wrb); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 1305 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1306 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1307 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1308 | |
| 1309 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1310 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); |
| 1311 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1312 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1313 | if (!status) { |
| 1314 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 1315 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) { |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 1316 | *link_speed = le16_to_cpu(resp->link_speed); |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame^] | 1317 | if (mac_speed) |
| 1318 | *mac_speed = resp->mac_speed; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 1319 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1322 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1323 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1324 | return status; |
| 1325 | } |
| 1326 | |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1327 | /* Uses synchronous mcc */ |
| 1328 | int be_cmd_get_die_temperature(struct be_adapter *adapter) |
| 1329 | { |
| 1330 | struct be_mcc_wrb *wrb; |
| 1331 | struct be_cmd_req_get_cntl_addnl_attribs *req; |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 1332 | u16 mccq_index; |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1333 | int status; |
| 1334 | |
| 1335 | spin_lock_bh(&adapter->mcc_lock); |
| 1336 | |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 1337 | mccq_index = adapter->mcc_obj.q.head; |
| 1338 | |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1339 | wrb = wrb_from_mccq(adapter); |
| 1340 | if (!wrb) { |
| 1341 | status = -EBUSY; |
| 1342 | goto err; |
| 1343 | } |
| 1344 | req = embedded_payload(wrb); |
| 1345 | |
| 1346 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1347 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES); |
| 1348 | |
| 1349 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1350 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES, sizeof(*req)); |
| 1351 | |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 1352 | wrb->tag1 = mccq_index; |
| 1353 | |
| 1354 | be_mcc_notify(adapter); |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1355 | |
| 1356 | err: |
| 1357 | spin_unlock_bh(&adapter->mcc_lock); |
| 1358 | return status; |
| 1359 | } |
| 1360 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1361 | /* Uses synchronous mcc */ |
| 1362 | int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size) |
| 1363 | { |
| 1364 | struct be_mcc_wrb *wrb; |
| 1365 | struct be_cmd_req_get_fat *req; |
| 1366 | int status; |
| 1367 | |
| 1368 | spin_lock_bh(&adapter->mcc_lock); |
| 1369 | |
| 1370 | wrb = wrb_from_mccq(adapter); |
| 1371 | if (!wrb) { |
| 1372 | status = -EBUSY; |
| 1373 | goto err; |
| 1374 | } |
| 1375 | req = embedded_payload(wrb); |
| 1376 | |
| 1377 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1378 | OPCODE_COMMON_MANAGE_FAT); |
| 1379 | |
| 1380 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1381 | OPCODE_COMMON_MANAGE_FAT, sizeof(*req)); |
| 1382 | req->fat_operation = cpu_to_le32(QUERY_FAT); |
| 1383 | status = be_mcc_notify_wait(adapter); |
| 1384 | if (!status) { |
| 1385 | struct be_cmd_resp_get_fat *resp = embedded_payload(wrb); |
| 1386 | if (log_size && resp->log_size) |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1387 | *log_size = le32_to_cpu(resp->log_size) - |
| 1388 | sizeof(u32); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1389 | } |
| 1390 | err: |
| 1391 | spin_unlock_bh(&adapter->mcc_lock); |
| 1392 | return status; |
| 1393 | } |
| 1394 | |
| 1395 | void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) |
| 1396 | { |
| 1397 | struct be_dma_mem get_fat_cmd; |
| 1398 | struct be_mcc_wrb *wrb; |
| 1399 | struct be_cmd_req_get_fat *req; |
| 1400 | struct be_sge *sge; |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1401 | u32 offset = 0, total_size, buf_size, |
| 1402 | log_offset = sizeof(u32), payload_len; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1403 | int status; |
| 1404 | |
| 1405 | if (buf_len == 0) |
| 1406 | return; |
| 1407 | |
| 1408 | total_size = buf_len; |
| 1409 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1410 | get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024; |
| 1411 | get_fat_cmd.va = pci_alloc_consistent(adapter->pdev, |
| 1412 | get_fat_cmd.size, |
| 1413 | &get_fat_cmd.dma); |
| 1414 | if (!get_fat_cmd.va) { |
| 1415 | status = -ENOMEM; |
| 1416 | dev_err(&adapter->pdev->dev, |
| 1417 | "Memory allocation failure while retrieving FAT data\n"); |
| 1418 | return; |
| 1419 | } |
| 1420 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1421 | spin_lock_bh(&adapter->mcc_lock); |
| 1422 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1423 | while (total_size) { |
| 1424 | buf_size = min(total_size, (u32)60*1024); |
| 1425 | total_size -= buf_size; |
| 1426 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1427 | wrb = wrb_from_mccq(adapter); |
| 1428 | if (!wrb) { |
| 1429 | status = -EBUSY; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1430 | goto err; |
| 1431 | } |
| 1432 | req = get_fat_cmd.va; |
| 1433 | sge = nonembedded_sgl(wrb); |
| 1434 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1435 | payload_len = sizeof(struct be_cmd_req_get_fat) + buf_size; |
| 1436 | be_wrb_hdr_prepare(wrb, payload_len, false, 1, |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1437 | OPCODE_COMMON_MANAGE_FAT); |
| 1438 | |
| 1439 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1440 | OPCODE_COMMON_MANAGE_FAT, payload_len); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1441 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1442 | sge->pa_hi = cpu_to_le32(upper_32_bits(get_fat_cmd.dma)); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1443 | sge->pa_lo = cpu_to_le32(get_fat_cmd.dma & 0xFFFFFFFF); |
| 1444 | sge->len = cpu_to_le32(get_fat_cmd.size); |
| 1445 | |
| 1446 | req->fat_operation = cpu_to_le32(RETRIEVE_FAT); |
| 1447 | req->read_log_offset = cpu_to_le32(log_offset); |
| 1448 | req->read_log_length = cpu_to_le32(buf_size); |
| 1449 | req->data_buffer_size = cpu_to_le32(buf_size); |
| 1450 | |
| 1451 | status = be_mcc_notify_wait(adapter); |
| 1452 | if (!status) { |
| 1453 | struct be_cmd_resp_get_fat *resp = get_fat_cmd.va; |
| 1454 | memcpy(buf + offset, |
| 1455 | resp->data_buffer, |
Somnath Kotur | 92aa921 | 2011-09-30 07:24:00 +0000 | [diff] [blame] | 1456 | le32_to_cpu(resp->read_log_length)); |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1457 | } else { |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1458 | dev_err(&adapter->pdev->dev, "FAT Table Retrieve error\n"); |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1459 | goto err; |
| 1460 | } |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1461 | offset += buf_size; |
| 1462 | log_offset += buf_size; |
| 1463 | } |
| 1464 | err: |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1465 | pci_free_consistent(adapter->pdev, get_fat_cmd.size, |
| 1466 | get_fat_cmd.va, |
| 1467 | get_fat_cmd.dma); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1468 | spin_unlock_bh(&adapter->mcc_lock); |
| 1469 | } |
| 1470 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1471 | /* Uses synchronous mcc */ |
| 1472 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver, |
| 1473 | char *fw_on_flash) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1474 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1475 | struct be_mcc_wrb *wrb; |
| 1476 | struct be_cmd_req_get_fw_version *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1477 | int status; |
| 1478 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1479 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1480 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1481 | wrb = wrb_from_mccq(adapter); |
| 1482 | if (!wrb) { |
| 1483 | status = -EBUSY; |
| 1484 | goto err; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1485 | } |
| 1486 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1487 | req = embedded_payload(wrb); |
| 1488 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1489 | OPCODE_COMMON_GET_FW_VERSION); |
| 1490 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1491 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); |
| 1492 | |
| 1493 | status = be_mcc_notify_wait(adapter); |
| 1494 | if (!status) { |
| 1495 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); |
| 1496 | strcpy(fw_ver, resp->firmware_version_string); |
| 1497 | if (fw_on_flash) |
| 1498 | strcpy(fw_on_flash, resp->fw_on_flash_version_string); |
| 1499 | } |
| 1500 | err: |
| 1501 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1502 | return status; |
| 1503 | } |
| 1504 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1505 | /* set the EQ delay interval of an EQ to specified value |
| 1506 | * Uses async mcc |
| 1507 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1508 | 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] | 1509 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1510 | struct be_mcc_wrb *wrb; |
| 1511 | struct be_cmd_req_modify_eq_delay *req; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1512 | int status = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1513 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1514 | spin_lock_bh(&adapter->mcc_lock); |
| 1515 | |
| 1516 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1517 | if (!wrb) { |
| 1518 | status = -EBUSY; |
| 1519 | goto err; |
| 1520 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1521 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1522 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1523 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1524 | OPCODE_COMMON_MODIFY_EQ_DELAY); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1525 | |
| 1526 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1527 | OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req)); |
| 1528 | |
| 1529 | req->num_eq = cpu_to_le32(1); |
| 1530 | req->delay[0].eq_id = cpu_to_le32(eq_id); |
| 1531 | req->delay[0].phase = 0; |
| 1532 | req->delay[0].delay_multiplier = cpu_to_le32(eqd); |
| 1533 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1534 | be_mcc_notify(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1535 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1536 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1537 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1538 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1539 | } |
| 1540 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1541 | /* Uses sycnhronous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1542 | 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] | 1543 | u32 num, bool untagged, bool promiscuous) |
| 1544 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1545 | struct be_mcc_wrb *wrb; |
| 1546 | struct be_cmd_req_vlan_config *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1547 | int status; |
| 1548 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1549 | spin_lock_bh(&adapter->mcc_lock); |
| 1550 | |
| 1551 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1552 | if (!wrb) { |
| 1553 | status = -EBUSY; |
| 1554 | goto err; |
| 1555 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1556 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1557 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1558 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1559 | OPCODE_COMMON_NTWK_VLAN_CONFIG); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1560 | |
| 1561 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1562 | OPCODE_COMMON_NTWK_VLAN_CONFIG, sizeof(*req)); |
| 1563 | |
| 1564 | req->interface_id = if_id; |
| 1565 | req->promiscuous = promiscuous; |
| 1566 | req->untagged = untagged; |
| 1567 | req->num_vlan = num; |
| 1568 | if (!promiscuous) { |
| 1569 | memcpy(req->normal_vlan, vtag_array, |
| 1570 | req->num_vlan * sizeof(vtag_array[0])); |
| 1571 | } |
| 1572 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1573 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1574 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1575 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1576 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1577 | return status; |
| 1578 | } |
| 1579 | |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1580 | int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1581 | { |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 1582 | struct be_mcc_wrb *wrb; |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1583 | struct be_dma_mem *mem = &adapter->rx_filter; |
| 1584 | struct be_cmd_req_rx_filter *req = mem->va; |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1585 | struct be_sge *sge; |
| 1586 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1587 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1588 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 1589 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1590 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1591 | if (!wrb) { |
| 1592 | status = -EBUSY; |
| 1593 | goto err; |
| 1594 | } |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1595 | sge = nonembedded_sgl(wrb); |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1596 | sge->pa_hi = cpu_to_le32(upper_32_bits(mem->dma)); |
| 1597 | sge->pa_lo = cpu_to_le32(mem->dma & 0xFFFFFFFF); |
| 1598 | sge->len = cpu_to_le32(mem->size); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1599 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1, |
| 1600 | OPCODE_COMMON_NTWK_RX_FILTER); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1601 | |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1602 | memset(req, 0, sizeof(*req)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1603 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1604 | OPCODE_COMMON_NTWK_RX_FILTER, sizeof(*req)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1605 | |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1606 | req->if_id = cpu_to_le32(adapter->if_handle); |
| 1607 | if (flags & IFF_PROMISC) { |
| 1608 | req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS | |
| 1609 | BE_IF_FLAGS_VLAN_PROMISCUOUS); |
| 1610 | if (value == ON) |
| 1611 | req->if_flags = cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS | |
Sathya Perla | 8e7d3f6 | 2011-09-27 13:29:38 -0400 | [diff] [blame] | 1612 | BE_IF_FLAGS_VLAN_PROMISCUOUS); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1613 | } else if (flags & IFF_ALLMULTI) { |
| 1614 | req->if_flags_mask = req->if_flags = |
Sathya Perla | 8e7d3f6 | 2011-09-27 13:29:38 -0400 | [diff] [blame] | 1615 | cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS); |
Sathya Perla | 24307ee | 2009-06-18 00:09:25 +0000 | [diff] [blame] | 1616 | } else { |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1617 | struct netdev_hw_addr *ha; |
| 1618 | int i = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1619 | |
Sathya Perla | 8e7d3f6 | 2011-09-27 13:29:38 -0400 | [diff] [blame] | 1620 | req->if_flags_mask = req->if_flags = |
| 1621 | cpu_to_le32(BE_IF_FLAGS_MULTICAST); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1622 | req->mcast_num = cpu_to_le16(netdev_mc_count(adapter->netdev)); |
| 1623 | netdev_for_each_mc_addr(ha, adapter->netdev) |
| 1624 | memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN); |
| 1625 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1626 | |
Sathya Perla | 0d1d587 | 2011-08-03 05:19:27 -0700 | [diff] [blame] | 1627 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1628 | err: |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1629 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1630 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1631 | } |
| 1632 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1633 | /* Uses synchrounous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1634 | 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] | 1635 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1636 | struct be_mcc_wrb *wrb; |
| 1637 | struct be_cmd_req_set_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1638 | int status; |
| 1639 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1640 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1641 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1642 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1643 | if (!wrb) { |
| 1644 | status = -EBUSY; |
| 1645 | goto err; |
| 1646 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1647 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1648 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1649 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1650 | OPCODE_COMMON_SET_FLOW_CONTROL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1651 | |
| 1652 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1653 | OPCODE_COMMON_SET_FLOW_CONTROL, sizeof(*req)); |
| 1654 | |
| 1655 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); |
| 1656 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); |
| 1657 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1658 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1659 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1660 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1661 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1662 | return status; |
| 1663 | } |
| 1664 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1665 | /* Uses sycn mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1666 | 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] | 1667 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1668 | struct be_mcc_wrb *wrb; |
| 1669 | struct be_cmd_req_get_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1670 | int status; |
| 1671 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1672 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1673 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1674 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1675 | if (!wrb) { |
| 1676 | status = -EBUSY; |
| 1677 | goto err; |
| 1678 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1679 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1680 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1681 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1682 | OPCODE_COMMON_GET_FLOW_CONTROL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1683 | |
| 1684 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1685 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); |
| 1686 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1687 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1688 | if (!status) { |
| 1689 | struct be_cmd_resp_get_flow_control *resp = |
| 1690 | embedded_payload(wrb); |
| 1691 | *tx_fc = le16_to_cpu(resp->tx_flow_control); |
| 1692 | *rx_fc = le16_to_cpu(resp->rx_flow_control); |
| 1693 | } |
| 1694 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1695 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1696 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1697 | return status; |
| 1698 | } |
| 1699 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1700 | /* Uses mbox */ |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1701 | int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, |
| 1702 | u32 *mode, u32 *caps) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1703 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1704 | struct be_mcc_wrb *wrb; |
| 1705 | struct be_cmd_req_query_fw_cfg *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1706 | int status; |
| 1707 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1708 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1709 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1710 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1711 | wrb = wrb_from_mbox(adapter); |
| 1712 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1713 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1714 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1715 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1716 | |
| 1717 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1718 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); |
| 1719 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1720 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1721 | if (!status) { |
| 1722 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); |
| 1723 | *port_num = le32_to_cpu(resp->phys_port); |
Ajit Khaparde | 3486be2 | 2010-07-23 02:04:54 +0000 | [diff] [blame] | 1724 | *mode = le32_to_cpu(resp->function_mode); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1725 | *caps = le32_to_cpu(resp->function_caps); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1726 | } |
| 1727 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1728 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1729 | return status; |
| 1730 | } |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1731 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1732 | /* Uses mbox */ |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1733 | int be_cmd_reset_function(struct be_adapter *adapter) |
| 1734 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1735 | struct be_mcc_wrb *wrb; |
| 1736 | struct be_cmd_req_hdr *req; |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1737 | int status; |
| 1738 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1739 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1740 | return -1; |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1741 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1742 | wrb = wrb_from_mbox(adapter); |
| 1743 | req = embedded_payload(wrb); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1744 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1745 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1746 | OPCODE_COMMON_FUNCTION_RESET); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1747 | |
| 1748 | be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON, |
| 1749 | OPCODE_COMMON_FUNCTION_RESET, sizeof(*req)); |
| 1750 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1751 | status = be_mbox_notify_wait(adapter); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1752 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1753 | mutex_unlock(&adapter->mbox_lock); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 1754 | return status; |
| 1755 | } |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1756 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1757 | int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, u16 table_size) |
| 1758 | { |
| 1759 | struct be_mcc_wrb *wrb; |
| 1760 | struct be_cmd_req_rss_config *req; |
Sathya Perla | 5d8bee6 | 2011-05-23 20:29:09 +0000 | [diff] [blame] | 1761 | u32 myhash[10] = {0x0123, 0x4567, 0x89AB, 0xCDEF, 0x01EF, |
| 1762 | 0x0123, 0x4567, 0x89AB, 0xCDEF, 0x01EF}; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1763 | int status; |
| 1764 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1765 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1766 | return -1; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1767 | |
| 1768 | wrb = wrb_from_mbox(adapter); |
| 1769 | req = embedded_payload(wrb); |
| 1770 | |
| 1771 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1772 | OPCODE_ETH_RSS_CONFIG); |
| 1773 | |
| 1774 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
| 1775 | OPCODE_ETH_RSS_CONFIG, sizeof(*req)); |
| 1776 | |
| 1777 | req->if_id = cpu_to_le32(adapter->if_handle); |
| 1778 | req->enable_rss = cpu_to_le16(RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4); |
| 1779 | req->cpu_table_size_log2 = cpu_to_le16(fls(table_size) - 1); |
| 1780 | memcpy(req->cpu_table, rsstable, table_size); |
| 1781 | memcpy(req->hash, myhash, sizeof(myhash)); |
| 1782 | be_dws_cpu_to_le(req->hash, sizeof(req->hash)); |
| 1783 | |
| 1784 | status = be_mbox_notify_wait(adapter); |
| 1785 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1786 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1787 | return status; |
| 1788 | } |
| 1789 | |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1790 | /* Uses sync mcc */ |
| 1791 | int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, |
| 1792 | u8 bcn, u8 sts, u8 state) |
| 1793 | { |
| 1794 | struct be_mcc_wrb *wrb; |
| 1795 | struct be_cmd_req_enable_disable_beacon *req; |
| 1796 | int status; |
| 1797 | |
| 1798 | spin_lock_bh(&adapter->mcc_lock); |
| 1799 | |
| 1800 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1801 | if (!wrb) { |
| 1802 | status = -EBUSY; |
| 1803 | goto err; |
| 1804 | } |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1805 | req = embedded_payload(wrb); |
| 1806 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1807 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1808 | OPCODE_COMMON_ENABLE_DISABLE_BEACON); |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1809 | |
| 1810 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1811 | OPCODE_COMMON_ENABLE_DISABLE_BEACON, sizeof(*req)); |
| 1812 | |
| 1813 | req->port_num = port_num; |
| 1814 | req->beacon_state = state; |
| 1815 | req->beacon_duration = bcn; |
| 1816 | req->status_duration = sts; |
| 1817 | |
| 1818 | status = be_mcc_notify_wait(adapter); |
| 1819 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1820 | err: |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1821 | spin_unlock_bh(&adapter->mcc_lock); |
| 1822 | return status; |
| 1823 | } |
| 1824 | |
| 1825 | /* Uses sync mcc */ |
| 1826 | int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state) |
| 1827 | { |
| 1828 | struct be_mcc_wrb *wrb; |
| 1829 | struct be_cmd_req_get_beacon_state *req; |
| 1830 | int status; |
| 1831 | |
| 1832 | spin_lock_bh(&adapter->mcc_lock); |
| 1833 | |
| 1834 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1835 | if (!wrb) { |
| 1836 | status = -EBUSY; |
| 1837 | goto err; |
| 1838 | } |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1839 | req = embedded_payload(wrb); |
| 1840 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1841 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 1842 | OPCODE_COMMON_GET_BEACON_STATE); |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1843 | |
| 1844 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1845 | OPCODE_COMMON_GET_BEACON_STATE, sizeof(*req)); |
| 1846 | |
| 1847 | req->port_num = port_num; |
| 1848 | |
| 1849 | status = be_mcc_notify_wait(adapter); |
| 1850 | if (!status) { |
| 1851 | struct be_cmd_resp_get_beacon_state *resp = |
| 1852 | embedded_payload(wrb); |
| 1853 | *state = resp->beacon_state; |
| 1854 | } |
| 1855 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1856 | err: |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 1857 | spin_unlock_bh(&adapter->mcc_lock); |
| 1858 | return status; |
| 1859 | } |
| 1860 | |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 1861 | int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd, |
| 1862 | u32 data_size, u32 data_offset, const char *obj_name, |
| 1863 | u32 *data_written, u8 *addn_status) |
| 1864 | { |
| 1865 | struct be_mcc_wrb *wrb; |
| 1866 | struct lancer_cmd_req_write_object *req; |
| 1867 | struct lancer_cmd_resp_write_object *resp; |
| 1868 | void *ctxt = NULL; |
| 1869 | int status; |
| 1870 | |
| 1871 | spin_lock_bh(&adapter->mcc_lock); |
| 1872 | adapter->flash_status = 0; |
| 1873 | |
| 1874 | wrb = wrb_from_mccq(adapter); |
| 1875 | if (!wrb) { |
| 1876 | status = -EBUSY; |
| 1877 | goto err_unlock; |
| 1878 | } |
| 1879 | |
| 1880 | req = embedded_payload(wrb); |
| 1881 | |
| 1882 | be_wrb_hdr_prepare(wrb, sizeof(struct lancer_cmd_req_write_object), |
| 1883 | true, 1, OPCODE_COMMON_WRITE_OBJECT); |
| 1884 | wrb->tag1 = CMD_SUBSYSTEM_COMMON; |
| 1885 | |
| 1886 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1887 | OPCODE_COMMON_WRITE_OBJECT, |
| 1888 | sizeof(struct lancer_cmd_req_write_object)); |
| 1889 | |
| 1890 | ctxt = &req->context; |
| 1891 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
| 1892 | write_length, ctxt, data_size); |
| 1893 | |
| 1894 | if (data_size == 0) |
| 1895 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
| 1896 | eof, ctxt, 1); |
| 1897 | else |
| 1898 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
| 1899 | eof, ctxt, 0); |
| 1900 | |
| 1901 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 1902 | req->write_offset = cpu_to_le32(data_offset); |
| 1903 | strcpy(req->object_name, obj_name); |
| 1904 | req->descriptor_count = cpu_to_le32(1); |
| 1905 | req->buf_len = cpu_to_le32(data_size); |
| 1906 | req->addr_low = cpu_to_le32((cmd->dma + |
| 1907 | sizeof(struct lancer_cmd_req_write_object)) |
| 1908 | & 0xFFFFFFFF); |
| 1909 | req->addr_high = cpu_to_le32(upper_32_bits(cmd->dma + |
| 1910 | sizeof(struct lancer_cmd_req_write_object))); |
| 1911 | |
| 1912 | be_mcc_notify(adapter); |
| 1913 | spin_unlock_bh(&adapter->mcc_lock); |
| 1914 | |
| 1915 | if (!wait_for_completion_timeout(&adapter->flash_compl, |
| 1916 | msecs_to_jiffies(12000))) |
| 1917 | status = -1; |
| 1918 | else |
| 1919 | status = adapter->flash_status; |
| 1920 | |
| 1921 | resp = embedded_payload(wrb); |
| 1922 | if (!status) { |
| 1923 | *data_written = le32_to_cpu(resp->actual_write_len); |
| 1924 | } else { |
| 1925 | *addn_status = resp->additional_status; |
| 1926 | status = resp->status; |
| 1927 | } |
| 1928 | |
| 1929 | return status; |
| 1930 | |
| 1931 | err_unlock: |
| 1932 | spin_unlock_bh(&adapter->mcc_lock); |
| 1933 | return status; |
| 1934 | } |
| 1935 | |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1936 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, |
| 1937 | u32 flash_type, u32 flash_opcode, u32 buf_size) |
| 1938 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1939 | struct be_mcc_wrb *wrb; |
Ajit Khaparde | 3f0d456 | 2010-02-09 01:30:35 +0000 | [diff] [blame] | 1940 | struct be_cmd_write_flashrom *req; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1941 | struct be_sge *sge; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1942 | int status; |
| 1943 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1944 | spin_lock_bh(&adapter->mcc_lock); |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 1945 | adapter->flash_status = 0; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1946 | |
| 1947 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1948 | if (!wrb) { |
| 1949 | status = -EBUSY; |
Dan Carpenter | 2892d9c | 2010-05-26 04:46:35 +0000 | [diff] [blame] | 1950 | goto err_unlock; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1951 | } |
| 1952 | req = cmd->va; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1953 | sge = nonembedded_sgl(wrb); |
| 1954 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1955 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1, |
| 1956 | OPCODE_COMMON_WRITE_FLASHROM); |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 1957 | wrb->tag1 = CMD_SUBSYSTEM_COMMON; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1958 | |
| 1959 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1960 | OPCODE_COMMON_WRITE_FLASHROM, cmd->size); |
| 1961 | sge->pa_hi = cpu_to_le32(upper_32_bits(cmd->dma)); |
| 1962 | sge->pa_lo = cpu_to_le32(cmd->dma & 0xFFFFFFFF); |
| 1963 | sge->len = cpu_to_le32(cmd->size); |
| 1964 | |
| 1965 | req->params.op_type = cpu_to_le32(flash_type); |
| 1966 | req->params.op_code = cpu_to_le32(flash_opcode); |
| 1967 | req->params.data_buf_size = cpu_to_le32(buf_size); |
| 1968 | |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 1969 | be_mcc_notify(adapter); |
| 1970 | spin_unlock_bh(&adapter->mcc_lock); |
| 1971 | |
| 1972 | if (!wait_for_completion_timeout(&adapter->flash_compl, |
Sathya Perla | e2edb7d | 2011-08-22 19:41:54 +0000 | [diff] [blame] | 1973 | msecs_to_jiffies(40000))) |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 1974 | status = -1; |
| 1975 | else |
| 1976 | status = adapter->flash_status; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1977 | |
Dan Carpenter | 2892d9c | 2010-05-26 04:46:35 +0000 | [diff] [blame] | 1978 | return status; |
| 1979 | |
| 1980 | err_unlock: |
| 1981 | spin_unlock_bh(&adapter->mcc_lock); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1982 | return status; |
| 1983 | } |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 1984 | |
Ajit Khaparde | 3f0d456 | 2010-02-09 01:30:35 +0000 | [diff] [blame] | 1985 | int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, |
| 1986 | int offset) |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 1987 | { |
| 1988 | struct be_mcc_wrb *wrb; |
| 1989 | struct be_cmd_write_flashrom *req; |
| 1990 | int status; |
| 1991 | |
| 1992 | spin_lock_bh(&adapter->mcc_lock); |
| 1993 | |
| 1994 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1995 | if (!wrb) { |
| 1996 | status = -EBUSY; |
| 1997 | goto err; |
| 1998 | } |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 1999 | req = embedded_payload(wrb); |
| 2000 | |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 2001 | be_wrb_hdr_prepare(wrb, sizeof(*req)+4, true, 0, |
| 2002 | OPCODE_COMMON_READ_FLASHROM); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2003 | |
| 2004 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2005 | OPCODE_COMMON_READ_FLASHROM, sizeof(*req)+4); |
| 2006 | |
Ajit Khaparde | 3f0d456 | 2010-02-09 01:30:35 +0000 | [diff] [blame] | 2007 | req->params.op_type = cpu_to_le32(IMG_TYPE_REDBOOT); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2008 | req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT); |
Ajit Khaparde | 8b93b71 | 2010-03-31 01:57:10 +0000 | [diff] [blame] | 2009 | req->params.offset = cpu_to_le32(offset); |
| 2010 | req->params.data_buf_size = cpu_to_le32(0x4); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2011 | |
| 2012 | status = be_mcc_notify_wait(adapter); |
| 2013 | if (!status) |
| 2014 | memcpy(flashed_crc, req->params.data_buf, 4); |
| 2015 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2016 | err: |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2017 | spin_unlock_bh(&adapter->mcc_lock); |
| 2018 | return status; |
| 2019 | } |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2020 | |
Dan Carpenter | c196b02 | 2010-05-26 04:47:39 +0000 | [diff] [blame] | 2021 | int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2022 | struct be_dma_mem *nonemb_cmd) |
| 2023 | { |
| 2024 | struct be_mcc_wrb *wrb; |
| 2025 | struct be_cmd_req_acpi_wol_magic_config *req; |
| 2026 | struct be_sge *sge; |
| 2027 | int status; |
| 2028 | |
| 2029 | spin_lock_bh(&adapter->mcc_lock); |
| 2030 | |
| 2031 | wrb = wrb_from_mccq(adapter); |
| 2032 | if (!wrb) { |
| 2033 | status = -EBUSY; |
| 2034 | goto err; |
| 2035 | } |
| 2036 | req = nonemb_cmd->va; |
| 2037 | sge = nonembedded_sgl(wrb); |
| 2038 | |
| 2039 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1, |
| 2040 | OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG); |
| 2041 | |
| 2042 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
| 2043 | OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, sizeof(*req)); |
| 2044 | memcpy(req->magic_mac, mac, ETH_ALEN); |
| 2045 | |
| 2046 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 2047 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 2048 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 2049 | |
| 2050 | status = be_mcc_notify_wait(adapter); |
| 2051 | |
| 2052 | err: |
| 2053 | spin_unlock_bh(&adapter->mcc_lock); |
| 2054 | return status; |
| 2055 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2056 | |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 2057 | int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num, |
| 2058 | u8 loopback_type, u8 enable) |
| 2059 | { |
| 2060 | struct be_mcc_wrb *wrb; |
| 2061 | struct be_cmd_req_set_lmode *req; |
| 2062 | int status; |
| 2063 | |
| 2064 | spin_lock_bh(&adapter->mcc_lock); |
| 2065 | |
| 2066 | wrb = wrb_from_mccq(adapter); |
| 2067 | if (!wrb) { |
| 2068 | status = -EBUSY; |
| 2069 | goto err; |
| 2070 | } |
| 2071 | |
| 2072 | req = embedded_payload(wrb); |
| 2073 | |
| 2074 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 2075 | OPCODE_LOWLEVEL_SET_LOOPBACK_MODE); |
| 2076 | |
| 2077 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
| 2078 | OPCODE_LOWLEVEL_SET_LOOPBACK_MODE, |
| 2079 | sizeof(*req)); |
| 2080 | |
| 2081 | req->src_port = port_num; |
| 2082 | req->dest_port = port_num; |
| 2083 | req->loopback_type = loopback_type; |
| 2084 | req->loopback_state = enable; |
| 2085 | |
| 2086 | status = be_mcc_notify_wait(adapter); |
| 2087 | err: |
| 2088 | spin_unlock_bh(&adapter->mcc_lock); |
| 2089 | return status; |
| 2090 | } |
| 2091 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2092 | int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num, |
| 2093 | u32 loopback_type, u32 pkt_size, u32 num_pkts, u64 pattern) |
| 2094 | { |
| 2095 | struct be_mcc_wrb *wrb; |
| 2096 | struct be_cmd_req_loopback_test *req; |
| 2097 | int status; |
| 2098 | |
| 2099 | spin_lock_bh(&adapter->mcc_lock); |
| 2100 | |
| 2101 | wrb = wrb_from_mccq(adapter); |
| 2102 | if (!wrb) { |
| 2103 | status = -EBUSY; |
| 2104 | goto err; |
| 2105 | } |
| 2106 | |
| 2107 | req = embedded_payload(wrb); |
| 2108 | |
| 2109 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 2110 | OPCODE_LOWLEVEL_LOOPBACK_TEST); |
| 2111 | |
| 2112 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
| 2113 | OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req)); |
Sathya Perla | 3ffd051 | 2010-06-01 00:19:33 -0700 | [diff] [blame] | 2114 | req->hdr.timeout = cpu_to_le32(4); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2115 | |
| 2116 | req->pattern = cpu_to_le64(pattern); |
| 2117 | req->src_port = cpu_to_le32(port_num); |
| 2118 | req->dest_port = cpu_to_le32(port_num); |
| 2119 | req->pkt_size = cpu_to_le32(pkt_size); |
| 2120 | req->num_pkts = cpu_to_le32(num_pkts); |
| 2121 | req->loopback_type = cpu_to_le32(loopback_type); |
| 2122 | |
| 2123 | status = be_mcc_notify_wait(adapter); |
| 2124 | if (!status) { |
| 2125 | struct be_cmd_resp_loopback_test *resp = embedded_payload(wrb); |
| 2126 | status = le32_to_cpu(resp->status); |
| 2127 | } |
| 2128 | |
| 2129 | err: |
| 2130 | spin_unlock_bh(&adapter->mcc_lock); |
| 2131 | return status; |
| 2132 | } |
| 2133 | |
| 2134 | int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern, |
| 2135 | u32 byte_cnt, struct be_dma_mem *cmd) |
| 2136 | { |
| 2137 | struct be_mcc_wrb *wrb; |
| 2138 | struct be_cmd_req_ddrdma_test *req; |
| 2139 | struct be_sge *sge; |
| 2140 | int status; |
| 2141 | int i, j = 0; |
| 2142 | |
| 2143 | spin_lock_bh(&adapter->mcc_lock); |
| 2144 | |
| 2145 | wrb = wrb_from_mccq(adapter); |
| 2146 | if (!wrb) { |
| 2147 | status = -EBUSY; |
| 2148 | goto err; |
| 2149 | } |
| 2150 | req = cmd->va; |
| 2151 | sge = nonembedded_sgl(wrb); |
| 2152 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1, |
| 2153 | OPCODE_LOWLEVEL_HOST_DDR_DMA); |
| 2154 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
| 2155 | OPCODE_LOWLEVEL_HOST_DDR_DMA, cmd->size); |
| 2156 | |
| 2157 | sge->pa_hi = cpu_to_le32(upper_32_bits(cmd->dma)); |
| 2158 | sge->pa_lo = cpu_to_le32(cmd->dma & 0xFFFFFFFF); |
| 2159 | sge->len = cpu_to_le32(cmd->size); |
| 2160 | |
| 2161 | req->pattern = cpu_to_le64(pattern); |
| 2162 | req->byte_count = cpu_to_le32(byte_cnt); |
| 2163 | for (i = 0; i < byte_cnt; i++) { |
| 2164 | req->snd_buff[i] = (u8)(pattern >> (j*8)); |
| 2165 | j++; |
| 2166 | if (j > 7) |
| 2167 | j = 0; |
| 2168 | } |
| 2169 | |
| 2170 | status = be_mcc_notify_wait(adapter); |
| 2171 | |
| 2172 | if (!status) { |
| 2173 | struct be_cmd_resp_ddrdma_test *resp; |
| 2174 | resp = cmd->va; |
| 2175 | if ((memcmp(resp->rcv_buff, req->snd_buff, byte_cnt) != 0) || |
| 2176 | resp->snd_err) { |
| 2177 | status = -1; |
| 2178 | } |
| 2179 | } |
| 2180 | |
| 2181 | err: |
| 2182 | spin_unlock_bh(&adapter->mcc_lock); |
| 2183 | return status; |
| 2184 | } |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2185 | |
Dan Carpenter | c196b02 | 2010-05-26 04:47:39 +0000 | [diff] [blame] | 2186 | int be_cmd_get_seeprom_data(struct be_adapter *adapter, |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2187 | struct be_dma_mem *nonemb_cmd) |
| 2188 | { |
| 2189 | struct be_mcc_wrb *wrb; |
| 2190 | struct be_cmd_req_seeprom_read *req; |
| 2191 | struct be_sge *sge; |
| 2192 | int status; |
| 2193 | |
| 2194 | spin_lock_bh(&adapter->mcc_lock); |
| 2195 | |
| 2196 | wrb = wrb_from_mccq(adapter); |
Ajit Khaparde | e45ff01 | 2011-02-04 17:18:28 +0000 | [diff] [blame] | 2197 | if (!wrb) { |
| 2198 | status = -EBUSY; |
| 2199 | goto err; |
| 2200 | } |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2201 | req = nonemb_cmd->va; |
| 2202 | sge = nonembedded_sgl(wrb); |
| 2203 | |
| 2204 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1, |
| 2205 | OPCODE_COMMON_SEEPROM_READ); |
| 2206 | |
| 2207 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2208 | OPCODE_COMMON_SEEPROM_READ, sizeof(*req)); |
| 2209 | |
| 2210 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 2211 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 2212 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 2213 | |
| 2214 | status = be_mcc_notify_wait(adapter); |
| 2215 | |
Ajit Khaparde | e45ff01 | 2011-02-04 17:18:28 +0000 | [diff] [blame] | 2216 | err: |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2217 | spin_unlock_bh(&adapter->mcc_lock); |
| 2218 | return status; |
| 2219 | } |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2220 | |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2221 | int be_cmd_get_phy_info(struct be_adapter *adapter, |
| 2222 | struct be_phy_info *phy_info) |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2223 | { |
| 2224 | struct be_mcc_wrb *wrb; |
| 2225 | struct be_cmd_req_get_phy_info *req; |
| 2226 | struct be_sge *sge; |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2227 | struct be_dma_mem cmd; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2228 | int status; |
| 2229 | |
| 2230 | spin_lock_bh(&adapter->mcc_lock); |
| 2231 | |
| 2232 | wrb = wrb_from_mccq(adapter); |
| 2233 | if (!wrb) { |
| 2234 | status = -EBUSY; |
| 2235 | goto err; |
| 2236 | } |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2237 | cmd.size = sizeof(struct be_cmd_req_get_phy_info); |
| 2238 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, |
| 2239 | &cmd.dma); |
| 2240 | if (!cmd.va) { |
| 2241 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
| 2242 | status = -ENOMEM; |
| 2243 | goto err; |
| 2244 | } |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2245 | |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2246 | req = cmd.va; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2247 | sge = nonembedded_sgl(wrb); |
| 2248 | |
| 2249 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1, |
| 2250 | OPCODE_COMMON_GET_PHY_DETAILS); |
| 2251 | |
| 2252 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2253 | OPCODE_COMMON_GET_PHY_DETAILS, |
| 2254 | sizeof(*req)); |
| 2255 | |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2256 | sge->pa_hi = cpu_to_le32(upper_32_bits(cmd.dma)); |
| 2257 | sge->pa_lo = cpu_to_le32(cmd.dma & 0xFFFFFFFF); |
| 2258 | sge->len = cpu_to_le32(cmd.size); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2259 | |
| 2260 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2261 | if (!status) { |
| 2262 | struct be_phy_info *resp_phy_info = |
| 2263 | cmd.va + sizeof(struct be_cmd_req_hdr); |
| 2264 | phy_info->phy_type = le16_to_cpu(resp_phy_info->phy_type); |
| 2265 | phy_info->interface_type = |
| 2266 | le16_to_cpu(resp_phy_info->interface_type); |
| 2267 | } |
| 2268 | pci_free_consistent(adapter->pdev, cmd.size, |
| 2269 | cmd.va, cmd.dma); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2270 | err: |
| 2271 | spin_unlock_bh(&adapter->mcc_lock); |
| 2272 | return status; |
| 2273 | } |
Ajit Khaparde | e1d1873 | 2010-07-23 01:52:13 +0000 | [diff] [blame] | 2274 | |
| 2275 | int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain) |
| 2276 | { |
| 2277 | struct be_mcc_wrb *wrb; |
| 2278 | struct be_cmd_req_set_qos *req; |
| 2279 | int status; |
| 2280 | |
| 2281 | spin_lock_bh(&adapter->mcc_lock); |
| 2282 | |
| 2283 | wrb = wrb_from_mccq(adapter); |
| 2284 | if (!wrb) { |
| 2285 | status = -EBUSY; |
| 2286 | goto err; |
| 2287 | } |
| 2288 | |
| 2289 | req = embedded_payload(wrb); |
| 2290 | |
| 2291 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 2292 | OPCODE_COMMON_SET_QOS); |
| 2293 | |
| 2294 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2295 | OPCODE_COMMON_SET_QOS, sizeof(*req)); |
| 2296 | |
| 2297 | req->hdr.domain = domain; |
Ajit Khaparde | 6bff57a | 2011-02-11 13:33:02 +0000 | [diff] [blame] | 2298 | req->valid_bits = cpu_to_le32(BE_QOS_BITS_NIC); |
| 2299 | req->max_bps_nic = cpu_to_le32(bps); |
Ajit Khaparde | e1d1873 | 2010-07-23 01:52:13 +0000 | [diff] [blame] | 2300 | |
| 2301 | status = be_mcc_notify_wait(adapter); |
| 2302 | |
| 2303 | err: |
| 2304 | spin_unlock_bh(&adapter->mcc_lock); |
| 2305 | return status; |
| 2306 | } |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2307 | |
| 2308 | int be_cmd_get_cntl_attributes(struct be_adapter *adapter) |
| 2309 | { |
| 2310 | struct be_mcc_wrb *wrb; |
| 2311 | struct be_cmd_req_cntl_attribs *req; |
| 2312 | struct be_cmd_resp_cntl_attribs *resp; |
| 2313 | struct be_sge *sge; |
| 2314 | int status; |
| 2315 | int payload_len = max(sizeof(*req), sizeof(*resp)); |
| 2316 | struct mgmt_controller_attrib *attribs; |
| 2317 | struct be_dma_mem attribs_cmd; |
| 2318 | |
| 2319 | memset(&attribs_cmd, 0, sizeof(struct be_dma_mem)); |
| 2320 | attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs); |
| 2321 | attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size, |
| 2322 | &attribs_cmd.dma); |
| 2323 | if (!attribs_cmd.va) { |
| 2324 | dev_err(&adapter->pdev->dev, |
| 2325 | "Memory allocation failure\n"); |
| 2326 | return -ENOMEM; |
| 2327 | } |
| 2328 | |
| 2329 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2330 | return -1; |
| 2331 | |
| 2332 | wrb = wrb_from_mbox(adapter); |
| 2333 | if (!wrb) { |
| 2334 | status = -EBUSY; |
| 2335 | goto err; |
| 2336 | } |
| 2337 | req = attribs_cmd.va; |
| 2338 | sge = nonembedded_sgl(wrb); |
| 2339 | |
| 2340 | be_wrb_hdr_prepare(wrb, payload_len, false, 1, |
| 2341 | OPCODE_COMMON_GET_CNTL_ATTRIBUTES); |
| 2342 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2343 | OPCODE_COMMON_GET_CNTL_ATTRIBUTES, payload_len); |
| 2344 | sge->pa_hi = cpu_to_le32(upper_32_bits(attribs_cmd.dma)); |
| 2345 | sge->pa_lo = cpu_to_le32(attribs_cmd.dma & 0xFFFFFFFF); |
| 2346 | sge->len = cpu_to_le32(attribs_cmd.size); |
| 2347 | |
| 2348 | status = be_mbox_notify_wait(adapter); |
| 2349 | if (!status) { |
Joe Perches | 43d620c | 2011-06-16 19:08:06 +0000 | [diff] [blame] | 2350 | attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2351 | adapter->hba_port_num = attribs->hba_attribs.phy_port; |
| 2352 | } |
| 2353 | |
| 2354 | err: |
| 2355 | mutex_unlock(&adapter->mbox_lock); |
| 2356 | pci_free_consistent(adapter->pdev, attribs_cmd.size, attribs_cmd.va, |
| 2357 | attribs_cmd.dma); |
| 2358 | return status; |
| 2359 | } |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2360 | |
| 2361 | /* Uses mbox */ |
Sathya Perla | 2dc1deb | 2011-07-19 19:52:33 +0000 | [diff] [blame] | 2362 | int be_cmd_req_native_mode(struct be_adapter *adapter) |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2363 | { |
| 2364 | struct be_mcc_wrb *wrb; |
| 2365 | struct be_cmd_req_set_func_cap *req; |
| 2366 | int status; |
| 2367 | |
| 2368 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2369 | return -1; |
| 2370 | |
| 2371 | wrb = wrb_from_mbox(adapter); |
| 2372 | if (!wrb) { |
| 2373 | status = -EBUSY; |
| 2374 | goto err; |
| 2375 | } |
| 2376 | |
| 2377 | req = embedded_payload(wrb); |
| 2378 | |
| 2379 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, |
| 2380 | OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP); |
| 2381 | |
| 2382 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2383 | OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP, sizeof(*req)); |
| 2384 | |
| 2385 | req->valid_cap_flags = cpu_to_le32(CAPABILITY_SW_TIMESTAMPS | |
| 2386 | CAPABILITY_BE3_NATIVE_ERX_API); |
| 2387 | req->cap_flags = cpu_to_le32(CAPABILITY_BE3_NATIVE_ERX_API); |
| 2388 | |
| 2389 | status = be_mbox_notify_wait(adapter); |
| 2390 | if (!status) { |
| 2391 | struct be_cmd_resp_set_func_cap *resp = embedded_payload(wrb); |
| 2392 | adapter->be3_native = le32_to_cpu(resp->cap_flags) & |
| 2393 | CAPABILITY_BE3_NATIVE_ERX_API; |
| 2394 | } |
| 2395 | err: |
| 2396 | mutex_unlock(&adapter->mbox_lock); |
| 2397 | return status; |
| 2398 | } |