-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
octeon_ep_vf: Add driver framework and device initialization
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 <srasheed@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Shinas Rasheed
authored and
David S. Miller
committed
Feb 12, 2024
1 parent
970cb1c
commit cb7dd71
Showing
19 changed files
with
2,399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Documentation/networking/device_drivers/ethernet/marvell/octeon_ep_vf.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
157
drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
158
drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.