Skip to content

Commit

Permalink
Merge branch 'sfc-E100-VF-respresenters'
Browse files Browse the repository at this point in the history
Edward Cree says:

====================
sfc: VF representors for EF100

This series adds representor netdevices for EF100 VFs, as a step towards
 supporting TC offload and vDPA usecases in future patches.
In this first series is basic netdevice creation and packet TX; the
 following series will add the RX path.

v3: dropped massive mcdi_pcol.h patch which was applied separately.
v2: converted comments on struct efx_nic members added in patch #4 to
 kernel-doc (Jakub).  While at it, also gave struct efx_rep its own kdoc
 since several members had comments on them.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jul 22, 2022
2 parents 16576a0 + 84e7fc2 commit 735dbc6
Show file tree
Hide file tree
Showing 23 changed files with 687 additions and 53 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/sfc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \
ef100.o ef100_nic.o ef100_netdev.o \
ef100_ethtool.o ef100_rx.o ef100_tx.o
sfc-$(CONFIG_SFC_MTD) += mtd.o
sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o
sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o mae.o

obj-$(CONFIG_SFC) += sfc.o

Expand Down
16 changes: 14 additions & 2 deletions drivers/net/ethernet/sfc/ef100_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static int ef100_net_stop(struct net_device *net_dev)
netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
raw_smp_processor_id());

efx_detach_reps(efx);
netif_stop_queue(net_dev);
efx_stop_all(efx);
efx_mcdi_mac_fini_stats(efx);
Expand Down Expand Up @@ -176,6 +177,8 @@ static int ef100_net_open(struct net_device *net_dev)
mutex_unlock(&efx->mac_lock);

efx->state = STATE_NET_UP;
if (netif_running(efx->net_dev))
efx_attach_reps(efx);

return 0;

Expand All @@ -195,6 +198,15 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb,
struct net_device *net_dev)
{
struct efx_nic *efx = efx_netdev_priv(net_dev);

return __ef100_hard_start_xmit(skb, efx, net_dev, NULL);
}

netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb,
struct efx_nic *efx,
struct net_device *net_dev,
struct efx_rep *efv)
{
struct efx_tx_queue *tx_queue;
struct efx_channel *channel;
int rc;
Expand All @@ -209,7 +221,7 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb,
}

tx_queue = &channel->tx_queue[0];
rc = ef100_enqueue_skb(tx_queue, skb);
rc = __ef100_enqueue_skb(tx_queue, skb, efv);
if (rc == 0)
return NETDEV_TX_OK;

Expand Down Expand Up @@ -312,7 +324,7 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
unregister_netdevice_notifier(&efx->netdev_notifier);
#if defined(CONFIG_SFC_SRIOV)
if (!efx->type->is_vf)
efx_ef100_pci_sriov_disable(efx);
efx_ef100_pci_sriov_disable(efx, true);
#endif

ef100_unregister_netdev(efx);
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ethernet/sfc/ef100_netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
*/

#include <linux/netdevice.h>
#include "ef100_rep.h"

netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb,
struct efx_nic *efx,
struct net_device *net_dev,
struct efx_rep *efv);
int ef100_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr);
int ef100_probe_netdev(struct efx_probe_data *probe_data);
Expand Down
7 changes: 7 additions & 0 deletions drivers/net/ethernet/sfc/ef100_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ static int ef100_probe_main(struct efx_nic *efx)
unsigned int bar_size = resource_size(&efx->pci_dev->resource[efx->mem_bar]);
struct ef100_nic_data *nic_data;
char fw_version[32];
u32 priv_mask = 0;
int i, rc;

if (WARN_ON(bar_size == 0))
Expand Down Expand Up @@ -1027,6 +1028,12 @@ static int ef100_probe_main(struct efx_nic *efx)
efx_mcdi_print_fwver(efx, fw_version, sizeof(fw_version));
pci_dbg(efx->pci_dev, "Firmware version %s\n", fw_version);

rc = efx_mcdi_get_privilege_mask(efx, &priv_mask);
if (rc) /* non-fatal, and priv_mask will still be 0 */
pci_info(efx->pci_dev,
"Failed to get privilege mask from FW, rc %d\n", rc);
nic_data->grp_mae = !!(priv_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAE);

if (compare_versions(fw_version, "1.1.0.1000") < 0) {
pci_info(efx->pci_dev, "Firmware uses old event descriptors\n");
rc = -EINVAL;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/sfc/ef100_nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct ef100_nic_data {
u8 port_id[ETH_ALEN];
DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS);
u64 stats[EF100_STAT_COUNT];
bool grp_mae; /* MAE Privilege */
u16 tso_max_hdr_len;
u16 tso_max_payload_num_segs;
u16 tso_max_frames;
Expand Down
83 changes: 60 additions & 23 deletions drivers/net/ethernet/sfc/ef100_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/****************************************************************************
* Driver for Solarflare network controllers and boards
* Copyright 2018 Solarflare Communications Inc.
* Copyright 2019-2020 Xilinx Inc.
* Copyright 2019-2022 Xilinx 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
Expand Down Expand Up @@ -181,12 +181,6 @@
/* RHEAD_BASE_EVENT */
#define ESF_GZ_E_TYPE_LBN 60
#define ESF_GZ_E_TYPE_WIDTH 4
#define ESE_GZ_EF100_EV_DRIVER 5
#define ESE_GZ_EF100_EV_MCDI 4
#define ESE_GZ_EF100_EV_CONTROL 3
#define ESE_GZ_EF100_EV_TX_TIMESTAMP 2
#define ESE_GZ_EF100_EV_TX_COMPLETION 1
#define ESE_GZ_EF100_EV_RX_PKTS 0
#define ESF_GZ_EV_EVQ_PHASE_LBN 59
#define ESF_GZ_EV_EVQ_PHASE_WIDTH 1
#define ESE_GZ_RHEAD_BASE_EVENT_STRUCT_SIZE 64
Expand Down Expand Up @@ -369,14 +363,18 @@
#define ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI_WIDTH 16
#define ESF_GZ_RX_PREFIX_CSUM_FRAME_LBN 144
#define ESF_GZ_RX_PREFIX_CSUM_FRAME_WIDTH 16
#define ESF_GZ_RX_PREFIX_INGRESS_VPORT_LBN 128
#define ESF_GZ_RX_PREFIX_INGRESS_VPORT_WIDTH 16
#define ESF_GZ_RX_PREFIX_INGRESS_MPORT_LBN 128
#define ESF_GZ_RX_PREFIX_INGRESS_MPORT_WIDTH 16
#define ESF_GZ_RX_PREFIX_USER_MARK_LBN 96
#define ESF_GZ_RX_PREFIX_USER_MARK_WIDTH 32
#define ESF_GZ_RX_PREFIX_RSS_HASH_LBN 64
#define ESF_GZ_RX_PREFIX_RSS_HASH_WIDTH 32
#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_LBN 32
#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_WIDTH 32
#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_LBN 34
#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_WIDTH 30
#define ESF_GZ_RX_PREFIX_VSWITCH_STATUS_LBN 33
#define ESF_GZ_RX_PREFIX_VSWITCH_STATUS_WIDTH 1
#define ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN 32
#define ESF_GZ_RX_PREFIX_VLAN_STRIPPED_WIDTH 1
#define ESF_GZ_RX_PREFIX_CLASS_LBN 16
#define ESF_GZ_RX_PREFIX_CLASS_WIDTH 16
#define ESF_GZ_RX_PREFIX_USER_FLAG_LBN 15
Expand Down Expand Up @@ -454,12 +452,8 @@
#define ESF_GZ_M2M_TRANSLATE_ADDR_WIDTH 1
#define ESF_GZ_M2M_RSVD_LBN 120
#define ESF_GZ_M2M_RSVD_WIDTH 2
#define ESF_GZ_M2M_ADDR_SPC_LBN 108
#define ESF_GZ_M2M_ADDR_SPC_WIDTH 12
#define ESF_GZ_M2M_ADDR_SPC_PASID_LBN 86
#define ESF_GZ_M2M_ADDR_SPC_PASID_WIDTH 22
#define ESF_GZ_M2M_ADDR_SPC_MODE_LBN 84
#define ESF_GZ_M2M_ADDR_SPC_MODE_WIDTH 2
#define ESF_GZ_M2M_ADDR_SPC_ID_LBN 84
#define ESF_GZ_M2M_ADDR_SPC_ID_WIDTH 36
#define ESF_GZ_M2M_LEN_MINUS_1_LBN 64
#define ESF_GZ_M2M_LEN_MINUS_1_WIDTH 20
#define ESF_GZ_M2M_ADDR_LBN 0
Expand Down Expand Up @@ -492,12 +486,8 @@
#define ESF_GZ_TX_SEG_TRANSLATE_ADDR_WIDTH 1
#define ESF_GZ_TX_SEG_RSVD2_LBN 120
#define ESF_GZ_TX_SEG_RSVD2_WIDTH 2
#define ESF_GZ_TX_SEG_ADDR_SPC_LBN 108
#define ESF_GZ_TX_SEG_ADDR_SPC_WIDTH 12
#define ESF_GZ_TX_SEG_ADDR_SPC_PASID_LBN 86
#define ESF_GZ_TX_SEG_ADDR_SPC_PASID_WIDTH 22
#define ESF_GZ_TX_SEG_ADDR_SPC_MODE_LBN 84
#define ESF_GZ_TX_SEG_ADDR_SPC_MODE_WIDTH 2
#define ESF_GZ_TX_SEG_ADDR_SPC_ID_LBN 84
#define ESF_GZ_TX_SEG_ADDR_SPC_ID_WIDTH 36
#define ESF_GZ_TX_SEG_RSVD_LBN 80
#define ESF_GZ_TX_SEG_RSVD_WIDTH 4
#define ESF_GZ_TX_SEG_LEN_LBN 64
Expand Down Expand Up @@ -583,6 +573,12 @@
#define ESE_GZ_SF_TX_TSO_DSC_FMT_STRUCT_SIZE 124


/* Enum D2VIO_MSG_OP */
#define ESE_GZ_QUE_JBDNE 3
#define ESE_GZ_QUE_EVICT 2
#define ESE_GZ_QUE_EMPTY 1
#define ESE_GZ_NOP 0

/* Enum DESIGN_PARAMS */
#define ESE_EF100_DP_GZ_RX_MAX_RUNT 17
#define ESE_EF100_DP_GZ_VI_STRIDES 16
Expand Down Expand Up @@ -630,6 +626,19 @@
#define ESE_GZ_PCI_BASE_CONFIG_SPACE_SIZE 256
#define ESE_GZ_PCI_EXPRESS_XCAP_HDR_SIZE 4

/* Enum RH_DSC_TYPE */
#define ESE_GZ_TX_TOMB 0xF
#define ESE_GZ_TX_VIO 0xE
#define ESE_GZ_TX_TSO_OVRRD 0x8
#define ESE_GZ_TX_D2CMP 0x7
#define ESE_GZ_TX_DATA 0x6
#define ESE_GZ_TX_D2M 0x5
#define ESE_GZ_TX_M2M 0x4
#define ESE_GZ_TX_SEG 0x3
#define ESE_GZ_TX_TSO 0x2
#define ESE_GZ_TX_OVRRD 0x1
#define ESE_GZ_TX_SEND 0x0

/* Enum RH_HCLASS_L2_CLASS */
#define ESE_GZ_RH_HCLASS_L2_CLASS_E2_0123VLAN 1
#define ESE_GZ_RH_HCLASS_L2_CLASS_OTHER 0
Expand Down Expand Up @@ -666,6 +675,25 @@
#define ESE_GZ_RH_HCLASS_TUNNEL_CLASS_VXLAN 1
#define ESE_GZ_RH_HCLASS_TUNNEL_CLASS_NONE 0

/* Enum SF_CTL_EVENT_SUBTYPE */
#define ESE_GZ_EF100_CTL_EV_EVQ_TIMEOUT 0x3
#define ESE_GZ_EF100_CTL_EV_FLUSH 0x2
#define ESE_GZ_EF100_CTL_EV_TIME_SYNC 0x1
#define ESE_GZ_EF100_CTL_EV_UNSOL_OVERFLOW 0x0

/* Enum SF_EVENT_TYPE */
#define ESE_GZ_EF100_EV_DRIVER 0x5
#define ESE_GZ_EF100_EV_MCDI 0x4
#define ESE_GZ_EF100_EV_CONTROL 0x3
#define ESE_GZ_EF100_EV_TX_TIMESTAMP 0x2
#define ESE_GZ_EF100_EV_TX_COMPLETION 0x1
#define ESE_GZ_EF100_EV_RX_PKTS 0x0

/* Enum SF_EW_EVENT_TYPE */
#define ESE_GZ_EF100_EWEV_VIRTQ_DESC 0x2
#define ESE_GZ_EF100_EWEV_TXQ_DESC 0x1
#define ESE_GZ_EF100_EWEV_64BIT 0x0

/* Enum TX_DESC_CSO_PARTIAL_EN */
#define ESE_GZ_TX_DESC_CSO_PARTIAL_EN_TCP 2
#define ESE_GZ_TX_DESC_CSO_PARTIAL_EN_UDP 1
Expand All @@ -681,6 +709,15 @@
#define ESE_GZ_TX_DESC_IP4_ID_INC_MOD16 2
#define ESE_GZ_TX_DESC_IP4_ID_INC_MOD15 1
#define ESE_GZ_TX_DESC_IP4_ID_NO_OP 0

/* Enum VIRTIO_NET_HDR_F */
#define ESE_GZ_NEEDS_CSUM 0x1

/* Enum VIRTIO_NET_HDR_GSO */
#define ESE_GZ_TCPV6 0x4
#define ESE_GZ_UDP 0x3
#define ESE_GZ_TCPV4 0x1
#define ESE_GZ_NONE 0x0
/**************************************************************************/

#define ESF_GZ_EV_DEBUG_EVENT_GEN_FLAGS_LBN 44
Expand Down
Loading

0 comments on commit 735dbc6

Please sign in to comment.