#!ipxe
#set bdf 0000:3d:00.3
#set QCTBDF 0000:00:08.0
#set QCTMAC 08:00:27:6b:53:eb
#set QCTMAC 08:00:27:89:ea:ad
#set QCTIP 10.5.12.120
#set QCTNETMASK 255.255.255.0
#set QCTGATEWAY 10.5.12.1
#set QCTFILENAME http://10.5.15.10/test/bdf.ipxe
#set QCTDNS 8.8.8.8
chain file:/utils/QCT.ipxe ||
console
isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||
isset ${QCTBDF} && goto boot_via_bdf ||
isset ${QCTMAC} && goto boot_via_mac ||
goto default_boot
exit
:exit_ipxe
exit
:boot_via_bdf
echo BOOT via BDF
set idx:int32 0
set loop_count:int32 1
:loop_bdf isset ${net${idx}/mac} || goto exit_ipxe
echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac} bdf ${net${idx}/busloc:busdevfn}
iseq ${net${idx}/busloc:busdevfn} ${QCTBDF} && set target_dev net${idx} ||
isset ${target_dev} && goto configure_ip ||
inc idx && goto loop_bdf
#:loop_done
exit
:boot_via_mac
echo BOOT via MAC
set idx:int32 0
set loop_count:int32 1
:loop_mac isset ${net${idx}/mac} || goto exit_ipxe
#echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac} bdf ${net${idx}/busloc:busdevfn}
iseq ${net${idx}/mac} ${QCTMAC} && set target_dev net${idx} ||
isset ${target_dev} && goto configure_ip ||
inc idx && goto loop_mac
#:loop_done
exit
:configure_ip
echo Configure IP address for ${target_dev}
isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||
isset ${QCTIP} || goto use_dhcp
i ||sset ${QCTNETMASK} || goto use_dhcp
isset ${QCTGATEWAY} || goto use_dhcp
goto use_static_ip
exit
:use_dhcp
echo use dhcp
dhcp ${target_dev} || goto default_boot
isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||
isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||
chain -r -a ${filename} ||
exit
:use_static_ip
echo use static ip
echo set ${target_dev}/ip ${QCTIP}
set ${target_dev}/ip ${QCTIP}
echo set ${target_dev}/netmask ${QCTNETMASK}
set ${target_dev}/netmask ${QCTNETMASK}
echo set ${target_dev}/gateway ${QCTGATEWAY}
set ${target_dev}/gateway ${QCTGATEWAY}
echo set ${filename}
chain -r -a ${filename} ||
exit
:default_boot
clear target_dev
isset ${QCTIP} || goto default_dhcp
isset ${QCTNETMASK} || goto default_dhcp
isset ${QCTGATEWAY} || goto default_dhcp
goto default_static_ip
exit
:default_dhcp
echo Default DHCP
set idx:int32 0
set loop_count:int32 1
:loop_dhcp isset ${net${idx}/mac} || goto exit_ipxe
ifopen net${idx}
echo Connectivity check for net${idx}
dhcp && goto chain_boot ||
ifclose net${idx}
inc idx
goto loop_dhcp
shell
exit
:default_static_ip
echo Default Static
set idx:int32 0
set loop_count:int32 1
:loop_static isset ${net${idx}/mac} || goto exit_ipxe
ifopen net${idx}
echo set net${idx}/ip ${QCTIP}
set net${idx}/ip ${QCTIP}
echo set net${idx}/netmask ${QCTNETMASK}
set net${idx}/netmask ${QCTNETMASK}
echo set net${idx}/gateway ${QCTGATEWAY}
set net${idx}/gateway ${QCTGATEWAY}
echo Connectivity check for net${idx}
ping -c 2 -q ${QCTGATEWAY} && goto chain_boot ||
ifclose net${idx}
inc idx
goto loop_static
shell
exit
:chain_boot
echo QCT Chain Boot
sleep 2
chain -r -a ${filename}
shell
exit