#define RELEASE_VERSION "1.0.3"
#define HOST_GPIO_PIN_INVALID -1
+#define CONFIG_ALLOW_MULTICAST_WAKEUP 1
static int resetpin = HOST_GPIO_PIN_INVALID;
+static int readypin = HOST_GPIO_PIN_INVALID;
+static int handshakepin = HOST_GPIO_PIN_INVALID;
static u32 clockspeed = 0;
extern u8 ap_bssid[MAC_ADDR_LEN];
extern volatile u8 host_sleep;
u32 raw_tp_mode = 0;
+int log_level = ESP_INFO;
module_param(resetpin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(resetpin, "Host's GPIO pin number which is connected to ESP32's EN to reset ESP32 device");
module_param(raw_tp_mode, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(raw_tp_mode, "Mode choosed to test raw throughput");
+module_param(readypin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+MODULE_PARM_DESC(readypin, "Data ready pin default is pin 13, gpio27");
+
+module_param(handshakepin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+MODULE_PARM_DESC(handshakepin, "Handshake pin default is pin 15, gpio22");
+
static void deinit_adapter(void);
ret = esp_send_packet(priv->adapter, skb);
if (ret) {
-/* esp_err("Failed to send SKB");*/
+ esp_verbose("Failed to send SKB");
priv->stats.tx_errors++;
} else {
priv->stats.tx_packets++;
clear_bit(ESP_INIT_DONE, &adapter->state_flags);
/* Deinit module if already initialized */
+ test_raw_tp_cleanup();
esp_deinit_module(adapter);
pos = evt_buf;
static void esp_set_rx_mode(struct net_device *ndev)
{
- struct esp_wifi_device *priv = netdev_priv(ndev);
- struct netdev_hw_addr *mac_addr;
- u32 count = 0;
-#if 0
- struct in_device *in_dev = in_dev_get(ndev);
- struct ip_mc_list *ip_list = in_dev->mc_list;
-#endif
- netdev_for_each_mc_addr(mac_addr, ndev) {
- if (count < MAX_MULTICAST_ADDR_COUNT) {
- /*esp_info("%d: "MACSTR"\n", count+1, MAC2STR(mac_addr->addr));*/
- memcpy(&mcast_list.mcast_addr[count++], mac_addr->addr, ETH_ALEN);
- }
- }
-
- mcast_list.priv = priv;
- mcast_list.addr_count = count;
-
- if (priv->port_open) {
- /*esp_info("Set Multicast list\n");*/
- if (adapter.mac_filter_wq)
- queue_work(adapter.mac_filter_wq, &adapter.mac_flter_work);
- }
-#if 0
- cmd_set_mcast_mac_list(priv, &mcast_list);
- while (ip_list) {
- esp_dbg(" IP MC Address: 0x%x\n", ip_list->multiaddr);
- ip_list = ip_list->next;
- }
-#endif
+ struct esp_adapter *adapter = esp_get_adapter();
+ schedule_work(&adapter->mac_flter_work);
}
static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (!priv->port_open) {
priv->stats.tx_dropped++;
- /*esp_err("Port not yet open\n");*/
+ esp_verbose("Port not yet open\n");
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
}
rtnl_lock();
- wdev = esp_cfg80211_add_iface(adapter->wiphy, "espsta%d", 1, NL80211_IFTYPE_STATION, NULL);
+ wdev = esp_cfg80211_add_iface(adapter->wiphy, "wlan%d", 1, NL80211_IFTYPE_STATION, NULL);
rtnl_unlock();
/* Return success if network added successfully */
RET_ON_FAIL(esp_commands_setup(adapter));
RET_ON_FAIL(esp_add_wiphy(adapter));
RET_ON_FAIL(esp_add_network_ifaces(adapter));
+ clear_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags);
return 0;
}
}
esp_stop_network_ifaces(adapter);
+ esp_cfg_cleanup(adapter);
/* BT may have been initialized after fw bootup event, deinit it */
esp_deinit_bt(adapter);
esp_commands_teardown(adapter);
u16 rx_checksum = 0, checksum = 0;
struct hci_dev *hdev = adapter->hcidev;
u8 *type = NULL;
- struct sk_buff *eap_skb = NULL;
- struct ethhdr *eth = NULL;
if (!skb)
return;
offset = le16_to_cpu(payload_header->offset);
if (payload_header->reserved2 == 0xFF) {
- print_hex_dump(KERN_INFO, "Wake up packet: ", DUMP_PREFIX_ADDRESS, 16, 1, skb->data, len+offset, 1);
+ esp_hex_dump("Wake up packet: ", skb->data, len+offset);
}
if (adapter->capabilities & ESP_CHECKSUM_ENABLED) {
}
if (payload_header->packet_type == PACKET_TYPE_EAPOL) {
- esp_info("Rx PACKET_TYPE_EAPOL!!!!\n");
+ esp_dbg("Rx PACKET_TYPE_EAPOL!!!!\n");
esp_port_open(priv);
-
- eap_skb = alloc_skb(skb->len + ETH_HLEN, GFP_KERNEL);
- if (!eap_skb) {
- esp_info("%u memory alloc failed\n", __LINE__);
- return;
- }
- eap_skb->dev = priv->ndev;
-
- if (!IS_ALIGNED((unsigned long) eap_skb->data, SKB_DATA_ADDR_ALIGNMENT)) {
- esp_info("%u eap skb unaligned\n", __LINE__);
- }
-
- eth = (struct ethhdr *) skb_put(eap_skb, ETH_HLEN);
- ether_addr_copy(eth->h_dest, /*skb->data*/priv->ndev->dev_addr);
- ether_addr_copy(eth->h_source, /*skb->data+6*/ ap_bssid);
- eth->h_proto = cpu_to_be16(ETH_P_PAE);
-
- skb_put_data(eap_skb, skb->data, skb->len);
- eap_skb->protocol = eth_type_trans(eap_skb, eap_skb->dev);
-
- netif_rx(eap_skb);
+ skb->dev = priv->ndev;
+ skb->protocol = eth_type_trans(skb, priv->ndev);
+ netif_rx(skb);
} else if (payload_header->packet_type == PACKET_TYPE_DATA) {
}
}
+char *esp_get_hardware_name(int hardware_id)
+{
+ if(hardware_id == ESP_FIRMWARE_CHIP_ESP32)
+ return "ESP32";
+ else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S2)
+ return "ESP32S2";
+ else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C3)
+ return "ESP32C3";
+ else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S3)
+ return "ESP32S3";
+ else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C2)
+ return "ESP32C2";
+ else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C6)
+ return "ESP32C6";
+ else
+ return "N/A";
+}
+
+bool esp_is_valid_hardware_id(int hardware_id)
+{
+ switch(hardware_id) {
+ case ESP_FIRMWARE_CHIP_ESP32:
+ case ESP_FIRMWARE_CHIP_ESP32S2:
+ case ESP_FIRMWARE_CHIP_ESP32C3:
+ case ESP_FIRMWARE_CHIP_ESP32S3:
+ case ESP_FIRMWARE_CHIP_ESP32C2:
+ case ESP_FIRMWARE_CHIP_ESP32C6:
+ return true;
+ default:
+ return false;
+ }
+}
+
int esp_is_tx_queue_paused(struct esp_wifi_device *priv)
{
if (!priv || !priv->ndev)
static void update_mac_filter(struct work_struct *work)
{
+ struct esp_adapter *adapter = esp_get_adapter();
+ struct esp_wifi_device *priv = adapter->priv[0];
+ struct net_device *ndev;
+ struct netdev_hw_addr *mac_addr;
+ u32 count = 0;
+
+ if (!priv)
+ return;
+
+ ndev = priv->ndev;
+ if (!ndev)
+ return;
+
+ if (!priv->port_open) {
+ esp_verbose("Port is not open yet, skipping mac filter update\n");
+ return;
+ }
+
+#if CONFIG_ALLOW_MULTICAST_WAKEUP
+ netdev_for_each_mc_addr(mac_addr, ndev) {
+ if (count < MAX_MULTICAST_ADDR_COUNT) {
+ esp_verbose("%d: "MACSTR"\n", count+1, MAC2STR(mac_addr->addr));
+ memcpy(&mcast_list.mcast_addr[count++], mac_addr->addr, ETH_ALEN);
+ }
+ }
+
+ mcast_list.priv = priv;
+ mcast_list.addr_count = count;
+
+ esp_verbose("Setting Multicast list\n");
cmd_set_mcast_mac_list(mcast_list.priv, &mcast_list);
+#else
+ esp_info("Not setting FW multicast addresses\n");
+#endif
}
static void esp_events_work(struct work_struct *work)
INIT_WORK(&adapter.events_work, esp_events_work);
- adapter.mac_filter_wq = alloc_workqueue("MAC_FILTER", 0, 0);
- if (!adapter.mac_filter_wq) {
- deinit_adapter();
- return NULL;
- }
-
INIT_WORK(&adapter.mac_flter_work, update_mac_filter);
return &adapter;
if (adapter.if_rx_workqueue)
destroy_workqueue(adapter.if_rx_workqueue);
-
- if (adapter.mac_filter_wq)
- destroy_workqueue(adapter.mac_filter_wq);
}
static void esp_reset(void)
}
}
+void dt_get_reset_pin(void)
+{
+ struct device_node *resetpin_node = NULL;
+ int temp_resetpin = HOST_GPIO_PIN_INVALID;
+
+
+ resetpin_node = of_find_compatible_node(NULL, NULL, "espressif,esp_sdio");
+ if (!resetpin_node)
+ resetpin_node = of_find_compatible_node(NULL, NULL, "espressif,esp_spi");
+ if (resetpin_node){
+ of_property_read_u32(resetpin_node, "resetpin", &temp_resetpin);
+ if (temp_resetpin == HOST_GPIO_PIN_INVALID)
+ esp_warn("Unable to find resetpin in device tree.\n");
+ else
+ resetpin = temp_resetpin;
+ }
+}
static int __init esp_init(void)
{
int ret = 0;
struct esp_adapter *adapter = NULL;
+ struct esp_if_params if_params;
+
+ dt_get_reset_pin();
/* Reset ESP, Clean start ESP */
esp_reset();
if (!adapter)
return -EFAULT;
+ if_params.speed = clockspeed;
+ if_params.handshake_pin = handshakepin;
+ if_params.data_ready_pin = readypin;
/* Init transport layer */
- ret = esp_init_interface_layer(adapter, clockspeed);
+ ret = esp_init_interface_layer(adapter, &if_params);
if (ret != 0) {
deinit_adapter();
}
+ ret = debugfs_init();
return ret;
}
if (resetpin != HOST_GPIO_PIN_INVALID) {
gpio_free(resetpin);
}
+ debugfs_exit();
}
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Wifi driver for ESP-Hosted solution");
MODULE_VERSION(RELEASE_VERSION);
module_init(esp_init);