Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: classifier.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)classifier.fth 1.1 07/01/23 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | ||
49 | d# 8 constant #rdc-tables | |
50 | d# 16 constant #rdc-tbl-entries | |
51 | ||
52 | \ Set all bits, including VPR0,1(,2,3), to 0 so that MAC/VLAN | |
53 | \ preference is in favor of MAC | |
54 | \ | |
55 | : init-vlan-tbl ( -- ) | |
56 | d# 4096 0 do 0 i enet-vlan-tbl-i! loop | |
57 | ; | |
58 | ||
59 | \ STAT will be set to 1 when read/write operation completes. | |
60 | \ | |
61 | : wait-tcam-done ( -- flag ) | |
62 | tcam-ctl@ stat-done and 0<> | |
63 | ; | |
64 | ||
65 | \ Clear four TCAM_KEY registers. The 0 value in these registers | |
66 | \ will be written to TCAM. (bits[194:0] of the TCAM do not matter | |
67 | \ because of our setting of the TCAM_MASK_i registers, but set them | |
68 | \ to 0 anyway.). | |
69 | \ | |
70 | : invalidate-tcam ( -- ) | |
71 | d# 256 0 do | |
72 | 0 tcam-key-0! | |
73 | h# ffff.ffff tcam-key-mask-0! | |
74 | \ Write the value (0) in TCAM_KEY regs to location i of the | |
75 | \ TCAM. bit stat-start==0 causes HW to start writing. | |
76 | rwc-write stat-start or i or tcam-ctl! \ TCAM_CTL.LOC = i | |
77 | d# 100 ['] wait-tcam-done wait-status | |
78 | 0= if | |
79 | cmn-error[ " Tcam access failed" ]cmn-end drop unloop | |
80 | then | |
81 | loop | |
82 | ; | |
83 | ||
84 | ||
85 | \ There are 128 Rx DMA table (RDC_TBL) entries, 16 for each of | |
86 | \ 8 RDC tables. We initialize the tables as follows: | |
87 | \ ith RDC Table has the ith Rx channel for all 16 entires, | |
88 | \ including the first entry as the default channel for that | |
89 | \ table. That is, | |
90 | \ RDC Table 0 entry 0~15: {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} | |
91 | \ RDC Table 1 entry 0~15: {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} | |
92 | \ RDC Table 2 entry 0~15: {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} | |
93 | \ RDC Table 3 entry 0~15: {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3} | |
94 | \ ... ... | |
95 | \ RDC Table 7 entry 0~15: {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7} | |
96 | \ | |
97 | \ i = 0~127, for Table 0, i= 0 ~ 15, i/16 ==> quot=0 | |
98 | \ for Table 1, i= 16 ~ 31, i/16 ==> quot=1 | |
99 | \ for Table 7, i=112 ~ 127, i/16 ==> quot=7 | |
100 | \ | |
101 | \ We have configured HOST_INFO register to indicate which RDC table should be | |
102 | \ used for this port. ( We selected port-th RDC table for port ), when | |
103 | \ there is a MAC address match, the HW will come here to find out the | |
104 | \ DMA channel to which the packet will be forward. | |
105 | \ | |
106 | : select-channels-for-rdc-tables ( -- ) | |
107 | #rdc-tables #rdc-tbl-entries * 0 do | |
108 | chan# i rdc-tbl-i! | |
109 | loop | |
110 | ; | |
111 | ||
112 | : set-default-rdc-for-my-port ( -- ) | |
113 | port case | |
114 | 0 of chan# def-pt0-rdc! endof | |
115 | 1 of chan# def-pt1-rdc! endof | |
116 | 2 of chan# def-pt2-rdc! endof | |
117 | 3 of chan# def-pt3-rdc! endof | |
118 | endcase | |
119 | ; | |
120 | ||
121 | \ Layer 2 Classification | |
122 | \ Set VLAN table so that preference is in favor of MAC match. | |
123 | \ Set MAC compare enable register so that only the comparison with | |
124 | \ unique MAC and flow control frame (actually, these two types of | |
125 | \ comparison can not be disabled in XMAC) are enabled but the | |
126 | \ comparisons with alternative MAC addresses is disabled. | |
127 | \ So if a incoming frame carries an MAC that matches the unique | |
128 | \ MAC, we will find the RDC table from the host-info register for | |
129 | \ the unique MAC ( We use p-th RDC table for port p). If there | |
130 | \ is an error in the frame or there is no match with the unique MAC, | |
131 | \ the frame will be directed to the default DMA associated with | |
132 | \ the port ( which is also set to p-th Rx DMA channel). | |
133 | \ Then the Neptune handles L2 classification as follows, | |
134 | \ (1) If a frame carries unique MAC or a flow control frame comes | |
135 | \ through port p, it will have DMA channel p as the L2 | |
136 | \ classification result. Then we do L234 classification | |
137 | \ using FFLP. | |
138 | \ (2) If a frame coming through port p carries alternative MAC | |
139 | \ address or it is a frame expecting address filtering or | |
140 | \ hash-hit, classification will fail and terminate and the | |
141 | \ frame will be sent to the default RDC channel p. | |
142 | \ | |
143 | : layer2-classification ( -- ) | |
144 | set-default-rdc-for-my-port | |
145 | select-channels-for-rdc-tables | |
146 | init-vlan-tbl | |
147 | init-hostinfo | |
148 | ; | |
149 | ||
150 | : classification ( -- ) | |
151 | layer2-classification | |
152 | invalidate-tcam | |
153 | ; | |
154 | ||
155 | \ Bit 26 (TCAM_DIS) of register FFLP_CFG_1 is set, so TCAM is | |
156 | \ not disabled. | |
157 | \ | |
158 | : init-fflp ( -- ) | |
159 | tcam-dis camlat=4 or err-dis or llc-snap or fflp-cfg-1! | |
160 | ; | |
161 | ||
162 | headerless |