Skip to content

Commit 3d4864b

Browse files
committed
Merge branch 'octeontx2-pf-Add-network-driver-for-physical-function'
Sunil Goutham says: ==================== octeontx2-pf: Add network driver for physical function OcteonTX2 SOC's resource virtualization unit (RVU) supports multiple physical and virtual functions. Each of the PF's functionality is determined by what kind of resources are attached to it. If NPA and NIX blocks are attached to a PF it can function as a highly capable network device. This patch series add a network driver for the PF. Initial set of patches adds mailbox communication with admin function (RVU AF) and configuration of queues. Followed by Rx and tx pkts NAPI handler and then support for HW offloads like RSS, TSO, Rxhash etc. Ethtool support to extract stats, config RSS, queue sizes, queue count is also added. Added documentation to give a high level overview of HW and different drivers which will be upstreamed and how they interact. Changes from v5: * Fixed otx2_atomic64_add() non ARM64 fallback definition. - Suggested by David Miller Changes from v4: * Replaced pci_set_dma_mask and pci_set_consistent_dma_mask fn()s with dma_set_mask_and_coherent(). * Some additonal code cleanup. * Fixed receive buffer segmnetation logic in otx2_alloc_rbuf() * Removed all unused BIG_ENDIAN structure definitions. * Removed unnecessary memory barriers - Sugested by Jakub Kicinski * Fixed mailbox initalization failure handling * Removed unused function parameter in otx2_skb_add_frag() - Suggested by Maciej Fijalkowski Changes from v3: * Fixed receive side scaling reinitialization during interface DOWN and UP to retain user configured settings, if any. * Removed driver version from ethtool. * Fixed otx2_set_rss_hash_opts() to return error incase RSS is not enabled. - Sugested by Jakub Kicinski Changes from v2: * Removed frames, bytes, dropped packet stats from ethtool to avoid duplication of same stats in netlink and ethtool. - Sugested by Jakub Kicinski * Removed number of channels and ringparam upper bound checking in ethtool support. * Fixed RSS hash option setting to reject unsupported config. - Suggested by Michal Kubecek Changes from v1: * Made driver dependent on 64bit, to fix build errors related to non availability of writeq/readq APIs for 32bit platforms. - Reported by kbuild test robot ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9e0703a + 688b3e8 commit 3d4864b

File tree

17 files changed

+5690
-3
lines changed

17 files changed

+5690
-3
lines changed

Documentation/networking/device_drivers/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Contents:
2222
intel/iavf
2323
intel/ice
2424
google/gve
25+
marvell/octeontx2
2526
mellanox/mlx5
2627
netronome/nfp
2728
pensando/ionic
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
3+
====================================
4+
Marvell OcteonTx2 RVU Kernel Drivers
5+
====================================
6+
7+
Copyright (c) 2020 Marvell International Ltd.
8+
9+
Contents
10+
========
11+
12+
- `Overview`_
13+
- `Drivers`_
14+
- `Basic packet flow`_
15+
16+
Overview
17+
========
18+
19+
Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC maps HW
20+
resources from the network, crypto and other functional blocks into
21+
PCI-compatible physical and virtual functions. Each functional block
22+
again has multiple local functions (LFs) for provisioning to PCI devices.
23+
RVU supports multiple PCIe SRIOV physical functions (PFs) and virtual
24+
functions (VFs). PF0 is called the administrative / admin function (AF)
25+
and has privileges to provision RVU functional block's LFs to each of the
26+
PF/VF.
27+
28+
RVU managed networking functional blocks
29+
- Network pool or buffer allocator (NPA)
30+
- Network interface controller (NIX)
31+
- Network parser CAM (NPC)
32+
- Schedule/Synchronize/Order unit (SSO)
33+
- Loopback interface (LBK)
34+
35+
RVU managed non-networking functional blocks
36+
- Crypto accelerator (CPT)
37+
- Scheduled timers unit (TIM)
38+
- Schedule/Synchronize/Order unit (SSO)
39+
Used for both networking and non networking usecases
40+
41+
Resource provisioning examples
42+
- A PF/VF with NIX-LF & NPA-LF resources works as a pure network device
43+
- A PF/VF with CPT-LF resource works as a pure crypto offload device.
44+
45+
RVU functional blocks are highly configurable as per software requirements.
46+
47+
Firmware setups following stuff before kernel boots
48+
- Enables required number of RVU PFs based on number of physical links.
49+
- Number of VFs per PF are either static or configurable at compile time.
50+
Based on config, firmware assigns VFs to each of the PFs.
51+
- Also assigns MSIX vectors to each of PF and VFs.
52+
- These are not changed after kernel boot.
53+
54+
Drivers
55+
=======
56+
57+
Linux kernel will have multiple drivers registering to different PF and VFs
58+
of RVU. Wrt networking there will be 3 flavours of drivers.
59+
60+
Admin Function driver
61+
---------------------
62+
63+
As mentioned above RVU PF0 is called the admin function (AF), this driver
64+
supports resource provisioning and configuration of functional blocks.
65+
Doesn't handle any I/O. It sets up few basic stuff but most of the
66+
funcionality is achieved via configuration requests from PFs and VFs.
67+
68+
PF/VFs communicates with AF via a shared memory region (mailbox). Upon
69+
receiving requests AF does resource provisioning and other HW configuration.
70+
AF is always attached to host kernel, but PFs and their VFs may be used by host
71+
kernel itself, or attached to VMs or to userspace applications like
72+
DPDK etc. So AF has to handle provisioning/configuration requests sent
73+
by any device from any domain.
74+
75+
AF driver also interacts with underlying firmware to
76+
- Manage physical ethernet links ie CGX LMACs.
77+
- Retrieve information like speed, duplex, autoneg etc
78+
- Retrieve PHY EEPROM and stats.
79+
- Configure FEC, PAM modes
80+
- etc
81+
82+
From pure networking side AF driver supports following functionality.
83+
- Map a physical link to a RVU PF to which a netdev is registered.
84+
- Attach NIX and NPA block LFs to RVU PF/VF which provide buffer pools, RQs, SQs
85+
for regular networking functionality.
86+
- Flow control (pause frames) enable/disable/config.
87+
- HW PTP timestamping related config.
88+
- NPC parser profile config, basically how to parse pkt and what info to extract.
89+
- NPC extract profile config, what to extract from the pkt to match data in MCAM entries.
90+
- Manage NPC MCAM entries, upon request can frame and install requested packet forwarding rules.
91+
- Defines receive side scaling (RSS) algorithms.
92+
- Defines segmentation offload algorithms (eg TSO)
93+
- VLAN stripping, capture and insertion config.
94+
- SSO and TIM blocks config which provide packet scheduling support.
95+
- Debugfs support, to check current resource provising, current status of
96+
NPA pools, NIX RQ, SQ and CQs, various stats etc which helps in debugging issues.
97+
- And many more.
98+
99+
Physical Function driver
100+
------------------------
101+
102+
This RVU PF handles IO, is mapped to a physical ethernet link and this
103+
driver registers a netdev. This supports SR-IOV. As said above this driver
104+
communicates with AF with a mailbox. To retrieve information from physical
105+
links this driver talks to AF and AF gets that info from firmware and responds
106+
back ie cannot talk to firmware directly.
107+
108+
Supports ethtool for configuring links, RSS, queue count, queue size,
109+
flow control, ntuple filters, dump PHY EEPROM, config FEC etc.
110+
111+
Virtual Function driver
112+
-----------------------
113+
114+
There are two types VFs, VFs that share the physical link with their parent
115+
SR-IOV PF and the VFs which work in pairs using internal HW loopback channels (LBK).
116+
117+
Type1:
118+
- These VFs and their parent PF share a physical link and used for outside communication.
119+
- VFs cannot communicate with AF directly, they send mbox message to PF and PF
120+
forwards that to AF. AF after processing, responds back to PF and PF forwards
121+
the reply to VF.
122+
- From functionality point of view there is no difference between PF and VF as same type
123+
HW resources are attached to both. But user would be able to configure few stuff only
124+
from PF as PF is treated as owner/admin of the link.
125+
126+
Type2:
127+
- RVU PF0 ie admin function creates these VFs and maps them to loopback block's channels.
128+
- A set of two VFs (VF0 & VF1, VF2 & VF3 .. so on) works as a pair ie pkts sent out of
129+
VF0 will be received by VF1 and viceversa.
130+
- These VFs can be used by applications or virtual machines to communicate between them
131+
without sending traffic outside. There is no switch present in HW, hence the support
132+
for loopback VFs.
133+
- These communicate directly with AF (PF0) via mbox.
134+
135+
Except for the IO channels or links used for packet reception and transmission there is
136+
no other difference between these VF types. AF driver takes care of IO channel mapping,
137+
hence same VF driver works for both types of devices.
138+
139+
Basic packet flow
140+
=================
141+
142+
Ingress
143+
-------
144+
145+
1. CGX LMAC receives packet.
146+
2. Forwards the packet to the NIX block.
147+
3. Then submitted to NPC block for parsing and then MCAM lookup to get the destination RVU device.
148+
4. NIX LF attached to the destination RVU device allocates a buffer from RQ mapped buffer pool of NPA block LF.
149+
5. RQ may be selected by RSS or by configuring MCAM rule with a RQ number.
150+
6. Packet is DMA'ed and driver is notified.
151+
152+
Egress
153+
------
154+
155+
1. Driver prepares a send descriptor and submits to SQ for transmission.
156+
2. The SQ is already configured (by AF) to transmit on a specific link/channel.
157+
3. The SQ descriptor ring is maintained in buffers allocated from SQ mapped pool of NPA block LF.
158+
4. NIX block transmits the pkt on the designated channel.
159+
5. NPC MCAM entries can be installed to divert pkt onto a different channel.

MAINTAINERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10000,6 +10000,16 @@ M: Jerin Jacob <[email protected]>
1000010000
1000110001
S: Supported
1000210002
F: drivers/net/ethernet/marvell/octeontx2/af/
10003+
F: Documentation/networking/device_drivers/marvell/octeontx2.rst
10004+
10005+
MARVELL OCTEONTX2 PHYSICAL FUNCTION DRIVER
10006+
M: Sunil Goutham <[email protected]>
10007+
M: Geetha sowjanya <[email protected]>
10008+
M: Subbaraya Sundeep <[email protected]>
10009+
M: hariprasad <[email protected]>
10010+
10011+
S: Supported
10012+
F: drivers/net/ethernet/marvell/octeontx2/nic/
1000310013

1000410014
MATROX FRAMEBUFFER DRIVER
1000510015

drivers/net/ethernet/marvell/octeontx2/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ config NDC_DIS_DYNAMIC_CACHING
2525
This config option disables caching of dynamic entries such as NIX SQEs
2626
, NPA stack pages etc in NDC. Also locks down NIX SQ/CQ/RQ/RSS and
2727
NPA Aura/Pool contexts.
28+
29+
config OCTEONTX2_PF
30+
tristate "Marvell OcteonTX2 NIC Physical Function driver"
31+
select OCTEONTX2_MBOX
32+
depends on (64BIT && COMPILE_TEST) || ARM64
33+
depends on PCI
34+
help
35+
This driver supports Marvell's OcteonTX2 NIC physical function.

drivers/net/ethernet/marvell/octeontx2/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# Makefile for Marvell OcteonTX2 device drivers.
44
#
55

6+
obj-$(CONFIG_OCTEONTX2_MBOX) += af/
67
obj-$(CONFIG_OCTEONTX2_AF) += af/
8+
obj-$(CONFIG_OCTEONTX2_PF) += nic/

drivers/net/ethernet/marvell/octeontx2/af/common.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,13 @@ enum nix_scheduler {
143143
NIX_TXSCH_LVL_CNT = 0x5,
144144
};
145145

146-
#define TXSCH_TL1_DFLT_RR_QTM ((1 << 24) - 1)
147-
#define TXSCH_TL1_DFLT_RR_PRIO (0x1ull)
146+
#define TXSCH_RR_QTM_MAX ((1 << 24) - 1)
147+
#define TXSCH_TL1_DFLT_RR_QTM TXSCH_RR_QTM_MAX
148+
#define TXSCH_TL1_DFLT_RR_PRIO (0x1ull)
149+
#define MAX_SCHED_WEIGHT 0xFF
150+
#define DFLT_RR_WEIGHT 71
151+
#define DFLT_RR_QTM ((DFLT_RR_WEIGHT * TXSCH_RR_QTM_MAX) \
152+
/ MAX_SCHED_WEIGHT)
148153

149154
/* Min/Max packet sizes, excluding FCS */
150155
#define NIC_HW_MIN_FRS 40

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ M(NIX_SET_RX_CFG, 0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp) \
210210
M(NIX_LSO_FORMAT_CFG, 0x8011, nix_lso_format_cfg, \
211211
nix_lso_format_cfg, \
212212
nix_lso_format_cfg_rsp) \
213-
M(NIX_RXVLAN_ALLOC, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp)
213+
M(NIX_RXVLAN_ALLOC, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp) \
214+
M(NIX_GET_MAC_ADDR, 0x8018, nix_get_mac_addr, msg_req, nix_get_mac_addr_rsp) \
214215

215216
/* Messages initiated by AF (range 0xC00 - 0xDFF) */
216217
#define MBOX_UP_CGX_MESSAGES \
@@ -618,6 +619,11 @@ struct nix_set_mac_addr {
618619
u8 mac_addr[ETH_ALEN]; /* MAC address to be set for this pcifunc */
619620
};
620621

622+
struct nix_get_mac_addr_rsp {
623+
struct mbox_msghdr hdr;
624+
u8 mac_addr[ETH_ALEN];
625+
};
626+
621627
struct nix_mark_format_cfg {
622628
struct mbox_msghdr hdr;
623629
u8 offset;

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,23 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
25462546
return 0;
25472547
}
25482548

2549+
int rvu_mbox_handler_nix_get_mac_addr(struct rvu *rvu,
2550+
struct msg_req *req,
2551+
struct nix_get_mac_addr_rsp *rsp)
2552+
{
2553+
u16 pcifunc = req->hdr.pcifunc;
2554+
struct rvu_pfvf *pfvf;
2555+
2556+
if (!is_nixlf_attached(rvu, pcifunc))
2557+
return NIX_AF_ERR_AF_LF_INVALID;
2558+
2559+
pfvf = rvu_get_pfvf(rvu, pcifunc);
2560+
2561+
ether_addr_copy(rsp->mac_addr, pfvf->mac_addr);
2562+
2563+
return 0;
2564+
}
2565+
25492566
int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,
25502567
struct msg_rsp *rsp)
25512568
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Makefile for Marvell's OcteonTX2 ethernet device drivers
4+
#
5+
6+
obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o
7+
8+
octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o
9+
10+
ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af

0 commit comments

Comments
 (0)