Lines Matching +full:discard +full:- +full:rx +full:- +full:length +full:- +full:errors
5 * SPDX-License-Identifier: Apache-2.0
9 * @brief AIROC Wi-Fi driver.
121 * AIROC Wi-Fi helper functions
139 ((**result_ptr).SSID.length == ((whd_scan_result_t *)user_data)->SSID.length)) { in airoc_wifi_scan_cb_search()
140 if (strncmp(((whd_scan_result_t *)user_data)->SSID.value, (**result_ptr).SSID.value, in airoc_wifi_scan_cb_search()
141 (**result_ptr).SSID.length) == 0) { in airoc_wifi_scan_cb_search()
187 if (p_whd_result->SSID.length != 0) { in parse_scan_result()
188 p_zy_result->ssid_length = p_whd_result->SSID.length; in parse_scan_result()
189 strncpy(p_zy_result->ssid, p_whd_result->SSID.value, p_whd_result->SSID.length); in parse_scan_result()
190 p_zy_result->channel = p_whd_result->channel; in parse_scan_result()
191 p_zy_result->security = convert_whd_security_to_zephyr(p_whd_result->security); in parse_scan_result()
192 p_zy_result->rssi = (int8_t)p_whd_result->signal_strength; in parse_scan_result()
193 p_zy_result->mac_length = 6; in parse_scan_result()
194 memcpy(p_zy_result->mac, &p_whd_result->BSSID, 6); in parse_scan_result()
205 data->scan_rslt_cb(data->iface, 0, NULL); in scan_callback()
206 data->scan_rslt_cb = NULL; in scan_callback()
217 data->scan_rslt_cb(data->iface, 0, &zephyr_scan_result); in scan_callback()
233 if ((buf == NULL) || (buf->size < size)) { in airoc_wifi_host_buffer_get()
255 return (uint8_t *)buf->data; in airoc_wifi_buffer_get_current_piece_data_pointer()
263 return (uint16_t)buf->size; in airoc_wifi_buffer_get_current_piece_size()
271 buf->size = size; in airoc_wifi_buffer_set_size()
282 (*buf)->len = (*buf)->size; in airoc_wifi_buffer_add_remove_at_front()
283 (*buf)->data = net_buf_pull(*buf, add_remove_amount); in airoc_wifi_buffer_add_remove_at_front()
285 (*buf)->data = net_buf_push(*buf, -add_remove_amount); in airoc_wifi_buffer_add_remove_at_front()
286 (*buf)->len = (*buf)->size; in airoc_wifi_buffer_add_remove_at_front()
293 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_send()
299 if (net_pkt_read(pkt, data->frame_buf, pkt_len) < 0) { in airoc_mgmt_send()
301 return -EIO; in airoc_mgmt_send()
304 /* Allocate Network Buffer from pool with Packet Length + Data Header */ in airoc_mgmt_send()
308 return -EIO; in airoc_mgmt_send()
315 (void)memcpy(buf->data, data->frame_buf, pkt_len); in airoc_mgmt_send()
322 data->stats.errors.tx++; in airoc_mgmt_send()
324 return -EIO; in airoc_mgmt_send()
328 data->stats.bytes.sent += pkt_len; in airoc_mgmt_send()
329 data->stats.pkts.tx++; in airoc_mgmt_send()
338 uint8_t *data = whd_buffer_get_current_piece_data_pointer(interface->whd_driver, buffer); in airoc_wifi_network_process_ethernet_data()
339 uint32_t len = whd_buffer_get_current_piece_size(interface->whd_driver, buffer); in airoc_wifi_network_process_ethernet_data()
366 airoc_wifi_data.stats.pkts.rx++; in airoc_wifi_network_process_ethernet_data()
372 airoc_wifi_data.stats.errors.rx++; in airoc_wifi_network_process_ethernet_data()
394 whd_mac_addr.octet[i] = config->filter.mac_address.addr[i]; in airoc_set_config()
396 if (config->filter.set) { in airoc_set_config()
405 return -ENOTSUP; in airoc_set_config()
444 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_init()
447 eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI; in airoc_mgmt_init()
448 data->iface = iface; in airoc_mgmt_init()
452 if (whd_wifi_get_mac_address(airoc_sta_if, &airoc_sta_if->mac_addr) != WHD_SUCCESS) { in airoc_mgmt_init()
455 (void)memcpy(&data->mac_addr, &airoc_sta_if->mac_addr, in airoc_mgmt_init()
456 sizeof(airoc_sta_if->mac_addr)); in airoc_mgmt_init()
460 if (net_if_set_link_addr(iface, data->mac_addr, 6, NET_LINK_ETHERNET)) { in airoc_mgmt_init()
471 net_if_carrier_on(data->iface); in airoc_mgmt_init()
477 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_scan()
479 if (data->scan_rslt_cb != NULL) { in airoc_mgmt_scan()
481 return -EINPROGRESS; in airoc_mgmt_scan()
484 if (k_sem_take(&data->sema_common, K_MSEC(AIROC_WIFI_WAIT_SEMA_MS)) != 0) { in airoc_mgmt_scan()
485 return -EAGAIN; in airoc_mgmt_scan()
488 data->scan_rslt_cb = cb; in airoc_mgmt_scan()
491 if (whd_wifi_scan(airoc_sta_if, params->scan_type, WHD_BSS_TYPE_ANY, &(data->ssid), NULL, in airoc_mgmt_scan()
492 NULL, NULL, scan_callback, &(data->scan_result), data) != WHD_SUCCESS) { in airoc_mgmt_scan()
494 k_sem_give(&data->sema_common); in airoc_mgmt_scan()
495 return -EAGAIN; in airoc_mgmt_scan()
498 k_sem_give(&data->sema_common); in airoc_mgmt_scan()
504 struct airoc_wifi_data *data = (struct airoc_wifi_data *)dev->data; in airoc_mgmt_connect()
508 if (k_sem_take(&data->sema_common, K_MSEC(AIROC_WIFI_WAIT_SEMA_MS)) != 0) { in airoc_mgmt_connect()
509 return -EAGAIN; in airoc_mgmt_connect()
512 if (data->is_sta_connected) { in airoc_mgmt_connect()
514 ret = -EALREADY; in airoc_mgmt_connect()
518 if (data->is_ap_up) { in airoc_mgmt_connect()
520 ret = -EBUSY; in airoc_mgmt_connect()
524 ssid.length = params->ssid_length; in airoc_mgmt_connect()
525 memcpy(ssid.value, params->ssid, params->ssid_length); in airoc_mgmt_connect()
530 usr_result.SSID.length = ssid.length; in airoc_mgmt_connect()
531 memcpy(usr_result.SSID.value, ssid.value, ssid.length); in airoc_mgmt_connect()
537 ret = -EAGAIN; in airoc_mgmt_connect()
543 ret = -EAGAIN; in airoc_mgmt_connect()
548 ret = -EAGAIN; in airoc_mgmt_connect()
554 if (whd_wifi_join(airoc_sta_if, &usr_result.SSID, usr_result.security, params->psk, in airoc_mgmt_connect()
555 params->psk_length) != WHD_SUCCESS) { in airoc_mgmt_connect()
558 ret = -EAGAIN; in airoc_mgmt_connect()
564 net_if_dormant_on(data->iface); in airoc_mgmt_connect()
566 net_if_dormant_off(data->iface); in airoc_mgmt_connect()
567 data->is_sta_connected = true; in airoc_mgmt_connect()
569 net_dhcpv4_restart(data->iface); in airoc_mgmt_connect()
573 wifi_mgmt_raise_connect_result_event(data->iface, ret); in airoc_mgmt_connect()
574 k_sem_give(&data->sema_common); in airoc_mgmt_connect()
581 struct airoc_wifi_data *data = (struct airoc_wifi_data *)dev->data; in airoc_mgmt_disconnect()
583 if (k_sem_take(&data->sema_common, K_MSEC(AIROC_WIFI_WAIT_SEMA_MS)) != 0) { in airoc_mgmt_disconnect()
584 return -EAGAIN; in airoc_mgmt_disconnect()
588 k_sem_give(&data->sema_common); in airoc_mgmt_disconnect()
589 ret = -EAGAIN; in airoc_mgmt_disconnect()
591 data->is_sta_connected = false; in airoc_mgmt_disconnect()
592 net_if_dormant_on(data->iface); in airoc_mgmt_disconnect()
595 wifi_mgmt_raise_disconnect_result_event(data->iface, ret); in airoc_mgmt_disconnect()
596 k_sem_give(&data->sema_common); in airoc_mgmt_disconnect()
607 .event_type = event_header->event_type in airoc_wifi_ap_link_events_handler()
617 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_ap_enable()
623 if (k_sem_take(&data->sema_common, K_MSEC(AIROC_WIFI_WAIT_SEMA_MS)) != 0) { in airoc_mgmt_ap_enable()
624 return -EAGAIN; in airoc_mgmt_ap_enable()
627 if (data->is_sta_connected) { in airoc_mgmt_ap_enable()
629 ret = -EBUSY; in airoc_mgmt_ap_enable()
633 if (data->is_ap_up) { in airoc_mgmt_ap_enable()
634 LOG_ERR("Already AP is on - first disable"); in airoc_mgmt_ap_enable()
635 ret = -EAGAIN; in airoc_mgmt_ap_enable()
639 if (!data->second_interface_init) { in airoc_mgmt_ap_enable()
640 if (whd_add_secondary_interface(data->whd_drv, NULL, &airoc_ap_if) != in airoc_mgmt_ap_enable()
643 ret = -EAGAIN; in airoc_mgmt_ap_enable()
646 data->second_interface_init = true; in airoc_mgmt_ap_enable()
649 ssid.length = params->ssid_length; in airoc_mgmt_ap_enable()
650 memcpy(ssid.value, params->ssid, ssid.length); in airoc_mgmt_ap_enable()
653 * - 2G channels from 1 to 11, in airoc_mgmt_ap_enable()
654 * - 5G channels from 36 to 165 in airoc_mgmt_ap_enable()
656 if (((params->channel > 0) && (params->channel < 12)) || in airoc_mgmt_ap_enable()
657 ((params->channel > 35) && (params->channel < 166))) { in airoc_mgmt_ap_enable()
658 channel = params->channel; in airoc_mgmt_ap_enable()
661 LOG_WRN("Discard of setting unsupported channel: %u (will set 1)", in airoc_mgmt_ap_enable()
662 params->channel); in airoc_mgmt_ap_enable()
665 switch (params->security) { in airoc_mgmt_ap_enable()
679 if (whd_wifi_init_ap(airoc_ap_if, &ssid, security, (const uint8_t *)params->psk, in airoc_mgmt_ap_enable()
680 params->psk_length, channel) != 0) { in airoc_mgmt_ap_enable()
682 ret = -EAGAIN; in airoc_mgmt_ap_enable()
688 ret = -EAGAIN; in airoc_mgmt_ap_enable()
697 ret = -EAGAIN; in airoc_mgmt_ap_enable()
701 data->is_ap_up = true; in airoc_mgmt_ap_enable()
703 net_if_dormant_off(data->iface); in airoc_mgmt_ap_enable()
706 k_sem_give(&data->sema_common); in airoc_mgmt_ap_enable()
713 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_wifi_stats()
715 stats->bytes.received = data->stats.bytes.received; in airoc_mgmt_wifi_stats()
716 stats->bytes.sent = data->stats.bytes.sent; in airoc_mgmt_wifi_stats()
717 stats->pkts.rx = data->stats.pkts.rx; in airoc_mgmt_wifi_stats()
718 stats->pkts.tx = data->stats.pkts.tx; in airoc_mgmt_wifi_stats()
719 stats->errors.rx = data->stats.errors.rx; in airoc_mgmt_wifi_stats()
720 stats->errors.tx = data->stats.errors.tx; in airoc_mgmt_wifi_stats()
721 stats->broadcast.rx = data->stats.broadcast.rx; in airoc_mgmt_wifi_stats()
722 stats->broadcast.tx = data->stats.broadcast.tx; in airoc_mgmt_wifi_stats()
723 stats->multicast.rx = data->stats.multicast.rx; in airoc_mgmt_wifi_stats()
724 stats->multicast.tx = data->stats.multicast.tx; in airoc_mgmt_wifi_stats()
725 stats->sta_mgmt.beacons_rx = data->stats.sta_mgmt.beacons_rx; in airoc_mgmt_wifi_stats()
726 stats->sta_mgmt.beacons_miss = data->stats.sta_mgmt.beacons_miss; in airoc_mgmt_wifi_stats()
735 struct airoc_wifi_data *data = dev->data; in airoc_mgmt_ap_disable()
737 if (k_sem_take(&data->sema_common, K_MSEC(AIROC_WIFI_WAIT_SEMA_MS)) != 0) { in airoc_mgmt_ap_disable()
738 return -EAGAIN; in airoc_mgmt_ap_disable()
747 data->is_ap_up = false; in airoc_mgmt_ap_disable()
749 net_if_dormant_on(data->iface); in airoc_mgmt_ap_disable()
754 k_sem_give(&data->sema_common); in airoc_mgmt_ap_disable()
757 return -ENODEV; in airoc_mgmt_ap_disable()
767 struct airoc_wifi_data *data = dev->data; in airoc_init()
776 return -EAGAIN; in airoc_init()
784 return -EAGAIN; in airoc_init()
792 return -EAGAIN; in airoc_init()
795 ret = k_sem_init(&data->sema_common, 1, 1); in airoc_init()
801 ret = k_sem_init(&data->sema_scan, 0, 1); in airoc_init()