Skip to content

Port ethernet to EMAC #4918

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

Closed
wants to merge 13 commits into from
Closed

Port ethernet to EMAC #4918

wants to merge 13 commits into from

Conversation

KariHaapalehto
Copy link
Contributor

@KariHaapalehto KariHaapalehto commented Aug 16, 2017

Updating EMAC to enable multiple interfaces
Untangling networking classes, making the abstractions a bit clearer to follow, etc
General refactoring
Removal of DEVICE_EMAC flag and introducing DEVICE_ETH and DEVICE_WIFI

Status

IN DEVELOPMENT

Updating EMAC to enable multiple interfaces
Untangling networking classes, making the abstractions a bit clearer to follow, etc
General refactoring
Removal of DEVICE_EMAC flag and introducing DEVICE_ETH and DEVICE_WIFI
Remove lwip depencies
@0xc0170
Copy link
Contributor

0xc0170 commented Aug 17, 2017

cc @bulislaw @geky @kjbracey-arm @hasnainvirk

ipstack_lwip.c renamed as mbed_ipstack.c

#ifdef __cplusplus
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file compile without LWIP?

@geky
Copy link
Contributor

geky commented Aug 18, 2017

@KariHaapalehto, @bulislaw
I think I'm a bit confused. Is this pr related to #4079?

@KariHaapalehto
Copy link
Contributor Author

@geky , yes this is related to #4079, more precisely ONME-3145

mbed_ipstac.c renamed back to ipstack_lwip.c and
moved to back \FEATURE_LWIP\lwip-interface
@theotherjimmy theotherjimmy changed the title Porting ethernet to EMAC Port ethernet to EMAC Aug 21, 2017
Copy link
Contributor

@geky geky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, although this should really be reviewed by @bulislaw on our side

doxyfile_options Outdated
@@ -2061,7 +2061,7 @@ PREDEFINED = DOXYGEN_ONLY \
DEVICE_ANALOGOUT \
DEVICE_CAN \
DEVICE_ETHERNET \
DEVICE_EMAC \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to keep DEVICE_EMAC around for backwards compatibility until all devices are ported over to DEVICE_ETH?

strncpy(_gateway, gateway ? gateway : "", sizeof(_gateway));
_gateway[sizeof(_gateway) - 1] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these removed? strncpy doesn't garuntee a null-terminator:
http://www.cplusplus.com/reference/cstring/strncpy/

return mbed_lwip_bringup_2(_dhcp, false,
nsapi_error_t err;
if (_stack.emac == NULL)
return NSAPI_ERROR_UNSUPPORTED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: style should have brackets for all if statements:

if (_stack.emac == NULL) {
    return NSAPI_ERROR_UNSUPPORTED;
}

mbed_ipstack_init();
err = mbed_ipstack_add_netif(_stack.emac, true);
if (err != NSAPI_ERROR_OK)
return err;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: brackets on if statements

*
* @return NSAPI_ERROR_OK on success, or error code
*/
void mbed_ipstack_init(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation doesn't seem to match return type, should this return nsapi_error_t?

* @param default_if true if the interface should be treated as the default one
* @return NSAPI_ERROR_OK on success, or error code
*/
nsapi_error_t mbed_ipstack_add_netif(emac_interface_t *emac, bool default_if);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "add_netif" still? netif is the lwip term, maybe "add_interface"?

hal/emac_api.h Outdated
* @param emac Emac interface
* @param address An multicast group IPv4 address
*/
typedef void (*emac_add_multicast_group)(emac_interface_t *emac, uint8_t *address);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this taking in a string representation of an IP address or a byte representation? Should it actually be taking in the nsapi_addr_t struct?

@SeppoTakalo SeppoTakalo self-requested a review August 23, 2017 07:19
@KariHaapalehto KariHaapalehto changed the base branch from master to feature-emac August 23, 2017 07:38
@adbridge adbridge requested a review from bulislaw August 24, 2017 11:28
… at K64F

Change "uint8_t *addr" to "uint8_t addr[ETH_HWADDR_LEN]" at the emac_api.h
Correct reset at emac_lwip.c
@KariHaapalehto
Copy link
Contributor Author

KariHaapalehto commented Aug 25, 2017

Changes has been compiled with gcc_arm compiler targeting for k64f with following configurations:
configs/eth_v4.json
configs/eth_v6.json
configs/wifi_esp8266_v4.json
configs/mesh_6lowpan.json
configs/mesh_6lowpan_subg.json
configs/mesh_thread.json

sys_sem_* replaced with osSemaphore*
so that \arch\sys_arch.h can be removed from emac_api.h
@theotherjimmy
Copy link
Contributor

@KariHaapalehto It looks like you broke doxygen. Could you fix that error (it's in travis)?

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 31, 2017

.\mbed-os\features\netsocket\mbed_ipstack.c:8:22: fatal error: ns_trace.h: No such file or directory uvisor failure,please fix

@hasnainvirk
Copy link
Contributor

@KariHaapalehto A general comment, I think you should squash one-liners into previous commits. Maybe its worth a try to actually go through your commits and squash them together if necessary.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2017

Please look at CI failures (both uvisor and jenkins CI report similar failures with includes not found)

Move emac_interface_t from emac_api.h to mbed_ipstack_lwip.h
and rename it to mbed_ipstack_interface
emac_interface_ops_t, mbed_ipstack_interface_t and _hw added to
EthernetInterface.h and _stack removed.
ipstack_lwip.c renamed as mbed_ipstack_lwip.c
@kjbracey
Copy link
Contributor

Work picked up in #5202 - I think this can be closed?

kjbracey added a commit to kjbracey/mbed-os that referenced this pull request Sep 26, 2017
Work picked up by Kari Haapalehto in
ARMmbed#4918, from Bartek Szatkowsi's
branch at ARMmbed#4079, commit 8c28917.

Bartek's summary:

* Porting ethernet to EMAC
* Updating EMAC to enable multiple interfaces
* Untangling networking classes, making the abstractions a bit clearer to follow, etc
* General refactoring
* Removal of DEVICE_EMAC flag and introducing DEVICE_ETH and DEVICE_WIFI

Revisions since initial branch:

* Refactor k64f_emac
* Remove lwip depencies
* Correct doxygen warnings
* Add weak definitions for mbed_ipstack.h functions.
* Remove emac_interface_t - drivers register with emac_interface_ops_t and
  void *, and get an mbed_ipstack_interface_t to pass to stack.
* Reinstate use of EthInterface abstraction
* ipstack_lwip.c renamed as mbed_ipstack_lwip.c
* Correct and clarify HW address EMAC ops
* Restore MBED_MAC_ADDR implementation
* Integrate PPP support with mbed_ipstack_lwip.cpp
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 26, 2017

I'll close this, please reopen if should not be.

@0xc0170 0xc0170 closed this Sep 26, 2017
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

Successfully merging this pull request may close these issues.

6 participants