1 /**********************************************************
2 * file: fdb.h
3 * purpose: netcp configurations routines
4 **************************************************************
5 * FILE: fdb.c
6 *
7 * DESCRIPTION: linux bridge forwarding data base processing for
8 * user space offload
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ****************************************************************************/
42 #include "stdlib.h"
43 #include "stdio.h"
44 #include "netapi.h"
45 //#include "fdb.h"
47 #define __u8 unsigned char
48 #define __u32 unsigned int
49 #define FDBMAX 128
50 #define PFDBMAX 8
51 #define OFFMAX 32
52 #define THRESH_OFF 50 //aging timer threshold: don't bother offloading entries < THRESH_OFF
54 #define MAX_INTERFACES 2
55 #define MAX_DSCP_ENTRIES 64
56 #define MAX_PBIT_ENTRIES 8
58 #define ntBridge_INIT_CONFIG_FLOW_BASE "flowBase"
59 #define ntBridge_INIT_CONFIG_QUEUE_BASE "queueBase"
60 #define ntBridge_INIT_CONFIG_VLAN_ID "vlanId"
61 #define ntBridge_INIT_CONFIG_INGRESS_DEF_PRI "ingressDefPri"
62 #define ntBridge_INIT_CONFIG_PORT "port"
63 #define ntBridge_INIT_CONFIG_DSCP_MAP_DEFAULT "dscp_map_default"
64 #define ntBridge_INIT_CONFIG_PBIT_MAP_DEFAULT "pbit_map_default"
66 //#define ntBridge_INIT_CONFIG_DSCP_MAP "dscpMap"
67 //#define ntBridge_INIT_CONFIG_PBIT_MAP "pbitMap"
68 #define ntBridge_INIT_CONFIG_QOS_MODE "mode"
71 typedef struct{
72 char flowBase[512];
73 char queueBase[512];
74 char vlanId[512];
75 char ingressDefPri[512];
76 char port[512];
77 char dscpMapQDefault[512];
78 char dscpMapFDefault[512];
79 char dscpMapQ[64][512];
80 char dscpMapF[64][512];
81 char pbitMapQDefault[512];
82 char pbitMapFDefault[512];
83 char pbitMapQ[8][512];
84 char pbitMapF[8][512];
85 char ctrlBitMap[512];
86 } ntBridgeCfgFile_T;
89 typedef struct{
90 char mac[32][512];
91 char switch_port[32][512];
92 } ntBridgeAleCfgFile_T;
94 typedef struct {
95 unsigned char mac[32][6];
96 uint8_t switch_port[32];
97 } ntBridgeAleCfg_T;
99 //the bridge fdb entry
100 typedef struct our_fdb_entry
101 {
102 uint8_t mac_addr[6];
103 uint8_t switch_port;
104 uint8_t is_local;
105 uint32_t ageing_timer_value; //jiffies
106 uint32_t unused;
107 } FDB_ENTRY_T;
109 //our offload db
110 typedef struct offload_db_t
111 {
112 __u8 mac_addr[6];
113 __u8 switch_port; //
114 __u8 ifno; //
115 __u32 spare0;
116 __u32 flags;
117 #define OUR_FSB_INUSE 0x80000000
118 #define OUR_FSB_PERM 0x40000000
119 #define OUR_FSB_LEARN 0x20000000
120 #define OUR_FSB_SKIP 0x00000001
121 } OFFLOAD_DB_T;