From f4c1856026c0edcc1e2285cf6ae773057bee51cd Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Thu, 22 Sep 2016 23:55:33 +0300 Subject: trafgen: l2: Add support for IEEE 802.3X PAUSE header Add EEE802.3X Ethernet MAC Control PAUSE frame proto header with two fields - opcode & time. By default Ethernet header is pushed on header init. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- trafgen_l2.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'trafgen_l2.c') diff --git a/trafgen_l2.c b/trafgen_l2.c index 866559c..8d2d285 100644 --- a/trafgen_l2.c +++ b/trafgen_l2.c @@ -30,6 +30,8 @@ static uint16_t pid_to_eth(enum proto_id pid) return ETH_P_MPLS_UC; case PROTO_VLAN: return ETH_P_8021Q; + case PROTO_PAUSE: + return ETH_P_PAUSE; default: bug(); } @@ -54,6 +56,30 @@ static const struct proto_ops eth_proto_ops = { .set_next_proto = eth_set_next_proto, }; +static struct proto_field pause_fields[] = { + { .id = PAUSE_OPCODE, .len = 2, .offset = 0 }, + { .id = PAUSE_TIME, .len = 2, .offset = 2 }, +}; + +static void pause_header_init(struct proto_hdr *hdr) +{ + uint8_t eth_dst[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x01 }; + + struct proto_hdr *lower; + + lower = proto_lower_default_add(hdr, PROTO_ETH); + proto_field_set_default_bytes(lower, ETH_DST_ADDR, eth_dst); + + proto_header_fields_add(hdr, pause_fields, array_size(pause_fields)); + proto_field_set_default_be16(hdr, PAUSE_OPCODE, 0x1); +} + +static struct proto_ops pause_proto_ops = { + .id = PROTO_PAUSE, + .layer = PROTO_L2, + .header_init = pause_header_init, +}; + static struct proto_field vlan_fields[] = { /* TPID overlaps with Ethernet header and points to ether type */ { .id = VLAN_TPID, .len = 2, .offset = -2 }, @@ -167,6 +193,7 @@ static const struct proto_ops mpls_proto_ops = { void protos_l2_init(void) { proto_ops_register(ð_proto_ops); + proto_ops_register(&pause_proto_ops); proto_ops_register(&vlan_proto_ops); proto_ops_register(&arp_proto_ops); proto_ops_register(&mpls_proto_ops); -- cgit v1.2.3-54-g00ecf