Commit fa34a514 authored by Alejandro Lucero's avatar Alejandro Lucero Committed by Paolo Abeni
Browse files

sfc: add devlink support for ef100



Add devlink infrastructure support. Further patches add devlink
info and devlink port support.

Signed-off-by: default avatarAlejandro Lucero <alejandro.lucero-palau@amd.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Acked-by: default avatarMartin Habets <habetsm.xilinx@gmail.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e9ab2559
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ config SFC
	depends on PTP_1588_CLOCK_OPTIONAL
	select MDIO
	select CRC32
	select NET_DEVLINK
	help
	  This driver supports 10/40-gigabit Ethernet cards based on
	  the Solarflare SFC9100-family controllers.
+2 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \
			   mcdi.o mcdi_port.o mcdi_port_common.o \
			   mcdi_functions.o mcdi_filters.o mcdi_mon.o \
			   ef100.o ef100_nic.o ef100_netdev.o \
			   ef100_ethtool.o ef100_rx.o ef100_tx.o
			   ef100_ethtool.o ef100_rx.o ef100_tx.o \
			   efx_devlink.o
sfc-$(CONFIG_SFC_MTD)	+= mtd.o
sfc-$(CONFIG_SFC_SRIOV)	+= sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \
                           mae.o tc.o tc_bindings.o tc_counters.o
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "rx_common.h"
#include "ef100_sriov.h"
#include "tc_bindings.h"
#include "efx_devlink.h"

static void ef100_update_name(struct efx_nic *efx)
{
@@ -332,6 +333,7 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
		efx_ef100_pci_sriov_disable(efx, true);
#endif

	efx_fini_devlink_lock(efx);
	ef100_unregister_netdev(efx);

#ifdef CONFIG_SFC_SRIOV
@@ -345,6 +347,8 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
	kfree(efx->phy_data);
	efx->phy_data = NULL;

	efx_fini_devlink_and_unlock(efx);

	free_netdev(efx->net_dev);
	efx->net_dev = NULL;
	efx->state = STATE_PROBED;
@@ -405,6 +409,11 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
	/* Don't fail init if RSS setup doesn't work. */
	efx_mcdi_push_default_indir_table(efx, efx->n_rx_channels);

	/* devlink creation, registration and lock */
	rc = efx_probe_devlink_and_lock(efx);
	if (rc)
		pci_info(efx->pci_dev, "devlink registration failed");

	rc = ef100_register_netdev(efx);
	if (rc)
		goto fail;
@@ -424,5 +433,6 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
	}

fail:
	efx_probe_devlink_unlock(efx);
	return rc;
}
+65 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/****************************************************************************
 * Driver for AMD network controllers and boards
 * Copyright (C) 2023, Advanced Micro Devices, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, incorporated herein by reference.
 */

#include "net_driver.h"
#include "efx_devlink.h"

struct efx_devlink {
	struct efx_nic *efx;
};

static const struct devlink_ops sfc_devlink_ops = {
};

void efx_fini_devlink_lock(struct efx_nic *efx)
{
	if (efx->devlink)
		devl_lock(efx->devlink);
}

void efx_fini_devlink_and_unlock(struct efx_nic *efx)
{
	if (efx->devlink) {
		devl_unregister(efx->devlink);
		devl_unlock(efx->devlink);
		devlink_free(efx->devlink);
		efx->devlink = NULL;
	}
}

int efx_probe_devlink_and_lock(struct efx_nic *efx)
{
	struct efx_devlink *devlink_private;

	if (efx->type->is_vf)
		return 0;

	efx->devlink = devlink_alloc(&sfc_devlink_ops,
				     sizeof(struct efx_devlink),
				     &efx->pci_dev->dev);
	if (!efx->devlink)
		return -ENOMEM;

	devl_lock(efx->devlink);
	devlink_private = devlink_priv(efx->devlink);
	devlink_private->efx = efx;

	devl_register(efx->devlink);

	return 0;
}

void efx_probe_devlink_unlock(struct efx_nic *efx)
{
	if (!efx->devlink)
		return;

	devl_unlock(efx->devlink);
}
+22 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/****************************************************************************
 * Driver for AMD network controllers and boards
 * Copyright (C) 2023, Advanced Micro Devices, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, incorporated herein by reference.
 */

#ifndef _EFX_DEVLINK_H
#define _EFX_DEVLINK_H

#include "net_driver.h"
#include <net/devlink.h>

int efx_probe_devlink_and_lock(struct efx_nic *efx);
void efx_probe_devlink_unlock(struct efx_nic *efx);
void efx_fini_devlink_lock(struct efx_nic *efx);
void efx_fini_devlink_and_unlock(struct efx_nic *efx);

#endif	/* _EFX_DEVLINK_H */
Loading