xcore / sc_ethernet

10/100 MII Ethernet MAC for XMOS microcontrollers

Home Page:http://xcore.github.com/sc_ethernet/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getmac.h/xc oddities

interactive-matter opened this issue · comments

While trying to integrate the source I found an interesting contradiction btw. getmac.h:

void ethernet_getmac_otp_indexed(port otp_data, out port otp_addr, port otp_ctrl, int macaddr[], unsigned index);
void ethernet_getmac_otp_count(port otp_data, out port otp_addr, port otp_ctrl, int macaddr[][2], unsigned count);
void ethernet_getmac_otp(port otp_data, out port otp_addr, port otp_ctrl, char macaddr[]);

and the getmac.xc:

void ethernet_getmac_otp_indexed(port otp_data, out port otp_addr, port otp_ctrl, char macaddr[], unsigned index)
void ethernet_getmac_otp_count(port otp_data, out port otp_addr, port otp_ctrl, int macaddr[][2], unsigned count)
void ethernet_getmac_otp(port otp_data, out port otp_addr, port otp_ctrl, char macaddr[])

In the header file macaddr is always int, in the xc file always char. Interestingly enough the compiler has no problem with that - but using a consistent format would make it easier to understand (e.g. stopping me to open issues)

correction: the compiler DOES not like it:

Creating app_ledtile.xe
.././../../sc_ethernet/module_ethernet/src/server/getmac.xc: Error: Type of symbol ethernet_getmac_otp_indexed has mismatch with previous definition:
.././../../sc_ethernet/module_ethernet/src/server/getmac.xc: Error: found: void ethernet_getmac_otp_indexed( port, out port, port, unsigned char[], unsigned int )
.././src/ethernet/localServer/retrieveMAC/get_mac_addr.xc: Error: previous: void ethernet_getmac_otp_indexed( port, out port, port, signed int[], unsigned int )

The address is compared inside the code using a word aligned compare, so it passes data back word aligned. that is the reason for the int[] rather than the char[]. I think that the char[] in the XC file is a mistake.

will fork, repair & pull request ;)
see comment abt. compiler error

thanks.

Whoops. See Dave's reply - it sounds like the correct type is array of ints.

its possible that the API does a byte copy from the word aligned entry to the char aligned one.

this OTP get mac thing was originally going to support layer-3 type routers where there are multiple MAC addresses for a single board. since we have abandoned that for the time being, there is only a need for a single MAC address for any board including ones with multiple ports. hence this indexed and count getmac stuff isn't really that important.

whoopsala, over my head ;)

perhaps you have seen the changes in my pull request - they seem to solve the issues from the compiler point of view (which is neccessarily the first step to fix it from a functional point of view). I will test it presumably next week (still in the middle of sc_ethernet migration for ap_led_tile).

Are there any automated test which could be used to verify the fix?

I'm not sure that there is, to test the multiple MAC address part. But the getting a single MAC address just gets entry zero, so if any code at all successfully returns a MAC address without causing an alignment exception, then you can be happy that all is ok.

Will close this issue after successfully testing it next week (lil' bit too short on time)

Hi Marcus,

I've had to revert to before your commit. It causes our AVB reference design to error on compile and I haven't time to implement the necessary fixes in all the AVB apps at the moment. Can you implement a fix in your LED repo in the meantime?

Hi Andy,

No problem. I will keep it in my fork. And try to keep my fork as updated as possible. I will reopen the issue so that we have a reminder. Is that OK?
Then we can see later how can get it into the upstream. I think it should be there.

Marcus

This mail may contain unwanted typos

Am 14.10.2011 um 19:20 schrieb Andy Lucas reply@reply.github.com:

Hi Marcus,

I've had to revert to before your commit. It causes our AVB reference design to error on compile and I haven't time to implement the necessary fixes in all the AVB apps at the moment. Can you implement a fix in your LED repo in the meantime?

Reply to this email directly or view it on GitHub:
#10 (comment)

Yes, great. Will revisit this in the near future.

is there any progress in applying the changes to the AVB framework?
Still want to get rid of my sc_ethernet fork ;)

Closing. Now using sc_otp for reading MAC addresses.