Fuel plugin for Mellanox support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install_ofed.sh 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. # Copyright 2015 Mellanox Technologies, Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13. # implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. readonly SCRIPT_DIR=$(dirname "$0")
  17. source $SCRIPT_DIR/common
  18. readonly KERNEL_VERSION="$(uname -r)"
  19. readonly OFED_PACKAGE_NAME="mlnx-ofed-fuel"
  20. readonly OFED_BASE_DIR="/opt/ofed"
  21. readonly OFED_SRC_DIR="${OFED_BASE_DIR}/MLNX_OFED"
  22. readonly OFED_SUCCESS_FILE="${OFED_BASE_DIR}/.success"
  23. readonly OFED_INFO="/usr/bin/ofed_info"
  24. OFED_DIR=$OFED_SRC_DIR
  25. function is_ofed_installed () {
  26. if [ -f ${OFED_SUCCESS_FILE} ] && [ -x ${OFED_INFO} ] && ( ${OFED_INFO} > /dev/null 2>&1 ); then
  27. installed_ofed_version=`${OFED_INFO} -s`
  28. logger_print info "OFED is already installed: ${installed_ofed_version}"
  29. return 0
  30. else
  31. return 1
  32. fi
  33. }
  34. function install_mlnx_ofed_src () {
  35. logger_print info "Installing ${OFED_PACKAGE_NAME} source code"
  36. if [ "$DISTRO" == "redhat" ]; then
  37. yum install ${OFED_PACKAGE_NAME} -y
  38. elif [ "$DISTRO" == "ubuntu" ]; then
  39. apt-get install ${OFED_PACKAGE_NAME} -y --force-yes
  40. fi
  41. if [ $? -ne 0 ]; then
  42. logger_print error "Failed installing ${OFED_PACKAGE_NAME} package"
  43. exit 1
  44. fi
  45. }
  46. function add_kernel_support () {
  47. # ubuntu doesn't require recompilation in case of kernel change, it supports dkms
  48. if [ "$DISTRO" == "ubuntu" ]; then
  49. return
  50. fi
  51. OFED_ADD_KERNEL_SUPPORT_SCRIPT="${OFED_DIR}/mlnx_add_kernel_support.sh"
  52. if [ ! -x $OFED_ADD_KERNEL_SUPPORT_SCRIPT ]; then
  53. logger_print error "Failed to find $OFED_ADD_KERNEL_SUPPORT_SCRIPT"
  54. exit 1
  55. fi
  56. OFED_VERSION=$(cat ${OFED_DIR}/.mlnx)
  57. OFED_ARCH=$(cat ${OFED_DIR}/.arch)
  58. OFED_DISTRO=$(cat ${OFED_DIR}/distro)
  59. RECOMPILED_OFED_NAME="MLNX_OFED_LINUX-${OFED_VERSION}-${OFED_DISTRO}-${OFED_ARCH}-ext"
  60. RECOMPILED_OFED_DIR="${OFED_BASE_DIR}/${RECOMPILED_OFED_NAME}"
  61. # Recompile OFED in case original OFED at $OFED_DIR doesn't support the existing kernel
  62. if ( ! grep -Fxq ${KERNEL_VERSION} ${OFED_DIR}/.supported_kernels ); then
  63. if [ ! -d ${RECOMPILED_OFED_DIR} ] || ( ! grep -Fxq ${KERNEL_VERSION} ${RECOMPILED_OFED_DIR}/.supported_kernels); then
  64. logger_print info "Recompiling OFED for kernel ${KERNEL_VERSION}"
  65. ${OFED_DIR}/mlnx_add_kernel_support.sh --force --yes --make-tgz --mlnx_ofed ${OFED_DIR}
  66. recompiled_ofed_archive=/tmp/${RECOMPILED_OFED_NAME}.tgz
  67. tar zxf $recompiled_ofed_archive -C ${OFED_BASE_DIR}
  68. rm -f $recompiled_ofed_archive
  69. fi
  70. OFED_DIR=$RECOMPILED_OFED_DIR
  71. fi
  72. }
  73. function install_missing_packages_for_ofed() {
  74. apt-get install -y --force-yes dpatch autoconf libgfortran3 \
  75. chrpath graphviz flex debhelper swig quilt m4 libltdl-dev \
  76. gfortran tcl bison autotools-dev tk python-libxml2 tcl8.4 \
  77. pkg-config automake tk8.4
  78. }
  79. function install_ofed_without_fw_update () {
  80. OFED_INSTALL_SCRIPT="${OFED_DIR}/mlnxofedinstall"
  81. if [ ! -f $OFED_INSTALL_SCRIPT ]; then
  82. logger_print error "Failed to find $OFED_INSTALL_SCRIPT"
  83. exit 1
  84. fi
  85. logger_print info "Installing missing packges for OFED"
  86. install_missing_packages_for_ofed
  87. logger_print info "Installing OFED drivers"
  88. OFED_INSTALL_SCRIPT_CMD="/usr/bin/perl ${OFED_INSTALL_SCRIPT}"
  89. ${OFED_INSTALL_SCRIPT_CMD} --force --without-fw-update
  90. rc=$?
  91. if [ $rc -ne 0 ]; then
  92. logger_print error "Failed execute ${OFED_INSTALL_SCRIPT_CMD} error code ${rc}"
  93. exit 1
  94. else
  95. touch ${OFED_SUCCESS_FILE}
  96. fi
  97. }
  98. function enable_eipoib (){
  99. sed -i s/^E_IPOIB_LOAD.*$/E_IPOIB_LOAD=yes/g /etc/infiniband/openib.conf
  100. # Set Buffers size
  101. if [ -f /etc/modprobe.d/ib_ipoib.conf ];then
  102. sed -i s/^.*queue_size.*$//g /etc/modprobe.d/ib_ipoib.conf
  103. fi
  104. if [[ $ROLE == *controller* ]];then
  105. buffer_size=32
  106. else
  107. buffer_size=128
  108. fi
  109. echo "options ib_ipoib recv_queue_size=$buffer_size send_queue_size=$buffer_size" > /etc/modprobe.d/ipoib.conf
  110. # Use fixed MLNX_OFED scripts
  111. \cp -f ./ipoibd /sbin/ipoibd
  112. \cp -f ./openibd /etc/init.d/openibd
  113. }
  114. function install_gawk (){
  115. apt-get -y install gawk
  116. }
  117. if ! is_ofed_installed; then
  118. # Install mlnx-ofed-fuel rpm/deb package which extracts OFED installation dir
  119. install_mlnx_ofed_src
  120. # Add support for the current kernel in case the OFED included in Fuel
  121. # wasn't compiled for the current kernel
  122. add_kernel_support
  123. # First install OFED without SR-IOV and FW upgrade
  124. install_ofed_without_fw_update
  125. # Enable Ethernet IP Over Infiniband in case of eth_ipoib driver
  126. enable_eipoib
  127. # Install gawk package for running ibdev2netdev -v
  128. install_gawk
  129. fi
  130. # Decrease loglevels for prevent flooding kernel messages to console
  131. sysctl_conf set 'kernel.printk' '4 4 1 7'
  132. service openibd stop
  133. service openibd start
  134. # Setting interfaces up
  135. for interface in `ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d' | \
  136. sed 's/://'`;do ifconfig $interface up; done
  137. exit 0