Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- handle port reordering all models of spokane
- --
- -- this script needs to handle 5 models
- -- (6-port inbuilt 82574 + 8-port 82574 DCARD: MODEL-1 (850 / 860 / 870))
- -- (e1000e + e1000e)
- -- (6-port inbuilt 82574 + 8-port 82576 Fiber DCARD: MODEL-1 (870F))
- -- (e1000e + igb)
- -- (6-port inbuilt 82574 + 8-port 82574 DCARD model2 (1520))
- -- (e1000e + e1000e)
- -- (6-port inbuilt 82574 + 4-port 82599 10G DCARD model2 (1525))
- -- (e1000e + ixgbe)
- -- (4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3 (2520))
- -- (igb + ixgbe)
- --
- -- Because guessing model in the absence of serial number is bound up in
- -- numbers of interfaces, this script also has model guessing.
- -------------------------------------------------------------------------------------
- moddir = "/lib/drivers/"
- -- Check if file exists
- function fexists(n)
- local f=io.open(n, "r")
- if not f then return end
- io.close(f)
- return f~=nil
- end
- function reverse_engineer_modelname()
- local lmodel="none"
- --
- -- Check the cpu model (for Seattle)
- --
- if (cpu_model == 686002758) then
- -- M440
- lmodel = "M440"
- return lmodel
- end
- --
- -- Check the cpu model (for Wesport)
- --
- if (cpu_model == 686003150) then
- -- T70
- lmodel = "T70"
- return lmodel
- end
- if (cpu_model == 686003160) then
- -- T70
- lmodel = "T70"
- return lmodel
- end
- --
- -- filter which one of the lower end model it is : 850 / 860 / 870 / 870F
- -- 850/860/870: same HW: port ordering remains same: (Only XTM software differences)
- -- 870F : same HW as above: s/8-port 82576 1G Fiber/8-port 82574 1G Ethernet/
- --
- if (cpu_count == 4) then
- -- 850 / 860 / 870 / 870F
- if (ethcount == 14) then
- if (e1000e_count == 14) then -- (6-port inbuilt 82574 + 8-port 82574 DCARD: MODEL-1 (850 / 860 / 870))
- lmodel = "XTM850"
- elseif ( (e1000e_count == 6) and (igb_count == 8)) then -- (6-port inbuilt 82574 + 8-port 82576 Fiber DCARD: MODEL-1 (870F))
- lmodel = "XTM870-F"
- end
- end
- end
- --
- -- filter which one of the higher end model it is : 1520/1525/2520
- -- xtm1520: 6-port inbuilt 82574 + 8-port 82574 DCARD model2
- -- xtm1525: 6-port inbuilt 82574 + 4-port 82599 10G DCARD model2
- -- xtm2520: 4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3
- --
- if (cpu_count == 8) then
- -- 1520 / 1525 / 2520
- if (e1000e_count == 14) then -- (6-port inbuilt 82574 + 8-port 82574 DCARD model2 (1520))
- -- model xtm1520
- lmodel = "XTM1520"
- elseif ((e1000e_count == 6) and (ixgbe_count == 4)) then -- (6-port inbuilt 82574 + 4-port 82599 10G DCARD model2 (1525))
- -- model xtm1525
- lmodel = "XTM1525"
- elseif ((igb_count == 12) and (ixgbe_count == 4)) then -- (4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3 (2520))
- -- model xtm2520
- lmodel = "XTM2520"
- end
- end
- return lmodel
- end -- function reverse_engineer_modelname ends
- E1000E_LOADED = "/tmp/e1000e_loaded"
- E1000E_UNLOADED = "/tmp/e1000e_unloaded"
- IGB_LOADED = "/tmp/igb_loaded"
- IGB_UNLOADED = "/tmp/igb_unloaded"
- IXGBE_LOADED = "/tmp/ixgbe_loaded"
- IXGBE_UNLOADED = "/tmp/ixgbe_unloaded"
- I40E_LOADED = "/tmp/i40e_loaded"
- I40E_UNLOADED = "/tmp/i40e_unloaded"
- e1000e_count = 0
- igb_count = 0
- ixgbe_count = 0
- -- Load the mdio driver
- wglua.insmod( moddir .. "mdio.ko" )
- -- Load the i2c-algo-bit driver
- wglua.insmod( moddir .. "i2c-algo-bit.ko" )
- -- Selectively load/unload driver for 8-port 1G E 82574 (e1000e devices)
- oldcount = wglua.ifcount()
- wglua.insmod( moddir .. "e1000e.ko" )
- newcount = wglua.ifcount()
- if (newcount > oldcount) then
- wglua.touch( E1000E_LOADED )
- e1000e_count = newcount - oldcount
- else
- wglua.rm( E1000E_LOADED )
- wglua.touch( E1000E_UNLOADED )
- wglua.rmmod( "e1000e" )
- end
- -- Selectively load/unload driver for 8-port 1G E I350 DCARD (igb devices)
- oldcount = wglua.ifcount()
- if ( fexists(moddir .. "igb-intel.ko" ) ) then
- wglua.insmod( moddir .. "igb-intel.ko" )
- else
- wglua.insmod( moddir .. "igb.ko" )
- end
- newcount = wglua.ifcount()
- if (newcount > oldcount) then
- wglua.touch( IGB_LOADED )
- igb_count = newcount - oldcount
- else
- wglua.rm( IGB_LOADED )
- wglua.touch( IGB_UNLOADED )
- wglua.rmmod( "igb" )
- end
- -- Selectively load/unload driver for 4-port 10G F DCARD (ixgbe/82599 devices)
- oldcount = wglua.ifcount()
- if ( fexists(moddir .. "ixgbe-intel.ko" ) ) then
- wglua.insmod( moddir .. "ixgbe-intel.ko" )
- else
- wglua.insmod( moddir .. "ixgbe.ko" )
- end
- newcount = wglua.ifcount()
- if (newcount > oldcount) then
- wglua.touch( IXGBE_LOADED )
- ixgbe_count = newcount - oldcount
- else
- wglua.rm( IXGBE_LOADED )
- wglua.touch( IXGBE_UNLOADED )
- wglua.rmmod( "ixgbe" )
- end
- cpu_count = wglua.cpu_count()
- ethcount = e1000e_count + igb_count + ixgbe_count
- -- nr_pages = wglua.nr_pages()
- -- get the cpu model
- local f1 = io.open( "/proc/wg_kernel/cpu_model", "r" )
- if ( f1 ~= nil ) then
- cpu_model = f1:read( "*n" )
- f1:close()
- end
- -- Selectively load/unload driver for 2-port 40G devices)
- oldcount = wglua.ifcount()
- if ( fexists(moddir .. "i40e-intel.ko" ) ) then
- wglua.insmod( moddir .. "configfs.ko" )
- wglua.insmod( moddir .. "i40e-intel.ko" )
- else
- wglua.insmod( moddir .. "configfs.ko" )
- wglua.insmod( moddir .. "i40e.ko" )
- end
- newcount = wglua.ifcount()
- if (newcount > oldcount) then
- wglua.touch( I40E_LOADED )
- i40e_count = newcount - oldcount
- else
- wglua.rm( I40E_LOADED )
- wglua.touch( I40E_UNLOADED )
- wglua.rmmod( "i40e" )
- end
- --
- -- get the modelname using getmodel
- -- If not reverse engineer the model name
- --
- model=mfgtools.getmodel()
- if ( model ~= "X00" ) then
- -- we have a modelname already: good
- print ("we have a known model name")
- else
- print ("we DO NOT have a known model name")
- model="none"
- model=reverse_engineer_modelname()
- end
- -- write the modelname to a tmpfile
- print (" model is " .. model)
- fd = io.open( "/tmp/modelname", "w" )
- if ( fd ~= nil ) then
- fd:write(model)
- fd:close()
- end
- -- order the eths for Spokane models
- wglua.sleep( 4 )
- if (model == "XTM850" or model == "XTM1520" or model == "XTM1520-RP" ) then
- wglua.touch( "/tmp/model_XTM850" )
- wglua.ifrename('eth13', 'eth13_tmp')
- wglua.ifrename('eth6', 'eth13')
- wglua.ifrename('eth1', 'eth6')
- wglua.ifrename('eth9', 'eth1')
- wglua.ifrename('eth2', 'eth9')
- wglua.ifrename('eth10', 'eth2')
- wglua.ifrename('eth5', 'eth10')
- wglua.ifrename('eth13_tmp', 'eth5')
- wglua.ifrename('eth11', 'eth11_tmp')
- wglua.ifrename('eth4', 'eth11')
- wglua.ifrename('eth12', 'eth4')
- wglua.ifrename('eth7', 'eth12')
- wglua.ifrename('eth0', 'eth7')
- wglua.ifrename('eth8', 'eth0')
- wglua.ifrename('eth3', 'eth8')
- wglua.ifrename('eth11_tmp', 'eth3')
- elseif (model == "XTM870-F" ) then
- wglua.touch( "/tmp/model_XTM870-F" )
- -- no ordering needed
- elseif (model == "XTM1525" or model == "XTM1525-RP" ) then
- wglua.touch( "/tmp/model_XTM1525" )
- -- no ordering needed
- elseif (model == "XTM2520" ) then
- wglua.touch( "/tmp/model_XTM2520" )
- wglua.ifrename('eth11', 'eth11_tmp')
- wglua.ifrename('eth3' , 'eth11')
- wglua.ifrename('eth11_tmp', 'eth3')
- wglua.ifrename('eth10', 'eth10_tmp')
- wglua.ifrename('eth7' , 'eth10')
- wglua.ifrename('eth1' , 'eth7')
- wglua.ifrename('eth9' , 'eth1')
- wglua.ifrename('eth2' , 'eth9')
- wglua.ifrename('eth10_tmp' , 'eth2')
- wglua.ifrename('eth8', 'eth8_tmp')
- wglua.ifrename('eth6', 'eth8')
- wglua.ifrename('eth5', 'eth6')
- wglua.ifrename('eth0', 'eth5')
- wglua.ifrename('eth8_tmp', 'eth0')
- else
- wglua.touch( "/tmp/donothing" )
- end
- -- handle eths for Seattle
- if (model == "M440") then
- wglua.touch( "/tmp/model_M440" )
- local err = wglua.insmod( "/lib/drivers/pssBspApis.ko" )
- if ( err == 0 ) then
- print ( "98DX3035 present" )
- -- wglua.mknod( "/dev/mvPP", "0644", "c", 234, 0 )
- -- wglua.mknod( "/dev/mvKernelExt", "0644", "c", 234, 1 )
- wglua.insmod( "/lib/drivers/mv_KernelExt.ko" )
- wglua.insmod( "/lib/drivers/mvPpDrv.ko" )
- wglua.insmod( "/lib/drivers/wg_pss.ko" )
- wglua.insmod( "/lib/drivers/wg_queue.ko" )
- wglua.ifconfig( "sw0", "0.0.0.0/32", "up" )
- wglua.ifconfig( "sw1", "0.0.0.0/32", "up" )
- wglua.ifconfig( "sw2", "0.0.0.0/32", "up" )
- wglua.ifconfig( "sw3", "0.0.0.0/32", "up" )
- wglua.system( "/sbin/setmacs" )
- wglua.system( "/sbin/cpssd -D" )
- else
- print ( "98DX3035 not present" )
- end
- else
- wglua.rm( "/etc/inittab.d/cpssd" )
- wglua.rm( "/sbin/cpssd" )
- end
- -- handle eths for Westport
- if (model == "T70") then
- wglua.touch( "/tmp/model_T70" )
- wglua.insmod( "/lib/drivers/dsa_core.ko" )
- wglua.insmod( "/lib/drivers/mv88e6xxx_drv.ko" )
- wglua.insmod( "/lib/drivers/wg_dsa.ko" )
- wglua.system( "/sbin/setmacs" )
- -- interim fix before we get the Final BIOS. i.e. BIOS version > v1.2
- fd = io.open( "/sys/firmware/acpi/interrupts/gpe17", "w" )
- if ( fd ~= nil ) then
- fd:write("disable\n")
- fd:close()
- else
- print ("GPE17: COULD NOT apply!")
- end
- end
- -- configure the interfaces
- -- ... loopback
- wglua.ifconfig( "lo", "127.0.0.1/8", "up" )
- -- ... switches
- wglua.ifconfig( "sw10", "0.0.0.0/0", "up" )
- wglua.ifconfig( "sw11", "0.0.0.0/0", "up" )
- -- wg_linux platform.pkgspec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement