1 // SPDX-License-Identifier: GPL-2.0-only
2 /****************************************************************************
3 * Driver for AMD network controllers and boards
4 * Copyright (C) 2023, Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
11 #include "net_driver.h"
12 #include "ef100_nic.h"
13 #include "efx_devlink.h"
14 #include <linux/rtc.h>
16 #include "mcdi_functions.h"
17 #include "mcdi_pcol.h"
18 #ifdef CONFIG_SFC_SRIOV
20 #include "ef100_rep.h"
27 #ifdef CONFIG_SFC_SRIOV
28 static void efx_devlink_del_port(struct devlink_port *dl_port)
32 devl_port_unregister(dl_port);
35 static int efx_devlink_add_port(struct efx_nic *efx,
36 struct mae_mport_desc *mport)
38 bool external = false;
40 if (!ef100_mport_on_local_intf(efx, mport))
43 switch (mport->mport_type) {
44 case MAE_MPORT_DESC_MPORT_TYPE_VNIC:
45 if (mport->vf_idx != MAE_MPORT_DESC_VF_IDX_NULL)
46 devlink_port_attrs_pci_vf_set(&mport->dl_port, 0, mport->pf_idx,
50 devlink_port_attrs_pci_pf_set(&mport->dl_port, 0, mport->pf_idx,
54 /* MAE_MPORT_DESC_MPORT_ALIAS and UNDEFINED */
58 mport->dl_port.index = mport->mport_id;
60 return devl_port_register(efx->devlink, &mport->dl_port, mport->mport_id);
63 static int efx_devlink_port_addr_get(struct devlink_port *port, u8 *hw_addr,
65 struct netlink_ext_ack *extack)
67 struct efx_devlink *devlink = devlink_priv(port->devlink);
68 struct mae_mport_desc *mport_desc;
73 mport_desc = container_of(port, struct mae_mport_desc, dl_port);
75 if (!ef100_mport_on_local_intf(devlink->efx, mport_desc)) {
77 NL_SET_ERR_MSG_FMT(extack,
78 "Port not on local interface (mport: %u)",
79 mport_desc->mport_id);
83 if (ef100_mport_is_vf(mport_desc))
84 EFX_POPULATE_QWORD_3(pciefn,
85 PCIE_FUNCTION_PF, PCIE_FUNCTION_PF_NULL,
86 PCIE_FUNCTION_VF, mport_desc->vf_idx,
87 PCIE_FUNCTION_INTF, PCIE_INTERFACE_CALLER);
89 EFX_POPULATE_QWORD_3(pciefn,
90 PCIE_FUNCTION_PF, mport_desc->pf_idx,
91 PCIE_FUNCTION_VF, PCIE_FUNCTION_VF_NULL,
92 PCIE_FUNCTION_INTF, PCIE_INTERFACE_CALLER);
94 rc = efx_ef100_lookup_client_id(devlink->efx, pciefn, &client_id);
96 NL_SET_ERR_MSG_FMT(extack,
97 "No internal client_ID for port (mport: %u)",
98 mport_desc->mport_id);
102 rc = ef100_get_mac_address(devlink->efx, hw_addr, client_id, true);
104 NL_SET_ERR_MSG_FMT(extack,
105 "No available MAC for port (mport: %u)",
106 mport_desc->mport_id);
108 *hw_addr_len = ETH_ALEN;
112 static int efx_devlink_port_addr_set(struct devlink_port *port,
113 const u8 *hw_addr, int hw_addr_len,
114 struct netlink_ext_ack *extack)
116 MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_CLIENT_MAC_ADDRESSES_IN_LEN(1));
117 struct efx_devlink *devlink = devlink_priv(port->devlink);
118 struct mae_mport_desc *mport_desc;
123 mport_desc = container_of(port, struct mae_mport_desc, dl_port);
125 if (!ef100_mport_is_vf(mport_desc)) {
126 NL_SET_ERR_MSG_FMT(extack,
127 "port mac change not allowed (mport: %u)",
128 mport_desc->mport_id);
132 EFX_POPULATE_QWORD_3(pciefn,
133 PCIE_FUNCTION_PF, PCIE_FUNCTION_PF_NULL,
134 PCIE_FUNCTION_VF, mport_desc->vf_idx,
135 PCIE_FUNCTION_INTF, PCIE_INTERFACE_CALLER);
137 rc = efx_ef100_lookup_client_id(devlink->efx, pciefn, &client_id);
139 NL_SET_ERR_MSG_FMT(extack,
140 "No internal client_ID for port (mport: %u)",
141 mport_desc->mport_id);
145 MCDI_SET_DWORD(inbuf, SET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
148 ether_addr_copy(MCDI_PTR(inbuf, SET_CLIENT_MAC_ADDRESSES_IN_MAC_ADDRS),
151 rc = efx_mcdi_rpc(devlink->efx, MC_CMD_SET_CLIENT_MAC_ADDRESSES, inbuf,
152 sizeof(inbuf), NULL, 0, NULL);
154 NL_SET_ERR_MSG_FMT(extack,
155 "sfc MC_CMD_SET_CLIENT_MAC_ADDRESSES mcdi error (mport: %u)",
156 mport_desc->mport_id);
163 static int efx_devlink_info_nvram_partition(struct efx_nic *efx,
164 struct devlink_info_req *req,
165 unsigned int partition_type,
166 const char *version_name)
168 char buf[EFX_MAX_VERSION_INFO_LEN];
172 rc = efx_mcdi_nvram_metadata(efx, partition_type, NULL, version, NULL,
175 /* If the partition does not exist, that is not an error. */
180 netif_err(efx, drv, efx->net_dev, "mcdi nvram %s: failed (rc=%d)\n",
185 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u", version[0],
186 version[1], version[2], version[3]);
187 devlink_info_version_stored_put(req, version_name, buf);
192 static int efx_devlink_info_stored_versions(struct efx_nic *efx,
193 struct devlink_info_req *req)
197 /* We do not care here about the specific error but just if an error
198 * happened. The specific error will be reported inside the call
199 * through system messages, and if any error happened in any call
200 * below, we report it through extack.
202 err = efx_devlink_info_nvram_partition(efx, req,
203 NVRAM_PARTITION_TYPE_BUNDLE,
204 DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID);
206 err |= efx_devlink_info_nvram_partition(efx, req,
207 NVRAM_PARTITION_TYPE_MC_FIRMWARE,
208 DEVLINK_INFO_VERSION_GENERIC_FW_MGMT);
210 err |= efx_devlink_info_nvram_partition(efx, req,
211 NVRAM_PARTITION_TYPE_SUC_FIRMWARE,
212 EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC);
214 err |= efx_devlink_info_nvram_partition(efx, req,
215 NVRAM_PARTITION_TYPE_EXPANSION_ROM,
216 EFX_DEVLINK_INFO_VERSION_FW_EXPROM);
218 err |= efx_devlink_info_nvram_partition(efx, req,
219 NVRAM_PARTITION_TYPE_EXPANSION_UEFI,
220 EFX_DEVLINK_INFO_VERSION_FW_UEFI);
224 #define EFX_VER_FLAG(_f) \
225 (MC_CMD_GET_VERSION_V5_OUT_ ## _f ## _PRESENT_LBN)
227 static void efx_devlink_info_running_v2(struct efx_nic *efx,
228 struct devlink_info_req *req,
229 unsigned int flags, efx_dword_t *outbuf)
231 char buf[EFX_MAX_VERSION_INFO_LEN];
233 const __le32 *dwords;
237 struct rtc_time build_date;
238 unsigned int build_id;
240 __maybe_unused u64 tstamp;
242 if (flags & BIT(EFX_VER_FLAG(BOARD_EXT_INFO))) {
243 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%s",
244 MCDI_PTR(outbuf, GET_VERSION_V2_OUT_BOARD_NAME));
245 devlink_info_version_fixed_put(req,
246 DEVLINK_INFO_VERSION_GENERIC_BOARD_ID,
249 /* Favour full board version if present (in V5 or later) */
250 if (~flags & BIT(EFX_VER_FLAG(BOARD_VERSION))) {
251 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u",
253 GET_VERSION_V2_OUT_BOARD_REVISION));
254 devlink_info_version_fixed_put(req,
255 DEVLINK_INFO_VERSION_GENERIC_BOARD_REV,
259 ver.str = MCDI_PTR(outbuf, GET_VERSION_V2_OUT_BOARD_SERIAL);
261 devlink_info_board_serial_number_put(req, ver.str);
264 if (flags & BIT(EFX_VER_FLAG(FPGA_EXT_INFO))) {
265 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
266 GET_VERSION_V2_OUT_FPGA_VERSION);
267 offset = snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u_%c%u",
268 le32_to_cpu(ver.dwords[0]),
269 'A' + le32_to_cpu(ver.dwords[1]),
270 le32_to_cpu(ver.dwords[2]));
272 ver.str = MCDI_PTR(outbuf, GET_VERSION_V2_OUT_FPGA_EXTRA);
274 snprintf(&buf[offset], EFX_MAX_VERSION_INFO_LEN - offset,
277 devlink_info_version_running_put(req,
278 EFX_DEVLINK_INFO_VERSION_FPGA_REV,
282 if (flags & BIT(EFX_VER_FLAG(CMC_EXT_INFO))) {
283 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
284 GET_VERSION_V2_OUT_CMCFW_VERSION);
285 offset = snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
286 le32_to_cpu(ver.dwords[0]),
287 le32_to_cpu(ver.dwords[1]),
288 le32_to_cpu(ver.dwords[2]),
289 le32_to_cpu(ver.dwords[3]));
291 #ifdef CONFIG_RTC_LIB
292 tstamp = MCDI_QWORD(outbuf,
293 GET_VERSION_V2_OUT_CMCFW_BUILD_DATE);
295 rtc_time64_to_tm(tstamp, &build_date);
296 snprintf(&buf[offset], EFX_MAX_VERSION_INFO_LEN - offset,
297 " (%ptRd)", &build_date);
301 devlink_info_version_running_put(req,
302 EFX_DEVLINK_INFO_VERSION_FW_MGMT_CMC,
306 ver.words = (__le16 *)MCDI_PTR(outbuf, GET_VERSION_V2_OUT_VERSION);
307 offset = snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
308 le16_to_cpu(ver.words[0]), le16_to_cpu(ver.words[1]),
309 le16_to_cpu(ver.words[2]), le16_to_cpu(ver.words[3]));
310 if (flags & BIT(EFX_VER_FLAG(MCFW_EXT_INFO))) {
311 build_id = MCDI_DWORD(outbuf, GET_VERSION_V2_OUT_MCFW_BUILD_ID);
312 snprintf(&buf[offset], EFX_MAX_VERSION_INFO_LEN - offset,
313 " (%x) %s", build_id,
314 MCDI_PTR(outbuf, GET_VERSION_V2_OUT_MCFW_BUILD_NAME));
316 devlink_info_version_running_put(req,
317 DEVLINK_INFO_VERSION_GENERIC_FW_MGMT,
320 if (flags & BIT(EFX_VER_FLAG(SUCFW_EXT_INFO))) {
321 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
322 GET_VERSION_V2_OUT_SUCFW_VERSION);
323 #ifdef CONFIG_RTC_LIB
324 tstamp = MCDI_QWORD(outbuf,
325 GET_VERSION_V2_OUT_SUCFW_BUILD_DATE);
326 rtc_time64_to_tm(tstamp, &build_date);
328 memset(&build_date, 0, sizeof(build_date));
330 build_id = MCDI_DWORD(outbuf, GET_VERSION_V2_OUT_SUCFW_CHIP_ID);
332 snprintf(buf, EFX_MAX_VERSION_INFO_LEN,
333 "%u.%u.%u.%u type %x (%ptRd)",
334 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
335 le32_to_cpu(ver.dwords[2]), le32_to_cpu(ver.dwords[3]),
336 build_id, &build_date);
338 devlink_info_version_running_put(req,
339 EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC,
344 static void efx_devlink_info_running_v3(struct efx_nic *efx,
345 struct devlink_info_req *req,
346 unsigned int flags, efx_dword_t *outbuf)
348 char buf[EFX_MAX_VERSION_INFO_LEN];
350 const __le32 *dwords;
355 if (flags & BIT(EFX_VER_FLAG(DATAPATH_HW_VERSION))) {
356 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
357 GET_VERSION_V3_OUT_DATAPATH_HW_VERSION);
359 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u",
360 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
361 le32_to_cpu(ver.dwords[2]));
363 devlink_info_version_running_put(req,
364 EFX_DEVLINK_INFO_VERSION_DATAPATH_HW,
368 if (flags & BIT(EFX_VER_FLAG(DATAPATH_FW_VERSION))) {
369 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
370 GET_VERSION_V3_OUT_DATAPATH_FW_VERSION);
372 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u",
373 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
374 le32_to_cpu(ver.dwords[2]));
376 devlink_info_version_running_put(req,
377 EFX_DEVLINK_INFO_VERSION_DATAPATH_FW,
382 static void efx_devlink_info_running_v4(struct efx_nic *efx,
383 struct devlink_info_req *req,
384 unsigned int flags, efx_dword_t *outbuf)
386 char buf[EFX_MAX_VERSION_INFO_LEN];
388 const __le32 *dwords;
393 if (flags & BIT(EFX_VER_FLAG(SOC_BOOT_VERSION))) {
394 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
395 GET_VERSION_V4_OUT_SOC_BOOT_VERSION);
397 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
398 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
399 le32_to_cpu(ver.dwords[2]),
400 le32_to_cpu(ver.dwords[3]));
402 devlink_info_version_running_put(req,
403 EFX_DEVLINK_INFO_VERSION_SOC_BOOT,
407 if (flags & BIT(EFX_VER_FLAG(SOC_UBOOT_VERSION))) {
408 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
409 GET_VERSION_V4_OUT_SOC_UBOOT_VERSION);
411 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
412 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
413 le32_to_cpu(ver.dwords[2]),
414 le32_to_cpu(ver.dwords[3]));
416 devlink_info_version_running_put(req,
417 EFX_DEVLINK_INFO_VERSION_SOC_UBOOT,
421 if (flags & BIT(EFX_VER_FLAG(SOC_MAIN_ROOTFS_VERSION))) {
422 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
423 GET_VERSION_V4_OUT_SOC_MAIN_ROOTFS_VERSION);
425 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
426 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
427 le32_to_cpu(ver.dwords[2]),
428 le32_to_cpu(ver.dwords[3]));
430 devlink_info_version_running_put(req,
431 EFX_DEVLINK_INFO_VERSION_SOC_MAIN,
435 if (flags & BIT(EFX_VER_FLAG(SOC_RECOVERY_BUILDROOT_VERSION))) {
436 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
437 GET_VERSION_V4_OUT_SOC_RECOVERY_BUILDROOT_VERSION);
439 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
440 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
441 le32_to_cpu(ver.dwords[2]),
442 le32_to_cpu(ver.dwords[3]));
444 devlink_info_version_running_put(req,
445 EFX_DEVLINK_INFO_VERSION_SOC_RECOVERY,
449 if (flags & BIT(EFX_VER_FLAG(SUCFW_VERSION)) &&
450 ~flags & BIT(EFX_VER_FLAG(SUCFW_EXT_INFO))) {
451 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
452 GET_VERSION_V4_OUT_SUCFW_VERSION);
454 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
455 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
456 le32_to_cpu(ver.dwords[2]),
457 le32_to_cpu(ver.dwords[3]));
459 devlink_info_version_running_put(req,
460 EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC,
465 static void efx_devlink_info_running_v5(struct efx_nic *efx,
466 struct devlink_info_req *req,
467 unsigned int flags, efx_dword_t *outbuf)
469 char buf[EFX_MAX_VERSION_INFO_LEN];
471 const __le32 *dwords;
476 if (flags & BIT(EFX_VER_FLAG(BOARD_VERSION))) {
477 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
478 GET_VERSION_V5_OUT_BOARD_VERSION);
480 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
481 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
482 le32_to_cpu(ver.dwords[2]),
483 le32_to_cpu(ver.dwords[3]));
485 devlink_info_version_running_put(req,
486 DEVLINK_INFO_VERSION_GENERIC_BOARD_REV,
490 if (flags & BIT(EFX_VER_FLAG(BUNDLE_VERSION))) {
491 ver.dwords = (__le32 *)MCDI_PTR(outbuf,
492 GET_VERSION_V5_OUT_BUNDLE_VERSION);
494 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
495 le32_to_cpu(ver.dwords[0]), le32_to_cpu(ver.dwords[1]),
496 le32_to_cpu(ver.dwords[2]),
497 le32_to_cpu(ver.dwords[3]));
499 devlink_info_version_running_put(req,
500 DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID,
505 static int efx_devlink_info_running_versions(struct efx_nic *efx,
506 struct devlink_info_req *req)
508 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_VERSION_V5_OUT_LEN);
509 MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_VERSION_EXT_IN_LEN);
510 char buf[EFX_MAX_VERSION_INFO_LEN];
512 const __le32 *dwords;
520 rc = efx_mcdi_rpc(efx, MC_CMD_GET_VERSION, inbuf, sizeof(inbuf),
521 outbuf, sizeof(outbuf), &outlength);
522 if (rc || outlength < MC_CMD_GET_VERSION_OUT_LEN) {
523 netif_err(efx, drv, efx->net_dev,
524 "mcdi MC_CMD_GET_VERSION failed\n");
528 /* Handle previous output */
529 if (outlength < MC_CMD_GET_VERSION_V2_OUT_LEN) {
530 ver.words = (__le16 *)MCDI_PTR(outbuf,
531 GET_VERSION_EXT_OUT_VERSION);
532 snprintf(buf, EFX_MAX_VERSION_INFO_LEN, "%u.%u.%u.%u",
533 le16_to_cpu(ver.words[0]),
534 le16_to_cpu(ver.words[1]),
535 le16_to_cpu(ver.words[2]),
536 le16_to_cpu(ver.words[3]));
538 devlink_info_version_running_put(req,
539 DEVLINK_INFO_VERSION_GENERIC_FW_MGMT,
544 /* Handle V2 additions */
545 flags = MCDI_DWORD(outbuf, GET_VERSION_V2_OUT_FLAGS);
546 efx_devlink_info_running_v2(efx, req, flags, outbuf);
548 if (outlength < MC_CMD_GET_VERSION_V3_OUT_LEN)
551 /* Handle V3 additions */
552 efx_devlink_info_running_v3(efx, req, flags, outbuf);
554 if (outlength < MC_CMD_GET_VERSION_V4_OUT_LEN)
557 /* Handle V4 additions */
558 efx_devlink_info_running_v4(efx, req, flags, outbuf);
560 if (outlength < MC_CMD_GET_VERSION_V5_OUT_LEN)
563 /* Handle V5 additions */
564 efx_devlink_info_running_v5(efx, req, flags, outbuf);
569 #define EFX_MAX_SERIALNUM_LEN (ETH_ALEN * 2 + 1)
571 static int efx_devlink_info_board_cfg(struct efx_nic *efx,
572 struct devlink_info_req *req)
574 char sn[EFX_MAX_SERIALNUM_LEN];
575 u8 mac_address[ETH_ALEN];
578 rc = efx_mcdi_get_board_cfg(efx, (u8 *)mac_address, NULL, NULL);
580 snprintf(sn, EFX_MAX_SERIALNUM_LEN, "%pm", mac_address);
581 devlink_info_serial_number_put(req, sn);
586 static int efx_devlink_info_get(struct devlink *devlink,
587 struct devlink_info_req *req,
588 struct netlink_ext_ack *extack)
590 struct efx_devlink *devlink_private = devlink_priv(devlink);
591 struct efx_nic *efx = devlink_private->efx;
594 /* Several different MCDI commands are used. We report if errors
595 * happened through extack. Specific error information via system
596 * messages inside the calls.
598 err = efx_devlink_info_board_cfg(efx, req);
600 err |= efx_devlink_info_stored_versions(efx, req);
602 err |= efx_devlink_info_running_versions(efx, req);
605 NL_SET_ERR_MSG_MOD(extack, "Errors when getting device info. Check system messages");
610 static const struct devlink_ops sfc_devlink_ops = {
611 .info_get = efx_devlink_info_get,
612 #ifdef CONFIG_SFC_SRIOV
613 .port_function_hw_addr_get = efx_devlink_port_addr_get,
614 .port_function_hw_addr_set = efx_devlink_port_addr_set,
618 #ifdef CONFIG_SFC_SRIOV
619 static struct devlink_port *ef100_set_devlink_port(struct efx_nic *efx, u32 idx)
621 struct mae_mport_desc *mport;
625 if (efx_mae_lookup_mport(efx, idx, &id)) {
626 /* This should not happen. */
627 if (idx == MAE_MPORT_DESC_VF_IDX_NULL)
628 pci_warn_once(efx->pci_dev, "No mport ID found for PF.\n");
630 pci_warn_once(efx->pci_dev, "No mport ID found for VF %u.\n",
635 mport = efx_mae_get_mport(efx, id);
637 /* This should not happen. */
638 if (idx == MAE_MPORT_DESC_VF_IDX_NULL)
639 pci_warn_once(efx->pci_dev, "No mport found for PF.\n");
641 pci_warn_once(efx->pci_dev, "No mport found for VF %u.\n",
646 rc = efx_devlink_add_port(efx, mport);
648 if (idx == MAE_MPORT_DESC_VF_IDX_NULL)
649 pci_warn(efx->pci_dev,
650 "devlink port creation for PF failed.\n");
652 pci_warn(efx->pci_dev,
653 "devlink_port creation for VF %u failed.\n",
658 return &mport->dl_port;
661 void ef100_rep_set_devlink_port(struct efx_rep *efv)
663 efv->dl_port = ef100_set_devlink_port(efv->parent, efv->idx);
666 void ef100_pf_set_devlink_port(struct efx_nic *efx)
668 efx->dl_port = ef100_set_devlink_port(efx, MAE_MPORT_DESC_VF_IDX_NULL);
671 void ef100_rep_unset_devlink_port(struct efx_rep *efv)
673 efx_devlink_del_port(efv->dl_port);
676 void ef100_pf_unset_devlink_port(struct efx_nic *efx)
678 efx_devlink_del_port(efx->dl_port);
682 void efx_fini_devlink_lock(struct efx_nic *efx)
685 devl_lock(efx->devlink);
688 void efx_fini_devlink_and_unlock(struct efx_nic *efx)
691 devl_unregister(efx->devlink);
692 devl_unlock(efx->devlink);
693 devlink_free(efx->devlink);
698 int efx_probe_devlink_and_lock(struct efx_nic *efx)
700 struct efx_devlink *devlink_private;
702 if (efx->type->is_vf)
705 efx->devlink = devlink_alloc(&sfc_devlink_ops,
706 sizeof(struct efx_devlink),
711 devl_lock(efx->devlink);
712 devlink_private = devlink_priv(efx->devlink);
713 devlink_private->efx = efx;
715 devl_register(efx->devlink);
720 void efx_probe_devlink_unlock(struct efx_nic *efx)
725 devl_unlock(efx->devlink);