Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1 | /* |
Vasundhara Volam | 4026382 | 2014-02-12 16:09:07 +0530 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2014 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 | |
Parav Pandit | 6a4ab66 | 2012-03-26 14:27:12 +0000 | [diff] [blame] | 18 | #include <linux/module.h> |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 19 | #include "be.h" |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 20 | #include "be_cmds.h" |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 21 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 22 | static struct be_cmd_priv_map cmd_priv_map[] = { |
| 23 | { |
| 24 | OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, |
| 25 | CMD_SUBSYSTEM_ETH, |
| 26 | BE_PRIV_LNKMGMT | BE_PRIV_VHADM | |
| 27 | BE_PRIV_DEVCFG | BE_PRIV_DEVSEC |
| 28 | }, |
| 29 | { |
| 30 | OPCODE_COMMON_GET_FLOW_CONTROL, |
| 31 | CMD_SUBSYSTEM_COMMON, |
| 32 | BE_PRIV_LNKQUERY | BE_PRIV_VHADM | |
| 33 | BE_PRIV_DEVCFG | BE_PRIV_DEVSEC |
| 34 | }, |
| 35 | { |
| 36 | OPCODE_COMMON_SET_FLOW_CONTROL, |
| 37 | CMD_SUBSYSTEM_COMMON, |
| 38 | BE_PRIV_LNKMGMT | BE_PRIV_VHADM | |
| 39 | BE_PRIV_DEVCFG | BE_PRIV_DEVSEC |
| 40 | }, |
| 41 | { |
| 42 | OPCODE_ETH_GET_PPORT_STATS, |
| 43 | CMD_SUBSYSTEM_ETH, |
| 44 | BE_PRIV_LNKMGMT | BE_PRIV_VHADM | |
| 45 | BE_PRIV_DEVCFG | BE_PRIV_DEVSEC |
| 46 | }, |
| 47 | { |
| 48 | OPCODE_COMMON_GET_PHY_DETAILS, |
| 49 | CMD_SUBSYSTEM_COMMON, |
| 50 | BE_PRIV_LNKMGMT | BE_PRIV_VHADM | |
| 51 | BE_PRIV_DEVCFG | BE_PRIV_DEVSEC |
| 52 | } |
| 53 | }; |
| 54 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 55 | static bool be_cmd_allowed(struct be_adapter *adapter, u8 opcode, u8 subsystem) |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 56 | { |
| 57 | int i; |
| 58 | int num_entries = sizeof(cmd_priv_map)/sizeof(struct be_cmd_priv_map); |
| 59 | u32 cmd_privileges = adapter->cmd_privileges; |
| 60 | |
| 61 | for (i = 0; i < num_entries; i++) |
| 62 | if (opcode == cmd_priv_map[i].opcode && |
| 63 | subsystem == cmd_priv_map[i].subsystem) |
| 64 | if (!(cmd_privileges & cmd_priv_map[i].priv_mask)) |
| 65 | return false; |
| 66 | |
| 67 | return true; |
| 68 | } |
| 69 | |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 70 | static inline void *embedded_payload(struct be_mcc_wrb *wrb) |
| 71 | { |
| 72 | return wrb->payload.embedded_payload; |
| 73 | } |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 74 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 75 | static void be_mcc_notify(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 76 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 77 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 78 | u32 val = 0; |
| 79 | |
Sathya Perla | 6589ade | 2011-11-10 19:18:00 +0000 | [diff] [blame] | 80 | if (be_error(adapter)) |
Ajit Khaparde | 7acc208 | 2011-02-11 13:38:17 +0000 | [diff] [blame] | 81 | return; |
Ajit Khaparde | 7acc208 | 2011-02-11 13:38:17 +0000 | [diff] [blame] | 82 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 83 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; |
| 84 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; |
Sathya Perla | f3eb62d | 2010-06-29 00:11:17 +0000 | [diff] [blame] | 85 | |
| 86 | wmb(); |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 87 | iowrite32(val, adapter->db + DB_MCCQ_OFFSET); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /* To check if valid bit is set, check the entire word as we don't know |
| 91 | * the endianness of the data (old entry is host endian while a new entry is |
| 92 | * little endian) */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 93 | 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] | 94 | { |
Sathya Perla | 9e9ff4b | 2013-02-12 23:05:19 +0000 | [diff] [blame] | 95 | u32 flags; |
| 96 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 97 | if (compl->flags != 0) { |
Sathya Perla | 9e9ff4b | 2013-02-12 23:05:19 +0000 | [diff] [blame] | 98 | flags = le32_to_cpu(compl->flags); |
| 99 | if (flags & CQE_FLAGS_VALID_MASK) { |
| 100 | compl->flags = flags; |
| 101 | return true; |
| 102 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 103 | } |
Sathya Perla | 9e9ff4b | 2013-02-12 23:05:19 +0000 | [diff] [blame] | 104 | return false; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /* Need to reset the entire word that houses the valid bit */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 108 | static inline void be_mcc_compl_use(struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 109 | { |
| 110 | compl->flags = 0; |
| 111 | } |
| 112 | |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 113 | static struct be_cmd_resp_hdr *be_decode_resp_hdr(u32 tag0, u32 tag1) |
| 114 | { |
| 115 | unsigned long addr; |
| 116 | |
| 117 | addr = tag1; |
| 118 | addr = ((addr << 16) << 16) | tag0; |
| 119 | return (void *)addr; |
| 120 | } |
| 121 | |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 122 | static bool be_skip_err_log(u8 opcode, u16 base_status, u16 addl_status) |
| 123 | { |
| 124 | if (base_status == MCC_STATUS_NOT_SUPPORTED || |
| 125 | base_status == MCC_STATUS_ILLEGAL_REQUEST || |
| 126 | addl_status == MCC_ADDL_STATUS_TOO_MANY_INTERFACES || |
| 127 | (opcode == OPCODE_COMMON_WRITE_FLASHROM && |
| 128 | (base_status == MCC_STATUS_ILLEGAL_FIELD || |
| 129 | addl_status == MCC_ADDL_STATUS_FLASH_IMAGE_CRC_MISMATCH))) |
| 130 | return true; |
| 131 | else |
| 132 | return false; |
| 133 | } |
| 134 | |
Sathya Perla | 559b633 | 2014-05-30 19:06:27 +0530 | [diff] [blame] | 135 | /* Place holder for all the async MCC cmds wherein the caller is not in a busy |
| 136 | * loop (has not issued be_mcc_notify_wait()) |
| 137 | */ |
| 138 | static void be_async_cmd_process(struct be_adapter *adapter, |
| 139 | struct be_mcc_compl *compl, |
| 140 | struct be_cmd_resp_hdr *resp_hdr) |
| 141 | { |
| 142 | enum mcc_base_status base_status = base_status(compl->status); |
| 143 | u8 opcode = 0, subsystem = 0; |
| 144 | |
| 145 | if (resp_hdr) { |
| 146 | opcode = resp_hdr->opcode; |
| 147 | subsystem = resp_hdr->subsystem; |
| 148 | } |
| 149 | |
| 150 | if (opcode == OPCODE_LOWLEVEL_LOOPBACK_TEST && |
| 151 | subsystem == CMD_SUBSYSTEM_LOWLEVEL) { |
| 152 | complete(&adapter->et_cmd_compl); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | if ((opcode == OPCODE_COMMON_WRITE_FLASHROM || |
| 157 | opcode == OPCODE_COMMON_WRITE_OBJECT) && |
| 158 | subsystem == CMD_SUBSYSTEM_COMMON) { |
| 159 | adapter->flash_status = compl->status; |
| 160 | complete(&adapter->et_cmd_compl); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | if ((opcode == OPCODE_ETH_GET_STATISTICS || |
| 165 | opcode == OPCODE_ETH_GET_PPORT_STATS) && |
| 166 | subsystem == CMD_SUBSYSTEM_ETH && |
| 167 | base_status == MCC_STATUS_SUCCESS) { |
| 168 | be_parse_stats(adapter); |
| 169 | adapter->stats_cmd_sent = false; |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | if (opcode == OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES && |
| 174 | subsystem == CMD_SUBSYSTEM_COMMON) { |
| 175 | if (base_status == MCC_STATUS_SUCCESS) { |
| 176 | struct be_cmd_resp_get_cntl_addnl_attribs *resp = |
| 177 | (void *)resp_hdr; |
| 178 | adapter->drv_stats.be_on_die_temperature = |
| 179 | resp->on_die_temperature; |
| 180 | } else { |
| 181 | adapter->be_get_temp_freq = 0; |
| 182 | } |
| 183 | return; |
| 184 | } |
| 185 | } |
| 186 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 187 | static int be_mcc_compl_process(struct be_adapter *adapter, |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 188 | struct be_mcc_compl *compl) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 189 | { |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 190 | enum mcc_base_status base_status; |
| 191 | enum mcc_addl_status addl_status; |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 192 | struct be_cmd_resp_hdr *resp_hdr; |
| 193 | u8 opcode = 0, subsystem = 0; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 194 | |
| 195 | /* Just swap the status to host endian; mcc tag is opaquely copied |
| 196 | * from mcc_wrb */ |
| 197 | be_dws_le_to_cpu(compl, 4); |
| 198 | |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 199 | base_status = base_status(compl->status); |
| 200 | addl_status = addl_status(compl->status); |
Vasundhara Volam | 96c9b2e | 2014-05-30 19:06:25 +0530 | [diff] [blame] | 201 | |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 202 | resp_hdr = be_decode_resp_hdr(compl->tag0, compl->tag1); |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 203 | if (resp_hdr) { |
| 204 | opcode = resp_hdr->opcode; |
| 205 | subsystem = resp_hdr->subsystem; |
| 206 | } |
| 207 | |
Sathya Perla | 559b633 | 2014-05-30 19:06:27 +0530 | [diff] [blame] | 208 | be_async_cmd_process(adapter, compl, resp_hdr); |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 209 | |
Sathya Perla | 559b633 | 2014-05-30 19:06:27 +0530 | [diff] [blame] | 210 | if (base_status != MCC_STATUS_SUCCESS && |
| 211 | !be_skip_err_log(opcode, base_status, addl_status)) { |
Vasundhara Volam | 96c9b2e | 2014-05-30 19:06:25 +0530 | [diff] [blame] | 212 | |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 213 | if (base_status == MCC_STATUS_UNAUTHORIZED_REQUEST) { |
Vasundhara Volam | 97f1d8c | 2012-06-13 19:51:44 +0000 | [diff] [blame] | 214 | dev_warn(&adapter->pdev->dev, |
Vasundhara Volam | 522609f | 2012-08-28 20:37:44 +0000 | [diff] [blame] | 215 | "VF is not privileged to issue opcode %d-%d\n", |
Vasundhara Volam | 97f1d8c | 2012-06-13 19:51:44 +0000 | [diff] [blame] | 216 | opcode, subsystem); |
Sathya Perla | 2b3f291 | 2011-06-29 23:32:56 +0000 | [diff] [blame] | 217 | } else { |
Vasundhara Volam | 97f1d8c | 2012-06-13 19:51:44 +0000 | [diff] [blame] | 218 | dev_err(&adapter->pdev->dev, |
| 219 | "opcode %d-%d failed:status %d-%d\n", |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 220 | opcode, subsystem, base_status, addl_status); |
Sathya Perla | 2b3f291 | 2011-06-29 23:32:56 +0000 | [diff] [blame] | 221 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 222 | } |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 223 | return compl->status; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 226 | /* 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] | 227 | static void be_async_link_state_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 228 | struct be_mcc_compl *compl) |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 229 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 230 | struct be_async_event_link_state *evt = |
| 231 | (struct be_async_event_link_state *)compl; |
| 232 | |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 233 | /* When link status changes, link speed must be re-queried from FW */ |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 234 | adapter->phy.link_speed = -1; |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 235 | |
Suresh Reddy | bdce2ad | 2014-03-11 18:53:04 +0530 | [diff] [blame] | 236 | /* On BEx the FW does not send a separate link status |
| 237 | * notification for physical and logical link. |
| 238 | * On other chips just process the logical link |
| 239 | * status notification |
| 240 | */ |
| 241 | if (!BEx_chip(adapter) && |
Padmanabh Ratnakar | 2e177a5 | 2012-07-18 02:52:15 +0000 | [diff] [blame] | 242 | !(evt->port_link_status & LOGICAL_LINK_STATUS_MASK)) |
| 243 | return; |
| 244 | |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 245 | /* For the initial link status do not rely on the ASYNC event as |
| 246 | * it may not be received in some cases. |
| 247 | */ |
| 248 | if (adapter->flags & BE_FLAGS_LINK_STATUS_INIT) |
Suresh Reddy | bdce2ad | 2014-03-11 18:53:04 +0530 | [diff] [blame] | 249 | be_link_status_update(adapter, |
| 250 | evt->port_link_status & LINK_STATUS_MASK); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 253 | /* Grp5 CoS Priority evt */ |
| 254 | static void be_async_grp5_cos_priority_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 255 | struct be_mcc_compl *compl) |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 256 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 257 | struct be_async_event_grp5_cos_priority *evt = |
| 258 | (struct be_async_event_grp5_cos_priority *)compl; |
| 259 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 260 | if (evt->valid) { |
| 261 | adapter->vlan_prio_bmap = evt->available_priority_bmap; |
Ajit Khaparde | 60964dd | 2011-02-11 13:37:25 +0000 | [diff] [blame] | 262 | adapter->recommended_prio &= ~VLAN_PRIO_MASK; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 263 | adapter->recommended_prio = |
| 264 | evt->reco_default_priority << VLAN_PRIO_SHIFT; |
| 265 | } |
| 266 | } |
| 267 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 268 | /* Grp5 QOS Speed evt: qos_link_speed is in units of 10 Mbps */ |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 269 | static void be_async_grp5_qos_speed_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 270 | struct be_mcc_compl *compl) |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 271 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 272 | struct be_async_event_grp5_qos_link_speed *evt = |
| 273 | (struct be_async_event_grp5_qos_link_speed *)compl; |
| 274 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 275 | if (adapter->phy.link_speed >= 0 && |
| 276 | evt->physical_port == adapter->port_num) |
| 277 | adapter->phy.link_speed = le16_to_cpu(evt->qos_link_speed) * 10; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 280 | /*Grp5 PVID evt*/ |
| 281 | static void be_async_grp5_pvid_state_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 282 | struct be_mcc_compl *compl) |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 283 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 284 | struct be_async_event_grp5_pvid_state *evt = |
| 285 | (struct be_async_event_grp5_pvid_state *)compl; |
| 286 | |
Ravikumar Nelavelli | bdac85b | 2014-03-11 18:53:05 +0530 | [diff] [blame] | 287 | if (evt->enabled) { |
Somnath Kotur | 939cf30 | 2011-08-18 21:51:49 -0700 | [diff] [blame] | 288 | adapter->pvid = le16_to_cpu(evt->tag) & VLAN_VID_MASK; |
Ravikumar Nelavelli | bdac85b | 2014-03-11 18:53:05 +0530 | [diff] [blame] | 289 | dev_info(&adapter->pdev->dev, "LPVID: %d\n", adapter->pvid); |
| 290 | } else { |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 291 | adapter->pvid = 0; |
Ravikumar Nelavelli | bdac85b | 2014-03-11 18:53:05 +0530 | [diff] [blame] | 292 | } |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 295 | static void be_async_grp5_evt_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 296 | struct be_mcc_compl *compl) |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 297 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 298 | u8 event_type = (compl->flags >> ASYNC_EVENT_TYPE_SHIFT) & |
| 299 | ASYNC_EVENT_TYPE_MASK; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 300 | |
| 301 | switch (event_type) { |
| 302 | case ASYNC_EVENT_COS_PRIORITY: |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 303 | be_async_grp5_cos_priority_process(adapter, compl); |
| 304 | break; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 305 | case ASYNC_EVENT_QOS_SPEED: |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 306 | be_async_grp5_qos_speed_process(adapter, compl); |
| 307 | break; |
Ajit Khaparde | 3968fa1 | 2011-02-20 11:41:53 +0000 | [diff] [blame] | 308 | case ASYNC_EVENT_PVID_STATE: |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 309 | be_async_grp5_pvid_state_process(adapter, compl); |
| 310 | break; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 311 | default: |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 312 | break; |
| 313 | } |
| 314 | } |
| 315 | |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 316 | static void be_async_dbg_evt_process(struct be_adapter *adapter, |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 317 | struct be_mcc_compl *cmp) |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 318 | { |
| 319 | u8 event_type = 0; |
| 320 | struct be_async_event_qnq *evt = (struct be_async_event_qnq *) cmp; |
| 321 | |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 322 | event_type = (cmp->flags >> ASYNC_EVENT_TYPE_SHIFT) & |
| 323 | ASYNC_EVENT_TYPE_MASK; |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 324 | |
| 325 | switch (event_type) { |
| 326 | case ASYNC_DEBUG_EVENT_TYPE_QNQ: |
| 327 | if (evt->valid) |
| 328 | adapter->qnq_vid = le16_to_cpu(evt->vlan_tag); |
| 329 | adapter->flags |= BE_FLAGS_QNQ_ASYNC_EVT_RCVD; |
| 330 | break; |
| 331 | default: |
Vasundhara Volam | 05ccaa2 | 2013-08-06 09:27:19 +0530 | [diff] [blame] | 332 | dev_warn(&adapter->pdev->dev, "Unknown debug event 0x%x!\n", |
| 333 | event_type); |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 334 | break; |
| 335 | } |
| 336 | } |
| 337 | |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 338 | static inline bool is_link_state_evt(u32 flags) |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 339 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 340 | return ((flags >> ASYNC_EVENT_CODE_SHIFT) & ASYNC_EVENT_CODE_MASK) == |
| 341 | ASYNC_EVENT_CODE_LINK_STATE; |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 342 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 343 | |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 344 | static inline bool is_grp5_evt(u32 flags) |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 345 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 346 | return ((flags >> ASYNC_EVENT_CODE_SHIFT) & ASYNC_EVENT_CODE_MASK) == |
| 347 | ASYNC_EVENT_CODE_GRP_5; |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 350 | static inline bool is_dbg_evt(u32 flags) |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 351 | { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 352 | return ((flags >> ASYNC_EVENT_CODE_SHIFT) & ASYNC_EVENT_CODE_MASK) == |
| 353 | ASYNC_EVENT_CODE_QNQ; |
| 354 | } |
| 355 | |
| 356 | static void be_mcc_event_process(struct be_adapter *adapter, |
| 357 | struct be_mcc_compl *compl) |
| 358 | { |
| 359 | if (is_link_state_evt(compl->flags)) |
| 360 | be_async_link_state_process(adapter, compl); |
| 361 | else if (is_grp5_evt(compl->flags)) |
| 362 | be_async_grp5_evt_process(adapter, compl); |
| 363 | else if (is_dbg_evt(compl->flags)) |
| 364 | be_async_dbg_evt_process(adapter, compl); |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 367 | 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] | 368 | { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 369 | struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 370 | struct be_mcc_compl *compl = queue_tail_node(mcc_cq); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 371 | |
| 372 | if (be_mcc_compl_is_new(compl)) { |
| 373 | queue_tail_inc(mcc_cq); |
| 374 | return compl; |
| 375 | } |
| 376 | return NULL; |
| 377 | } |
| 378 | |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 379 | void be_async_mcc_enable(struct be_adapter *adapter) |
| 380 | { |
| 381 | spin_lock_bh(&adapter->mcc_cq_lock); |
| 382 | |
| 383 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, 0); |
| 384 | adapter->mcc_obj.rearm_cq = true; |
| 385 | |
| 386 | spin_unlock_bh(&adapter->mcc_cq_lock); |
| 387 | } |
| 388 | |
| 389 | void be_async_mcc_disable(struct be_adapter *adapter) |
| 390 | { |
Sathya Perla | a323d9b | 2012-12-17 19:38:50 +0000 | [diff] [blame] | 391 | spin_lock_bh(&adapter->mcc_cq_lock); |
| 392 | |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 393 | adapter->mcc_obj.rearm_cq = false; |
Sathya Perla | a323d9b | 2012-12-17 19:38:50 +0000 | [diff] [blame] | 394 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, false, 0); |
| 395 | |
| 396 | spin_unlock_bh(&adapter->mcc_cq_lock); |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 399 | int be_process_mcc(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 400 | { |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 401 | struct be_mcc_compl *compl; |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 402 | int num = 0, status = 0; |
Sathya Perla | 7a1e9b2 | 2010-02-17 01:35:11 +0000 | [diff] [blame] | 403 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 404 | |
Amerigo Wang | 072a9c4 | 2012-08-24 21:41:11 +0000 | [diff] [blame] | 405 | spin_lock(&adapter->mcc_cq_lock); |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 406 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 407 | while ((compl = be_mcc_compl_get(adapter))) { |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 408 | if (compl->flags & CQE_FLAGS_ASYNC_MASK) { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 409 | be_mcc_event_process(adapter, compl); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 410 | } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { |
Sathya Perla | 3acf19d | 2014-05-30 19:06:28 +0530 | [diff] [blame] | 411 | status = be_mcc_compl_process(adapter, compl); |
| 412 | atomic_dec(&mcc_obj->q.used); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 413 | } |
| 414 | be_mcc_compl_use(compl); |
| 415 | num++; |
| 416 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 417 | |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 418 | if (num) |
| 419 | be_cq_notify(adapter, mcc_obj->cq.id, mcc_obj->rearm_cq, num); |
| 420 | |
Amerigo Wang | 072a9c4 | 2012-08-24 21:41:11 +0000 | [diff] [blame] | 421 | spin_unlock(&adapter->mcc_cq_lock); |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 422 | return status; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 425 | /* Wait till no more pending mcc requests are present */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 426 | static int be_mcc_wait_compl(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 427 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 428 | #define mcc_timeout 120000 /* 12s timeout */ |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 429 | int i, status = 0; |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 430 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 431 | |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 432 | for (i = 0; i < mcc_timeout; i++) { |
Sathya Perla | 6589ade | 2011-11-10 19:18:00 +0000 | [diff] [blame] | 433 | if (be_error(adapter)) |
| 434 | return -EIO; |
| 435 | |
Amerigo Wang | 072a9c4 | 2012-08-24 21:41:11 +0000 | [diff] [blame] | 436 | local_bh_disable(); |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 437 | status = be_process_mcc(adapter); |
Amerigo Wang | 072a9c4 | 2012-08-24 21:41:11 +0000 | [diff] [blame] | 438 | local_bh_enable(); |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 439 | |
| 440 | if (atomic_read(&mcc_obj->q.used) == 0) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 441 | break; |
| 442 | udelay(100); |
| 443 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 444 | if (i == mcc_timeout) { |
Sathya Perla | 6589ade | 2011-11-10 19:18:00 +0000 | [diff] [blame] | 445 | dev_err(&adapter->pdev->dev, "FW not responding\n"); |
| 446 | adapter->fw_timeout = true; |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 447 | return -EIO; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 448 | } |
Sathya Perla | f31e50a | 2010-03-02 03:56:39 -0800 | [diff] [blame] | 449 | return status; |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | /* Notify MCC requests and wait for completion */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 453 | static int be_mcc_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 454 | { |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 455 | int status; |
| 456 | struct be_mcc_wrb *wrb; |
| 457 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
| 458 | u16 index = mcc_obj->q.head; |
| 459 | struct be_cmd_resp_hdr *resp; |
| 460 | |
| 461 | index_dec(&index, mcc_obj->q.len); |
| 462 | wrb = queue_index_node(&mcc_obj->q, index); |
| 463 | |
| 464 | resp = be_decode_resp_hdr(wrb->tag0, wrb->tag1); |
| 465 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 466 | be_mcc_notify(adapter); |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 467 | |
| 468 | status = be_mcc_wait_compl(adapter); |
| 469 | if (status == -EIO) |
| 470 | goto out; |
| 471 | |
Kalesh AP | 4c60005 | 2014-05-30 19:06:26 +0530 | [diff] [blame] | 472 | status = (resp->base_status | |
| 473 | ((resp->addl_status & CQE_ADDL_STATUS_MASK) << |
| 474 | CQE_ADDL_STATUS_SHIFT)); |
Padmanabh Ratnakar | 652bf64 | 2012-04-25 01:47:03 +0000 | [diff] [blame] | 475 | out: |
| 476 | return status; |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 477 | } |
| 478 | |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 479 | 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] | 480 | { |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 481 | int msecs = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 482 | u32 ready; |
| 483 | |
| 484 | do { |
Sathya Perla | 6589ade | 2011-11-10 19:18:00 +0000 | [diff] [blame] | 485 | if (be_error(adapter)) |
| 486 | return -EIO; |
| 487 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 488 | ready = ioread32(db); |
Sathya Perla | 434b364 | 2011-11-10 19:17:59 +0000 | [diff] [blame] | 489 | if (ready == 0xffffffff) |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 490 | return -1; |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 491 | |
| 492 | ready &= MPU_MAILBOX_DB_RDY_MASK; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 493 | if (ready) |
| 494 | break; |
| 495 | |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 496 | if (msecs > 4000) { |
Sathya Perla | 6589ade | 2011-11-10 19:18:00 +0000 | [diff] [blame] | 497 | dev_err(&adapter->pdev->dev, "FW not responding\n"); |
| 498 | adapter->fw_timeout = true; |
Padmanabh Ratnakar | f67ef7b | 2012-07-12 03:57:09 +0000 | [diff] [blame] | 499 | be_detect_error(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 500 | return -1; |
| 501 | } |
| 502 | |
Sathya Perla | 1dbf53a | 2011-05-12 19:32:16 +0000 | [diff] [blame] | 503 | msleep(1); |
Sathya Perla | f25b03a | 2010-05-30 23:34:14 +0000 | [diff] [blame] | 504 | msecs++; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 505 | } while (true); |
| 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | /* |
| 511 | * Insert the mailbox address into the doorbell in two steps |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 512 | * 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] | 513 | */ |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 514 | static int be_mbox_notify_wait(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 515 | { |
| 516 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 517 | u32 val = 0; |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 518 | void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET; |
| 519 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 520 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 521 | struct be_mcc_compl *compl = &mbox->compl; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 522 | |
Sathya Perla | cf58847 | 2010-02-14 21:22:01 +0000 | [diff] [blame] | 523 | /* wait for ready to be set */ |
| 524 | status = be_mbox_db_ready_wait(adapter, db); |
| 525 | if (status != 0) |
| 526 | return status; |
| 527 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 528 | val |= MPU_MAILBOX_DB_HI_MASK; |
| 529 | /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */ |
| 530 | val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; |
| 531 | iowrite32(val, db); |
| 532 | |
| 533 | /* wait for ready to be set */ |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 534 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 535 | if (status != 0) |
| 536 | return status; |
| 537 | |
| 538 | val = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 539 | /* at bits 2 - 31 place mbox dma addr lsb bits 4 - 33 */ |
| 540 | val |= (u32)(mbox_mem->dma >> 4) << 2; |
| 541 | iowrite32(val, db); |
| 542 | |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 543 | status = be_mbox_db_ready_wait(adapter, db); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 544 | if (status != 0) |
| 545 | return status; |
| 546 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 547 | /* A cq entry has been made now */ |
Sathya Perla | efd2e40 | 2009-07-27 22:53:10 +0000 | [diff] [blame] | 548 | if (be_mcc_compl_is_new(compl)) { |
| 549 | status = be_mcc_compl_process(adapter, &mbox->compl); |
| 550 | be_mcc_compl_use(compl); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 551 | if (status) |
| 552 | return status; |
| 553 | } else { |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 554 | dev_err(&adapter->pdev->dev, "invalid mailbox completion\n"); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 555 | return -1; |
| 556 | } |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 557 | return 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 558 | } |
| 559 | |
Sathya Perla | c5b3ad4 | 2013-03-05 22:23:20 +0000 | [diff] [blame] | 560 | static u16 be_POST_stage_get(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 561 | { |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 562 | u32 sem; |
| 563 | |
Sathya Perla | c5b3ad4 | 2013-03-05 22:23:20 +0000 | [diff] [blame] | 564 | if (BEx_chip(adapter)) |
| 565 | sem = ioread32(adapter->csr + SLIPORT_SEMAPHORE_OFFSET_BEx); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 566 | else |
Sathya Perla | c5b3ad4 | 2013-03-05 22:23:20 +0000 | [diff] [blame] | 567 | pci_read_config_dword(adapter->pdev, |
| 568 | SLIPORT_SEMAPHORE_OFFSET_SH, &sem); |
| 569 | |
| 570 | return sem & POST_STAGE_MASK; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 571 | } |
| 572 | |
Gavin Shan | 87f20c2 | 2013-10-29 17:30:57 +0800 | [diff] [blame] | 573 | static int lancer_wait_ready(struct be_adapter *adapter) |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 574 | { |
| 575 | #define SLIPORT_READY_TIMEOUT 30 |
| 576 | u32 sliport_status; |
| 577 | int status = 0, i; |
| 578 | |
| 579 | for (i = 0; i < SLIPORT_READY_TIMEOUT; i++) { |
| 580 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
| 581 | if (sliport_status & SLIPORT_STATUS_RDY_MASK) |
| 582 | break; |
| 583 | |
| 584 | msleep(1000); |
| 585 | } |
| 586 | |
| 587 | if (i == SLIPORT_READY_TIMEOUT) |
| 588 | status = -1; |
| 589 | |
| 590 | return status; |
| 591 | } |
| 592 | |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 593 | static bool lancer_provisioning_error(struct be_adapter *adapter) |
| 594 | { |
| 595 | u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0; |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 596 | |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 597 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
| 598 | if (sliport_status & SLIPORT_STATUS_ERR_MASK) { |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 599 | sliport_err1 = ioread32(adapter->db + SLIPORT_ERROR1_OFFSET); |
| 600 | sliport_err2 = ioread32(adapter->db + SLIPORT_ERROR2_OFFSET); |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 601 | |
| 602 | if (sliport_err1 == SLIPORT_ERROR_NO_RESOURCE1 && |
| 603 | sliport_err2 == SLIPORT_ERROR_NO_RESOURCE2) |
| 604 | return true; |
| 605 | } |
| 606 | return false; |
| 607 | } |
| 608 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 609 | int lancer_test_and_set_rdy_state(struct be_adapter *adapter) |
| 610 | { |
| 611 | int status; |
| 612 | u32 sliport_status, err, reset_needed; |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 613 | bool resource_error; |
| 614 | |
| 615 | resource_error = lancer_provisioning_error(adapter); |
| 616 | if (resource_error) |
Somnath Kotur | 01e5b2c | 2013-05-29 22:56:17 +0000 | [diff] [blame] | 617 | return -EAGAIN; |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 618 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 619 | status = lancer_wait_ready(adapter); |
| 620 | if (!status) { |
| 621 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
| 622 | err = sliport_status & SLIPORT_STATUS_ERR_MASK; |
| 623 | reset_needed = sliport_status & SLIPORT_STATUS_RN_MASK; |
| 624 | if (err && reset_needed) { |
| 625 | iowrite32(SLI_PORT_CONTROL_IP_MASK, |
| 626 | adapter->db + SLIPORT_CONTROL_OFFSET); |
| 627 | |
| 628 | /* check adapter has corrected the error */ |
| 629 | status = lancer_wait_ready(adapter); |
| 630 | sliport_status = ioread32(adapter->db + |
| 631 | SLIPORT_STATUS_OFFSET); |
| 632 | sliport_status &= (SLIPORT_STATUS_ERR_MASK | |
| 633 | SLIPORT_STATUS_RN_MASK); |
| 634 | if (status || sliport_status) |
| 635 | status = -1; |
| 636 | } else if (err || reset_needed) { |
| 637 | status = -1; |
| 638 | } |
| 639 | } |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 640 | /* Stop error recovery if error is not recoverable. |
| 641 | * No resource error is temporary errors and will go away |
| 642 | * when PF provisions resources. |
| 643 | */ |
| 644 | resource_error = lancer_provisioning_error(adapter); |
Somnath Kotur | 01e5b2c | 2013-05-29 22:56:17 +0000 | [diff] [blame] | 645 | if (resource_error) |
| 646 | status = -EAGAIN; |
Padmanabh Ratnakar | 67297ad | 2012-10-20 06:02:27 +0000 | [diff] [blame] | 647 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 648 | return status; |
| 649 | } |
| 650 | |
| 651 | int be_fw_wait_ready(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 652 | { |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 653 | u16 stage; |
| 654 | int status, timeout = 0; |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 655 | struct device *dev = &adapter->pdev->dev; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 656 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 657 | if (lancer_chip(adapter)) { |
| 658 | status = lancer_wait_ready(adapter); |
| 659 | return status; |
| 660 | } |
| 661 | |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 662 | do { |
Sathya Perla | c5b3ad4 | 2013-03-05 22:23:20 +0000 | [diff] [blame] | 663 | stage = be_POST_stage_get(adapter); |
Gavin Shan | 66d29cb | 2013-03-03 21:48:46 +0000 | [diff] [blame] | 664 | if (stage == POST_STAGE_ARMFW_RDY) |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 665 | return 0; |
Gavin Shan | 66d29cb | 2013-03-03 21:48:46 +0000 | [diff] [blame] | 666 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 667 | dev_info(dev, "Waiting for POST, %ds elapsed\n", timeout); |
Gavin Shan | 66d29cb | 2013-03-03 21:48:46 +0000 | [diff] [blame] | 668 | if (msleep_interruptible(2000)) { |
| 669 | dev_err(dev, "Waiting for POST aborted\n"); |
| 670 | return -EINTR; |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 671 | } |
Gavin Shan | 66d29cb | 2013-03-03 21:48:46 +0000 | [diff] [blame] | 672 | timeout += 2; |
Somnath Kotur | 3ab81b5 | 2011-10-03 08:10:57 +0000 | [diff] [blame] | 673 | } while (timeout < 60); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 674 | |
Sathya Perla | 6ed35ee | 2011-05-12 19:32:15 +0000 | [diff] [blame] | 675 | dev_err(dev, "POST timeout; stage=0x%x\n", stage); |
Sathya Perla | 43a04fdc | 2009-10-14 20:21:17 +0000 | [diff] [blame] | 676 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 677 | } |
| 678 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 679 | |
| 680 | static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb) |
| 681 | { |
| 682 | return &wrb->payload.sgl[0]; |
| 683 | } |
| 684 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 685 | static inline void fill_wrb_tags(struct be_mcc_wrb *wrb, unsigned long addr) |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 686 | { |
| 687 | wrb->tag0 = addr & 0xFFFFFFFF; |
| 688 | wrb->tag1 = upper_32_bits(addr); |
| 689 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 690 | |
| 691 | /* Don't touch the hdr after it's prepared */ |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 692 | /* mem will be NULL for embedded commands */ |
| 693 | static void be_wrb_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 694 | u8 subsystem, u8 opcode, int cmd_len, |
| 695 | struct be_mcc_wrb *wrb, |
| 696 | struct be_dma_mem *mem) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 697 | { |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 698 | struct be_sge *sge; |
| 699 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 700 | req_hdr->opcode = opcode; |
| 701 | req_hdr->subsystem = subsystem; |
| 702 | req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr)); |
Ajit Khaparde | 07793d3 | 2010-02-16 00:18:46 +0000 | [diff] [blame] | 703 | req_hdr->version = 0; |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 704 | fill_wrb_tags(wrb, (ulong) req_hdr); |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 705 | wrb->payload_length = cmd_len; |
| 706 | if (mem) { |
| 707 | wrb->embedded |= (1 & MCC_WRB_SGE_CNT_MASK) << |
| 708 | MCC_WRB_SGE_CNT_SHIFT; |
| 709 | sge = nonembedded_sgl(wrb); |
| 710 | sge->pa_hi = cpu_to_le32(upper_32_bits(mem->dma)); |
| 711 | sge->pa_lo = cpu_to_le32(mem->dma & 0xFFFFFFFF); |
| 712 | sge->len = cpu_to_le32(mem->size); |
| 713 | } else |
| 714 | wrb->embedded |= MCC_WRB_EMBEDDED_MASK; |
| 715 | be_dws_cpu_to_le(wrb, 8); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 719 | struct be_dma_mem *mem) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 720 | { |
| 721 | int i, buf_pages = min(PAGES_4K_SPANNED(mem->va, mem->size), max_pages); |
| 722 | u64 dma = (u64)mem->dma; |
| 723 | |
| 724 | for (i = 0; i < buf_pages; i++) { |
| 725 | pages[i].lo = cpu_to_le32(dma & 0xFFFFFFFF); |
| 726 | pages[i].hi = cpu_to_le32(upper_32_bits(dma)); |
| 727 | dma += PAGE_SIZE_4K; |
| 728 | } |
| 729 | } |
| 730 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 731 | 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] | 732 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 733 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
| 734 | struct be_mcc_wrb *wrb |
| 735 | = &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; |
| 736 | memset(wrb, 0, sizeof(*wrb)); |
| 737 | return wrb; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 738 | } |
| 739 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 740 | static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 741 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 742 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
| 743 | struct be_mcc_wrb *wrb; |
| 744 | |
Padmanabh Ratnakar | aa790db | 2012-10-20 06:03:25 +0000 | [diff] [blame] | 745 | if (!mccq->created) |
| 746 | return NULL; |
| 747 | |
Vasundhara Volam | 4d27712 | 2013-04-21 23:28:15 +0000 | [diff] [blame] | 748 | if (atomic_read(&mccq->used) >= mccq->len) |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 749 | return NULL; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 750 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 751 | wrb = queue_head_node(mccq); |
| 752 | queue_head_inc(mccq); |
| 753 | atomic_inc(&mccq->used); |
| 754 | memset(wrb, 0, sizeof(*wrb)); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 755 | return wrb; |
| 756 | } |
| 757 | |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 758 | static bool use_mcc(struct be_adapter *adapter) |
| 759 | { |
| 760 | return adapter->mcc_obj.q.created; |
| 761 | } |
| 762 | |
| 763 | /* Must be used only in process context */ |
| 764 | static int be_cmd_lock(struct be_adapter *adapter) |
| 765 | { |
| 766 | if (use_mcc(adapter)) { |
| 767 | spin_lock_bh(&adapter->mcc_lock); |
| 768 | return 0; |
| 769 | } else { |
| 770 | return mutex_lock_interruptible(&adapter->mbox_lock); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | /* Must be used only in process context */ |
| 775 | static void be_cmd_unlock(struct be_adapter *adapter) |
| 776 | { |
| 777 | if (use_mcc(adapter)) |
| 778 | spin_unlock_bh(&adapter->mcc_lock); |
| 779 | else |
| 780 | return mutex_unlock(&adapter->mbox_lock); |
| 781 | } |
| 782 | |
| 783 | static struct be_mcc_wrb *be_cmd_copy(struct be_adapter *adapter, |
| 784 | struct be_mcc_wrb *wrb) |
| 785 | { |
| 786 | struct be_mcc_wrb *dest_wrb; |
| 787 | |
| 788 | if (use_mcc(adapter)) { |
| 789 | dest_wrb = wrb_from_mccq(adapter); |
| 790 | if (!dest_wrb) |
| 791 | return NULL; |
| 792 | } else { |
| 793 | dest_wrb = wrb_from_mbox(adapter); |
| 794 | } |
| 795 | |
| 796 | memcpy(dest_wrb, wrb, sizeof(*wrb)); |
| 797 | if (wrb->embedded & cpu_to_le32(MCC_WRB_EMBEDDED_MASK)) |
| 798 | fill_wrb_tags(dest_wrb, (ulong) embedded_payload(wrb)); |
| 799 | |
| 800 | return dest_wrb; |
| 801 | } |
| 802 | |
| 803 | /* Must be used only in process context */ |
| 804 | static int be_cmd_notify_wait(struct be_adapter *adapter, |
| 805 | struct be_mcc_wrb *wrb) |
| 806 | { |
| 807 | struct be_mcc_wrb *dest_wrb; |
| 808 | int status; |
| 809 | |
| 810 | status = be_cmd_lock(adapter); |
| 811 | if (status) |
| 812 | return status; |
| 813 | |
| 814 | dest_wrb = be_cmd_copy(adapter, wrb); |
| 815 | if (!dest_wrb) |
| 816 | return -EBUSY; |
| 817 | |
| 818 | if (use_mcc(adapter)) |
| 819 | status = be_mcc_notify_wait(adapter); |
| 820 | else |
| 821 | status = be_mbox_notify_wait(adapter); |
| 822 | |
| 823 | if (!status) |
| 824 | memcpy(wrb, dest_wrb, sizeof(*wrb)); |
| 825 | |
| 826 | be_cmd_unlock(adapter); |
| 827 | return status; |
| 828 | } |
| 829 | |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 830 | /* Tell fw we're about to start firing cmds by writing a |
| 831 | * special pattern across the wrb hdr; uses mbox |
| 832 | */ |
| 833 | int be_cmd_fw_init(struct be_adapter *adapter) |
| 834 | { |
| 835 | u8 *wrb; |
| 836 | int status; |
| 837 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 838 | if (lancer_chip(adapter)) |
| 839 | return 0; |
| 840 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 841 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 842 | return -1; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 843 | |
| 844 | wrb = (u8 *)wrb_from_mbox(adapter); |
Sathya Perla | 359a972 | 2010-12-01 01:03:36 +0000 | [diff] [blame] | 845 | *wrb++ = 0xFF; |
| 846 | *wrb++ = 0x12; |
| 847 | *wrb++ = 0x34; |
| 848 | *wrb++ = 0xFF; |
| 849 | *wrb++ = 0xFF; |
| 850 | *wrb++ = 0x56; |
| 851 | *wrb++ = 0x78; |
| 852 | *wrb = 0xFF; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 853 | |
| 854 | status = be_mbox_notify_wait(adapter); |
| 855 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 856 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 857 | return status; |
| 858 | } |
| 859 | |
| 860 | /* Tell fw we're done with firing cmds by writing a |
| 861 | * special pattern across the wrb hdr; uses mbox |
| 862 | */ |
| 863 | int be_cmd_fw_clean(struct be_adapter *adapter) |
| 864 | { |
| 865 | u8 *wrb; |
| 866 | int status; |
| 867 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 868 | if (lancer_chip(adapter)) |
| 869 | return 0; |
| 870 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 871 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 872 | return -1; |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 873 | |
| 874 | wrb = (u8 *)wrb_from_mbox(adapter); |
| 875 | *wrb++ = 0xFF; |
| 876 | *wrb++ = 0xAA; |
| 877 | *wrb++ = 0xBB; |
| 878 | *wrb++ = 0xFF; |
| 879 | *wrb++ = 0xFF; |
| 880 | *wrb++ = 0xCC; |
| 881 | *wrb++ = 0xDD; |
| 882 | *wrb = 0xFF; |
| 883 | |
| 884 | status = be_mbox_notify_wait(adapter); |
| 885 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 886 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 2243e2e | 2009-11-22 22:02:03 +0000 | [diff] [blame] | 887 | return status; |
| 888 | } |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 889 | |
Sathya Perla | f2f781a | 2013-08-27 16:57:30 +0530 | [diff] [blame] | 890 | int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 891 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 892 | struct be_mcc_wrb *wrb; |
| 893 | struct be_cmd_req_eq_create *req; |
Sathya Perla | f2f781a | 2013-08-27 16:57:30 +0530 | [diff] [blame] | 894 | struct be_dma_mem *q_mem = &eqo->q.dma_mem; |
| 895 | int status, ver = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 896 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 897 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 898 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 899 | |
| 900 | wrb = wrb_from_mbox(adapter); |
| 901 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 902 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 903 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 904 | OPCODE_COMMON_EQ_CREATE, sizeof(*req), wrb, |
| 905 | NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 906 | |
Sathya Perla | f2f781a | 2013-08-27 16:57:30 +0530 | [diff] [blame] | 907 | /* Support for EQ_CREATEv2 available only SH-R onwards */ |
| 908 | if (!(BEx_chip(adapter) || lancer_chip(adapter))) |
| 909 | ver = 2; |
| 910 | |
| 911 | req->hdr.version = ver; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 912 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
| 913 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 914 | AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); |
| 915 | /* 4byte eqe*/ |
| 916 | AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); |
| 917 | AMAP_SET_BITS(struct amap_eq_context, count, req->context, |
Sathya Perla | f2f781a | 2013-08-27 16:57:30 +0530 | [diff] [blame] | 918 | __ilog2_u32(eqo->q.len / 256)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 919 | be_dws_cpu_to_le(req->context, sizeof(req->context)); |
| 920 | |
| 921 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 922 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 923 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 924 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 925 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 926 | |
Sathya Perla | f2f781a | 2013-08-27 16:57:30 +0530 | [diff] [blame] | 927 | eqo->q.id = le16_to_cpu(resp->eq_id); |
| 928 | eqo->msix_idx = |
| 929 | (ver == 2) ? le16_to_cpu(resp->msix_idx) : eqo->idx; |
| 930 | eqo->q.created = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 931 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 932 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 933 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 934 | return status; |
| 935 | } |
| 936 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 937 | /* Use MCC */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 938 | int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
Sathya Perla | 5ee4979 | 2012-09-28 04:39:41 +0000 | [diff] [blame] | 939 | bool permanent, u32 if_handle, u32 pmac_id) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 940 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 941 | struct be_mcc_wrb *wrb; |
| 942 | struct be_cmd_req_mac_query *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 943 | int status; |
| 944 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 945 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 946 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 947 | wrb = wrb_from_mccq(adapter); |
| 948 | if (!wrb) { |
| 949 | status = -EBUSY; |
| 950 | goto err; |
| 951 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 952 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 953 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 954 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 955 | OPCODE_COMMON_NTWK_MAC_QUERY, sizeof(*req), wrb, |
| 956 | NULL); |
Sathya Perla | 5ee4979 | 2012-09-28 04:39:41 +0000 | [diff] [blame] | 957 | req->type = MAC_ADDRESS_TYPE_NETWORK; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 958 | if (permanent) { |
| 959 | req->permanent = 1; |
| 960 | } else { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 961 | req->if_id = cpu_to_le16((u16) if_handle); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 962 | req->pmac_id = cpu_to_le32(pmac_id); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 963 | req->permanent = 0; |
| 964 | } |
| 965 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 966 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 967 | if (!status) { |
| 968 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 969 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 970 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 971 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 972 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 973 | err: |
| 974 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 975 | return status; |
| 976 | } |
| 977 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 978 | /* Uses synchronous MCCQ */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 979 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 980 | u32 if_id, u32 *pmac_id, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 981 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 982 | struct be_mcc_wrb *wrb; |
| 983 | struct be_cmd_req_pmac_add *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 984 | int status; |
| 985 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 986 | spin_lock_bh(&adapter->mcc_lock); |
| 987 | |
| 988 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 989 | if (!wrb) { |
| 990 | status = -EBUSY; |
| 991 | goto err; |
| 992 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 993 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 994 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 995 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 996 | OPCODE_COMMON_NTWK_PMAC_ADD, sizeof(*req), wrb, |
| 997 | NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 998 | |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 999 | req->hdr.domain = domain; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1000 | req->if_id = cpu_to_le32(if_id); |
| 1001 | memcpy(req->mac_address, mac_addr, ETH_ALEN); |
| 1002 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1003 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1004 | if (!status) { |
| 1005 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1006 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1007 | *pmac_id = le32_to_cpu(resp->pmac_id); |
| 1008 | } |
| 1009 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1010 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1011 | spin_unlock_bh(&adapter->mcc_lock); |
Somnath Kotur | e3a7ae2 | 2011-10-27 07:14:05 +0000 | [diff] [blame] | 1012 | |
| 1013 | if (status == MCC_STATUS_UNAUTHORIZED_REQUEST) |
| 1014 | status = -EPERM; |
| 1015 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1016 | return status; |
| 1017 | } |
| 1018 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1019 | /* Uses synchronous MCCQ */ |
Sathya Perla | 3012803 | 2011-11-10 19:17:57 +0000 | [diff] [blame] | 1020 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1021 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1022 | struct be_mcc_wrb *wrb; |
| 1023 | struct be_cmd_req_pmac_del *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1024 | int status; |
| 1025 | |
Sathya Perla | 3012803 | 2011-11-10 19:17:57 +0000 | [diff] [blame] | 1026 | if (pmac_id == -1) |
| 1027 | return 0; |
| 1028 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1029 | spin_lock_bh(&adapter->mcc_lock); |
| 1030 | |
| 1031 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1032 | if (!wrb) { |
| 1033 | status = -EBUSY; |
| 1034 | goto err; |
| 1035 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1036 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1037 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1038 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1039 | OPCODE_COMMON_NTWK_PMAC_DEL, sizeof(*req), wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1040 | |
Ajit Khaparde | f8617e0 | 2011-02-11 13:36:37 +0000 | [diff] [blame] | 1041 | req->hdr.domain = dom; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1042 | req->if_id = cpu_to_le32(if_id); |
| 1043 | req->pmac_id = cpu_to_le32(pmac_id); |
| 1044 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1045 | status = be_mcc_notify_wait(adapter); |
| 1046 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1047 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1048 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1049 | return status; |
| 1050 | } |
| 1051 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1052 | /* Uses Mbox */ |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 1053 | int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1054 | struct be_queue_info *eq, bool no_delay, int coalesce_wm) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1055 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1056 | struct be_mcc_wrb *wrb; |
| 1057 | struct be_cmd_req_cq_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1058 | struct be_dma_mem *q_mem = &cq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1059 | void *ctxt; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1060 | int status; |
| 1061 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1062 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1063 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1064 | |
| 1065 | wrb = wrb_from_mbox(adapter); |
| 1066 | req = embedded_payload(wrb); |
| 1067 | ctxt = &req->context; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1068 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1069 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1070 | OPCODE_COMMON_CQ_CREATE, sizeof(*req), wrb, |
| 1071 | NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1072 | |
| 1073 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
Ajit Khaparde | bbdc42f | 2013-05-01 09:37:17 +0000 | [diff] [blame] | 1074 | |
| 1075 | if (BEx_chip(adapter)) { |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1076 | AMAP_SET_BITS(struct amap_cq_context_be, coalescwm, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1077 | coalesce_wm); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1078 | AMAP_SET_BITS(struct amap_cq_context_be, nodelay, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1079 | ctxt, no_delay); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1080 | AMAP_SET_BITS(struct amap_cq_context_be, count, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1081 | __ilog2_u32(cq->len / 256)); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1082 | AMAP_SET_BITS(struct amap_cq_context_be, valid, ctxt, 1); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1083 | AMAP_SET_BITS(struct amap_cq_context_be, eventable, ctxt, 1); |
| 1084 | AMAP_SET_BITS(struct amap_cq_context_be, eqid, ctxt, eq->id); |
Ajit Khaparde | bbdc42f | 2013-05-01 09:37:17 +0000 | [diff] [blame] | 1085 | } else { |
| 1086 | req->hdr.version = 2; |
| 1087 | req->page_size = 1; /* 1 for 4K */ |
Ajit Khaparde | 09e83a9 | 2013-11-22 12:51:20 -0600 | [diff] [blame] | 1088 | |
| 1089 | /* coalesce-wm field in this cmd is not relevant to Lancer. |
| 1090 | * Lancer uses COMMON_MODIFY_CQ to set this field |
| 1091 | */ |
| 1092 | if (!lancer_chip(adapter)) |
| 1093 | AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm, |
| 1094 | ctxt, coalesce_wm); |
Ajit Khaparde | bbdc42f | 2013-05-01 09:37:17 +0000 | [diff] [blame] | 1095 | AMAP_SET_BITS(struct amap_cq_context_v2, nodelay, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1096 | no_delay); |
Ajit Khaparde | bbdc42f | 2013-05-01 09:37:17 +0000 | [diff] [blame] | 1097 | AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1098 | __ilog2_u32(cq->len / 256)); |
Ajit Khaparde | bbdc42f | 2013-05-01 09:37:17 +0000 | [diff] [blame] | 1099 | AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1); |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1100 | AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1); |
| 1101 | AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1102 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1103 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1104 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 1105 | |
| 1106 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 1107 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1108 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1109 | if (!status) { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1110 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1111 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1112 | cq->id = le16_to_cpu(resp->cq_id); |
| 1113 | cq->created = true; |
| 1114 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1115 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1116 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1117 | |
| 1118 | return status; |
| 1119 | } |
| 1120 | |
| 1121 | static u32 be_encoded_q_len(int q_len) |
| 1122 | { |
| 1123 | u32 len_encoded = fls(q_len); /* log2(len) + 1 */ |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1124 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1125 | if (len_encoded == 16) |
| 1126 | len_encoded = 0; |
| 1127 | return len_encoded; |
| 1128 | } |
| 1129 | |
Jingoo Han | 4188e7d | 2013-08-05 18:02:02 +0900 | [diff] [blame] | 1130 | static int be_cmd_mccq_ext_create(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1131 | struct be_queue_info *mccq, |
| 1132 | struct be_queue_info *cq) |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1133 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1134 | struct be_mcc_wrb *wrb; |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1135 | struct be_cmd_req_mcc_ext_create *req; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1136 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1137 | void *ctxt; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1138 | int status; |
| 1139 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1140 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1141 | return -1; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1142 | |
| 1143 | wrb = wrb_from_mbox(adapter); |
| 1144 | req = embedded_payload(wrb); |
| 1145 | ctxt = &req->context; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1146 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1147 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1148 | OPCODE_COMMON_MCC_CREATE_EXT, sizeof(*req), wrb, |
| 1149 | NULL); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1150 | |
Ajit Khaparde | d4a2ac3 | 2010-03-11 01:35:59 +0000 | [diff] [blame] | 1151 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
Vasundhara Volam | 666d39c | 2014-01-15 13:23:31 +0530 | [diff] [blame] | 1152 | if (BEx_chip(adapter)) { |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1153 | AMAP_SET_BITS(struct amap_mcc_context_be, valid, ctxt, 1); |
| 1154 | AMAP_SET_BITS(struct amap_mcc_context_be, ring_size, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1155 | be_encoded_q_len(mccq->len)); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1156 | AMAP_SET_BITS(struct amap_mcc_context_be, cq_id, ctxt, cq->id); |
Vasundhara Volam | 666d39c | 2014-01-15 13:23:31 +0530 | [diff] [blame] | 1157 | } else { |
| 1158 | req->hdr.version = 1; |
| 1159 | req->cq_id = cpu_to_le16(cq->id); |
| 1160 | |
| 1161 | AMAP_SET_BITS(struct amap_mcc_context_v1, ring_size, ctxt, |
| 1162 | be_encoded_q_len(mccq->len)); |
| 1163 | AMAP_SET_BITS(struct amap_mcc_context_v1, valid, ctxt, 1); |
| 1164 | AMAP_SET_BITS(struct amap_mcc_context_v1, async_cq_id, |
| 1165 | ctxt, cq->id); |
| 1166 | AMAP_SET_BITS(struct amap_mcc_context_v1, async_cq_valid, |
| 1167 | ctxt, 1); |
Sathya Perla | fe6d2a3 | 2010-11-21 23:25:50 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Somnath Kotur | cc4ce02 | 2010-10-21 07:11:14 -0700 | [diff] [blame] | 1170 | /* 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] | 1171 | req->async_event_bitmap[0] = cpu_to_le32(0x00000022); |
Ajit Khaparde | bc0c340 | 2013-04-24 11:52:50 +0000 | [diff] [blame] | 1172 | req->async_event_bitmap[0] |= cpu_to_le32(1 << ASYNC_EVENT_CODE_QNQ); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1173 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 1174 | |
| 1175 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 1176 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1177 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1178 | if (!status) { |
| 1179 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1180 | |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1181 | mccq->id = le16_to_cpu(resp->id); |
| 1182 | mccq->created = true; |
| 1183 | } |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1184 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1185 | |
| 1186 | return status; |
| 1187 | } |
| 1188 | |
Jingoo Han | 4188e7d | 2013-08-05 18:02:02 +0900 | [diff] [blame] | 1189 | static int be_cmd_mccq_org_create(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1190 | struct be_queue_info *mccq, |
| 1191 | struct be_queue_info *cq) |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1192 | { |
| 1193 | struct be_mcc_wrb *wrb; |
| 1194 | struct be_cmd_req_mcc_create *req; |
| 1195 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
| 1196 | void *ctxt; |
| 1197 | int status; |
| 1198 | |
| 1199 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1200 | return -1; |
| 1201 | |
| 1202 | wrb = wrb_from_mbox(adapter); |
| 1203 | req = embedded_payload(wrb); |
| 1204 | ctxt = &req->context; |
| 1205 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1206 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1207 | OPCODE_COMMON_MCC_CREATE, sizeof(*req), wrb, |
| 1208 | NULL); |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1209 | |
| 1210 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
| 1211 | |
| 1212 | AMAP_SET_BITS(struct amap_mcc_context_be, valid, ctxt, 1); |
| 1213 | AMAP_SET_BITS(struct amap_mcc_context_be, ring_size, ctxt, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1214 | be_encoded_q_len(mccq->len)); |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1215 | AMAP_SET_BITS(struct amap_mcc_context_be, cq_id, ctxt, cq->id); |
| 1216 | |
| 1217 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 1218 | |
| 1219 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 1220 | |
| 1221 | status = be_mbox_notify_wait(adapter); |
| 1222 | if (!status) { |
| 1223 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1224 | |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1225 | mccq->id = le16_to_cpu(resp->id); |
| 1226 | mccq->created = true; |
| 1227 | } |
| 1228 | |
| 1229 | mutex_unlock(&adapter->mbox_lock); |
| 1230 | return status; |
| 1231 | } |
| 1232 | |
| 1233 | int be_cmd_mccq_create(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1234 | struct be_queue_info *mccq, struct be_queue_info *cq) |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1235 | { |
| 1236 | int status; |
| 1237 | |
| 1238 | status = be_cmd_mccq_ext_create(adapter, mccq, cq); |
Vasundhara Volam | 666d39c | 2014-01-15 13:23:31 +0530 | [diff] [blame] | 1239 | if (status && BEx_chip(adapter)) { |
Somnath Kotur | 34b1ef0 | 2011-06-01 00:33:22 +0000 | [diff] [blame] | 1240 | dev_warn(&adapter->pdev->dev, "Upgrade to F/W ver 2.102.235.0 " |
| 1241 | "or newer to avoid conflicting priorities between NIC " |
| 1242 | "and FCoE traffic"); |
| 1243 | status = be_cmd_mccq_org_create(adapter, mccq, cq); |
| 1244 | } |
| 1245 | return status; |
| 1246 | } |
| 1247 | |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1248 | int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1249 | { |
Sathya Perla | 7707133 | 2013-08-27 16:57:34 +0530 | [diff] [blame] | 1250 | struct be_mcc_wrb wrb = {0}; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1251 | struct be_cmd_req_eth_tx_create *req; |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1252 | struct be_queue_info *txq = &txo->q; |
| 1253 | struct be_queue_info *cq = &txo->cq; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1254 | struct be_dma_mem *q_mem = &txq->dma_mem; |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1255 | int status, ver = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1256 | |
Sathya Perla | 7707133 | 2013-08-27 16:57:34 +0530 | [diff] [blame] | 1257 | req = embedded_payload(&wrb); |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1258 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1259 | OPCODE_ETH_TX_CREATE, sizeof(*req), &wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1260 | |
Padmanabh Ratnakar | 8b7756c | 2011-03-07 03:08:52 +0000 | [diff] [blame] | 1261 | if (lancer_chip(adapter)) { |
| 1262 | req->hdr.version = 1; |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1263 | } else if (BEx_chip(adapter)) { |
| 1264 | if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) |
| 1265 | req->hdr.version = 2; |
| 1266 | } else { /* For SH */ |
| 1267 | req->hdr.version = 2; |
Padmanabh Ratnakar | 8b7756c | 2011-03-07 03:08:52 +0000 | [diff] [blame] | 1268 | } |
| 1269 | |
Vasundhara Volam | 81b0265 | 2013-10-01 15:59:57 +0530 | [diff] [blame] | 1270 | if (req->hdr.version > 0) |
| 1271 | req->if_id = cpu_to_le16(adapter->if_handle); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1272 | req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); |
| 1273 | req->ulp_num = BE_ULP1_NUM; |
| 1274 | req->type = BE_ETH_TX_RING_TYPE_STANDARD; |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1275 | req->cq_id = cpu_to_le16(cq->id); |
| 1276 | req->queue_size = be_encoded_q_len(txq->len); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1277 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1278 | ver = req->hdr.version; |
| 1279 | |
Sathya Perla | 7707133 | 2013-08-27 16:57:34 +0530 | [diff] [blame] | 1280 | status = be_cmd_notify_wait(adapter, &wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1281 | if (!status) { |
Sathya Perla | 7707133 | 2013-08-27 16:57:34 +0530 | [diff] [blame] | 1282 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(&wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1283 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1284 | txq->id = le16_to_cpu(resp->cid); |
Vasundhara Volam | 94d73aa | 2013-04-21 23:28:14 +0000 | [diff] [blame] | 1285 | if (ver == 2) |
| 1286 | txo->db_offset = le32_to_cpu(resp->db_offset); |
| 1287 | else |
| 1288 | txo->db_offset = DB_TXULP1_OFFSET; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1289 | txq->created = true; |
| 1290 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1291 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1292 | return status; |
| 1293 | } |
| 1294 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1295 | /* Uses MCC */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1296 | int be_cmd_rxq_create(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1297 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, |
| 1298 | u32 if_id, u32 rss, u8 *rss_id) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1299 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1300 | struct be_mcc_wrb *wrb; |
| 1301 | struct be_cmd_req_eth_rx_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1302 | struct be_dma_mem *q_mem = &rxq->dma_mem; |
| 1303 | int status; |
| 1304 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1305 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1306 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1307 | wrb = wrb_from_mccq(adapter); |
| 1308 | if (!wrb) { |
| 1309 | status = -EBUSY; |
| 1310 | goto err; |
| 1311 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1312 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1313 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1314 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1315 | OPCODE_ETH_RX_CREATE, sizeof(*req), wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1316 | |
| 1317 | req->cq_id = cpu_to_le16(cq_id); |
| 1318 | req->frag_size = fls(frag_size) - 1; |
| 1319 | req->num_pages = 2; |
| 1320 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
| 1321 | req->interface_id = cpu_to_le32(if_id); |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 1322 | req->max_frame_size = cpu_to_le16(BE_MAX_JUMBO_FRAME_SIZE); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1323 | req->rss_queue = cpu_to_le32(rss); |
| 1324 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1325 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1326 | if (!status) { |
| 1327 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1328 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1329 | rxq->id = le16_to_cpu(resp->id); |
| 1330 | rxq->created = true; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 1331 | *rss_id = resp->rss_id; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1332 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1333 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1334 | err: |
| 1335 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1336 | return status; |
| 1337 | } |
| 1338 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1339 | /* Generic destroyer function for all types of queues |
| 1340 | * Uses Mbox |
| 1341 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1342 | int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1343 | int queue_type) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1344 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1345 | struct be_mcc_wrb *wrb; |
| 1346 | struct be_cmd_req_q_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1347 | u8 subsys = 0, opcode = 0; |
| 1348 | int status; |
| 1349 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1350 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 1351 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1352 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1353 | wrb = wrb_from_mbox(adapter); |
| 1354 | req = embedded_payload(wrb); |
| 1355 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1356 | switch (queue_type) { |
| 1357 | case QTYPE_EQ: |
| 1358 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1359 | opcode = OPCODE_COMMON_EQ_DESTROY; |
| 1360 | break; |
| 1361 | case QTYPE_CQ: |
| 1362 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1363 | opcode = OPCODE_COMMON_CQ_DESTROY; |
| 1364 | break; |
| 1365 | case QTYPE_TXQ: |
| 1366 | subsys = CMD_SUBSYSTEM_ETH; |
| 1367 | opcode = OPCODE_ETH_TX_DESTROY; |
| 1368 | break; |
| 1369 | case QTYPE_RXQ: |
| 1370 | subsys = CMD_SUBSYSTEM_ETH; |
| 1371 | opcode = OPCODE_ETH_RX_DESTROY; |
| 1372 | break; |
Sathya Perla | 5fb379e | 2009-06-18 00:02:59 +0000 | [diff] [blame] | 1373 | case QTYPE_MCCQ: |
| 1374 | subsys = CMD_SUBSYSTEM_COMMON; |
| 1375 | opcode = OPCODE_COMMON_MCC_DESTROY; |
| 1376 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1377 | default: |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 1378 | BUG(); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1379 | } |
Ajit Khaparde | d744b44 | 2009-12-03 06:12:06 +0000 | [diff] [blame] | 1380 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1381 | be_wrb_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req), wrb, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1382 | NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1383 | req->id = cpu_to_le16(q->id); |
| 1384 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1385 | status = be_mbox_notify_wait(adapter); |
Padmanabh Ratnakar | aa790db | 2012-10-20 06:03:25 +0000 | [diff] [blame] | 1386 | q->created = false; |
Sathya Perla | 5f0b849 | 2009-07-27 22:52:56 +0000 | [diff] [blame] | 1387 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 1388 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1389 | return status; |
| 1390 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1391 | |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1392 | /* Uses MCC */ |
| 1393 | int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q) |
| 1394 | { |
| 1395 | struct be_mcc_wrb *wrb; |
| 1396 | struct be_cmd_req_q_destroy *req; |
| 1397 | int status; |
| 1398 | |
| 1399 | spin_lock_bh(&adapter->mcc_lock); |
| 1400 | |
| 1401 | wrb = wrb_from_mccq(adapter); |
| 1402 | if (!wrb) { |
| 1403 | status = -EBUSY; |
| 1404 | goto err; |
| 1405 | } |
| 1406 | req = embedded_payload(wrb); |
| 1407 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1408 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1409 | OPCODE_ETH_RX_DESTROY, sizeof(*req), wrb, NULL); |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1410 | req->id = cpu_to_le16(q->id); |
| 1411 | |
| 1412 | status = be_mcc_notify_wait(adapter); |
Padmanabh Ratnakar | aa790db | 2012-10-20 06:03:25 +0000 | [diff] [blame] | 1413 | q->created = false; |
Sathya Perla | 482c9e7 | 2011-06-29 23:33:17 +0000 | [diff] [blame] | 1414 | |
| 1415 | err: |
| 1416 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1417 | return status; |
| 1418 | } |
| 1419 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1420 | /* Create an rx filtering policy configuration on an i/f |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 1421 | * Will use MBOX only if MCCQ has not been created. |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1422 | */ |
Sathya Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 1423 | int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, |
Padmanabh Ratnakar | 1578e77 | 2012-06-07 04:37:08 +0000 | [diff] [blame] | 1424 | u32 *if_handle, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1425 | { |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 1426 | struct be_mcc_wrb wrb = {0}; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1427 | struct be_cmd_req_if_create *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1428 | int status; |
| 1429 | |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 1430 | req = embedded_payload(&wrb); |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1431 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1432 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, |
| 1433 | sizeof(*req), &wrb, NULL); |
Sarveshwar Bandi | ba343c7 | 2010-03-31 02:56:12 +0000 | [diff] [blame] | 1434 | req->hdr.domain = domain; |
Sathya Perla | 73d540f | 2009-10-14 20:20:42 +0000 | [diff] [blame] | 1435 | req->capability_flags = cpu_to_le32(cap_flags); |
| 1436 | req->enable_flags = cpu_to_le32(en_flags); |
Padmanabh Ratnakar | 1578e77 | 2012-06-07 04:37:08 +0000 | [diff] [blame] | 1437 | req->pmac_invalid = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1438 | |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 1439 | status = be_cmd_notify_wait(adapter, &wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1440 | if (!status) { |
Sathya Perla | bea5098 | 2013-08-27 16:57:33 +0530 | [diff] [blame] | 1441 | struct be_cmd_resp_if_create *resp = embedded_payload(&wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1442 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1443 | *if_handle = le32_to_cpu(resp->interface_id); |
Sathya Perla | b5bb977 | 2013-07-23 15:25:01 +0530 | [diff] [blame] | 1444 | |
| 1445 | /* Hack to retrieve VF's pmac-id on BE3 */ |
| 1446 | if (BE3_chip(adapter) && !be_physfn(adapter)) |
| 1447 | adapter->pmac_id[0] = le32_to_cpu(resp->pmac_id); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1448 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1449 | return status; |
| 1450 | } |
| 1451 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 1452 | /* Uses MCCQ */ |
Sathya Perla | 3012803 | 2011-11-10 19:17:57 +0000 | [diff] [blame] | 1453 | int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1454 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1455 | struct be_mcc_wrb *wrb; |
| 1456 | struct be_cmd_req_if_destroy *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1457 | int status; |
| 1458 | |
Sathya Perla | 3012803 | 2011-11-10 19:17:57 +0000 | [diff] [blame] | 1459 | if (interface_id == -1) |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 1460 | return 0; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1461 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 1462 | spin_lock_bh(&adapter->mcc_lock); |
| 1463 | |
| 1464 | wrb = wrb_from_mccq(adapter); |
| 1465 | if (!wrb) { |
| 1466 | status = -EBUSY; |
| 1467 | goto err; |
| 1468 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1469 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1470 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1471 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1472 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, |
| 1473 | sizeof(*req), wrb, NULL); |
Ajit Khaparde | 658681f | 2011-02-11 13:34:46 +0000 | [diff] [blame] | 1474 | req->hdr.domain = domain; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1475 | req->interface_id = cpu_to_le32(interface_id); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1476 | |
Sathya Perla | f9449ab | 2011-10-24 02:45:01 +0000 | [diff] [blame] | 1477 | status = be_mcc_notify_wait(adapter); |
| 1478 | err: |
| 1479 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1480 | return status; |
| 1481 | } |
| 1482 | |
| 1483 | /* Get stats is a non embedded command: the request is not embedded inside |
| 1484 | * WRB but is a separate dma memory block |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1485 | * Uses asynchronous MCC |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1486 | */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1487 | 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] | 1488 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1489 | struct be_mcc_wrb *wrb; |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1490 | struct be_cmd_req_hdr *hdr; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1491 | int status = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1492 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1493 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1494 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1495 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1496 | if (!wrb) { |
| 1497 | status = -EBUSY; |
| 1498 | goto err; |
| 1499 | } |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1500 | hdr = nonemb_cmd->va; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1501 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1502 | be_wrb_cmd_hdr_prepare(hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1503 | OPCODE_ETH_GET_STATISTICS, nonemb_cmd->size, wrb, |
| 1504 | nonemb_cmd); |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1505 | |
Sathya Perla | ca34fe3 | 2012-11-06 17:48:56 +0000 | [diff] [blame] | 1506 | /* version 1 of the cmd is not supported only by BE2 */ |
Ajit Khaparde | 6100086 | 2013-10-03 16:16:33 -0500 | [diff] [blame] | 1507 | if (BE2_chip(adapter)) |
| 1508 | hdr->version = 0; |
| 1509 | if (BE3_chip(adapter) || lancer_chip(adapter)) |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1510 | hdr->version = 1; |
Ajit Khaparde | 6100086 | 2013-10-03 16:16:33 -0500 | [diff] [blame] | 1511 | else |
| 1512 | hdr->version = 2; |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 1513 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1514 | be_mcc_notify(adapter); |
Ajit Khaparde | b2aebe6 | 2011-02-20 11:41:39 +0000 | [diff] [blame] | 1515 | adapter->stats_cmd_sent = true; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1516 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1517 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1518 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1519 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1520 | } |
| 1521 | |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1522 | /* Lancer Stats */ |
| 1523 | int lancer_cmd_get_pport_stats(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1524 | struct be_dma_mem *nonemb_cmd) |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1525 | { |
| 1526 | |
| 1527 | struct be_mcc_wrb *wrb; |
| 1528 | struct lancer_cmd_req_pport_stats *req; |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1529 | int status = 0; |
| 1530 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 1531 | if (!be_cmd_allowed(adapter, OPCODE_ETH_GET_PPORT_STATS, |
| 1532 | CMD_SUBSYSTEM_ETH)) |
| 1533 | return -EPERM; |
| 1534 | |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1535 | spin_lock_bh(&adapter->mcc_lock); |
| 1536 | |
| 1537 | wrb = wrb_from_mccq(adapter); |
| 1538 | if (!wrb) { |
| 1539 | status = -EBUSY; |
| 1540 | goto err; |
| 1541 | } |
| 1542 | req = nonemb_cmd->va; |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1543 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1544 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1545 | OPCODE_ETH_GET_PPORT_STATS, nonemb_cmd->size, |
| 1546 | wrb, nonemb_cmd); |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1547 | |
Padmanabh Ratnakar | d51ebd3 | 2012-04-25 01:46:52 +0000 | [diff] [blame] | 1548 | req->cmd_params.params.pport_num = cpu_to_le16(adapter->hba_port_num); |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1549 | req->cmd_params.params.reset_stats = 0; |
| 1550 | |
Selvin Xavier | 005d569 | 2011-05-16 07:36:35 +0000 | [diff] [blame] | 1551 | be_mcc_notify(adapter); |
| 1552 | adapter->stats_cmd_sent = true; |
| 1553 | |
| 1554 | err: |
| 1555 | spin_unlock_bh(&adapter->mcc_lock); |
| 1556 | return status; |
| 1557 | } |
| 1558 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 1559 | static int be_mac_to_link_speed(int mac_speed) |
| 1560 | { |
| 1561 | switch (mac_speed) { |
| 1562 | case PHY_LINK_SPEED_ZERO: |
| 1563 | return 0; |
| 1564 | case PHY_LINK_SPEED_10MBPS: |
| 1565 | return 10; |
| 1566 | case PHY_LINK_SPEED_100MBPS: |
| 1567 | return 100; |
| 1568 | case PHY_LINK_SPEED_1GBPS: |
| 1569 | return 1000; |
| 1570 | case PHY_LINK_SPEED_10GBPS: |
| 1571 | return 10000; |
Vasundhara Volam | b971f84 | 2013-08-06 09:27:15 +0530 | [diff] [blame] | 1572 | case PHY_LINK_SPEED_20GBPS: |
| 1573 | return 20000; |
| 1574 | case PHY_LINK_SPEED_25GBPS: |
| 1575 | return 25000; |
| 1576 | case PHY_LINK_SPEED_40GBPS: |
| 1577 | return 40000; |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 1578 | } |
| 1579 | return 0; |
| 1580 | } |
| 1581 | |
| 1582 | /* Uses synchronous mcc |
| 1583 | * Returns link_speed in Mbps |
| 1584 | */ |
| 1585 | int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed, |
| 1586 | u8 *link_status, u32 dom) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1587 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1588 | struct be_mcc_wrb *wrb; |
| 1589 | struct be_cmd_req_link_status *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1590 | int status; |
| 1591 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1592 | spin_lock_bh(&adapter->mcc_lock); |
| 1593 | |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 1594 | if (link_status) |
| 1595 | *link_status = LINK_DOWN; |
| 1596 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1597 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1598 | if (!wrb) { |
| 1599 | status = -EBUSY; |
| 1600 | goto err; |
| 1601 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1602 | req = embedded_payload(wrb); |
Sathya Perla | a8f447bd | 2009-06-18 00:10:27 +0000 | [diff] [blame] | 1603 | |
Padmanabh Ratnakar | 57cd80d | 2012-02-03 09:49:46 +0000 | [diff] [blame] | 1604 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1605 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, |
| 1606 | sizeof(*req), wrb, NULL); |
Padmanabh Ratnakar | 57cd80d | 2012-02-03 09:49:46 +0000 | [diff] [blame] | 1607 | |
Sathya Perla | ca34fe3 | 2012-11-06 17:48:56 +0000 | [diff] [blame] | 1608 | /* version 1 of the cmd is not supported only by BE2 */ |
| 1609 | if (!BE2_chip(adapter)) |
Padmanabh Ratnakar | daad616 | 2011-11-16 02:03:45 +0000 | [diff] [blame] | 1610 | req->hdr.version = 1; |
| 1611 | |
Padmanabh Ratnakar | 57cd80d | 2012-02-03 09:49:46 +0000 | [diff] [blame] | 1612 | req->hdr.domain = dom; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1613 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1614 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1615 | if (!status) { |
| 1616 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1617 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 1618 | if (link_speed) { |
| 1619 | *link_speed = resp->link_speed ? |
| 1620 | le16_to_cpu(resp->link_speed) * 10 : |
| 1621 | be_mac_to_link_speed(resp->mac_speed); |
| 1622 | |
| 1623 | if (!resp->logical_link_status) |
| 1624 | *link_speed = 0; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 1625 | } |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 1626 | if (link_status) |
| 1627 | *link_status = resp->logical_link_status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1628 | } |
| 1629 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1630 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1631 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1632 | return status; |
| 1633 | } |
| 1634 | |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1635 | /* Uses synchronous mcc */ |
| 1636 | int be_cmd_get_die_temperature(struct be_adapter *adapter) |
| 1637 | { |
| 1638 | struct be_mcc_wrb *wrb; |
| 1639 | struct be_cmd_req_get_cntl_addnl_attribs *req; |
Vasundhara Volam | 117affe | 2013-08-06 09:27:20 +0530 | [diff] [blame] | 1640 | int status = 0; |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1641 | |
| 1642 | spin_lock_bh(&adapter->mcc_lock); |
| 1643 | |
| 1644 | wrb = wrb_from_mccq(adapter); |
| 1645 | if (!wrb) { |
| 1646 | status = -EBUSY; |
| 1647 | goto err; |
| 1648 | } |
| 1649 | req = embedded_payload(wrb); |
| 1650 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1651 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1652 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES, |
| 1653 | sizeof(*req), wrb, NULL); |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1654 | |
Somnath Kotur | 3de0945 | 2011-09-30 07:25:05 +0000 | [diff] [blame] | 1655 | be_mcc_notify(adapter); |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 1656 | |
| 1657 | err: |
| 1658 | spin_unlock_bh(&adapter->mcc_lock); |
| 1659 | return status; |
| 1660 | } |
| 1661 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1662 | /* Uses synchronous mcc */ |
| 1663 | int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size) |
| 1664 | { |
| 1665 | struct be_mcc_wrb *wrb; |
| 1666 | struct be_cmd_req_get_fat *req; |
| 1667 | int status; |
| 1668 | |
| 1669 | spin_lock_bh(&adapter->mcc_lock); |
| 1670 | |
| 1671 | wrb = wrb_from_mccq(adapter); |
| 1672 | if (!wrb) { |
| 1673 | status = -EBUSY; |
| 1674 | goto err; |
| 1675 | } |
| 1676 | req = embedded_payload(wrb); |
| 1677 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1678 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1679 | OPCODE_COMMON_MANAGE_FAT, sizeof(*req), wrb, |
| 1680 | NULL); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1681 | req->fat_operation = cpu_to_le32(QUERY_FAT); |
| 1682 | status = be_mcc_notify_wait(adapter); |
| 1683 | if (!status) { |
| 1684 | struct be_cmd_resp_get_fat *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1685 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1686 | if (log_size && resp->log_size) |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1687 | *log_size = le32_to_cpu(resp->log_size) - |
| 1688 | sizeof(u32); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1689 | } |
| 1690 | err: |
| 1691 | spin_unlock_bh(&adapter->mcc_lock); |
| 1692 | return status; |
| 1693 | } |
| 1694 | |
Vasundhara Volam | c5f156d | 2014-09-02 09:56:54 +0530 | [diff] [blame] | 1695 | int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1696 | { |
| 1697 | struct be_dma_mem get_fat_cmd; |
| 1698 | struct be_mcc_wrb *wrb; |
| 1699 | struct be_cmd_req_get_fat *req; |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1700 | u32 offset = 0, total_size, buf_size, |
| 1701 | log_offset = sizeof(u32), payload_len; |
Vasundhara Volam | c5f156d | 2014-09-02 09:56:54 +0530 | [diff] [blame] | 1702 | int status = 0; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1703 | |
| 1704 | if (buf_len == 0) |
Vasundhara Volam | c5f156d | 2014-09-02 09:56:54 +0530 | [diff] [blame] | 1705 | return -EIO; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1706 | |
| 1707 | total_size = buf_len; |
| 1708 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1709 | get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024; |
| 1710 | get_fat_cmd.va = pci_alloc_consistent(adapter->pdev, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1711 | get_fat_cmd.size, |
| 1712 | &get_fat_cmd.dma); |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1713 | if (!get_fat_cmd.va) { |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1714 | dev_err(&adapter->pdev->dev, |
| 1715 | "Memory allocation failure while retrieving FAT data\n"); |
Vasundhara Volam | c5f156d | 2014-09-02 09:56:54 +0530 | [diff] [blame] | 1716 | return -ENOMEM; |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1719 | spin_lock_bh(&adapter->mcc_lock); |
| 1720 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1721 | while (total_size) { |
| 1722 | buf_size = min(total_size, (u32)60*1024); |
| 1723 | total_size -= buf_size; |
| 1724 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1725 | wrb = wrb_from_mccq(adapter); |
| 1726 | if (!wrb) { |
| 1727 | status = -EBUSY; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1728 | goto err; |
| 1729 | } |
| 1730 | req = get_fat_cmd.va; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1731 | |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1732 | payload_len = sizeof(struct be_cmd_req_get_fat) + buf_size; |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1733 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1734 | OPCODE_COMMON_MANAGE_FAT, payload_len, |
| 1735 | wrb, &get_fat_cmd); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1736 | |
| 1737 | req->fat_operation = cpu_to_le32(RETRIEVE_FAT); |
| 1738 | req->read_log_offset = cpu_to_le32(log_offset); |
| 1739 | req->read_log_length = cpu_to_le32(buf_size); |
| 1740 | req->data_buffer_size = cpu_to_le32(buf_size); |
| 1741 | |
| 1742 | status = be_mcc_notify_wait(adapter); |
| 1743 | if (!status) { |
| 1744 | struct be_cmd_resp_get_fat *resp = get_fat_cmd.va; |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 1745 | |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1746 | memcpy(buf + offset, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1747 | resp->data_buffer, |
| 1748 | le32_to_cpu(resp->read_log_length)); |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1749 | } else { |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1750 | dev_err(&adapter->pdev->dev, "FAT Table Retrieve error\n"); |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1751 | goto err; |
| 1752 | } |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1753 | offset += buf_size; |
| 1754 | log_offset += buf_size; |
| 1755 | } |
| 1756 | err: |
Somnath Kotur | fe2a70e | 2011-04-21 03:18:12 +0000 | [diff] [blame] | 1757 | pci_free_consistent(adapter->pdev, get_fat_cmd.size, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1758 | get_fat_cmd.va, get_fat_cmd.dma); |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1759 | spin_unlock_bh(&adapter->mcc_lock); |
Vasundhara Volam | c5f156d | 2014-09-02 09:56:54 +0530 | [diff] [blame] | 1760 | return status; |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1761 | } |
| 1762 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1763 | /* Uses synchronous mcc */ |
Kalesh AP | e97e3cd | 2014-07-17 16:20:26 +0530 | [diff] [blame] | 1764 | int be_cmd_get_fw_ver(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1765 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1766 | struct be_mcc_wrb *wrb; |
| 1767 | struct be_cmd_req_get_fw_version *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1768 | int status; |
| 1769 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1770 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1771 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1772 | wrb = wrb_from_mccq(adapter); |
| 1773 | if (!wrb) { |
| 1774 | status = -EBUSY; |
| 1775 | goto err; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1776 | } |
| 1777 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1778 | req = embedded_payload(wrb); |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1779 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1780 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1781 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req), wrb, |
| 1782 | NULL); |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1783 | status = be_mcc_notify_wait(adapter); |
| 1784 | if (!status) { |
| 1785 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); |
Sathya Perla | acbafeb | 2014-09-02 09:56:46 +0530 | [diff] [blame] | 1786 | |
Vasundhara Volam | 242eb47 | 2014-09-12 17:39:15 +0530 | [diff] [blame] | 1787 | strlcpy(adapter->fw_ver, resp->firmware_version_string, |
| 1788 | sizeof(adapter->fw_ver)); |
| 1789 | strlcpy(adapter->fw_on_flash, resp->fw_on_flash_version_string, |
| 1790 | sizeof(adapter->fw_on_flash)); |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 1791 | } |
| 1792 | err: |
| 1793 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1794 | return status; |
| 1795 | } |
| 1796 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1797 | /* set the EQ delay interval of an EQ to specified value |
| 1798 | * Uses async mcc |
| 1799 | */ |
Kalesh AP | b502ae8 | 2014-09-19 15:46:51 +0530 | [diff] [blame] | 1800 | static int __be_cmd_modify_eqd(struct be_adapter *adapter, |
| 1801 | struct be_set_eqd *set_eqd, int num) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1802 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1803 | struct be_mcc_wrb *wrb; |
| 1804 | struct be_cmd_req_modify_eq_delay *req; |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 1805 | int status = 0, i; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1806 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1807 | spin_lock_bh(&adapter->mcc_lock); |
| 1808 | |
| 1809 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1810 | if (!wrb) { |
| 1811 | status = -EBUSY; |
| 1812 | goto err; |
| 1813 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1814 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1815 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1816 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1817 | OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req), wrb, |
| 1818 | NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1819 | |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 1820 | req->num_eq = cpu_to_le32(num); |
| 1821 | for (i = 0; i < num; i++) { |
| 1822 | req->set_eqd[i].eq_id = cpu_to_le32(set_eqd[i].eq_id); |
| 1823 | req->set_eqd[i].phase = 0; |
| 1824 | req->set_eqd[i].delay_multiplier = |
| 1825 | cpu_to_le32(set_eqd[i].delay_multiplier); |
| 1826 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1827 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1828 | be_mcc_notify(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1829 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1830 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1831 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1832 | } |
| 1833 | |
Kalesh AP | 9367670 | 2014-09-12 17:39:20 +0530 | [diff] [blame] | 1834 | int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *set_eqd, |
| 1835 | int num) |
| 1836 | { |
| 1837 | int num_eqs, i = 0; |
| 1838 | |
| 1839 | if (lancer_chip(adapter) && num > 8) { |
| 1840 | while (num) { |
| 1841 | num_eqs = min(num, 8); |
| 1842 | __be_cmd_modify_eqd(adapter, &set_eqd[i], num_eqs); |
| 1843 | i += num_eqs; |
| 1844 | num -= num_eqs; |
| 1845 | } |
| 1846 | } else { |
| 1847 | __be_cmd_modify_eqd(adapter, set_eqd, num); |
| 1848 | } |
| 1849 | |
| 1850 | return 0; |
| 1851 | } |
| 1852 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1853 | /* Uses sycnhronous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1854 | int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, |
Kalesh AP | 4d567d9 | 2014-05-09 13:29:17 +0530 | [diff] [blame] | 1855 | u32 num) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1856 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1857 | struct be_mcc_wrb *wrb; |
| 1858 | struct be_cmd_req_vlan_config *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1859 | int status; |
| 1860 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1861 | spin_lock_bh(&adapter->mcc_lock); |
| 1862 | |
| 1863 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1864 | if (!wrb) { |
| 1865 | status = -EBUSY; |
| 1866 | goto err; |
| 1867 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1868 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1869 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1870 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1871 | OPCODE_COMMON_NTWK_VLAN_CONFIG, sizeof(*req), |
| 1872 | wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1873 | |
| 1874 | req->interface_id = if_id; |
Ajit Khaparde | 012bd38 | 2013-11-18 10:44:24 -0600 | [diff] [blame] | 1875 | req->untagged = BE_IF_FLAGS_UNTAGGED & be_if_cap_flags(adapter) ? 1 : 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1876 | req->num_vlan = num; |
Kalesh AP | 4d567d9 | 2014-05-09 13:29:17 +0530 | [diff] [blame] | 1877 | memcpy(req->normal_vlan, vtag_array, |
| 1878 | req->num_vlan * sizeof(vtag_array[0])); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1879 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1880 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1881 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1882 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1883 | return status; |
| 1884 | } |
| 1885 | |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1886 | 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] | 1887 | { |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 1888 | struct be_mcc_wrb *wrb; |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1889 | struct be_dma_mem *mem = &adapter->rx_filter; |
| 1890 | struct be_cmd_req_rx_filter *req = mem->va; |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1891 | int status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1892 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1893 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6ac7b68 | 2009-06-18 00:05:54 +0000 | [diff] [blame] | 1894 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1895 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1896 | if (!wrb) { |
| 1897 | status = -EBUSY; |
| 1898 | goto err; |
| 1899 | } |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1900 | memset(req, 0, sizeof(*req)); |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1901 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1902 | OPCODE_COMMON_NTWK_RX_FILTER, sizeof(*req), |
| 1903 | wrb, mem); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1904 | |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1905 | req->if_id = cpu_to_le32(adapter->if_handle); |
| 1906 | if (flags & IFF_PROMISC) { |
| 1907 | req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1908 | BE_IF_FLAGS_VLAN_PROMISCUOUS | |
| 1909 | BE_IF_FLAGS_MCAST_PROMISCUOUS); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1910 | if (value == ON) |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1911 | req->if_flags = |
| 1912 | cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS | |
| 1913 | BE_IF_FLAGS_VLAN_PROMISCUOUS | |
| 1914 | BE_IF_FLAGS_MCAST_PROMISCUOUS); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1915 | } else if (flags & IFF_ALLMULTI) { |
| 1916 | req->if_flags_mask = req->if_flags = |
Sathya Perla | 8e7d3f6 | 2011-09-27 13:29:38 -0400 | [diff] [blame] | 1917 | cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS); |
Ajit Khaparde | d9d604f | 2013-09-27 15:17:58 -0500 | [diff] [blame] | 1918 | } else if (flags & BE_FLAGS_VLAN_PROMISC) { |
| 1919 | req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_VLAN_PROMISCUOUS); |
| 1920 | |
| 1921 | if (value == ON) |
| 1922 | req->if_flags = |
| 1923 | cpu_to_le32(BE_IF_FLAGS_VLAN_PROMISCUOUS); |
Sathya Perla | 24307ee | 2009-06-18 00:09:25 +0000 | [diff] [blame] | 1924 | } else { |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1925 | struct netdev_hw_addr *ha; |
| 1926 | int i = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1927 | |
Sathya Perla | 8e7d3f6 | 2011-09-27 13:29:38 -0400 | [diff] [blame] | 1928 | req->if_flags_mask = req->if_flags = |
| 1929 | cpu_to_le32(BE_IF_FLAGS_MULTICAST); |
Padmanabh Ratnakar | 1610c79 | 2011-11-03 01:49:27 +0000 | [diff] [blame] | 1930 | |
| 1931 | /* Reset mcast promisc mode if already set by setting mask |
| 1932 | * and not setting flags field |
| 1933 | */ |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 1934 | req->if_flags_mask |= |
| 1935 | cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS & |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 1936 | be_if_cap_flags(adapter)); |
Padmanabh Ratnakar | 016f97b | 2011-11-03 01:49:13 +0000 | [diff] [blame] | 1937 | req->mcast_num = cpu_to_le32(netdev_mc_count(adapter->netdev)); |
Sathya Perla | 5b8821b | 2011-08-02 19:57:44 +0000 | [diff] [blame] | 1938 | netdev_for_each_mc_addr(ha, adapter->netdev) |
| 1939 | memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN); |
| 1940 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1941 | |
Ajit Khaparde | 012bd38 | 2013-11-18 10:44:24 -0600 | [diff] [blame] | 1942 | if ((req->if_flags_mask & cpu_to_le32(be_if_cap_flags(adapter))) != |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1943 | req->if_flags_mask) { |
Ajit Khaparde | 012bd38 | 2013-11-18 10:44:24 -0600 | [diff] [blame] | 1944 | dev_warn(&adapter->pdev->dev, |
| 1945 | "Cannot set rx filter flags 0x%x\n", |
| 1946 | req->if_flags_mask); |
| 1947 | dev_warn(&adapter->pdev->dev, |
| 1948 | "Interface is capable of 0x%x flags only\n", |
| 1949 | be_if_cap_flags(adapter)); |
| 1950 | } |
| 1951 | req->if_flags_mask &= cpu_to_le32(be_if_cap_flags(adapter)); |
| 1952 | |
Sathya Perla | 0d1d587 | 2011-08-03 05:19:27 -0700 | [diff] [blame] | 1953 | status = be_mcc_notify_wait(adapter); |
Ajit Khaparde | 012bd38 | 2013-11-18 10:44:24 -0600 | [diff] [blame] | 1954 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1955 | err: |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1956 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | e7b909a | 2009-11-22 22:01:10 +0000 | [diff] [blame] | 1957 | return status; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1958 | } |
| 1959 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1960 | /* Uses synchrounous mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 1961 | 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] | 1962 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1963 | struct be_mcc_wrb *wrb; |
| 1964 | struct be_cmd_req_set_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1965 | int status; |
| 1966 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 1967 | if (!be_cmd_allowed(adapter, OPCODE_COMMON_SET_FLOW_CONTROL, |
| 1968 | CMD_SUBSYSTEM_COMMON)) |
| 1969 | return -EPERM; |
| 1970 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1971 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1972 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1973 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1974 | if (!wrb) { |
| 1975 | status = -EBUSY; |
| 1976 | goto err; |
| 1977 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1978 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1979 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 1980 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 1981 | OPCODE_COMMON_SET_FLOW_CONTROL, sizeof(*req), |
| 1982 | wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1983 | |
Suresh Reddy | b29812c | 2014-09-12 17:39:17 +0530 | [diff] [blame] | 1984 | req->hdr.version = 1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1985 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); |
| 1986 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); |
| 1987 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1988 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1989 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 1990 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1991 | spin_unlock_bh(&adapter->mcc_lock); |
Suresh Reddy | b29812c | 2014-09-12 17:39:17 +0530 | [diff] [blame] | 1992 | |
| 1993 | if (base_status(status) == MCC_STATUS_FEATURE_NOT_SUPPORTED) |
| 1994 | return -EOPNOTSUPP; |
| 1995 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1996 | return status; |
| 1997 | } |
| 1998 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 1999 | /* Uses sycn mcc */ |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 2000 | 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] | 2001 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2002 | struct be_mcc_wrb *wrb; |
| 2003 | struct be_cmd_req_get_flow_control *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2004 | int status; |
| 2005 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 2006 | if (!be_cmd_allowed(adapter, OPCODE_COMMON_GET_FLOW_CONTROL, |
| 2007 | CMD_SUBSYSTEM_COMMON)) |
| 2008 | return -EPERM; |
| 2009 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2010 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2011 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2012 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2013 | if (!wrb) { |
| 2014 | status = -EBUSY; |
| 2015 | goto err; |
| 2016 | } |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2017 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2018 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2019 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2020 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req), |
| 2021 | wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2022 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2023 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2024 | if (!status) { |
| 2025 | struct be_cmd_resp_get_flow_control *resp = |
| 2026 | embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2027 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2028 | *tx_fc = le16_to_cpu(resp->tx_flow_control); |
| 2029 | *rx_fc = le16_to_cpu(resp->rx_flow_control); |
| 2030 | } |
| 2031 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2032 | err: |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2033 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2034 | return status; |
| 2035 | } |
| 2036 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2037 | /* Uses mbox */ |
Kalesh AP | e97e3cd | 2014-07-17 16:20:26 +0530 | [diff] [blame] | 2038 | int be_cmd_query_fw_cfg(struct be_adapter *adapter) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2039 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2040 | struct be_mcc_wrb *wrb; |
| 2041 | struct be_cmd_req_query_fw_cfg *req; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2042 | int status; |
| 2043 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 2044 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2045 | return -1; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2046 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2047 | wrb = wrb_from_mbox(adapter); |
| 2048 | req = embedded_payload(wrb); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2049 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2050 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2051 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, |
| 2052 | sizeof(*req), wrb, NULL); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2053 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2054 | status = be_mbox_notify_wait(adapter); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2055 | if (!status) { |
| 2056 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2057 | |
Kalesh AP | e97e3cd | 2014-07-17 16:20:26 +0530 | [diff] [blame] | 2058 | adapter->port_num = le32_to_cpu(resp->phys_port); |
| 2059 | adapter->function_mode = le32_to_cpu(resp->function_mode); |
| 2060 | adapter->function_caps = le32_to_cpu(resp->function_caps); |
| 2061 | adapter->asic_rev = le32_to_cpu(resp->asic_revision) & 0xFF; |
Sathya Perla | acbafeb | 2014-09-02 09:56:46 +0530 | [diff] [blame] | 2062 | dev_info(&adapter->pdev->dev, |
| 2063 | "FW config: function_mode=0x%x, function_caps=0x%x\n", |
| 2064 | adapter->function_mode, adapter->function_caps); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2065 | } |
| 2066 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 2067 | mutex_unlock(&adapter->mbox_lock); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 2068 | return status; |
| 2069 | } |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2070 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2071 | /* Uses mbox */ |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2072 | int be_cmd_reset_function(struct be_adapter *adapter) |
| 2073 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2074 | struct be_mcc_wrb *wrb; |
| 2075 | struct be_cmd_req_hdr *req; |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2076 | int status; |
| 2077 | |
Padmanabh Ratnakar | bf99e50 | 2012-07-12 03:56:58 +0000 | [diff] [blame] | 2078 | if (lancer_chip(adapter)) { |
| 2079 | status = lancer_wait_ready(adapter); |
| 2080 | if (!status) { |
| 2081 | iowrite32(SLI_PORT_CONTROL_IP_MASK, |
| 2082 | adapter->db + SLIPORT_CONTROL_OFFSET); |
| 2083 | status = lancer_test_and_set_rdy_state(adapter); |
| 2084 | } |
| 2085 | if (status) { |
| 2086 | dev_err(&adapter->pdev->dev, |
| 2087 | "Adapter in non recoverable error\n"); |
| 2088 | } |
| 2089 | return status; |
| 2090 | } |
| 2091 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 2092 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2093 | return -1; |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2094 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2095 | wrb = wrb_from_mbox(adapter); |
| 2096 | req = embedded_payload(wrb); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2097 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2098 | be_wrb_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2099 | OPCODE_COMMON_FUNCTION_RESET, sizeof(*req), wrb, |
| 2100 | NULL); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2101 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2102 | status = be_mbox_notify_wait(adapter); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2103 | |
Ivan Vecera | 2984961 | 2010-12-14 05:43:19 +0000 | [diff] [blame] | 2104 | mutex_unlock(&adapter->mbox_lock); |
sarveshwarb | 14074ea | 2009-08-05 13:05:24 -0700 | [diff] [blame] | 2105 | return status; |
| 2106 | } |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2107 | |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 2108 | int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, |
Ben Hutchings | 33cb0fa | 2014-05-15 02:01:23 +0100 | [diff] [blame] | 2109 | u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey) |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2110 | { |
| 2111 | struct be_mcc_wrb *wrb; |
| 2112 | struct be_cmd_req_rss_config *req; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2113 | int status; |
| 2114 | |
Vasundhara Volam | da1388d | 2014-01-06 13:02:23 +0530 | [diff] [blame] | 2115 | if (!(be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS)) |
| 2116 | return 0; |
| 2117 | |
Kalesh AP | b51aa36 | 2014-05-09 13:29:19 +0530 | [diff] [blame] | 2118 | spin_lock_bh(&adapter->mcc_lock); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2119 | |
Kalesh AP | b51aa36 | 2014-05-09 13:29:19 +0530 | [diff] [blame] | 2120 | wrb = wrb_from_mccq(adapter); |
| 2121 | if (!wrb) { |
| 2122 | status = -EBUSY; |
| 2123 | goto err; |
| 2124 | } |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2125 | req = embedded_payload(wrb); |
| 2126 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2127 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2128 | OPCODE_ETH_RSS_CONFIG, sizeof(*req), wrb, NULL); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2129 | |
| 2130 | req->if_id = cpu_to_le32(adapter->if_handle); |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 2131 | req->enable_rss = cpu_to_le16(rss_hash_opts); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2132 | req->cpu_table_size_log2 = cpu_to_le16(fls(table_size) - 1); |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 2133 | |
Kalesh AP | b51aa36 | 2014-05-09 13:29:19 +0530 | [diff] [blame] | 2134 | if (!BEx_chip(adapter)) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 2135 | req->hdr.version = 1; |
| 2136 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2137 | memcpy(req->cpu_table, rsstable, table_size); |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 2138 | memcpy(req->hash, rss_hkey, RSS_HASH_KEY_LEN); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2139 | be_dws_cpu_to_le(req->hash, sizeof(req->hash)); |
| 2140 | |
Kalesh AP | b51aa36 | 2014-05-09 13:29:19 +0530 | [diff] [blame] | 2141 | status = be_mcc_notify_wait(adapter); |
| 2142 | err: |
| 2143 | spin_unlock_bh(&adapter->mcc_lock); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 2144 | return status; |
| 2145 | } |
| 2146 | |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2147 | /* Uses sync mcc */ |
| 2148 | int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2149 | u8 bcn, u8 sts, u8 state) |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2150 | { |
| 2151 | struct be_mcc_wrb *wrb; |
| 2152 | struct be_cmd_req_enable_disable_beacon *req; |
| 2153 | int status; |
| 2154 | |
| 2155 | spin_lock_bh(&adapter->mcc_lock); |
| 2156 | |
| 2157 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2158 | if (!wrb) { |
| 2159 | status = -EBUSY; |
| 2160 | goto err; |
| 2161 | } |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2162 | req = embedded_payload(wrb); |
| 2163 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2164 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2165 | OPCODE_COMMON_ENABLE_DISABLE_BEACON, |
| 2166 | sizeof(*req), wrb, NULL); |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2167 | |
| 2168 | req->port_num = port_num; |
| 2169 | req->beacon_state = state; |
| 2170 | req->beacon_duration = bcn; |
| 2171 | req->status_duration = sts; |
| 2172 | |
| 2173 | status = be_mcc_notify_wait(adapter); |
| 2174 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2175 | err: |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2176 | spin_unlock_bh(&adapter->mcc_lock); |
| 2177 | return status; |
| 2178 | } |
| 2179 | |
| 2180 | /* Uses sync mcc */ |
| 2181 | int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state) |
| 2182 | { |
| 2183 | struct be_mcc_wrb *wrb; |
| 2184 | struct be_cmd_req_get_beacon_state *req; |
| 2185 | int status; |
| 2186 | |
| 2187 | spin_lock_bh(&adapter->mcc_lock); |
| 2188 | |
| 2189 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2190 | if (!wrb) { |
| 2191 | status = -EBUSY; |
| 2192 | goto err; |
| 2193 | } |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2194 | req = embedded_payload(wrb); |
| 2195 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2196 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2197 | OPCODE_COMMON_GET_BEACON_STATE, sizeof(*req), |
| 2198 | wrb, NULL); |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2199 | |
| 2200 | req->port_num = port_num; |
| 2201 | |
| 2202 | status = be_mcc_notify_wait(adapter); |
| 2203 | if (!status) { |
| 2204 | struct be_cmd_resp_get_beacon_state *resp = |
| 2205 | embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2206 | |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2207 | *state = resp->beacon_state; |
| 2208 | } |
| 2209 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2210 | err: |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 2211 | spin_unlock_bh(&adapter->mcc_lock); |
| 2212 | return status; |
| 2213 | } |
| 2214 | |
Mark Leonard | e36edd9 | 2014-09-12 17:39:18 +0530 | [diff] [blame] | 2215 | /* Uses sync mcc */ |
| 2216 | int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, |
| 2217 | u8 page_num, u8 *data) |
| 2218 | { |
| 2219 | struct be_dma_mem cmd; |
| 2220 | struct be_mcc_wrb *wrb; |
| 2221 | struct be_cmd_req_port_type *req; |
| 2222 | int status; |
| 2223 | |
| 2224 | if (page_num > TR_PAGE_A2) |
| 2225 | return -EINVAL; |
| 2226 | |
| 2227 | cmd.size = sizeof(struct be_cmd_resp_port_type); |
| 2228 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
| 2229 | if (!cmd.va) { |
| 2230 | dev_err(&adapter->pdev->dev, "Memory allocation failed\n"); |
| 2231 | return -ENOMEM; |
| 2232 | } |
| 2233 | memset(cmd.va, 0, cmd.size); |
| 2234 | |
| 2235 | spin_lock_bh(&adapter->mcc_lock); |
| 2236 | |
| 2237 | wrb = wrb_from_mccq(adapter); |
| 2238 | if (!wrb) { |
| 2239 | status = -EBUSY; |
| 2240 | goto err; |
| 2241 | } |
| 2242 | req = cmd.va; |
| 2243 | |
| 2244 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2245 | OPCODE_COMMON_READ_TRANSRECV_DATA, |
| 2246 | cmd.size, wrb, &cmd); |
| 2247 | |
| 2248 | req->port = cpu_to_le32(adapter->hba_port_num); |
| 2249 | req->page_num = cpu_to_le32(page_num); |
| 2250 | status = be_mcc_notify_wait(adapter); |
| 2251 | if (!status) { |
| 2252 | struct be_cmd_resp_port_type *resp = cmd.va; |
| 2253 | |
| 2254 | memcpy(data, resp->page_data, PAGE_DATA_LEN); |
| 2255 | } |
| 2256 | err: |
| 2257 | spin_unlock_bh(&adapter->mcc_lock); |
| 2258 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
| 2259 | return status; |
| 2260 | } |
| 2261 | |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2262 | int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd, |
Padmanabh Ratnakar | f67ef7b | 2012-07-12 03:57:09 +0000 | [diff] [blame] | 2263 | u32 data_size, u32 data_offset, |
| 2264 | const char *obj_name, u32 *data_written, |
| 2265 | u8 *change_status, u8 *addn_status) |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2266 | { |
| 2267 | struct be_mcc_wrb *wrb; |
| 2268 | struct lancer_cmd_req_write_object *req; |
| 2269 | struct lancer_cmd_resp_write_object *resp; |
| 2270 | void *ctxt = NULL; |
| 2271 | int status; |
| 2272 | |
| 2273 | spin_lock_bh(&adapter->mcc_lock); |
| 2274 | adapter->flash_status = 0; |
| 2275 | |
| 2276 | wrb = wrb_from_mccq(adapter); |
| 2277 | if (!wrb) { |
| 2278 | status = -EBUSY; |
| 2279 | goto err_unlock; |
| 2280 | } |
| 2281 | |
| 2282 | req = embedded_payload(wrb); |
| 2283 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2284 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2285 | OPCODE_COMMON_WRITE_OBJECT, |
| 2286 | sizeof(struct lancer_cmd_req_write_object), wrb, |
| 2287 | NULL); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2288 | |
| 2289 | ctxt = &req->context; |
| 2290 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2291 | write_length, ctxt, data_size); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2292 | |
| 2293 | if (data_size == 0) |
| 2294 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2295 | eof, ctxt, 1); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2296 | else |
| 2297 | AMAP_SET_BITS(struct amap_lancer_write_obj_context, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2298 | eof, ctxt, 0); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2299 | |
| 2300 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
| 2301 | req->write_offset = cpu_to_le32(data_offset); |
Vasundhara Volam | 242eb47 | 2014-09-12 17:39:15 +0530 | [diff] [blame] | 2302 | strlcpy(req->object_name, obj_name, sizeof(req->object_name)); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2303 | req->descriptor_count = cpu_to_le32(1); |
| 2304 | req->buf_len = cpu_to_le32(data_size); |
| 2305 | req->addr_low = cpu_to_le32((cmd->dma + |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2306 | sizeof(struct lancer_cmd_req_write_object)) |
| 2307 | & 0xFFFFFFFF); |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2308 | req->addr_high = cpu_to_le32(upper_32_bits(cmd->dma + |
| 2309 | sizeof(struct lancer_cmd_req_write_object))); |
| 2310 | |
| 2311 | be_mcc_notify(adapter); |
| 2312 | spin_unlock_bh(&adapter->mcc_lock); |
| 2313 | |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2314 | if (!wait_for_completion_timeout(&adapter->et_cmd_compl, |
Somnath Kotur | 701962d | 2013-05-02 03:36:34 +0000 | [diff] [blame] | 2315 | msecs_to_jiffies(60000))) |
Kalesh AP | fd45160 | 2014-07-17 16:20:21 +0530 | [diff] [blame] | 2316 | status = -ETIMEDOUT; |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2317 | else |
| 2318 | status = adapter->flash_status; |
| 2319 | |
| 2320 | resp = embedded_payload(wrb); |
Padmanabh Ratnakar | f67ef7b | 2012-07-12 03:57:09 +0000 | [diff] [blame] | 2321 | if (!status) { |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2322 | *data_written = le32_to_cpu(resp->actual_write_len); |
Padmanabh Ratnakar | f67ef7b | 2012-07-12 03:57:09 +0000 | [diff] [blame] | 2323 | *change_status = resp->change_status; |
| 2324 | } else { |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2325 | *addn_status = resp->additional_status; |
Padmanabh Ratnakar | f67ef7b | 2012-07-12 03:57:09 +0000 | [diff] [blame] | 2326 | } |
Shripad Nunjundarao | 485bf56 | 2011-05-16 07:36:59 +0000 | [diff] [blame] | 2327 | |
| 2328 | return status; |
| 2329 | |
| 2330 | err_unlock: |
| 2331 | spin_unlock_bh(&adapter->mcc_lock); |
| 2332 | return status; |
| 2333 | } |
| 2334 | |
Ravikumar Nelavelli | 6809cee | 2014-09-12 17:39:19 +0530 | [diff] [blame] | 2335 | int be_cmd_query_cable_type(struct be_adapter *adapter) |
| 2336 | { |
| 2337 | u8 page_data[PAGE_DATA_LEN]; |
| 2338 | int status; |
| 2339 | |
| 2340 | status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, |
| 2341 | page_data); |
| 2342 | if (!status) { |
| 2343 | switch (adapter->phy.interface_type) { |
| 2344 | case PHY_TYPE_QSFP: |
| 2345 | adapter->phy.cable_type = |
| 2346 | page_data[QSFP_PLUS_CABLE_TYPE_OFFSET]; |
| 2347 | break; |
| 2348 | case PHY_TYPE_SFP_PLUS_10GB: |
| 2349 | adapter->phy.cable_type = |
| 2350 | page_data[SFP_PLUS_CABLE_TYPE_OFFSET]; |
| 2351 | break; |
| 2352 | default: |
| 2353 | adapter->phy.cable_type = 0; |
| 2354 | break; |
| 2355 | } |
| 2356 | } |
| 2357 | return status; |
| 2358 | } |
| 2359 | |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 2360 | int lancer_cmd_delete_object(struct be_adapter *adapter, const char *obj_name) |
| 2361 | { |
| 2362 | struct lancer_cmd_req_delete_object *req; |
| 2363 | struct be_mcc_wrb *wrb; |
| 2364 | int status; |
| 2365 | |
| 2366 | spin_lock_bh(&adapter->mcc_lock); |
| 2367 | |
| 2368 | wrb = wrb_from_mccq(adapter); |
| 2369 | if (!wrb) { |
| 2370 | status = -EBUSY; |
| 2371 | goto err; |
| 2372 | } |
| 2373 | |
| 2374 | req = embedded_payload(wrb); |
| 2375 | |
| 2376 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2377 | OPCODE_COMMON_DELETE_OBJECT, |
| 2378 | sizeof(*req), wrb, NULL); |
| 2379 | |
Vasundhara Volam | 242eb47 | 2014-09-12 17:39:15 +0530 | [diff] [blame] | 2380 | strlcpy(req->object_name, obj_name, sizeof(req->object_name)); |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 2381 | |
| 2382 | status = be_mcc_notify_wait(adapter); |
| 2383 | err: |
| 2384 | spin_unlock_bh(&adapter->mcc_lock); |
| 2385 | return status; |
| 2386 | } |
| 2387 | |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 2388 | int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2389 | u32 data_size, u32 data_offset, const char *obj_name, |
| 2390 | u32 *data_read, u32 *eof, u8 *addn_status) |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 2391 | { |
| 2392 | struct be_mcc_wrb *wrb; |
| 2393 | struct lancer_cmd_req_read_object *req; |
| 2394 | struct lancer_cmd_resp_read_object *resp; |
| 2395 | int status; |
| 2396 | |
| 2397 | spin_lock_bh(&adapter->mcc_lock); |
| 2398 | |
| 2399 | wrb = wrb_from_mccq(adapter); |
| 2400 | if (!wrb) { |
| 2401 | status = -EBUSY; |
| 2402 | goto err_unlock; |
| 2403 | } |
| 2404 | |
| 2405 | req = embedded_payload(wrb); |
| 2406 | |
| 2407 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2408 | OPCODE_COMMON_READ_OBJECT, |
| 2409 | sizeof(struct lancer_cmd_req_read_object), wrb, |
| 2410 | NULL); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 2411 | |
| 2412 | req->desired_read_len = cpu_to_le32(data_size); |
| 2413 | req->read_offset = cpu_to_le32(data_offset); |
| 2414 | strcpy(req->object_name, obj_name); |
| 2415 | req->descriptor_count = cpu_to_le32(1); |
| 2416 | req->buf_len = cpu_to_le32(data_size); |
| 2417 | req->addr_low = cpu_to_le32((cmd->dma & 0xFFFFFFFF)); |
| 2418 | req->addr_high = cpu_to_le32(upper_32_bits(cmd->dma)); |
| 2419 | |
| 2420 | status = be_mcc_notify_wait(adapter); |
| 2421 | |
| 2422 | resp = embedded_payload(wrb); |
| 2423 | if (!status) { |
| 2424 | *data_read = le32_to_cpu(resp->actual_read_len); |
| 2425 | *eof = le32_to_cpu(resp->eof); |
| 2426 | } else { |
| 2427 | *addn_status = resp->additional_status; |
| 2428 | } |
| 2429 | |
| 2430 | err_unlock: |
| 2431 | spin_unlock_bh(&adapter->mcc_lock); |
| 2432 | return status; |
| 2433 | } |
| 2434 | |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2435 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2436 | u32 flash_type, u32 flash_opcode, u32 buf_size) |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2437 | { |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2438 | struct be_mcc_wrb *wrb; |
Ajit Khaparde | 3f0d456 | 2010-02-09 01:30:35 +0000 | [diff] [blame] | 2439 | struct be_cmd_write_flashrom *req; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2440 | int status; |
| 2441 | |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2442 | spin_lock_bh(&adapter->mcc_lock); |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 2443 | adapter->flash_status = 0; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2444 | |
| 2445 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2446 | if (!wrb) { |
| 2447 | status = -EBUSY; |
Dan Carpenter | 2892d9c | 2010-05-26 04:46:35 +0000 | [diff] [blame] | 2448 | goto err_unlock; |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2449 | } |
| 2450 | req = cmd->va; |
Sathya Perla | b31c50a | 2009-09-17 10:30:13 -0700 | [diff] [blame] | 2451 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2452 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2453 | OPCODE_COMMON_WRITE_FLASHROM, cmd->size, wrb, |
| 2454 | cmd); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2455 | |
| 2456 | req->params.op_type = cpu_to_le32(flash_type); |
| 2457 | req->params.op_code = cpu_to_le32(flash_opcode); |
| 2458 | req->params.data_buf_size = cpu_to_le32(buf_size); |
| 2459 | |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 2460 | be_mcc_notify(adapter); |
| 2461 | spin_unlock_bh(&adapter->mcc_lock); |
| 2462 | |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2463 | if (!wait_for_completion_timeout(&adapter->et_cmd_compl, |
| 2464 | msecs_to_jiffies(40000))) |
Kalesh AP | fd45160 | 2014-07-17 16:20:21 +0530 | [diff] [blame] | 2465 | status = -ETIMEDOUT; |
Sarveshwar Bandi | dd131e7 | 2010-05-25 16:16:32 -0700 | [diff] [blame] | 2466 | else |
| 2467 | status = adapter->flash_status; |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2468 | |
Dan Carpenter | 2892d9c | 2010-05-26 04:46:35 +0000 | [diff] [blame] | 2469 | return status; |
| 2470 | |
| 2471 | err_unlock: |
| 2472 | spin_unlock_bh(&adapter->mcc_lock); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 2473 | return status; |
| 2474 | } |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2475 | |
Ajit Khaparde | 3f0d456 | 2010-02-09 01:30:35 +0000 | [diff] [blame] | 2476 | int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, |
Vasundhara Volam | 96c9b2e | 2014-05-30 19:06:25 +0530 | [diff] [blame] | 2477 | u16 optype, int offset) |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2478 | { |
| 2479 | struct be_mcc_wrb *wrb; |
Padmanabh Ratnakar | be71644 | 2012-10-22 23:02:44 +0000 | [diff] [blame] | 2480 | struct be_cmd_read_flash_crc *req; |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2481 | int status; |
| 2482 | |
| 2483 | spin_lock_bh(&adapter->mcc_lock); |
| 2484 | |
| 2485 | wrb = wrb_from_mccq(adapter); |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2486 | if (!wrb) { |
| 2487 | status = -EBUSY; |
| 2488 | goto err; |
| 2489 | } |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2490 | req = embedded_payload(wrb); |
| 2491 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2492 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Padmanabh Ratnakar | be71644 | 2012-10-22 23:02:44 +0000 | [diff] [blame] | 2493 | OPCODE_COMMON_READ_FLASHROM, sizeof(*req), |
| 2494 | wrb, NULL); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2495 | |
Vasundhara Volam | 96c9b2e | 2014-05-30 19:06:25 +0530 | [diff] [blame] | 2496 | req->params.op_type = cpu_to_le32(optype); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2497 | req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT); |
Ajit Khaparde | 8b93b71 | 2010-03-31 01:57:10 +0000 | [diff] [blame] | 2498 | req->params.offset = cpu_to_le32(offset); |
| 2499 | req->params.data_buf_size = cpu_to_le32(0x4); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2500 | |
| 2501 | status = be_mcc_notify_wait(adapter); |
| 2502 | if (!status) |
Padmanabh Ratnakar | be71644 | 2012-10-22 23:02:44 +0000 | [diff] [blame] | 2503 | memcpy(flashed_crc, req->crc, 4); |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2504 | |
Sathya Perla | 713d0394 | 2009-11-22 22:02:45 +0000 | [diff] [blame] | 2505 | err: |
Sarveshwar Bandi | fa9a6fe | 2009-11-20 14:23:47 -0800 | [diff] [blame] | 2506 | spin_unlock_bh(&adapter->mcc_lock); |
| 2507 | return status; |
| 2508 | } |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2509 | |
Dan Carpenter | c196b02 | 2010-05-26 04:47:39 +0000 | [diff] [blame] | 2510 | int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2511 | struct be_dma_mem *nonemb_cmd) |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2512 | { |
| 2513 | struct be_mcc_wrb *wrb; |
| 2514 | struct be_cmd_req_acpi_wol_magic_config *req; |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2515 | int status; |
| 2516 | |
| 2517 | spin_lock_bh(&adapter->mcc_lock); |
| 2518 | |
| 2519 | wrb = wrb_from_mccq(adapter); |
| 2520 | if (!wrb) { |
| 2521 | status = -EBUSY; |
| 2522 | goto err; |
| 2523 | } |
| 2524 | req = nonemb_cmd->va; |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2525 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2526 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2527 | OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, sizeof(*req), |
| 2528 | wrb, nonemb_cmd); |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2529 | memcpy(req->magic_mac, mac, ETH_ALEN); |
| 2530 | |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 2531 | status = be_mcc_notify_wait(adapter); |
| 2532 | |
| 2533 | err: |
| 2534 | spin_unlock_bh(&adapter->mcc_lock); |
| 2535 | return status; |
| 2536 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2537 | |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 2538 | int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num, |
| 2539 | u8 loopback_type, u8 enable) |
| 2540 | { |
| 2541 | struct be_mcc_wrb *wrb; |
| 2542 | struct be_cmd_req_set_lmode *req; |
| 2543 | int status; |
| 2544 | |
| 2545 | spin_lock_bh(&adapter->mcc_lock); |
| 2546 | |
| 2547 | wrb = wrb_from_mccq(adapter); |
| 2548 | if (!wrb) { |
| 2549 | status = -EBUSY; |
| 2550 | goto err; |
| 2551 | } |
| 2552 | |
| 2553 | req = embedded_payload(wrb); |
| 2554 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2555 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2556 | OPCODE_LOWLEVEL_SET_LOOPBACK_MODE, sizeof(*req), |
| 2557 | wrb, NULL); |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 2558 | |
| 2559 | req->src_port = port_num; |
| 2560 | req->dest_port = port_num; |
| 2561 | req->loopback_type = loopback_type; |
| 2562 | req->loopback_state = enable; |
| 2563 | |
| 2564 | status = be_mcc_notify_wait(adapter); |
| 2565 | err: |
| 2566 | spin_unlock_bh(&adapter->mcc_lock); |
| 2567 | return status; |
| 2568 | } |
| 2569 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2570 | int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2571 | u32 loopback_type, u32 pkt_size, u32 num_pkts, |
| 2572 | u64 pattern) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2573 | { |
| 2574 | struct be_mcc_wrb *wrb; |
| 2575 | struct be_cmd_req_loopback_test *req; |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2576 | struct be_cmd_resp_loopback_test *resp; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2577 | int status; |
| 2578 | |
| 2579 | spin_lock_bh(&adapter->mcc_lock); |
| 2580 | |
| 2581 | wrb = wrb_from_mccq(adapter); |
| 2582 | if (!wrb) { |
| 2583 | status = -EBUSY; |
| 2584 | goto err; |
| 2585 | } |
| 2586 | |
| 2587 | req = embedded_payload(wrb); |
| 2588 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2589 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2590 | OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req), wrb, |
| 2591 | NULL); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2592 | |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2593 | req->hdr.timeout = cpu_to_le32(15); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2594 | req->pattern = cpu_to_le64(pattern); |
| 2595 | req->src_port = cpu_to_le32(port_num); |
| 2596 | req->dest_port = cpu_to_le32(port_num); |
| 2597 | req->pkt_size = cpu_to_le32(pkt_size); |
| 2598 | req->num_pkts = cpu_to_le32(num_pkts); |
| 2599 | req->loopback_type = cpu_to_le32(loopback_type); |
| 2600 | |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2601 | be_mcc_notify(adapter); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2602 | |
Suresh Reddy | 5eeff63 | 2014-01-06 13:02:24 +0530 | [diff] [blame] | 2603 | spin_unlock_bh(&adapter->mcc_lock); |
| 2604 | |
| 2605 | wait_for_completion(&adapter->et_cmd_compl); |
| 2606 | resp = embedded_payload(wrb); |
| 2607 | status = le32_to_cpu(resp->status); |
| 2608 | |
| 2609 | return status; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2610 | err: |
| 2611 | spin_unlock_bh(&adapter->mcc_lock); |
| 2612 | return status; |
| 2613 | } |
| 2614 | |
| 2615 | int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2616 | u32 byte_cnt, struct be_dma_mem *cmd) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2617 | { |
| 2618 | struct be_mcc_wrb *wrb; |
| 2619 | struct be_cmd_req_ddrdma_test *req; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2620 | int status; |
| 2621 | int i, j = 0; |
| 2622 | |
| 2623 | spin_lock_bh(&adapter->mcc_lock); |
| 2624 | |
| 2625 | wrb = wrb_from_mccq(adapter); |
| 2626 | if (!wrb) { |
| 2627 | status = -EBUSY; |
| 2628 | goto err; |
| 2629 | } |
| 2630 | req = cmd->va; |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2631 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2632 | OPCODE_LOWLEVEL_HOST_DDR_DMA, cmd->size, wrb, |
| 2633 | cmd); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2634 | |
| 2635 | req->pattern = cpu_to_le64(pattern); |
| 2636 | req->byte_count = cpu_to_le32(byte_cnt); |
| 2637 | for (i = 0; i < byte_cnt; i++) { |
| 2638 | req->snd_buff[i] = (u8)(pattern >> (j*8)); |
| 2639 | j++; |
| 2640 | if (j > 7) |
| 2641 | j = 0; |
| 2642 | } |
| 2643 | |
| 2644 | status = be_mcc_notify_wait(adapter); |
| 2645 | |
| 2646 | if (!status) { |
| 2647 | struct be_cmd_resp_ddrdma_test *resp; |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2648 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 2649 | resp = cmd->va; |
| 2650 | if ((memcmp(resp->rcv_buff, req->snd_buff, byte_cnt) != 0) || |
| 2651 | resp->snd_err) { |
| 2652 | status = -1; |
| 2653 | } |
| 2654 | } |
| 2655 | |
| 2656 | err: |
| 2657 | spin_unlock_bh(&adapter->mcc_lock); |
| 2658 | return status; |
| 2659 | } |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2660 | |
Dan Carpenter | c196b02 | 2010-05-26 04:47:39 +0000 | [diff] [blame] | 2661 | int be_cmd_get_seeprom_data(struct be_adapter *adapter, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2662 | struct be_dma_mem *nonemb_cmd) |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2663 | { |
| 2664 | struct be_mcc_wrb *wrb; |
| 2665 | struct be_cmd_req_seeprom_read *req; |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2666 | int status; |
| 2667 | |
| 2668 | spin_lock_bh(&adapter->mcc_lock); |
| 2669 | |
| 2670 | wrb = wrb_from_mccq(adapter); |
Ajit Khaparde | e45ff01 | 2011-02-04 17:18:28 +0000 | [diff] [blame] | 2671 | if (!wrb) { |
| 2672 | status = -EBUSY; |
| 2673 | goto err; |
| 2674 | } |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2675 | req = nonemb_cmd->va; |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2676 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2677 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2678 | OPCODE_COMMON_SEEPROM_READ, sizeof(*req), wrb, |
| 2679 | nonemb_cmd); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2680 | |
| 2681 | status = be_mcc_notify_wait(adapter); |
| 2682 | |
Ajit Khaparde | e45ff01 | 2011-02-04 17:18:28 +0000 | [diff] [blame] | 2683 | err: |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 2684 | spin_unlock_bh(&adapter->mcc_lock); |
| 2685 | return status; |
| 2686 | } |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2687 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 2688 | int be_cmd_get_phy_info(struct be_adapter *adapter) |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2689 | { |
| 2690 | struct be_mcc_wrb *wrb; |
| 2691 | struct be_cmd_req_get_phy_info *req; |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2692 | struct be_dma_mem cmd; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2693 | int status; |
| 2694 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 2695 | if (!be_cmd_allowed(adapter, OPCODE_COMMON_GET_PHY_DETAILS, |
| 2696 | CMD_SUBSYSTEM_COMMON)) |
| 2697 | return -EPERM; |
| 2698 | |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2699 | spin_lock_bh(&adapter->mcc_lock); |
| 2700 | |
| 2701 | wrb = wrb_from_mccq(adapter); |
| 2702 | if (!wrb) { |
| 2703 | status = -EBUSY; |
| 2704 | goto err; |
| 2705 | } |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2706 | cmd.size = sizeof(struct be_cmd_req_get_phy_info); |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2707 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2708 | if (!cmd.va) { |
| 2709 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
| 2710 | status = -ENOMEM; |
| 2711 | goto err; |
| 2712 | } |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2713 | |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2714 | req = cmd.va; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2715 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2716 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2717 | OPCODE_COMMON_GET_PHY_DETAILS, sizeof(*req), |
| 2718 | wrb, &cmd); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2719 | |
| 2720 | status = be_mcc_notify_wait(adapter); |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2721 | if (!status) { |
| 2722 | struct be_phy_info *resp_phy_info = |
| 2723 | cmd.va + sizeof(struct be_cmd_req_hdr); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2724 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 2725 | adapter->phy.phy_type = le16_to_cpu(resp_phy_info->phy_type); |
| 2726 | adapter->phy.interface_type = |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2727 | le16_to_cpu(resp_phy_info->interface_type); |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 2728 | adapter->phy.auto_speeds_supported = |
| 2729 | le16_to_cpu(resp_phy_info->auto_speeds_supported); |
| 2730 | adapter->phy.fixed_speeds_supported = |
| 2731 | le16_to_cpu(resp_phy_info->fixed_speeds_supported); |
| 2732 | adapter->phy.misc_params = |
| 2733 | le32_to_cpu(resp_phy_info->misc_params); |
Vasundhara Volam | 68cb7e4 | 2013-08-06 09:27:18 +0530 | [diff] [blame] | 2734 | |
| 2735 | if (BE2_chip(adapter)) { |
| 2736 | adapter->phy.fixed_speeds_supported = |
| 2737 | BE_SUPPORTED_SPEED_10GBPS | |
| 2738 | BE_SUPPORTED_SPEED_1GBPS; |
| 2739 | } |
Sathya Perla | 306f134 | 2011-08-02 19:57:45 +0000 | [diff] [blame] | 2740 | } |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2741 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 2742 | err: |
| 2743 | spin_unlock_bh(&adapter->mcc_lock); |
| 2744 | return status; |
| 2745 | } |
Ajit Khaparde | e1d1873 | 2010-07-23 01:52:13 +0000 | [diff] [blame] | 2746 | |
| 2747 | int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain) |
| 2748 | { |
| 2749 | struct be_mcc_wrb *wrb; |
| 2750 | struct be_cmd_req_set_qos *req; |
| 2751 | int status; |
| 2752 | |
| 2753 | spin_lock_bh(&adapter->mcc_lock); |
| 2754 | |
| 2755 | wrb = wrb_from_mccq(adapter); |
| 2756 | if (!wrb) { |
| 2757 | status = -EBUSY; |
| 2758 | goto err; |
| 2759 | } |
| 2760 | |
| 2761 | req = embedded_payload(wrb); |
| 2762 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2763 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2764 | OPCODE_COMMON_SET_QOS, sizeof(*req), wrb, NULL); |
Ajit Khaparde | e1d1873 | 2010-07-23 01:52:13 +0000 | [diff] [blame] | 2765 | |
| 2766 | req->hdr.domain = domain; |
Ajit Khaparde | 6bff57a | 2011-02-11 13:33:02 +0000 | [diff] [blame] | 2767 | req->valid_bits = cpu_to_le32(BE_QOS_BITS_NIC); |
| 2768 | req->max_bps_nic = cpu_to_le32(bps); |
Ajit Khaparde | e1d1873 | 2010-07-23 01:52:13 +0000 | [diff] [blame] | 2769 | |
| 2770 | status = be_mcc_notify_wait(adapter); |
| 2771 | |
| 2772 | err: |
| 2773 | spin_unlock_bh(&adapter->mcc_lock); |
| 2774 | return status; |
| 2775 | } |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2776 | |
| 2777 | int be_cmd_get_cntl_attributes(struct be_adapter *adapter) |
| 2778 | { |
| 2779 | struct be_mcc_wrb *wrb; |
| 2780 | struct be_cmd_req_cntl_attribs *req; |
| 2781 | struct be_cmd_resp_cntl_attribs *resp; |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2782 | int status; |
| 2783 | int payload_len = max(sizeof(*req), sizeof(*resp)); |
| 2784 | struct mgmt_controller_attrib *attribs; |
| 2785 | struct be_dma_mem attribs_cmd; |
| 2786 | |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 2787 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2788 | return -1; |
| 2789 | |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2790 | memset(&attribs_cmd, 0, sizeof(struct be_dma_mem)); |
| 2791 | attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs); |
| 2792 | attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2793 | &attribs_cmd.dma); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2794 | if (!attribs_cmd.va) { |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2795 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 2796 | status = -ENOMEM; |
| 2797 | goto err; |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2798 | } |
| 2799 | |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2800 | wrb = wrb_from_mbox(adapter); |
| 2801 | if (!wrb) { |
| 2802 | status = -EBUSY; |
| 2803 | goto err; |
| 2804 | } |
| 2805 | req = attribs_cmd.va; |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2806 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2807 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2808 | OPCODE_COMMON_GET_CNTL_ATTRIBUTES, payload_len, |
| 2809 | wrb, &attribs_cmd); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2810 | |
| 2811 | status = be_mbox_notify_wait(adapter); |
| 2812 | if (!status) { |
Joe Perches | 43d620c | 2011-06-16 19:08:06 +0000 | [diff] [blame] | 2813 | attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2814 | adapter->hba_port_num = attribs->hba_attribs.phy_port; |
| 2815 | } |
| 2816 | |
| 2817 | err: |
| 2818 | mutex_unlock(&adapter->mbox_lock); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 2819 | if (attribs_cmd.va) |
| 2820 | pci_free_consistent(adapter->pdev, attribs_cmd.size, |
| 2821 | attribs_cmd.va, attribs_cmd.dma); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 2822 | return status; |
| 2823 | } |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2824 | |
| 2825 | /* Uses mbox */ |
Sathya Perla | 2dc1deb | 2011-07-19 19:52:33 +0000 | [diff] [blame] | 2826 | int be_cmd_req_native_mode(struct be_adapter *adapter) |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2827 | { |
| 2828 | struct be_mcc_wrb *wrb; |
| 2829 | struct be_cmd_req_set_func_cap *req; |
| 2830 | int status; |
| 2831 | |
| 2832 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 2833 | return -1; |
| 2834 | |
| 2835 | wrb = wrb_from_mbox(adapter); |
| 2836 | if (!wrb) { |
| 2837 | status = -EBUSY; |
| 2838 | goto err; |
| 2839 | } |
| 2840 | |
| 2841 | req = embedded_payload(wrb); |
| 2842 | |
Somnath Kotur | 106df1e | 2011-10-27 07:12:13 +0000 | [diff] [blame] | 2843 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2844 | OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP, |
| 2845 | sizeof(*req), wrb, NULL); |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2846 | |
| 2847 | req->valid_cap_flags = cpu_to_le32(CAPABILITY_SW_TIMESTAMPS | |
| 2848 | CAPABILITY_BE3_NATIVE_ERX_API); |
| 2849 | req->cap_flags = cpu_to_le32(CAPABILITY_BE3_NATIVE_ERX_API); |
| 2850 | |
| 2851 | status = be_mbox_notify_wait(adapter); |
| 2852 | if (!status) { |
| 2853 | struct be_cmd_resp_set_func_cap *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2854 | |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2855 | adapter->be3_native = le32_to_cpu(resp->cap_flags) & |
| 2856 | CAPABILITY_BE3_NATIVE_ERX_API; |
Sathya Perla | d379142 | 2012-09-28 04:39:44 +0000 | [diff] [blame] | 2857 | if (!adapter->be3_native) |
| 2858 | dev_warn(&adapter->pdev->dev, |
| 2859 | "adapter not in advanced mode\n"); |
Sathya Perla | 2e588f8 | 2011-03-11 02:49:26 +0000 | [diff] [blame] | 2860 | } |
| 2861 | err: |
| 2862 | mutex_unlock(&adapter->mbox_lock); |
| 2863 | return status; |
| 2864 | } |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2865 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 2866 | /* Get privilege(s) for a function */ |
| 2867 | int be_cmd_get_fn_privileges(struct be_adapter *adapter, u32 *privilege, |
| 2868 | u32 domain) |
| 2869 | { |
| 2870 | struct be_mcc_wrb *wrb; |
| 2871 | struct be_cmd_req_get_fn_privileges *req; |
| 2872 | int status; |
| 2873 | |
| 2874 | spin_lock_bh(&adapter->mcc_lock); |
| 2875 | |
| 2876 | wrb = wrb_from_mccq(adapter); |
| 2877 | if (!wrb) { |
| 2878 | status = -EBUSY; |
| 2879 | goto err; |
| 2880 | } |
| 2881 | |
| 2882 | req = embedded_payload(wrb); |
| 2883 | |
| 2884 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2885 | OPCODE_COMMON_GET_FN_PRIVILEGES, sizeof(*req), |
| 2886 | wrb, NULL); |
| 2887 | |
| 2888 | req->hdr.domain = domain; |
| 2889 | |
| 2890 | status = be_mcc_notify_wait(adapter); |
| 2891 | if (!status) { |
| 2892 | struct be_cmd_resp_get_fn_privileges *resp = |
| 2893 | embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 2894 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 2895 | *privilege = le32_to_cpu(resp->privilege_mask); |
Suresh Reddy | 02308d7 | 2014-01-15 13:23:36 +0530 | [diff] [blame] | 2896 | |
| 2897 | /* In UMC mode FW does not return right privileges. |
| 2898 | * Override with correct privilege equivalent to PF. |
| 2899 | */ |
| 2900 | if (BEx_chip(adapter) && be_is_mc(adapter) && |
| 2901 | be_physfn(adapter)) |
| 2902 | *privilege = MAX_PRIVILEGES; |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 2903 | } |
| 2904 | |
| 2905 | err: |
| 2906 | spin_unlock_bh(&adapter->mcc_lock); |
| 2907 | return status; |
| 2908 | } |
| 2909 | |
Sathya Perla | 04a0602 | 2013-07-23 15:25:00 +0530 | [diff] [blame] | 2910 | /* Set privilege(s) for a function */ |
| 2911 | int be_cmd_set_fn_privileges(struct be_adapter *adapter, u32 privileges, |
| 2912 | u32 domain) |
| 2913 | { |
| 2914 | struct be_mcc_wrb *wrb; |
| 2915 | struct be_cmd_req_set_fn_privileges *req; |
| 2916 | int status; |
| 2917 | |
| 2918 | spin_lock_bh(&adapter->mcc_lock); |
| 2919 | |
| 2920 | wrb = wrb_from_mccq(adapter); |
| 2921 | if (!wrb) { |
| 2922 | status = -EBUSY; |
| 2923 | goto err; |
| 2924 | } |
| 2925 | |
| 2926 | req = embedded_payload(wrb); |
| 2927 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 2928 | OPCODE_COMMON_SET_FN_PRIVILEGES, sizeof(*req), |
| 2929 | wrb, NULL); |
| 2930 | req->hdr.domain = domain; |
| 2931 | if (lancer_chip(adapter)) |
| 2932 | req->privileges_lancer = cpu_to_le32(privileges); |
| 2933 | else |
| 2934 | req->privileges = cpu_to_le32(privileges); |
| 2935 | |
| 2936 | status = be_mcc_notify_wait(adapter); |
| 2937 | err: |
| 2938 | spin_unlock_bh(&adapter->mcc_lock); |
| 2939 | return status; |
| 2940 | } |
| 2941 | |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 2942 | /* pmac_id_valid: true => pmac_id is supplied and MAC address is requested. |
| 2943 | * pmac_id_valid: false => pmac_id or MAC address is requested. |
| 2944 | * If pmac_id is returned, pmac_id_valid is returned as true |
| 2945 | */ |
Padmanabh Ratnakar | 1578e77 | 2012-06-07 04:37:08 +0000 | [diff] [blame] | 2946 | int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac, |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 2947 | bool *pmac_id_valid, u32 *pmac_id, u32 if_handle, |
| 2948 | u8 domain) |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2949 | { |
| 2950 | struct be_mcc_wrb *wrb; |
| 2951 | struct be_cmd_req_get_mac_list *req; |
| 2952 | int status; |
| 2953 | int mac_count; |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2954 | struct be_dma_mem get_mac_list_cmd; |
| 2955 | int i; |
| 2956 | |
| 2957 | memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem)); |
| 2958 | get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list); |
| 2959 | get_mac_list_cmd.va = pci_alloc_consistent(adapter->pdev, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2960 | get_mac_list_cmd.size, |
| 2961 | &get_mac_list_cmd.dma); |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2962 | |
| 2963 | if (!get_mac_list_cmd.va) { |
| 2964 | dev_err(&adapter->pdev->dev, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 2965 | "Memory allocation failure during GET_MAC_LIST\n"); |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2966 | return -ENOMEM; |
| 2967 | } |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2968 | |
| 2969 | spin_lock_bh(&adapter->mcc_lock); |
| 2970 | |
| 2971 | wrb = wrb_from_mccq(adapter); |
| 2972 | if (!wrb) { |
| 2973 | status = -EBUSY; |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2974 | goto out; |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2975 | } |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2976 | |
| 2977 | req = get_mac_list_cmd.va; |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2978 | |
| 2979 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | bf591f5 | 2013-05-08 02:05:48 +0000 | [diff] [blame] | 2980 | OPCODE_COMMON_GET_MAC_LIST, |
| 2981 | get_mac_list_cmd.size, wrb, &get_mac_list_cmd); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2982 | req->hdr.domain = domain; |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2983 | req->mac_type = MAC_ADDRESS_TYPE_NETWORK; |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 2984 | if (*pmac_id_valid) { |
| 2985 | req->mac_id = cpu_to_le32(*pmac_id); |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 2986 | req->iface_id = cpu_to_le16(if_handle); |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 2987 | req->perm_override = 0; |
| 2988 | } else { |
| 2989 | req->perm_override = 1; |
| 2990 | } |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 2991 | |
| 2992 | status = be_mcc_notify_wait(adapter); |
| 2993 | if (!status) { |
| 2994 | struct be_cmd_resp_get_mac_list *resp = |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 2995 | get_mac_list_cmd.va; |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 2996 | |
| 2997 | if (*pmac_id_valid) { |
| 2998 | memcpy(mac, resp->macid_macaddr.mac_addr_id.macaddr, |
| 2999 | ETH_ALEN); |
| 3000 | goto out; |
| 3001 | } |
| 3002 | |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3003 | mac_count = resp->true_mac_count + resp->pseudo_mac_count; |
| 3004 | /* Mac list returned could contain one or more active mac_ids |
Padmanabh Ratnakar | 1578e77 | 2012-06-07 04:37:08 +0000 | [diff] [blame] | 3005 | * or one or more true or pseudo permanant mac addresses. |
| 3006 | * If an active mac_id is present, return first active mac_id |
| 3007 | * found. |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3008 | */ |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3009 | for (i = 0; i < mac_count; i++) { |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3010 | struct get_list_macaddr *mac_entry; |
| 3011 | u16 mac_addr_size; |
| 3012 | u32 mac_id; |
| 3013 | |
| 3014 | mac_entry = &resp->macaddr_list[i]; |
| 3015 | mac_addr_size = le16_to_cpu(mac_entry->mac_addr_size); |
| 3016 | /* mac_id is a 32 bit value and mac_addr size |
| 3017 | * is 6 bytes |
| 3018 | */ |
| 3019 | if (mac_addr_size == sizeof(u32)) { |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3020 | *pmac_id_valid = true; |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3021 | mac_id = mac_entry->mac_addr_id.s_mac_id.mac_id; |
| 3022 | *pmac_id = le32_to_cpu(mac_id); |
| 3023 | goto out; |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3024 | } |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3025 | } |
Padmanabh Ratnakar | 1578e77 | 2012-06-07 04:37:08 +0000 | [diff] [blame] | 3026 | /* If no active mac_id found, return first mac addr */ |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3027 | *pmac_id_valid = false; |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3028 | memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3029 | ETH_ALEN); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3030 | } |
| 3031 | |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3032 | out: |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3033 | spin_unlock_bh(&adapter->mcc_lock); |
Padmanabh Ratnakar | e5e1ee8 | 2012-02-03 09:50:17 +0000 | [diff] [blame] | 3034 | pci_free_consistent(adapter->pdev, get_mac_list_cmd.size, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3035 | get_mac_list_cmd.va, get_mac_list_cmd.dma); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3036 | return status; |
| 3037 | } |
| 3038 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3039 | int be_cmd_get_active_mac(struct be_adapter *adapter, u32 curr_pmac_id, |
| 3040 | u8 *mac, u32 if_handle, bool active, u32 domain) |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3041 | { |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3042 | |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 3043 | if (!active) |
| 3044 | be_cmd_get_mac_from_list(adapter, mac, &active, &curr_pmac_id, |
| 3045 | if_handle, domain); |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3046 | if (BEx_chip(adapter)) |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3047 | return be_cmd_mac_addr_query(adapter, mac, false, |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 3048 | if_handle, curr_pmac_id); |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3049 | else |
| 3050 | /* Fetch the MAC address using pmac_id */ |
| 3051 | return be_cmd_get_mac_from_list(adapter, mac, &active, |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 3052 | &curr_pmac_id, |
| 3053 | if_handle, domain); |
Sathya Perla | 5a712c1 | 2013-07-23 15:24:59 +0530 | [diff] [blame] | 3054 | } |
| 3055 | |
Sathya Perla | 95046b9 | 2013-07-23 15:25:02 +0530 | [diff] [blame] | 3056 | int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac) |
| 3057 | { |
| 3058 | int status; |
| 3059 | bool pmac_valid = false; |
| 3060 | |
| 3061 | memset(mac, 0, ETH_ALEN); |
| 3062 | |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3063 | if (BEx_chip(adapter)) { |
| 3064 | if (be_physfn(adapter)) |
| 3065 | status = be_cmd_mac_addr_query(adapter, mac, true, 0, |
| 3066 | 0); |
| 3067 | else |
| 3068 | status = be_cmd_mac_addr_query(adapter, mac, false, |
| 3069 | adapter->if_handle, 0); |
| 3070 | } else { |
Sathya Perla | 95046b9 | 2013-07-23 15:25:02 +0530 | [diff] [blame] | 3071 | status = be_cmd_get_mac_from_list(adapter, mac, &pmac_valid, |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 3072 | NULL, adapter->if_handle, 0); |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3073 | } |
| 3074 | |
Sathya Perla | 95046b9 | 2013-07-23 15:25:02 +0530 | [diff] [blame] | 3075 | return status; |
| 3076 | } |
| 3077 | |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3078 | /* Uses synchronous MCCQ */ |
| 3079 | int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, |
| 3080 | u8 mac_count, u32 domain) |
| 3081 | { |
| 3082 | struct be_mcc_wrb *wrb; |
| 3083 | struct be_cmd_req_set_mac_list *req; |
| 3084 | int status; |
| 3085 | struct be_dma_mem cmd; |
| 3086 | |
| 3087 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
| 3088 | cmd.size = sizeof(struct be_cmd_req_set_mac_list); |
| 3089 | cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3090 | &cmd.dma, GFP_KERNEL); |
Joe Perches | d0320f7 | 2013-03-14 13:07:21 +0000 | [diff] [blame] | 3091 | if (!cmd.va) |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3092 | return -ENOMEM; |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3093 | |
| 3094 | spin_lock_bh(&adapter->mcc_lock); |
| 3095 | |
| 3096 | wrb = wrb_from_mccq(adapter); |
| 3097 | if (!wrb) { |
| 3098 | status = -EBUSY; |
| 3099 | goto err; |
| 3100 | } |
| 3101 | |
| 3102 | req = cmd.va; |
| 3103 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3104 | OPCODE_COMMON_SET_MAC_LIST, sizeof(*req), |
| 3105 | wrb, &cmd); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3106 | |
| 3107 | req->hdr.domain = domain; |
| 3108 | req->mac_count = mac_count; |
| 3109 | if (mac_count) |
| 3110 | memcpy(req->mac, mac_array, ETH_ALEN*mac_count); |
| 3111 | |
| 3112 | status = be_mcc_notify_wait(adapter); |
| 3113 | |
| 3114 | err: |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3115 | dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma); |
Padmanabh Ratnakar | 590c391 | 2011-11-25 05:47:26 +0000 | [diff] [blame] | 3116 | spin_unlock_bh(&adapter->mcc_lock); |
| 3117 | return status; |
| 3118 | } |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3119 | |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3120 | /* Wrapper to delete any active MACs and provision the new mac. |
| 3121 | * Changes to MAC_LIST are allowed iff none of the MAC addresses in the |
| 3122 | * current list are active. |
| 3123 | */ |
| 3124 | int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id, u32 dom) |
| 3125 | { |
| 3126 | bool active_mac = false; |
| 3127 | u8 old_mac[ETH_ALEN]; |
| 3128 | u32 pmac_id; |
| 3129 | int status; |
| 3130 | |
| 3131 | status = be_cmd_get_mac_from_list(adapter, old_mac, &active_mac, |
Suresh Reddy | b188f09 | 2014-01-15 13:23:39 +0530 | [diff] [blame] | 3132 | &pmac_id, if_id, dom); |
| 3133 | |
Sathya Perla | 3175d8c | 2013-07-23 15:25:03 +0530 | [diff] [blame] | 3134 | if (!status && active_mac) |
| 3135 | be_cmd_pmac_del(adapter, if_id, pmac_id, dom); |
| 3136 | |
| 3137 | return be_cmd_set_mac_list(adapter, mac, mac ? 1 : 0, dom); |
| 3138 | } |
| 3139 | |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3140 | int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3141 | u32 domain, u16 intf_id, u16 hsw_mode) |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3142 | { |
| 3143 | struct be_mcc_wrb *wrb; |
| 3144 | struct be_cmd_req_set_hsw_config *req; |
| 3145 | void *ctxt; |
| 3146 | int status; |
| 3147 | |
| 3148 | spin_lock_bh(&adapter->mcc_lock); |
| 3149 | |
| 3150 | wrb = wrb_from_mccq(adapter); |
| 3151 | if (!wrb) { |
| 3152 | status = -EBUSY; |
| 3153 | goto err; |
| 3154 | } |
| 3155 | |
| 3156 | req = embedded_payload(wrb); |
| 3157 | ctxt = &req->context; |
| 3158 | |
| 3159 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3160 | OPCODE_COMMON_SET_HSW_CONFIG, sizeof(*req), wrb, |
| 3161 | NULL); |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3162 | |
| 3163 | req->hdr.domain = domain; |
| 3164 | AMAP_SET_BITS(struct amap_set_hsw_context, interface_id, ctxt, intf_id); |
| 3165 | if (pvid) { |
| 3166 | AMAP_SET_BITS(struct amap_set_hsw_context, pvid_valid, ctxt, 1); |
| 3167 | AMAP_SET_BITS(struct amap_set_hsw_context, pvid, ctxt, pvid); |
| 3168 | } |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3169 | if (!BEx_chip(adapter) && hsw_mode) { |
| 3170 | AMAP_SET_BITS(struct amap_set_hsw_context, interface_id, |
| 3171 | ctxt, adapter->hba_port_num); |
| 3172 | AMAP_SET_BITS(struct amap_set_hsw_context, pport, ctxt, 1); |
| 3173 | AMAP_SET_BITS(struct amap_set_hsw_context, port_fwd_type, |
| 3174 | ctxt, hsw_mode); |
| 3175 | } |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3176 | |
| 3177 | be_dws_cpu_to_le(req->context, sizeof(req->context)); |
| 3178 | status = be_mcc_notify_wait(adapter); |
| 3179 | |
| 3180 | err: |
| 3181 | spin_unlock_bh(&adapter->mcc_lock); |
| 3182 | return status; |
| 3183 | } |
| 3184 | |
| 3185 | /* Get Hyper switch config */ |
| 3186 | int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid, |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3187 | u32 domain, u16 intf_id, u8 *mode) |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3188 | { |
| 3189 | struct be_mcc_wrb *wrb; |
| 3190 | struct be_cmd_req_get_hsw_config *req; |
| 3191 | void *ctxt; |
| 3192 | int status; |
| 3193 | u16 vid; |
| 3194 | |
| 3195 | spin_lock_bh(&adapter->mcc_lock); |
| 3196 | |
| 3197 | wrb = wrb_from_mccq(adapter); |
| 3198 | if (!wrb) { |
| 3199 | status = -EBUSY; |
| 3200 | goto err; |
| 3201 | } |
| 3202 | |
| 3203 | req = embedded_payload(wrb); |
| 3204 | ctxt = &req->context; |
| 3205 | |
| 3206 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3207 | OPCODE_COMMON_GET_HSW_CONFIG, sizeof(*req), wrb, |
| 3208 | NULL); |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3209 | |
| 3210 | req->hdr.domain = domain; |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3211 | AMAP_SET_BITS(struct amap_get_hsw_req_context, interface_id, |
| 3212 | ctxt, intf_id); |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3213 | AMAP_SET_BITS(struct amap_get_hsw_req_context, pvid_valid, ctxt, 1); |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3214 | |
Vasundhara Volam | 2c07c1d | 2014-01-15 13:23:32 +0530 | [diff] [blame] | 3215 | if (!BEx_chip(adapter) && mode) { |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3216 | AMAP_SET_BITS(struct amap_get_hsw_req_context, interface_id, |
| 3217 | ctxt, adapter->hba_port_num); |
| 3218 | AMAP_SET_BITS(struct amap_get_hsw_req_context, pport, ctxt, 1); |
| 3219 | } |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3220 | be_dws_cpu_to_le(req->context, sizeof(req->context)); |
| 3221 | |
| 3222 | status = be_mcc_notify_wait(adapter); |
| 3223 | if (!status) { |
| 3224 | struct be_cmd_resp_get_hsw_config *resp = |
| 3225 | embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 3226 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3227 | be_dws_le_to_cpu(&resp->context, sizeof(resp->context)); |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3228 | vid = AMAP_GET_BITS(struct amap_get_hsw_resp_context, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3229 | pvid, &resp->context); |
Ajit Khaparde | a77dcb8 | 2013-08-30 15:01:16 -0500 | [diff] [blame] | 3230 | if (pvid) |
| 3231 | *pvid = le16_to_cpu(vid); |
| 3232 | if (mode) |
| 3233 | *mode = AMAP_GET_BITS(struct amap_get_hsw_resp_context, |
| 3234 | port_fwd_type, &resp->context); |
Ajit Khaparde | f1f3ee1 | 2012-03-18 06:23:41 +0000 | [diff] [blame] | 3235 | } |
| 3236 | |
| 3237 | err: |
| 3238 | spin_unlock_bh(&adapter->mcc_lock); |
| 3239 | return status; |
| 3240 | } |
| 3241 | |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3242 | int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) |
| 3243 | { |
| 3244 | struct be_mcc_wrb *wrb; |
| 3245 | struct be_cmd_req_acpi_wol_magic_config_v1 *req; |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 3246 | int status = 0; |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3247 | struct be_dma_mem cmd; |
| 3248 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 3249 | if (!be_cmd_allowed(adapter, OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, |
| 3250 | CMD_SUBSYSTEM_ETH)) |
| 3251 | return -EPERM; |
| 3252 | |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 3253 | if (be_is_wol_excluded(adapter)) |
| 3254 | return status; |
| 3255 | |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3256 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 3257 | return -1; |
| 3258 | |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3259 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
| 3260 | cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1); |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3261 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3262 | if (!cmd.va) { |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3263 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3264 | status = -ENOMEM; |
| 3265 | goto err; |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3266 | } |
| 3267 | |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3268 | wrb = wrb_from_mbox(adapter); |
| 3269 | if (!wrb) { |
| 3270 | status = -EBUSY; |
| 3271 | goto err; |
| 3272 | } |
| 3273 | |
| 3274 | req = cmd.va; |
| 3275 | |
| 3276 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
| 3277 | OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 3278 | sizeof(*req), wrb, &cmd); |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3279 | |
| 3280 | req->hdr.version = 1; |
| 3281 | req->query_options = BE_GET_WOL_CAP; |
| 3282 | |
| 3283 | status = be_mbox_notify_wait(adapter); |
| 3284 | if (!status) { |
| 3285 | struct be_cmd_resp_acpi_wol_magic_config_v1 *resp; |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 3286 | |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3287 | resp = (struct be_cmd_resp_acpi_wol_magic_config_v1 *) cmd.va; |
| 3288 | |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3289 | adapter->wol_cap = resp->wol_settings; |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 3290 | if (adapter->wol_cap & BE_WOL_CAP) |
| 3291 | adapter->wol_en = true; |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3292 | } |
| 3293 | err: |
| 3294 | mutex_unlock(&adapter->mbox_lock); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3295 | if (cmd.va) |
| 3296 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3297 | return status; |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 3298 | |
| 3299 | } |
Vasundhara Volam | baaa08d | 2014-01-15 13:23:34 +0530 | [diff] [blame] | 3300 | |
| 3301 | int be_cmd_set_fw_log_level(struct be_adapter *adapter, u32 level) |
| 3302 | { |
| 3303 | struct be_dma_mem extfat_cmd; |
| 3304 | struct be_fat_conf_params *cfgs; |
| 3305 | int status; |
| 3306 | int i, j; |
| 3307 | |
| 3308 | memset(&extfat_cmd, 0, sizeof(struct be_dma_mem)); |
| 3309 | extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps); |
| 3310 | extfat_cmd.va = pci_alloc_consistent(adapter->pdev, extfat_cmd.size, |
| 3311 | &extfat_cmd.dma); |
| 3312 | if (!extfat_cmd.va) |
| 3313 | return -ENOMEM; |
| 3314 | |
| 3315 | status = be_cmd_get_ext_fat_capabilites(adapter, &extfat_cmd); |
| 3316 | if (status) |
| 3317 | goto err; |
| 3318 | |
| 3319 | cfgs = (struct be_fat_conf_params *) |
| 3320 | (extfat_cmd.va + sizeof(struct be_cmd_resp_hdr)); |
| 3321 | for (i = 0; i < le32_to_cpu(cfgs->num_modules); i++) { |
| 3322 | u32 num_modes = le32_to_cpu(cfgs->module[i].num_modes); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 3323 | |
Vasundhara Volam | baaa08d | 2014-01-15 13:23:34 +0530 | [diff] [blame] | 3324 | for (j = 0; j < num_modes; j++) { |
| 3325 | if (cfgs->module[i].trace_lvl[j].mode == MODE_UART) |
| 3326 | cfgs->module[i].trace_lvl[j].dbg_lvl = |
| 3327 | cpu_to_le32(level); |
| 3328 | } |
| 3329 | } |
| 3330 | |
| 3331 | status = be_cmd_set_ext_fat_capabilites(adapter, &extfat_cmd, cfgs); |
| 3332 | err: |
| 3333 | pci_free_consistent(adapter->pdev, extfat_cmd.size, extfat_cmd.va, |
| 3334 | extfat_cmd.dma); |
| 3335 | return status; |
| 3336 | } |
| 3337 | |
| 3338 | int be_cmd_get_fw_log_level(struct be_adapter *adapter) |
| 3339 | { |
| 3340 | struct be_dma_mem extfat_cmd; |
| 3341 | struct be_fat_conf_params *cfgs; |
| 3342 | int status, j; |
| 3343 | int level = 0; |
| 3344 | |
| 3345 | memset(&extfat_cmd, 0, sizeof(struct be_dma_mem)); |
| 3346 | extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps); |
| 3347 | extfat_cmd.va = pci_alloc_consistent(adapter->pdev, extfat_cmd.size, |
| 3348 | &extfat_cmd.dma); |
| 3349 | |
| 3350 | if (!extfat_cmd.va) { |
| 3351 | dev_err(&adapter->pdev->dev, "%s: Memory allocation failure\n", |
| 3352 | __func__); |
| 3353 | goto err; |
| 3354 | } |
| 3355 | |
| 3356 | status = be_cmd_get_ext_fat_capabilites(adapter, &extfat_cmd); |
| 3357 | if (!status) { |
| 3358 | cfgs = (struct be_fat_conf_params *)(extfat_cmd.va + |
| 3359 | sizeof(struct be_cmd_resp_hdr)); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 3360 | |
Vasundhara Volam | baaa08d | 2014-01-15 13:23:34 +0530 | [diff] [blame] | 3361 | for (j = 0; j < le32_to_cpu(cfgs->module[0].num_modes); j++) { |
| 3362 | if (cfgs->module[0].trace_lvl[j].mode == MODE_UART) |
| 3363 | level = cfgs->module[0].trace_lvl[j].dbg_lvl; |
| 3364 | } |
| 3365 | } |
| 3366 | pci_free_consistent(adapter->pdev, extfat_cmd.size, extfat_cmd.va, |
| 3367 | extfat_cmd.dma); |
| 3368 | err: |
| 3369 | return level; |
| 3370 | } |
| 3371 | |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 3372 | int be_cmd_get_ext_fat_capabilites(struct be_adapter *adapter, |
| 3373 | struct be_dma_mem *cmd) |
| 3374 | { |
| 3375 | struct be_mcc_wrb *wrb; |
| 3376 | struct be_cmd_req_get_ext_fat_caps *req; |
| 3377 | int status; |
| 3378 | |
| 3379 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 3380 | return -1; |
| 3381 | |
| 3382 | wrb = wrb_from_mbox(adapter); |
| 3383 | if (!wrb) { |
| 3384 | status = -EBUSY; |
| 3385 | goto err; |
| 3386 | } |
| 3387 | |
| 3388 | req = cmd->va; |
| 3389 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3390 | OPCODE_COMMON_GET_EXT_FAT_CAPABILITES, |
| 3391 | cmd->size, wrb, cmd); |
| 3392 | req->parameter_type = cpu_to_le32(1); |
| 3393 | |
| 3394 | status = be_mbox_notify_wait(adapter); |
| 3395 | err: |
| 3396 | mutex_unlock(&adapter->mbox_lock); |
| 3397 | return status; |
| 3398 | } |
| 3399 | |
| 3400 | int be_cmd_set_ext_fat_capabilites(struct be_adapter *adapter, |
| 3401 | struct be_dma_mem *cmd, |
| 3402 | struct be_fat_conf_params *configs) |
| 3403 | { |
| 3404 | struct be_mcc_wrb *wrb; |
| 3405 | struct be_cmd_req_set_ext_fat_caps *req; |
| 3406 | int status; |
| 3407 | |
| 3408 | spin_lock_bh(&adapter->mcc_lock); |
| 3409 | |
| 3410 | wrb = wrb_from_mccq(adapter); |
| 3411 | if (!wrb) { |
| 3412 | status = -EBUSY; |
| 3413 | goto err; |
| 3414 | } |
| 3415 | |
| 3416 | req = cmd->va; |
| 3417 | memcpy(&req->set_params, configs, sizeof(struct be_fat_conf_params)); |
| 3418 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3419 | OPCODE_COMMON_SET_EXT_FAT_CAPABILITES, |
| 3420 | cmd->size, wrb, cmd); |
| 3421 | |
| 3422 | status = be_mcc_notify_wait(adapter); |
| 3423 | err: |
| 3424 | spin_unlock_bh(&adapter->mcc_lock); |
| 3425 | return status; |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 3426 | } |
Parav Pandit | 6a4ab66 | 2012-03-26 14:27:12 +0000 | [diff] [blame] | 3427 | |
Padmanabh Ratnakar | b4e32a7 | 2012-07-12 03:57:35 +0000 | [diff] [blame] | 3428 | int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name) |
| 3429 | { |
| 3430 | struct be_mcc_wrb *wrb; |
| 3431 | struct be_cmd_req_get_port_name *req; |
| 3432 | int status; |
| 3433 | |
| 3434 | if (!lancer_chip(adapter)) { |
| 3435 | *port_name = adapter->hba_port_num + '0'; |
| 3436 | return 0; |
| 3437 | } |
| 3438 | |
| 3439 | spin_lock_bh(&adapter->mcc_lock); |
| 3440 | |
| 3441 | wrb = wrb_from_mccq(adapter); |
| 3442 | if (!wrb) { |
| 3443 | status = -EBUSY; |
| 3444 | goto err; |
| 3445 | } |
| 3446 | |
| 3447 | req = embedded_payload(wrb); |
| 3448 | |
| 3449 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3450 | OPCODE_COMMON_GET_PORT_NAME, sizeof(*req), wrb, |
| 3451 | NULL); |
| 3452 | req->hdr.version = 1; |
| 3453 | |
| 3454 | status = be_mcc_notify_wait(adapter); |
| 3455 | if (!status) { |
| 3456 | struct be_cmd_resp_get_port_name *resp = embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 3457 | |
Padmanabh Ratnakar | b4e32a7 | 2012-07-12 03:57:35 +0000 | [diff] [blame] | 3458 | *port_name = resp->port_name[adapter->hba_port_num]; |
| 3459 | } else { |
| 3460 | *port_name = adapter->hba_port_num + '0'; |
| 3461 | } |
| 3462 | err: |
| 3463 | spin_unlock_bh(&adapter->mcc_lock); |
| 3464 | return status; |
| 3465 | } |
| 3466 | |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3467 | /* Descriptor type */ |
| 3468 | enum { |
| 3469 | FUNC_DESC = 1, |
| 3470 | VFT_DESC = 2 |
| 3471 | }; |
| 3472 | |
| 3473 | static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count, |
| 3474 | int desc_type) |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3475 | { |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3476 | struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf; |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3477 | struct be_nic_res_desc *nic; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3478 | int i; |
| 3479 | |
| 3480 | for (i = 0; i < desc_count; i++) { |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3481 | if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 || |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3482 | hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1) { |
| 3483 | nic = (struct be_nic_res_desc *)hdr; |
| 3484 | if (desc_type == FUNC_DESC || |
| 3485 | (desc_type == VFT_DESC && |
| 3486 | nic->flags & (1 << VFT_SHIFT))) |
| 3487 | return nic; |
| 3488 | } |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3489 | |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3490 | hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0; |
| 3491 | hdr = (void *)hdr + hdr->desc_len; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3492 | } |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3493 | return NULL; |
| 3494 | } |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3495 | |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3496 | static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count) |
| 3497 | { |
| 3498 | return be_get_nic_desc(buf, desc_count, VFT_DESC); |
| 3499 | } |
| 3500 | |
| 3501 | static struct be_nic_res_desc *be_get_func_nic_desc(u8 *buf, u32 desc_count) |
| 3502 | { |
| 3503 | return be_get_nic_desc(buf, desc_count, FUNC_DESC); |
| 3504 | } |
| 3505 | |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3506 | static struct be_pcie_res_desc *be_get_pcie_desc(u8 devfn, u8 *buf, |
| 3507 | u32 desc_count) |
| 3508 | { |
| 3509 | struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf; |
| 3510 | struct be_pcie_res_desc *pcie; |
| 3511 | int i; |
| 3512 | |
| 3513 | for (i = 0; i < desc_count; i++) { |
| 3514 | if ((hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V0 || |
| 3515 | hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V1)) { |
| 3516 | pcie = (struct be_pcie_res_desc *)hdr; |
| 3517 | if (pcie->pf_num == devfn) |
| 3518 | return pcie; |
| 3519 | } |
| 3520 | |
| 3521 | hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0; |
| 3522 | hdr = (void *)hdr + hdr->desc_len; |
| 3523 | } |
Wei Yang | 950e295 | 2013-05-22 15:58:22 +0000 | [diff] [blame] | 3524 | return NULL; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3525 | } |
| 3526 | |
Vasundhara Volam | f93f160 | 2014-02-12 16:09:25 +0530 | [diff] [blame] | 3527 | static struct be_port_res_desc *be_get_port_desc(u8 *buf, u32 desc_count) |
| 3528 | { |
| 3529 | struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf; |
| 3530 | int i; |
| 3531 | |
| 3532 | for (i = 0; i < desc_count; i++) { |
| 3533 | if (hdr->desc_type == PORT_RESOURCE_DESC_TYPE_V1) |
| 3534 | return (struct be_port_res_desc *)hdr; |
| 3535 | |
| 3536 | hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0; |
| 3537 | hdr = (void *)hdr + hdr->desc_len; |
| 3538 | } |
| 3539 | return NULL; |
| 3540 | } |
| 3541 | |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3542 | static void be_copy_nic_desc(struct be_resources *res, |
| 3543 | struct be_nic_res_desc *desc) |
| 3544 | { |
| 3545 | res->max_uc_mac = le16_to_cpu(desc->unicast_mac_count); |
| 3546 | res->max_vlans = le16_to_cpu(desc->vlan_count); |
| 3547 | res->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count); |
| 3548 | res->max_tx_qs = le16_to_cpu(desc->txq_count); |
| 3549 | res->max_rss_qs = le16_to_cpu(desc->rssq_count); |
| 3550 | res->max_rx_qs = le16_to_cpu(desc->rq_count); |
| 3551 | res->max_evt_qs = le16_to_cpu(desc->eq_count); |
| 3552 | /* Clear flags that driver is not interested in */ |
| 3553 | res->if_cap_flags = le32_to_cpu(desc->cap_flags) & |
| 3554 | BE_IF_CAP_FLAGS_WANT; |
| 3555 | /* Need 1 RXQ as the default RXQ */ |
| 3556 | if (res->max_rss_qs && res->max_rss_qs == res->max_rx_qs) |
| 3557 | res->max_rss_qs -= 1; |
| 3558 | } |
| 3559 | |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3560 | /* Uses Mbox */ |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3561 | int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res) |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3562 | { |
| 3563 | struct be_mcc_wrb *wrb; |
| 3564 | struct be_cmd_req_get_func_config *req; |
| 3565 | int status; |
| 3566 | struct be_dma_mem cmd; |
| 3567 | |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3568 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 3569 | return -1; |
| 3570 | |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3571 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
| 3572 | cmd.size = sizeof(struct be_cmd_resp_get_func_config); |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3573 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3574 | if (!cmd.va) { |
| 3575 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3576 | status = -ENOMEM; |
| 3577 | goto err; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3578 | } |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3579 | |
| 3580 | wrb = wrb_from_mbox(adapter); |
| 3581 | if (!wrb) { |
| 3582 | status = -EBUSY; |
| 3583 | goto err; |
| 3584 | } |
| 3585 | |
| 3586 | req = cmd.va; |
| 3587 | |
| 3588 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3589 | OPCODE_COMMON_GET_FUNC_CONFIG, |
| 3590 | cmd.size, wrb, &cmd); |
| 3591 | |
Kalesh AP | 28710c5 | 2013-04-28 22:21:13 +0000 | [diff] [blame] | 3592 | if (skyhawk_chip(adapter)) |
| 3593 | req->hdr.version = 1; |
| 3594 | |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3595 | status = be_mbox_notify_wait(adapter); |
| 3596 | if (!status) { |
| 3597 | struct be_cmd_resp_get_func_config *resp = cmd.va; |
| 3598 | u32 desc_count = le32_to_cpu(resp->desc_count); |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3599 | struct be_nic_res_desc *desc; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3600 | |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3601 | desc = be_get_func_nic_desc(resp->func_param, desc_count); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3602 | if (!desc) { |
| 3603 | status = -EINVAL; |
| 3604 | goto err; |
| 3605 | } |
| 3606 | |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3607 | adapter->pf_number = desc->pf_num; |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3608 | be_copy_nic_desc(res, desc); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3609 | } |
| 3610 | err: |
| 3611 | mutex_unlock(&adapter->mbox_lock); |
Suresh Reddy | d98ef50 | 2013-04-25 00:56:55 +0000 | [diff] [blame] | 3612 | if (cmd.va) |
| 3613 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3614 | return status; |
| 3615 | } |
| 3616 | |
Vasundhara Volam | ba48c0c | 2014-06-30 13:01:30 +0530 | [diff] [blame] | 3617 | /* Will use MBOX only if MCCQ has not been created */ |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3618 | int be_cmd_get_profile_config(struct be_adapter *adapter, |
| 3619 | struct be_resources *res, u8 domain) |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3620 | { |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3621 | struct be_cmd_resp_get_profile_config *resp; |
Vasundhara Volam | ba48c0c | 2014-06-30 13:01:30 +0530 | [diff] [blame] | 3622 | struct be_cmd_req_get_profile_config *req; |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3623 | struct be_nic_res_desc *vf_res; |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3624 | struct be_pcie_res_desc *pcie; |
Vasundhara Volam | f93f160 | 2014-02-12 16:09:25 +0530 | [diff] [blame] | 3625 | struct be_port_res_desc *port; |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3626 | struct be_nic_res_desc *nic; |
Vasundhara Volam | ba48c0c | 2014-06-30 13:01:30 +0530 | [diff] [blame] | 3627 | struct be_mcc_wrb wrb = {0}; |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3628 | struct be_dma_mem cmd; |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3629 | u32 desc_count; |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3630 | int status; |
| 3631 | |
| 3632 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3633 | cmd.size = sizeof(struct be_cmd_resp_get_profile_config); |
| 3634 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
| 3635 | if (!cmd.va) |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3636 | return -ENOMEM; |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3637 | |
Vasundhara Volam | ba48c0c | 2014-06-30 13:01:30 +0530 | [diff] [blame] | 3638 | req = cmd.va; |
| 3639 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3640 | OPCODE_COMMON_GET_PROFILE_CONFIG, |
| 3641 | cmd.size, &wrb, &cmd); |
| 3642 | |
| 3643 | req->hdr.domain = domain; |
| 3644 | if (!lancer_chip(adapter)) |
| 3645 | req->hdr.version = 1; |
| 3646 | req->type = ACTIVE_PROFILE_TYPE; |
| 3647 | |
| 3648 | status = be_cmd_notify_wait(adapter, &wrb); |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3649 | if (status) |
| 3650 | goto err; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3651 | |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3652 | resp = cmd.va; |
| 3653 | desc_count = le32_to_cpu(resp->desc_count); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3654 | |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 3655 | pcie = be_get_pcie_desc(adapter->pdev->devfn, resp->func_param, |
| 3656 | desc_count); |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3657 | if (pcie) |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3658 | res->max_vfs = le16_to_cpu(pcie->num_vfs); |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3659 | |
Vasundhara Volam | f93f160 | 2014-02-12 16:09:25 +0530 | [diff] [blame] | 3660 | port = be_get_port_desc(resp->func_param, desc_count); |
| 3661 | if (port) |
| 3662 | adapter->mc_type = port->mc_type; |
| 3663 | |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3664 | nic = be_get_func_nic_desc(resp->func_param, desc_count); |
Sathya Perla | 92bf14a | 2013-08-27 16:57:32 +0530 | [diff] [blame] | 3665 | if (nic) |
| 3666 | be_copy_nic_desc(res, nic); |
| 3667 | |
Vasundhara Volam | 10cccf6 | 2014-06-30 13:01:31 +0530 | [diff] [blame] | 3668 | vf_res = be_get_vft_desc(resp->func_param, desc_count); |
| 3669 | if (vf_res) |
| 3670 | res->vf_if_cap_flags = vf_res->cap_flags; |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3671 | err: |
Vasundhara Volam | a05f99d | 2013-04-21 23:28:17 +0000 | [diff] [blame] | 3672 | if (cmd.va) |
Vasundhara Volam | 150d58c | 2013-08-27 16:57:31 +0530 | [diff] [blame] | 3673 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
Padmanabh Ratnakar | abb9395 | 2012-10-20 06:01:41 +0000 | [diff] [blame] | 3674 | return status; |
| 3675 | } |
| 3676 | |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3677 | /* Will use MBOX only if MCCQ has not been created */ |
| 3678 | static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc, |
| 3679 | int size, int count, u8 version, u8 domain) |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3680 | { |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3681 | struct be_cmd_req_set_profile_config *req; |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3682 | struct be_mcc_wrb wrb = {0}; |
| 3683 | struct be_dma_mem cmd; |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3684 | int status; |
| 3685 | |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3686 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
| 3687 | cmd.size = sizeof(struct be_cmd_req_set_profile_config); |
| 3688 | cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma); |
| 3689 | if (!cmd.va) |
| 3690 | return -ENOMEM; |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3691 | |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3692 | req = cmd.va; |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3693 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3694 | OPCODE_COMMON_SET_PROFILE_CONFIG, cmd.size, |
| 3695 | &wrb, &cmd); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3696 | req->hdr.version = version; |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3697 | req->hdr.domain = domain; |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3698 | req->desc_count = cpu_to_le32(count); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3699 | memcpy(req->desc, desc, size); |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3700 | |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3701 | status = be_cmd_notify_wait(adapter, &wrb); |
| 3702 | |
| 3703 | if (cmd.va) |
| 3704 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); |
Padmanabh Ratnakar | d5c1847 | 2012-10-20 06:01:53 +0000 | [diff] [blame] | 3705 | return status; |
| 3706 | } |
| 3707 | |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3708 | /* Mark all fields invalid */ |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3709 | static void be_reset_nic_desc(struct be_nic_res_desc *nic) |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3710 | { |
| 3711 | memset(nic, 0, sizeof(*nic)); |
| 3712 | nic->unicast_mac_count = 0xFFFF; |
| 3713 | nic->mcc_count = 0xFFFF; |
| 3714 | nic->vlan_count = 0xFFFF; |
| 3715 | nic->mcast_mac_count = 0xFFFF; |
| 3716 | nic->txq_count = 0xFFFF; |
| 3717 | nic->rq_count = 0xFFFF; |
| 3718 | nic->rssq_count = 0xFFFF; |
| 3719 | nic->lro_count = 0xFFFF; |
| 3720 | nic->cq_count = 0xFFFF; |
| 3721 | nic->toe_conn_count = 0xFFFF; |
| 3722 | nic->eq_count = 0xFFFF; |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3723 | nic->iface_count = 0xFFFF; |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3724 | nic->link_param = 0xFF; |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3725 | nic->channel_id_param = cpu_to_le16(0xF000); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3726 | nic->acpi_params = 0xFF; |
| 3727 | nic->wol_param = 0x0F; |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3728 | nic->tunnel_iface_count = 0xFFFF; |
| 3729 | nic->direct_tenant_iface_count = 0xFFFF; |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3730 | nic->bw_min = 0xFFFFFFFF; |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3731 | nic->bw_max = 0xFFFFFFFF; |
| 3732 | } |
| 3733 | |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3734 | /* Mark all fields invalid */ |
| 3735 | static void be_reset_pcie_desc(struct be_pcie_res_desc *pcie) |
| 3736 | { |
| 3737 | memset(pcie, 0, sizeof(*pcie)); |
| 3738 | pcie->sriov_state = 0xFF; |
| 3739 | pcie->pf_state = 0xFF; |
| 3740 | pcie->pf_type = 0xFF; |
| 3741 | pcie->num_vfs = 0xFFFF; |
| 3742 | } |
| 3743 | |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3744 | int be_cmd_config_qos(struct be_adapter *adapter, u32 max_rate, u16 link_speed, |
| 3745 | u8 domain) |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3746 | { |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3747 | struct be_nic_res_desc nic_desc; |
| 3748 | u32 bw_percent; |
| 3749 | u16 version = 0; |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3750 | |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3751 | if (BE3_chip(adapter)) |
| 3752 | return be_cmd_set_qos(adapter, max_rate / 10, domain); |
| 3753 | |
| 3754 | be_reset_nic_desc(&nic_desc); |
| 3755 | nic_desc.pf_num = adapter->pf_number; |
| 3756 | nic_desc.vf_num = domain; |
| 3757 | if (lancer_chip(adapter)) { |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3758 | nic_desc.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V0; |
| 3759 | nic_desc.hdr.desc_len = RESOURCE_DESC_SIZE_V0; |
| 3760 | nic_desc.flags = (1 << QUN_SHIFT) | (1 << IMM_SHIFT) | |
| 3761 | (1 << NOSV_SHIFT); |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3762 | nic_desc.bw_max = cpu_to_le32(max_rate / 10); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3763 | } else { |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3764 | version = 1; |
| 3765 | nic_desc.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V1; |
| 3766 | nic_desc.hdr.desc_len = RESOURCE_DESC_SIZE_V1; |
| 3767 | nic_desc.flags = (1 << IMM_SHIFT) | (1 << NOSV_SHIFT); |
| 3768 | bw_percent = max_rate ? (max_rate * 100) / link_speed : 100; |
| 3769 | nic_desc.bw_max = cpu_to_le32(bw_percent); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3770 | } |
Ravikumar Nelavelli | 0f77ba7 | 2014-05-30 19:06:24 +0530 | [diff] [blame] | 3771 | |
| 3772 | return be_cmd_set_profile_config(adapter, &nic_desc, |
| 3773 | nic_desc.hdr.desc_len, |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3774 | 1, version, domain); |
| 3775 | } |
| 3776 | |
| 3777 | int be_cmd_set_sriov_config(struct be_adapter *adapter, |
| 3778 | struct be_resources res, u16 num_vfs) |
| 3779 | { |
| 3780 | struct { |
| 3781 | struct be_pcie_res_desc pcie; |
| 3782 | struct be_nic_res_desc nic_vft; |
| 3783 | } __packed desc; |
| 3784 | u16 vf_q_count; |
| 3785 | |
| 3786 | if (BEx_chip(adapter) || lancer_chip(adapter)) |
| 3787 | return 0; |
| 3788 | |
| 3789 | /* PF PCIE descriptor */ |
| 3790 | be_reset_pcie_desc(&desc.pcie); |
| 3791 | desc.pcie.hdr.desc_type = PCIE_RESOURCE_DESC_TYPE_V1; |
| 3792 | desc.pcie.hdr.desc_len = RESOURCE_DESC_SIZE_V1; |
| 3793 | desc.pcie.flags = (1 << IMM_SHIFT) | (1 << NOSV_SHIFT); |
| 3794 | desc.pcie.pf_num = adapter->pdev->devfn; |
| 3795 | desc.pcie.sriov_state = num_vfs ? 1 : 0; |
| 3796 | desc.pcie.num_vfs = cpu_to_le16(num_vfs); |
| 3797 | |
| 3798 | /* VF NIC Template descriptor */ |
| 3799 | be_reset_nic_desc(&desc.nic_vft); |
| 3800 | desc.nic_vft.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V1; |
| 3801 | desc.nic_vft.hdr.desc_len = RESOURCE_DESC_SIZE_V1; |
| 3802 | desc.nic_vft.flags = (1 << VFT_SHIFT) | (1 << IMM_SHIFT) | |
| 3803 | (1 << NOSV_SHIFT); |
| 3804 | desc.nic_vft.pf_num = adapter->pdev->devfn; |
| 3805 | desc.nic_vft.vf_num = 0; |
| 3806 | |
| 3807 | if (num_vfs && res.vf_if_cap_flags & BE_IF_FLAGS_RSS) { |
| 3808 | /* If number of VFs requested is 8 less than max supported, |
| 3809 | * assign 8 queue pairs to the PF and divide the remaining |
| 3810 | * resources evenly among the VFs |
| 3811 | */ |
| 3812 | if (num_vfs < (be_max_vfs(adapter) - 8)) |
| 3813 | vf_q_count = (res.max_rss_qs - 8) / num_vfs; |
| 3814 | else |
| 3815 | vf_q_count = res.max_rss_qs / num_vfs; |
| 3816 | |
| 3817 | desc.nic_vft.rq_count = cpu_to_le16(vf_q_count); |
| 3818 | desc.nic_vft.txq_count = cpu_to_le16(vf_q_count); |
| 3819 | desc.nic_vft.rssq_count = cpu_to_le16(vf_q_count - 1); |
| 3820 | desc.nic_vft.cq_count = cpu_to_le16(3 * vf_q_count); |
| 3821 | } else { |
| 3822 | desc.nic_vft.txq_count = cpu_to_le16(1); |
| 3823 | desc.nic_vft.rq_count = cpu_to_le16(1); |
| 3824 | desc.nic_vft.rssq_count = cpu_to_le16(0); |
| 3825 | /* One CQ for each TX, RX and MCCQ */ |
| 3826 | desc.nic_vft.cq_count = cpu_to_le16(3); |
| 3827 | } |
| 3828 | |
| 3829 | return be_cmd_set_profile_config(adapter, &desc, |
| 3830 | 2 * RESOURCE_DESC_SIZE_V1, 2, 1, 0); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3831 | } |
| 3832 | |
| 3833 | int be_cmd_manage_iface(struct be_adapter *adapter, u32 iface, u8 op) |
| 3834 | { |
| 3835 | struct be_mcc_wrb *wrb; |
| 3836 | struct be_cmd_req_manage_iface_filters *req; |
| 3837 | int status; |
| 3838 | |
| 3839 | if (iface == 0xFFFFFFFF) |
| 3840 | return -1; |
| 3841 | |
| 3842 | spin_lock_bh(&adapter->mcc_lock); |
| 3843 | |
| 3844 | wrb = wrb_from_mccq(adapter); |
| 3845 | if (!wrb) { |
| 3846 | status = -EBUSY; |
| 3847 | goto err; |
| 3848 | } |
| 3849 | req = embedded_payload(wrb); |
| 3850 | |
| 3851 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3852 | OPCODE_COMMON_MANAGE_IFACE_FILTERS, sizeof(*req), |
| 3853 | wrb, NULL); |
| 3854 | req->op = op; |
| 3855 | req->target_iface_id = cpu_to_le32(iface); |
| 3856 | |
| 3857 | status = be_mcc_notify_wait(adapter); |
| 3858 | err: |
| 3859 | spin_unlock_bh(&adapter->mcc_lock); |
| 3860 | return status; |
| 3861 | } |
| 3862 | |
| 3863 | int be_cmd_set_vxlan_port(struct be_adapter *adapter, __be16 port) |
| 3864 | { |
| 3865 | struct be_port_res_desc port_desc; |
| 3866 | |
| 3867 | memset(&port_desc, 0, sizeof(port_desc)); |
| 3868 | port_desc.hdr.desc_type = PORT_RESOURCE_DESC_TYPE_V1; |
| 3869 | port_desc.hdr.desc_len = RESOURCE_DESC_SIZE_V1; |
| 3870 | port_desc.flags = (1 << IMM_SHIFT) | (1 << NOSV_SHIFT); |
| 3871 | port_desc.link_num = adapter->hba_port_num; |
| 3872 | if (port) { |
| 3873 | port_desc.nv_flags = NV_TYPE_VXLAN | (1 << SOCVID_SHIFT) | |
| 3874 | (1 << RCVID_SHIFT); |
| 3875 | port_desc.nv_port = swab16(port); |
| 3876 | } else { |
| 3877 | port_desc.nv_flags = NV_TYPE_DISABLED; |
| 3878 | port_desc.nv_port = 0; |
| 3879 | } |
| 3880 | |
| 3881 | return be_cmd_set_profile_config(adapter, &port_desc, |
Vasundhara Volam | bec84e6 | 2014-06-30 13:01:32 +0530 | [diff] [blame] | 3882 | RESOURCE_DESC_SIZE_V1, 1, 1, 0); |
Sathya Perla | a401801 | 2014-03-27 10:46:18 +0530 | [diff] [blame] | 3883 | } |
| 3884 | |
Sathya Perla | 4c87661 | 2013-02-03 20:30:11 +0000 | [diff] [blame] | 3885 | int be_cmd_get_if_id(struct be_adapter *adapter, struct be_vf_cfg *vf_cfg, |
| 3886 | int vf_num) |
| 3887 | { |
| 3888 | struct be_mcc_wrb *wrb; |
| 3889 | struct be_cmd_req_get_iface_list *req; |
| 3890 | struct be_cmd_resp_get_iface_list *resp; |
| 3891 | int status; |
| 3892 | |
| 3893 | spin_lock_bh(&adapter->mcc_lock); |
| 3894 | |
| 3895 | wrb = wrb_from_mccq(adapter); |
| 3896 | if (!wrb) { |
| 3897 | status = -EBUSY; |
| 3898 | goto err; |
| 3899 | } |
| 3900 | req = embedded_payload(wrb); |
| 3901 | |
| 3902 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 3903 | OPCODE_COMMON_GET_IFACE_LIST, sizeof(*resp), |
| 3904 | wrb, NULL); |
| 3905 | req->hdr.domain = vf_num + 1; |
| 3906 | |
| 3907 | status = be_mcc_notify_wait(adapter); |
| 3908 | if (!status) { |
| 3909 | resp = (struct be_cmd_resp_get_iface_list *)req; |
| 3910 | vf_cfg->if_handle = le32_to_cpu(resp->if_desc.if_id); |
| 3911 | } |
| 3912 | |
| 3913 | err: |
| 3914 | spin_unlock_bh(&adapter->mcc_lock); |
| 3915 | return status; |
| 3916 | } |
| 3917 | |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 3918 | static int lancer_wait_idle(struct be_adapter *adapter) |
| 3919 | { |
| 3920 | #define SLIPORT_IDLE_TIMEOUT 30 |
| 3921 | u32 reg_val; |
| 3922 | int status = 0, i; |
| 3923 | |
| 3924 | for (i = 0; i < SLIPORT_IDLE_TIMEOUT; i++) { |
| 3925 | reg_val = ioread32(adapter->db + PHYSDEV_CONTROL_OFFSET); |
| 3926 | if ((reg_val & PHYSDEV_CONTROL_INP_MASK) == 0) |
| 3927 | break; |
| 3928 | |
| 3929 | ssleep(1); |
| 3930 | } |
| 3931 | |
| 3932 | if (i == SLIPORT_IDLE_TIMEOUT) |
| 3933 | status = -1; |
| 3934 | |
| 3935 | return status; |
| 3936 | } |
| 3937 | |
| 3938 | int lancer_physdev_ctrl(struct be_adapter *adapter, u32 mask) |
| 3939 | { |
| 3940 | int status = 0; |
| 3941 | |
| 3942 | status = lancer_wait_idle(adapter); |
| 3943 | if (status) |
| 3944 | return status; |
| 3945 | |
| 3946 | iowrite32(mask, adapter->db + PHYSDEV_CONTROL_OFFSET); |
| 3947 | |
| 3948 | return status; |
| 3949 | } |
| 3950 | |
| 3951 | /* Routine to check whether dump image is present or not */ |
| 3952 | bool dump_present(struct be_adapter *adapter) |
| 3953 | { |
| 3954 | u32 sliport_status = 0; |
| 3955 | |
| 3956 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
| 3957 | return !!(sliport_status & SLIPORT_STATUS_DIP_MASK); |
| 3958 | } |
| 3959 | |
| 3960 | int lancer_initiate_dump(struct be_adapter *adapter) |
| 3961 | { |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 3962 | struct device *dev = &adapter->pdev->dev; |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 3963 | int status; |
| 3964 | |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 3965 | if (dump_present(adapter)) { |
| 3966 | dev_info(dev, "Previous dump not cleared, not forcing dump\n"); |
| 3967 | return -EEXIST; |
| 3968 | } |
| 3969 | |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 3970 | /* give firmware reset and diagnostic dump */ |
| 3971 | status = lancer_physdev_ctrl(adapter, PHYSDEV_CONTROL_FW_RESET_MASK | |
| 3972 | PHYSDEV_CONTROL_DD_MASK); |
| 3973 | if (status < 0) { |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 3974 | dev_err(dev, "FW reset failed\n"); |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 3975 | return status; |
| 3976 | } |
| 3977 | |
| 3978 | status = lancer_wait_idle(adapter); |
| 3979 | if (status) |
| 3980 | return status; |
| 3981 | |
| 3982 | if (!dump_present(adapter)) { |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 3983 | dev_err(dev, "FW dump not generated\n"); |
| 3984 | return -EIO; |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 3985 | } |
| 3986 | |
| 3987 | return 0; |
| 3988 | } |
| 3989 | |
Kalesh AP | f061338 | 2014-08-01 17:47:32 +0530 | [diff] [blame] | 3990 | int lancer_delete_dump(struct be_adapter *adapter) |
| 3991 | { |
| 3992 | int status; |
| 3993 | |
| 3994 | status = lancer_cmd_delete_object(adapter, LANCER_FW_DUMP_FILE); |
| 3995 | return be_cmd_status(status); |
| 3996 | } |
| 3997 | |
Padmanabh Ratnakar | dcf7ebb | 2012-10-20 06:03:49 +0000 | [diff] [blame] | 3998 | /* Uses sync mcc */ |
| 3999 | int be_cmd_enable_vf(struct be_adapter *adapter, u8 domain) |
| 4000 | { |
| 4001 | struct be_mcc_wrb *wrb; |
| 4002 | struct be_cmd_enable_disable_vf *req; |
| 4003 | int status; |
| 4004 | |
Vasundhara Volam | 0599863 | 2013-10-01 15:59:59 +0530 | [diff] [blame] | 4005 | if (BEx_chip(adapter)) |
Padmanabh Ratnakar | dcf7ebb | 2012-10-20 06:03:49 +0000 | [diff] [blame] | 4006 | return 0; |
| 4007 | |
| 4008 | spin_lock_bh(&adapter->mcc_lock); |
| 4009 | |
| 4010 | wrb = wrb_from_mccq(adapter); |
| 4011 | if (!wrb) { |
| 4012 | status = -EBUSY; |
| 4013 | goto err; |
| 4014 | } |
| 4015 | |
| 4016 | req = embedded_payload(wrb); |
| 4017 | |
| 4018 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 4019 | OPCODE_COMMON_ENABLE_DISABLE_VF, sizeof(*req), |
| 4020 | wrb, NULL); |
| 4021 | |
| 4022 | req->hdr.domain = domain; |
| 4023 | req->enable = 1; |
| 4024 | status = be_mcc_notify_wait(adapter); |
| 4025 | err: |
| 4026 | spin_unlock_bh(&adapter->mcc_lock); |
| 4027 | return status; |
| 4028 | } |
| 4029 | |
Somnath Kotur | 68c45a2 | 2013-03-14 02:42:07 +0000 | [diff] [blame] | 4030 | int be_cmd_intr_set(struct be_adapter *adapter, bool intr_enable) |
| 4031 | { |
| 4032 | struct be_mcc_wrb *wrb; |
| 4033 | struct be_cmd_req_intr_set *req; |
| 4034 | int status; |
| 4035 | |
| 4036 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 4037 | return -1; |
| 4038 | |
| 4039 | wrb = wrb_from_mbox(adapter); |
| 4040 | |
| 4041 | req = embedded_payload(wrb); |
| 4042 | |
| 4043 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 4044 | OPCODE_COMMON_SET_INTERRUPT_ENABLE, sizeof(*req), |
| 4045 | wrb, NULL); |
| 4046 | |
| 4047 | req->intr_enabled = intr_enable; |
| 4048 | |
| 4049 | status = be_mbox_notify_wait(adapter); |
| 4050 | |
| 4051 | mutex_unlock(&adapter->mbox_lock); |
| 4052 | return status; |
| 4053 | } |
| 4054 | |
Vasundhara Volam | 542963b | 2014-01-15 13:23:33 +0530 | [diff] [blame] | 4055 | /* Uses MBOX */ |
| 4056 | int be_cmd_get_active_profile(struct be_adapter *adapter, u16 *profile_id) |
| 4057 | { |
| 4058 | struct be_cmd_req_get_active_profile *req; |
| 4059 | struct be_mcc_wrb *wrb; |
| 4060 | int status; |
| 4061 | |
| 4062 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
| 4063 | return -1; |
| 4064 | |
| 4065 | wrb = wrb_from_mbox(adapter); |
| 4066 | if (!wrb) { |
| 4067 | status = -EBUSY; |
| 4068 | goto err; |
| 4069 | } |
| 4070 | |
| 4071 | req = embedded_payload(wrb); |
| 4072 | |
| 4073 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 4074 | OPCODE_COMMON_GET_ACTIVE_PROFILE, sizeof(*req), |
| 4075 | wrb, NULL); |
| 4076 | |
| 4077 | status = be_mbox_notify_wait(adapter); |
| 4078 | if (!status) { |
| 4079 | struct be_cmd_resp_get_active_profile *resp = |
| 4080 | embedded_payload(wrb); |
Kalesh AP | 03d28ff | 2014-09-19 15:46:56 +0530 | [diff] [blame^] | 4081 | |
Vasundhara Volam | 542963b | 2014-01-15 13:23:33 +0530 | [diff] [blame] | 4082 | *profile_id = le16_to_cpu(resp->active_profile_id); |
| 4083 | } |
| 4084 | |
| 4085 | err: |
| 4086 | mutex_unlock(&adapter->mbox_lock); |
| 4087 | return status; |
| 4088 | } |
| 4089 | |
Suresh Reddy | bdce2ad | 2014-03-11 18:53:04 +0530 | [diff] [blame] | 4090 | int be_cmd_set_logical_link_config(struct be_adapter *adapter, |
| 4091 | int link_state, u8 domain) |
| 4092 | { |
| 4093 | struct be_mcc_wrb *wrb; |
| 4094 | struct be_cmd_req_set_ll_link *req; |
| 4095 | int status; |
| 4096 | |
| 4097 | if (BEx_chip(adapter) || lancer_chip(adapter)) |
| 4098 | return 0; |
| 4099 | |
| 4100 | spin_lock_bh(&adapter->mcc_lock); |
| 4101 | |
| 4102 | wrb = wrb_from_mccq(adapter); |
| 4103 | if (!wrb) { |
| 4104 | status = -EBUSY; |
| 4105 | goto err; |
| 4106 | } |
| 4107 | |
| 4108 | req = embedded_payload(wrb); |
| 4109 | |
| 4110 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 4111 | OPCODE_COMMON_SET_LOGICAL_LINK_CONFIG, |
| 4112 | sizeof(*req), wrb, NULL); |
| 4113 | |
| 4114 | req->hdr.version = 1; |
| 4115 | req->hdr.domain = domain; |
| 4116 | |
| 4117 | if (link_state == IFLA_VF_LINK_STATE_ENABLE) |
| 4118 | req->link_config |= 1; |
| 4119 | |
| 4120 | if (link_state == IFLA_VF_LINK_STATE_AUTO) |
| 4121 | req->link_config |= 1 << PLINK_TRACK_SHIFT; |
| 4122 | |
| 4123 | status = be_mcc_notify_wait(adapter); |
| 4124 | err: |
| 4125 | spin_unlock_bh(&adapter->mcc_lock); |
| 4126 | return status; |
| 4127 | } |
| 4128 | |
Parav Pandit | 6a4ab66 | 2012-03-26 14:27:12 +0000 | [diff] [blame] | 4129 | int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload, |
Sathya Perla | a2cc4e0 | 2014-05-09 13:29:14 +0530 | [diff] [blame] | 4130 | int wrb_payload_size, u16 *cmd_status, u16 *ext_status) |
Parav Pandit | 6a4ab66 | 2012-03-26 14:27:12 +0000 | [diff] [blame] | 4131 | { |
| 4132 | struct be_adapter *adapter = netdev_priv(netdev_handle); |
| 4133 | struct be_mcc_wrb *wrb; |
| 4134 | struct be_cmd_req_hdr *hdr = (struct be_cmd_req_hdr *) wrb_payload; |
| 4135 | struct be_cmd_req_hdr *req; |
| 4136 | struct be_cmd_resp_hdr *resp; |
| 4137 | int status; |
| 4138 | |
| 4139 | spin_lock_bh(&adapter->mcc_lock); |
| 4140 | |
| 4141 | wrb = wrb_from_mccq(adapter); |
| 4142 | if (!wrb) { |
| 4143 | status = -EBUSY; |
| 4144 | goto err; |
| 4145 | } |
| 4146 | req = embedded_payload(wrb); |
| 4147 | resp = embedded_payload(wrb); |
| 4148 | |
| 4149 | be_wrb_cmd_hdr_prepare(req, hdr->subsystem, |
| 4150 | hdr->opcode, wrb_payload_size, wrb, NULL); |
| 4151 | memcpy(req, wrb_payload, wrb_payload_size); |
| 4152 | be_dws_cpu_to_le(req, wrb_payload_size); |
| 4153 | |
| 4154 | status = be_mcc_notify_wait(adapter); |
| 4155 | if (cmd_status) |
| 4156 | *cmd_status = (status & 0xffff); |
| 4157 | if (ext_status) |
| 4158 | *ext_status = 0; |
| 4159 | memcpy(wrb_payload, resp, sizeof(*resp) + resp->response_length); |
| 4160 | be_dws_le_to_cpu(wrb_payload, sizeof(*resp) + resp->response_length); |
| 4161 | err: |
| 4162 | spin_unlock_bh(&adapter->mcc_lock); |
| 4163 | return status; |
| 4164 | } |
| 4165 | EXPORT_SYMBOL(be_roce_mcc_cmd); |