Changes between Initial Version and Version 1 of OpenWrt/swconfig


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (5 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OpenWrt/swconfig

    v1 v1  
     1{{{#!html
     2          <div id="wikipage" class="trac-content"><p>
     3</p><div class="wiki-toc">
     4<ol>
     5  <li>
     6    <a href="#swconfig">swconfig</a>
     7    <ol>
     8      <li>
     9        <a href="#Usage">Usage</a>
     10      </li>
     11      <li>
     12        <a href="#GW16083">GW16083</a>
     13      </li>
     14    </ol>
     15  </li>
     16</ol>
     17</div><p>
     18</p>
     19<h1 id="swconfig">swconfig</h1>
     20<p>
     21<tt>swconfig</tt> is a lightweight Linux kernel driver API and a command-line tool that helps users configure ports on a managed switch to configure things like VLAN tagging. Note that you can also use <tt>uci</tt>, or write directly to <tt>/etc/config/network</tt> for a more permanent solution. This tool allows for an 'unmanaged' switch to become a 'managed' switch, allowing for things like VLAN tagging/untagging and individual port monitoring.
     22</p>
     23<p>
     24Note that <tt>swconfig</tt> is an <a class="wiki" href="/wiki/OpenWrt">OpenWrt</a> kernel feature only and is not a part of mainline Linux (see the discussion <a class="ext-link" href="http://comments.gmane.org/gmane.linux.network/288039"><span class="icon">​</span>here</a> on why it has not been accepted). The switch architecture that has made it into mainline Linux is the Distributed Switch Architecture or DSA.
     25</p>
     26<p>
     27Capabilities of swconfig:
     28</p>
     29<ul><li>get/set a port VLAN id (TAG)
     30</li><li>get/set VLAN port membership
     31</li><li>get a port link status
     32</li><li>get port statistics counters
     33</li><li>reset switch
     34</li><li>apply conifg to switch
     35</li><li>based on generic Netlink infrastructure (easily extensible)
     36</li><li>much smaller API than DSA and does not interfere with network stack packet flow, but rather focuses on the control path of managed switches
     37</li></ul><p>
     38Because swconfig does not create a network interface per switch port, it can not support STP, LLDP, 802.1x, or other protocols that operate at a network device layer as the CPU can't send/receive packets to/from individual ports on the switch chip.
     39</p>
     40<p>
     41See also:
     42</p>
     43<ul><li><a class="ext-link" href="http://wiki.openwrt.org/doc/techref/swconfig"><span class="icon">​</span>http://wiki.openwrt.org/doc/techref/swconfig</a>
     44</li><li><a class="wiki" href="/wiki/linux/vlan#dsa">Distributed Switch Architecture</a>
     45</li></ul><h2 id="Usage">Usage</h2>
     46<p>
     47First thing a user should do is list out the devices currently available for <tt>swconfig</tt> to configure.
     48</p>
     49<div class="code"><pre>root@OpenWrt:/# swconfig list
     50Found: switch0 - mvsw6171
     51</pre></div><p>
     52From this point on, you can list the current configuration of the switch, or show a list of options that the switch supports:
     53</p>
     54<ul><li>enable or disable a port:
     55<pre class="wiki">swconifg dev &lt;switch&gt; port &lt;portno&gt; set disable &lt;0|1&gt;
     56</pre></li><li>disable VLANs:
     57<pre class="wiki">swconfig dev &lt;switch&gt; set enable_vlan 0
     58swconfig dev &lt;switch&gt; set apply
     59</pre></li><li>
     60</li></ul><p>
     61For example, <a class="wiki" href="/wiki/OpenWrt">OpenWrt</a> running on a Ventana board with a <a class="wiki" href="/wiki/ventana/expansion#gw16083">GW16083</a> Ethernet expansion mezzanine:
     62</p>
     63<div class="code"><pre>root@OpenWrt:/# swconfig dev switch0 show
     64Global attributes:
     65        enable_vlan: 0
     66Port 0:
     67        mask: 0x0000: <span class="o">(</span>0<span class="o">)</span>
     68        qmode: 0
     69        pvid: 0
     70        link: port:0 link:down
     71Port 1:
     72        mask: 0x0000: <span class="o">(</span>1<span class="o">)</span>
     73        qmode: 0
     74        pvid: 0
     75        link: port:1 link:down
     76Port 2:
     77        mask: 0x0000: <span class="o">(</span>2<span class="o">)</span>
     78        qmode: 0
     79        pvid: 0
     80        link: port:2 link:up speed:1000baseT full-duplex
     81Port 3:
     82        mask: 0x0000: <span class="o">(</span>3<span class="o">)</span>
     83        qmode: 0
     84        pvid: 0
     85        link: port:3 link:down
     86Port 4:
     87        mask: 0x0000: <span class="o">(</span>4<span class="o">)</span>
     88        qmode: 0
     89        pvid: 0
     90        link: port:4 link:up speed:1000baseT full-duplex
     91Port 5:
     92        mask: 0x0000: <span class="o">(</span>5<span class="o">)</span>
     93        qmode: 0
     94        pvid: 0
     95        link: port:5 link:down
     96Port 6:
     97        mask: 0x0000: <span class="o">(</span>6<span class="o">)</span>
     98        qmode: 0
     99        pvid: 0
     100        link: port:6 link:down
     101</pre></div><div class="code"><pre>root@OpenWrt:/# swconfig dev switch0 <span class="nb">help
     102</span>switch0: mvsw6171<span class="o">(</span>MV88E6176<span class="o">)</span>, ports: 7 <span class="o">(</span>cpu @ 4<span class="o">)</span>, vlans: 64
     103     --switch
     104        Attribute 1 <span class="o">(</span>int<span class="o">)</span>: enable_vlan <span class="o">(</span>Enable 802.1q VLAN support<span class="o">)</span>
     105        Attribute 2 <span class="o">(</span>none<span class="o">)</span>: apply <span class="o">(</span>Activate changes in the hardware<span class="o">)</span>
     106        Attribute 3 <span class="o">(</span>none<span class="o">)</span>: reset <span class="o">(</span>Reset the switch<span class="o">)</span>
     107     --vlan
     108        Attribute 1 <span class="o">(</span>int<span class="o">)</span>: port_based <span class="o">(</span>Use port-based <span class="o">(</span>non-802.1q<span class="o">)</span> VLAN only<span class="o">)</span>
     109        Attribute 2 <span class="o">(</span>int<span class="o">)</span>: vid <span class="o">(</span>Get/set VLAN ID<span class="o">)</span>
     110        Attribute 3 <span class="o">(</span>ports<span class="o">)</span>: ports <span class="o">(</span>VLAN port mapping<span class="o">)</span>
     111     --port
     112        Attribute 1 <span class="o">(</span>string<span class="o">)</span>: mask <span class="o">(</span>Port-based VLAN mask<span class="o">)</span>
     113        Attribute 2 <span class="o">(</span>int<span class="o">)</span>: qmode <span class="o">(</span>802.1q mode: <span class="nv">0</span><span class="o">=</span>off/1<span class="o">=</span>fallback/2<span class="o">=</span>check/3<span class="o">=</span>secure<span class="o">)</span>
     114        Attribute 3 <span class="o">(</span>int<span class="o">)</span>: pvid <span class="o">(</span>Primary VLAN ID<span class="o">)</span>
     115        Attribute 4 <span class="o">(</span>string<span class="o">)</span>: link <span class="o">(</span>Get port link information<span class="o">)</span>
     116</pre></div><p>
     117In order to set values, you have to read the attribute, determine the information it requires and set it. For example, if you want to create a VLAN with an VID of 100, and add several ports to it, the following would be the appropriate way to accomplish this
     118</p>
     119<div class="code"><pre>root@OpenWrt:/# swconfig dev switch0 vlan 5 <span class="nb">set </span>vid 100
     120root@OpenWrt:/# swconfig dev switch0 vlan 5 <span class="nb">set </span>ports <span class="s1">'2t 4'</span>
     121root@OpenWrt:/# swconfig dev switch0 <span class="nb">set </span>enable_vlan 1
     122root@OpenWrt:/# swconfig dev switch0 <span class="nb">set </span>apply
     123</pre></div><p>
     124The above example:
     125</p>
     126<ol><li>Creates a VLAN (#5)
     127</li><li>Adds two ports to it (2t and 4) while adding tagging to the number '2' port (the 't' appended to the '2')
     128</li><li>Enables vlan's on this switch
     129</li><li>And finally applies the settings.
     130</li></ol><p>
     131The result will look as follows:
     132</p>
     133<div class="code"><pre>root@OpenWrt:/# swconfig dev switch0 show
     134Global attributes:
     135        enable_vlan: 1
     136Port 0:
     137        mask: 0x0000: <span class="o">(</span>0<span class="o">)</span>
     138        qmode: 0
     139        pvid: 0
     140        link: port:0 link:down
     141Port 1:
     142        mask: 0x0000: <span class="o">(</span>1<span class="o">)</span>
     143        qmode: 0
     144        pvid: 0
     145        link: port:1 link:down
     146Port 2:
     147        mask: 0x0000: <span class="o">(</span>2<span class="o">)</span>
     148        qmode: 3
     149        pvid: 0
     150        link: port:2 link:up speed:1000baseT full-duplex
     151Port 3:
     152        mask: 0x0000: <span class="o">(</span>3<span class="o">)</span>
     153        qmode: 0
     154        pvid: 0
     155        link: port:3 link:down
     156Port 4:
     157        mask: 0x0000: <span class="o">(</span>4<span class="o">)</span>
     158        qmode: 3
     159        pvid: 100
     160        link: port:4 link:up speed:1000baseT full-duplex
     161Port 5:
     162        mask: 0x0000: <span class="o">(</span>5<span class="o">)</span>
     163        qmode: 0
     164        pvid: 0
     165        link: port:5 link:down
     166Port 6:
     167        mask: 0x0000: <span class="o">(</span>6<span class="o">)</span>
     168        qmode: 0
     169        pvid: 0
     170        link: port:6 link:down
     171VLAN 5:
     172        port_based: 0
     173        vid: 100
     174        ports: 2t 4
     175</pre></div><p>
     176Please note that port 4 was added to the vlan due to it being the CPU port. One can determine this by running the following command
     177</p>
     178<div class="code"><pre>root@OpenWrt:/# swconfig dev switch0 <span class="nb">help</span> | grep <span class="s2">"cpu @"</span>
     179switch0: mvsw6171<span class="o">(</span>MV88E6176<span class="o">)</span>, ports: 7 <span class="o">(</span>cpu @ 4<span class="o">)</span>, vlans: 64
     180</pre></div><p>
     181<span class="wikianchor" id="gw16083"></span>
     182</p>
     183<h2 id="GW16083">GW16083</h2>
     184<p>
     185The <a class="wiki" href="/wiki/ventana/expansion#gw16083">GW16083</a> is an Ethernet expansion mezzanine that is compatible with the Gateworks Ventana product family (if a mezzanine expansion is available on your board).
     186</p>
     187<p>
     188Note that the GW16083 support was added for <tt>swconfig</tt> in <a class="wiki" href="/wiki/OpenWrt">OpenWrt</a> very recently in our latest <a class="wiki" href="/wiki/OpenWrt">OpenWrt</a> on Github.
     189</p>
     190<p>
     191Note that the port numbers that <tt>swconfig</tt> are the physical ports on the MV88Ewith the GW16083 MV88E6176 chip. To map them to the silkscreen on the board use this table:
     192</p>
     193<p>
     194Please see <a class="wiki" href="/wiki/ventana/expansion#gw16083">GW16083</a> for a table of port mapping (matching silkscreen/connector to port numbers)
     195</p>
     196}}}