modules/admin-full: add option for RTL8366 jumbo frame passthrough to vlan page
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / vlan.lua
index 149b5c6..2a45e60 100644 (file)
@@ -20,11 +20,14 @@ m.uci:foreach("network", "switch",
                local switch_name = x.name or x['.name']
                local has_vlan4k  = nil
                local has_ptpvid  = nil
+               local has_jumbo3  = nil
                local max_vid     = 16
                local num_vlans   = 16
                local num_ports   = 5
                local cpu_port    = 5
 
+               local enable_vlan4k = false
+
                -- Parse some common switch properties from swconfig help output.
                local swc = io.popen("swconfig dev %q help 2>/dev/null" % switch_name)
                if swc then
@@ -47,14 +50,19 @@ m.uci:foreach("network", "switch",
                                        num_ports, cpu_port, num_vlans =
                                                line:match("ports: (%d+) %(cpu @ (%d+)%), vlans: (%d+)")
 
-                                       num_ports = tonumber(num_ports or  5)
-                                       num_vlans = tonumber(num_vlans or 16)
-                                       cpu_port  = tonumber(cpu_port  or  5)
+                                       num_ports = tonumber(num_ports) or  5
+                                       num_vlans = tonumber(num_vlans) or 16
+                                       cpu_port  = tonumber(cpu_port)  or  5
 
                                elseif line:match(": pvid") or line:match(": tag") or line:match(": vid") then
                                        if is_vlan_attr then has_vlan4k = line:match(": (%w+)") end
                                        if is_port_attr then has_ptpvid = line:match(": (%w+)") end
 
+                               elseif line:match(": enable_vlan4k") then
+                                       enable_vlan4k = true
+
+                               elseif line:match(": max_length") then
+                                       has_jumbo3 = true
                                end
                        end
 
@@ -93,15 +101,20 @@ m.uci:foreach("network", "switch",
                s = m:section(NamedSection, x['.name'], "switch", translatef("Switch %q", switch_name))
                s.addremove = false
 
-               s:option(Flag, "enable", "Enable this switch")
-                       .cfgvalue = function(self, section) return Flag.cfgvalue(self, section) or self.enabled end
+               s:option(Flag, "enable", translate("Enable this switch")).default = "1"
+               s:option(Flag, "enable_vlan", translate("Enable VLAN functionality")).default = "1"
 
-               s:option(Flag, "enable_vlan", "Enable VLAN functionality")
-                       .cfgvalue = function(self, section) return Flag.cfgvalue(self, section) or self.enabled end
+               if enable_vlan4k then
+                       s:option(Flag, "enable_vlan4k", translate("Enable 4K VLANs"))
+               end
 
-               s:option(Flag, "reset", "Reset switch during setup")
-                       .cfgvalue = function(self, section) return Flag.cfgvalue(self, section) or self.enabled end
+               if has_jumbo3 then
+                       j = s:option(Flag, "max_length", translate("Enable Jumbo Frame passthrough"))
+                       j.enabled = "3"
+                       j.rmempty = true
+               end
 
+               s:option(Flag, "reset", translate("Reset switch during setup")).default = "1"
 
                -- VLAN table
                s = m:section(TypedSection, "switch_vlan", translatef("VLANs on %q", switch_name))
@@ -199,6 +212,7 @@ m.uci:foreach("network", "switch",
                local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID")
 
                vid.rmempty = false
+               vid.forcewrite = true
 
                -- Validate user provided VLAN ID, make sure its within the bounds
                -- allowed by the switch.
@@ -250,6 +264,7 @@ m.uci:foreach("network", "switch",
 
                        po.cfgvalue = portvalue
                        po.validate = portvalidate
+                       po.write    = function() end
 
                        port_opts[#port_opts+1] = po
                end
@@ -264,8 +279,7 @@ m.uci:foreach("network", "switch",
                        s = m:section(TypedSection, "switch",
                                translatef("Port PVIDs on %q", switch_name),
                                translate("Port <abbr title=\"Primary VLAN IDs\">PVIDs</abbr> specify " ..
-                                       "the default VLAN ID added to received untagged frames.<br />" ..
-                                       "Leave the ID field empty to disable auto tagging on the associated port."))
+                                       "the default VLAN ID added to received untagged frames."))
 
                        s.template  = "cbi/tblsection"
                        s.addremove = false