Commit 4ec1d5fd authored by David S. Miller's avatar David S. Miller

Merge branch 'octeon_ep_vf'

Shinas Rasheed says:

====================
add octeon_ep_vf driver

This driver implements networking functionality of Marvell's Octeon
PCI Endpoint NIC VF.

This driver support following devices:
 * Network controller: Cavium, Inc. Device b203
 * Network controller: Cavium, Inc. Device b403
 * Network controller: Cavium, Inc. Device b103
 * Network controller: Cavium, Inc. Device b903
 * Network controller: Cavium, Inc. Device ba03
 * Network controller: Cavium, Inc. Device bc03
 * Network controller: Cavium, Inc. Device bd03

Changes:
V7:
  - Separated octep_vf_get_if_stats from octep_vf_main.h to later patch
    in [1/8]
  - Moved introducing ndo_ops from [3/8] to [5/8]

V6: https://lore.kernel.org/all/20240207065207.3092004-1-srasheed@marvell.com/
  - Removed reuse of netif_tx_stop_all_queues, called implicitly in
    netif_tx_disable, when stopping netdev
  - Corrected error jump labels to have proper action-specific names in
    probe function
  - Removed singlethreaded workqueue implementation, since only tx
    timeout task is run. Run the same in the system workqueue
  - netdev_hold when tx_timeout happens to protect against free_netdev
    if race occurs between rmmod and a tx timeout. netdev_put the
    reference when timeout task ends to progress freeing netdev

V5: https://lore.kernel.org/all/20240129050254.3047778-1-srasheed@marvell.com/
  - Changed unchecked return types to void and removed unnecessary
    initializations in [2/8] patch.

V4: https://lore.kernel.org/all/20240108124213.2966536-1-srasheed@marvell.com/
  - Moved some stats from ethtool and added more to ndo_get_stats64
  - Replaced code in IQ full check function to use helper from
    net/netdev_queues.h
  - Refactored code so that NETDEV_TX_BUSY is avoided

V3: https://lore.kernel.org/all/20240105203823.2953604-1-srasheed@marvell.com/
  - Removed UINT64_MAX, which is unused
  - Replaced masks and ULL declarations with GENMASK_ULL(), ULL() and
    other linux/bits.h macros, corrected declarations to conform to xmas tree format in patch [2/8]
  - Moved vfree and vzalloc null pointer casting corrections to patch
    [3/8], and corrected return values to follow standard kernel error codes in same
   - Set static budget of 64 for tx completion processing in NAPI
  - Replaces napi_complete and build_skb APIs to napi_complete_done and
    napi_build_skb APIs respectively
  - Replaced code with helper from net/netdev_queues.h to wake queues in TX completion
    processing
  - Removed duplicate reporting of TX/RX packets/bytes, which is already
    done during ndo_get_stats64

V2: https://lore.kernel.org/all/20231223134000.2906144-1-srasheed@marvell.com/
  - Removed linux/version.h header file from inclusion in
    octep_vf_main.c
  - Corrected Makefile entry to include building octep_vf_mbox.c in
    [6/8] patch.
  - Removed redundant vzalloc pointer cast and vfree pointer check in
    [6/8] patch.

V1: https://lore.kernel.org/all/20231221092844.2885872-1-srasheed@marvell.com/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 970cb1ce 90cabae2
...@@ -42,6 +42,7 @@ Contents: ...@@ -42,6 +42,7 @@ Contents:
intel/ice intel/ice
marvell/octeontx2 marvell/octeontx2
marvell/octeon_ep marvell/octeon_ep
marvell/octeon_ep_vf
mellanox/mlx5/index mellanox/mlx5/index
microsoft/netvsc microsoft/netvsc
neterion/s2io neterion/s2io
......
.. SPDX-License-Identifier: GPL-2.0+
=======================================================================
Linux kernel networking driver for Marvell's Octeon PCI Endpoint NIC VF
=======================================================================
Network driver for Marvell's Octeon PCI EndPoint NIC VF.
Copyright (c) 2020 Marvell International Ltd.
Overview
========
This driver implements networking functionality of Marvell's Octeon PCI
EndPoint NIC VF.
Supported Devices
=================
Currently, this driver support following devices:
* Network controller: Cavium, Inc. Device b203
* Network controller: Cavium, Inc. Device b403
* Network controller: Cavium, Inc. Device b103
* Network controller: Cavium, Inc. Device b903
* Network controller: Cavium, Inc. Device ba03
* Network controller: Cavium, Inc. Device bc03
* Network controller: Cavium, Inc. Device bd03
...@@ -13059,6 +13059,15 @@ L: netdev@vger.kernel.org ...@@ -13059,6 +13059,15 @@ L: netdev@vger.kernel.org
S: Supported S: Supported
F: drivers/net/ethernet/marvell/octeon_ep F: drivers/net/ethernet/marvell/octeon_ep
MARVELL OCTEON ENDPOINT VF DRIVER
M: Veerasenareddy Burru <vburru@marvell.com>
M: Sathesh Edara <sedara@marvell.com>
M: Shinas Rasheed <srasheed@marvell.com>
M: Satananda Burla <sburla@marvell.com>
L: netdev@vger.kernel.org
S: Supported
F: drivers/net/ethernet/marvell/octeon_ep_vf
MARVELL OCTEONTX2 PHYSICAL FUNCTION DRIVER MARVELL OCTEONTX2 PHYSICAL FUNCTION DRIVER
M: Sunil Goutham <sgoutham@marvell.com> M: Sunil Goutham <sgoutham@marvell.com>
M: Geetha sowjanya <gakula@marvell.com> M: Geetha sowjanya <gakula@marvell.com>
......
...@@ -180,6 +180,7 @@ config SKY2_DEBUG ...@@ -180,6 +180,7 @@ config SKY2_DEBUG
source "drivers/net/ethernet/marvell/octeontx2/Kconfig" source "drivers/net/ethernet/marvell/octeontx2/Kconfig"
source "drivers/net/ethernet/marvell/octeon_ep/Kconfig" source "drivers/net/ethernet/marvell/octeon_ep/Kconfig"
source "drivers/net/ethernet/marvell/octeon_ep_vf/Kconfig"
source "drivers/net/ethernet/marvell/prestera/Kconfig" source "drivers/net/ethernet/marvell/prestera/Kconfig"
endif # NET_VENDOR_MARVELL endif # NET_VENDOR_MARVELL
...@@ -12,5 +12,6 @@ obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o ...@@ -12,5 +12,6 @@ obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o
obj-$(CONFIG_SKGE) += skge.o obj-$(CONFIG_SKGE) += skge.o
obj-$(CONFIG_SKY2) += sky2.o obj-$(CONFIG_SKY2) += sky2.o
obj-y += octeon_ep/ obj-y += octeon_ep/
obj-y += octeon_ep_vf/
obj-y += octeontx2/ obj-y += octeontx2/
obj-y += prestera/ obj-y += prestera/
# SPDX-License-Identifier: GPL-2.0-only
#
# Marvell's Octeon PCI Endpoint NIC VF Driver Configuration
#
config OCTEON_EP_VF
tristate "Marvell Octeon PCI Endpoint NIC VF Driver"
depends on 64BIT
depends on PCI
help
This driver supports networking functionality of Marvell's
Octeon PCI Endpoint NIC VF.
To know the list of devices supported by this driver, refer
documentation in
<file:Documentation/networking/device_drivers/ethernet/marvell/octeon_ep_vf.rst>.
To compile this drivers as a module, choose M here. Name of the
module is octeon_ep_vf.
# SPDX-License-Identifier: GPL-2.0
#
# Network driver for Marvell's Octeon PCI Endpoint NIC VF
#
obj-$(CONFIG_OCTEON_EP_VF) += octeon_ep_vf.o
octeon_ep_vf-y := octep_vf_main.o octep_vf_cn9k.o octep_vf_cnxk.o \
octep_vf_tx.o octep_vf_rx.o octep_vf_mbox.o \
octep_vf_ethtool.o
This diff is collapsed.
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_CONFIG_H_
#define _OCTEP_VF_CONFIG_H_
/* Tx instruction types by length */
#define OCTEP_VF_32BYTE_INSTR 32
#define OCTEP_VF_64BYTE_INSTR 64
/* Tx Queue: maximum descriptors per ring */
#define OCTEP_VF_IQ_MAX_DESCRIPTORS 1024
/* Minimum input (Tx) requests to be enqueued to ring doorbell */
#define OCTEP_VF_DB_MIN 8
/* Packet threshold for Tx queue interrupt */
#define OCTEP_VF_IQ_INTR_THRESHOLD 0x0
/* Minimum watermark for backpressure */
#define OCTEP_VF_OQ_WMARK_MIN 256
/* Rx Queue: maximum descriptors per ring */
#define OCTEP_VF_OQ_MAX_DESCRIPTORS 1024
/* Rx buffer size: Use page size buffers.
* Build skb from allocated page buffer once the packet is received.
* When a gathered packet is received, make head page as skb head and
* page buffers in consecutive Rx descriptors as fragments.
*/
#define OCTEP_VF_OQ_BUF_SIZE (SKB_WITH_OVERHEAD(PAGE_SIZE))
#define OCTEP_VF_OQ_PKTS_PER_INTR 128
#define OCTEP_VF_OQ_REFILL_THRESHOLD (OCTEP_VF_OQ_MAX_DESCRIPTORS / 4)
#define OCTEP_VF_OQ_INTR_PKT_THRESHOLD 1
#define OCTEP_VF_OQ_INTR_TIME_THRESHOLD 10
#define OCTEP_VF_MSIX_NAME_SIZE (IFNAMSIZ + 32)
/* Tx Queue wake threshold
* wakeup a stopped Tx queue if minimum 2 descriptors are available.
* Even a skb with fragments consume only one Tx queue descriptor entry.
*/
#define OCTEP_VF_WAKE_QUEUE_THRESHOLD 2
/* Minimum MTU supported by Octeon network interface */
#define OCTEP_VF_MIN_MTU ETH_MIN_MTU
/* Maximum MTU supported by Octeon interface*/
#define OCTEP_VF_MAX_MTU (10000 - (ETH_HLEN + ETH_FCS_LEN))
/* Default MTU */
#define OCTEP_VF_DEFAULT_MTU 1500
/* Macros to get octeon config params */
#define CFG_GET_IQ_CFG(cfg) ((cfg)->iq)
#define CFG_GET_IQ_NUM_DESC(cfg) ((cfg)->iq.num_descs)
#define CFG_GET_IQ_INSTR_TYPE(cfg) ((cfg)->iq.instr_type)
#define CFG_GET_IQ_INSTR_SIZE(cfg) (64)
#define CFG_GET_IQ_DB_MIN(cfg) ((cfg)->iq.db_min)
#define CFG_GET_IQ_INTR_THRESHOLD(cfg) ((cfg)->iq.intr_threshold)
#define CFG_GET_OQ_NUM_DESC(cfg) ((cfg)->oq.num_descs)
#define CFG_GET_OQ_BUF_SIZE(cfg) ((cfg)->oq.buf_size)
#define CFG_GET_OQ_REFILL_THRESHOLD(cfg) ((cfg)->oq.refill_threshold)
#define CFG_GET_OQ_INTR_PKT(cfg) ((cfg)->oq.oq_intr_pkt)
#define CFG_GET_OQ_INTR_TIME(cfg) ((cfg)->oq.oq_intr_time)
#define CFG_GET_OQ_WMARK(cfg) ((cfg)->oq.wmark)
#define CFG_GET_PORTS_ACTIVE_IO_RINGS(cfg) ((cfg)->ring_cfg.active_io_rings)
#define CFG_GET_PORTS_MAX_IO_RINGS(cfg) ((cfg)->ring_cfg.max_io_rings)
#define CFG_GET_CORE_TICS_PER_US(cfg) ((cfg)->core_cfg.core_tics_per_us)
#define CFG_GET_COPROC_TICS_PER_US(cfg) ((cfg)->core_cfg.coproc_tics_per_us)
#define CFG_GET_IOQ_MSIX(cfg) ((cfg)->msix_cfg.ioq_msix)
/* Hardware Tx Queue configuration. */
struct octep_vf_iq_config {
/* Size of the Input queue (number of commands) */
u16 num_descs;
/* Command size - 32 or 64 bytes */
u16 instr_type;
/* Minimum number of commands pending to be posted to Octeon before driver
* hits the Input queue doorbell.
*/
u16 db_min;
/* Trigger the IQ interrupt when processed cmd count reaches
* this level.
*/
u32 intr_threshold;
};
/* Hardware Rx Queue configuration. */
struct octep_vf_oq_config {
/* Size of Output queue (number of descriptors) */
u16 num_descs;
/* Size of buffer in this Output queue. */
u16 buf_size;
/* The number of buffers that were consumed during packet processing
* by the driver on this Output queue before the driver attempts to
* replenish the descriptor ring with new buffers.
*/
u16 refill_threshold;
/* Interrupt Coalescing (Packet Count). Octeon will interrupt the host
* only if it sent as many packets as specified by this field.
* The driver usually does not use packet count interrupt coalescing.
*/
u32 oq_intr_pkt;
/* Interrupt Coalescing (Time Interval). Octeon will interrupt the host
* if at least one packet was sent in the time interval specified by
* this field. The driver uses time interval interrupt coalescing by
* default. The time is specified in microseconds.
*/
u32 oq_intr_time;
/* Water mark for backpressure.
* Output queue sends backpressure signal to source when
* free buffer count falls below wmark.
*/
u32 wmark;
};
/* Tx/Rx configuration */
struct octep_vf_ring_config {
/* Max number of IOQs */
u16 max_io_rings;
/* Number of active IOQs */
u16 active_io_rings;
};
/* Octeon MSI-x config. */
struct octep_vf_msix_config {
/* Number of IOQ interrupts */
u16 ioq_msix;
};
/* Data Structure to hold configuration limits and active config */
struct octep_vf_config {
/* Input Queue attributes. */
struct octep_vf_iq_config iq;
/* Output Queue attributes. */
struct octep_vf_oq_config oq;
/* MSI-X interrupt config */
struct octep_vf_msix_config msix_cfg;
/* NIC VF ring Configuration */
struct octep_vf_ring_config ring_cfg;
};
#endif /* _OCTEP_VF_CONFIG_H_ */
// SPDX-License-Identifier: GPL-2.0
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include "octep_vf_config.h"
#include "octep_vf_main.h"
static const char octep_vf_gstrings_global_stats[][ETH_GSTRING_LEN] = {
"rx_alloc_errors",
"tx_busy_errors",
"tx_hw_pkts",
"tx_hw_octs",
"tx_hw_bcast",
"tx_hw_mcast",
"rx_hw_pkts",
"rx_hw_bytes",
"rx_hw_bcast",
"rx_dropped_bytes_fifo_full",
};
#define OCTEP_VF_GLOBAL_STATS_CNT (sizeof(octep_vf_gstrings_global_stats) / ETH_GSTRING_LEN)
static const char octep_vf_gstrings_tx_q_stats[][ETH_GSTRING_LEN] = {
"tx_packets_posted[Q-%u]",
"tx_packets_completed[Q-%u]",
"tx_bytes[Q-%u]",
"tx_busy[Q-%u]",
};
#define OCTEP_VF_TX_Q_STATS_CNT (sizeof(octep_vf_gstrings_tx_q_stats) / ETH_GSTRING_LEN)
static const char octep_vf_gstrings_rx_q_stats[][ETH_GSTRING_LEN] = {
"rx_packets[Q-%u]",
"rx_bytes[Q-%u]",
"rx_alloc_errors[Q-%u]",
};
#define OCTEP_VF_RX_Q_STATS_CNT (sizeof(octep_vf_gstrings_rx_q_stats) / ETH_GSTRING_LEN)
static void octep_vf_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info)
{
struct octep_vf_device *oct = netdev_priv(netdev);
strscpy(info->driver, OCTEP_VF_DRV_NAME, sizeof(info->driver));
strscpy(info->bus_info, pci_name(oct->pdev), sizeof(info->bus_info));
}
static void octep_vf_get_strings(struct net_device *netdev,
u32 stringset, u8 *data)
{
struct octep_vf_device *oct = netdev_priv(netdev);
u16 num_queues = CFG_GET_PORTS_ACTIVE_IO_RINGS(oct->conf);
char *strings = (char *)data;
int i, j;
switch (stringset) {
case ETH_SS_STATS:
for (i = 0; i < OCTEP_VF_GLOBAL_STATS_CNT; i++) {
snprintf(strings, ETH_GSTRING_LEN,
octep_vf_gstrings_global_stats[i]);
strings += ETH_GSTRING_LEN;
}
for (i = 0; i < num_queues; i++) {
for (j = 0; j < OCTEP_VF_TX_Q_STATS_CNT; j++) {
snprintf(strings, ETH_GSTRING_LEN,
octep_vf_gstrings_tx_q_stats[j], i);
strings += ETH_GSTRING_LEN;
}
}
for (i = 0; i < num_queues; i++) {
for (j = 0; j < OCTEP_VF_RX_Q_STATS_CNT; j++) {
snprintf(strings, ETH_GSTRING_LEN,
octep_vf_gstrings_rx_q_stats[j], i);
strings += ETH_GSTRING_LEN;
}
}
break;
default:
break;
}
}
static int octep_vf_get_sset_count(struct net_device *netdev, int sset)
{
struct octep_vf_device *oct = netdev_priv(netdev);
u16 num_queues = CFG_GET_PORTS_ACTIVE_IO_RINGS(oct->conf);
switch (sset) {
case ETH_SS_STATS:
return OCTEP_VF_GLOBAL_STATS_CNT + (num_queues *
(OCTEP_VF_TX_Q_STATS_CNT + OCTEP_VF_RX_Q_STATS_CNT));
break;
default:
return -EOPNOTSUPP;
}
}
static void octep_vf_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
struct octep_vf_device *oct = netdev_priv(netdev);
struct octep_vf_iface_tx_stats *iface_tx_stats;
struct octep_vf_iface_rx_stats *iface_rx_stats;
u64 rx_alloc_errors, tx_busy_errors;
int q, i;
rx_alloc_errors = 0;
tx_busy_errors = 0;
octep_vf_get_if_stats(oct);
iface_tx_stats = &oct->iface_tx_stats;
iface_rx_stats = &oct->iface_rx_stats;
for (q = 0; q < oct->num_oqs; q++) {
struct octep_vf_iq *iq = oct->iq[q];
struct octep_vf_oq *oq = oct->oq[q];
tx_busy_errors += iq->stats.tx_busy;
rx_alloc_errors += oq->stats.alloc_failures;
}
i = 0;
data[i++] = rx_alloc_errors;
data[i++] = tx_busy_errors;
data[i++] = iface_tx_stats->pkts;
data[i++] = iface_tx_stats->octs;
data[i++] = iface_tx_stats->bcst;
data[i++] = iface_tx_stats->mcst;
data[i++] = iface_rx_stats->pkts;
data[i++] = iface_rx_stats->octets;
data[i++] = iface_rx_stats->bcast_pkts;
data[i++] = iface_rx_stats->dropped_octets_fifo_full;
/* Per Tx Queue stats */
for (q = 0; q < oct->num_iqs; q++) {
struct octep_vf_iq *iq = oct->iq[q];
data[i++] = iq->stats.instr_posted;
data[i++] = iq->stats.instr_completed;
data[i++] = iq->stats.bytes_sent;
data[i++] = iq->stats.tx_busy;
}
/* Per Rx Queue stats */
for (q = 0; q < oct->num_oqs; q++) {
struct octep_vf_oq *oq = oct->oq[q];
data[i++] = oq->stats.packets;
data[i++] = oq->stats.bytes;
data[i++] = oq->stats.alloc_failures;
}
}
#define OCTEP_VF_SET_ETHTOOL_LINK_MODES_BITMAP(octep_vf_speeds, ksettings, name) \
{ \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_T)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseT_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_R)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseR_FEC); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_CR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseCR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_KR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseKR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_LR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseLR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_10GBASE_SR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 10000baseSR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_25GBASE_CR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 25000baseCR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_25GBASE_KR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 25000baseKR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_25GBASE_SR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 25000baseSR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_40GBASE_CR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 40000baseCR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_40GBASE_KR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 40000baseKR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_40GBASE_LR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 40000baseLR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_40GBASE_SR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 40000baseSR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_CR2)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseCR2_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_KR2)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseKR2_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_SR2)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseSR2_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_CR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseCR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_KR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseKR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_LR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseLR_ER_FR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_50GBASE_SR)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 50000baseSR_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_100GBASE_CR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 100000baseCR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_100GBASE_KR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 100000baseKR4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_100GBASE_LR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 100000baseLR4_ER4_Full); \
if ((octep_vf_speeds) & BIT(OCTEP_VF_LINK_MODE_100GBASE_SR4)) \
ethtool_link_ksettings_add_link_mode(ksettings, name, 100000baseSR4_Full); \
}
static int octep_vf_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd)
{
struct octep_vf_device *oct = netdev_priv(netdev);
struct octep_vf_iface_link_info *link_info;
u32 advertised_modes, supported_modes;
ethtool_link_ksettings_zero_link_mode(cmd, supported);
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
octep_vf_get_link_info(oct);
advertised_modes = oct->link_info.advertised_modes;
supported_modes = oct->link_info.supported_modes;
link_info = &oct->link_info;
OCTEP_VF_SET_ETHTOOL_LINK_MODES_BITMAP(supported_modes, cmd, supported);
OCTEP_VF_SET_ETHTOOL_LINK_MODES_BITMAP(advertised_modes, cmd, advertising);
if (link_info->autoneg) {
if (link_info->autoneg & OCTEP_VF_LINK_MODE_AUTONEG_SUPPORTED)
ethtool_link_ksettings_add_link_mode(cmd, supported, Autoneg);
if (link_info->autoneg & OCTEP_VF_LINK_MODE_AUTONEG_ADVERTISED) {
ethtool_link_ksettings_add_link_mode(cmd, advertising, Autoneg);
cmd->base.autoneg = AUTONEG_ENABLE;
} else {
cmd->base.autoneg = AUTONEG_DISABLE;
}
} else {
cmd->base.autoneg = AUTONEG_DISABLE;
}
cmd->base.port = PORT_FIBRE;
ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE);
ethtool_link_ksettings_add_link_mode(cmd, advertising, FIBRE);
if (netif_carrier_ok(netdev)) {
cmd->base.speed = link_info->speed;
cmd->base.duplex = DUPLEX_FULL;
} else {
cmd->base.speed = SPEED_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN;
}
return 0;
}
static const struct ethtool_ops octep_vf_ethtool_ops = {
.get_drvinfo = octep_vf_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_strings = octep_vf_get_strings,
.get_sset_count = octep_vf_get_sset_count,
.get_ethtool_stats = octep_vf_get_ethtool_stats,
.get_link_ksettings = octep_vf_get_link_ksettings,
};
void octep_vf_set_ethtool_ops(struct net_device *netdev)
{
netdev->ethtool_ops = &octep_vf_ethtool_ops;
}
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_MAIN_H_
#define _OCTEP_VF_MAIN_H_
#include "octep_vf_tx.h"
#include "octep_vf_rx.h"
#include "octep_vf_mbox.h"
#define OCTEP_VF_DRV_NAME "octeon_ep_vf"
#define OCTEP_VF_DRV_STRING "Marvell Octeon EndPoint NIC VF Driver"
#define OCTEP_PCI_DEVICE_ID_CN93_VF 0xB203 //93xx VF
#define OCTEP_PCI_DEVICE_ID_CNF95N_VF 0xB403 //95N VF
#define OCTEP_PCI_DEVICE_ID_CN98_VF 0xB103
#define OCTEP_PCI_DEVICE_ID_CN10KA_VF 0xB903
#define OCTEP_PCI_DEVICE_ID_CNF10KA_VF 0xBA03
#define OCTEP_PCI_DEVICE_ID_CNF10KB_VF 0xBC03
#define OCTEP_PCI_DEVICE_ID_CN10KB_VF 0xBD03
#define OCTEP_VF_MAX_QUEUES 63
#define OCTEP_VF_MAX_IQ OCTEP_VF_MAX_QUEUES
#define OCTEP_VF_MAX_OQ OCTEP_VF_MAX_QUEUES
#define OCTEP_VF_MAX_MSIX_VECTORS OCTEP_VF_MAX_OQ
#define OCTEP_VF_IQ_INTR_RESEND_BIT 59
#define OCTEP_VF_OQ_INTR_RESEND_BIT 59
#define IQ_INSTR_PENDING(iq) ({ typeof(iq) iq__ = (iq); \
((iq__)->host_write_index - (iq__)->flush_index) & \
(iq__)->ring_size_mask; \
})
#define IQ_INSTR_SPACE(iq) ({ typeof(iq) iq_ = (iq); \
(iq_)->max_count - IQ_INSTR_PENDING(iq_); \
})
/* PCI address space mapping information.
* Each of the 3 address spaces given by BAR0, BAR2 and BAR4 of
* Octeon gets mapped to different physical address spaces in
* the kernel.
*/
struct octep_vf_mmio {
/* The physical address to which the PCI address space is mapped. */
u8 __iomem *hw_addr;
/* Flag indicating the mapping was successful. */
int mapped;
};
struct octep_vf_hw_ops {
void (*setup_iq_regs)(struct octep_vf_device *oct, int q);
void (*setup_oq_regs)(struct octep_vf_device *oct, int q);
void (*setup_mbox_regs)(struct octep_vf_device *oct, int mbox);
irqreturn_t (*non_ioq_intr_handler)(void *ioq_vector);
irqreturn_t (*ioq_intr_handler)(void *ioq_vector);
void (*reinit_regs)(struct octep_vf_device *oct);
u32 (*update_iq_read_idx)(struct octep_vf_iq *iq);
void (*enable_interrupts)(struct octep_vf_device *oct);
void (*disable_interrupts)(struct octep_vf_device *oct);
void (*enable_io_queues)(struct octep_vf_device *oct);
void (*disable_io_queues)(struct octep_vf_device *oct);
void (*enable_iq)(struct octep_vf_device *oct, int q);
void (*disable_iq)(struct octep_vf_device *oct, int q);
void (*enable_oq)(struct octep_vf_device *oct, int q);
void (*disable_oq)(struct octep_vf_device *oct, int q);
void (*reset_io_queues)(struct octep_vf_device *oct);
void (*dump_registers)(struct octep_vf_device *oct);
};
/* Octeon mailbox data */
struct octep_vf_mbox_data {
/* Holds the offset of received data via mailbox. */
u32 data_index;
/* Holds the received data via mailbox. */
u8 recv_data[OCTEP_PFVF_MBOX_MAX_DATA_BUF_SIZE];
};
/* wrappers around work structs */
struct octep_vf_mbox_wk {
struct work_struct work;
void *ctxptr;
};
/* Octeon device mailbox */
struct octep_vf_mbox {
/* A mutex to protect access to this q_mbox. */
struct mutex lock;
u32 state;
/* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
u8 __iomem *mbox_int_reg;
/* SLI_PKT_PF_VF_MBOX_SIG(0) for PF,
* SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
*/
u8 __iomem *mbox_write_reg;
/* SLI_PKT_PF_VF_MBOX_SIG(1) for PF,
* SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
*/
u8 __iomem *mbox_read_reg;
/* Octeon mailbox data */
struct octep_vf_mbox_data mbox_data;
/* Octeon mailbox work handler to process Mbox messages */
struct octep_vf_mbox_wk wk;
};
/* Tx/Rx queue vector per interrupt. */
struct octep_vf_ioq_vector {
char name[OCTEP_VF_MSIX_NAME_SIZE];
struct napi_struct napi;
struct octep_vf_device *octep_vf_dev;
struct octep_vf_iq *iq;
struct octep_vf_oq *oq;
cpumask_t affinity_mask;
};
/* Octeon hardware/firmware offload capability flags. */
#define OCTEP_VF_CAP_TX_CHECKSUM BIT(0)
#define OCTEP_VF_CAP_RX_CHECKSUM BIT(1)
#define OCTEP_VF_CAP_TSO BIT(2)
/* Link modes */
enum octep_vf_link_mode_bit_indices {
OCTEP_VF_LINK_MODE_10GBASE_T = 0,
OCTEP_VF_LINK_MODE_10GBASE_R,
OCTEP_VF_LINK_MODE_10GBASE_CR,
OCTEP_VF_LINK_MODE_10GBASE_KR,
OCTEP_VF_LINK_MODE_10GBASE_LR,
OCTEP_VF_LINK_MODE_10GBASE_SR,
OCTEP_VF_LINK_MODE_25GBASE_CR,
OCTEP_VF_LINK_MODE_25GBASE_KR,
OCTEP_VF_LINK_MODE_25GBASE_SR,
OCTEP_VF_LINK_MODE_40GBASE_CR4,
OCTEP_VF_LINK_MODE_40GBASE_KR4,
OCTEP_VF_LINK_MODE_40GBASE_LR4,
OCTEP_VF_LINK_MODE_40GBASE_SR4,
OCTEP_VF_LINK_MODE_50GBASE_CR2,
OCTEP_VF_LINK_MODE_50GBASE_KR2,
OCTEP_VF_LINK_MODE_50GBASE_SR2,
OCTEP_VF_LINK_MODE_50GBASE_CR,
OCTEP_VF_LINK_MODE_50GBASE_KR,
OCTEP_VF_LINK_MODE_50GBASE_LR,
OCTEP_VF_LINK_MODE_50GBASE_SR,
OCTEP_VF_LINK_MODE_100GBASE_CR4,
OCTEP_VF_LINK_MODE_100GBASE_KR4,
OCTEP_VF_LINK_MODE_100GBASE_LR4,
OCTEP_VF_LINK_MODE_100GBASE_SR4,
OCTEP_VF_LINK_MODE_NBITS
};
/* Hardware interface link state information. */
struct octep_vf_iface_link_info {
/* Bitmap of Supported link speeds/modes. */
u64 supported_modes;
/* Bitmap of Advertised link speeds/modes. */
u64 advertised_modes;
/* Negotiated link speed in Mbps. */
u32 speed;
/* MTU */
u16 mtu;
/* Autonegotiation state. */
#define OCTEP_VF_LINK_MODE_AUTONEG_SUPPORTED BIT(0)
#define OCTEP_VF_LINK_MODE_AUTONEG_ADVERTISED BIT(1)
u8 autoneg;
/* Pause frames setting. */
#define OCTEP_VF_LINK_MODE_PAUSE_SUPPORTED BIT(0)
#define OCTEP_VF_LINK_MODE_PAUSE_ADVERTISED BIT(1)
u8 pause;
/* Admin state of the link (ifconfig <iface> up/down */
u8 admin_up;
/* Operational state of the link: physical link is up down */
u8 oper_up;
};
/* Hardware interface stats information. */
struct octep_vf_iface_rxtx_stats {
/* Hardware Interface Rx statistics */
struct octep_vf_iface_rx_stats iface_rx_stats;
/* Hardware Interface Tx statistics */
struct octep_vf_iface_tx_stats iface_tx_stats;
};
struct octep_vf_fw_info {
/* pkind value to be used in every Tx hardware descriptor */
u8 pkind;
/* front size data */
u8 fsz;
/* supported rx offloads OCTEP_VF_RX_OFFLOAD_* */
u16 rx_ol_flags;
/* supported tx offloads OCTEP_VF_TX_OFFLOAD_* */
u16 tx_ol_flags;
};
/* The Octeon device specific private data structure.
* Each Octeon device has this structure to represent all its components.
*/
struct octep_vf_device {
struct octep_vf_config *conf;
/* Octeon Chip type. */
u16 chip_id;
u16 rev_id;
/* Device capabilities enabled */
u64 caps_enabled;
/* Device capabilities supported */
u64 caps_supported;
/* Pointer to basic Linux device */
struct device *dev;
/* Linux PCI device pointer */
struct pci_dev *pdev;
/* Netdev corresponding to the Octeon device */
struct net_device *netdev;
/* memory mapped io range */
struct octep_vf_mmio mmio;
/* MAC address */
u8 mac_addr[ETH_ALEN];
/* Tx queues (IQ: Instruction Queue) */
u16 num_iqs;
/* Pointers to Octeon Tx queues */
struct octep_vf_iq *iq[OCTEP_VF_MAX_IQ];
/* Rx queues (OQ: Output Queue) */
u16 num_oqs;
/* Pointers to Octeon Rx queues */
struct octep_vf_oq *oq[OCTEP_VF_MAX_OQ];
/* Hardware port number of the PCIe interface */
u16 pcie_port;
/* Hardware operations */
struct octep_vf_hw_ops hw_ops;
/* IRQ info */
u16 num_irqs;
u16 num_non_ioq_irqs;
char *non_ioq_irq_names;
struct msix_entry *msix_entries;
/* IOq information of it's corresponding MSI-X interrupt. */
struct octep_vf_ioq_vector *ioq_vector[OCTEP_VF_MAX_QUEUES];
/* Hardware Interface Tx statistics */
struct octep_vf_iface_tx_stats iface_tx_stats;
/* Hardware Interface Rx statistics */
struct octep_vf_iface_rx_stats iface_rx_stats;
/* Hardware Interface Link info like supported modes, aneg support */
struct octep_vf_iface_link_info link_info;
/* Mailbox to talk to VFs */
struct octep_vf_mbox *mbox;
/* Work entry to handle Tx timeout */
struct work_struct tx_timeout_task;
/* offset for iface stats */
u32 ctrl_mbox_ifstats_offset;
/* Negotiated Mbox version */
u32 mbox_neg_ver;
/* firmware info */
struct octep_vf_fw_info fw_info;
};
static inline u16 OCTEP_VF_MAJOR_REV(struct octep_vf_device *oct)
{
u16 rev = (oct->rev_id & 0xC) >> 2;
return (rev == 0) ? 1 : rev;
}
static inline u16 OCTEP_VF_MINOR_REV(struct octep_vf_device *oct)
{
return (oct->rev_id & 0x3);
}
/* Octeon CSR read/write access APIs */
#define octep_vf_write_csr(octep_vf_dev, reg_off, value) \
writel(value, (octep_vf_dev)->mmio.hw_addr + (reg_off))
#define octep_vf_write_csr64(octep_vf_dev, reg_off, val64) \
writeq(val64, (octep_vf_dev)->mmio.hw_addr + (reg_off))
#define octep_vf_read_csr(octep_vf_dev, reg_off) \
readl((octep_vf_dev)->mmio.hw_addr + (reg_off))
#define octep_vf_read_csr64(octep_vf_dev, reg_off) \
readq((octep_vf_dev)->mmio.hw_addr + (reg_off))
extern struct workqueue_struct *octep_vf_wq;
int octep_vf_device_setup(struct octep_vf_device *oct);
int octep_vf_setup_iqs(struct octep_vf_device *oct);
void octep_vf_free_iqs(struct octep_vf_device *oct);
void octep_vf_clean_iqs(struct octep_vf_device *oct);
int octep_vf_setup_oqs(struct octep_vf_device *oct);
void octep_vf_free_oqs(struct octep_vf_device *oct);
void octep_vf_oq_dbell_init(struct octep_vf_device *oct);
void octep_vf_device_setup_cn93(struct octep_vf_device *oct);
void octep_vf_device_setup_cnxk(struct octep_vf_device *oct);
int octep_vf_iq_process_completions(struct octep_vf_iq *iq, u16 budget);
int octep_vf_oq_process_rx(struct octep_vf_oq *oq, int budget);
void octep_vf_set_ethtool_ops(struct net_device *netdev);
int octep_vf_get_link_info(struct octep_vf_device *oct);
int octep_vf_get_if_stats(struct octep_vf_device *oct);
void octep_vf_mbox_work(struct work_struct *work);
#endif /* _OCTEP_VF_MAIN_H_ */
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_MBOX_H_
#define _OCTEP_VF_MBOX_H_
/* When a new command is implemented, VF Mbox version should be bumped.
*/
enum octep_pfvf_mbox_version {
OCTEP_PFVF_MBOX_VERSION_V0,
OCTEP_PFVF_MBOX_VERSION_V1,
OCTEP_PFVF_MBOX_VERSION_V2
};
#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V2
enum octep_pfvf_mbox_opcode {
OCTEP_PFVF_MBOX_CMD_VERSION,
OCTEP_PFVF_MBOX_CMD_SET_MTU,
OCTEP_PFVF_MBOX_CMD_SET_MAC_ADDR,
OCTEP_PFVF_MBOX_CMD_GET_MAC_ADDR,
OCTEP_PFVF_MBOX_CMD_GET_LINK_INFO,
OCTEP_PFVF_MBOX_CMD_GET_STATS,
OCTEP_PFVF_MBOX_CMD_SET_RX_STATE,
OCTEP_PFVF_MBOX_CMD_SET_LINK_STATUS,
OCTEP_PFVF_MBOX_CMD_GET_LINK_STATUS,
OCTEP_PFVF_MBOX_CMD_GET_MTU,
OCTEP_PFVF_MBOX_CMD_DEV_REMOVE,
OCTEP_PFVF_MBOX_CMD_GET_FW_INFO,
OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS,
OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS,
OCTEP_PFVF_MBOX_CMD_MAX,
};
enum octep_pfvf_mbox_word_type {
OCTEP_PFVF_MBOX_TYPE_CMD,
OCTEP_PFVF_MBOX_TYPE_RSP_ACK,
OCTEP_PFVF_MBOX_TYPE_RSP_NACK,
};
enum octep_pfvf_mbox_cmd_status {
OCTEP_PFVF_MBOX_CMD_STATUS_NOT_SETUP = 1,
OCTEP_PFVF_MBOX_CMD_STATUS_TIMEDOUT = 2,
OCTEP_PFVF_MBOX_CMD_STATUS_NACK = 3,
OCTEP_PFVF_MBOX_CMD_STATUS_BUSY = 4,
OCTEP_PFVF_MBOX_CMD_STATUS_ERR = 5
};
enum octep_pfvf_link_status {
OCTEP_PFVF_LINK_STATUS_DOWN,
OCTEP_PFVF_LINK_STATUS_UP,
};
enum octep_pfvf_link_speed {
OCTEP_PFVF_LINK_SPEED_NONE,
OCTEP_PFVF_LINK_SPEED_1000,
OCTEP_PFVF_LINK_SPEED_10000,
OCTEP_PFVF_LINK_SPEED_25000,
OCTEP_PFVF_LINK_SPEED_40000,
OCTEP_PFVF_LINK_SPEED_50000,
OCTEP_PFVF_LINK_SPEED_100000,
OCTEP_PFVF_LINK_SPEED_LAST,
};
enum octep_pfvf_link_duplex {
OCTEP_PFVF_LINK_HALF_DUPLEX,
OCTEP_PFVF_LINK_FULL_DUPLEX,
};
enum octep_pfvf_link_autoneg {
OCTEP_PFVF_LINK_AUTONEG,
OCTEP_PFVF_LINK_FIXED,
};
#define OCTEP_PFVF_MBOX_TIMEOUT_WAIT_COUNT 8000
#define OCTEP_PFVF_MBOX_TIMEOUT_WAIT_UDELAY 1000
#define OCTEP_PFVF_MBOX_MAX_RETRIES 2
#define OCTEP_PFVF_MBOX_VERSION 0
#define OCTEP_PFVF_MBOX_MAX_DATA_SIZE 6
#define OCTEP_PFVF_MBOX_MAX_DATA_BUF_SIZE 320
#define OCTEP_PFVF_MBOX_MORE_FRAG_FLAG 1
union octep_pfvf_mbox_word {
u64 u64;
struct {
u64 opcode:8;
u64 type:2;
u64 rsvd:6;
u64 data:48;
} s;
struct {
u64 opcode:8;
u64 type:2;
u64 frag:1;
u64 rsvd:5;
u8 data[6];
} s_data;
struct {
u64 opcode:8;
u64 type:2;
u64 rsvd:6;
u64 version:48;
} s_version;
struct {
u64 opcode:8;
u64 type:2;
u64 rsvd:6;
u8 mac_addr[6];
} s_set_mac;
struct {
u64 opcode:8;
u64 type:2;
u64 rsvd:6;
u64 mtu:48;
} s_set_mtu;
struct {
u64 opcode:8;
u64 type:2;
u64 state:1;
u64 rsvd:53;
} s_link_state;
struct {
u64 opcode:8;
u64 type:2;
u64 status:1;
u64 rsvd:53;
} s_link_status;
struct {
u64 opcode:8;
u64 type:2;
u64 pkind:8;
u64 fsz:8;
u64 rx_ol_flags:16;
u64 tx_ol_flags:16;
u64 rsvd:6;
} s_fw_info;
struct {
u64 opcode:8;
u64 type:2;
u64 rsvd:22;
u64 rx_ol_flags:16;
u64 tx_ol_flags:16;
} s_offloads;
} __packed;
int octep_vf_setup_mbox(struct octep_vf_device *oct);
void octep_vf_delete_mbox(struct octep_vf_device *oct);
int octep_vf_mbox_send_cmd(struct octep_vf_device *oct, union octep_pfvf_mbox_word cmd,
union octep_pfvf_mbox_word *rsp);
int octep_vf_mbox_bulk_read(struct octep_vf_device *oct, enum octep_pfvf_mbox_opcode opcode,
u8 *data, int *size);
int octep_vf_mbox_set_mtu(struct octep_vf_device *oct, int mtu);
int octep_vf_mbox_set_mac_addr(struct octep_vf_device *oct, char *mac_addr);
int octep_vf_mbox_get_mac_addr(struct octep_vf_device *oct, char *mac_addr);
int octep_vf_mbox_version_check(struct octep_vf_device *oct);
int octep_vf_mbox_set_rx_state(struct octep_vf_device *oct, bool state);
int octep_vf_mbox_set_link_status(struct octep_vf_device *oct, bool status);
int octep_vf_mbox_get_link_status(struct octep_vf_device *oct, u8 *oper_up);
int octep_vf_mbox_dev_remove(struct octep_vf_device *oct);
int octep_vf_mbox_get_fw_info(struct octep_vf_device *oct);
int octep_vf_mbox_set_offloads(struct octep_vf_device *oct, u16 tx_offloads, u16 rx_offloads);
#endif
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_REGS_CN9K_H_
#define _OCTEP_VF_REGS_CN9K_H_
/*############################ RST #########################*/
#define CN93_VF_CONFIG_XPANSION_BAR 0x38
#define CN93_VF_CONFIG_PCIE_CAP 0x70
#define CN93_VF_CONFIG_PCIE_DEVCAP 0x74
#define CN93_VF_CONFIG_PCIE_DEVCTL 0x78
#define CN93_VF_CONFIG_PCIE_LINKCAP 0x7C
#define CN93_VF_CONFIG_PCIE_LINKCTL 0x80
#define CN93_VF_CONFIG_PCIE_SLOTCAP 0x84
#define CN93_VF_CONFIG_PCIE_SLOTCTL 0x88
#define CN93_VF_RING_OFFSET BIT_ULL(17)
/*###################### RING IN REGISTERS #########################*/
#define CN93_VF_SDP_R_IN_CONTROL_START 0x10000
#define CN93_VF_SDP_R_IN_ENABLE_START 0x10010
#define CN93_VF_SDP_R_IN_INSTR_BADDR_START 0x10020
#define CN93_VF_SDP_R_IN_INSTR_RSIZE_START 0x10030
#define CN93_VF_SDP_R_IN_INSTR_DBELL_START 0x10040
#define CN93_VF_SDP_R_IN_CNTS_START 0x10050
#define CN93_VF_SDP_R_IN_INT_LEVELS_START 0x10060
#define CN93_VF_SDP_R_IN_PKT_CNT_START 0x10080
#define CN93_VF_SDP_R_IN_BYTE_CNT_START 0x10090
#define CN93_VF_SDP_R_IN_CONTROL(ring) \
(CN93_VF_SDP_R_IN_CONTROL_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_ENABLE(ring) \
(CN93_VF_SDP_R_IN_ENABLE_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_INSTR_BADDR(ring) \
(CN93_VF_SDP_R_IN_INSTR_BADDR_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_INSTR_RSIZE(ring) \
(CN93_VF_SDP_R_IN_INSTR_RSIZE_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_INSTR_DBELL(ring) \
(CN93_VF_SDP_R_IN_INSTR_DBELL_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_CNTS(ring) \
(CN93_VF_SDP_R_IN_CNTS_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_INT_LEVELS(ring) \
(CN93_VF_SDP_R_IN_INT_LEVELS_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_PKT_CNT(ring) \
(CN93_VF_SDP_R_IN_PKT_CNT_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_IN_BYTE_CNT(ring) \
(CN93_VF_SDP_R_IN_BYTE_CNT_START + ((ring) * CN93_VF_RING_OFFSET))
/*------------------ R_IN Masks ----------------*/
/** Rings per Virtual Function **/
#define CN93_VF_R_IN_CTL_RPVF_MASK (0xF)
#define CN93_VF_R_IN_CTL_RPVF_POS (48)
/* Number of instructions to be read in one MAC read request.
* setting to Max value(4)
**/
#define CN93_VF_R_IN_CTL_IDLE BIT_ULL(28)
#define CN93_VF_R_IN_CTL_RDSIZE (0x3ULL << 25)
#define CN93_VF_R_IN_CTL_IS_64B BIT_ULL(24)
#define CN93_VF_R_IN_CTL_D_NSR BIT_ULL(8)
#define CN93_VF_R_IN_CTL_D_ESR BIT_ULL(6)
#define CN93_VF_R_IN_CTL_D_ROR BIT_ULL(5)
#define CN93_VF_R_IN_CTL_NSR BIT_ULL(3)
#define CN93_VF_R_IN_CTL_ESR BIT_ULL(1)
#define CN93_VF_R_IN_CTL_ROR BIT_ULL(0)
#define CN93_VF_R_IN_CTL_MASK (CN93_VF_R_IN_CTL_RDSIZE | CN93_VF_R_IN_CTL_IS_64B)
/*###################### RING OUT REGISTERS #########################*/
#define CN93_VF_SDP_R_OUT_CNTS_START 0x10100
#define CN93_VF_SDP_R_OUT_INT_LEVELS_START 0x10110
#define CN93_VF_SDP_R_OUT_SLIST_BADDR_START 0x10120
#define CN93_VF_SDP_R_OUT_SLIST_RSIZE_START 0x10130
#define CN93_VF_SDP_R_OUT_SLIST_DBELL_START 0x10140
#define CN93_VF_SDP_R_OUT_CONTROL_START 0x10150
#define CN93_VF_SDP_R_OUT_ENABLE_START 0x10160
#define CN93_VF_SDP_R_OUT_PKT_CNT_START 0x10180
#define CN93_VF_SDP_R_OUT_BYTE_CNT_START 0x10190
#define CN93_VF_SDP_R_OUT_CONTROL(ring) \
(CN93_VF_SDP_R_OUT_CONTROL_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_ENABLE(ring) \
(CN93_VF_SDP_R_OUT_ENABLE_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_SLIST_BADDR(ring) \
(CN93_VF_SDP_R_OUT_SLIST_BADDR_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_SLIST_RSIZE(ring) \
(CN93_VF_SDP_R_OUT_SLIST_RSIZE_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_SLIST_DBELL(ring) \
(CN93_VF_SDP_R_OUT_SLIST_DBELL_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_CNTS(ring) \
(CN93_VF_SDP_R_OUT_CNTS_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_INT_LEVELS(ring) \
(CN93_VF_SDP_R_OUT_INT_LEVELS_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_PKT_CNT(ring) \
(CN93_VF_SDP_R_OUT_PKT_CNT_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_OUT_BYTE_CNT(ring) \
(CN93_VF_SDP_R_OUT_BYTE_CNT_START + ((ring) * CN93_VF_RING_OFFSET))
/*------------------ R_OUT Masks ----------------*/
#define CN93_VF_R_OUT_INT_LEVELS_BMODE BIT_ULL(63)
#define CN93_VF_R_OUT_INT_LEVELS_TIMET (32)
#define CN93_VF_R_OUT_CTL_IDLE BIT_ULL(40)
#define CN93_VF_R_OUT_CTL_ES_I BIT_ULL(34)
#define CN93_VF_R_OUT_CTL_NSR_I BIT_ULL(33)
#define CN93_VF_R_OUT_CTL_ROR_I BIT_ULL(32)
#define CN93_VF_R_OUT_CTL_ES_D BIT_ULL(30)
#define CN93_VF_R_OUT_CTL_NSR_D BIT_ULL(29)
#define CN93_VF_R_OUT_CTL_ROR_D BIT_ULL(28)
#define CN93_VF_R_OUT_CTL_ES_P BIT_ULL(26)
#define CN93_VF_R_OUT_CTL_NSR_P BIT_ULL(25)
#define CN93_VF_R_OUT_CTL_ROR_P BIT_ULL(24)
#define CN93_VF_R_OUT_CTL_IMODE BIT_ULL(23)
/* ##################### Mail Box Registers ########################## */
/* SDP PF to VF Mailbox Data Register */
#define CN93_VF_SDP_R_MBOX_PF_VF_DATA_START 0x10210
/* SDP Packet PF to VF Mailbox Interrupt Register */
#define CN93_VF_SDP_R_MBOX_PF_VF_INT_START 0x10220
/* SDP VF to PF Mailbox Data Register */
#define CN93_VF_SDP_R_MBOX_VF_PF_DATA_START 0x10230
#define CN93_VF_SDP_R_MBOX_PF_VF_INT_ENAB BIT_ULL(1)
#define CN93_VF_SDP_R_MBOX_PF_VF_INT_STATUS BIT_ULL(0)
#define CN93_VF_SDP_R_MBOX_PF_VF_DATA(ring) \
(CN93_VF_SDP_R_MBOX_PF_VF_DATA_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_MBOX_PF_VF_INT(ring) \
(CN93_VF_SDP_R_MBOX_PF_VF_INT_START + ((ring) * CN93_VF_RING_OFFSET))
#define CN93_VF_SDP_R_MBOX_VF_PF_DATA(ring) \
(CN93_VF_SDP_R_MBOX_VF_PF_DATA_START + ((ring) * CN93_VF_RING_OFFSET))
#endif /* _OCTEP_VF_REGS_CN9K_H_ */
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_REGS_CNXK_H_
#define _OCTEP_VF_REGS_CNXK_H_
/*############################ RST #########################*/
#define CNXK_VF_CONFIG_XPANSION_BAR 0x38
#define CNXK_VF_CONFIG_PCIE_CAP 0x70
#define CNXK_VF_CONFIG_PCIE_DEVCAP 0x74
#define CNXK_VF_CONFIG_PCIE_DEVCTL 0x78
#define CNXK_VF_CONFIG_PCIE_LINKCAP 0x7C
#define CNXK_VF_CONFIG_PCIE_LINKCTL 0x80
#define CNXK_VF_CONFIG_PCIE_SLOTCAP 0x84
#define CNXK_VF_CONFIG_PCIE_SLOTCTL 0x88
#define CNXK_VF_RING_OFFSET (0x1ULL << 17)
/*###################### RING IN REGISTERS #########################*/
#define CNXK_VF_SDP_R_IN_CONTROL_START 0x10000
#define CNXK_VF_SDP_R_IN_ENABLE_START 0x10010
#define CNXK_VF_SDP_R_IN_INSTR_BADDR_START 0x10020
#define CNXK_VF_SDP_R_IN_INSTR_RSIZE_START 0x10030
#define CNXK_VF_SDP_R_IN_INSTR_DBELL_START 0x10040
#define CNXK_VF_SDP_R_IN_CNTS_START 0x10050
#define CNXK_VF_SDP_R_IN_INT_LEVELS_START 0x10060
#define CNXK_VF_SDP_R_IN_PKT_CNT_START 0x10080
#define CNXK_VF_SDP_R_IN_BYTE_CNT_START 0x10090
#define CNXK_VF_SDP_R_ERR_TYPE_START 0x10400
#define CNXK_VF_SDP_R_ERR_TYPE(ring) \
(CNXK_VF_SDP_R_ERR_TYPE_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_CONTROL(ring) \
(CNXK_VF_SDP_R_IN_CONTROL_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_ENABLE(ring) \
(CNXK_VF_SDP_R_IN_ENABLE_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_INSTR_BADDR(ring) \
(CNXK_VF_SDP_R_IN_INSTR_BADDR_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_INSTR_RSIZE(ring) \
(CNXK_VF_SDP_R_IN_INSTR_RSIZE_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_INSTR_DBELL(ring) \
(CNXK_VF_SDP_R_IN_INSTR_DBELL_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_CNTS(ring) \
(CNXK_VF_SDP_R_IN_CNTS_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_INT_LEVELS(ring) \
(CNXK_VF_SDP_R_IN_INT_LEVELS_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_PKT_CNT(ring) \
(CNXK_VF_SDP_R_IN_PKT_CNT_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_IN_BYTE_CNT(ring) \
(CNXK_VF_SDP_R_IN_BYTE_CNT_START + ((ring) * CNXK_VF_RING_OFFSET))
/*------------------ R_IN Masks ----------------*/
/** Rings per Virtual Function **/
#define CNXK_VF_R_IN_CTL_RPVF_MASK (0xF)
#define CNXK_VF_R_IN_CTL_RPVF_POS (48)
/* Number of instructions to be read in one MAC read request.
* setting to Max value(4)
**/
#define CNXK_VF_R_IN_CTL_IDLE (0x1ULL << 28)
#define CNXK_VF_R_IN_CTL_RDSIZE (0x3ULL << 25)
#define CNXK_VF_R_IN_CTL_IS_64B (0x1ULL << 24)
#define CNXK_VF_R_IN_CTL_D_NSR (0x1ULL << 8)
#define CNXK_VF_R_IN_CTL_D_ESR (0x1ULL << 6)
#define CNXK_VF_R_IN_CTL_D_ROR (0x1ULL << 5)
#define CNXK_VF_R_IN_CTL_NSR (0x1ULL << 3)
#define CNXK_VF_R_IN_CTL_ESR (0x1ULL << 1)
#define CNXK_VF_R_IN_CTL_ROR (0x1ULL << 0)
#define CNXK_VF_R_IN_CTL_MASK (CNXK_VF_R_IN_CTL_RDSIZE | CNXK_VF_R_IN_CTL_IS_64B)
/*###################### RING OUT REGISTERS #########################*/
#define CNXK_VF_SDP_R_OUT_CNTS_START 0x10100
#define CNXK_VF_SDP_R_OUT_INT_LEVELS_START 0x10110
#define CNXK_VF_SDP_R_OUT_SLIST_BADDR_START 0x10120
#define CNXK_VF_SDP_R_OUT_SLIST_RSIZE_START 0x10130
#define CNXK_VF_SDP_R_OUT_SLIST_DBELL_START 0x10140
#define CNXK_VF_SDP_R_OUT_CONTROL_START 0x10150
#define CNXK_VF_SDP_R_OUT_WMARK_START 0x10160
#define CNXK_VF_SDP_R_OUT_ENABLE_START 0x10170
#define CNXK_VF_SDP_R_OUT_PKT_CNT_START 0x10180
#define CNXK_VF_SDP_R_OUT_BYTE_CNT_START 0x10190
#define CNXK_VF_SDP_R_OUT_CONTROL(ring) \
(CNXK_VF_SDP_R_OUT_CONTROL_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_ENABLE(ring) \
(CNXK_VF_SDP_R_OUT_ENABLE_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_SLIST_BADDR(ring) \
(CNXK_VF_SDP_R_OUT_SLIST_BADDR_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_SLIST_RSIZE(ring) \
(CNXK_VF_SDP_R_OUT_SLIST_RSIZE_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_SLIST_DBELL(ring) \
(CNXK_VF_SDP_R_OUT_SLIST_DBELL_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_WMARK(ring) \
(CNXK_VF_SDP_R_OUT_WMARK_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_CNTS(ring) \
(CNXK_VF_SDP_R_OUT_CNTS_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_INT_LEVELS(ring) \
(CNXK_VF_SDP_R_OUT_INT_LEVELS_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_PKT_CNT(ring) \
(CNXK_VF_SDP_R_OUT_PKT_CNT_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_OUT_BYTE_CNT(ring) \
(CNXK_VF_SDP_R_OUT_BYTE_CNT_START + ((ring) * CNXK_VF_RING_OFFSET))
/*------------------ R_OUT Masks ----------------*/
#define CNXK_VF_R_OUT_INT_LEVELS_BMODE BIT_ULL(63)
#define CNXK_VF_R_OUT_INT_LEVELS_TIMET (32)
#define CNXK_VF_R_OUT_CTL_IDLE BIT_ULL(40)
#define CNXK_VF_R_OUT_CTL_ES_I BIT_ULL(34)
#define CNXK_VF_R_OUT_CTL_NSR_I BIT_ULL(33)
#define CNXK_VF_R_OUT_CTL_ROR_I BIT_ULL(32)
#define CNXK_VF_R_OUT_CTL_ES_D BIT_ULL(30)
#define CNXK_VF_R_OUT_CTL_NSR_D BIT_ULL(29)
#define CNXK_VF_R_OUT_CTL_ROR_D BIT_ULL(28)
#define CNXK_VF_R_OUT_CTL_ES_P BIT_ULL(26)
#define CNXK_VF_R_OUT_CTL_NSR_P BIT_ULL(25)
#define CNXK_VF_R_OUT_CTL_ROR_P BIT_ULL(24)
#define CNXK_VF_R_OUT_CTL_IMODE BIT_ULL(23)
/* ##################### Mail Box Registers ########################## */
/* SDP PF to VF Mailbox Data Register */
#define CNXK_VF_SDP_R_MBOX_PF_VF_DATA_START 0x10210
/* SDP Packet PF to VF Mailbox Interrupt Register */
#define CNXK_VF_SDP_R_MBOX_PF_VF_INT_START 0x10220
/* SDP VF to PF Mailbox Data Register */
#define CNXK_VF_SDP_R_MBOX_VF_PF_DATA_START 0x10230
#define CNXK_VF_SDP_R_MBOX_PF_VF_INT_ENAB BIT_ULL(1)
#define CNXK_VF_SDP_R_MBOX_PF_VF_INT_STATUS BIT_ULL(0)
#define CNXK_VF_SDP_R_MBOX_PF_VF_DATA(ring) \
(CNXK_VF_SDP_R_MBOX_PF_VF_DATA_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_MBOX_PF_VF_INT(ring) \
(CNXK_VF_SDP_R_MBOX_PF_VF_INT_START + ((ring) * CNXK_VF_RING_OFFSET))
#define CNXK_VF_SDP_R_MBOX_VF_PF_DATA(ring) \
(CNXK_VF_SDP_R_MBOX_VF_PF_DATA_START + ((ring) * CNXK_VF_RING_OFFSET))
#endif /* _OCTEP_VF_REGS_CNXK_H_ */
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_RX_H_
#define _OCTEP_VF_RX_H_
/* struct octep_vf_oq_desc_hw - Octeon Hardware OQ descriptor format.
*
* The descriptor ring is made of descriptors which have 2 64-bit values:
*
* @buffer_ptr: DMA address of the skb->data
* @info_ptr: DMA address of host memory, used to update pkt count by hw.
* This is currently unused to save pci writes.
*/
struct octep_vf_oq_desc_hw {
dma_addr_t buffer_ptr;
u64 info_ptr;
};
static_assert(sizeof(struct octep_vf_oq_desc_hw) == 16);
#define OCTEP_VF_OQ_DESC_SIZE (sizeof(struct octep_vf_oq_desc_hw))
/* Rx offload flags */
#define OCTEP_VF_RX_OFFLOAD_VLAN_STRIP BIT(0)
#define OCTEP_VF_RX_OFFLOAD_IPV4_CKSUM BIT(1)
#define OCTEP_VF_RX_OFFLOAD_UDP_CKSUM BIT(2)
#define OCTEP_VF_RX_OFFLOAD_TCP_CKSUM BIT(3)
#define OCTEP_VF_RX_OFFLOAD_CKSUM (OCTEP_VF_RX_OFFLOAD_IPV4_CKSUM | \
OCTEP_VF_RX_OFFLOAD_UDP_CKSUM | \
OCTEP_VF_RX_OFFLOAD_TCP_CKSUM)
#define OCTEP_VF_RX_IP_CSUM(flags) ((flags) & \
(OCTEP_VF_RX_OFFLOAD_IPV4_CKSUM | \
OCTEP_VF_RX_OFFLOAD_TCP_CKSUM | \
OCTEP_VF_RX_OFFLOAD_UDP_CKSUM))
/* bit 0 is vlan strip */
#define OCTEP_VF_RX_CSUM_IP_VERIFIED BIT(1)
#define OCTEP_VF_RX_CSUM_L4_VERIFIED BIT(2)
#define OCTEP_VF_RX_CSUM_VERIFIED(flags) ((flags) & \
(OCTEP_VF_RX_CSUM_L4_VERIFIED | \
OCTEP_VF_RX_CSUM_IP_VERIFIED))
/* Extended Response Header in packet data received from Hardware.
* Includes metadata like checksum status.
* this is valid only if hardware/firmware published support for this.
* This is at offset 0 of packet data (skb->data).
*/
struct octep_vf_oq_resp_hw_ext {
/* Reserved. */
u64 rsvd:48;
/* rx offload flags */
u16 rx_ol_flags;
};
static_assert(sizeof(struct octep_vf_oq_resp_hw_ext) == 8);
#define OCTEP_VF_OQ_RESP_HW_EXT_SIZE (sizeof(struct octep_vf_oq_resp_hw_ext))
/* Length of Rx packet DMA'ed by Octeon to Host.
* this is in bigendian; so need to be converted to cpu endian.
* Octeon writes this at the beginning of Rx buffer (skb->data).
*/
struct octep_vf_oq_resp_hw {
/* The Length of the packet. */
__be64 length;
};
static_assert(sizeof(struct octep_vf_oq_resp_hw) == 8);
#define OCTEP_VF_OQ_RESP_HW_SIZE (sizeof(struct octep_vf_oq_resp_hw))
/* Pointer to data buffer.
* Driver keeps a pointer to the data buffer that it made available to
* the Octeon device. Since the descriptor ring keeps physical (bus)
* addresses, this field is required for the driver to keep track of
* the virtual address pointers. The fields are operated by
* OS-dependent routines.
*/
struct octep_vf_rx_buffer {
struct page *page;
/* length from rx hardware descriptor after converting to cpu endian */
u64 len;
};
#define OCTEP_VF_OQ_RECVBUF_SIZE (sizeof(struct octep_vf_rx_buffer))
/* Output Queue statistics. Each output queue has four stats fields. */
struct octep_vf_oq_stats {
/* Number of packets received from the Device. */
u64 packets;
/* Number of bytes received from the Device. */
u64 bytes;
/* Number of times failed to allocate buffers. */
u64 alloc_failures;
};
#define OCTEP_VF_OQ_STATS_SIZE (sizeof(struct octep_vf_oq_stats))
/* Hardware interface Rx statistics */
struct octep_vf_iface_rx_stats {
/* Received packets */
u64 pkts;
/* Octets of received packets */
u64 octets;
/* Received PAUSE and Control packets */
u64 pause_pkts;
/* Received PAUSE and Control octets */
u64 pause_octets;
/* Filtered DMAC0 packets */
u64 dmac0_pkts;
/* Filtered DMAC0 octets */
u64 dmac0_octets;
/* Packets dropped due to RX FIFO full */
u64 dropped_pkts_fifo_full;
/* Octets dropped due to RX FIFO full */
u64 dropped_octets_fifo_full;
/* Error packets */
u64 err_pkts;
/* Filtered DMAC1 packets */
u64 dmac1_pkts;
/* Filtered DMAC1 octets */
u64 dmac1_octets;
/* NCSI-bound packets dropped */
u64 ncsi_dropped_pkts;
/* NCSI-bound octets dropped */
u64 ncsi_dropped_octets;
/* Multicast packets received. */
u64 mcast_pkts;
/* Broadcast packets received. */
u64 bcast_pkts;
};
/* The Descriptor Ring Output Queue structure.
* This structure has all the information required to implement a
* Octeon OQ.
*/
struct octep_vf_oq {
u32 q_no;
struct octep_vf_device *octep_vf_dev;
struct net_device *netdev;
struct device *dev;
struct napi_struct *napi;
/* The receive buffer list. This list has the virtual addresses
* of the buffers.
*/
struct octep_vf_rx_buffer *buff_info;
/* Pointer to the mapped packet credit register.
* Host writes number of info/buffer ptrs available to this register
*/
u8 __iomem *pkts_credit_reg;
/* Pointer to the mapped packet sent register.
* Octeon writes the number of packets DMA'ed to host memory
* in this register.
*/
u8 __iomem *pkts_sent_reg;
/* Statistics for this OQ. */
struct octep_vf_oq_stats stats;
/* Packets pending to be processed */
u32 pkts_pending;
u32 last_pkt_count;
/* Index in the ring where the driver should read the next packet */
u32 host_read_idx;
/* Number of descriptors in this ring. */
u32 max_count;
u32 ring_size_mask;
/* The number of descriptors pending refill. */
u32 refill_count;
/* Index in the ring where the driver will refill the
* descriptor's buffer
*/
u32 host_refill_idx;
u32 refill_threshold;
/* The size of each buffer pointed by the buffer pointer. */
u32 buffer_size;
u32 max_single_buffer_size;
/* The 8B aligned descriptor ring starts at this address. */
struct octep_vf_oq_desc_hw *desc_ring;
/* DMA mapped address of the OQ descriptor ring. */
dma_addr_t desc_ring_dma;
};
#define OCTEP_VF_OQ_SIZE (sizeof(struct octep_vf_oq))
#endif /* _OCTEP_VF_RX_H_ */
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef _OCTEP_VF_TX_H_
#define _OCTEP_VF_TX_H_
#define IQ_SEND_OK 0
#define IQ_SEND_STOP 1
#define IQ_SEND_FAILED -1
#define TX_BUFTYPE_NONE 0
#define TX_BUFTYPE_NET 1
#define TX_BUFTYPE_NET_SG 2
#define NUM_TX_BUFTYPES 3
/* Hardware format for Scatter/Gather list
*
* 63 48|47 32|31 16|15 0
* -----------------------------------------
* | Len 0 | Len 1 | Len 2 | Len 3 |
* -----------------------------------------
* | Ptr 0 |
* -----------------------------------------
* | Ptr 1 |
* -----------------------------------------
* | Ptr 2 |
* -----------------------------------------
* | Ptr 3 |
* -----------------------------------------
*/
struct octep_vf_tx_sglist_desc {
u16 len[4];
dma_addr_t dma_ptr[4];
};
static_assert(sizeof(struct octep_vf_tx_sglist_desc) == 40);
/* Each Scatter/Gather entry sent to hardwar hold four pointers.
* So, number of entries required is (MAX_SKB_FRAGS + 1)/4, where '+1'
* is for main skb which also goes as a gather buffer to Octeon hardware.
* To allocate sufficient SGLIST entries for a packet with max fragments,
* align by adding 3 before calcuating max SGLIST entries per packet.
*/
#define OCTEP_VF_SGLIST_ENTRIES_PER_PKT ((MAX_SKB_FRAGS + 1 + 3) / 4)
#define OCTEP_VF_SGLIST_SIZE_PER_PKT \
(OCTEP_VF_SGLIST_ENTRIES_PER_PKT * sizeof(struct octep_vf_tx_sglist_desc))
struct octep_vf_tx_buffer {
struct sk_buff *skb;
dma_addr_t dma;
struct octep_vf_tx_sglist_desc *sglist;
dma_addr_t sglist_dma;
u8 gather;
};
#define OCTEP_VF_IQ_TXBUFF_INFO_SIZE (sizeof(struct octep_vf_tx_buffer))
/* VF Hardware interface Tx statistics */
struct octep_vf_iface_tx_stats {
/* Total frames sent on the interface */
u64 pkts;
/* Total octets sent on the interface */
u64 octs;
/* Packets sent to a broadcast DMAC */
u64 bcst;
/* Packets sent to the multicast DMAC */
u64 mcst;
/* Packets dropped */
u64 dropped;
/* Reserved */
u64 reserved[13];
};
/* VF Input Queue statistics */
struct octep_vf_iq_stats {
/* Instructions posted to this queue. */
u64 instr_posted;
/* Instructions copied by hardware for processing. */
u64 instr_completed;
/* Instructions that could not be processed. */
u64 instr_dropped;
/* Bytes sent through this queue. */
u64 bytes_sent;
/* Gather entries sent through this queue. */
u64 sgentry_sent;
/* Number of transmit failures due to TX_BUSY */
u64 tx_busy;
/* Number of times the queue is restarted */
u64 restart_cnt;
};
/* The instruction (input) queue.
* The input queue is used to post raw (instruction) mode data or packet
* data to Octeon device from the host. Each input queue (up to 4) for
* a Octeon device has one such structure to represent it.
*/
struct octep_vf_iq {
u32 q_no;
struct octep_vf_device *octep_vf_dev;
struct net_device *netdev;
struct device *dev;
struct netdev_queue *netdev_q;
/* Index in input ring where driver should write the next packet */
u16 host_write_index;
/* Index in input ring where Octeon is expected to read next packet */
u16 octep_vf_read_index;
/* This index aids in finding the window in the queue where Octeon
* has read the commands.
*/
u16 flush_index;
/* Statistics for this input queue. */
struct octep_vf_iq_stats stats;
/* Pointer to the Virtual Base addr of the input ring. */
struct octep_vf_tx_desc_hw *desc_ring;
/* DMA mapped base address of the input descriptor ring. */
dma_addr_t desc_ring_dma;
/* Info of Tx buffers pending completion. */
struct octep_vf_tx_buffer *buff_info;
/* Base pointer to Scatter/Gather lists for all ring descriptors. */
struct octep_vf_tx_sglist_desc *sglist;
/* DMA mapped addr of Scatter Gather Lists */
dma_addr_t sglist_dma;
/* Octeon doorbell register for the ring. */
u8 __iomem *doorbell_reg;
/* Octeon instruction count register for this ring. */
u8 __iomem *inst_cnt_reg;
/* interrupt level register for this ring */
u8 __iomem *intr_lvl_reg;
/* Maximum no. of instructions in this queue. */
u32 max_count;
u32 ring_size_mask;
u32 pkt_in_done;
u32 pkts_processed;
u32 status;
/* Number of instructions pending to be posted to Octeon. */
u32 fill_cnt;
/* The max. number of instructions that can be held pending by the
* driver before ringing doorbell.
*/
u32 fill_threshold;
};
/* Hardware Tx Instruction Header */
struct octep_vf_instr_hdr {
/* Data Len */
u64 tlen:16;
/* Reserved */
u64 rsvd:20;
/* PKIND for SDP */
u64 pkind:6;
/* Front Data size */
u64 fsz:6;
/* No. of entries in gather list */
u64 gsz:14;
/* Gather indicator 1=gather*/
u64 gather:1;
/* Reserved3 */
u64 reserved3:1;
};
static_assert(sizeof(struct octep_vf_instr_hdr) == 8);
/* Tx offload flags */
#define OCTEP_VF_TX_OFFLOAD_VLAN_INSERT BIT(0)
#define OCTEP_VF_TX_OFFLOAD_IPV4_CKSUM BIT(1)
#define OCTEP_VF_TX_OFFLOAD_UDP_CKSUM BIT(2)
#define OCTEP_VF_TX_OFFLOAD_TCP_CKSUM BIT(3)
#define OCTEP_VF_TX_OFFLOAD_SCTP_CKSUM BIT(4)
#define OCTEP_VF_TX_OFFLOAD_TCP_TSO BIT(5)
#define OCTEP_VF_TX_OFFLOAD_UDP_TSO BIT(6)
#define OCTEP_VF_TX_OFFLOAD_CKSUM (OCTEP_VF_TX_OFFLOAD_IPV4_CKSUM | \
OCTEP_VF_TX_OFFLOAD_UDP_CKSUM | \
OCTEP_VF_TX_OFFLOAD_TCP_CKSUM)
#define OCTEP_VF_TX_OFFLOAD_TSO (OCTEP_VF_TX_OFFLOAD_TCP_TSO | \
OCTEP_VF_TX_OFFLOAD_UDP_TSO)
#define OCTEP_VF_TX_IP_CSUM(flags) ((flags) & \
(OCTEP_VF_TX_OFFLOAD_IPV4_CKSUM | \
OCTEP_VF_TX_OFFLOAD_TCP_CKSUM | \
OCTEP_VF_TX_OFFLOAD_UDP_CKSUM))
#define OCTEP_VF_TX_TSO(flags) ((flags) & \
(OCTEP_VF_TX_OFFLOAD_TCP_TSO | \
OCTEP_VF_TX_OFFLOAD_UDP_TSO))
struct tx_mdata {
/* offload flags */
u16 ol_flags;
/* gso size */
u16 gso_size;
/* gso flags */
u16 gso_segs;
/* reserved */
u16 rsvd1;
/* reserved */
u64 rsvd2;
};
static_assert(sizeof(struct tx_mdata) == 16);
/* 64-byte Tx instruction format.
* Format of instruction for a 64-byte mode input queue.
*
* only first 16-bytes (dptr and ih) are mandatory; rest are optional
* and filled by the driver based on firmware/hardware capabilities.
* These optional headers together called Front Data and its size is
* described by ih->fsz.
*/
struct octep_vf_tx_desc_hw {
/* Pointer where the input data is available. */
u64 dptr;
/* Instruction Header. */
union {
struct octep_vf_instr_hdr ih;
u64 ih64;
};
union {
u64 txm64[2];
struct tx_mdata txm;
};
/* Additional headers available in a 64-byte instruction. */
u64 exhdr[4];
};
static_assert(sizeof(struct octep_vf_tx_desc_hw) == 64);
#define OCTEP_VF_IQ_DESC_SIZE (sizeof(struct octep_vf_tx_desc_hw))
#endif /* _OCTEP_VF_TX_H_ */
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