Skip to content

emac HAL API, WiFiInterface additions #2874

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

Merged
merged 69 commits into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b826f0e
Merge pull request #2699 from bulislaw/feature_wifi_rebase
0xc0170 Sep 14, 2016
f9f1f44
Extend and rework WiFi interface
bulislaw Sep 5, 2016
4fde794
Merge pull request #2627 from bulislaw/feature_wifi
0xc0170 Sep 15, 2016
ed0dfb4
HAL: Add Emac interface
bulislaw Sep 15, 2016
ac8c2f9
EMAC: Add emac_stack_t implementation for LWIP
bulislaw Sep 19, 2016
4a6728c
EMAC: Add LWIP adaptation layer
bulislaw Sep 20, 2016
ddd65b4
WiFi: Add IPStackInterface abstraction for IP stacks
bulislaw Sep 22, 2016
aad3e1f
WiFi: Extend WiFiInterface API and documentation
bulislaw Sep 22, 2016
8bfd108
Merge pull request #2729 from bulislaw/feature_wifi
0xc0170 Sep 23, 2016
20f5adb
Merge branch 'master' into feature_wifi
0xc0170 Sep 26, 2016
e0a48e9
K64F: add EMAC device_has
0xc0170 Sep 27, 2016
bd3a81d
lwip: add emac interrupt API
0xc0170 Sep 27, 2016
febf1a8
lwipipstack: lwip_bringup arguments update
0xc0170 Sep 28, 2016
b256b2f
network-sockets: revert API for static configuration
0xc0170 Sep 28, 2016
3d14c20
WiFiInterface: remove connect implementation
0xc0170 Sep 28, 2016
f12676d
Merge branch 'master' into feature_wifi
0xc0170 Sep 29, 2016
81932ee
lwip emac - remove non-existent header inclusion
0xc0170 Sep 29, 2016
517f050
IPStackInterface - add ip address
0xc0170 Sep 29, 2016
33d9565
WifiInterface - use Callback class for callbacks
0xc0170 Sep 29, 2016
da75298
WiFiInterface: change scope of wifi_ap_t structure
0xc0170 Sep 29, 2016
5ed97d5
nsapi: error no ssid name correction
0xc0170 Sep 29, 2016
a30aa8f
EMAC: Add LWIP adaptation layer
bulislaw Sep 20, 2016
7a3a580
WiFi: Add IPStackInterface abstraction for IP stacks
bulislaw Sep 22, 2016
26c3eef
Fixed return type for disconnect
Sep 22, 2016
05974a6
Added EMAC
Sep 22, 2016
40cd23c
Added pointer for wifi_ap_t in wifi_connect_cb_t to be able to use NULL
Sep 22, 2016
b07d602
Added missing ;
Sep 22, 2016
2ce9039
Added wifi_emac_api.cpp
Sep 22, 2016
c80641f
EMAC: Fix "#if DEVICE_EMAC " usage
bulislaw Sep 23, 2016
f122695
WiFi: Decuple IP stack bringup and IP address provisioning
bulislaw Sep 26, 2016
8af7551
Removed check since the interface is not fully up yet so we can't blo…
Sep 27, 2016
6040561
Added start_dhcp and start_static_ip
Sep 27, 2016
841c9b5
Fixed missing timeout argument for lwip_start_dhcp
Sep 27, 2016
31a1a7f
Fixed bug in packetIndication for packetInfo->rxData + use mutexes + …
Sep 27, 2016
f8ad018
Added
Sep 27, 2016
1b797bb
EthernetInterface: ctor uses connect() method
0xc0170 Sep 29, 2016
d40c19b
lwipstack: add start dhcp and static ip functions
0xc0170 Sep 29, 2016
ac8f5d1
eth arch: missing endif fix
0xc0170 Sep 29, 2016
780ec1e
eth arch: duplication of declarations removal
0xc0170 Sep 29, 2016
7c8afa9
IPStackInterface: removal of this layer
0xc0170 Sep 29, 2016
961cde3
WiFiInterface: change variables to protected
0xc0170 Sep 30, 2016
bad51a5
targets: remove emac for k64f, not supported yet
0xc0170 Sep 30, 2016
372f8e4
lwip stack: dhcp in bringup not done for emac targets
0xc0170 Sep 30, 2016
ad8b52f
EthernetInterface: revert unrelated changes
0xc0170 Sep 30, 2016
e31f198
lwip_stack: remove emac int enable/disable functions
0xc0170 Sep 30, 2016
ebe0227
NetworkInterface- fix comments for dhcp and ip methods
0xc0170 Sep 30, 2016
e7b7fec
NetworkInterface: fix start_dhcp argument type
0xc0170 Sep 30, 2016
0fe1246
WiFiInterface - remove data arguments
0xc0170 Sep 30, 2016
63f0ff1
NetworkInterface: remove dhcp and static ip methods
0xc0170 Sep 30, 2016
56a223e
emac interface - typedef should be available for non-emac targets
0xc0170 Sep 30, 2016
cca026d
WiFiInterface - revert removal of connect method
0xc0170 Sep 30, 2016
5b12539
wifi - Removed asynchronous functions
geky Sep 30, 2016
0f40c12
wifi - Moved wifi_ap_t into its own class WiFiAccessPoint
geky Sep 30, 2016
6440ffa
cellular - Matched changes to the WiFiinterface in cellular
geky Sep 30, 2016
3f66a62
UBLOX_C029: remove emac implementation
0xc0170 Oct 1, 2016
13bf0bd
Merge commit 'upstream/master~' into feature_wifi_ublox
geky Oct 2, 2016
5cd2d78
Merge remote-tracking branch 'upstream/master' into feature_wifi_ublo…
geky Oct 2, 2016
d0be573
EMAC: Fix LWIP_IPV4 and DEVICE_EMAC flag usage
bulislaw Oct 3, 2016
98eb50f
Refactor lwip_stack function names to include mbed prefix
bulislaw Oct 4, 2016
ae11b51
Split lwip initialisation and interface bringup
bulislaw Oct 4, 2016
1e7ba5f
Fix merge issues
bulislaw Oct 4, 2016
b418fce
Added function for increasing ref count.
Oct 3, 2016
8ea46ea
Fixed missing abstract connect method
Oct 4, 2016
e87f013
Fixed missing public
Oct 4, 2016
f5675cc
Increased the stack size for the lwIP thread from 1024 to 1200. Neede…
Oct 4, 2016
26eb5f1
Fixed mbed_lwip_get_netmask amd mbed_lwip_get_gateway
Oct 4, 2016
e1a4db7
Merge pull request #2 from andreaslarssonublox/feature_wifi_ublox_and…
0xc0170 Oct 4, 2016
febc341
Fix spelling error: NSAPI_SECURITY_UNSUPPORTED
bulislaw Oct 4, 2016
4f1eded
Renamed NSAPI_SECURITY_UNSUPPORTED -> NSAPI_SECURITY_UNKNOWN
geky Oct 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions features/FEATURE_LWIP/lwip-interface/EthernetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ int EthernetInterface::set_dhcp(bool dhcp)

int EthernetInterface::connect()
{
return lwip_bringup(_dhcp,
return mbed_lwip_bringup(_dhcp,
_ip_address[0] ? _ip_address : 0,
_netmask[0] ? _netmask : 0,
_gateway[0] ? _gateway : 0);
}

int EthernetInterface::disconnect()
{
return lwip_bringdown();
return mbed_lwip_bringdown();
}

const char *EthernetInterface::get_mac_address()
{
return lwip_get_mac_address();
return mbed_lwip_get_mac_address();
}

const char *EthernetInterface::get_ip_address()
{
if (lwip_get_ip_address(_ip_address, sizeof _ip_address)) {
if (mbed_lwip_get_ip_address(_ip_address, sizeof _ip_address)) {
return _ip_address;
}

Expand All @@ -68,7 +68,7 @@ const char *EthernetInterface::get_ip_address()

const char *EthernetInterface::get_netmask()
{
if (lwip_get_netmask(_netmask, sizeof _netmask)) {
if (mbed_lwip_get_netmask(_netmask, sizeof _netmask)) {
return _netmask;
}

Expand All @@ -77,7 +77,7 @@ const char *EthernetInterface::get_netmask()

const char *EthernetInterface::get_gateway()
{
if (lwip_get_gateway(_gateway, sizeof _gateway)) {
if (mbed_lwip_get_gateway(_gateway, sizeof _gateway)) {
return _gateway;
}

Expand Down
91 changes: 91 additions & 0 deletions features/FEATURE_LWIP/lwip-interface/emac_lwip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* mbed Microcontroller Library
* Copyright (c) 2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "platform.h"

#if DEVICE_EMAC

#include "emac_api.h"
#include "emac_stack_mem.h"
#include "lwip/tcpip.h"
#include "lwip/tcp.h"
#include "lwip/ip.h"
#include "netif/etharp.h"

static err_t emac_lwip_low_level_output(struct netif *netif, struct pbuf *p)
{
emac_interface_t *mac = (emac_interface_t *)netif->state;
bool ret = mac->ops.link_out(mac, (emac_stack_mem_t *)p);

return ret ? ERR_OK : ERR_IF;
}

static void emac_lwip_input(void *data, emac_stack_t *buf)
{
struct pbuf *p = (struct pbuf *)buf;
struct netif *netif = (struct netif *)data;

/* pass all packets to ethernet_input, which decides what packets it supports */
if (netif->input(p, netif) != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("Emac LWIP: IP input error\n"));

pbuf_free(p);
}
}

static void emac_lwip_state_change(void *data, bool up)
{
struct netif *netif = (struct netif *)data;

if (up) {
tcpip_callback_with_block((tcpip_callback_fn)netif_set_link_up, netif, 1);
} else {
tcpip_callback_with_block((tcpip_callback_fn)netif_set_link_down, netif, 1);
}
}

err_t emac_lwip_if_init(struct netif *netif)
{
int err = ERR_OK;
emac_interface_t *mac = (emac_interface_t *)netif->state;

mac->ops.set_link_input_cb(mac, emac_lwip_input, netif);
mac->ops.set_link_state_cb(mac, emac_lwip_state_change, netif);

netif->hwaddr_len = mac->ops.get_hwaddr_size(mac);
mac->ops.get_hwaddr(mac, netif->hwaddr);

netif->mtu = mac->ops.get_mtu_size(mac);

/* Interface capabilities */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;

mac->ops.get_ifname(mac, netif->name, 2);

#if LWIP_IPV4
netif->output = etharp_output;
#endif /* LWIP_IPV4 */

netif->linkoutput = emac_lwip_low_level_output;

if (!mac->ops.power_up(mac)) {
err = ERR_IF;
}

return err;
}

#endif /* DEVICE_EMAC */
88 changes: 88 additions & 0 deletions features/FEATURE_LWIP/lwip-interface/emac_stack_lwip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* mbed Microcontroller Library
* Copyright (c) 2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "platform.h"

#if DEVICE_EMAC

#include "emac_stack_mem.h"
#include "pbuf.h"

emac_stack_mem_t *emac_stack_mem_alloc(emac_stack_t* stack, uint32_t size, uint32_t align)
{

struct pbuf *pbuf = pbuf_alloc(PBUF_RAW, size + align, PBUF_RAM);
if (pbuf == NULL) {
return NULL;
}

if (align) {
uint32_t remainder = (uint32_t)pbuf->payload % align;
uint32_t offset = align - remainder;
if (offset >= align) {
offset = align;
}

pbuf->payload = (void*)((char*)pbuf->payload + offset);
pbuf->tot_len -= offset;
pbuf->len -= offset;
}

return (emac_stack_mem_t*)pbuf;
}

void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem)
{
pbuf_free((struct pbuf*)mem);
}

void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem)
{
return ((struct pbuf*)mem)->payload;
}

uint32_t emac_stack_mem_len(emac_stack_t* stack, emac_stack_mem_t *mem)
{
return ((struct pbuf*)mem)->len;
}

void emac_stack_mem_set_len(emac_stack_t* stack, emac_stack_mem_t *mem, uint32_t len)
{
struct pbuf *pbuf = (struct pbuf*)mem;

pbuf->len = len;
}

emac_stack_mem_t *emac_stack_mem_chain_dequeue(emac_stack_t* stack, emac_stack_mem_chain_t **chain)
{
struct pbuf **list = (struct pbuf**)chain;
struct pbuf *head = *list;
*list = (*list)->next;

return (emac_stack_mem_t *)head;
}

uint32_t emac_stack_mem_chain_len(emac_stack_t* stack, emac_stack_mem_chain_t *chain)
{
return ((struct pbuf*)chain)->tot_len;
}

void emac_stack_mem_ref(emac_stack_t* stack, emac_stack_mem_t *mem)
{
pbuf_ref((struct pbuf*)mem);
}

#endif /* DEVICE_EMAC */
6 changes: 5 additions & 1 deletion features/FEATURE_LWIP/lwip-interface/eth_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@
extern "C" {
#endif

#if DEVICE_EMAC
err_t emac_lwip_if_init(struct netif *netif);

#else /* DEVICE_EMAC */
void eth_arch_enable_interrupts(void);
void eth_arch_disable_interrupts(void);
err_t eth_arch_enetif_init(struct netif *netif);
#endif

#ifdef __cplusplus
}
#endif

#endif // #ifndef ETHARCHINTERFACE_H_

Loading