Skip to content

Commit

Permalink
octeon_ep_vf: Add driver framework and device initialization
Browse files Browse the repository at this point in the history
Add driver framework and device setup and initialization for Octeon
PCI Endpoint NIC VF.

Add implementation to load module, initialize, register network device,
cleanup and unload module.

Signed-off-by: Shinas Rasheed <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
shinas-marvell authored and davem330 committed Jan 2, 2024
1 parent 3ce4f9c commit ebdc193
Show file tree
Hide file tree
Showing 19 changed files with 2,416 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/networking/device_drivers/ethernet/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Contents:
intel/ice
marvell/octeontx2
marvell/octeon_ep
marvell/octeon_ep_vf
mellanox/mlx5/index
microsoft/netvsc
neterion/s2io
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. 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
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ config SKY2_DEBUG

source "drivers/net/ethernet/marvell/octeontx2/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"

endif # NET_VENDOR_MARVELL
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o
obj-$(CONFIG_SKGE) += skge.o
obj-$(CONFIG_SKY2) += sky2.o
obj-y += octeon_ep/
obj-y += octeon_ep_vf/
obj-y += octeontx2/
obj-y += prestera/
19 changes: 19 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep_vf/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.
9 changes: 9 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep_vf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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
157 changes: 157 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// 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/etherdevice.h>

#include "octep_vf_config.h"
#include "octep_vf_main.h"
#include "octep_vf_regs_cn9k.h"

/* Reset all hardware Tx/Rx queues */
static void octep_vf_reset_io_queues_cn93(struct octep_vf_device *oct)
{
}

/* Initialize configuration limits and initial active config */
static void octep_vf_init_config_cn93_vf(struct octep_vf_device *oct)
{
struct octep_vf_config *conf = oct->conf;
u64 reg_val;

reg_val = octep_vf_read_csr64(oct, CN93_VF_SDP_R_IN_CONTROL(0));
conf->ring_cfg.max_io_rings = (reg_val >> CN93_VF_R_IN_CTL_RPVF_POS) &
CN93_VF_R_IN_CTL_RPVF_MASK;
conf->ring_cfg.active_io_rings = conf->ring_cfg.max_io_rings;

conf->iq.num_descs = OCTEP_VF_IQ_MAX_DESCRIPTORS;
conf->iq.instr_type = OCTEP_VF_64BYTE_INSTR;
conf->iq.db_min = OCTEP_VF_DB_MIN;
conf->iq.intr_threshold = OCTEP_VF_IQ_INTR_THRESHOLD;

conf->oq.num_descs = OCTEP_VF_OQ_MAX_DESCRIPTORS;
conf->oq.buf_size = OCTEP_VF_OQ_BUF_SIZE;
conf->oq.refill_threshold = OCTEP_VF_OQ_REFILL_THRESHOLD;
conf->oq.oq_intr_pkt = OCTEP_VF_OQ_INTR_PKT_THRESHOLD;
conf->oq.oq_intr_time = OCTEP_VF_OQ_INTR_TIME_THRESHOLD;

conf->msix_cfg.ioq_msix = conf->ring_cfg.active_io_rings;
}

/* Setup registers for a hardware Tx Queue */
static void octep_vf_setup_iq_regs_cn93(struct octep_vf_device *oct, int iq_no)
{
}

/* Setup registers for a hardware Rx Queue */
static void octep_vf_setup_oq_regs_cn93(struct octep_vf_device *oct, int oq_no)
{
}

/* Setup registers for a VF mailbox */
static void octep_vf_setup_mbox_regs_cn93(struct octep_vf_device *oct, int q_no)
{
}

/* Tx/Rx queue interrupt handler */
static irqreturn_t octep_vf_ioq_intr_handler_cn93(void *data)
{
return IRQ_HANDLED;
}

/* Re-initialize Octeon hardware registers */
static void octep_vf_reinit_regs_cn93(struct octep_vf_device *oct)
{
}

/* Enable all interrupts */
static void octep_vf_enable_interrupts_cn93(struct octep_vf_device *oct)
{
}

/* Disable all interrupts */
static void octep_vf_disable_interrupts_cn93(struct octep_vf_device *oct)
{
}

/* Get new Octeon Read Index: index of descriptor that Octeon reads next. */
static u32 octep_vf_update_iq_read_index_cn93(struct octep_vf_iq *iq)
{
return 0;
}

/* Enable a hardware Tx Queue */
static void octep_vf_enable_iq_cn93(struct octep_vf_device *oct, int iq_no)
{
}

/* Enable a hardware Rx Queue */
static void octep_vf_enable_oq_cn93(struct octep_vf_device *oct, int oq_no)
{
}

/* Enable all hardware Tx/Rx Queues assigned to VF */
static void octep_vf_enable_io_queues_cn93(struct octep_vf_device *oct)
{
}

/* Disable a hardware Tx Queue assigned to VF */
static void octep_vf_disable_iq_cn93(struct octep_vf_device *oct, int iq_no)
{
}

/* Disable a hardware Rx Queue assigned to VF */
static void octep_vf_disable_oq_cn93(struct octep_vf_device *oct, int oq_no)
{
}

/* Disable all hardware Tx/Rx Queues assigned to VF */
static void octep_vf_disable_io_queues_cn93(struct octep_vf_device *oct)
{
}

/* Dump hardware registers (including Tx/Rx queues) for debugging. */
static void octep_vf_dump_registers_cn93(struct octep_vf_device *oct)
{
}

/**
* octep_vf_device_setup_cn93() - Setup Octeon device.
*
* @oct: Octeon device private data structure.
*
* - initialize hardware operations.
* - get target side pcie port number for the device.
* - set initial configuration and max limits.
*/
void octep_vf_device_setup_cn93(struct octep_vf_device *oct)
{
oct->hw_ops.setup_iq_regs = octep_vf_setup_iq_regs_cn93;
oct->hw_ops.setup_oq_regs = octep_vf_setup_oq_regs_cn93;
oct->hw_ops.setup_mbox_regs = octep_vf_setup_mbox_regs_cn93;

oct->hw_ops.ioq_intr_handler = octep_vf_ioq_intr_handler_cn93;
oct->hw_ops.reinit_regs = octep_vf_reinit_regs_cn93;

oct->hw_ops.enable_interrupts = octep_vf_enable_interrupts_cn93;
oct->hw_ops.disable_interrupts = octep_vf_disable_interrupts_cn93;

oct->hw_ops.update_iq_read_idx = octep_vf_update_iq_read_index_cn93;

oct->hw_ops.enable_iq = octep_vf_enable_iq_cn93;
oct->hw_ops.enable_oq = octep_vf_enable_oq_cn93;
oct->hw_ops.enable_io_queues = octep_vf_enable_io_queues_cn93;

oct->hw_ops.disable_iq = octep_vf_disable_iq_cn93;
oct->hw_ops.disable_oq = octep_vf_disable_oq_cn93;
oct->hw_ops.disable_io_queues = octep_vf_disable_io_queues_cn93;
oct->hw_ops.reset_io_queues = octep_vf_reset_io_queues_cn93;

oct->hw_ops.dump_registers = octep_vf_dump_registers_cn93;
octep_vf_init_config_cn93_vf(oct);
}
158 changes: 158 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// 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/etherdevice.h>

#include "octep_vf_config.h"
#include "octep_vf_main.h"
#include "octep_vf_regs_cnxk.h"

/* Reset all hardware Tx/Rx queues */
static void octep_vf_reset_io_queues_cnxk(struct octep_vf_device *oct)
{
}

/* Initialize configuration limits and initial active config */
static void octep_vf_init_config_cnxk_vf(struct octep_vf_device *oct)
{
struct octep_vf_config *conf = oct->conf;
u64 reg_val;

reg_val = octep_vf_read_csr64(oct, CNXK_VF_SDP_R_IN_CONTROL(0));
conf->ring_cfg.max_io_rings = (reg_val >> CNXK_VF_R_IN_CTL_RPVF_POS) &
CNXK_VF_R_IN_CTL_RPVF_MASK;
conf->ring_cfg.active_io_rings = conf->ring_cfg.max_io_rings;

conf->iq.num_descs = OCTEP_VF_IQ_MAX_DESCRIPTORS;
conf->iq.instr_type = OCTEP_VF_64BYTE_INSTR;
conf->iq.db_min = OCTEP_VF_DB_MIN;
conf->iq.intr_threshold = OCTEP_VF_IQ_INTR_THRESHOLD;

conf->oq.num_descs = OCTEP_VF_OQ_MAX_DESCRIPTORS;
conf->oq.buf_size = OCTEP_VF_OQ_BUF_SIZE;
conf->oq.refill_threshold = OCTEP_VF_OQ_REFILL_THRESHOLD;
conf->oq.oq_intr_pkt = OCTEP_VF_OQ_INTR_PKT_THRESHOLD;
conf->oq.oq_intr_time = OCTEP_VF_OQ_INTR_TIME_THRESHOLD;
conf->oq.wmark = OCTEP_VF_OQ_WMARK_MIN;

conf->msix_cfg.ioq_msix = conf->ring_cfg.active_io_rings;
}

/* Setup registers for a hardware Tx Queue */
static void octep_vf_setup_iq_regs_cnxk(struct octep_vf_device *oct, int iq_no)
{
}

/* Setup registers for a hardware Rx Queue */
static void octep_vf_setup_oq_regs_cnxk(struct octep_vf_device *oct, int oq_no)
{
}

/* Setup registers for a VF mailbox */
static void octep_vf_setup_mbox_regs_cnxk(struct octep_vf_device *oct, int q_no)
{
}

/* Tx/Rx queue interrupt handler */
static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void *data)
{
return IRQ_HANDLED;
}

/* Re-initialize Octeon hardware registers */
static void octep_vf_reinit_regs_cnxk(struct octep_vf_device *oct)
{
}

/* Enable all interrupts */
static void octep_vf_enable_interrupts_cnxk(struct octep_vf_device *oct)
{
}

/* Disable all interrupts */
static void octep_vf_disable_interrupts_cnxk(struct octep_vf_device *oct)
{
}

/* Get new Octeon Read Index: index of descriptor that Octeon reads next. */
static u32 octep_vf_update_iq_read_index_cnxk(struct octep_vf_iq *iq)
{
return 0;
}

/* Enable a hardware Tx Queue */
static void octep_vf_enable_iq_cnxk(struct octep_vf_device *oct, int iq_no)
{
}

/* Enable a hardware Rx Queue */
static void octep_vf_enable_oq_cnxk(struct octep_vf_device *oct, int oq_no)
{
}

/* Enable all hardware Tx/Rx Queues assigned to VF */
static void octep_vf_enable_io_queues_cnxk(struct octep_vf_device *oct)
{
}

/* Disable a hardware Tx Queue assigned to VF */
static void octep_vf_disable_iq_cnxk(struct octep_vf_device *oct, int iq_no)
{
}

/* Disable a hardware Rx Queue assigned to VF */
static void octep_vf_disable_oq_cnxk(struct octep_vf_device *oct, int oq_no)
{
}

/* Disable all hardware Tx/Rx Queues assigned to VF */
static void octep_vf_disable_io_queues_cnxk(struct octep_vf_device *oct)
{
}

/* Dump hardware registers (including Tx/Rx queues) for debugging. */
static void octep_vf_dump_registers_cnxk(struct octep_vf_device *oct)
{
}

/**
* octep_vf_device_setup_cnxk() - Setup Octeon device.
*
* @oct: Octeon device private data structure.
*
* - initialize hardware operations.
* - get target side pcie port number for the device.
* - set initial configuration and max limits.
*/
void octep_vf_device_setup_cnxk(struct octep_vf_device *oct)
{
oct->hw_ops.setup_iq_regs = octep_vf_setup_iq_regs_cnxk;
oct->hw_ops.setup_oq_regs = octep_vf_setup_oq_regs_cnxk;
oct->hw_ops.setup_mbox_regs = octep_vf_setup_mbox_regs_cnxk;

oct->hw_ops.ioq_intr_handler = octep_vf_ioq_intr_handler_cnxk;
oct->hw_ops.reinit_regs = octep_vf_reinit_regs_cnxk;

oct->hw_ops.enable_interrupts = octep_vf_enable_interrupts_cnxk;
oct->hw_ops.disable_interrupts = octep_vf_disable_interrupts_cnxk;

oct->hw_ops.update_iq_read_idx = octep_vf_update_iq_read_index_cnxk;

oct->hw_ops.enable_iq = octep_vf_enable_iq_cnxk;
oct->hw_ops.enable_oq = octep_vf_enable_oq_cnxk;
oct->hw_ops.enable_io_queues = octep_vf_enable_io_queues_cnxk;

oct->hw_ops.disable_iq = octep_vf_disable_iq_cnxk;
oct->hw_ops.disable_oq = octep_vf_disable_oq_cnxk;
oct->hw_ops.disable_io_queues = octep_vf_disable_io_queues_cnxk;
oct->hw_ops.reset_io_queues = octep_vf_reset_io_queues_cnxk;

oct->hw_ops.dump_registers = octep_vf_dump_registers_cnxk;
octep_vf_init_config_cnxk_vf(oct);
}
Loading

0 comments on commit ebdc193

Please sign in to comment.