Skip to content

Commit cb7dd71

Browse files
shinas-marvelldavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 970cb1c commit cb7dd71

File tree

19 files changed

+2399
-0
lines changed

19 files changed

+2399
-0
lines changed

Documentation/networking/device_drivers/ethernet/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Contents:
4242
intel/ice
4343
marvell/octeontx2
4444
marvell/octeon_ep
45+
marvell/octeon_ep_vf
4546
mellanox/mlx5/index
4647
microsoft/netvsc
4748
neterion/s2io
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. SPDX-License-Identifier: GPL-2.0+
2+
3+
=======================================================================
4+
Linux kernel networking driver for Marvell's Octeon PCI Endpoint NIC VF
5+
=======================================================================
6+
7+
Network driver for Marvell's Octeon PCI EndPoint NIC VF.
8+
Copyright (c) 2020 Marvell International Ltd.
9+
10+
Overview
11+
========
12+
This driver implements networking functionality of Marvell's Octeon PCI
13+
EndPoint NIC VF.
14+
15+
Supported Devices
16+
=================
17+
Currently, this driver support following devices:
18+
* Network controller: Cavium, Inc. Device b203
19+
* Network controller: Cavium, Inc. Device b403
20+
* Network controller: Cavium, Inc. Device b103
21+
* Network controller: Cavium, Inc. Device b903
22+
* Network controller: Cavium, Inc. Device ba03
23+
* Network controller: Cavium, Inc. Device bc03
24+
* Network controller: Cavium, Inc. Device bd03

drivers/net/ethernet/marvell/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ config SKY2_DEBUG
180180

181181
source "drivers/net/ethernet/marvell/octeontx2/Kconfig"
182182
source "drivers/net/ethernet/marvell/octeon_ep/Kconfig"
183+
source "drivers/net/ethernet/marvell/octeon_ep_vf/Kconfig"
183184
source "drivers/net/ethernet/marvell/prestera/Kconfig"
184185

185186
endif # NET_VENDOR_MARVELL

drivers/net/ethernet/marvell/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o
1212
obj-$(CONFIG_SKGE) += skge.o
1313
obj-$(CONFIG_SKY2) += sky2.o
1414
obj-y += octeon_ep/
15+
obj-y += octeon_ep_vf/
1516
obj-y += octeontx2/
1617
obj-y += prestera/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Marvell's Octeon PCI Endpoint NIC VF Driver Configuration
4+
#
5+
6+
config OCTEON_EP_VF
7+
tristate "Marvell Octeon PCI Endpoint NIC VF Driver"
8+
depends on 64BIT
9+
depends on PCI
10+
help
11+
This driver supports networking functionality of Marvell's
12+
Octeon PCI Endpoint NIC VF.
13+
14+
To know the list of devices supported by this driver, refer
15+
documentation in
16+
<file:Documentation/networking/device_drivers/ethernet/marvell/octeon_ep_vf.rst>.
17+
18+
To compile this drivers as a module, choose M here. Name of the
19+
module is octeon_ep_vf.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Network driver for Marvell's Octeon PCI Endpoint NIC VF
4+
#
5+
6+
obj-$(CONFIG_OCTEON_EP_VF) += octeon_ep_vf.o
7+
8+
octeon_ep_vf-y := octep_vf_main.o octep_vf_cn9k.o octep_vf_cnxk.o \
9+
octep_vf_tx.o octep_vf_rx.o octep_vf_mbox.o
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
3+
*
4+
* Copyright (C) 2020 Marvell.
5+
*
6+
*/
7+
8+
#include <linux/pci.h>
9+
#include <linux/netdevice.h>
10+
#include <linux/etherdevice.h>
11+
12+
#include "octep_vf_config.h"
13+
#include "octep_vf_main.h"
14+
#include "octep_vf_regs_cn9k.h"
15+
16+
/* Reset all hardware Tx/Rx queues */
17+
static void octep_vf_reset_io_queues_cn93(struct octep_vf_device *oct)
18+
{
19+
}
20+
21+
/* Initialize configuration limits and initial active config */
22+
static void octep_vf_init_config_cn93_vf(struct octep_vf_device *oct)
23+
{
24+
struct octep_vf_config *conf = oct->conf;
25+
u64 reg_val;
26+
27+
reg_val = octep_vf_read_csr64(oct, CN93_VF_SDP_R_IN_CONTROL(0));
28+
conf->ring_cfg.max_io_rings = (reg_val >> CN93_VF_R_IN_CTL_RPVF_POS) &
29+
CN93_VF_R_IN_CTL_RPVF_MASK;
30+
conf->ring_cfg.active_io_rings = conf->ring_cfg.max_io_rings;
31+
32+
conf->iq.num_descs = OCTEP_VF_IQ_MAX_DESCRIPTORS;
33+
conf->iq.instr_type = OCTEP_VF_64BYTE_INSTR;
34+
conf->iq.db_min = OCTEP_VF_DB_MIN;
35+
conf->iq.intr_threshold = OCTEP_VF_IQ_INTR_THRESHOLD;
36+
37+
conf->oq.num_descs = OCTEP_VF_OQ_MAX_DESCRIPTORS;
38+
conf->oq.buf_size = OCTEP_VF_OQ_BUF_SIZE;
39+
conf->oq.refill_threshold = OCTEP_VF_OQ_REFILL_THRESHOLD;
40+
conf->oq.oq_intr_pkt = OCTEP_VF_OQ_INTR_PKT_THRESHOLD;
41+
conf->oq.oq_intr_time = OCTEP_VF_OQ_INTR_TIME_THRESHOLD;
42+
43+
conf->msix_cfg.ioq_msix = conf->ring_cfg.active_io_rings;
44+
}
45+
46+
/* Setup registers for a hardware Tx Queue */
47+
static void octep_vf_setup_iq_regs_cn93(struct octep_vf_device *oct, int iq_no)
48+
{
49+
}
50+
51+
/* Setup registers for a hardware Rx Queue */
52+
static void octep_vf_setup_oq_regs_cn93(struct octep_vf_device *oct, int oq_no)
53+
{
54+
}
55+
56+
/* Setup registers for a VF mailbox */
57+
static void octep_vf_setup_mbox_regs_cn93(struct octep_vf_device *oct, int q_no)
58+
{
59+
}
60+
61+
/* Tx/Rx queue interrupt handler */
62+
static irqreturn_t octep_vf_ioq_intr_handler_cn93(void *data)
63+
{
64+
return IRQ_HANDLED;
65+
}
66+
67+
/* Re-initialize Octeon hardware registers */
68+
static void octep_vf_reinit_regs_cn93(struct octep_vf_device *oct)
69+
{
70+
}
71+
72+
/* Enable all interrupts */
73+
static void octep_vf_enable_interrupts_cn93(struct octep_vf_device *oct)
74+
{
75+
}
76+
77+
/* Disable all interrupts */
78+
static void octep_vf_disable_interrupts_cn93(struct octep_vf_device *oct)
79+
{
80+
}
81+
82+
/* Get new Octeon Read Index: index of descriptor that Octeon reads next. */
83+
static u32 octep_vf_update_iq_read_index_cn93(struct octep_vf_iq *iq)
84+
{
85+
return 0;
86+
}
87+
88+
/* Enable a hardware Tx Queue */
89+
static void octep_vf_enable_iq_cn93(struct octep_vf_device *oct, int iq_no)
90+
{
91+
}
92+
93+
/* Enable a hardware Rx Queue */
94+
static void octep_vf_enable_oq_cn93(struct octep_vf_device *oct, int oq_no)
95+
{
96+
}
97+
98+
/* Enable all hardware Tx/Rx Queues assigned to VF */
99+
static void octep_vf_enable_io_queues_cn93(struct octep_vf_device *oct)
100+
{
101+
}
102+
103+
/* Disable a hardware Tx Queue assigned to VF */
104+
static void octep_vf_disable_iq_cn93(struct octep_vf_device *oct, int iq_no)
105+
{
106+
}
107+
108+
/* Disable a hardware Rx Queue assigned to VF */
109+
static void octep_vf_disable_oq_cn93(struct octep_vf_device *oct, int oq_no)
110+
{
111+
}
112+
113+
/* Disable all hardware Tx/Rx Queues assigned to VF */
114+
static void octep_vf_disable_io_queues_cn93(struct octep_vf_device *oct)
115+
{
116+
}
117+
118+
/* Dump hardware registers (including Tx/Rx queues) for debugging. */
119+
static void octep_vf_dump_registers_cn93(struct octep_vf_device *oct)
120+
{
121+
}
122+
123+
/**
124+
* octep_vf_device_setup_cn93() - Setup Octeon device.
125+
*
126+
* @oct: Octeon device private data structure.
127+
*
128+
* - initialize hardware operations.
129+
* - get target side pcie port number for the device.
130+
* - set initial configuration and max limits.
131+
*/
132+
void octep_vf_device_setup_cn93(struct octep_vf_device *oct)
133+
{
134+
oct->hw_ops.setup_iq_regs = octep_vf_setup_iq_regs_cn93;
135+
oct->hw_ops.setup_oq_regs = octep_vf_setup_oq_regs_cn93;
136+
oct->hw_ops.setup_mbox_regs = octep_vf_setup_mbox_regs_cn93;
137+
138+
oct->hw_ops.ioq_intr_handler = octep_vf_ioq_intr_handler_cn93;
139+
oct->hw_ops.reinit_regs = octep_vf_reinit_regs_cn93;
140+
141+
oct->hw_ops.enable_interrupts = octep_vf_enable_interrupts_cn93;
142+
oct->hw_ops.disable_interrupts = octep_vf_disable_interrupts_cn93;
143+
144+
oct->hw_ops.update_iq_read_idx = octep_vf_update_iq_read_index_cn93;
145+
146+
oct->hw_ops.enable_iq = octep_vf_enable_iq_cn93;
147+
oct->hw_ops.enable_oq = octep_vf_enable_oq_cn93;
148+
oct->hw_ops.enable_io_queues = octep_vf_enable_io_queues_cn93;
149+
150+
oct->hw_ops.disable_iq = octep_vf_disable_iq_cn93;
151+
oct->hw_ops.disable_oq = octep_vf_disable_oq_cn93;
152+
oct->hw_ops.disable_io_queues = octep_vf_disable_io_queues_cn93;
153+
oct->hw_ops.reset_io_queues = octep_vf_reset_io_queues_cn93;
154+
155+
oct->hw_ops.dump_registers = octep_vf_dump_registers_cn93;
156+
octep_vf_init_config_cn93_vf(oct);
157+
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Marvell Octeon EP (EndPoint) VF Ethernet Driver
3+
*
4+
* Copyright (C) 2020 Marvell.
5+
*
6+
*/
7+
8+
#include <linux/pci.h>
9+
#include <linux/netdevice.h>
10+
#include <linux/etherdevice.h>
11+
12+
#include "octep_vf_config.h"
13+
#include "octep_vf_main.h"
14+
#include "octep_vf_regs_cnxk.h"
15+
16+
/* Reset all hardware Tx/Rx queues */
17+
static void octep_vf_reset_io_queues_cnxk(struct octep_vf_device *oct)
18+
{
19+
}
20+
21+
/* Initialize configuration limits and initial active config */
22+
static void octep_vf_init_config_cnxk_vf(struct octep_vf_device *oct)
23+
{
24+
struct octep_vf_config *conf = oct->conf;
25+
u64 reg_val;
26+
27+
reg_val = octep_vf_read_csr64(oct, CNXK_VF_SDP_R_IN_CONTROL(0));
28+
conf->ring_cfg.max_io_rings = (reg_val >> CNXK_VF_R_IN_CTL_RPVF_POS) &
29+
CNXK_VF_R_IN_CTL_RPVF_MASK;
30+
conf->ring_cfg.active_io_rings = conf->ring_cfg.max_io_rings;
31+
32+
conf->iq.num_descs = OCTEP_VF_IQ_MAX_DESCRIPTORS;
33+
conf->iq.instr_type = OCTEP_VF_64BYTE_INSTR;
34+
conf->iq.db_min = OCTEP_VF_DB_MIN;
35+
conf->iq.intr_threshold = OCTEP_VF_IQ_INTR_THRESHOLD;
36+
37+
conf->oq.num_descs = OCTEP_VF_OQ_MAX_DESCRIPTORS;
38+
conf->oq.buf_size = OCTEP_VF_OQ_BUF_SIZE;
39+
conf->oq.refill_threshold = OCTEP_VF_OQ_REFILL_THRESHOLD;
40+
conf->oq.oq_intr_pkt = OCTEP_VF_OQ_INTR_PKT_THRESHOLD;
41+
conf->oq.oq_intr_time = OCTEP_VF_OQ_INTR_TIME_THRESHOLD;
42+
conf->oq.wmark = OCTEP_VF_OQ_WMARK_MIN;
43+
44+
conf->msix_cfg.ioq_msix = conf->ring_cfg.active_io_rings;
45+
}
46+
47+
/* Setup registers for a hardware Tx Queue */
48+
static void octep_vf_setup_iq_regs_cnxk(struct octep_vf_device *oct, int iq_no)
49+
{
50+
}
51+
52+
/* Setup registers for a hardware Rx Queue */
53+
static void octep_vf_setup_oq_regs_cnxk(struct octep_vf_device *oct, int oq_no)
54+
{
55+
}
56+
57+
/* Setup registers for a VF mailbox */
58+
static void octep_vf_setup_mbox_regs_cnxk(struct octep_vf_device *oct, int q_no)
59+
{
60+
}
61+
62+
/* Tx/Rx queue interrupt handler */
63+
static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void *data)
64+
{
65+
return IRQ_HANDLED;
66+
}
67+
68+
/* Re-initialize Octeon hardware registers */
69+
static void octep_vf_reinit_regs_cnxk(struct octep_vf_device *oct)
70+
{
71+
}
72+
73+
/* Enable all interrupts */
74+
static void octep_vf_enable_interrupts_cnxk(struct octep_vf_device *oct)
75+
{
76+
}
77+
78+
/* Disable all interrupts */
79+
static void octep_vf_disable_interrupts_cnxk(struct octep_vf_device *oct)
80+
{
81+
}
82+
83+
/* Get new Octeon Read Index: index of descriptor that Octeon reads next. */
84+
static u32 octep_vf_update_iq_read_index_cnxk(struct octep_vf_iq *iq)
85+
{
86+
return 0;
87+
}
88+
89+
/* Enable a hardware Tx Queue */
90+
static void octep_vf_enable_iq_cnxk(struct octep_vf_device *oct, int iq_no)
91+
{
92+
}
93+
94+
/* Enable a hardware Rx Queue */
95+
static void octep_vf_enable_oq_cnxk(struct octep_vf_device *oct, int oq_no)
96+
{
97+
}
98+
99+
/* Enable all hardware Tx/Rx Queues assigned to VF */
100+
static void octep_vf_enable_io_queues_cnxk(struct octep_vf_device *oct)
101+
{
102+
}
103+
104+
/* Disable a hardware Tx Queue assigned to VF */
105+
static void octep_vf_disable_iq_cnxk(struct octep_vf_device *oct, int iq_no)
106+
{
107+
}
108+
109+
/* Disable a hardware Rx Queue assigned to VF */
110+
static void octep_vf_disable_oq_cnxk(struct octep_vf_device *oct, int oq_no)
111+
{
112+
}
113+
114+
/* Disable all hardware Tx/Rx Queues assigned to VF */
115+
static void octep_vf_disable_io_queues_cnxk(struct octep_vf_device *oct)
116+
{
117+
}
118+
119+
/* Dump hardware registers (including Tx/Rx queues) for debugging. */
120+
static void octep_vf_dump_registers_cnxk(struct octep_vf_device *oct)
121+
{
122+
}
123+
124+
/**
125+
* octep_vf_device_setup_cnxk() - Setup Octeon device.
126+
*
127+
* @oct: Octeon device private data structure.
128+
*
129+
* - initialize hardware operations.
130+
* - get target side pcie port number for the device.
131+
* - set initial configuration and max limits.
132+
*/
133+
void octep_vf_device_setup_cnxk(struct octep_vf_device *oct)
134+
{
135+
oct->hw_ops.setup_iq_regs = octep_vf_setup_iq_regs_cnxk;
136+
oct->hw_ops.setup_oq_regs = octep_vf_setup_oq_regs_cnxk;
137+
oct->hw_ops.setup_mbox_regs = octep_vf_setup_mbox_regs_cnxk;
138+
139+
oct->hw_ops.ioq_intr_handler = octep_vf_ioq_intr_handler_cnxk;
140+
oct->hw_ops.reinit_regs = octep_vf_reinit_regs_cnxk;
141+
142+
oct->hw_ops.enable_interrupts = octep_vf_enable_interrupts_cnxk;
143+
oct->hw_ops.disable_interrupts = octep_vf_disable_interrupts_cnxk;
144+
145+
oct->hw_ops.update_iq_read_idx = octep_vf_update_iq_read_index_cnxk;
146+
147+
oct->hw_ops.enable_iq = octep_vf_enable_iq_cnxk;
148+
oct->hw_ops.enable_oq = octep_vf_enable_oq_cnxk;
149+
oct->hw_ops.enable_io_queues = octep_vf_enable_io_queues_cnxk;
150+
151+
oct->hw_ops.disable_iq = octep_vf_disable_iq_cnxk;
152+
oct->hw_ops.disable_oq = octep_vf_disable_oq_cnxk;
153+
oct->hw_ops.disable_io_queues = octep_vf_disable_io_queues_cnxk;
154+
oct->hw_ops.reset_io_queues = octep_vf_reset_io_queues_cnxk;
155+
156+
oct->hw_ops.dump_registers = octep_vf_dump_registers_cnxk;
157+
octep_vf_init_config_cnxk_vf(oct);
158+
}

0 commit comments

Comments
 (0)