Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload sdk source code to support linux kernel 4.9.0-9 #3076

Closed
wants to merge 15 commits into from
Closed
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
10 changes: 10 additions & 0 deletions platform/nephos/nephos-modules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Nephos Platform modules

VERSION = 1.0.0

NEPHOS_MODULE = nephos-modules_$(VERSION)_amd64.deb
$(NEPHOS_MODULE)_SRC_PATH = $(PLATFORM_PATH)/nephos-modules
$(NEPHOS_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
SONIC_DPKG_DEBS += $(NEPHOS_MODULE)

SONIC_STRETCH_DEBS += $(NEPHOS_MODULE)
2 changes: 2 additions & 0 deletions platform/nephos/nephos-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Nephos-modules
Device drivers for support of Nephos platform for the SONiC project
5 changes: 5 additions & 0 deletions platform/nephos/nephos-modules/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nephos-modules (1.0.0) unstable; urgency=low

* Initial release

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

Package: nephos-modules
Architecture: amd64
Depends: linux-image-4.9.0-9-amd64
Description: kernel modules for nephos asic
33 changes: 33 additions & 0 deletions platform/nephos/nephos-modules/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/make -f

export INSTALL_MOD_DIR:=extra

PACKAGE_NAME := nephos-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:
make -C $(MODULE_SRC)

override_dh_auto_install:
dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/extra
cp $(MODULE_SRC)/build/module/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/extra
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/

override_dh_usrlocal:

override_dh_pysupport:

override_dh_clean:
dh_clean
test -d $(MODULE_SRC)/build || rm -rf $(MODULE_SRC)/build
50 changes: 50 additions & 0 deletions platform/nephos/nephos-modules/modules/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
################################################################################
# Copyright (C) 2019 Nephos, 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.
################################################################################
NPS_MODULES_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_PATH := $(NPS_MODULES_DIR)/src
INC_PATH := $(SRC_PATH)/inc
################################################################################
include $(NPS_MODULES_DIR)/config.mk
################################################################################
MODULE_OUTPUT_DIR := $(BUILD_OUTPUT_DIR)/module
################################################################################
all: compile install
################################################################################
EXTRA_CFLAGS += -I$(INC_PATH)
EXTRA_CFLAGS += -DNPS_EN_NETIF
EXTRA_CFLAGS += -DNPS_EN_TAURUS
EXTRA_CFLAGS += -DNPS_LINUX_USER_MODE
EXTRA_CFLAGS += -DNPS_EN_LITTLE_ENDIAN
ifeq ($(shell uname -m),x86_64)
EXTRA_CFLAGS += -DNPS_EN_HOST_64_BIT_LITTLE_ENDIAN
else
EXTRA_CFLAGS += -DNPS_EN_HOST_32_BIT_LITTLE_ENDIAN
endif
################################################################################
include $(SRC_PATH)/make.mk
################################################################################
compile::

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/nephos/nephos-modules/modules/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
################################################################################
# Copyright (C) 2019 Nephos, 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 NPS kernel modules.

1. Modify nps-modules/config.mk to specify the output directory to BUILD_OUTPUT_DIR.
The default output path is nps-modules/build.

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

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

4. Load modules:
(1) insmod nps_dev.ko
(2) insmod nps_netif.ko

Note that the module inserting sequence cannot be changed.
30 changes: 30 additions & 0 deletions platform/nephos/nephos-modules/modules/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
################################################################################
# Copyright (C) 2019 Nephos, 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.
################################################################################
BUILD_OUTPUT_DIR := $(NPS_MODULES_DIR)/build
################################################################################
#OS_PATH := /lib/modules/$(shell uname -r)/build
OS_PATH := /lib/modules/$(KVERSION)/build

################################################################################
MAKE := make
RM := rm -rf
MKDIR := mkdir -p
CP := cp
MV := mv
TEST_PATH := test -d
################################################################################
export BUILD_OUTPUT_DIR
export OS_PATH
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# This script load/unload nps kernel modules

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

case "$1" in
start)
echo -n "Load nps 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

modprobe nps_dev
modprobe nps_netif

echo "done."
;;

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

rmmod nps_netif
rmmod nps_dev
echo "done."
;;

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

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

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

[Service]
Type=oneshot
ExecStart=-/etc/init.d/nps-modules-4.9.0-9-amd64 start
ExecStop=-/etc/init.d/nps-modules-4.9.0-9-amd64 stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Loading