Commit fa15072b authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'sfc-devlink-support-for-ef100'

Alejandro Lucero says:

====================
sfc: devlink support for ef100

This patchset adds devlink port support for ef100 allowing setting VFs
mac addresses through the VF representor devlink ports.

Basic devlink infrastructure is first introduced, then support for info
command. Next changes for enumerating MAE ports which will be used for
devlink port creation when netdevs are registered.

Adding support for devlink port_function_hw_addr_get requires changes in
the ef100 driver for getting the mac address based on a client handle.
This allows to obtain VFs mac addresses during netdev initialization as
well what is included in patch 6.

Such client handle is used in patches 7 and 8 for getting and setting
devlink port addresses.
====================

Link: https://lore.kernel.org/r/20230215090828.11697-1-alejandro.lucero-palau@amd.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents e9ab2559 3b6096c9
...@@ -66,3 +66,4 @@ parameters, info versions, and other features it supports. ...@@ -66,3 +66,4 @@ parameters, info versions, and other features it supports.
prestera prestera
iosm iosm
octeontx2 octeontx2
sfc
.. SPDX-License-Identifier: GPL-2.0
===================
sfc devlink support
===================
This document describes the devlink features implemented by the ``sfc``
device driver for the ef100 device.
Info versions
=============
The ``sfc`` driver reports the following versions
.. list-table:: devlink info versions implemented
:widths: 5 5 90
* - Name
- Type
- Description
* - ``fw.mgmt.suc``
- running
- For boards where the management function is split between multiple
control units, this is the SUC control unit's firmware version.
* - ``fw.mgmt.cmc``
- running
- For boards where the management function is split between multiple
control units, this is the CMC control unit's firmware version.
* - ``fpga.rev``
- running
- FPGA design revision.
* - ``fpga.app``
- running
- Datapath programmable logic version.
* - ``fw.app``
- running
- Datapath software/microcode/firmware version.
* - ``coproc.boot``
- running
- SmartNIC application co-processor (APU) first stage boot loader version.
* - ``coproc.uboot``
- running
- SmartNIC application co-processor (APU) co-operating system loader version.
* - ``coproc.main``
- running
- SmartNIC application co-processor (APU) main operating system version.
* - ``coproc.recovery``
- running
- SmartNIC application co-processor (APU) recovery operating system version.
* - ``fw.exprom``
- running
- Expansion ROM version. For boards where the expansion ROM is split between
multiple images (e.g. PXE and UEFI), this is the specifically the PXE boot
ROM version.
* - ``fw.uefi``
- running
- UEFI driver version (No UNDI support).
...@@ -18937,6 +18937,7 @@ M: Edward Cree <ecree.xilinx@gmail.com> ...@@ -18937,6 +18937,7 @@ M: Edward Cree <ecree.xilinx@gmail.com>
M: Martin Habets <habetsm.xilinx@gmail.com> M: Martin Habets <habetsm.xilinx@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
S: Supported S: Supported
F: Documentation/networking/devlink/sfc.rst
F: drivers/net/ethernet/sfc/ F: drivers/net/ethernet/sfc/
SFF/SFP/SFP+ MODULE SUPPORT SFF/SFP/SFP+ MODULE SUPPORT
......
...@@ -22,6 +22,7 @@ config SFC ...@@ -22,6 +22,7 @@ config SFC
depends on PTP_1588_CLOCK_OPTIONAL depends on PTP_1588_CLOCK_OPTIONAL
select MDIO select MDIO
select CRC32 select CRC32
select NET_DEVLINK
help help
This driver supports 10/40-gigabit Ethernet cards based on This driver supports 10/40-gigabit Ethernet cards based on
the Solarflare SFC9100-family controllers. the Solarflare SFC9100-family controllers.
......
...@@ -6,7 +6,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ ...@@ -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.o mcdi_port.o mcdi_port_common.o \
mcdi_functions.o mcdi_filters.o mcdi_mon.o \ mcdi_functions.o mcdi_filters.o mcdi_mon.o \
ef100.o ef100_nic.o ef100_netdev.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_MTD) += mtd.o
sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.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 mae.o tc.o tc_bindings.o tc_counters.o
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "rx_common.h" #include "rx_common.h"
#include "ef100_sriov.h" #include "ef100_sriov.h"
#include "tc_bindings.h" #include "tc_bindings.h"
#include "efx_devlink.h"
static void ef100_update_name(struct efx_nic *efx) static void ef100_update_name(struct efx_nic *efx)
{ {
...@@ -332,9 +333,11 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) ...@@ -332,9 +333,11 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
efx_ef100_pci_sriov_disable(efx, true); efx_ef100_pci_sriov_disable(efx, true);
#endif #endif
efx_fini_devlink_lock(efx);
ef100_unregister_netdev(efx); ef100_unregister_netdev(efx);
#ifdef CONFIG_SFC_SRIOV #ifdef CONFIG_SFC_SRIOV
ef100_pf_unset_devlink_port(efx);
efx_fini_tc(efx); efx_fini_tc(efx);
#endif #endif
...@@ -345,6 +348,8 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) ...@@ -345,6 +348,8 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
kfree(efx->phy_data); kfree(efx->phy_data);
efx->phy_data = NULL; efx->phy_data = NULL;
efx_fini_devlink_and_unlock(efx);
free_netdev(efx->net_dev); free_netdev(efx->net_dev);
efx->net_dev = NULL; efx->net_dev = NULL;
efx->state = STATE_PROBED; efx->state = STATE_PROBED;
...@@ -354,6 +359,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) ...@@ -354,6 +359,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
{ {
struct efx_nic *efx = &probe_data->efx; struct efx_nic *efx = &probe_data->efx;
struct efx_probe_data **probe_ptr; struct efx_probe_data **probe_ptr;
struct ef100_nic_data *nic_data;
struct net_device *net_dev; struct net_device *net_dev;
int rc; int rc;
...@@ -405,6 +411,20 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) ...@@ -405,6 +411,20 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
/* Don't fail init if RSS setup doesn't work. */ /* Don't fail init if RSS setup doesn't work. */
efx_mcdi_push_default_indir_table(efx, efx->n_rx_channels); efx_mcdi_push_default_indir_table(efx, efx->n_rx_channels);
nic_data = efx->nic_data;
rc = ef100_get_mac_address(efx, net_dev->perm_addr, CLIENT_HANDLE_SELF,
efx->type->is_vf);
if (rc)
return rc;
/* Assign MAC address */
eth_hw_addr_set(net_dev, net_dev->perm_addr);
ether_addr_copy(nic_data->port_id, net_dev->perm_addr);
/* 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); rc = ef100_register_netdev(efx);
if (rc) if (rc)
goto fail; goto fail;
...@@ -413,6 +433,9 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) ...@@ -413,6 +433,9 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
rc = ef100_probe_netdev_pf(efx); rc = ef100_probe_netdev_pf(efx);
if (rc) if (rc)
goto fail; goto fail;
#ifdef CONFIG_SFC_SRIOV
ef100_pf_set_devlink_port(efx);
#endif
} }
efx->netdev_notifier.notifier_call = ef100_netdev_event; efx->netdev_notifier.notifier_call = ef100_netdev_event;
...@@ -423,6 +446,13 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) ...@@ -423,6 +446,13 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
goto fail; goto fail;
} }
efx_probe_devlink_unlock(efx);
return rc;
fail: fail:
#ifdef CONFIG_SFC_SRIOV
/* remove devlink port if does exist */
ef100_pf_unset_devlink_port(efx);
#endif
efx_probe_devlink_unlock(efx);
return rc; return rc;
} }
...@@ -130,23 +130,34 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx) ...@@ -130,23 +130,34 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx)
/* MCDI calls /* MCDI calls
*/ */
static int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address) int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
int client_handle, bool empty_ok)
{ {
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN); MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1));
MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN);
size_t outlen; size_t outlen;
int rc; int rc;
BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0); BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0);
MCDI_SET_DWORD(inbuf, GET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
client_handle);
rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0, rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_MAC_ADDRESSES, inbuf,
outbuf, sizeof(outbuf), &outlen); sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
if (rc) if (rc)
return rc; return rc;
if (outlen < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)
return -EIO;
if (outlen >= MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)) {
ether_addr_copy(mac_address, ether_addr_copy(mac_address,
MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE)); MCDI_PTR(outbuf, GET_CLIENT_MAC_ADDRESSES_OUT_MAC_ADDRS));
} else if (empty_ok) {
pci_warn(efx->pci_dev,
"No MAC address provisioned for client ID %#x.\n",
client_handle);
eth_zero_addr(mac_address);
} else {
return -ENOENT;
}
return 0; return 0;
} }
...@@ -736,7 +747,7 @@ static int efx_ef100_get_base_mport(struct efx_nic *efx) ...@@ -736,7 +747,7 @@ static int efx_ef100_get_base_mport(struct efx_nic *efx)
/* Construct mport selector for "physical network port" */ /* Construct mport selector for "physical network port" */
efx_mae_mport_wire(efx, &selector); efx_mae_mport_wire(efx, &selector);
/* Look up actual mport ID */ /* Look up actual mport ID */
rc = efx_mae_lookup_mport(efx, selector, &id); rc = efx_mae_fw_lookup_mport(efx, selector, &id);
if (rc) if (rc)
return rc; return rc;
/* The ID should always fit in 16 bits, because that's how wide the /* The ID should always fit in 16 bits, because that's how wide the
...@@ -747,6 +758,19 @@ static int efx_ef100_get_base_mport(struct efx_nic *efx) ...@@ -747,6 +758,19 @@ static int efx_ef100_get_base_mport(struct efx_nic *efx)
id); id);
nic_data->base_mport = id; nic_data->base_mport = id;
nic_data->have_mport = true; nic_data->have_mport = true;
/* Construct mport selector for "calling PF" */
efx_mae_mport_uplink(efx, &selector);
/* Look up actual mport ID */
rc = efx_mae_fw_lookup_mport(efx, selector, &id);
if (rc)
return rc;
if (id >> 16)
netif_warn(efx, probe, efx->net_dev, "Bad own m-port id %#x\n",
id);
nic_data->own_mport = id;
nic_data->have_own_mport = true;
return 0; return 0;
} }
#endif #endif
...@@ -1098,19 +1122,39 @@ static int ef100_probe_main(struct efx_nic *efx) ...@@ -1098,19 +1122,39 @@ static int ef100_probe_main(struct efx_nic *efx)
return rc; return rc;
} }
/* MCDI commands are related to the same device issuing them. This function
* allows to do an MCDI command on behalf of another device, mainly PFs setting
* things for VFs.
*/
int efx_ef100_lookup_client_id(struct efx_nic *efx, efx_qword_t pciefn, u32 *id)
{
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_HANDLE_OUT_LEN);
MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_HANDLE_IN_LEN);
u64 pciefn_flat = le64_to_cpu(pciefn.u64[0]);
size_t outlen;
int rc;
MCDI_SET_DWORD(inbuf, GET_CLIENT_HANDLE_IN_TYPE,
MC_CMD_GET_CLIENT_HANDLE_IN_TYPE_FUNC);
MCDI_SET_QWORD(inbuf, GET_CLIENT_HANDLE_IN_FUNC,
pciefn_flat);
rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_HANDLE, inbuf, sizeof(inbuf),
outbuf, sizeof(outbuf), &outlen);
if (rc)
return rc;
if (outlen < sizeof(outbuf))
return -EIO;
*id = MCDI_DWORD(outbuf, GET_CLIENT_HANDLE_OUT_HANDLE);
return 0;
}
int ef100_probe_netdev_pf(struct efx_nic *efx) int ef100_probe_netdev_pf(struct efx_nic *efx)
{ {
struct ef100_nic_data *nic_data = efx->nic_data; struct ef100_nic_data *nic_data = efx->nic_data;
struct net_device *net_dev = efx->net_dev; struct net_device *net_dev = efx->net_dev;
int rc; int rc;
rc = ef100_get_mac_address(efx, net_dev->perm_addr);
if (rc)
goto fail;
/* Assign MAC address */
eth_hw_addr_set(net_dev, net_dev->perm_addr);
memcpy(nic_data->port_id, net_dev->perm_addr, ETH_ALEN);
if (!nic_data->grp_mae) if (!nic_data->grp_mae)
return 0; return 0;
...@@ -1126,6 +1170,14 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) ...@@ -1126,6 +1170,14 @@ int ef100_probe_netdev_pf(struct efx_nic *efx)
rc); rc);
} }
rc = efx_init_mae(efx);
if (rc)
netif_warn(efx, probe, net_dev,
"Failed to init MAE rc %d; representors will not function\n",
rc);
else
efx_ef100_init_reps(efx);
rc = efx_init_tc(efx); rc = efx_init_tc(efx);
if (rc) { if (rc) {
/* Either we don't have an MAE at all (i.e. legacy v-switching), /* Either we don't have an MAE at all (i.e. legacy v-switching),
...@@ -1142,9 +1194,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) ...@@ -1142,9 +1194,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx)
efx->fixed_features |= NETIF_F_HW_TC; efx->fixed_features |= NETIF_F_HW_TC;
} }
#endif #endif
return 0;
fail:
return rc; return rc;
} }
...@@ -1157,6 +1206,12 @@ void ef100_remove(struct efx_nic *efx) ...@@ -1157,6 +1206,12 @@ void ef100_remove(struct efx_nic *efx)
{ {
struct ef100_nic_data *nic_data = efx->nic_data; struct ef100_nic_data *nic_data = efx->nic_data;
#ifdef CONFIG_SFC_SRIOV
if (efx->mae) {
efx_ef100_fini_reps(efx);
efx_fini_mae(efx);
}
#endif
efx_mcdi_detach(efx); efx_mcdi_detach(efx);
efx_mcdi_fini(efx); efx_mcdi_fini(efx);
if (nic_data) if (nic_data)
......
...@@ -74,6 +74,10 @@ struct ef100_nic_data { ...@@ -74,6 +74,10 @@ struct ef100_nic_data {
u64 stats[EF100_STAT_COUNT]; u64 stats[EF100_STAT_COUNT];
u32 base_mport; u32 base_mport;
bool have_mport; /* base_mport was populated successfully */ bool have_mport; /* base_mport was populated successfully */
u32 own_mport;
u32 local_mae_intf; /* interface_idx that corresponds to us, in mport enumerate */
bool have_own_mport; /* own_mport was populated successfully */
bool have_local_intf; /* local_mae_intf was populated successfully */
bool grp_mae; /* MAE Privilege */ bool grp_mae; /* MAE Privilege */
u16 tso_max_hdr_len; u16 tso_max_hdr_len;
u16 tso_max_payload_num_segs; u16 tso_max_payload_num_segs;
...@@ -88,4 +92,7 @@ int efx_ef100_init_datapath_caps(struct efx_nic *efx); ...@@ -88,4 +92,7 @@ int efx_ef100_init_datapath_caps(struct efx_nic *efx);
int ef100_phy_probe(struct efx_nic *efx); int ef100_phy_probe(struct efx_nic *efx);
int ef100_filter_table_probe(struct efx_nic *efx); int ef100_filter_table_probe(struct efx_nic *efx);
int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
int client_handle, bool empty_ok);
int efx_ef100_lookup_client_id(struct efx_nic *efx, efx_qword_t pciefn, u32 *id);
#endif /* EFX_EF100_NIC_H */ #endif /* EFX_EF100_NIC_H */
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
* by the Free Software Foundation, incorporated herein by reference. * by the Free Software Foundation, incorporated herein by reference.
*/ */
#include <linux/rhashtable.h>
#include "ef100_rep.h" #include "ef100_rep.h"
#include "ef100_netdev.h" #include "ef100_netdev.h"
#include "ef100_nic.h" #include "ef100_nic.h"
#include "mae.h" #include "mae.h"
#include "rx_common.h" #include "rx_common.h"
#include "tc_bindings.h" #include "tc_bindings.h"
#include "efx_devlink.h"
#define EFX_EF100_REP_DRIVER "efx_ef100_rep" #define EFX_EF100_REP_DRIVER "efx_ef100_rep"
...@@ -242,14 +244,11 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, ...@@ -242,14 +244,11 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx,
static int efx_ef100_configure_rep(struct efx_rep *efv) static int efx_ef100_configure_rep(struct efx_rep *efv)
{ {
struct efx_nic *efx = efv->parent; struct efx_nic *efx = efv->parent;
u32 selector;
int rc; int rc;
efv->rx_pring_size = EFX_REP_DEFAULT_PSEUDO_RING_SIZE; efv->rx_pring_size = EFX_REP_DEFAULT_PSEUDO_RING_SIZE;
/* Construct mport selector for corresponding VF */
efx_mae_mport_vf(efx, efv->idx, &selector);
/* Look up actual mport ID */ /* Look up actual mport ID */
rc = efx_mae_lookup_mport(efx, selector, &efv->mport); rc = efx_mae_lookup_mport(efx, efv->idx, &efv->mport);
if (rc) if (rc)
return rc; return rc;
pci_dbg(efx->pci_dev, "VF %u has mport ID %#x\n", efv->idx, efv->mport); pci_dbg(efx->pci_dev, "VF %u has mport ID %#x\n", efv->idx, efv->mport);
...@@ -299,6 +298,7 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i) ...@@ -299,6 +298,7 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i)
i, rc); i, rc);
goto fail1; goto fail1;
} }
ef100_rep_set_devlink_port(efv);
rc = register_netdev(efv->net_dev); rc = register_netdev(efv->net_dev);
if (rc) { if (rc) {
pci_err(efx->pci_dev, pci_err(efx->pci_dev,
...@@ -310,6 +310,7 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i) ...@@ -310,6 +310,7 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i)
efv->net_dev->name); efv->net_dev->name);
return 0; return 0;
fail2: fail2:
ef100_rep_unset_devlink_port(efv);
efx_ef100_deconfigure_rep(efv); efx_ef100_deconfigure_rep(efv);
fail1: fail1:
efx_ef100_rep_destroy_netdev(efv); efx_ef100_rep_destroy_netdev(efv);
...@@ -325,6 +326,7 @@ void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv) ...@@ -325,6 +326,7 @@ void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv)
return; return;
netif_dbg(efx, drv, rep_dev, "Removing VF representor\n"); netif_dbg(efx, drv, rep_dev, "Removing VF representor\n");
unregister_netdev(rep_dev); unregister_netdev(rep_dev);
ef100_rep_unset_devlink_port(efv);
efx_ef100_deconfigure_rep(efv); efx_ef100_deconfigure_rep(efv);
efx_ef100_rep_destroy_netdev(efv); efx_ef100_rep_destroy_netdev(efv);
} }
...@@ -341,6 +343,53 @@ void efx_ef100_fini_vfreps(struct efx_nic *efx) ...@@ -341,6 +343,53 @@ void efx_ef100_fini_vfreps(struct efx_nic *efx)
efx_ef100_vfrep_destroy(efx, efv); efx_ef100_vfrep_destroy(efx, efv);
} }
static bool ef100_mport_is_pcie_vnic(struct mae_mport_desc *mport_desc)
{
return mport_desc->mport_type == MAE_MPORT_DESC_MPORT_TYPE_VNIC &&
mport_desc->vnic_client_type == MAE_MPORT_DESC_VNIC_CLIENT_TYPE_FUNCTION;
}
bool ef100_mport_on_local_intf(struct efx_nic *efx,
struct mae_mport_desc *mport_desc)
{
struct ef100_nic_data *nic_data = efx->nic_data;
bool pcie_func;
pcie_func = ef100_mport_is_pcie_vnic(mport_desc);
return nic_data->have_local_intf && pcie_func &&
mport_desc->interface_idx == nic_data->local_mae_intf;
}
bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc)
{
bool pcie_func;
pcie_func = ef100_mport_is_pcie_vnic(mport_desc);
return pcie_func && (mport_desc->vf_idx != MAE_MPORT_DESC_VF_IDX_NULL);
}
void efx_ef100_init_reps(struct efx_nic *efx)
{
struct ef100_nic_data *nic_data = efx->nic_data;
int rc;
nic_data->have_local_intf = false;
rc = efx_mae_enumerate_mports(efx);
if (rc)
pci_warn(efx->pci_dev,
"Could not enumerate mports (rc=%d), are we admin?",
rc);
}
void efx_ef100_fini_reps(struct efx_nic *efx)
{
struct efx_mae *mae = efx->mae;
rhashtable_free_and_destroy(&mae->mports_ht, efx_mae_remove_mport,
NULL);
}
static int efx_ef100_rep_poll(struct napi_struct *napi, int weight) static int efx_ef100_rep_poll(struct napi_struct *napi, int weight)
{ {
struct efx_rep *efv = container_of(napi, struct efx_rep, napi); struct efx_rep *efv = container_of(napi, struct efx_rep, napi);
......
...@@ -22,6 +22,8 @@ struct efx_rep_sw_stats { ...@@ -22,6 +22,8 @@ struct efx_rep_sw_stats {
atomic64_t rx_dropped, tx_errors; atomic64_t rx_dropped, tx_errors;
}; };
struct devlink_port;
/** /**
* struct efx_rep - Private data for an Efx representor * struct efx_rep - Private data for an Efx representor
* *
...@@ -39,6 +41,7 @@ struct efx_rep_sw_stats { ...@@ -39,6 +41,7 @@ struct efx_rep_sw_stats {
* @rx_lock: protects @rx_list * @rx_lock: protects @rx_list
* @napi: NAPI control structure * @napi: NAPI control structure
* @stats: software traffic counters for netdev stats * @stats: software traffic counters for netdev stats
* @dl_port: devlink port associated to this netdev representor
*/ */
struct efx_rep { struct efx_rep {
struct efx_nic *parent; struct efx_nic *parent;
...@@ -54,6 +57,7 @@ struct efx_rep { ...@@ -54,6 +57,7 @@ struct efx_rep {
spinlock_t rx_lock; spinlock_t rx_lock;
struct napi_struct napi; struct napi_struct napi;
struct efx_rep_sw_stats stats; struct efx_rep_sw_stats stats;
struct devlink_port *dl_port;
}; };
int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i); int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i);
...@@ -67,4 +71,10 @@ void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf); ...@@ -67,4 +71,10 @@ void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf);
*/ */
struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport); struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport);
extern const struct net_device_ops efx_ef100_rep_netdev_ops; extern const struct net_device_ops efx_ef100_rep_netdev_ops;
void efx_ef100_init_reps(struct efx_nic *efx);
void efx_ef100_fini_reps(struct efx_nic *efx);
struct mae_mport_desc;
bool ef100_mport_on_local_intf(struct efx_nic *efx,
struct mae_mport_desc *mport_desc);
bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc);
#endif /* EF100_REP_H */ #endif /* EF100_REP_H */
This diff is collapsed.
/* 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>
/* Custom devlink-info version object names for details that do not map to the
* generic standardized names.
*/
#define EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC "fw.mgmt.suc"
#define EFX_DEVLINK_INFO_VERSION_FW_MGMT_CMC "fw.mgmt.cmc"
#define EFX_DEVLINK_INFO_VERSION_FPGA_REV "fpga.rev"
#define EFX_DEVLINK_INFO_VERSION_DATAPATH_HW "fpga.app"
#define EFX_DEVLINK_INFO_VERSION_DATAPATH_FW DEVLINK_INFO_VERSION_GENERIC_FW_APP
#define EFX_DEVLINK_INFO_VERSION_SOC_BOOT "coproc.boot"
#define EFX_DEVLINK_INFO_VERSION_SOC_UBOOT "coproc.uboot"
#define EFX_DEVLINK_INFO_VERSION_SOC_MAIN "coproc.main"
#define EFX_DEVLINK_INFO_VERSION_SOC_RECOVERY "coproc.recovery"
#define EFX_DEVLINK_INFO_VERSION_FW_EXPROM "fw.exprom"
#define EFX_DEVLINK_INFO_VERSION_FW_UEFI "fw.uefi"
#define EFX_MAX_VERSION_INFO_LEN 64
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);
#ifdef CONFIG_SFC_SRIOV
struct efx_rep;
void ef100_pf_set_devlink_port(struct efx_nic *efx);
void ef100_rep_set_devlink_port(struct efx_rep *efv);
void ef100_pf_unset_devlink_port(struct efx_nic *efx);
void ef100_rep_unset_devlink_port(struct efx_rep *efv);
#endif
#endif /* _EFX_DEVLINK_H */
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
* by the Free Software Foundation, incorporated herein by reference. * by the Free Software Foundation, incorporated herein by reference.
*/ */
#include <linux/rhashtable.h>
#include "ef100_nic.h"
#include "mae.h" #include "mae.h"
#include "mcdi.h" #include "mcdi.h"
#include "mcdi_pcol.h"
#include "mcdi_pcol_mae.h" #include "mcdi_pcol_mae.h"
int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label) int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label)
...@@ -94,7 +97,7 @@ void efx_mae_mport_mport(struct efx_nic *efx __always_unused, u32 mport_id, u32 ...@@ -94,7 +97,7 @@ void efx_mae_mport_mport(struct efx_nic *efx __always_unused, u32 mport_id, u32
} }
/* id is really only 24 bits wide */ /* id is really only 24 bits wide */
int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id) int efx_mae_fw_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id)
{ {
MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN); MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN);
MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_LOOKUP_IN_LEN); MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_LOOKUP_IN_LEN);
...@@ -485,11 +488,193 @@ int efx_mae_free_counter(struct efx_nic *efx, struct efx_tc_counter *cnt) ...@@ -485,11 +488,193 @@ int efx_mae_free_counter(struct efx_nic *efx, struct efx_tc_counter *cnt)
return 0; return 0;
} }
int efx_mae_lookup_mport(struct efx_nic *efx, u32 vf_idx, u32 *id)
{
struct ef100_nic_data *nic_data = efx->nic_data;
struct efx_mae *mae = efx->mae;
struct rhashtable_iter walk;
struct mae_mport_desc *m;
int rc = -ENOENT;
rhashtable_walk_enter(&mae->mports_ht, &walk);
rhashtable_walk_start(&walk);
while ((m = rhashtable_walk_next(&walk)) != NULL) {
if (m->mport_type == MAE_MPORT_DESC_MPORT_TYPE_VNIC &&
m->interface_idx == nic_data->local_mae_intf &&
m->pf_idx == 0 &&
m->vf_idx == vf_idx) {
*id = m->mport_id;
rc = 0;
break;
}
}
rhashtable_walk_stop(&walk);
rhashtable_walk_exit(&walk);
return rc;
}
static bool efx_mae_asl_id(u32 id) static bool efx_mae_asl_id(u32 id)
{ {
return !!(id & BIT(31)); return !!(id & BIT(31));
} }
/* mport handling */
static const struct rhashtable_params efx_mae_mports_ht_params = {
.key_len = sizeof(u32),
.key_offset = offsetof(struct mae_mport_desc, mport_id),
.head_offset = offsetof(struct mae_mport_desc, linkage),
};
struct mae_mport_desc *efx_mae_get_mport(struct efx_nic *efx, u32 mport_id)
{
return rhashtable_lookup_fast(&efx->mae->mports_ht, &mport_id,
efx_mae_mports_ht_params);
}
static int efx_mae_add_mport(struct efx_nic *efx, struct mae_mport_desc *desc)
{
struct efx_mae *mae = efx->mae;
int rc;
rc = rhashtable_insert_fast(&mae->mports_ht, &desc->linkage,
efx_mae_mports_ht_params);
if (rc) {
pci_err(efx->pci_dev, "Failed to insert MPORT %08x, rc %d\n",
desc->mport_id, rc);
kfree(desc);
return rc;
}
return rc;
}
void efx_mae_remove_mport(void *desc, void *arg)
{
struct mae_mport_desc *mport = desc;
synchronize_rcu();
kfree(mport);
}
static int efx_mae_process_mport(struct efx_nic *efx,
struct mae_mport_desc *desc)
{
struct ef100_nic_data *nic_data = efx->nic_data;
struct mae_mport_desc *mport;
mport = efx_mae_get_mport(efx, desc->mport_id);
if (!IS_ERR_OR_NULL(mport)) {
netif_err(efx, drv, efx->net_dev,
"mport with id %u does exist!!!\n", desc->mport_id);
return -EEXIST;
}
if (nic_data->have_own_mport &&
desc->mport_id == nic_data->own_mport) {
WARN_ON(desc->mport_type != MAE_MPORT_DESC_MPORT_TYPE_VNIC);
WARN_ON(desc->vnic_client_type !=
MAE_MPORT_DESC_VNIC_CLIENT_TYPE_FUNCTION);
nic_data->local_mae_intf = desc->interface_idx;
nic_data->have_local_intf = true;
pci_dbg(efx->pci_dev, "MAE interface_idx is %u\n",
nic_data->local_mae_intf);
}
return efx_mae_add_mport(efx, desc);
}
#define MCDI_MPORT_JOURNAL_LEN \
ALIGN(MC_CMD_MAE_MPORT_READ_JOURNAL_OUT_LENMAX_MCDI2, 4)
int efx_mae_enumerate_mports(struct efx_nic *efx)
{
efx_dword_t *outbuf = kzalloc(MCDI_MPORT_JOURNAL_LEN, GFP_KERNEL);
MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_READ_JOURNAL_IN_LEN);
MCDI_DECLARE_STRUCT_PTR(desc);
size_t outlen, stride, count;
int rc = 0, i;
if (!outbuf)
return -ENOMEM;
do {
rc = efx_mcdi_rpc(efx, MC_CMD_MAE_MPORT_READ_JOURNAL, inbuf,
sizeof(inbuf), outbuf,
MCDI_MPORT_JOURNAL_LEN, &outlen);
if (rc)
goto fail;
if (outlen < MC_CMD_MAE_MPORT_READ_JOURNAL_OUT_MPORT_DESC_DATA_OFST) {
rc = -EIO;
goto fail;
}
count = MCDI_DWORD(outbuf, MAE_MPORT_READ_JOURNAL_OUT_MPORT_DESC_COUNT);
if (!count)
continue; /* not break; we want to look at MORE flag */
stride = MCDI_DWORD(outbuf, MAE_MPORT_READ_JOURNAL_OUT_SIZEOF_MPORT_DESC);
if (stride < MAE_MPORT_DESC_LEN) {
rc = -EIO;
goto fail;
}
if (outlen < MC_CMD_MAE_MPORT_READ_JOURNAL_OUT_LEN(count * stride)) {
rc = -EIO;
goto fail;
}
for (i = 0; i < count; i++) {
struct mae_mport_desc *d;
d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d) {
rc = -ENOMEM;
goto fail;
}
desc = (efx_dword_t *)
_MCDI_PTR(outbuf, MC_CMD_MAE_MPORT_READ_JOURNAL_OUT_MPORT_DESC_DATA_OFST +
i * stride);
d->mport_id = MCDI_STRUCT_DWORD(desc, MAE_MPORT_DESC_MPORT_ID);
d->flags = MCDI_STRUCT_DWORD(desc, MAE_MPORT_DESC_FLAGS);
d->caller_flags = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_CALLER_FLAGS);
d->mport_type = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_MPORT_TYPE);
switch (d->mport_type) {
case MAE_MPORT_DESC_MPORT_TYPE_NET_PORT:
d->port_idx = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_NET_PORT_IDX);
break;
case MAE_MPORT_DESC_MPORT_TYPE_ALIAS:
d->alias_mport_id = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_ALIAS_DELIVER_MPORT_ID);
break;
case MAE_MPORT_DESC_MPORT_TYPE_VNIC:
d->vnic_client_type = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_VNIC_CLIENT_TYPE);
d->interface_idx = MCDI_STRUCT_DWORD(desc,
MAE_MPORT_DESC_VNIC_FUNCTION_INTERFACE);
d->pf_idx = MCDI_STRUCT_WORD(desc,
MAE_MPORT_DESC_VNIC_FUNCTION_PF_IDX);
d->vf_idx = MCDI_STRUCT_WORD(desc,
MAE_MPORT_DESC_VNIC_FUNCTION_VF_IDX);
break;
default:
/* Unknown mport_type, just accept it */
break;
}
rc = efx_mae_process_mport(efx, d);
/* Any failure will be due to memory allocation faiure,
* so there is no point to try subsequent entries.
*/
if (rc)
goto fail;
}
} while (MCDI_FIELD(outbuf, MAE_MPORT_READ_JOURNAL_OUT, MORE) &&
!WARN_ON(!count));
fail:
kfree(outbuf);
return rc;
}
int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act) int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act)
{ {
MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN); MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN);
...@@ -805,3 +990,34 @@ int efx_mae_delete_rule(struct efx_nic *efx, u32 id) ...@@ -805,3 +990,34 @@ int efx_mae_delete_rule(struct efx_nic *efx, u32 id)
return -EIO; return -EIO;
return 0; return 0;
} }
int efx_init_mae(struct efx_nic *efx)
{
struct ef100_nic_data *nic_data = efx->nic_data;
struct efx_mae *mae;
int rc;
if (!nic_data->have_mport)
return -EINVAL;
mae = kmalloc(sizeof(*mae), GFP_KERNEL);
if (!mae)
return -ENOMEM;
rc = rhashtable_init(&mae->mports_ht, &efx_mae_mports_ht_params);
if (rc < 0) {
kfree(mae);
return rc;
}
efx->mae = mae;
mae->efx = efx;
return 0;
}
void efx_fini_mae(struct efx_nic *efx)
{
struct efx_mae *mae = efx->mae;
kfree(mae);
efx->mae = NULL;
}
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define EF100_MAE_H #define EF100_MAE_H
/* MCDI interface for the ef100 Match-Action Engine */ /* MCDI interface for the ef100 Match-Action Engine */
#include <net/devlink.h>
#include "net_driver.h" #include "net_driver.h"
#include "tc.h" #include "tc.h"
#include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */ #include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */
...@@ -27,6 +28,40 @@ void efx_mae_mport_mport(struct efx_nic *efx, u32 mport_id, u32 *out); ...@@ -27,6 +28,40 @@ void efx_mae_mport_mport(struct efx_nic *efx, u32 mport_id, u32 *out);
int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id);
struct mae_mport_desc {
u32 mport_id;
u32 flags;
u32 caller_flags; /* enum mae_mport_desc_caller_flags */
u32 mport_type; /* MAE_MPORT_DESC_MPORT_TYPE_* */
union {
u32 port_idx; /* for mport_type == NET_PORT */
u32 alias_mport_id; /* for mport_type == ALIAS */
struct { /* for mport_type == VNIC */
u32 vnic_client_type; /* MAE_MPORT_DESC_VNIC_CLIENT_TYPE_* */
u32 interface_idx;
u16 pf_idx;
u16 vf_idx;
};
};
struct rhash_head linkage;
struct devlink_port dl_port;
};
int efx_mae_enumerate_mports(struct efx_nic *efx);
struct mae_mport_desc *efx_mae_get_mport(struct efx_nic *efx, u32 mport_id);
void efx_mae_put_mport(struct efx_nic *efx, struct mae_mport_desc *desc);
/**
* struct efx_mae - MAE information
*
* @efx: The associated NIC
* @mports_ht: m-port descriptions from MC_CMD_MAE_MPORT_READ_JOURNAL
*/
struct efx_mae {
struct efx_nic *efx;
struct rhashtable mports_ht;
};
int efx_mae_start_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue); int efx_mae_start_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue);
int efx_mae_stop_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue); int efx_mae_stop_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue);
void efx_mae_counters_grant_credits(struct work_struct *work); void efx_mae_counters_grant_credits(struct work_struct *work);
...@@ -60,4 +95,9 @@ int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match, ...@@ -60,4 +95,9 @@ int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match,
u32 prio, u32 acts_id, u32 *id); u32 prio, u32 acts_id, u32 *id);
int efx_mae_delete_rule(struct efx_nic *efx, u32 id); int efx_mae_delete_rule(struct efx_nic *efx, u32 id);
int efx_init_mae(struct efx_nic *efx);
void efx_fini_mae(struct efx_nic *efx);
void efx_mae_remove_mport(void *desc, void *arg);
int efx_mae_fw_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id);
int efx_mae_lookup_mport(struct efx_nic *efx, u32 vf, u32 *id);
#endif /* EF100_MAE_H */ #endif /* EF100_MAE_H */
...@@ -2175,6 +2175,78 @@ int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask) ...@@ -2175,6 +2175,78 @@ int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask)
return 0; return 0;
} }
int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type,
u32 *subtype, u16 version[4], char *desc,
size_t descsize)
{
MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN);
efx_dword_t *outbuf;
size_t outlen;
u32 flags;
int rc;
outbuf = kzalloc(MC_CMD_NVRAM_METADATA_OUT_LENMAX_MCDI2, GFP_KERNEL);
if (!outbuf)
return -ENOMEM;
MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type);
rc = efx_mcdi_rpc_quiet(efx, MC_CMD_NVRAM_METADATA, inbuf,
sizeof(inbuf), outbuf,
MC_CMD_NVRAM_METADATA_OUT_LENMAX_MCDI2,
&outlen);
if (rc)
goto out_free;
if (outlen < MC_CMD_NVRAM_METADATA_OUT_LENMIN) {
rc = -EIO;
goto out_free;
}
flags = MCDI_DWORD(outbuf, NVRAM_METADATA_OUT_FLAGS);
if (desc && descsize > 0) {
if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_VALID_LBN)) {
if (descsize <=
MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen)) {
rc = -E2BIG;
goto out_free;
}
strncpy(desc,
MCDI_PTR(outbuf, NVRAM_METADATA_OUT_DESCRIPTION),
MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen));
desc[MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen)] = '\0';
} else {
desc[0] = '\0';
}
}
if (subtype) {
if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_SUBTYPE_VALID_LBN))
*subtype = MCDI_DWORD(outbuf, NVRAM_METADATA_OUT_SUBTYPE);
else
*subtype = 0;
}
if (version) {
if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_VERSION_VALID_LBN)) {
version[0] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_W);
version[1] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_X);
version[2] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_Y);
version[3] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_Z);
} else {
version[0] = 0;
version[1] = 0;
version[2] = 0;
version[3] = 0;
}
}
out_free:
kfree(outbuf);
return rc;
}
#ifdef CONFIG_SFC_MTD #ifdef CONFIG_SFC_MTD
#define EFX_MCDI_NVRAM_LEN_MAX 128 #define EFX_MCDI_NVRAM_LEN_MAX 128
......
...@@ -229,6 +229,9 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); ...@@ -229,6 +229,9 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
#define MCDI_WORD(_buf, _field) \ #define MCDI_WORD(_buf, _field) \
((u16)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \ ((u16)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \
le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field))) le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field)))
#define MCDI_STRUCT_WORD(_buf, _field) \
((void)BUILD_BUG_ON_ZERO(_field ## _LEN != 2), \
le16_to_cpu(*(__force const __le16 *)MCDI_STRUCT_PTR(_buf, _field)))
/* Write a 16-bit field defined in the protocol as being big-endian. */ /* Write a 16-bit field defined in the protocol as being big-endian. */
#define MCDI_STRUCT_SET_WORD_BE(_buf, _field, _value) do { \ #define MCDI_STRUCT_SET_WORD_BE(_buf, _field, _value) do { \
BUILD_BUG_ON(_field ## _LEN != 2); \ BUILD_BUG_ON(_field ## _LEN != 2); \
...@@ -241,6 +244,8 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); ...@@ -241,6 +244,8 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
EFX_POPULATE_DWORD_1(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0, _value) EFX_POPULATE_DWORD_1(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0, _value)
#define MCDI_DWORD(_buf, _field) \ #define MCDI_DWORD(_buf, _field) \
EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0) EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0)
#define MCDI_STRUCT_DWORD(_buf, _field) \
EFX_DWORD_FIELD(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0)
/* Write a 32-bit field defined in the protocol as being big-endian. */ /* Write a 32-bit field defined in the protocol as being big-endian. */
#define MCDI_STRUCT_SET_DWORD_BE(_buf, _field, _value) do { \ #define MCDI_STRUCT_SET_DWORD_BE(_buf, _field, _value) do { \
BUILD_BUG_ON(_field ## _LEN != 4); \ BUILD_BUG_ON(_field ## _LEN != 4); \
...@@ -378,6 +383,9 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type, ...@@ -378,6 +383,9 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
size_t *size_out, size_t *erase_size_out, size_t *size_out, size_t *erase_size_out,
bool *protected_out); bool *protected_out);
int efx_new_mcdi_nvram_test_all(struct efx_nic *efx); int efx_new_mcdi_nvram_test_all(struct efx_nic *efx);
int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type,
u32 *subtype, u16 version[4], char *desc,
size_t descsize);
int efx_mcdi_nvram_test_all(struct efx_nic *efx); int efx_mcdi_nvram_test_all(struct efx_nic *efx);
int efx_mcdi_handle_assertion(struct efx_nic *efx); int efx_mcdi_handle_assertion(struct efx_nic *efx);
int efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode); int efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
......
...@@ -845,6 +845,8 @@ enum efx_xdp_tx_queues_mode { ...@@ -845,6 +845,8 @@ enum efx_xdp_tx_queues_mode {
EFX_XDP_TX_QUEUES_BORROWED /* queues borrowed from net stack */ EFX_XDP_TX_QUEUES_BORROWED /* queues borrowed from net stack */
}; };
struct efx_mae;
/** /**
* struct efx_nic - an Efx NIC * struct efx_nic - an Efx NIC
* @name: Device name (net device name or bus id before net device registered) * @name: Device name (net device name or bus id before net device registered)
...@@ -881,6 +883,7 @@ enum efx_xdp_tx_queues_mode { ...@@ -881,6 +883,7 @@ enum efx_xdp_tx_queues_mode {
* @msi_context: Context for each MSI * @msi_context: Context for each MSI
* @extra_channel_types: Types of extra (non-traffic) channels that * @extra_channel_types: Types of extra (non-traffic) channels that
* should be allocated for this NIC * should be allocated for this NIC
* @mae: Details of the Match Action Engine
* @xdp_tx_queue_count: Number of entries in %xdp_tx_queues. * @xdp_tx_queue_count: Number of entries in %xdp_tx_queues.
* @xdp_tx_queues: Array of pointers to tx queues used for XDP transmit. * @xdp_tx_queues: Array of pointers to tx queues used for XDP transmit.
* @xdp_txq_queues_mode: XDP TX queues sharing strategy. * @xdp_txq_queues_mode: XDP TX queues sharing strategy.
...@@ -994,6 +997,8 @@ enum efx_xdp_tx_queues_mode { ...@@ -994,6 +997,8 @@ enum efx_xdp_tx_queues_mode {
* xdp_rxq_info structures? * xdp_rxq_info structures?
* @netdev_notifier: Netdevice notifier. * @netdev_notifier: Netdevice notifier.
* @tc: state for TC offload (EF100). * @tc: state for TC offload (EF100).
* @devlink: reference to devlink structure owned by this device
* @dl_port: devlink port associated with the PF
* @mem_bar: The BAR that is mapped into membase. * @mem_bar: The BAR that is mapped into membase.
* @reg_base: Offset from the start of the bar to the function control window. * @reg_base: Offset from the start of the bar to the function control window.
* @monitor_work: Hardware monitor workitem * @monitor_work: Hardware monitor workitem
...@@ -1043,6 +1048,7 @@ struct efx_nic { ...@@ -1043,6 +1048,7 @@ struct efx_nic {
struct efx_msi_context msi_context[EFX_MAX_CHANNELS]; struct efx_msi_context msi_context[EFX_MAX_CHANNELS];
const struct efx_channel_type * const struct efx_channel_type *
extra_channel_type[EFX_MAX_EXTRA_CHANNELS]; extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
struct efx_mae *mae;
unsigned int xdp_tx_queue_count; unsigned int xdp_tx_queue_count;
struct efx_tx_queue **xdp_tx_queues; struct efx_tx_queue **xdp_tx_queues;
...@@ -1179,6 +1185,8 @@ struct efx_nic { ...@@ -1179,6 +1185,8 @@ struct efx_nic {
struct notifier_block netdev_notifier; struct notifier_block netdev_notifier;
struct efx_tc_state *tc; struct efx_tc_state *tc;
struct devlink *devlink;
struct devlink_port *dl_port;
unsigned int mem_bar; unsigned int mem_bar;
u32 reg_base; u32 reg_base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment