X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fpppoe%2Fpppoe.h;h=f010750f420a973fa1e1e0e9cedd04359bd95dd4;hb=eb987d3a09f669787014b1553f032219522149e1;hp=37d628eb903052fe4c11211a8e4ce2dbb2998917;hpb=62f9cdd82c52dc05cb89a742d21aba013ce526d4;p=vpp.git diff --git a/src/plugins/pppoe/pppoe.h b/src/plugins/pppoe/pppoe.h index 37d628eb903..f010750f420 100644 --- a/src/plugins/pppoe/pppoe.h +++ b/src/plugins/pppoe/pppoe.h @@ -48,8 +48,8 @@ typedef struct typedef struct { - /* Rewrite string */ - u8 *rewrite; + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); /* pppoe session_id in HOST byte order */ u16 session_id; @@ -76,7 +76,7 @@ typedef struct _(DROP, "error-drop") \ _(IP4_INPUT, "ip4-input") \ _(IP6_INPUT, "ip6-input" ) \ -_(CP_INPUT, "pppoe-tap-dispatch" ) \ +_(CP_INPUT, "pppoe-cp-dispatch" ) \ typedef enum { @@ -102,8 +102,8 @@ typedef enum /* * The size of pppoe session table */ -#define PPPOE_NUM_BUCKETS (128 * 1024) -#define PPPOE_MEMORY_SIZE (16<<20) +#define PPPOE_NUM_BUCKETS (64 * 1024) +#define PPPOE_MEMORY_SIZE (8<<20) /* *INDENT-OFF* */ /* @@ -150,10 +150,13 @@ typedef struct typedef struct { - /* For DP: vector of encap session instances, */ + /* Vector of encap session instances, */ pppoe_session_t *sessions; /* For CP: vector of CP path */ + BVT (clib_bihash) link_table; + + /* For DP: vector of DP path */ BVT (clib_bihash) session_table; /* Free vlib hw_if_indices */ @@ -163,7 +166,7 @@ typedef struct u32 *session_index_by_sw_if_index; /* used for pppoe cp path */ - u32 tap_if_index; + u32 cp_if_index; /* API message ID base */ u16 msg_id_base; @@ -177,10 +180,7 @@ typedef struct extern pppoe_main_t pppoe_main; extern vlib_node_registration_t pppoe_input_node; -extern vlib_node_registration_t pppoe_encap_node; -extern vlib_node_registration_t pppoe_tap_dispatch_node; - -u8 *format_pppoe_encap_trace (u8 * s, va_list * args); +extern vlib_node_registration_t pppoe_cp_dispatch_node; typedef struct { @@ -201,7 +201,7 @@ typedef struct { u8 is_add; u32 client_if_index; - u32 tap_if_index; + u32 cp_if_index; } vnet_pppoe_add_del_tap_args_t; always_inline u64 @@ -232,8 +232,46 @@ pppoe_make_key (u8 * mac_address, u16 session_id) return temp; } +/** + * Perform learning on one packet based on the mac table lookup result. + * */ +static_always_inline void +pppoe_learn_process (BVT (clib_bihash) * table, + u32 sw_if_index0, + pppoe_entry_key_t * key0, + pppoe_entry_key_t * cached_key, + u32 * bucket0, pppoe_entry_result_t * result0) +{ + /* Check mac table lookup result */ + if (PREDICT_TRUE (result0->fields.sw_if_index == sw_if_index0)) + { + /* + * The entry was in the table, and the sw_if_index matched, the normal case + */ + return; + } + else if (result0->fields.sw_if_index == ~0) + { + /* The entry was not in table, so add it */ + result0->fields.sw_if_index = sw_if_index0; + result0->fields.session_index = ~0; + cached_key->raw = ~0; /* invalidate the cache */ + } + else + { + /* The entry was in the table, but with the wrong sw_if_index mapping (mac move) */ + result0->fields.sw_if_index = sw_if_index0; + } + + /* Update the entry */ + BVT (clib_bihash_kv) kv; + kv.key = key0->raw; + kv.value = result0->raw; + BV (clib_bihash_add_del) (table, &kv, 1 /* is_add */ ); +} + static_always_inline void -pppoe_lookup_1 (BVT (clib_bihash) * session_table, +pppoe_lookup_1 (BVT (clib_bihash) * table, pppoe_entry_key_t * cached_key, pppoe_entry_result_t * cached_result, u8 * mac0, @@ -257,7 +295,7 @@ pppoe_lookup_1 (BVT (clib_bihash) * session_table, kv.key = key0->raw; kv.value = ~0ULL; - BV (clib_bihash_search_inline) (session_table, &kv); + BV (clib_bihash_search_inline) (table, &kv); result0->raw = kv.value; /* Update one-entry cache */ @@ -267,7 +305,7 @@ pppoe_lookup_1 (BVT (clib_bihash) * session_table, } static_always_inline void -pppoe_update_1 (BVT (clib_bihash) * session_table, +pppoe_update_1 (BVT (clib_bihash) * table, u8 * mac0, u16 session_id0, pppoe_entry_key_t * key0, @@ -281,7 +319,7 @@ pppoe_update_1 (BVT (clib_bihash) * session_table, BVT (clib_bihash_kv) kv; kv.key = key0->raw; kv.value = result0->raw; - BV (clib_bihash_add_del) (session_table, &kv, 1 /* is_add */ ); + BV (clib_bihash_add_del) (table, &kv, 1 /* is_add */ ); } #endif /* _PPPOE_H */