Skip to content

Commit

Permalink
octeon: native driver for Marvell Octeon SoC
Browse files Browse the repository at this point in the history
Type: feature
Change-Id: I6898625c4e8854f777407dac3159e4c639a54860
Signed-off-by: Monendra Singh Kushwaha <kmonendra@marvell.com>
Signed-off-by: Damjan Marion <damarion@cisco.com>
  • Loading branch information
dmarion committed Jan 17, 2024
1 parent dc26d50 commit 01fe7ab
Show file tree
Hide file tree
Showing 21 changed files with 2,659 additions and 18 deletions.
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ I: ena
M: Damjan Marion <damarion@cisco.com>
F: src/plugins/dev_ena/

Plugin - Marvell Octeon device driver
I: octeon
M: Monendra Singh Kushwaha <kmonendra@marvell.com>
M: Damjan Marion <damarion@cisco.com>
F: src/plugins/dev_octeon/

Plugin - Dispatch Trace PCAP
I: dispatch-trace
M: Dave Barach <vpp@barachs.net>
Expand Down
3 changes: 3 additions & 0 deletions build-data/packages/vpp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ vpp_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(vpp_cmake_prefix_path)"
ifeq ("$(V)","1")
vpp_cmake_args += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
endif
ifneq ($(VPP_PLATFORM),)
vpp_cmake_args += -DVPP_PLATFORM="$(VPP_PLATFORM)"
endif
ifneq ($(VPP_EXCLUDED_PLUGINS),)
vpp_cmake_args += -DVPP_EXCLUDED_PLUGINS="$(VPP_EXCLUDED_PLUGINS)"
endif
Expand Down
4 changes: 3 additions & 1 deletion build/external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ CMAKE?=cmake
endif

ARCH_X86_64=$(filter x86_64,$(shell uname -m))
AARCH64=$(filter aarch64,$(shell uname -m))

include packages.mk
include packages/ipsec-mb.mk
include packages/quicly.mk
include packages/rdma-core.mk
include packages/dpdk.mk
include packages/xdp-tools.mk
include packages/octeon-roc.mk

.PHONY: clean
clean:
@rm -rf $(B) $(I)

.PHONY: install
install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install
install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install $(if $(AARCH64), octeon-roc-install)

.PHONY: config
config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
Expand Down
26 changes: 26 additions & 0 deletions build/external/packages/octeon-roc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2023 Marvell.
# SPDX-License-Identifier: Apache-2.0
# https://spdx.org/licenses/Apache-2.0.html

octeon-roc_version := 0.2
octeon-roc_tarball := octeon-roc-v$(octeon-roc_version).tar.gz
octeon-roc_tarball_md5sum := a72bb3b27fd3bbaf58aadd99514620e1

octeon-roc_tarball_strip_dirs := 1
octeon-roc_url := https://github.com/MarvellEmbeddedProcessors/marvell-vpp/archive/refs/tags/$(octeon-roc_tarball)

define octeon-roc_config_cmds
@true
endef

define octeon-roc_build_cmds
@cd ${octeon-roc_src_dir} && rm -f $(octeon-roc_build_log) && $(CMAKE) ${octeon-roc_src_dir} -DCMAKE_INSTALL_PREFIX='$(octeon-roc_install_dir)' >> $(octeon-roc_build_log)
@$(MAKE) -C ${octeon-roc_src_dir} >> $(octeon-roc_build_log)
endef

define octeon-roc_install_cmds
@$(MAKE) -C ${octeon-roc_src_dir} install >> $(octeon-roc_install_log)
endef

$(eval $(call package,octeon-roc))

12 changes: 12 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -o pipefail -o errtrace -o nounset -o errexit
# submitting any changes

# defaults
platform=default
build_dir=.
install_dir=/usr/local
build_type=release
Expand All @@ -31,6 +32,7 @@ OPTIONS:
--native-only, -n Only compile for Native CPU (no multiarch)
--wipe, -w Wipe whole repo (except startup.* files)
--sanitize, -s Enable sanitizer (mem)
--platform, -p Specify target platform
__EOF__
}

Expand Down Expand Up @@ -76,6 +78,15 @@ while (( "$#" )); do
exit 1
fi
;;
-p|--platform)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
platform=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-n|--native-only)
native_only=yes
shift 1
Expand Down Expand Up @@ -121,6 +132,7 @@ args+=("-DCMAKE_PREFIX_PATH=/opt/vpp/external/${arch}")
args+=("-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON")
args+=("-DCMAKE_INSTALL_PREFIX=${install_dir}")
args+=("-DCMAKE_BUILD_TYPE:STRING=${build_type}")
args+=("-DVPP_PLATFORM=${platform}")
[ "${native_only}" == "yes" ] && args+=("-DVPP_BUILD_NATIVE_ONLY:BOOL=ON")

[ "${wipe}" == "yes" ] && git clean -fdx --exclude=startup.\*
Expand Down
2 changes: 2 additions & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ det
dev
devbind
dev_iavf
dev_octeon
df
dhcp
dhcp
Expand Down Expand Up @@ -786,6 +787,7 @@ O'Driscoll
oacl
oam
OAM
octeon
oddbuf
Oddbuf
offline
Expand Down
46 changes: 46 additions & 0 deletions extras/deb/mkdeb-octeon-roc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

PKG=vpp-dep-octeon-roc
URL=https://github.com/MarvellEmbeddedProcessors/marvell-vpp.git
ARCH=$(dpkg --print-architecture)
TMP_DIR=$(mktemp -d -p $PWD)

set -eEuo pipefail

err_handler()
{
trap '' INT TERM EXIT ERR
echo "Cleaning up ${TMP_DIR}"
rm -rf ${TMP_DIR}
exit
}
trap "err_handler" INT TERM EXIT ERR

SRC=${TMP_DIR}/src
BUILD=${TMP_DIR}/build
STAGE=${TMP_DIR}/pkg
INSTALL_PREFIX=/opt/vpp/external/$(uname -m)

git clone ${URL} ${SRC}
VER=0.0.$(git -C ${SRC} rev-list --count HEAD)

cmake -S ${SRC} -B ${BUILD}
cmake --build ${BUILD} --parallel
cmake --install ${BUILD} --prefix ${STAGE}${INSTALL_PREFIX}

mkdir -p ${STAGE}/DEBIAN

cat > ${STAGE}/DEBIAN/control << __EOF__
Package: ${PKG}
Version: ${VER}
Architecture: ${ARCH}
Maintainer: vpp-dev <vpp-dev@fd.io>
Installed-Size: $(du -ks ${STAGE}|cut -f 1)
Section: system
Priority: extra
Description: Marvell Octeon ROC library for VPP
See https://github.com/MarvellEmbeddedProcessors/marvell-vpp
__EOF__

DEB=${PKG}_${VER}_${ARCH}.deb
dpkg-deb -b ${STAGE} ${DEB}
28 changes: 26 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_COMPILER_NAMES clang gcc cc)
if(DEFINED VPP_PLATFORM AND VPP_PLATFORM STREQUAL "default")
unset(VPP_PLATFORM)
set(VPP_PLATFORM_NAME "default")
elseif(DEFINED VPP_PLATFORM)
set(platform_file ${CMAKE_SOURCE_DIR}/cmake/platform/${VPP_PLATFORM}.cmake)
if(NOT EXISTS ${platform_file})
message(FATAL_ERROR "unknown platform ${VPP_PLATFORM}")
endif()
include(${platform_file})
set(VPP_PLATFORM_NAME ${VPP_PLATFORM})
else()
set(VPP_PLATFORM_NAME "default")
endif()

if (DEFINED VPP_PLATFORM_C_COMPILER_NAMES)
set(CMAKE_C_COMPILER_NAMES ${VPP_PLATFORM_C_COMPILER_NAME})
else()
set(CMAKE_C_COMPILER_NAMES clang gcc cc)
endif()

project(vpp C)

Expand All @@ -37,6 +55,11 @@ execute_process(
OUTPUT_VARIABLE VPP_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (VPP_PLATFORM)
set(VPP_VERSION ${VPP_VERSION}-${VPP_PLATFORM_NAME})
endif()

string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)

Expand Down Expand Up @@ -183,7 +206,7 @@ if(VPP_ENABLE_TRAJECTORY_TRACE)
endif()

##############################################################################
# unittest with clang ode coverage
# unittest with clang code coverage
##############################################################################

if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
Expand Down Expand Up @@ -307,6 +330,7 @@ mark_as_advanced(CLEAR
# print configuration
##############################################################################
message(STATUS "Configuration:")
pr("VPP platform" ${VPP_PLATFORM_NAME})
pr("VPP version" ${VPP_VERSION})
pr("VPP library version" ${VPP_LIB_VERSION})
pr("GIT toplevel dir" ${VPP_GIT_TOPLEVEL_DIR})
Expand Down
46 changes: 31 additions & 15 deletions src/cmake/cpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ endmacro()
##############################################################################
# Cache line size
##############################################################################
if(DEFINED VPP_CACHE_LINE_SIZE)
# Cache line size assigned via cmake args
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set(VPP_CACHE_LINE_SIZE 128)

if(DEFINED VPP_PLATFORM_CACHE_LINE_SIZE)
set(VPP_CACHE_LINE_SIZE ${VPP_PLATFORM_CACHE_LINE_SIZE})
else()
set(VPP_CACHE_LINE_SIZE 64)
endif()
if(DEFINED VPP_CACHE_LINE_SIZE)
# Cache line size assigned via cmake args
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set(VPP_CACHE_LINE_SIZE 128)
else()
set(VPP_CACHE_LINE_SIZE 64)
endif()

set(VPP_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE}
CACHE STRING "Target CPU cache line size")
set(VPP_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE}
CACHE STRING "Target CPU cache line size")
endif()

set_log2_cacheline_size(VPP_LOG2_CACHE_LINE_SIZE ${VPP_CACHE_LINE_SIZE})

Expand All @@ -57,7 +62,9 @@ endif()
# CPU optimizations and multiarch support
##############################################################################

option(VPP_BUILD_NATIVE_ONLY "Build only for native CPU." OFF)
if(NOT DEFINED VPP_PLATFORM)
option(VPP_BUILD_NATIVE_ONLY "Build only for native CPU." OFF)
endif()

macro(add_vpp_march_variant v)
cmake_parse_arguments(ARG
Expand Down Expand Up @@ -104,14 +111,23 @@ macro(add_vpp_march_variant v)
endif()
endmacro()

if(VPP_BUILD_NATIVE_ONLY)
if(DEFINED VPP_PLATFORM)
if(DEFINED VPP_PLATFORM_MARCH_FLAGS)
set(VPP_DEFAULT_MARCH_FLAGS ${VPP_PLATFORM_MARCH_FLAGS})
check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march)
if(NOT compiler_flag_march)
message(FATAL_ERROR "platform build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler")
endif()
else()
set(VPP_DEFAULT_MARCH_FLAGS "")
endif()
set(MARCH_VARIANTS_NAMES "platform-only")
elseif(VPP_BUILD_NATIVE_ONLY)
set(VPP_BUILD_NATIVE_ARCH "native" CACHE STRING "native CPU -march= value.")
set(VPP_DEFAULT_MARCH_FLAGS -march=${VPP_BUILD_NATIVE_ARCH})
if(VPP_BUILD_NATIVE_ONLY)
check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march)
if(NOT compiler_flag_march)
message(FATAL_ERROR "Native-only build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler")
endif()
check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march)
if(NOT compiler_flag_march)
message(FATAL_ERROR "Native-only build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler")
endif()
set(MARCH_VARIANTS_NAMES "native-only")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
Expand Down
3 changes: 3 additions & 0 deletions src/cmake/platform/octeon10.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(VPP_PLATFORM_CACHE_LINE_SIZE 64)
set(VPP_PLATFORM_MARCH_FLAGS -march=armv8.3-a+crypto+sve2-bitperm)
41 changes: 41 additions & 0 deletions src/plugins/dev_octeon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright(c) 2022 Cisco Systems, Inc.

if (NOT VPP_PLATFORM_NAME STREQUAL "octeon10")
return()
endif()

# Find OCTEON roc files
vpp_find_path(OCTEON_ROC_DIR PATH_SUFFIXES octeon-roc NAMES platform.h)
vpp_plugin_find_library(dev-octeon OCTEON_ROC_LIB "libocteon-roc.a")

if (NOT OCTEON_ROC_DIR)
message("OCTEON ROC files not found - Marvell OCTEON device plugin disabled")
return()
endif()

if (NOT OCTEON_ROC_LIB)
message("OCTEON ROC library (libocteon-roc.a) not found - Marvell OCTEON device plugin disabled")
return ()
endif()

include_directories (${OCTEON_ROC_DIR}/)

add_vpp_plugin(dev_octeon
SOURCES
init.c
format.c
port.c
queue.c
roc_helper.c
rx_node.c
tx_node.c

MULTIARCH_SOURCES
rx_node.c
tx_node.c

LINK_LIBRARIES
${OCTEON_ROC_LIB}
)

29 changes: 29 additions & 0 deletions src/plugins/dev_octeon/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright (c) 2023 Cisco Systems, Inc.
*/

#ifndef _OCT_COMMON_H_
#define _OCT_COMMON_H_

#include <vppinfra/clib.h>
#include <vppinfra/format.h>
#include <vnet/vnet.h>
#include <vnet/dev/dev.h>
#include <base/roc_api.h>

static_always_inline u32
oct_aura_free_all_buffers (vlib_main_t *vm, u64 aura_handle, u16 hdr_off)
{
u32 n = 0;
u64 iova;

while ((iova = roc_npa_aura_op_alloc (aura_handle, 0)))
{
vlib_buffer_t *b = (void *) iova + hdr_off;
vlib_buffer_free_one (vm, vlib_get_buffer_index (vm, b));
n++;
}
return n;
}

#endif /* _OCT_COMMON_H_ */
Loading

0 comments on commit 01fe7ab

Please sign in to comment.