daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Jul 16th, 2018 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- handle port reordering all models of spokane
  3. --
  4. -- this script needs to handle 5 models
  5. --  (6-port inbuilt 82574 + 8-port 82574 DCARD: MODEL-1 (850 / 860 / 870))
  6. --      (e1000e + e1000e)
  7. --  (6-port inbuilt 82574 + 8-port 82576 Fiber DCARD: MODEL-1 (870F))
  8. --      (e1000e + igb)
  9. --  (6-port inbuilt 82574 + 8-port 82574 DCARD model2 (1520))                
  10. --      (e1000e + e1000e)
  11. --  (6-port inbuilt 82574 + 4-port 82599 10G DCARD model2 (1525))
  12. --      (e1000e + ixgbe)
  13. --  (4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3 (2520))  
  14. --      (igb + ixgbe)
  15. --
  16. --  Because guessing model in the absence of serial number is bound up in
  17. --  numbers of interfaces, this script also has model guessing.
  18.  
  19. -------------------------------------------------------------------------------------
  20.  
  21. moddir = "/lib/drivers/"
  22.  
  23. -- Check if file exists
  24. function fexists(n)
  25.     local f=io.open(n, "r")
  26.     if not f then return end
  27.     io.close(f)
  28.     return f~=nil
  29. end
  30.  
  31. function reverse_engineer_modelname()
  32.  
  33.     local lmodel="none"
  34.  
  35.     --
  36.     -- Check the cpu model (for Seattle)
  37.     --
  38.     if (cpu_model == 686002758) then
  39.         -- M440
  40.         lmodel = "M440"
  41.         return lmodel
  42.     end
  43.  
  44.     --
  45.     -- Check the cpu model (for Wesport)
  46.     --
  47.     if (cpu_model == 686003150) then
  48.         -- T70
  49.         lmodel = "T70"
  50.         return lmodel
  51.     end
  52.     if (cpu_model == 686003160) then
  53.         -- T70
  54.         lmodel = "T70"
  55.         return lmodel
  56.     end
  57.  
  58.     --
  59.     -- filter which one of the lower end model it is : 850 / 860 / 870 / 870F
  60.     --  850/860/870: same HW: port ordering remains same: (Only XTM software differences)
  61.     --  870F       : same HW as above: s/8-port 82576 1G Fiber/8-port 82574 1G Ethernet/
  62.     --
  63.     if (cpu_count == 4) then
  64.         -- 850 / 860 / 870 / 870F
  65.  
  66.         if (ethcount == 14) then
  67.             if (e1000e_count == 14) then                    -- (6-port inbuilt 82574 + 8-port 82574 DCARD: MODEL-1 (850 / 860 / 870))
  68.                 lmodel = "XTM850"
  69.             elseif ( (e1000e_count == 6) and (igb_count == 8)) then     -- (6-port inbuilt 82574 + 8-port 82576 Fiber DCARD: MODEL-1 (870F))
  70.                 lmodel = "XTM870-F"
  71.             end
  72.       end
  73.     end
  74.  
  75.     --
  76.     -- filter which one of the higher end model it is : 1520/1525/2520
  77.     -- xtm1520:     6-port inbuilt 82574 + 8-port 82574 DCARD model2
  78.     -- xtm1525:     6-port inbuilt 82574 + 4-port 82599 10G DCARD model2
  79.     -- xtm2520:     4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3
  80.     --
  81.     if (cpu_count == 8) then
  82.         -- 1520 / 1525 / 2520
  83.  
  84.         if (e1000e_count == 14) then                -- (6-port inbuilt 82574 + 8-port 82574 DCARD model2 (1520))
  85.             -- model xtm1520
  86.             lmodel = "XTM1520"
  87.         elseif ((e1000e_count == 6) and (ixgbe_count == 4)) then    -- (6-port inbuilt 82574 + 4-port 82599 10G DCARD model2 (1525))
  88.             -- model xtm1525
  89.             lmodel = "XTM1525"
  90.         elseif ((igb_count == 12) and (ixgbe_count == 4)) then  -- (4-port inbuild I-350 + 8-port I-350 DCARD + 82599 10G DCARD model3 (2520))
  91.             -- model xtm2520
  92.             lmodel = "XTM2520"
  93.         end
  94.     end
  95.  
  96.     return lmodel
  97.  
  98. end -- function reverse_engineer_modelname ends
  99.  
  100.  
  101. E1000E_LOADED = "/tmp/e1000e_loaded"
  102. E1000E_UNLOADED = "/tmp/e1000e_unloaded"
  103. IGB_LOADED = "/tmp/igb_loaded"
  104. IGB_UNLOADED = "/tmp/igb_unloaded"
  105. IXGBE_LOADED = "/tmp/ixgbe_loaded"
  106. IXGBE_UNLOADED = "/tmp/ixgbe_unloaded"
  107. I40E_LOADED = "/tmp/i40e_loaded"
  108. I40E_UNLOADED = "/tmp/i40e_unloaded"
  109.  
  110. e1000e_count = 0
  111. igb_count = 0
  112. ixgbe_count = 0
  113.  
  114. -- Load the mdio driver
  115. wglua.insmod( moddir .. "mdio.ko" )
  116.  
  117. -- Load the i2c-algo-bit driver
  118. wglua.insmod( moddir .. "i2c-algo-bit.ko" )
  119.  
  120. -- Selectively load/unload driver for 8-port 1G E 82574 (e1000e devices)
  121. oldcount = wglua.ifcount()
  122. wglua.insmod( moddir .. "e1000e.ko" )
  123. newcount = wglua.ifcount()
  124. if (newcount > oldcount) then
  125.     wglua.touch( E1000E_LOADED )
  126.     e1000e_count = newcount - oldcount
  127. else
  128.     wglua.rm( E1000E_LOADED )
  129.     wglua.touch( E1000E_UNLOADED )
  130.     wglua.rmmod( "e1000e" )
  131. end
  132.  
  133. -- Selectively load/unload driver for 8-port 1G E I350 DCARD (igb devices)
  134. oldcount = wglua.ifcount()
  135. if (    fexists(moddir .. "igb-intel.ko" ) ) then
  136.   wglua.insmod( moddir .. "igb-intel.ko" )
  137. else
  138.   wglua.insmod( moddir .. "igb.ko" )
  139. end
  140. newcount = wglua.ifcount()
  141. if (newcount > oldcount) then
  142.     wglua.touch( IGB_LOADED )
  143.     igb_count = newcount - oldcount
  144. else
  145.     wglua.rm( IGB_LOADED )
  146.     wglua.touch( IGB_UNLOADED )
  147.     wglua.rmmod( "igb" )
  148. end
  149.  
  150. -- Selectively load/unload driver for 4-port 10G F DCARD (ixgbe/82599 devices)
  151. oldcount = wglua.ifcount()
  152. if (    fexists(moddir .. "ixgbe-intel.ko" ) ) then
  153.   wglua.insmod( moddir .. "ixgbe-intel.ko" )
  154. else
  155.   wglua.insmod( moddir .. "ixgbe.ko" )
  156. end
  157. newcount = wglua.ifcount()
  158. if (newcount > oldcount) then
  159.     wglua.touch( IXGBE_LOADED )
  160.     ixgbe_count = newcount - oldcount
  161. else
  162.     wglua.rm( IXGBE_LOADED )
  163.     wglua.touch( IXGBE_UNLOADED )
  164.     wglua.rmmod( "ixgbe" )
  165. end
  166.  
  167. cpu_count = wglua.cpu_count()
  168. ethcount = e1000e_count + igb_count + ixgbe_count
  169. -- nr_pages  = wglua.nr_pages()
  170.  
  171. -- get the cpu model
  172. local f1 = io.open( "/proc/wg_kernel/cpu_model", "r" )
  173. if  ( f1 ~= nil ) then
  174.     cpu_model = f1:read( "*n" )
  175.     f1:close()
  176. end
  177.  
  178. -- Selectively load/unload driver for 2-port 40G devices)
  179. oldcount = wglua.ifcount()
  180. if (    fexists(moddir .. "i40e-intel.ko" ) ) then
  181.   wglua.insmod( moddir .. "configfs.ko" )
  182.   wglua.insmod( moddir .. "i40e-intel.ko" )
  183. else
  184.   wglua.insmod( moddir .. "configfs.ko" )
  185.   wglua.insmod( moddir .. "i40e.ko" )
  186. end
  187. newcount = wglua.ifcount()
  188. if (newcount > oldcount) then
  189.     wglua.touch( I40E_LOADED )
  190.     i40e_count = newcount - oldcount
  191. else
  192.     wglua.rm( I40E_LOADED )
  193.     wglua.touch( I40E_UNLOADED )
  194.     wglua.rmmod( "i40e" )
  195. end
  196.  
  197. --
  198. -- get the modelname using getmodel
  199. -- If not reverse engineer the model name
  200. --
  201. model=mfgtools.getmodel()
  202. if ( model ~= "X00" ) then
  203.     -- we have a modelname already: good
  204.     print ("we have a known model name")
  205. else
  206.     print ("we DO NOT have a known model name")
  207.     model="none"
  208.     model=reverse_engineer_modelname()
  209. end
  210.  
  211. -- write the modelname to a tmpfile
  212. print (" model is " .. model)
  213. fd = io.open( "/tmp/modelname", "w" )
  214. if ( fd ~= nil ) then
  215.     fd:write(model)
  216.     fd:close()
  217. end
  218.  
  219. -- order the eths for Spokane models
  220. wglua.sleep( 4 )
  221. if (model == "XTM850" or model == "XTM1520" or model == "XTM1520-RP" ) then
  222.  
  223.     wglua.touch( "/tmp/model_XTM850" )
  224.     wglua.ifrename('eth13', 'eth13_tmp')
  225.     wglua.ifrename('eth6', 'eth13')
  226.     wglua.ifrename('eth1', 'eth6')
  227.     wglua.ifrename('eth9', 'eth1')
  228.     wglua.ifrename('eth2', 'eth9')
  229.     wglua.ifrename('eth10', 'eth2')
  230.     wglua.ifrename('eth5', 'eth10')
  231.     wglua.ifrename('eth13_tmp', 'eth5')
  232.  
  233.     wglua.ifrename('eth11', 'eth11_tmp')
  234.     wglua.ifrename('eth4', 'eth11')
  235.     wglua.ifrename('eth12', 'eth4')
  236.     wglua.ifrename('eth7', 'eth12')
  237.     wglua.ifrename('eth0', 'eth7')
  238.     wglua.ifrename('eth8', 'eth0')
  239.     wglua.ifrename('eth3', 'eth8')
  240.     wglua.ifrename('eth11_tmp', 'eth3')
  241.  
  242. elseif (model == "XTM870-F" ) then
  243.     wglua.touch( "/tmp/model_XTM870-F" )
  244.     -- no ordering needed
  245.  
  246. elseif (model == "XTM1525" or model == "XTM1525-RP" ) then
  247.     wglua.touch( "/tmp/model_XTM1525" )
  248.     -- no ordering needed
  249.  
  250. elseif (model == "XTM2520" ) then
  251.  
  252.     wglua.touch( "/tmp/model_XTM2520" )
  253.  
  254.     wglua.ifrename('eth11', 'eth11_tmp')
  255.     wglua.ifrename('eth3' , 'eth11')
  256.     wglua.ifrename('eth11_tmp', 'eth3')
  257.    
  258.     wglua.ifrename('eth10', 'eth10_tmp')
  259.     wglua.ifrename('eth7' , 'eth10')
  260.     wglua.ifrename('eth1' , 'eth7')
  261.     wglua.ifrename('eth9' , 'eth1')
  262.     wglua.ifrename('eth2' , 'eth9')
  263.     wglua.ifrename('eth10_tmp' , 'eth2')
  264.    
  265.     wglua.ifrename('eth8', 'eth8_tmp')
  266.     wglua.ifrename('eth6', 'eth8')
  267.     wglua.ifrename('eth5', 'eth6')
  268.     wglua.ifrename('eth0', 'eth5')
  269.     wglua.ifrename('eth8_tmp', 'eth0')
  270.  
  271. else
  272.     wglua.touch( "/tmp/donothing" )
  273. end
  274.  
  275. -- handle eths for Seattle
  276. if (model == "M440") then
  277.  
  278.     wglua.touch( "/tmp/model_M440" )
  279.  
  280.     local err = wglua.insmod( "/lib/drivers/pssBspApis.ko" )
  281.     if  ( err == 0 ) then
  282.         print ( "98DX3035 present" )
  283.         -- wglua.mknod( "/dev/mvPP",        "0644", "c", 234, 0 )
  284.         -- wglua.mknod( "/dev/mvKernelExt", "0644", "c", 234, 1 )
  285.         wglua.insmod( "/lib/drivers/mv_KernelExt.ko" )
  286.         wglua.insmod( "/lib/drivers/mvPpDrv.ko" )
  287.         wglua.insmod( "/lib/drivers/wg_pss.ko" )
  288.         wglua.insmod( "/lib/drivers/wg_queue.ko" )
  289.         wglua.ifconfig( "sw0", "0.0.0.0/32", "up" )
  290.         wglua.ifconfig( "sw1", "0.0.0.0/32", "up" )
  291.         wglua.ifconfig( "sw2", "0.0.0.0/32", "up" )
  292.         wglua.ifconfig( "sw3", "0.0.0.0/32", "up" )
  293.         wglua.system( "/sbin/setmacs" )
  294.         wglua.system( "/sbin/cpssd -D" )
  295.     else
  296.         print ( "98DX3035 not present" )
  297.     end
  298.    
  299. else
  300.     wglua.rm( "/etc/inittab.d/cpssd" )
  301.     wglua.rm( "/sbin/cpssd" )
  302. end
  303.  
  304. -- handle eths for Westport
  305. if (model == "T70") then
  306.     wglua.touch( "/tmp/model_T70" )
  307.     wglua.insmod( "/lib/drivers/dsa_core.ko" )
  308.     wglua.insmod( "/lib/drivers/mv88e6xxx_drv.ko" )
  309.     wglua.insmod( "/lib/drivers/wg_dsa.ko" )
  310.     wglua.system( "/sbin/setmacs" )
  311.  
  312.  
  313.     -- interim fix before we get the Final BIOS. i.e. BIOS version > v1.2
  314.     fd = io.open( "/sys/firmware/acpi/interrupts/gpe17", "w" )
  315.     if ( fd ~= nil ) then
  316.         fd:write("disable\n")
  317.         fd:close()
  318.     else
  319.         print ("GPE17: COULD NOT apply!")
  320.     end
  321.  
  322. end
  323.  
  324. -- configure the interfaces
  325. -- ... loopback
  326. wglua.ifconfig( "lo", "127.0.0.1/8", "up" )
  327. -- ... switches
  328. wglua.ifconfig( "sw10", "0.0.0.0/0", "up" )
  329. wglua.ifconfig( "sw11", "0.0.0.0/0", "up" )
  330.  
  331. -- wg_linux platform.pkgspec
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top