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

BSD Sockets API: Offloading Support #4821

Merged
merged 3 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
driver: wifi: simplelink: Register socket offload operations.
If the SimpleLink WiFi driver is configured, and socket offload
enabled, this revectors the Zephyr BSD socket APIs to the SimpleLink
WiFi host driver BSD socket APIs, providing a
direct offload of the TCP/IP stack to the CC3220SF network
coprocessor.

Fixes #3706

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
  • Loading branch information
Gil Pitney committed Aug 20, 2018
commit b75b0ea76ce13ee718dd0da6b97dd47fdcb99e41
1 change: 1 addition & 0 deletions drivers/wifi/simplelink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ if(CONFIG_WIFI_SIMPLELINK)
simplelink.c
)
endif()
zephyr_sources_ifdef(CONFIG_NET_SOCKETS_OFFLOAD simplelink_sockets.c)
48 changes: 34 additions & 14 deletions drivers/wifi/simplelink/simplelink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
#include <net/net_if.h>
#include <net/wifi_mgmt.h>
#include <net/net_offload.h>
#ifdef CONFIG_NET_SOCKETS_OFFLOAD
#include <net/socket_offload.h>
#endif

#include <ti/drivers/net/wifi/wlan.h>
#include "simplelink_support.h"
#include "simplelink_sockets.h"

#define SCAN_RETRY_DELAY 2000 /* ms */

Expand Down Expand Up @@ -73,19 +77,6 @@ static void simplelink_wifi_cb(u32_t event, struct sl_connect_state *conn)
}
}

/* TBD: Only here to link/test WiFi mgmnt part */
static struct net_offload simplelink_offload = {
.get = NULL,
.bind = NULL,
.listen = NULL,
.connect = NULL,
.accept = NULL,
.send = NULL,
.sendto = NULL,
.recv = NULL,
.put = NULL,
};

static void simplelink_scan_work_handler(struct k_work *work)
{
if (simplelink_data.num_results_or_err > 0) {
Expand Down Expand Up @@ -183,6 +174,30 @@ static int simplelink_mgmt_disconnect(struct device *dev)
return ret ? -EIO : ret;
}

static int simplelink_dummy_get(sa_family_t family,
enum net_sock_type type,
enum net_ip_protocol ip_proto,
struct net_context **context)
{

SYS_LOG_ERR("NET_SOCKET_OFFLOAD must be configured for this driver");

return -1;
}

/* Placeholders, until Zepyr IP stack updated to handle a NULL net_offload */
static struct net_offload simplelink_offload = {
.get = simplelink_dummy_get,
.bind = NULL,
.listen = NULL,
.connect = NULL,
.accept = NULL,
.send = NULL,
.sendto = NULL,
.recv = NULL,
.put = NULL,
};

static void simplelink_iface_init(struct net_if *iface)
{
SYS_LOG_DBG("MAC Address %02X:%02X:%02X:%02X:%02X:%02X",
Expand All @@ -195,7 +210,7 @@ static void simplelink_iface_init(struct net_if *iface)
sizeof(simplelink_data.mac),
NET_LINK_ETHERNET);

/* TBD: Pending support for socket offload: */
/* Direct socket offload used instead of net offload for this driver */
iface->if_dev->offload = &simplelink_offload;

simplelink_data.iface = iface;
Expand Down Expand Up @@ -228,6 +243,11 @@ static int simplelink_init(struct device *dev)
k_delayed_work_init(&simplelink_data.work,
simplelink_scan_work_handler);

#ifdef CONFIG_NET_SOCKETS_OFFLOAD
/* Direct socket offload: */
socket_offload_register(&simplelink_ops);
#endif

SYS_LOG_DBG("SimpleLink driver Initialized");

return 0;
Expand Down
Loading