Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions files/build_templates/per_namespace/syncd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ After=opennsl-modules.service
{% elif sonic_asic_platform == 'nephos' %}
Requires=nps-modules.service
After=nps-modules.service
{% elif sonic_asic_platform == 'clounix' %}
Requires=clx-modules.service
After=clx-modules.service
{% endif %}
Requires=config-setup.service
After=config-setup.service
Expand Down
11 changes: 11 additions & 0 deletions platform/clounix/clounix-modules.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

SPATH := $($(CLOUNIX_MODULE)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/clounix/clounix-modules.mk platform/clounix/clounix-modules.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files))

$(CLOUNIX_MODULE)_CACHE_MODE := GIT_CONTENT_SHA
$(CLOUNIX_MODULE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(CLOUNIX_MODULE)_DEP_FILES := $(DEP_FILES)
$(CLOUNIX_MODULE)_SMDEP_FILES := $(SMDEP_FILES)
$(CLOUNIX_MODULE)_SMDEP_PATHS := $(SPATH)
8 changes: 8 additions & 0 deletions platform/clounix/clounix-modules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Clounix Platform modules

VERSION = 1.0.1

CLOUNIX_MODULE = clounix-modules_$(VERSION)_amd64.deb
$(CLOUNIX_MODULE)_SRC_PATH = $(PLATFORM_PATH)/clounix-modules
$(CLOUNIX_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(CLOUNIX_SAI)
SONIC_DPKG_DEBS += $(CLOUNIX_MODULE)
2 changes: 2 additions & 0 deletions platform/clounix/clounix-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Clounix-modules
Device drivers for support of Clounix platform for the SONiC project
11 changes: 11 additions & 0 deletions platform/clounix/clounix-modules/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
clounix-modules (1.0.1) unstable; urgency=low

* Upgrade ko version to 3.0.0

-- Support <[email protected]> Tue, 17 Mar 2020 15:54:00 +0800

clounix-modules (1.0.0) unstable; urgency=low

* Initial release

-- Support <[email protected]> Fri, 15 Mar 2019 15:54:00 +0800
1 change: 1 addition & 0 deletions platform/clounix/clounix-modules/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
12 changes: 12 additions & 0 deletions platform/clounix/clounix-modules/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: clounix-modules
Section: main
Priority: extra
Maintainer: support <[email protected]>
Build-Depends: debhelper (>= 8.0.0), bzip2
Standards-Version: 3.9.3

Package: clounix-modules
Architecture: amd64
Depends: linux-image-4.19.0-12-2-amd64-unsigned
Description: kernel modules for clounix asic

34 changes: 34 additions & 0 deletions platform/clounix/clounix-modules/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/make -f
export INSTALL_MOD_DIR:=extra

PACKAGE_NAME := clounix-modules
KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
SERVICE_DIR := service
INITD_DIR := init.d
MODULE_SRC := $(shell pwd)/modules
CURRENT_DIR := $(cd "$(dirname "$0")"; pwd)

%:
dh $@

override_dh_auto_build:
ls
make -C $(MODULE_SRC)

override_dh_auto_install:
dh_installdirs -p$(PACKAGE_NAME) /lib/systemd/system
cp $(MODULE_SRC)/service/*.service debian/$(PACKAGE_NAME)/lib/systemd/system/
dh_installdirs -p$(PACKAGE_NAME) /etc/init.d
cp $(MODULE_SRC)/init.d/* debian/$(PACKAGE_NAME)/etc/init.d/
dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/extra/
cp $(MODULE_SRC)/build/module/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR);

override_dh_usrlocal:

override_dh_pysupport:

override_dh_clean:
dh_clean
test -d $(MODULE_SRC)/build || rm -rf $(MODULE_SRC)/build

94 changes: 94 additions & 0 deletions platform/clounix/clounix-modules/modules/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
################################################################################
# Copyright (C) 2021 Clounix, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# version 2 along with this program.
################################################################################
################################################################################
KERNEL_MODULE := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

################################################################################
MAKE := $(shell which make)
RM := rm -rf
MKDIR := mkdir -p
CP := cp
MV := mv
TEST_PATH := test -d

#KVERSION ?= $(shell uname -r)
KVERSION ?= 4.19.0-12-2-amd64
OS_PATH := /lib/modules/$(KVERSION)/build
SRC_PATH := $(KERNEL_MODULE)/src
INC_PATH := $(SRC_PATH)/inc
BUILD_OUTPUT_DIR := $(KERNEL_MODULE)/build
MODULE_OUTPUT_DIR := $(BUILD_OUTPUT_DIR)/module

all: compile install
################################################################################
EXTRA_CFLAGS += -I$(INC_PATH)
EXTRA_CFLAGS += -I$(SRC_PATH)/clx_netif/inc/
EXTRA_CFLAGS += -DCLX_EN_NETIF
EXTRA_CFLAGS += -DCLX_EN_DAWN
EXTRA_CFLAGS += -DCLX_EN_LIGHTNING
EXTRA_CFLAGS += -DCLX_EN_DEBUG
EXTRA_CFLAGS += -DCLX_LINUX_USER_MODE
EXTRA_CFLAGS += -DCLX_EN_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCLX_EN_COMPILER_SUPPORT_FUNCTION
EXTRA_CFLAGS += -DCLX_EN_COMPILER_SUPPORT_LONG_LONG

ifeq ($(shell uname -m),x86_64)
EXTRA_CFLAGS += -DCLX_EN_HOST_64_BIT_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCLX_EN_64BIT_ADDR
else
EXTRA_CFLAGS += -DCLX_EN_HOST_32_BIT_LITTLE_ENDIAN
endif

################################################################################
DEV_MODULE_NAME := clx_dev
NETIF_MODULE_NAME := clx_netif

################################################################################
DEV_OBJS_TOTAL := ./src/clx_dev/osal_mdc.o
DEV_OBJS_TOTAL += ./src/clx_dev/osal_isymbol.o

NETIF_OBJS_TOTAL := ./src/clx_netif/netif_knl.o
NETIF_OBJS_TOTAL += ./src/clx_netif/netif_osal.o
NETIF_OBJS_TOTAL += ./src/clx_netif/netif_perf.o
NETIF_OBJS_TOTAL += ./src/clx_netif/netif_nl.o
NETIF_OBJS_TOTAL += ./src/clx_netif/hal_dawn_pkt_knl.o
NETIF_OBJS_TOTAL += ./src/clx_netif/hal_lightning_pkt_knl.o

obj-m := $(DEV_MODULE_NAME).o $(NETIF_MODULE_NAME).o
$(DEV_MODULE_NAME)-objs := $(DEV_OBJS_TOTAL)
$(NETIF_MODULE_NAME)-objs := $(NETIF_OBJS_TOTAL)

KBUILD_EXTRA_SYMBOLS := $(BUILD_OUTPUT_DIR)/Module.symvers
################################################################################
folder:
$(TEST_PATH) $(BUILD_OUTPUT_DIR) || $(MKDIR) $(BUILD_OUTPUT_DIR)
$(TEST_PATH) $(BUILD_OUTPUT_DIR)/src || $(MKDIR) $(BUILD_OUTPUT_DIR)/src

compile:: folder
touch $(BUILD_OUTPUT_DIR)/Makefile
$(MAKE) -C $(OS_PATH) M=$(BUILD_OUTPUT_DIR) src=$(shell pwd) modules EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS=$(KBUILD_EXTRA_SYMBOLS)

install::
$(TEST_PATH) $(MODULE_OUTPUT_DIR) || $(MKDIR) $(MODULE_OUTPUT_DIR)
$(MV) $(BUILD_OUTPUT_DIR)/$(DEV_MODULE_NAME).ko $(MODULE_OUTPUT_DIR)/$(DEV_MODULE_NAME).ko
$(MV) $(BUILD_OUTPUT_DIR)/$(NETIF_MODULE_NAME).ko $(MODULE_OUTPUT_DIR)/$(NETIF_MODULE_NAME).ko

clean::
$(RM) $(BUILD_OUTPUT_DIR)

.PHONY: all compile install clean
.NOTPARALLEL: all compile install clean

32 changes: 32 additions & 0 deletions platform/clounix/clounix-modules/modules/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
################################################################################
# Copyright (C) 2021 Clounix, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# version 2 along with this program.
################################################################################
Step 1~4 show how to build and execute CLX kernel modules.

1. Modify clounix-modules/Makefile to specify the output directory to BUILD_OUTPUT_DIR.
The default output path is clounix-modules/build.

2. Compile:
cd clounix-modules/ && make

3. The output kernel modules will be found in $(BUILD_OUTPUT_DIR)/modules/
- clx_dev.ko
- clx_netif.ko

4. Load modules:
(1) insmod clx_dev.ko
(2) insmod clx_netif.ko

Note that the module inserting sequence cannot be changed.
62 changes: 62 additions & 0 deletions platform/clounix/clounix-modules/modules/init.d/clx-modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# This script load/unload clx kernel modules

### BEGIN INIT INFO
# Provides: load-clx-modules
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Load clx kernel modules
### END INIT INFO

case "$1" in
start)
echo -n "Load clx kernel modules... "

RMEM_SIZE=`cat /proc/sys/net/core/rmem_max`
if [ $RMEM_SIZE -lt 8388608 ]; then
echo "8388608" > /proc/sys/net/core/rmem_max
fi
WMEM_SIZE=`cat /proc/sys/net/core/wmem_max`
if [ $WMEM_SIZE -lt 25165824 ]; then
echo "25165824" > /proc/sys/net/core/wmem_max
fi

if ! modprobe clx_dev ; then
modprobe nps_dev
fi
if ! modprobe clx_netif ; then
modprobe nps_netif
fi

echo "done."
;;

stop)
echo -n "Unload clx kernel modules... "

if ! rmmod clx_netif ; then
rmmod nps_netif
fi
if ! rmmod clx_dev ; then
rmmod nps_dev
fi

echo "done."
;;

force-reload|restart)
echo "Not supported"
;;

*)
echo "Usage: /etc/init.d/clx-modules {start|stop}"
exit 1
;;
esac

exit 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Clounix kernel modules init
After=local-fs.target
Before=syncd.service

[Service]
Type=oneshot
ExecStart=-/etc/init.d/clx-modules start
ExecStop=-/etc/init.d/clx-modules stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2022 Clounix
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation (the "GPL").
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 (GPLv2) for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 (GPLv2) along with this source code.
*/

/* FILE NAME: osal_isymbol.c
* PURPOSE:
* It provide global OSAL symbol export for linux kernel module
* NOTES:
*/
#include <linux/init.h>
#include <linux/module.h>

/* ----------------------------------------------------- */
#include <osal/osal_mdc.h>
/* dma */
extern struct pci_dev *_ptr_ext_pci_dev;
EXPORT_SYMBOL(_ptr_ext_pci_dev);

#if defined(CLX_LINUX_KERNEL_MODE)
#include <clx_init.h>
extern CLX_INIT_WRITE_FUNC_T _ext_dsh_write_func;
EXPORT_SYMBOL(_ext_dsh_write_func);
#endif

#if defined(CLX_LINUX_USER_MODE)
EXPORT_SYMBOL(osal_mdc_readPciReg);
EXPORT_SYMBOL(osal_mdc_writePciReg);
#if defined(CLX_EN_NETIF)
/* intr */
/* for kernel module, this API will be exported by script with other OSAL functions in osal_symbol.c */
EXPORT_SYMBOL(osal_mdc_registerIsr);
#endif
#endif
Loading
Loading