
if [ "${g60s_getHBAmodule}" = "" ]
then
    g60s_getHBAmodule="yes"

    checkHBAConfig ()
    {
 
	   ISCSI_SOFT_INITIATOR="0"
  
	   if [ -f /etc/linx-release ]
	   then
	       IS_Rocky=$(cat /etc/linx-release | grep "Rocky" -c)
	   else
	       IS_Rocky=0
	   fi
	   
	   if [ ${IS_Rocky} = 1 ]
	   then
		 TEMP_PATH="/usr/sbin"
	   else
		 TEMP_PATH="/sbin"
	   fi
	   lspci_n=`$TEMP_PATH/lspci -n | awk '{print $2}'` 
	   lspci_numeric=`expr "$lspci_n" : 'Class'`

	   if [ "$lspci_numeric" == "0" ]
	   then
			HBAModels=`$TEMP_PATH/lspci -n | /bin/gawk '/ 0c04:/ || / 0c06:/ || / 0100.*1077.*22../ || / 0100.*1000.*005/ ||/ 0280:/  {print $2 $3 $4 $5 }'`
	   else
			HBAModels=`$TEMP_PATH/lspci -n | /bin/gawk '/Class 0c04/ || /Class 0c06/ || /Class 0100.*1077.*22../ || /Class 0100.*1000.*005/ ||/Class 0280/  {print $3 $4 $5 $6 }'` 
	   fi
	   export HBAModels
	   
	   echo "$HBAModels" | /bin/gawk -v ISCSI_SOFT_INITIATOR=${ISCSI_SOFT_INITIATOR}\
			'BEGIN {
					NumberOfSupportedHBAModel = 0;
					nonSupportedHBAVendorExists = 0;
					FS=":";
 
 
					SupportedHBAModel["1000"] = "0050,0054,0056,0058,005a,005e,0062,0064,0072,0621,0622,0624,0626,0628,0640,0642,0646";
					SupportedHBAModel["1077"] = "2300,2310,2312,2322,2340,2342,2420,2422,2432,2440,2442,2460,2462,2532,4010,4022,4032,5422,5432,6312,6322,8001,8432";
					SupportedHBAModel["10df"] = "f011,f015,f095,f098,f0a1,f0a5,f0d5,f0e1,f0e5,f900,f980,fa00,fa01,fc00,fc10,fc20,fc40,fd00,fd11,fd12,fe00,fe05,fe11,fe12,f100,f111,f112,e628,e620,e630";
			SupportedHBAModel["1657"] = "0013,0017,0014";
					SupportedHBAModel["15b3"] = "5a44,6274,6278,6282,634a,673c";
 
					errorMessage[1] = "Unsupported Host Adapter Vendor: Vendor ID";
					errorMessage[2] = "Unsupported Host Adapter Model: Product ID";

			}
			{
					HBAVendorSupported = 0;
					HBAModelSupported = 0;
					HBAVendor = $2;
					HBAModel = $3;

			if ( match($0,"Class 0100") != 0  && match(HBAVendor, "1077") != 0  && match(HBAModel,"22") != 0 )
 
			{
				print errorMessage[2],HBAModel;
			}
			else
			{
				for (i in SupportedHBAModel)
				{
					if ( match(HBAVendor,i) != 0)
					{
						HBAVendorSupported = 1;
						SupportedVendor[i] ++;

						split(SupportedHBAModel[i],a,",");
						for ( j in a )
						{
							if (match(HBAModel,a[j]) != 0)
							{
								HBAModelSupported = 1;
								break;
							}
						}
						if ( HBAModelSupported == 0)
						{
							print errorMessage[2],HBAModel;
							UnsupportedModelFromVendor[i] = 1;
						}
						break; 
					}
				}
				if (HBAVendorSupported == 0)
				{
					nonSupportedHBAVendorExists = 1;
				}
			}
			}
			END {
 
			configCheckResult = 0;
			for (i in SupportedVendor) {
				if (match (i, "1077") != 0)
					VendorName = "QLogic" ;
				if (match (i, "1000") != 0)
					VendorName = "LSI";
				if (match (i, "10df") != 0)
					VendorName = "Emulex";
				if (match (i, "15b3") != 0)
					VendorName = "Supported";
 
				if (match (i, "1657") != 0)
					VendorName = "Brocade";
							SupportedVendors++;
			}
			if ( SupportedVendors == 0)
			{
 
				if(ISCSI_SOFT_INITIATOR == 1)
				{
					print "Find a software iSCSI initiator installed";
					configCheckResult = 3;
				}
				else
				{
					configCheckResult = 2;
				}
			}
			else
			{
				if ( SupportedVendors > 1 )
				{
					print "Host Adapters from different supported vendors co-exists on your system.";
					configCheckResult = 1;
				}

				for (i in UnsupportedModelFromVendor)
				{
					if (match (i, "1077") != 0)
						VendorName = "QLogic" ;
					if (match (i, "1000") != 0)
						VendorName = "LSI";
					if (match (i, "10df") != 0)
						VendorName = "Emulex";
					if (match (i, "15b3") != 0)
						VendorName = "Supported";
 
					if (match (i, "1657") != 0)
					VendorName = "Brocade";
					print "Unsupported model from Vendor", VendorName, " exists.";
					configCheckResult = 1;
				}
				if ( nonSupportedHBAVendorExists == 1)
				{
					print "Host Adapter from unsupported vendor detected.";
					configCheckResult = 1;
				}
			}
			print configCheckResult>"/tmp/checkResultFile.mpp";
			} ' ;
	}

	ModuleNameCheck()
	{
 
	   if [ "$#" -gt "0" ]
	   then
		   MPP_RAMDISK_KERNEL_VERSION="$1"
	   else
		   MPP_RAMDISK_KERNEL_VERSION="$(uname -r)"
	   fi

	   export MPP_RAMDISK_KERNEL_VERSION

	   /sbin/depmod -a ${MPP_RAMDISK_KERNEL_VERSION}

 
	   if [ "XXX${HBAModels}" == "XXX" ]
	   then
			return 0
	   fi

	   echo "$HBAModels" > /tmp/HBAModel.mpp
	   PCIMAP_MPP=`/bin/gawk ' { print $1,":",$2,":",$3; } ' /lib/modules/${MPP_RAMDISK_KERNEL_VERSION}/modules.pcimap`;
	   MODULE_LIST=`echo "$PCIMAP_MPP" | /bin/gawk -v HBAFile="/tmp/HBAModel.mpp" '
			BEGIN {
					FS=":";
					MODULE_LIST="";
					i=0;
					while ( getline < HBAFile > 0) {
						  VendorId[i] = "0x0000"$2;
						  split($3, device, "(");
						  DeviceId[i] = "0x0000"device[1];
						  i++;
					}
			}
			END {
					print MODULE_LIST ;
			}
			{
					HBAVendor = $2;
					HBAModel = $3;
					HBAModuleName = $1;

					for (i in VendorId)
					{
						if ( match(HBAVendor,VendorId[i]) != 0)
						{
							for ( j in DeviceId )
							{
								if (match(HBAModel,DeviceId[j]) != 0)
								{
									if(match(MODULE_LIST, HBAModuleName) == 0)
									{										
										if(match(HBAModuleName,"bna") == 0)
										{
											MODULE_LIST = MODULE_LIST HBAModuleName;
										}
									}
								}
							}
						}
					}
			} '`

 
	   if [ ! "$MODULE_LIST" = "" ]
	   then
		   export $MODULE_LIST;
	   fi

	   rm /tmp/HBAModel.mpp

	}
	
	function g60s_getHBAmoduleName()
	{
		print_debug "begin checkHBAConfig" "g60s"
		checkHBAConfig
		print_debug "begin ModuleNameCheck" "g60s"
		ModuleNameCheck
		print_debug "find Module Name: $MODULE_LIST" "g60s"
	}

else
    print_debug "g60s_getHBAmodule is in this shell." "g60s"
fi