Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error message contains variable names that do not exist in source program. #304

Closed
hanw opened this issue Feb 15, 2017 · 5 comments
Closed
Assignees

Comments

@hanw
Copy link
Contributor

hanw commented Feb 15, 2017

../extensions/p4_tests/p4_16/mdp.p4(220): warning: index1 may be uninitialized
way1.apply(index1, m, result1);
^^^^^^
../extensions/p4_tests/p4_16/mdp.p4(221): warning: index2 may be uninitialized
way2.apply(index2, m, result2);
^^^^^^
../extensions/p4_tests/p4_16/mdp.p4(222): warning: index3 may be uninitialized
way3.apply(index3, m, result3);
^^^^^^
error: tmp_5: Duplicates declaration tmp_5
error: tmp_5: Duplicates declaration tmp_5

@hanw
Copy link
Contributor Author

hanw commented Feb 15, 2017

tmp_5 is a variable name that does not exist in source program.

@mihaibudiu
Copy link
Contributor

Can you supply a p4 program to reproduce this issue?

@hanw
Copy link
Contributor Author

hanw commented Feb 15, 2017

#include <v1model.p4>

header ethernet_h{
	bit<48> dstAddr;
	bit<48> srcAddr;
	bit<16> etherType;
}

header ipv4_h {
	bit<4> version;
	bit<4> ihl;
	bit<8> diffserv;
	bit<16> totalLen;
	bit<16> identification;
	bit<3> flags;
	bit<13> fragOffset;
	bit<8> ttl;
	bit<8> protocol;
	bit<16> hdrChecksum;
	bit<32> srcAddr;
	bit<32> dstAddr;
}

header udp_h {
	bit<16> srcPort;
	bit<16> dstPort;
	bit<16> length;
	bit<16> checksum;
}

header mdp_h {
	bit<32> msgSeqNum;
	bit<64> sendTime;
}

header mdp_msg_h{
	bit<16> msgSz;
}

header mdp_sbe_h{
	bit<16> blockLen;
	bit<16> templateId;
	bit<16> schemaId;
	bit<16> version;
}

header event_meta_h{
	bit<16> group_size;
}

header refresh_book_h {
	bit<64> transactionTime;
	bit<16> matchEventIndicator;
	bit<16> blockLen;
	bit<16> numEntries;
}

header refresh_book_group_h {
	bit<64> mdEntryPx;
	bit<32> mdEntrySz;
	bit<32> securityId;
	bit<32> rptReq;
	bit<32> numOrders;
	bit<8> mdPriceLvl;
	bit<8> mdUpdateAction;
	bit<8> mdEntryType;
	bit<40> padding;
}

struct Parsed_packet {
	ethernet_h ethernet;
	ipv4_h ipv4;
	udp_h udp;
	mdp_h mdp;
	mdp_msg_h mdp_msg;
	mdp_sbe_h mdp_sbe;
	refresh_book_h refresh_book;
	refresh_book_group_h[10] refresh_group;
}

struct Metadata {
	event_meta_h event;
    bit<32> result;
    bit<32> latency_digest;
}

enum op_num {
    INSTRUCTION_1,
    INSTRUCTION_2,
    INSTRUCTION_3,
    INSTRUCTION_4
}

const op_num PLT_BF_OP = op_num.INSTRUCTION_1;
typedef bit<32> StateType;

extern StatefulALU<STATE_TYPE> {
    // Constructor: Takes register size and initial value as well as the
    //              default/reset values of the parameters.
    //              All arguments but the register size are optional and
    //              default to zero.
    StatefulALU(bit<32> stateSize, STATE_TYPE stateInitialValue,
                bit<32> p1, bit<32> p2, bit<32> p3, bit<32> p4);

    STATE_TYPE get_state( in bit<32> index );
    void set_state( in bit<32> index, in STATE_TYPE new_value );

    // Runtime (control plane) modifiable parameters.  Default value is
    // provided by the constructor, control plane will have set, reset, and get
    // functions.
    bit<32> getParam1();
    bit<32> getParam2();
    bit<32> getParam3();
    bit<32> getParam4();

    abstract bit<32> execute_instr( in op_num op, in bit<32> index, in bit<32> phv1, in bit<32> phv2 );
}


parser myparser(packet_in pi, out Parsed_packet po, inout Metadata m, inout standard_metadata_t std) {
	state start {
		pi.extract(po.ethernet);
		transition select(po.ethernet.etherType) {
			0x800: parse_ipv4;
		}
	}

	state parse_ipv4 {
		pi.extract(po.ipv4);
		transition select(po.ipv4.protocol) {
			0x11: parse_udp;
		}
	}

	state parse_udp {
		pi.extract(po.udp);
		transition select(po.udp.dstPort) {
			15311: parse_mdp;
			14311: parse_mdp;
		}
	}

	state parse_mdp {
		pi.extract(po.mdp);
		transition parse_mdp_msg;
	}

	state parse_mdp_msg {
		pi.extract(po.mdp_msg);
		transition parse_mdp_sbe;
	}

	state parse_mdp_sbe {
		pi.extract(po.mdp_sbe);
		transition parse_mdp_refresh_book;
	}

	state parse_mdp_refresh_book {
		pi.extract(po.refresh_book);
		m.event.group_size = po.refresh_book.numEntries;
		transition select(m.event.group_size) {
			0: accept;
			default: parse_mdp_refresh_group;
		}
	}

	state parse_mdp_refresh_group {
		pi.extract(po.refresh_group.next);
		m.event.group_size = m.event.group_size - 1;
		transition select(m.event.group_size) {
			0: accept;
			default: parse_mdp_refresh_group;
		}
	}
}

control _verify(in Parsed_packet h, inout Metadata m) {
	apply{}
}

control PLT_bloom_filter_way_ctrl(in bit<32> index, in Metadata metadata, out bit<32> result) {

    StatefulALU<StateType>(256*1024, 0, 0, 0, 0, 0) PLT_bloom_filter_way = {
        bit<32> execute_instr( in op_num op, in bit<32> index, in bit<32> digest, in bit<32> not_used ) {
            if (op == PLT_BF_OP) {
                StateType digest_in_state = this.get_state( index );
                this.set_state( index, (StateType)digest );

                bit<32> ret = 0;
                if (digest_in_state == (StateType)digest)
                    ret  = 1;
                if (digest_in_state == 0)
                    ret = ret | 2;
                return ret;
            }
        }
    };

    apply {
        result = PLT_bloom_filter_way.execute_instr( PLT_BF_OP, index, metadata.latency_digest, 0 );
    }
}

control ingress(inout Parsed_packet h,
				inout Metadata m,
				inout standard_metadata_t std) {

    PLT_bloom_filter_way_ctrl() way1;
    PLT_bloom_filter_way_ctrl() way2;
    PLT_bloom_filter_way_ctrl() way3;

	apply{
        bit<32> index1;
        bit<32> index2;
        bit<32> index3;
        bit<32> result1;
        bit<32> result2;
        bit<32> result3;
        way1.apply(index1, m, result1);
        way2.apply(index2, m, result2);
        way3.apply(index3, m, result3);
        m.result = result1 | result2 | result3;
	}
}

control egress(inout Parsed_packet h, inout Metadata m, inout standard_metadata_t std) {
	apply{}
}

control compute(inout Parsed_packet h, inout Metadata m) {
	apply{}
}

control deparser(packet_out b, in Parsed_packet h) {
	apply{}
}

V1Switch(myparser(),
		 _verify(),
		 ingress(),
		 egress(),
		 compute(),
		 deparser()) main;

@hanw
Copy link
Contributor Author

hanw commented Feb 15, 2017

Sorry, it is a rather long example.

ChrisDodd pushed a commit that referenced this issue Feb 16, 2017
* Fixed bugs in EBPF back-end; made the 'builder' argument into a field

* cpplint fix

* Removed useless decl

* Support for ebpf control-plane: .h file

* Deleted one line by mistake

* Support for functions; control-plane table initialization

* cpplint fixes

* Bug-fixes in ebpf back-end

* Two bugfixes

* Support for enum types in ebpf

* additional support for enum types

* Fix for issue 304

* Fix for issue #306; cpplint fixes
@sethfowler
Copy link
Contributor

A fix for this issue was landed; closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants