drivers: wifi: simplelink: enable IPv6 support
IPv6 support was not fully implemented in the driver and was disabled. This commit completes the implementation and enables it when configured. Signed-off-by: Vincent Wan <vwan@ti.com>
This commit is contained in:
parent
d20b1aebf9
commit
53f408afe8
3 changed files with 42 additions and 15 deletions
|
@ -24,6 +24,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
#define SCAN_RETRY_DELAY 2000 /* ms */
|
#define SCAN_RETRY_DELAY 2000 /* ms */
|
||||||
#define FC_TIMEOUT K_SECONDS(CONFIG_WIFI_SIMPLELINK_FAST_CONNECT_TIMEOUT)
|
#define FC_TIMEOUT K_SECONDS(CONFIG_WIFI_SIMPLELINK_FAST_CONNECT_TIMEOUT)
|
||||||
|
|
||||||
|
#define SIMPLELINK_IPV4 0x1
|
||||||
|
#define SIMPLELINK_IPV6 0x2
|
||||||
|
|
||||||
struct simplelink_data {
|
struct simplelink_data {
|
||||||
struct net_if *iface;
|
struct net_if *iface;
|
||||||
unsigned char mac[6];
|
unsigned char mac[6];
|
||||||
|
@ -34,6 +37,7 @@ struct simplelink_data {
|
||||||
int num_results_or_err;
|
int num_results_or_err;
|
||||||
int scan_retries;
|
int scan_retries;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
uint8_t mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct simplelink_data simplelink_data;
|
static struct simplelink_data simplelink_data;
|
||||||
|
@ -64,7 +68,18 @@ static void simplelink_wifi_cb(uint32_t event, struct sl_connect_state *conn)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLELINK_WIFI_CB_IPACQUIRED:
|
case SIMPLELINK_WIFI_CB_IPACQUIRED:
|
||||||
if (!simplelink_data.initialized) {
|
simplelink_data.mask &= ~SIMPLELINK_IPV4;
|
||||||
|
if ((simplelink_data.mask == 0) &&
|
||||||
|
(!simplelink_data.initialized)) {
|
||||||
|
simplelink_data.initialized = true;
|
||||||
|
k_sem_give(&ip_acquired);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIMPLELINK_WIFI_CB_IPV6ACQUIRED:
|
||||||
|
simplelink_data.mask &= ~SIMPLELINK_IPV6;
|
||||||
|
if ((simplelink_data.mask == 0) &&
|
||||||
|
(!simplelink_data.initialized)) {
|
||||||
simplelink_data.initialized = true;
|
simplelink_data.initialized = true;
|
||||||
k_sem_give(&ip_acquired);
|
k_sem_give(&ip_acquired);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +217,12 @@ static void simplelink_iface_init(struct net_if *iface)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
simplelink_data.iface = iface;
|
simplelink_data.iface = iface;
|
||||||
|
simplelink_data.mask = 0;
|
||||||
|
|
||||||
|
simplelink_data.mask |= IS_ENABLED(CONFIG_NET_IPV4) ?
|
||||||
|
SIMPLELINK_IPV4 : 0;
|
||||||
|
simplelink_data.mask |= IS_ENABLED(CONFIG_NET_IPV6) ?
|
||||||
|
SIMPLELINK_IPV6 : 0;
|
||||||
|
|
||||||
/* Direct socket offload used instead of net offload: */
|
/* Direct socket offload used instead of net offload: */
|
||||||
iface->if_dev->offload = &simplelink_offload;
|
iface->if_dev->offload = &simplelink_offload;
|
||||||
|
|
|
@ -70,9 +70,7 @@ static int32_t configure_simplelink(void)
|
||||||
{
|
{
|
||||||
int32_t retval = -1;
|
int32_t retval = -1;
|
||||||
int32_t mode = -1;
|
int32_t mode = -1;
|
||||||
#if !defined(CONFIG_NET_IPV6)
|
|
||||||
uint32_t if_bitmap = 0U;
|
uint32_t if_bitmap = 0U;
|
||||||
#endif
|
|
||||||
SlWlanScanParamCommand_t scan_default = { 0 };
|
SlWlanScanParamCommand_t scan_default = { 0 };
|
||||||
SlWlanRxFilterOperationCommandBuff_t rx_filterid_mask = { { 0 } };
|
SlWlanRxFilterOperationCommandBuff_t rx_filterid_mask = { { 0 } };
|
||||||
uint8_t config_opt;
|
uint8_t config_opt;
|
||||||
|
@ -172,16 +170,17 @@ static int32_t configure_simplelink(void)
|
||||||
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
|
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_IPV6)
|
||||||
#if !defined(CONFIG_NET_IPV6)
|
if_bitmap = ~0;
|
||||||
|
#else
|
||||||
/* Disable ipv6 */
|
/* Disable ipv6 */
|
||||||
if_bitmap = !(SL_NETCFG_IF_IPV6_STA_LOCAL |
|
if_bitmap = !(SL_NETCFG_IF_IPV6_STA_LOCAL |
|
||||||
SL_NETCFG_IF_IPV6_STA_GLOBAL);
|
SL_NETCFG_IF_IPV6_STA_GLOBAL);
|
||||||
|
#endif
|
||||||
retval = sl_NetCfgSet(SL_NETCFG_IF, SL_NETCFG_IF_STATE,
|
retval = sl_NetCfgSet(SL_NETCFG_IF, SL_NETCFG_IF_STATE,
|
||||||
sizeof(if_bitmap),
|
sizeof(if_bitmap),
|
||||||
(const unsigned char *)&if_bitmap);
|
(const unsigned char *)&if_bitmap);
|
||||||
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
|
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Configure scan parameters to default */
|
/* Configure scan parameters to default */
|
||||||
scan_default.ChannelsMask = CHANNEL_MASK_ALL;
|
scan_default.ChannelsMask = CHANNEL_MASK_ALL;
|
||||||
|
@ -370,7 +369,7 @@ void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *netapp_event)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (netapp_event->Id) {
|
switch (netapp_event->Id) {
|
||||||
case SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED:
|
case SL_NETAPP_EVENT_IPV4_ACQUIRED:
|
||||||
SET_STATUS_BIT(nwp.status, STATUS_BIT_IP_ACQUIRED);
|
SET_STATUS_BIT(nwp.status, STATUS_BIT_IP_ACQUIRED);
|
||||||
|
|
||||||
/* Ip Acquired Event Data */
|
/* Ip Acquired Event Data */
|
||||||
|
@ -395,7 +394,7 @@ void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *netapp_event)
|
||||||
nwp.cb(SIMPLELINK_WIFI_CB_IPACQUIRED, &sl_conn);
|
nwp.cb(SIMPLELINK_WIFI_CB_IPACQUIRED, &sl_conn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6:
|
case SL_NETAPP_EVENT_IPV6_ACQUIRED:
|
||||||
SET_STATUS_BIT(nwp.status, STATUS_BIT_IPV6_ACQUIRED);
|
SET_STATUS_BIT(nwp.status, STATUS_BIT_IPV6_ACQUIRED);
|
||||||
|
|
||||||
for (i = 0U; i < 4; i++) {
|
for (i = 0U; i < 4; i++) {
|
||||||
|
@ -404,15 +403,20 @@ void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *netapp_event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG_LEVEL >= LOG_LEVEL_INF) {
|
if (LOG_LEVEL >= LOG_LEVEL_INF) {
|
||||||
char ipv6_addr[NET_IPV6_ADDR_LEN];
|
LOG_INF("[NETAPP EVENT] IP Acquired: "
|
||||||
|
"IPv6=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
|
||||||
|
((sl_conn.ipv6_addr[0] >> 16) & 0xffff),
|
||||||
|
sl_conn.ipv6_addr[0] & 0xffff,
|
||||||
|
((sl_conn.ipv6_addr[1] >> 16) & 0xffff),
|
||||||
|
sl_conn.ipv6_addr[1] & 0xffff,
|
||||||
|
((sl_conn.ipv6_addr[2] >> 16) & 0xffff),
|
||||||
|
sl_conn.ipv6_addr[2] & 0xffff,
|
||||||
|
((sl_conn.ipv6_addr[3] >> 16) & 0xffff),
|
||||||
|
sl_conn.ipv6_addr[3] & 0xffff);
|
||||||
|
|
||||||
net_addr_ntop(AF_INET6, sl_conn.ipv6_addr,
|
|
||||||
ipv6_addr,
|
|
||||||
sizeof(ipv6_addr));
|
|
||||||
LOG_INF("[NETAPP EVENT] IP Acquired: IPv6= %s",
|
|
||||||
ipv6_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nwp.cb(SIMPLELINK_WIFI_CB_IPV6ACQUIRED, &sl_conn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED:
|
case SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED:
|
||||||
|
|
|
@ -19,7 +19,9 @@ extern "C" {
|
||||||
|
|
||||||
/* Define ID for simplelink_wifi_cb to not conflict with WLAN event IDs: */
|
/* Define ID for simplelink_wifi_cb to not conflict with WLAN event IDs: */
|
||||||
#define SIMPLELINK_WIFI_CB_IPACQUIRED \
|
#define SIMPLELINK_WIFI_CB_IPACQUIRED \
|
||||||
(SL_WLAN_EVENT_MAX + SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED)
|
(SL_WLAN_EVENT_MAX + SL_NETAPP_EVENT_IPV4_ACQUIRED)
|
||||||
|
#define SIMPLELINK_WIFI_CB_IPV6ACQUIRED \
|
||||||
|
(SL_WLAN_EVENT_MAX + SL_NETAPP_EVENT_IPV6_ACQUIRED)
|
||||||
|
|
||||||
struct sl_connect_state {
|
struct sl_connect_state {
|
||||||
uint32_t gateway_ip;
|
uint32_t gateway_ip;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue