Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2018-2022 Advanced Micro Devices, Inc.
3 : : */
4 : :
5 : : #include <stdbool.h>
6 : :
7 : : #include <rte_memzone.h>
8 : :
9 : : #include "ionic.h"
10 : : #include "ionic_ethdev.h"
11 : : #include "ionic_lif.h"
12 : :
13 : : static const char *
14 : 0 : ionic_error_to_str(enum ionic_status_code code)
15 : : {
16 [ # # # # : 0 : switch (code) {
# # # # #
# # # # #
# # # # #
# # # ]
17 : : case IONIC_RC_SUCCESS:
18 : : return "IONIC_RC_SUCCESS";
19 : 0 : case IONIC_RC_EVERSION:
20 : 0 : return "IONIC_RC_EVERSION";
21 : 0 : case IONIC_RC_EOPCODE:
22 : 0 : return "IONIC_RC_EOPCODE";
23 : 0 : case IONIC_RC_EIO:
24 : 0 : return "IONIC_RC_EIO";
25 : 0 : case IONIC_RC_EPERM:
26 : 0 : return "IONIC_RC_EPERM";
27 : 0 : case IONIC_RC_EQID:
28 : 0 : return "IONIC_RC_EQID";
29 : 0 : case IONIC_RC_EQTYPE:
30 : 0 : return "IONIC_RC_EQTYPE";
31 : 0 : case IONIC_RC_ENOENT:
32 : 0 : return "IONIC_RC_ENOENT";
33 : 0 : case IONIC_RC_EINTR:
34 : 0 : return "IONIC_RC_EINTR";
35 : 0 : case IONIC_RC_EAGAIN:
36 : 0 : return "IONIC_RC_EAGAIN";
37 : 0 : case IONIC_RC_ENOMEM:
38 : 0 : return "IONIC_RC_ENOMEM";
39 : 0 : case IONIC_RC_EFAULT:
40 : 0 : return "IONIC_RC_EFAULT";
41 : 0 : case IONIC_RC_EBUSY:
42 : 0 : return "IONIC_RC_EBUSY";
43 : 0 : case IONIC_RC_EEXIST:
44 : 0 : return "IONIC_RC_EEXIST";
45 : 0 : case IONIC_RC_EINVAL:
46 : 0 : return "IONIC_RC_EINVAL";
47 : 0 : case IONIC_RC_ENOSPC:
48 : 0 : return "IONIC_RC_ENOSPC";
49 : 0 : case IONIC_RC_ERANGE:
50 : 0 : return "IONIC_RC_ERANGE";
51 : 0 : case IONIC_RC_BAD_ADDR:
52 : 0 : return "IONIC_RC_BAD_ADDR";
53 : 0 : case IONIC_RC_DEV_CMD:
54 : 0 : return "IONIC_RC_DEV_CMD";
55 : 0 : case IONIC_RC_ERROR:
56 : 0 : return "IONIC_RC_ERROR";
57 : 0 : case IONIC_RC_ERDMA:
58 : 0 : return "IONIC_RC_ERDMA";
59 : 0 : default:
60 : 0 : return "IONIC_RC_UNKNOWN";
61 : : }
62 : : }
63 : :
64 : : const char *
65 : 0 : ionic_opcode_to_str(enum ionic_cmd_opcode opcode)
66 : : {
67 [ # # # # : 0 : switch (opcode) {
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
68 : : case IONIC_CMD_NOP:
69 : : return "IONIC_CMD_NOP";
70 : 0 : case IONIC_CMD_INIT:
71 : 0 : return "IONIC_CMD_INIT";
72 : 0 : case IONIC_CMD_RESET:
73 : 0 : return "IONIC_CMD_RESET";
74 : 0 : case IONIC_CMD_IDENTIFY:
75 : 0 : return "IONIC_CMD_IDENTIFY";
76 : 0 : case IONIC_CMD_GETATTR:
77 : 0 : return "IONIC_CMD_GETATTR";
78 : 0 : case IONIC_CMD_SETATTR:
79 : 0 : return "IONIC_CMD_SETATTR";
80 : 0 : case IONIC_CMD_PORT_IDENTIFY:
81 : 0 : return "IONIC_CMD_PORT_IDENTIFY";
82 : 0 : case IONIC_CMD_PORT_INIT:
83 : 0 : return "IONIC_CMD_PORT_INIT";
84 : 0 : case IONIC_CMD_PORT_RESET:
85 : 0 : return "IONIC_CMD_PORT_RESET";
86 : 0 : case IONIC_CMD_PORT_GETATTR:
87 : 0 : return "IONIC_CMD_PORT_GETATTR";
88 : 0 : case IONIC_CMD_PORT_SETATTR:
89 : 0 : return "IONIC_CMD_PORT_SETATTR";
90 : 0 : case IONIC_CMD_LIF_INIT:
91 : 0 : return "IONIC_CMD_LIF_INIT";
92 : 0 : case IONIC_CMD_LIF_RESET:
93 : 0 : return "IONIC_CMD_LIF_RESET";
94 : 0 : case IONIC_CMD_LIF_IDENTIFY:
95 : 0 : return "IONIC_CMD_LIF_IDENTIFY";
96 : 0 : case IONIC_CMD_LIF_SETATTR:
97 : 0 : return "IONIC_CMD_LIF_SETATTR";
98 : 0 : case IONIC_CMD_LIF_GETATTR:
99 : 0 : return "IONIC_CMD_LIF_GETATTR";
100 : 0 : case IONIC_CMD_RX_MODE_SET:
101 : 0 : return "IONIC_CMD_RX_MODE_SET";
102 : 0 : case IONIC_CMD_RX_FILTER_ADD:
103 : 0 : return "IONIC_CMD_RX_FILTER_ADD";
104 : 0 : case IONIC_CMD_RX_FILTER_DEL:
105 : 0 : return "IONIC_CMD_RX_FILTER_DEL";
106 : 0 : case IONIC_CMD_Q_INIT:
107 : 0 : return "IONIC_CMD_Q_INIT";
108 : 0 : case IONIC_CMD_Q_CONTROL:
109 : 0 : return "IONIC_CMD_Q_CONTROL";
110 : 0 : case IONIC_CMD_Q_IDENTIFY:
111 : 0 : return "IONIC_CMD_Q_IDENTIFY";
112 : 0 : case IONIC_CMD_RDMA_RESET_LIF:
113 : 0 : return "IONIC_CMD_RDMA_RESET_LIF";
114 : 0 : case IONIC_CMD_RDMA_CREATE_EQ:
115 : 0 : return "IONIC_CMD_RDMA_CREATE_EQ";
116 : 0 : case IONIC_CMD_RDMA_CREATE_CQ:
117 : 0 : return "IONIC_CMD_RDMA_CREATE_CQ";
118 : 0 : case IONIC_CMD_RDMA_CREATE_ADMINQ:
119 : 0 : return "IONIC_CMD_RDMA_CREATE_ADMINQ";
120 : 0 : default:
121 : 0 : return "DEVCMD_UNKNOWN";
122 : : }
123 : : }
124 : :
125 : : static int
126 : 0 : ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
127 : : {
128 : : const char *name;
129 : : const char *status;
130 : :
131 : 0 : name = ionic_opcode_to_str(ctx->cmd.cmd.opcode);
132 : :
133 [ # # # # ]: 0 : if (ctx->comp.comp.status || timeout) {
134 : 0 : status = ionic_error_to_str(ctx->comp.comp.status);
135 [ # # # # ]: 0 : IONIC_PRINT(ERR, "%s (%d) failed: %s (%d)",
136 : : name,
137 : : ctx->cmd.cmd.opcode,
138 : : timeout ? "TIMEOUT" : status,
139 : : timeout ? -1 : ctx->comp.comp.status);
140 : 0 : return -EIO;
141 : : }
142 : :
143 : 0 : IONIC_PRINT(DEBUG, "%s (%d) succeeded", name, ctx->cmd.cmd.opcode);
144 : :
145 : 0 : return 0;
146 : : }
147 : :
148 : : static bool
149 : 0 : ionic_adminq_service(struct ionic_cq *cq, uint16_t cq_desc_index,
150 : : void *cb_arg __rte_unused)
151 : : {
152 : 0 : struct ionic_admin_comp *cq_desc_base = cq->base;
153 : 0 : struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
154 : 0 : struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
155 : : struct ionic_queue *q = &qcq->q;
156 : : struct ionic_admin_ctx *ctx;
157 : : uint16_t curr_q_tail_idx;
158 : : uint16_t stop_index;
159 : : void **info;
160 : :
161 [ # # ]: 0 : if (!color_match(cq_desc->color, cq->done_color))
162 : : return false;
163 : :
164 : 0 : stop_index = rte_le_to_cpu_16(cq_desc->comp_index);
165 : :
166 : : do {
167 : 0 : info = IONIC_INFO_PTR(q, q->tail_idx);
168 : :
169 : 0 : ctx = info[0];
170 [ # # ]: 0 : if (ctx) {
171 : 0 : memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
172 : :
173 : 0 : ctx->pending_work = false; /* done */
174 : : }
175 : :
176 : 0 : curr_q_tail_idx = q->tail_idx;
177 : 0 : q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
178 [ # # ]: 0 : } while (curr_q_tail_idx != stop_index);
179 : :
180 : : return true;
181 : : }
182 : :
183 : : /** ionic_adminq_post - Post an admin command.
184 : : * @lif: Handle to lif.
185 : : * @cmd_ctx: Api admin command context.
186 : : *
187 : : * Post the command to an admin queue in the ethernet driver. If this command
188 : : * succeeds, then the command has been posted, but that does not indicate a
189 : : * completion. If this command returns success, then the completion callback
190 : : * will eventually be called.
191 : : *
192 : : * Return: zero or negative error status.
193 : : */
194 : : static int
195 : 0 : ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
196 : : {
197 : 0 : struct ionic_queue *q = &lif->adminqcq->qcq.q;
198 : 0 : struct ionic_admin_cmd *q_desc_base = q->base;
199 : : struct ionic_admin_cmd *q_desc;
200 : : void **info;
201 : : int err = 0;
202 : :
203 : 0 : rte_spinlock_lock(&lif->adminq_lock);
204 : :
205 [ # # ]: 0 : if (ionic_q_space_avail(q) < 1) {
206 : : err = -ENOSPC;
207 : 0 : goto err_out;
208 : : }
209 : :
210 : 0 : q_desc = &q_desc_base[q->head_idx];
211 : :
212 : 0 : memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
213 : :
214 : 0 : info = IONIC_INFO_PTR(q, q->head_idx);
215 : 0 : info[0] = ctx;
216 : :
217 : 0 : q->head_idx = Q_NEXT_TO_POST(q, 1);
218 : :
219 : : /* Ring doorbell */
220 : : rte_wmb();
221 : : ionic_q_flush(q);
222 : :
223 : 0 : err_out:
224 : : rte_spinlock_unlock(&lif->adminq_lock);
225 : :
226 : 0 : return err;
227 : : }
228 : :
229 : : static int
230 : 0 : ionic_adminq_wait_for_completion(struct ionic_lif *lif,
231 : : struct ionic_admin_ctx *ctx, unsigned long max_wait)
232 : : {
233 : 0 : struct ionic_queue *q = &lif->adminqcq->qcq.q;
234 : : unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
235 : : unsigned long step_deadline;
236 : 0 : unsigned long max_wait_usec = max_wait * 1000000L;
237 : : unsigned long elapsed_usec = 0;
238 : : int budget = 8;
239 : : uint16_t idx;
240 : : void **info;
241 : :
242 : : step_deadline = IONIC_ADMINQ_WDOG_MS * 1000 / step_usec;
243 : :
244 [ # # # # ]: 0 : while (ctx->pending_work && elapsed_usec < max_wait_usec) {
245 : : /*
246 : : * Locking here as adminq is served inline and could be
247 : : * called from multiple places
248 : : */
249 : 0 : rte_spinlock_lock(&lif->adminq_service_lock);
250 : :
251 : 0 : ionic_qcq_service(&lif->adminqcq->qcq, budget,
252 : : ionic_adminq_service, NULL);
253 : :
254 : : /*
255 : : * Ring the doorbell again if work is pending after deadline.
256 : : */
257 [ # # # # ]: 0 : if (ctx->pending_work && !step_deadline) {
258 : : step_deadline = IONIC_ADMINQ_WDOG_MS *
259 : : 1000 / step_usec;
260 : :
261 : 0 : rte_spinlock_lock(&lif->adminq_lock);
262 : 0 : idx = Q_NEXT_TO_POST(q, -1);
263 : 0 : info = IONIC_INFO_PTR(q, idx);
264 [ # # ]: 0 : if (info[0] == ctx)
265 : : ionic_q_flush(q);
266 : : rte_spinlock_unlock(&lif->adminq_lock);
267 : : }
268 : :
269 : : rte_spinlock_unlock(&lif->adminq_service_lock);
270 : :
271 : 0 : rte_delay_us_block(step_usec);
272 : 0 : elapsed_usec += step_usec;
273 : 0 : step_deadline--;
274 : : }
275 : :
276 : 0 : return (!ctx->pending_work);
277 : : }
278 : :
279 : : int
280 : 0 : ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
281 : : {
282 : : bool done;
283 : : int err;
284 : :
285 : 0 : IONIC_PRINT(DEBUG, "Sending %s (%d) via the admin queue",
286 : : ionic_opcode_to_str(ctx->cmd.cmd.opcode), ctx->cmd.cmd.opcode);
287 : :
288 : 0 : err = ionic_adminq_post(lif, ctx);
289 [ # # ]: 0 : if (err) {
290 : 0 : IONIC_PRINT(ERR, "Failure posting %d to the admin queue (%d)",
291 : : ctx->cmd.cmd.opcode, err);
292 : 0 : return err;
293 : : }
294 : :
295 : 0 : done = ionic_adminq_wait_for_completion(lif, ctx,
296 : : IONIC_DEVCMD_TIMEOUT);
297 : :
298 : 0 : return ionic_adminq_check_err(ctx, !done /* timed out */);
299 : : }
300 : :
301 : : static int
302 : 0 : ionic_dev_cmd_wait(struct ionic_dev *idev, unsigned long max_wait)
303 : : {
304 : : unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
305 : 0 : unsigned long max_wait_usec = max_wait * 1000000L;
306 : : unsigned long elapsed_usec = 0;
307 : : int done;
308 : :
309 : : /* Wait for dev cmd to complete.. but no more than max_wait sec */
310 : :
311 : : do {
312 : 0 : done = ionic_dev_cmd_done(idev);
313 [ # # ]: 0 : if (done) {
314 : 0 : IONIC_PRINT(DEBUG, "DEVCMD %d done took %ld usecs",
315 : : ioread8(&idev->dev_cmd->cmd.cmd.opcode),
316 : : elapsed_usec);
317 : 0 : return 0;
318 : : }
319 : :
320 : 0 : rte_delay_us_block(step_usec);
321 : :
322 : 0 : elapsed_usec += step_usec;
323 [ # # ]: 0 : } while (elapsed_usec < max_wait_usec);
324 : :
325 : 0 : IONIC_PRINT(ERR, "DEVCMD %d timeout after %ld usecs",
326 : : ioread8(&idev->dev_cmd->cmd.cmd.opcode),
327 : : elapsed_usec);
328 : :
329 : 0 : return -ETIMEDOUT;
330 : : }
331 : :
332 : : static int
333 : : ionic_dev_cmd_check_error(struct ionic_dev *idev)
334 : : {
335 : : uint8_t status;
336 : :
337 : 0 : status = ionic_dev_cmd_status(idev);
338 [ # # ]: 0 : if (status == IONIC_RC_SUCCESS)
339 : : return 0;
340 : :
341 [ # # ]: 0 : return (status == IONIC_RC_EAGAIN) ? -EAGAIN : -EIO;
342 : : }
343 : :
344 : : int
345 : 0 : ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait)
346 : : {
347 : : int err;
348 : :
349 : 0 : err = ionic_dev_cmd_wait(idev, max_wait);
350 : :
351 [ # # ]: 0 : if (!err)
352 : : err = ionic_dev_cmd_check_error(idev);
353 : :
354 : 0 : IONIC_PRINT(DEBUG, "dev_cmd returned %d", err);
355 : 0 : return err;
356 : : }
357 : :
358 : : int
359 : 0 : ionic_setup(struct ionic_adapter *adapter)
360 : : {
361 : 0 : return (*adapter->intf->setup)(adapter);
362 : : }
363 : :
364 : : int
365 : 0 : ionic_identify(struct ionic_adapter *adapter)
366 : : {
367 : 0 : struct ionic_dev *idev = &adapter->idev;
368 : 0 : struct ionic_identity *ident = &adapter->ident;
369 : : uint32_t drv_size = RTE_DIM(ident->drv.words);
370 : : uint32_t cmd_size = RTE_DIM(idev->dev_cmd->data);
371 : : uint32_t dev_size = RTE_DIM(ident->dev.words);
372 : : uint32_t i, nwords;
373 : : int err;
374 : :
375 : : memset(ident, 0, sizeof(*ident));
376 : :
377 : 0 : ident->drv.os_type = IONIC_OS_TYPE_LINUX;
378 : 0 : ident->drv.os_dist = 0;
379 : 0 : snprintf(ident->drv.os_dist_str,
380 : : sizeof(ident->drv.os_dist_str), "Unknown");
381 : 0 : ident->drv.kernel_ver = 0;
382 : 0 : snprintf(ident->drv.kernel_ver_str,
383 : : sizeof(ident->drv.kernel_ver_str), "DPDK");
384 : 0 : strncpy(ident->drv.driver_ver_str, IONIC_DRV_VERSION,
385 : : sizeof(ident->drv.driver_ver_str) - 1);
386 : :
387 : : nwords = RTE_MIN(drv_size, cmd_size);
388 [ # # ]: 0 : for (i = 0; i < nwords; i++)
389 : 0 : iowrite32(ident->drv.words[i], &idev->dev_cmd->data[i]);
390 : :
391 : 0 : ionic_dev_cmd_identify(idev, IONIC_IDENTITY_VERSION_1);
392 : 0 : err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
393 [ # # ]: 0 : if (!err) {
394 : : nwords = RTE_MIN(dev_size, cmd_size);
395 [ # # ]: 0 : for (i = 0; i < nwords; i++)
396 : 0 : ident->dev.words[i] = ioread32(&idev->dev_cmd->data[i]);
397 : : }
398 : :
399 : 0 : return err;
400 : : }
401 : :
402 : : int
403 : 0 : ionic_init(struct ionic_adapter *adapter)
404 : : {
405 : 0 : struct ionic_dev *idev = &adapter->idev;
406 : :
407 : 0 : ionic_dev_cmd_init(idev);
408 : 0 : return ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
409 : : }
410 : :
411 : : int
412 : 0 : ionic_reset(struct ionic_adapter *adapter)
413 : : {
414 : 0 : struct ionic_dev *idev = &adapter->idev;
415 : :
416 : 0 : ionic_dev_cmd_reset(idev);
417 : 0 : return ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
418 : : }
419 : :
420 : : int
421 : 0 : ionic_port_identify(struct ionic_adapter *adapter)
422 : : {
423 : 0 : struct ionic_dev *idev = &adapter->idev;
424 : : struct ionic_identity *ident = &adapter->ident;
425 : : uint32_t port_words = RTE_DIM(ident->port.words);
426 : : uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data);
427 : : uint32_t i, nwords;
428 : : int err;
429 : :
430 : 0 : ionic_dev_cmd_port_identify(idev);
431 : 0 : err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
432 [ # # ]: 0 : if (!err) {
433 : : nwords = RTE_MIN(port_words, cmd_words);
434 [ # # ]: 0 : for (i = 0; i < nwords; i++)
435 : 0 : ident->port.words[i] =
436 : 0 : ioread32(&idev->dev_cmd->data[i]);
437 : : }
438 : :
439 : 0 : IONIC_PRINT(INFO, "speed %d",
440 : : rte_le_to_cpu_32(ident->port.config.speed));
441 : 0 : IONIC_PRINT(INFO, "mtu %d",
442 : : rte_le_to_cpu_32(ident->port.config.mtu));
443 : 0 : IONIC_PRINT(INFO, "state %d", ident->port.config.state);
444 : 0 : IONIC_PRINT(INFO, "an_enable %d", ident->port.config.an_enable);
445 : 0 : IONIC_PRINT(INFO, "fec_type %d", ident->port.config.fec_type);
446 : 0 : IONIC_PRINT(INFO, "pause_type %d", ident->port.config.pause_type);
447 : 0 : IONIC_PRINT(INFO, "loopback_mode %d",
448 : : ident->port.config.loopback_mode);
449 : :
450 : 0 : return err;
451 : : }
452 : :
453 : : static const struct rte_memzone *
454 : 0 : ionic_memzone_reserve(const char *name, uint32_t len, int socket_id)
455 : : {
456 : : const struct rte_memzone *mz;
457 : :
458 : 0 : mz = rte_memzone_lookup(name);
459 [ # # ]: 0 : if (mz)
460 : : return mz;
461 : :
462 : 0 : mz = rte_memzone_reserve_aligned(name, len, socket_id,
463 : : RTE_MEMZONE_IOVA_CONTIG, IONIC_ALIGN);
464 : 0 : return mz;
465 : : }
466 : :
467 : : int
468 : 0 : ionic_port_init(struct ionic_adapter *adapter)
469 : : {
470 : 0 : struct ionic_dev *idev = &adapter->idev;
471 : : struct ionic_identity *ident = &adapter->ident;
472 : : char z_name[RTE_MEMZONE_NAMESIZE];
473 : : uint32_t config_words = RTE_DIM(ident->port.config.words);
474 : : uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data);
475 : : uint32_t i, nwords;
476 : : int err;
477 : :
478 [ # # ]: 0 : if (idev->port_info)
479 : : return 0;
480 : :
481 : 0 : idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info),
482 : : rte_mem_page_size());
483 : :
484 : 0 : snprintf(z_name, sizeof(z_name), "%s_port_%s_info",
485 : : IONIC_DRV_NAME, adapter->name);
486 : :
487 : 0 : idev->port_info_z = ionic_memzone_reserve(z_name, idev->port_info_sz,
488 : : SOCKET_ID_ANY);
489 [ # # ]: 0 : if (!idev->port_info_z) {
490 : 0 : IONIC_PRINT(ERR, "Cannot reserve port info DMA memory");
491 : 0 : return -ENOMEM;
492 : : }
493 : :
494 : 0 : idev->port_info = idev->port_info_z->addr;
495 : 0 : idev->port_info_pa = idev->port_info_z->iova;
496 : :
497 : : nwords = RTE_MIN(config_words, cmd_words);
498 : :
499 [ # # ]: 0 : for (i = 0; i < nwords; i++)
500 : 0 : iowrite32(ident->port.config.words[i], &idev->dev_cmd->data[i]);
501 : :
502 : 0 : idev->port_info->config.state = IONIC_PORT_ADMIN_STATE_UP;
503 : 0 : ionic_dev_cmd_port_init(idev);
504 : 0 : err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
505 [ # # ]: 0 : if (err)
506 : 0 : IONIC_PRINT(ERR, "Failed to init port");
507 : :
508 : : return err;
509 : : }
510 : :
511 : : int
512 : 0 : ionic_port_reset(struct ionic_adapter *adapter)
513 : : {
514 : 0 : struct ionic_dev *idev = &adapter->idev;
515 : : int err;
516 : :
517 [ # # ]: 0 : if (!idev->port_info)
518 : : return 0;
519 : :
520 : 0 : ionic_dev_cmd_port_reset(idev);
521 : 0 : err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
522 [ # # ]: 0 : if (err) {
523 : 0 : IONIC_PRINT(ERR, "Failed to reset port");
524 : 0 : return err;
525 : : }
526 : :
527 : 0 : idev->port_info = NULL;
528 : 0 : idev->port_info_pa = 0;
529 : :
530 : 0 : return 0;
531 : : }
|