blob: 0e7043801bb1c214c78f4bbbdd5047fac89ad27f [file] [log] [blame]
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -08001/*
Jubin John05d6ac12016-02-14 20:22:17 -08002 * Copyright(c) 2015, 2016 Intel Corporation.
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -08003 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -08009 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * BSD LICENSE
19 *
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -080020 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 *
24 * - Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * - Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 * - Neither the name of Intel Corporation nor the names of its
31 * contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 *
46 */
Easwar Hariharanc3838b32016-02-09 14:29:13 -080047
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -080048#include "hfi.h"
Easwar Hariharanc3838b32016-02-09 14:29:13 -080049#include "efivar.h"
Dean Luicke83eba22016-09-30 04:41:45 -070050#include "eprom.h"
Easwar Hariharanc3838b32016-02-09 14:29:13 -080051
Easwar Hariharanfe4d9242016-10-17 04:19:47 -070052static int validate_scratch_checksum(struct hfi1_devdata *dd)
53{
54 u64 checksum = 0, temp_scratch = 0;
55 int i, j, version;
56
57 temp_scratch = read_csr(dd, ASIC_CFG_SCRATCH);
58 version = (temp_scratch & BITMAP_VERSION_SMASK) >> BITMAP_VERSION_SHIFT;
59
60 /* Prevent power on default of all zeroes from passing checksum */
61 if (!version)
62 return 0;
63
64 /*
65 * ASIC scratch 0 only contains the checksum and bitmap version as
66 * fields of interest, both of which are handled separately from the
67 * loop below, so skip it
68 */
69 checksum += version;
70 for (i = 1; i < ASIC_NUM_SCRATCH; i++) {
71 temp_scratch = read_csr(dd, ASIC_CFG_SCRATCH + (8 * i));
72 for (j = sizeof(u64); j != 0; j -= 2) {
73 checksum += (temp_scratch & 0xFFFF);
74 temp_scratch >>= 16;
75 }
76 }
77
78 while (checksum >> 16)
79 checksum = (checksum & CHECKSUM_MASK) + (checksum >> 16);
80
81 temp_scratch = read_csr(dd, ASIC_CFG_SCRATCH);
82 temp_scratch &= CHECKSUM_SMASK;
83 temp_scratch >>= CHECKSUM_SHIFT;
84
85 if (checksum + temp_scratch == 0xFFFF)
86 return 1;
87 return 0;
88}
89
90static void save_platform_config_fields(struct hfi1_devdata *dd)
91{
92 struct hfi1_pportdata *ppd = dd->pport;
93 u64 temp_scratch = 0, temp_dest = 0;
94
95 temp_scratch = read_csr(dd, ASIC_CFG_SCRATCH_1);
96
97 temp_dest = temp_scratch &
98 (dd->hfi1_id ? PORT1_PORT_TYPE_SMASK :
99 PORT0_PORT_TYPE_SMASK);
100 ppd->port_type = temp_dest >>
101 (dd->hfi1_id ? PORT1_PORT_TYPE_SHIFT :
102 PORT0_PORT_TYPE_SHIFT);
103
104 temp_dest = temp_scratch &
105 (dd->hfi1_id ? PORT1_LOCAL_ATTEN_SMASK :
106 PORT0_LOCAL_ATTEN_SMASK);
107 ppd->local_atten = temp_dest >>
108 (dd->hfi1_id ? PORT1_LOCAL_ATTEN_SHIFT :
109 PORT0_LOCAL_ATTEN_SHIFT);
110
111 temp_dest = temp_scratch &
112 (dd->hfi1_id ? PORT1_REMOTE_ATTEN_SMASK :
113 PORT0_REMOTE_ATTEN_SMASK);
114 ppd->remote_atten = temp_dest >>
115 (dd->hfi1_id ? PORT1_REMOTE_ATTEN_SHIFT :
116 PORT0_REMOTE_ATTEN_SHIFT);
117
118 temp_dest = temp_scratch &
119 (dd->hfi1_id ? PORT1_DEFAULT_ATTEN_SMASK :
120 PORT0_DEFAULT_ATTEN_SMASK);
121 ppd->default_atten = temp_dest >>
122 (dd->hfi1_id ? PORT1_DEFAULT_ATTEN_SHIFT :
123 PORT0_DEFAULT_ATTEN_SHIFT);
124
125 temp_scratch = read_csr(dd, dd->hfi1_id ? ASIC_CFG_SCRATCH_3 :
126 ASIC_CFG_SCRATCH_2);
127
128 ppd->tx_preset_eq = (temp_scratch & TX_EQ_SMASK) >> TX_EQ_SHIFT;
129 ppd->tx_preset_noeq = (temp_scratch & TX_NO_EQ_SMASK) >> TX_NO_EQ_SHIFT;
130 ppd->rx_preset = (temp_scratch & RX_SMASK) >> RX_SHIFT;
131
132 ppd->max_power_class = (temp_scratch & QSFP_MAX_POWER_SMASK) >>
133 QSFP_MAX_POWER_SHIFT;
134}
135
Easwar Hariharanc3838b32016-02-09 14:29:13 -0800136void get_platform_config(struct hfi1_devdata *dd)
137{
138 int ret = 0;
139 unsigned long size = 0;
140 u8 *temp_platform_config = NULL;
Dean Luicke83eba22016-09-30 04:41:45 -0700141 u32 esize;
142
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700143 if (is_integrated(dd)) {
144 if (validate_scratch_checksum(dd)) {
145 save_platform_config_fields(dd);
146 return;
147 }
148 dd_dev_err(dd, "%s: Config bitmap corrupted/uninitialized\n",
149 __func__);
150 dd_dev_err(dd,
151 "%s: Please update your BIOS to support active channels\n",
152 __func__);
153 } else {
154 ret = eprom_read_platform_config(dd,
155 (void **)&temp_platform_config,
156 &esize);
157 if (!ret) {
158 /* success */
159 dd->platform_config.data = temp_platform_config;
160 dd->platform_config.size = esize;
161 return;
162 }
163 /* fail, try EFI variable */
164
165 ret = read_hfi1_efi_var(dd, "configuration", &size,
166 (void **)&temp_platform_config);
167 if (!ret) {
168 dd->platform_config.data = temp_platform_config;
169 dd->platform_config.size = size;
170 return;
171 }
Dean Luicke83eba22016-09-30 04:41:45 -0700172 }
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700173 dd_dev_err(dd,
174 "%s: Failed to get platform config, falling back to sub-optimal default file\n",
175 __func__);
Dean Luicke83eba22016-09-30 04:41:45 -0700176 /* fall back to request firmware */
177 platform_config_load = 1;
Easwar Hariharanc3838b32016-02-09 14:29:13 -0800178}
179
180void free_platform_config(struct hfi1_devdata *dd)
181{
182 if (!platform_config_load) {
183 /*
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700184 * was loaded from EFI or the EPROM, release memory
185 * allocated by read_efi_var/eprom_read_platform_config
Easwar Hariharanc3838b32016-02-09 14:29:13 -0800186 */
187 kfree(dd->platform_config.data);
188 }
189 /*
190 * else do nothing, dispose_firmware will release
191 * struct firmware platform_config on driver exit
192 */
193}
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800194
Easwar Hariharan9775a992016-05-12 10:22:39 -0700195void get_port_type(struct hfi1_pportdata *ppd)
196{
197 int ret;
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700198 u32 temp;
Easwar Hariharan9775a992016-05-12 10:22:39 -0700199
200 ret = get_platform_config_field(ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700201 PORT_TABLE_PORT_TYPE, &temp,
Easwar Hariharan9775a992016-05-12 10:22:39 -0700202 4);
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700203 if (ret) {
Easwar Hariharan9775a992016-05-12 10:22:39 -0700204 ppd->port_type = PORT_TYPE_UNKNOWN;
Easwar Hariharanfe4d9242016-10-17 04:19:47 -0700205 return;
206 }
207 ppd->port_type = temp;
Easwar Hariharan9775a992016-05-12 10:22:39 -0700208}
209
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800210int set_qsfp_tx(struct hfi1_pportdata *ppd, int on)
211{
212 u8 tx_ctrl_byte = on ? 0x0 : 0xF;
213 int ret = 0;
214
215 ret = qsfp_write(ppd, ppd->dd->hfi1_id, QSFP_TX_CTRL_BYTE_OFFS,
216 &tx_ctrl_byte, 1);
217 /* we expected 1, so consider 0 an error */
218 if (ret == 0)
219 ret = -EIO;
220 else if (ret == 1)
221 ret = 0;
222 return ret;
223}
224
225static int qual_power(struct hfi1_pportdata *ppd)
226{
227 u32 cable_power_class = 0, power_class_max = 0;
228 u8 *cache = ppd->qsfp_info.cache;
229 int ret = 0;
230
231 ret = get_platform_config_field(
232 ppd->dd, PLATFORM_CONFIG_SYSTEM_TABLE, 0,
233 SYSTEM_TABLE_QSFP_POWER_CLASS_MAX, &power_class_max, 4);
234 if (ret)
235 return ret;
236
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700237 cable_power_class = get_qsfp_power_class(cache[QSFP_MOD_PWR_OFFS]);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800238
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700239 if (cable_power_class > power_class_max)
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800240 ppd->offline_disabled_reason =
241 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_POWER_POLICY);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800242
243 if (ppd->offline_disabled_reason ==
244 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_POWER_POLICY)) {
245 dd_dev_info(
246 ppd->dd,
247 "%s: Port disabled due to system power restrictions\n",
248 __func__);
249 ret = -EPERM;
250 }
251 return ret;
252}
253
254static int qual_bitrate(struct hfi1_pportdata *ppd)
255{
256 u16 lss = ppd->link_speed_supported, lse = ppd->link_speed_enabled;
257 u8 *cache = ppd->qsfp_info.cache;
258
259 if ((lss & OPA_LINK_SPEED_25G) && (lse & OPA_LINK_SPEED_25G) &&
260 cache[QSFP_NOM_BIT_RATE_250_OFFS] < 0x64)
261 ppd->offline_disabled_reason =
262 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_LINKSPEED_POLICY);
263
264 if ((lss & OPA_LINK_SPEED_12_5G) && (lse & OPA_LINK_SPEED_12_5G) &&
265 cache[QSFP_NOM_BIT_RATE_100_OFFS] < 0x7D)
266 ppd->offline_disabled_reason =
267 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_LINKSPEED_POLICY);
268
269 if (ppd->offline_disabled_reason ==
270 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_LINKSPEED_POLICY)) {
271 dd_dev_info(
272 ppd->dd,
273 "%s: Cable failed bitrate check, disabling port\n",
274 __func__);
275 return -EPERM;
276 }
277 return 0;
278}
279
280static int set_qsfp_high_power(struct hfi1_pportdata *ppd)
281{
282 u8 cable_power_class = 0, power_ctrl_byte = 0;
283 u8 *cache = ppd->qsfp_info.cache;
284 int ret;
285
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700286 cable_power_class = get_qsfp_power_class(cache[QSFP_MOD_PWR_OFFS]);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800287
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700288 if (cable_power_class > QSFP_POWER_CLASS_1) {
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800289 power_ctrl_byte = cache[QSFP_PWR_CTRL_BYTE_OFFS];
290
291 power_ctrl_byte |= 1;
292 power_ctrl_byte &= ~(0x2);
293
294 ret = qsfp_write(ppd, ppd->dd->hfi1_id,
295 QSFP_PWR_CTRL_BYTE_OFFS,
296 &power_ctrl_byte, 1);
297 if (ret != 1)
298 return -EIO;
299
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700300 if (cable_power_class > QSFP_POWER_CLASS_4) {
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800301 power_ctrl_byte |= (1 << 2);
302 ret = qsfp_write(ppd, ppd->dd->hfi1_id,
303 QSFP_PWR_CTRL_BYTE_OFFS,
304 &power_ctrl_byte, 1);
305 if (ret != 1)
306 return -EIO;
307 }
308
309 /* SFF 8679 rev 1.7 LPMode Deassert time */
310 msleep(300);
311 }
312 return 0;
313}
314
315static void apply_rx_cdr(struct hfi1_pportdata *ppd,
316 u32 rx_preset_index,
317 u8 *cdr_ctrl_byte)
318{
319 u32 rx_preset;
320 u8 *cache = ppd->qsfp_info.cache;
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700321 int cable_power_class;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800322
323 if (!((cache[QSFP_MOD_PWR_OFFS] & 0x4) &&
324 (cache[QSFP_CDR_INFO_OFFS] & 0x40)))
325 return;
326
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700327 /* RX CDR present, bypass supported */
328 cable_power_class = get_qsfp_power_class(cache[QSFP_MOD_PWR_OFFS]);
329
330 if (cable_power_class <= QSFP_POWER_CLASS_3) {
331 /* Power class <= 3, ignore config & turn RX CDR on */
332 *cdr_ctrl_byte |= 0xF;
333 return;
334 }
335
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800336 get_platform_config_field(
337 ppd->dd, PLATFORM_CONFIG_RX_PRESET_TABLE,
338 rx_preset_index, RX_PRESET_TABLE_QSFP_RX_CDR_APPLY,
339 &rx_preset, 4);
340
341 if (!rx_preset) {
342 dd_dev_info(
343 ppd->dd,
344 "%s: RX_CDR_APPLY is set to disabled\n",
345 __func__);
346 return;
347 }
348 get_platform_config_field(
349 ppd->dd, PLATFORM_CONFIG_RX_PRESET_TABLE,
350 rx_preset_index, RX_PRESET_TABLE_QSFP_RX_CDR,
351 &rx_preset, 4);
352
353 /* Expand cdr setting to all 4 lanes */
354 rx_preset = (rx_preset | (rx_preset << 1) |
355 (rx_preset << 2) | (rx_preset << 3));
356
357 if (rx_preset) {
358 *cdr_ctrl_byte |= rx_preset;
359 } else {
360 *cdr_ctrl_byte &= rx_preset;
361 /* Preserve current TX CDR status */
362 *cdr_ctrl_byte |= (cache[QSFP_CDR_CTRL_BYTE_OFFS] & 0xF0);
363 }
364}
365
366static void apply_tx_cdr(struct hfi1_pportdata *ppd,
367 u32 tx_preset_index,
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700368 u8 *cdr_ctrl_byte)
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800369{
370 u32 tx_preset;
371 u8 *cache = ppd->qsfp_info.cache;
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700372 int cable_power_class;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800373
374 if (!((cache[QSFP_MOD_PWR_OFFS] & 0x8) &&
375 (cache[QSFP_CDR_INFO_OFFS] & 0x80)))
376 return;
377
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700378 /* TX CDR present, bypass supported */
379 cable_power_class = get_qsfp_power_class(cache[QSFP_MOD_PWR_OFFS]);
380
381 if (cable_power_class <= QSFP_POWER_CLASS_3) {
382 /* Power class <= 3, ignore config & turn TX CDR on */
383 *cdr_ctrl_byte |= 0xF0;
384 return;
385 }
386
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800387 get_platform_config_field(
388 ppd->dd,
389 PLATFORM_CONFIG_TX_PRESET_TABLE, tx_preset_index,
390 TX_PRESET_TABLE_QSFP_TX_CDR_APPLY, &tx_preset, 4);
391
392 if (!tx_preset) {
393 dd_dev_info(
394 ppd->dd,
395 "%s: TX_CDR_APPLY is set to disabled\n",
396 __func__);
397 return;
398 }
399 get_platform_config_field(
400 ppd->dd,
401 PLATFORM_CONFIG_TX_PRESET_TABLE,
402 tx_preset_index,
403 TX_PRESET_TABLE_QSFP_TX_CDR, &tx_preset, 4);
404
405 /* Expand cdr setting to all 4 lanes */
406 tx_preset = (tx_preset | (tx_preset << 1) |
407 (tx_preset << 2) | (tx_preset << 3));
408
409 if (tx_preset)
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700410 *cdr_ctrl_byte |= (tx_preset << 4);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800411 else
412 /* Preserve current/determined RX CDR status */
Easwar Hariharan145dd2b2016-04-12 11:25:31 -0700413 *cdr_ctrl_byte &= ((tx_preset << 4) | 0xF);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800414}
415
416static void apply_cdr_settings(
417 struct hfi1_pportdata *ppd, u32 rx_preset_index,
418 u32 tx_preset_index)
419{
420 u8 *cache = ppd->qsfp_info.cache;
421 u8 cdr_ctrl_byte = cache[QSFP_CDR_CTRL_BYTE_OFFS];
422
423 apply_rx_cdr(ppd, rx_preset_index, &cdr_ctrl_byte);
424
425 apply_tx_cdr(ppd, tx_preset_index, &cdr_ctrl_byte);
426
427 qsfp_write(ppd, ppd->dd->hfi1_id, QSFP_CDR_CTRL_BYTE_OFFS,
428 &cdr_ctrl_byte, 1);
429}
430
431static void apply_tx_eq_auto(struct hfi1_pportdata *ppd)
432{
433 u8 *cache = ppd->qsfp_info.cache;
434 u8 tx_eq;
435
436 if (!(cache[QSFP_EQ_INFO_OFFS] & 0x8))
437 return;
438 /* Disable adaptive TX EQ if present */
439 tx_eq = cache[(128 * 3) + 241];
440 tx_eq &= 0xF0;
441 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 241, &tx_eq, 1);
442}
443
444static void apply_tx_eq_prog(struct hfi1_pportdata *ppd, u32 tx_preset_index)
445{
446 u8 *cache = ppd->qsfp_info.cache;
447 u32 tx_preset;
448 u8 tx_eq;
449
450 if (!(cache[QSFP_EQ_INFO_OFFS] & 0x4))
451 return;
452
453 get_platform_config_field(
454 ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE,
455 tx_preset_index, TX_PRESET_TABLE_QSFP_TX_EQ_APPLY,
456 &tx_preset, 4);
457 if (!tx_preset) {
458 dd_dev_info(
459 ppd->dd,
460 "%s: TX_EQ_APPLY is set to disabled\n",
461 __func__);
462 return;
463 }
464 get_platform_config_field(
465 ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE,
466 tx_preset_index, TX_PRESET_TABLE_QSFP_TX_EQ,
467 &tx_preset, 4);
468
469 if (((cache[(128 * 3) + 224] & 0xF0) >> 4) < tx_preset) {
470 dd_dev_info(
471 ppd->dd,
472 "%s: TX EQ %x unsupported\n",
473 __func__, tx_preset);
474
475 dd_dev_info(
476 ppd->dd,
477 "%s: Applying EQ %x\n",
478 __func__, cache[608] & 0xF0);
479
480 tx_preset = (cache[608] & 0xF0) >> 4;
481 }
482
483 tx_eq = tx_preset | (tx_preset << 4);
484 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 234, &tx_eq, 1);
485 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 235, &tx_eq, 1);
486}
487
488static void apply_rx_eq_emp(struct hfi1_pportdata *ppd, u32 rx_preset_index)
489{
490 u32 rx_preset;
491 u8 rx_eq, *cache = ppd->qsfp_info.cache;
492
493 if (!(cache[QSFP_EQ_INFO_OFFS] & 0x2))
494 return;
495 get_platform_config_field(
496 ppd->dd, PLATFORM_CONFIG_RX_PRESET_TABLE,
497 rx_preset_index, RX_PRESET_TABLE_QSFP_RX_EMP_APPLY,
498 &rx_preset, 4);
499
500 if (!rx_preset) {
501 dd_dev_info(
502 ppd->dd,
503 "%s: RX_EMP_APPLY is set to disabled\n",
504 __func__);
505 return;
506 }
507 get_platform_config_field(
508 ppd->dd, PLATFORM_CONFIG_RX_PRESET_TABLE,
509 rx_preset_index, RX_PRESET_TABLE_QSFP_RX_EMP,
510 &rx_preset, 4);
511
512 if ((cache[(128 * 3) + 224] & 0xF) < rx_preset) {
513 dd_dev_info(
514 ppd->dd,
515 "%s: Requested RX EMP %x\n",
516 __func__, rx_preset);
517
518 dd_dev_info(
519 ppd->dd,
520 "%s: Applying supported EMP %x\n",
521 __func__, cache[608] & 0xF);
522
523 rx_preset = cache[608] & 0xF;
524 }
525
526 rx_eq = rx_preset | (rx_preset << 4);
527
528 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 236, &rx_eq, 1);
529 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 237, &rx_eq, 1);
530}
531
532static void apply_eq_settings(struct hfi1_pportdata *ppd,
533 u32 rx_preset_index, u32 tx_preset_index)
534{
535 u8 *cache = ppd->qsfp_info.cache;
536
537 /* no point going on w/o a page 3 */
538 if (cache[2] & 4) {
539 dd_dev_info(ppd->dd,
540 "%s: Upper page 03 not present\n",
541 __func__);
542 return;
543 }
544
545 apply_tx_eq_auto(ppd);
546
547 apply_tx_eq_prog(ppd, tx_preset_index);
548
549 apply_rx_eq_emp(ppd, rx_preset_index);
550}
551
552static void apply_rx_amplitude_settings(
553 struct hfi1_pportdata *ppd, u32 rx_preset_index,
554 u32 tx_preset_index)
555{
556 u32 rx_preset;
557 u8 rx_amp = 0, i = 0, preferred = 0, *cache = ppd->qsfp_info.cache;
558
559 /* no point going on w/o a page 3 */
560 if (cache[2] & 4) {
561 dd_dev_info(ppd->dd,
562 "%s: Upper page 03 not present\n",
563 __func__);
564 return;
565 }
566 if (!(cache[QSFP_EQ_INFO_OFFS] & 0x1)) {
567 dd_dev_info(ppd->dd,
568 "%s: RX_AMP_APPLY is set to disabled\n",
569 __func__);
570 return;
571 }
572
573 get_platform_config_field(ppd->dd,
574 PLATFORM_CONFIG_RX_PRESET_TABLE,
575 rx_preset_index,
576 RX_PRESET_TABLE_QSFP_RX_AMP_APPLY,
577 &rx_preset, 4);
578
579 if (!rx_preset) {
580 dd_dev_info(ppd->dd,
581 "%s: RX_AMP_APPLY is set to disabled\n",
582 __func__);
583 return;
584 }
585 get_platform_config_field(ppd->dd,
586 PLATFORM_CONFIG_RX_PRESET_TABLE,
587 rx_preset_index,
588 RX_PRESET_TABLE_QSFP_RX_AMP,
589 &rx_preset, 4);
590
591 dd_dev_info(ppd->dd,
592 "%s: Requested RX AMP %x\n",
593 __func__,
594 rx_preset);
595
596 for (i = 0; i < 4; i++) {
597 if (cache[(128 * 3) + 225] & (1 << i)) {
598 preferred = i;
599 if (preferred == rx_preset)
600 break;
601 }
602 }
603
604 /*
605 * Verify that preferred RX amplitude is not just a
606 * fall through of the default
607 */
608 if (!preferred && !(cache[(128 * 3) + 225] & 0x1)) {
609 dd_dev_info(ppd->dd, "No supported RX AMP, not applying\n");
610 return;
611 }
612
613 dd_dev_info(ppd->dd,
614 "%s: Applying RX AMP %x\n", __func__, preferred);
615
616 rx_amp = preferred | (preferred << 4);
617 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 238, &rx_amp, 1);
618 qsfp_write(ppd, ppd->dd->hfi1_id, (256 * 3) + 239, &rx_amp, 1);
619}
620
621#define OPA_INVALID_INDEX 0xFFF
622
Easwar Hariharan97167e82016-02-09 14:29:22 -0800623static void apply_tx_lanes(struct hfi1_pportdata *ppd, u8 field_id,
624 u32 config_data, const char *message)
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800625{
626 u8 i;
627 int ret = HCMD_SUCCESS;
628
629 for (i = 0; i < 4; i++) {
Easwar Hariharan97167e82016-02-09 14:29:22 -0800630 ret = load_8051_config(ppd->dd, field_id, i, config_data);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800631 if (ret != HCMD_SUCCESS) {
632 dd_dev_err(
633 ppd->dd,
634 "%s: %s for lane %u failed\n",
635 message, __func__, i);
636 }
637 }
638}
639
640static void apply_tunings(
641 struct hfi1_pportdata *ppd, u32 tx_preset_index,
642 u8 tuning_method, u32 total_atten, u8 limiting_active)
643{
644 int ret = 0;
645 u32 config_data = 0, tx_preset = 0;
646 u8 precur = 0, attn = 0, postcur = 0, external_device_config = 0;
647 u8 *cache = ppd->qsfp_info.cache;
648
Easwar Hariharan97167e82016-02-09 14:29:22 -0800649 /* Pass tuning method to 8051 */
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800650 read_8051_config(ppd->dd, LINK_TUNING_PARAMETERS, GENERAL_CONFIG,
651 &config_data);
Dean Luickf6de3d32016-05-24 12:51:00 -0700652 config_data &= ~(0xff << TUNING_METHOD_SHIFT);
653 config_data |= ((u32)tuning_method << TUNING_METHOD_SHIFT);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800654 ret = load_8051_config(ppd->dd, LINK_TUNING_PARAMETERS, GENERAL_CONFIG,
655 config_data);
656 if (ret != HCMD_SUCCESS)
657 dd_dev_err(ppd->dd, "%s: Failed to set tuning method\n",
658 __func__);
659
Easwar Hariharan97167e82016-02-09 14:29:22 -0800660 /* Set same channel loss for both TX and RX */
661 config_data = 0 | (total_atten << 16) | (total_atten << 24);
662 apply_tx_lanes(ppd, CHANNEL_LOSS_SETTINGS, config_data,
663 "Setting channel loss");
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800664
Easwar Hariharan97167e82016-02-09 14:29:22 -0800665 /* Inform 8051 of cable capabilities */
666 if (ppd->qsfp_info.cache_valid) {
667 external_device_config =
668 ((cache[QSFP_MOD_PWR_OFFS] & 0x4) << 3) |
669 ((cache[QSFP_MOD_PWR_OFFS] & 0x8) << 2) |
670 ((cache[QSFP_EQ_INFO_OFFS] & 0x2) << 1) |
671 (cache[QSFP_EQ_INFO_OFFS] & 0x4);
672 ret = read_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS,
673 GENERAL_CONFIG, &config_data);
674 /* Clear, then set the external device config field */
Easwar Hariharan27a340f2016-05-12 10:22:45 -0700675 config_data &= ~(u32)0xFF;
676 config_data |= external_device_config;
Easwar Hariharan97167e82016-02-09 14:29:22 -0800677 ret = load_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS,
678 GENERAL_CONFIG, config_data);
679 if (ret != HCMD_SUCCESS)
680 dd_dev_info(ppd->dd,
681 "%s: Failed set ext device config params\n",
682 __func__);
683 }
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800684
Easwar Hariharan97167e82016-02-09 14:29:22 -0800685 if (tx_preset_index == OPA_INVALID_INDEX) {
686 if (ppd->port_type == PORT_TYPE_QSFP && limiting_active)
687 dd_dev_info(ppd->dd, "%s: Invalid Tx preset index\n",
688 __func__);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800689 return;
Easwar Hariharan97167e82016-02-09 14:29:22 -0800690 }
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800691
Easwar Hariharan97167e82016-02-09 14:29:22 -0800692 /* Following for limiting active channels only */
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800693 get_platform_config_field(
694 ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE, tx_preset_index,
695 TX_PRESET_TABLE_PRECUR, &tx_preset, 4);
696 precur = tx_preset;
697
698 get_platform_config_field(
699 ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE,
700 tx_preset_index, TX_PRESET_TABLE_ATTN, &tx_preset, 4);
701 attn = tx_preset;
702
703 get_platform_config_field(
704 ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE,
705 tx_preset_index, TX_PRESET_TABLE_POSTCUR, &tx_preset, 4);
706 postcur = tx_preset;
707
708 config_data = precur | (attn << 8) | (postcur << 16);
709
Easwar Hariharan97167e82016-02-09 14:29:22 -0800710 apply_tx_lanes(ppd, TX_EQ_SETTINGS, config_data,
711 "Applying TX settings");
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800712}
713
Dean Luicke4e0e392016-04-12 11:28:36 -0700714/* Must be holding the QSFP i2c resource */
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800715static int tune_active_qsfp(struct hfi1_pportdata *ppd, u32 *ptr_tx_preset,
716 u32 *ptr_rx_preset, u32 *ptr_total_atten)
717{
Dean Luick765a6fa2016-03-05 08:50:06 -0800718 int ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800719 u16 lss = ppd->link_speed_supported, lse = ppd->link_speed_enabled;
720 u8 *cache = ppd->qsfp_info.cache;
721
722 ppd->qsfp_info.limiting_active = 1;
723
724 ret = set_qsfp_tx(ppd, 0);
725 if (ret)
Dean Luicke4e0e392016-04-12 11:28:36 -0700726 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800727
728 ret = qual_power(ppd);
729 if (ret)
Dean Luicke4e0e392016-04-12 11:28:36 -0700730 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800731
732 ret = qual_bitrate(ppd);
733 if (ret)
Dean Luicke4e0e392016-04-12 11:28:36 -0700734 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800735
Easwar Hariharanb5e71012016-07-25 13:40:03 -0700736 /*
737 * We'll change the QSFP memory contents from here on out, thus we set a
738 * flag here to remind ourselves to reset the QSFP module. This prevents
739 * reuse of stale settings established in our previous pass through.
740 */
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800741 if (ppd->qsfp_info.reset_needed) {
742 reset_qsfp(ppd);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800743 refresh_qsfp_cache(ppd, &ppd->qsfp_info);
744 } else {
745 ppd->qsfp_info.reset_needed = 1;
746 }
747
748 ret = set_qsfp_high_power(ppd);
749 if (ret)
Dean Luicke4e0e392016-04-12 11:28:36 -0700750 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800751
752 if (cache[QSFP_EQ_INFO_OFFS] & 0x4) {
753 ret = get_platform_config_field(
754 ppd->dd,
755 PLATFORM_CONFIG_PORT_TABLE, 0,
756 PORT_TABLE_TX_PRESET_IDX_ACTIVE_EQ,
757 ptr_tx_preset, 4);
758 if (ret) {
759 *ptr_tx_preset = OPA_INVALID_INDEX;
Dean Luicke4e0e392016-04-12 11:28:36 -0700760 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800761 }
762 } else {
763 ret = get_platform_config_field(
764 ppd->dd,
765 PLATFORM_CONFIG_PORT_TABLE, 0,
766 PORT_TABLE_TX_PRESET_IDX_ACTIVE_NO_EQ,
767 ptr_tx_preset, 4);
768 if (ret) {
769 *ptr_tx_preset = OPA_INVALID_INDEX;
Dean Luicke4e0e392016-04-12 11:28:36 -0700770 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800771 }
772 }
773
774 ret = get_platform_config_field(
775 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
776 PORT_TABLE_RX_PRESET_IDX, ptr_rx_preset, 4);
777 if (ret) {
778 *ptr_rx_preset = OPA_INVALID_INDEX;
Dean Luicke4e0e392016-04-12 11:28:36 -0700779 return ret;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800780 }
781
782 if ((lss & OPA_LINK_SPEED_25G) && (lse & OPA_LINK_SPEED_25G))
783 get_platform_config_field(
784 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
785 PORT_TABLE_LOCAL_ATTEN_25G, ptr_total_atten, 4);
786 else if ((lss & OPA_LINK_SPEED_12_5G) && (lse & OPA_LINK_SPEED_12_5G))
787 get_platform_config_field(
788 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
789 PORT_TABLE_LOCAL_ATTEN_12G, ptr_total_atten, 4);
790
791 apply_cdr_settings(ppd, *ptr_rx_preset, *ptr_tx_preset);
792
793 apply_eq_settings(ppd, *ptr_rx_preset, *ptr_tx_preset);
794
795 apply_rx_amplitude_settings(ppd, *ptr_rx_preset, *ptr_tx_preset);
796
797 ret = set_qsfp_tx(ppd, 1);
Dean Luick765a6fa2016-03-05 08:50:06 -0800798
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800799 return ret;
800}
801
802static int tune_qsfp(struct hfi1_pportdata *ppd,
803 u32 *ptr_tx_preset, u32 *ptr_rx_preset,
804 u8 *ptr_tuning_method, u32 *ptr_total_atten)
805{
806 u32 cable_atten = 0, remote_atten = 0, platform_atten = 0;
807 u16 lss = ppd->link_speed_supported, lse = ppd->link_speed_enabled;
808 int ret = 0;
809 u8 *cache = ppd->qsfp_info.cache;
810
811 switch ((cache[QSFP_MOD_TECH_OFFS] & 0xF0) >> 4) {
812 case 0xA ... 0xB:
813 ret = get_platform_config_field(
814 ppd->dd,
815 PLATFORM_CONFIG_PORT_TABLE, 0,
816 PORT_TABLE_LOCAL_ATTEN_25G,
817 &platform_atten, 4);
818 if (ret)
819 return ret;
820
821 if ((lss & OPA_LINK_SPEED_25G) && (lse & OPA_LINK_SPEED_25G))
822 cable_atten = cache[QSFP_CU_ATTEN_12G_OFFS];
823 else if ((lss & OPA_LINK_SPEED_12_5G) &&
824 (lse & OPA_LINK_SPEED_12_5G))
825 cable_atten = cache[QSFP_CU_ATTEN_7G_OFFS];
826
827 /* Fallback to configured attenuation if cable memory is bad */
828 if (cable_atten == 0 || cable_atten > 36) {
829 ret = get_platform_config_field(
830 ppd->dd,
831 PLATFORM_CONFIG_SYSTEM_TABLE, 0,
832 SYSTEM_TABLE_QSFP_ATTENUATION_DEFAULT_25G,
833 &cable_atten, 4);
834 if (ret)
835 return ret;
836 }
837
838 ret = get_platform_config_field(
839 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
840 PORT_TABLE_REMOTE_ATTEN_25G, &remote_atten, 4);
841 if (ret)
842 return ret;
843
844 *ptr_total_atten = platform_atten + cable_atten + remote_atten;
845
846 *ptr_tuning_method = OPA_PASSIVE_TUNING;
847 break;
848 case 0x0 ... 0x9: /* fallthrough */
849 case 0xC: /* fallthrough */
850 case 0xE:
851 ret = tune_active_qsfp(ppd, ptr_tx_preset, ptr_rx_preset,
852 ptr_total_atten);
853 if (ret)
854 return ret;
855
856 *ptr_tuning_method = OPA_ACTIVE_TUNING;
857 break;
858 case 0xD: /* fallthrough */
859 case 0xF:
860 default:
861 dd_dev_info(ppd->dd, "%s: Unknown/unsupported cable\n",
862 __func__);
863 break;
864 }
865 return ret;
866}
867
868/*
869 * This function communicates its success or failure via ppd->driver_link_ready
870 * Thus, it depends on its association with start_link(...) which checks
871 * driver_link_ready before proceeding with the link negotiation and
872 * initialization process.
873 */
874void tune_serdes(struct hfi1_pportdata *ppd)
875{
876 int ret = 0;
877 u32 total_atten = 0;
878 u32 remote_atten = 0, platform_atten = 0;
879 u32 rx_preset_index, tx_preset_index;
Easwar Hariharan97167e82016-02-09 14:29:22 -0800880 u8 tuning_method = 0, limiting_active = 0;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800881 struct hfi1_devdata *dd = ppd->dd;
882
883 rx_preset_index = OPA_INVALID_INDEX;
884 tx_preset_index = OPA_INVALID_INDEX;
885
886 /* the link defaults to enabled */
887 ppd->link_enabled = 1;
888 /* the driver link ready state defaults to not ready */
889 ppd->driver_link_ready = 0;
890 ppd->offline_disabled_reason = HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE);
891
Easwar Hariharan715c4302016-02-03 14:32:14 -0800892 /* Skip the tuning for testing (loopback != none) and simulations */
893 if (loopback != LOOPBACK_NONE ||
Easwar Hariharanc3838b32016-02-09 14:29:13 -0800894 ppd->dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800895 ppd->driver_link_ready = 1;
896 return;
897 }
898
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800899 switch (ppd->port_type) {
900 case PORT_TYPE_DISCONNECTED:
901 ppd->offline_disabled_reason =
902 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_DISCONNECTED);
903 dd_dev_info(dd, "%s: Port disconnected, disabling port\n",
904 __func__);
905 goto bail;
906 case PORT_TYPE_FIXED:
907 /* platform_atten, remote_atten pre-zeroed to catch error */
908 get_platform_config_field(
909 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
910 PORT_TABLE_LOCAL_ATTEN_25G, &platform_atten, 4);
911
912 get_platform_config_field(
913 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
914 PORT_TABLE_REMOTE_ATTEN_25G, &remote_atten, 4);
915
916 total_atten = platform_atten + remote_atten;
917
918 tuning_method = OPA_PASSIVE_TUNING;
919 break;
920 case PORT_TYPE_VARIABLE:
921 if (qsfp_mod_present(ppd)) {
922 /*
923 * platform_atten, remote_atten pre-zeroed to
924 * catch error
925 */
926 get_platform_config_field(
927 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
928 PORT_TABLE_LOCAL_ATTEN_25G,
929 &platform_atten, 4);
930
931 get_platform_config_field(
932 ppd->dd, PLATFORM_CONFIG_PORT_TABLE, 0,
933 PORT_TABLE_REMOTE_ATTEN_25G,
934 &remote_atten, 4);
935
936 total_atten = platform_atten + remote_atten;
937
938 tuning_method = OPA_PASSIVE_TUNING;
Easwar Hariharan623bba22016-04-12 11:25:57 -0700939 } else {
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800940 ppd->offline_disabled_reason =
941 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_CHASSIS_CONFIG);
Easwar Hariharan623bba22016-04-12 11:25:57 -0700942 goto bail;
943 }
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800944 break;
945 case PORT_TYPE_QSFP:
946 if (qsfp_mod_present(ppd)) {
Dean Luicke4e0e392016-04-12 11:28:36 -0700947 ret = acquire_chip_resource(ppd->dd,
948 qsfp_resource(ppd->dd),
949 QSFP_WAIT);
950 if (ret) {
951 dd_dev_err(ppd->dd, "%s: hfi%d: cannot lock i2c chain\n",
952 __func__, (int)ppd->dd->hfi1_id);
953 goto bail;
954 }
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800955 refresh_qsfp_cache(ppd, &ppd->qsfp_info);
956
957 if (ppd->qsfp_info.cache_valid) {
958 ret = tune_qsfp(ppd,
959 &tx_preset_index,
960 &rx_preset_index,
961 &tuning_method,
962 &total_atten);
Easwar Hariharanc3838b32016-02-09 14:29:13 -0800963
964 /*
965 * We may have modified the QSFP memory, so
966 * update the cache to reflect the changes
967 */
968 refresh_qsfp_cache(ppd, &ppd->qsfp_info);
Easwar Hariharan97167e82016-02-09 14:29:22 -0800969 limiting_active =
970 ppd->qsfp_info.limiting_active;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800971 } else {
972 dd_dev_err(dd,
973 "%s: Reading QSFP memory failed\n",
974 __func__);
Dean Luicke4e0e392016-04-12 11:28:36 -0700975 ret = -EINVAL; /* a fail indication */
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800976 }
Dean Luicke4e0e392016-04-12 11:28:36 -0700977 release_chip_resource(ppd->dd, qsfp_resource(ppd->dd));
978 if (ret)
979 goto bail;
Easwar Hariharan623bba22016-04-12 11:25:57 -0700980 } else {
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800981 ppd->offline_disabled_reason =
982 HFI1_ODR_MASK(
Easwar Hariharane1bf0d52016-02-03 14:36:58 -0800983 OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED);
Easwar Hariharan623bba22016-04-12 11:25:57 -0700984 goto bail;
985 }
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800986 break;
987 default:
988 dd_dev_info(ppd->dd, "%s: Unknown port type\n", __func__);
Easwar Hariharan97167e82016-02-09 14:29:22 -0800989 ppd->port_type = PORT_TYPE_UNKNOWN;
990 tuning_method = OPA_UNKNOWN_TUNING;
991 total_atten = 0;
992 limiting_active = 0;
993 tx_preset_index = OPA_INVALID_INDEX;
994 break;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800995 }
Easwar Hariharan97167e82016-02-09 14:29:22 -0800996
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -0800997 if (ppd->offline_disabled_reason ==
998 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
999 apply_tunings(ppd, tx_preset_index, tuning_method,
Easwar Hariharan97167e82016-02-09 14:29:22 -08001000 total_atten, limiting_active);
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -08001001
Easwar Hariharanc3838b32016-02-09 14:29:13 -08001002 if (!ret)
1003 ppd->driver_link_ready = 1;
Easwar Hariharan8ebd4cf2016-02-03 14:31:14 -08001004
1005 return;
1006bail:
1007 ppd->driver_link_ready = 0;
1008}