wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 1 | #ifndef _ADDRESS_TABLE_H |
| 2 | #define _ADDRESS_TABLE_H 1 |
| 3 | |
| 4 | /* |
| 5 | * ---------------------------------------------------------------------------- |
| 6 | * addressTable.h - this file has all the declarations of the address table |
| 7 | */ |
| 8 | |
| 9 | #define _8K_TABLE 0 |
| 10 | #define ADDRESS_TABLE_ALIGNMENT 8 |
| 11 | #define HASH_DEFAULT_MODE 14 |
| 12 | #define HASH_MODE 13 |
| 13 | #define HASH_SIZE 12 |
| 14 | #define HOP_NUMBER 12 |
| 15 | #define MAC_ADDRESS_STRING_SIZE 12 |
| 16 | #define MAC_ENTRY_SIZE sizeof(addrTblEntry) |
| 17 | #define MAX_NUMBER_OF_ADDRESSES_TO_STORE 1000 |
| 18 | #define PROMISCUOUS_MODE 0 |
| 19 | #define SKIP 1<<1 |
| 20 | #define SKIP_BIT 1 |
| 21 | #define VALID 1 |
| 22 | |
| 23 | /* |
| 24 | * ---------------------------------------------------------------------------- |
| 25 | * XXX_MIKE - potential sign-extension bugs lurk here... |
| 26 | */ |
| 27 | #define NIBBLE_SWAPPING_32_BIT(X) ( (((X) & 0xf0f0f0f0) >> 4) \ |
| 28 | | (((X) & 0x0f0f0f0f) << 4) ) |
| 29 | |
| 30 | #define NIBBLE_SWAPPING_16_BIT(X) ( (((X) & 0x0000f0f0) >> 4) \ |
| 31 | | (((X) & 0x00000f0f) << 4) ) |
| 32 | |
| 33 | #define FLIP_4_BITS(X) ( (((X) & 0x01) << 3) | (((X) & 0x002) << 1) \ |
| 34 | | (((X) & 0x04) >> 1) | (((X) & 0x008) >> 3) ) |
| 35 | |
| 36 | #define FLIP_6_BITS(X) ( (((X) & 0x01) << 5) | (((X) & 0x020) >> 5) \ |
| 37 | | (((X) & 0x02) << 3) | (((X) & 0x010) >> 3) \ |
| 38 | | (((X) & 0x04) << 1) | (((X) & 0x008) >> 1) ) |
| 39 | |
| 40 | #define FLIP_9_BITS(X) ( (((X) & 0x01) << 8) | (((X) & 0x100) >> 8) \ |
| 41 | | (((X) & 0x02) << 6) | (((X) & 0x080) >> 6) \ |
| 42 | | (((X) & 0x04) << 4) | (((X) & 0x040) >> 4) \ |
| 43 | | ((X) & 0x10) | (((X) & 0x08) << 2) | (((X) & 0x020) >> 2) ) |
| 44 | |
| 45 | /* |
| 46 | * V: value we're operating on |
| 47 | * O: offset of rightmost bit in field |
| 48 | * W: width of field to shift |
| 49 | * S: distance to shift left |
| 50 | */ |
| 51 | #define MASK( fieldWidth ) ((1 << (fieldWidth)) - 1) |
| 52 | #define leftShiftedBitfield( V,O,W,S) (((V) & (MASK(W) << (O))) << (S)) |
| 53 | #define rightShiftedBitfield(V,O,W,S) (((u32)((V) & (MASK(W) << (O)))) >> (S)) |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | * Push to main memory all cache lines associated with |
| 58 | * the specified range of virtual memory addresses |
| 59 | * |
| 60 | * A: Address of first byte in range to flush |
| 61 | * N: Number of bytes to flush |
| 62 | * Note - flush_dcache_range() does a "sync", does NOT invalidate |
| 63 | */ |
| 64 | #define DCACHE_FLUSH_N_SYNC( A, N ) flush_dcache_range( (A), ((A)+(N)) ) |
| 65 | |
| 66 | |
| 67 | |
| 68 | typedef struct addressTableEntryStruct { |
| 69 | u32 hi; |
| 70 | u32 lo; |
| 71 | } addrTblEntry; |
| 72 | |
| 73 | u32 |
| 74 | uncachedPages( u32 pages ); |
| 75 | u32 |
| 76 | hashTableFunction( u32 macH, u32 macL, u32 HashSize, u32 hash_mode ); |
| 77 | |
| 78 | unsigned int |
| 79 | initAddressTable( u32 port, u32 hashMode, u32 hashSize ); |
| 80 | |
| 81 | int |
| 82 | addAddressTableEntry( u32 port, u32 macH, u32 macL, u32 rd, u32 skip ); |
| 83 | |
| 84 | #endif /* #ifndef _ADDRESS_TABLE_H */ |