-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scsi: Add Linkdata ps3stor RAIDHBA card support
This driver comes from WuXi Stars Micro System Technologies, which provides support for Linkdata ps3stor RAIDHBA card. Link: deepin-community/kernel#433 Link: deepin-community/kernel#487 Link: deepin-community/kernel#493 Co-developed-by: wenlunpeng <[email protected]> Signed-off-by: wenlunpeng <[email protected]> Co-developed-by: Wentao Guan <[email protected]> Signed-off-by: Wentao Guan <[email protected]> Signed-off-by: WangYuli <[email protected]>
- Loading branch information
1 parent
81b0de7
commit b851aa0
Showing
126 changed files
with
71,850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
# Linkdata network device configuration | ||
# | ||
|
||
config SCSI_LINKDATA_PS3STOR | ||
tristate "Linkdata ps3stor RAIDHBA card" | ||
depends on PCI && SCSI | ||
depends on SCSI_FC_ATTRS && CONFIG_SCSI_SAS_ATTRS | ||
select FW_LOADER | ||
help | ||
This driver support Linkdata ps3stor RAIDHBA card. | ||
|
||
To compile this driver as a module choose M here; the module | ||
will be called ps3stor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
EXTRA_CFLAGS += -DPS3_CFG_RELEASE | ||
EXTRA_CFLAGS += -DPS3_HARDWARE_ASIC | ||
EXTRA_CFLAGS += -DPS3_MODEL_V200 | ||
|
||
obj-$(CONFIG_SCSI_LINKDATA_PS3STOR) += ps3stor.o | ||
|
||
ps3stor-objs := ps3_cmd_channel.o ps3_device_update.o ps3_ioc_manager.o ps3_mgr_channel.o ps3_platform_utils.o ps3_scsi_cmd_err.o \ | ||
ps3_cmd_complete.o ps3_err_inject.o ps3_ioc_state.o ps3_mgr_cmd.o ps3_qos.o ps3_scsih.o \ | ||
ps3_cmd_statistics.o ps3_event.o ps3_ioctl.o ps3_mgr_cmd_err.o ps3_r1x_write_lock.o ps3_scsih_cmd_parse.o \ | ||
ps3_debug.o ps3_inject.o ps3_io_trace.o ps3_module_para.o ps3_rb_tree.o ps3_scsih_raid_engine.o \ | ||
ps3_device_manager.o ps3_instance_manager.o ps3_irq.o ps3_nvme_resp_to_scsi.o ps3_recovery.o ps3_trace_id_alloc.o \ | ||
ps3_device_manager_sas.o ps3_ioc_adp.o ps3_load.o ps3_pci.o ps3_sas_transport.o ps3_watchdog.o | ||
ps3stor-objs += linux/ps3_base.o linux/ps3_cli.o linux/ps3_cli_debug.o linux/ps3_driver_log.o linux/ps3_dump.o linux/ps3_pcie_err_handle.o | ||
|
||
ccflags-y += -Werror -frecord-gcc-switches | ||
ccflags-y += $(call cc-option, -Wmaybe-uninitialized) | ||
ccflags-y += -I$(srctree) \ | ||
-I$(srctree)/drivers/scsi/linkdata \ | ||
-I$(srctree)/drivers/scsi/linkdata/linux \ | ||
-I$(srctree)/drivers/scsi/linkdata/include \ | ||
-I$(srctree)/drivers/scsi/linkdata/include/htp_v200 | ||
ccflags-y += $(call cc-option, -mno-outline-atomics) | ||
|
||
clean: | ||
@rm -rf *.o *.d *.ko Module.* modules.* *.mod.* .*.d .*.cmd .tmp_versions *.o.ur-safe | ||
@rm -rf ./linux/*.o | ||
@rm -rf ./tags | ||
@rm -rf ./output.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# | ||
# clean.sh: a script clean the driver. | ||
# | ||
|
||
make clean | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
#!/bin/bash | ||
install_module=0 | ||
is_pkg_install="" | ||
pkg_mode="" | ||
ramfs_file="" | ||
ramfs_bak_file="" | ||
timestamp="" | ||
rpm_initrd="/boot/initramfs-$(uname -r).img" | ||
dpkg_initrd="/boot/initrd.img-$(uname -r)" | ||
driverDesDir="/lib/modules/$(uname -r)/kernel/drivers/scsi/" | ||
print_usage() { | ||
echo "Usage: $0 [-install|-auto] [-help]" | ||
echo "" | ||
echo "Options:" | ||
echo " -install|-i: compile and install the driver immediately" | ||
echo " -auto|-a: compile and install the driver, effective on next reboot" | ||
echo " -help|-h: print usage message" | ||
echo "" | ||
echo "Performs the compilation and installation of a driver. If no options given then does compilation only." | ||
exit 1 | ||
} | ||
|
||
find_rpm_or_deb() { | ||
is_pkg_install=$1 | ||
pkg_mode=$2 | ||
ramfs_file=$3 | ||
|
||
if [ -f "$rpm_initrd" ]; then | ||
ramfs_file=$rpm_initrd | ||
pkg_mode="rpm" | ||
if rpm -qa |grep ps3stor &> /dev/null ; then | ||
is_pkg_install="pkg" | ||
elif lsinitrd "$ramfs_file" | grep -q "ps3stor" ; then | ||
is_pkg_install="auto" | ||
elif lsmod | grep -q ps3stor; then | ||
is_pkg_install="install" | ||
else | ||
is_pkg_install="no" | ||
fi | ||
|
||
elif [ -f "$dpkg_initrd" ]; then | ||
ramfs_file=$dpkg_initrd | ||
pkg_mode="deb" | ||
dpkg_status=$(dpkg -l | grep ps3stor | awk '{ print $1 }') | ||
if [ "$dpkg_status" == "ii" ]; then | ||
is_pkg_install="pkg" | ||
elif lsinitramfs -l "$ramfs_file" | grep -q "ps3stor" ; then | ||
is_pkg_install="auto" | ||
elif lsmod | grep -q ps3stor; then | ||
is_pkg_install="install" | ||
else | ||
is_pkg_install="no" | ||
fi | ||
else | ||
is_pkg_install="no" | ||
fi | ||
} | ||
|
||
backup_restore(){ | ||
if [ -e "${driverDesDir}/ps3stor.ko.$timestamp" ]; then | ||
cp -f ${driverDesDir}/ps3stor.ko.$timestamp ${driverDesDir}/ps3stor.ko | ||
fi | ||
if [ -e "${driverDesDir}/ps3stor.ko.xz.$timestamp" ]; then | ||
cp -f ${driverDesDir}/ps3stor.ko.xz.$timestamp ${driverDesDir}/ps3stor.ko.xz | ||
fi | ||
if [ -e "$ramfs_bak_file" ]; then | ||
echo "The backup file for boot is $ramfs_bak_file, please use the backup file to restore the system environment." | ||
fi | ||
echo "The ps3stor.ko deployed failed." | ||
} | ||
|
||
check_return(){ | ||
if [ $? -ne 0 ]; then | ||
backup_restore | ||
exit 1; | ||
fi | ||
} | ||
|
||
auto_install(){ | ||
if [ $pkg_mode != "rpm" ] && [ $pkg_mode != "deb" ]; then | ||
echo "Cannot find initrd file." | ||
exit 1 | ||
fi | ||
timestamp=$(date +"%Y%m%d%H%M%S") | ||
if [ -e "${driverDesDir}/ps3stor.ko" ]; then | ||
cp -f ${driverDesDir}/ps3stor.ko ${driverDesDir}/ps3stor.ko.$timestamp | ||
fi | ||
if [ -e "${driverDesDir}/ps3stor.ko.xz" ]; then | ||
cp -f ${driverDesDir}/ps3stor.ko.xz ${driverDesDir}/ps3stor.ko.xz.$timestamp | ||
fi | ||
ramfs_bak_file=$ramfs_file.${timestamp} | ||
if [ -e "$ramfs_file" ]; then | ||
cp -f "$ramfs_file" "$ramfs_bak_file" | ||
fi | ||
if [ $? -ne 0 ]; then | ||
echo "Initramfs backup failed, please check permissions and disk space." | ||
exit 1 | ||
fi | ||
md5_sum_of_ramfs_back=$(md5sum "$ramfs_file" | awk '{print $1}') | ||
|
||
cp -f ps3stor.ko $driverDesDir | ||
xz -f ps3stor.ko | ||
cp -f ps3stor.ko.xz $driverDesDir | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to store ps3stor file, please check permissions and disk space." | ||
exit 1 | ||
fi | ||
|
||
depmod -a | ||
check_return | ||
|
||
sleep 1s | ||
|
||
if [ "$pkg_mode" == "rpm" ]; then | ||
dracut -v -f | ||
elif [ "$pkg_mode" == "deb" ]; then | ||
mkinitramfs -o $ramfs_file | ||
fi | ||
check_return | ||
sleep 1s | ||
|
||
max_retries=30 | ||
retry_interval=1 | ||
attempt=0 | ||
while [ $attempt -lt $max_retries ]; do | ||
md5_sum_of_ramfs=$(md5sum "$ramfs_file" | awk '{print $1}') | ||
echo "The ps3stor.ko is being deployed, please wait." | ||
if [ "$pkg_mode" == "rpm" ] ; then | ||
if lsinitrd "$ramfs_file" | grep -q "ps3stor" && [ $md5_sum_of_ramfs != $md5_sum_of_ramfs_back ]; then | ||
echo "The ps3stor.ko has been deployed. For immediate effect, please reboot or shutdown." | ||
break | ||
fi | ||
elif [ "$pkg_mode" == "deb" ] ; then | ||
if lsinitramfs -l "$ramfs_file" | grep -q "ps3stor" && [ $md5_sum_of_ramfs != $md5_sum_of_ramfs_back ]; then | ||
echo "The ps3stor.ko has been deployed. For immediate effect, please reboot or shutdown." | ||
break | ||
fi | ||
fi | ||
attempt=$((attempt + 1)) | ||
sleep $retry_interval | ||
done | ||
if [ $attempt -ge $max_retries ]; then | ||
backup_restore | ||
exit 1 | ||
fi | ||
|
||
} | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-install|-i) | ||
if [ $install_module -ne 0 ];then | ||
print_usage | ||
exit 1 | ||
else | ||
install_module=1 | ||
shift | ||
fi | ||
;; | ||
-auto|-a) | ||
if [ $install_module -ne 0 ];then | ||
print_usage | ||
exit 1 | ||
else | ||
install_module=2 | ||
shift | ||
fi | ||
;; | ||
-help|-h) | ||
print_usage | ||
exit 0 | ||
shift | ||
;; | ||
*) | ||
echo "Invalid argument: $1" | ||
print_usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
output_filename="output.log" | ||
if [ -e "$output_filename" ]; then | ||
rm -rf output_filename | ||
fi | ||
chmod a+x clean.sh | ||
./clean.sh | ||
|
||
if ! command -v gcc &> /dev/null; then | ||
echo "Error: The gcc compiler is not installed in the system." | ||
echo "Please install gcc before running this script." | ||
exit 1 | ||
fi | ||
|
||
kernel_source_dir="/lib/modules/`uname -r`/build" | ||
|
||
make -j4 -C $kernel_source_dir M=$PWD 2>&1 | tee output_filename | ||
|
||
ko_filename="ps3stor.ko" | ||
if [ ! -f "$ko_filename" ]; then | ||
echo "The compilation execution failed." | ||
exit 1 | ||
fi | ||
|
||
if [ $install_module == 0 ]; then | ||
exit 0 | ||
fi | ||
find_rpm_or_deb $is_pkg_install $pkg_mode $ramfs_file | ||
if [ "$is_pkg_install" == "pkg" ]; then | ||
echo "The ps3stor.ko module has been loaded in rpm/deb format. Please unload the current driver pkg first." | ||
exit 1 | ||
elif [ "$is_pkg_install" = "auto" ]; then | ||
echo "Already have a ps3stor.ko loaded in auto. Please unload first." | ||
exit 1 | ||
elif [ "$is_pkg_install" = "install" ]; then | ||
echo "Already have a ps3stor.ko loaded. Please unload first." | ||
exit 1 | ||
elif [ "$is_pkg_install" = "no" ]; then | ||
if [ $install_module == 1 ]; then | ||
if !(lsmod |grep -q scsi_transport_sas); then | ||
modprobe scsi_transport_sas | ||
fi | ||
if [ $? -eq 0 ]; then | ||
insmod ps3stor.ko | ||
if [ $? -eq 0 ]; then | ||
echo "The ps3stor.ko module has been loaded successfully." | ||
else | ||
echo "The ps3stor.ko module has been loaded failed." | ||
exit 1 | ||
fi | ||
else | ||
echo "The ps3stor.ko module has been loaded failed." | ||
exit 1 | ||
fi | ||
elif [ $install_module == 2 ]; then | ||
auto_install | ||
fi | ||
else | ||
echo "unknown err" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Master copy of dkms.conf for ps3stor. | ||
# Dont edit this file manually. Auto build script makes necessary changes. | ||
# | ||
|
||
PACKAGE_NAME="ps3stor" | ||
PACKAGE_VERSION=0.0.0.0 | ||
MOD_PATH=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION} | ||
|
||
MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${MOD_PATH}/build modules" | ||
CLEAN="make -C ${kernel_source_dir} SUBDIRS=${MOD_PATH}/build clean" | ||
|
||
BUILT_MODULE_NAME[0]="ps3stor" | ||
DEST_MODULE_LOCATION[0]="/kernel/drivers/scsi/" | ||
MODULES_CONF_ALIAS_TYPE[0]="scsi_hostadapter" | ||
|
||
REMAKE_INITRD="yes" |
Oops, something went wrong.