Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wr-switch-sw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
white-rabbit
wr-switch-sw
Commits
f08386fe
Commit
f08386fe
authored
Jan 08, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'adam-vlans'
Create script which can be filled with vlans' configuration
parents
6ba8e2f4
4d6d611d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
155 additions
and
27 deletions
+155
-27
endpoint.c
kernel/wr_nic/endpoint.c
+15
-13
enable_switching.sh
userspace/rootfs_override/etc/init.d/enable_switching.sh
+46
-0
vlan.sh
userspace/rootfs_override/etc/init.d/vlan.sh
+44
-0
S61vlan.sh
userspace/rootfs_override/etc/rcS/S61vlan.sh
+1
-0
S62enable_switching.sh
userspace/rootfs_override/etc/rcS/S62enable_switching.sh
+1
-0
vlan_config.sh
userspace/rootfs_override/wr/etc/vlan_config.sh
+33
-0
wrs_vlans.c
userspace/tools/wrs_vlans.c
+14
-5
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+1
-9
No files found.
kernel/wr_nic/endpoint.c
View file @
f08386fe
...
...
@@ -176,7 +176,6 @@ int wrn_ep_open(struct net_device *dev)
{
struct
wrn_ep
*
ep
=
netdev_priv
(
dev
);
unsigned
long
timerarg
=
(
unsigned
long
)
dev
;
int
prio
,
prio_map
;
if
(
WR_IS_NODE
)
{
netif_carrier_on
(
dev
);
...
...
@@ -184,18 +183,6 @@ int wrn_ep_open(struct net_device *dev)
}
/* Prepare hardware registers: first config, then bring up */
writel
(
0
|
EP_VCR0_QMODE_W
(
0x3
)
/* unqualified port */
|
EP_VCR0_PRIO_VAL_W
(
4
),
/* some mid priority */
&
ep
->
ep_regs
->
VCR0
);
/* Write default 802.1Q tag priority to traffic class mapping */
prio_map
=
0
;
for
(
prio
=
0
;
prio
<
8
;
++
prio
)
{
prio_map
|=
(
0x7
&
prio
)
<<
(
prio
*
3
);
}
writel
(
prio_map
,
&
ep
->
ep_regs
->
TCAR
);
/*
* enable RX timestamping (it has no impact on performance)
...
...
@@ -255,6 +242,7 @@ int wrn_endpoint_probe(struct net_device *dev)
struct
wrn_ep
*
ep
=
netdev_priv
(
dev
);
static
u8
wraddr
[
6
];
int
err
;
int
prio
,
prio_map
;
u32
val
;
if
(
is_zero_ether_addr
(
wraddr
))
{
...
...
@@ -319,6 +307,20 @@ int wrn_endpoint_probe(struct net_device *dev)
ep
->
mii
.
advertising
=
ADVERTISE_1000XFULL
;
ep
->
mii
.
full_duplex
=
1
;
/* set-up VLAN related registers during driver loading not during
* opening device */
writel
(
0
|
EP_VCR0_QMODE_W
(
0x3
)
/* unqualified port */
|
EP_VCR0_PRIO_VAL_W
(
4
),
/* some mid priority */
&
ep
->
ep_regs
->
VCR0
);
/* Write default 802.1Q tag priority to traffic class mapping */
prio_map
=
0
;
for
(
prio
=
0
;
prio
<
8
;
++
prio
)
{
prio_map
|=
(
0x7
&
prio
)
<<
(
prio
*
3
);
}
writel
(
prio_map
,
&
ep
->
ep_regs
->
TCAR
);
/* Finally, register and succeed, or fail and undo */
err
=
register_netdev
(
dev
);
...
...
userspace/rootfs_override/etc/init.d/enable_switching.sh
0 → 100755
View file @
f08386fe
#!/bin/sh
start
()
{
echo
-n
"Enable switching: "
# bring up all interfaces
for
i
in
`
ls
/sys/class/net |
grep
wr
`
do
ifconfig
$i
up
done
echo
"OK"
}
stop
()
{
echo
-n
"Disable switching: "
# bring down all interfaces
for
i
in
`
ls
/sys/class/net |
grep
wr
`
do
ifconfig
$i
down
done
echo
"OK"
}
restart
()
{
stop
start
}
case
"
$1
"
in
start
)
start
;;
stop
)
stop
;;
restart|reload
)
restart
;;
*
)
echo
$"Usage:
$0
{start|stop|restart}"
exit
1
;;
esac
userspace/rootfs_override/etc/init.d/vlan.sh
0 → 100755
View file @
f08386fe
#!/bin/sh
start
()
{
echo
-n
"Setting up VLANs: "
# set-up VLANs
/wr/etc/vlan_config.sh
if
[
$?
-eq
0
]
;
then
echo
"OK"
else
echo
"Failed"
fi
}
stop
()
{
echo
-n
"Clean VLANs' configuration: "
/wr/bin/wrs_vlans
--ep
0-17
--emode
3
/wr/bin/wrs_vlans
--clear
echo
"OK"
}
restart
()
{
stop
start
}
case
"
$1
"
in
start
)
start
;;
stop
)
stop
;;
restart|reload
)
restart
;;
*
)
echo
$"Usage:
$0
{start|stop|restart}"
exit
1
;;
esac
userspace/rootfs_override/etc/rcS/S61vlan.sh
0 → 120000
View file @
f08386fe
../init.d/vlan.sh
\ No newline at end of file
userspace/rootfs_override/etc/rcS/S62enable_switching.sh
0 → 120000
View file @
f08386fe
../init.d/enable_switching.sh
\ No newline at end of file
userspace/rootfs_override/wr/etc/vlan_config.sh
0 → 100755
View file @
f08386fe
#!/bin/sh
set
-e
## vlan configuration
## fill this file with vlans configuration
## Please note:
## wr1 is marked as port 2 on the front panel of the switch
## in other words:
## --ep1 == wr1
## but:
## wr1 == port2
## example configuration:
# configure ports 1-4,6,8-18 as evid 1
# /wr/bin/wrs_vlans --ep 0-3,5,7-17 --emode 0 --evid 1
# configure ports 5,7 as evid 2
# /wr/bin/wrs_vlans --ep 4,6 --emode 0 --evid 2
## set VID=1 on all ports except 4 and 6
## - binary: 11 1111 1111 1010 1111
## - hex : 0x3FFAF
# /wr/bin/wrs_vlans --rvid 1 --rfid 1 --rmask 0x3FFAF
## set VID=2 at ports 5 and 7 - this is
## - binary: 00 0000 0000 0101 0000
## - hex : 0x00050
# /wr/bin/wrs_vlans --rvid 2 --rfid 2 --rmask 0x00050
## when VLANs are defined, comment out the line below
echo
-n
"no configuration "
exit
0
userspace/tools/wrs_vlans.c
View file @
f08386fe
...
...
@@ -150,13 +150,20 @@ int main(int argc, char *argv[])
print_help
(
prgname
);
exit
(
0
);
}
rtud_ch
=
minipc_client_create
(
"rtud"
,
0
);
if
(
!
rtud_ch
)
{
fprintf
(
stderr
,
"%s: Can't connect to RTUd mini-rpc server
\n
"
,
prgname
);
exit
(
1
);
n_wait
=
0
;
/* connect to the RTUd mini-rpc */
while
((
rtud_ch
=
minipc_client_create
(
"rtud"
,
0
))
==
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
fprintf
(
stderr
,
"%s: Can't connect to RTUd mini-rpc "
"server
\n
"
,
prgname
);
exit
(
1
);
}
sleep
(
1
);
}
n_wait
=
0
;
/* open rtu shm */
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_rtu
,
&
rtu_port_shmem
))
!=
0
)
{
n_wait
++
;
...
...
@@ -181,6 +188,8 @@ int main(int argc, char *argv[])
exit
(
1
);
}
/* get vlans array */
rtu_hdr
=
(
void
*
)
rtu_port_shmem
+
rtu_port_shmem
->
data_off
;
vlan_tab_shm
=
wrs_shm_follow
(
rtu_port_shmem
,
rtu_hdr
->
vlans
);
...
...
userspace/wrsw_hal/hal_ports.c
View file @
f08386fe
...
...
@@ -86,14 +86,6 @@ static int hal_port_check_presence(const char *if_name, unsigned char *mac)
return
1
;
}
static
void
hal_port_enable
(
int
port
,
int
enable
)
{
char
str
[
50
];
snprintf
(
str
,
sizeof
(
str
),
"/sbin/ifconfig wr%d %s"
,
port
,
enable
?
"up"
:
"down"
);
system
(
str
);
}
/* Port initialization, from dot-config values */
static
int
hal_port_init
(
int
index
)
{
...
...
@@ -142,7 +134,7 @@ static int hal_port_init(int index)
p
->
t4_phase_transition
=
DEFAULT_T4_PHASE_TRANS
;
p
->
clock_period
=
REF_CLOCK_PERIOD_PS
;
hal_port_enable
(
p
->
hw_index
,
1
);
/* enabling of ports is done by startup script */
{
static
struct
roletab
{
char
*
name
;
int
value
;
}
*
rp
,
rt
[]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment