2 ******************************************************************************
6 * @brief Entry point of the ECRNX driver
8 * Copyright (C) ESWIN 2015-2020
10 ******************************************************************************
13 #include "ecrnx_main.h"
14 #include "eswin_utils.h"
15 #include "ecrnx_calibration_data.h"
17 #ifdef CONFIG_ECRNX_WIFO_CAIL
18 #define AMT_GAIN_DELTA_MSG_FLAG ("gaindelta=")
19 #define AMT_GAIN_DELTA_MSG_BUFF_LEN 60 //strlen(AMT_GAIN_DELTA_MSG_FLAG) + sizeof(gain_delta)
20 static char gain_delta_msg_buf[AMT_GAIN_DELTA_MSG_BUFF_LEN];
23 struct ecrnx_iwpriv_amt_vif amt_vif;
24 #if defined(CONFIG_WIRELESS_EXT) && defined(CONFIG_WEXT_PRIV)
25 extern const struct iw_handler_def ecrnx_wext_private_handler;
28 static int eswin_netdev_amt_open(struct net_device *ndev)
30 ECRNX_DBG("amt netdev open\n");
35 static int eswin_netdev_amt_stop(struct net_device *ndev)
37 ECRNX_DBG("amt netdev stop\n");
42 static netdev_tx_t eswin_netdev_amt_start_xmit(struct sk_buff *skb,
43 struct net_device *ndev)
46 dev_kfree_skb_any(skb);
51 static const struct net_device_ops eswin_netdev_ops_amt = {
52 .ndo_open = eswin_netdev_amt_open,
53 .ndo_stop = eswin_netdev_amt_stop,
54 .ndo_start_xmit = eswin_netdev_amt_start_xmit
57 static int ecrnx_amt_gain_delta_msg_send(void)
62 memcpy(gain_delta_msg_buf, AMT_GAIN_DELTA_MSG_FLAG, strlen(AMT_GAIN_DELTA_MSG_FLAG));
63 memcpy((gain_delta_msg_buf + strlen(AMT_GAIN_DELTA_MSG_FLAG)), gain_delta, GAIN_DELTA_CFG_BUF_SIZE);
65 host_send(gain_delta_msg_buf, sizeof(gain_delta_msg_buf), TX_FLAG_AMT_IWPRIV_IE);
70 int ecrnx_amt_init(void)
72 struct net_device *ndev;
73 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0))
74 ndev = alloc_netdev(0, "amt0", ether_setup);
76 ndev = alloc_netdev(0, "amt0", NET_NAME_UNKNOWN, ether_setup);
79 ECRNX_DBG("alloc netdev fail !!");
85 init_waitqueue_head(&amt_vif.rxdataq);
87 ndev->netdev_ops = &eswin_netdev_ops_amt;
88 #if defined(CONFIG_WIRELESS_EXT) && defined(CONFIG_WEXT_PRIV)
89 ndev->wireless_handlers = &ecrnx_wext_private_handler;
91 /* clear the mac address */
92 memset(ndev->dev_addr, 0, ETH_ALEN);
94 if (register_netdev(ndev) != 0)
97 ecrnx_amt_gain_delta_msg_send();
99 ECRNX_PRINT(" %s:register the amt net device success\n", __func__);
103 ECRNX_ERR(" %s couldn't register the amt net device!!", __func__);
109 void ecrnx_amt_deinit(void)
111 ECRNX_DBG(ECRNX_FN_ENTRY_STR);
114 unregister_netdev(amt_vif.ndev);